@lindle/linoardo 1.0.48 → 1.0.50
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/chunk-3J6Y3EQW.js +538 -0
- package/dist/chunk-3J6Y3EQW.js.map +1 -0
- package/dist/{chunk-LRWM4ZWZ.js → chunk-DEJ7ZDGL.js} +3 -3
- package/dist/chunk-DEJ7ZDGL.js.map +1 -0
- package/dist/{chunk-TRR7TDVA.js → chunk-HE44Z7XP.js} +12 -3
- package/dist/chunk-HE44Z7XP.js.map +1 -0
- package/dist/{chunk-Z5A2OIDI.js → chunk-SM2VNSPP.js} +4 -7
- package/dist/chunk-SM2VNSPP.js.map +1 -0
- package/dist/{chunk-LSIAP7ZZ.js → chunk-XLA2NCDF.js} +3 -9
- package/dist/chunk-XLA2NCDF.js.map +1 -0
- package/dist/expansion-panel.cjs +1 -7
- package/dist/expansion-panel.cjs.map +1 -1
- package/dist/expansion-panel.js +1 -1
- package/dist/index.cjs +581 -520
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/profileCard.cjs +1 -1
- package/dist/profileCard.cjs.map +1 -1
- package/dist/profileCard.js +1 -1
- package/dist/progress.cjs +2 -5
- package/dist/progress.cjs.map +1 -1
- package/dist/progress.js +1 -1
- package/dist/select.js +1 -2
- package/dist/styles.css +254 -187
- package/dist/textarea.cjs +484 -423
- package/dist/textarea.cjs.map +1 -1
- package/dist/textarea.d.cts +27 -23
- package/dist/textarea.d.ts +27 -23
- package/dist/textarea.js +1 -2
- package/package.json +7 -1
- package/dist/chunk-67TAA2MA.js +0 -470
- package/dist/chunk-67TAA2MA.js.map +0 -1
- package/dist/chunk-6SKW43XI.js +0 -14
- package/dist/chunk-6SKW43XI.js.map +0 -1
- package/dist/chunk-LRWM4ZWZ.js.map +0 -1
- package/dist/chunk-LSIAP7ZZ.js.map +0 -1
- package/dist/chunk-TRR7TDVA.js.map +0 -1
- package/dist/chunk-Z5A2OIDI.js.map +0 -1
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';
|
|
3
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
4
|
+
import Underline from '@tiptap/extension-underline';
|
|
5
|
+
import { useEditor, EditorContent } from '@tiptap/react';
|
|
6
|
+
import { createLowlight, common } from 'lowlight';
|
|
7
|
+
import TurndownService from 'turndown';
|
|
8
|
+
import { marked } from 'marked';
|
|
9
|
+
import { twMerge } from 'tailwind-merge';
|
|
10
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
// src/Form/TextArea/index.tsx
|
|
13
|
+
var variantClasses = {
|
|
14
|
+
solid: "rounded border border-gray-400 bg-white shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-within:border-primary/70 dark:focus-within:ring-primary/40",
|
|
15
|
+
sharp: "rounded-none border border-gray-400 bg-white shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-within:border-primary/70 dark:focus-within:ring-primary/40",
|
|
16
|
+
outline: "rounded border-2 border-black bg-white focus-within:border-black focus-within:ring-2 focus-within:ring-black/30 dark:border-black dark:bg-transparent dark:focus-within:border-black dark:focus-within:ring-black/40",
|
|
17
|
+
text: "rounded-none border-0 border-b border-transparent px-0 bg-transparent focus-within:border-primary focus-within:ring-0 focus-within:ring-transparent dark:border-b-gray-600 dark:focus-within:border-primary/70",
|
|
18
|
+
ghost: "rounded border border-transparent bg-gray-50 text-gray-900 focus-within:bg-white focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/15 dark:bg-slate-800 dark:text-gray-100 dark:focus-within:bg-slate-700 dark:focus-within:border-primary/60 dark:focus-within:ring-primary/25",
|
|
19
|
+
filled: "rounded border border-gray-200 bg-gray-100 focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/25 dark:border-gray-700 dark:bg-slate-800 dark:focus-within:border-primary/60 dark:focus-within:ring-primary/30",
|
|
20
|
+
underlined: "rounded-none border-0 border-b border-gray-300 px-0 bg-transparent focus-within:border-primary focus-within:ring-0 focus-within:ring-transparent dark:border-b-gray-600 dark:focus-within:border-primary/70"
|
|
21
|
+
};
|
|
22
|
+
var roundedClasses = {
|
|
23
|
+
sm: "rounded-sm",
|
|
24
|
+
md: "rounded-md",
|
|
25
|
+
lg: "rounded-lg",
|
|
26
|
+
xl: "rounded-xl",
|
|
27
|
+
"2xl": "rounded-2xl",
|
|
28
|
+
"3xl": "rounded-3xl"
|
|
29
|
+
};
|
|
30
|
+
var sizeClasses = {
|
|
31
|
+
"x-small": {
|
|
32
|
+
paddingY: "py-2",
|
|
33
|
+
paddingX: "px-2",
|
|
34
|
+
text: "text-xs"
|
|
35
|
+
},
|
|
36
|
+
small: {
|
|
37
|
+
paddingY: "py-2.5",
|
|
38
|
+
paddingX: "px-2.5",
|
|
39
|
+
text: "text-sm"
|
|
40
|
+
},
|
|
41
|
+
medium: {
|
|
42
|
+
paddingY: "py-3",
|
|
43
|
+
paddingX: "px-3",
|
|
44
|
+
text: "text-base"
|
|
45
|
+
},
|
|
46
|
+
large: {
|
|
47
|
+
paddingY: "py-3.5",
|
|
48
|
+
paddingX: "px-3.5",
|
|
49
|
+
text: "text-lg"
|
|
50
|
+
},
|
|
51
|
+
"x-large": {
|
|
52
|
+
paddingY: "py-4",
|
|
53
|
+
paddingX: "px-4",
|
|
54
|
+
text: "text-xl"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var statusClasses = {
|
|
58
|
+
error: "border-red-500 focus:border-red-500 focus:ring-red-400",
|
|
59
|
+
warn: "border-amber-500 focus:border-amber-500 focus:ring-amber-400",
|
|
60
|
+
success: "border-emerald-500 focus:border-emerald-500 focus:ring-emerald-400"
|
|
61
|
+
};
|
|
62
|
+
var statusMessageClasses = {
|
|
63
|
+
error: "text-red-600 dark:text-red-300",
|
|
64
|
+
warn: "text-amber-600 dark:text-amber-300",
|
|
65
|
+
success: "text-emerald-600 dark:text-emerald-300"
|
|
66
|
+
};
|
|
67
|
+
var DEFAULT_TOOLBAR = ["bold", "italic", "underline", "strike", "heading", "bulletList", "orderedList", "blockquote", "codeBlock"];
|
|
68
|
+
var CODE_BLOCK_LANGUAGES = ["ts", "json", "python", "bash"];
|
|
69
|
+
var DEFAULT_CODE_BLOCK_LANGUAGE = CODE_BLOCK_LANGUAGES[0];
|
|
70
|
+
var TEXTAREA_TAB_CHARACTER = " ";
|
|
71
|
+
var lowlight = createLowlight(common);
|
|
72
|
+
lowlight.registerAlias({ ts: "typescript" });
|
|
73
|
+
var turndown = new TurndownService({
|
|
74
|
+
codeBlockStyle: "fenced",
|
|
75
|
+
headingStyle: "atx",
|
|
76
|
+
bulletListMarker: "-"
|
|
77
|
+
});
|
|
78
|
+
var markdownToHtml = (markdown) => {
|
|
79
|
+
if (!markdown) {
|
|
80
|
+
return "<p></p>";
|
|
81
|
+
}
|
|
82
|
+
return marked.parse(markdown);
|
|
83
|
+
};
|
|
84
|
+
var htmlToMarkdown = (html) => turndown.turndown(html).trim();
|
|
85
|
+
var createChangeEvent = (element) => ({
|
|
86
|
+
target: element,
|
|
87
|
+
currentTarget: element
|
|
88
|
+
});
|
|
89
|
+
var assignRef = (ref, value) => {
|
|
90
|
+
if (typeof ref === "function") {
|
|
91
|
+
ref(value);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (ref) {
|
|
95
|
+
ref.current = value;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var updateTextareaValue = (element, nextValue, selectionStart, selectionEnd) => {
|
|
99
|
+
element.value = nextValue;
|
|
100
|
+
element.setSelectionRange(selectionStart, selectionEnd);
|
|
101
|
+
};
|
|
102
|
+
var indentSelectedLines = (value, selectionStart, selectionEnd) => {
|
|
103
|
+
const lineStart = value.lastIndexOf("\n", Math.max(0, selectionStart - 1)) + 1;
|
|
104
|
+
const lineEndIndex = value.indexOf("\n", selectionEnd);
|
|
105
|
+
const lineEnd = lineEndIndex === -1 ? value.length : lineEndIndex;
|
|
106
|
+
const selectedBlock = value.slice(lineStart, lineEnd);
|
|
107
|
+
const lines = selectedBlock.split("\n");
|
|
108
|
+
const indentedBlock = lines.map((line) => `${TEXTAREA_TAB_CHARACTER}${line}`).join("\n");
|
|
109
|
+
return {
|
|
110
|
+
nextValue: `${value.slice(0, lineStart)}${indentedBlock}${value.slice(lineEnd)}`,
|
|
111
|
+
selectionStart: selectionStart + TEXTAREA_TAB_CHARACTER.length,
|
|
112
|
+
selectionEnd: selectionEnd + lines.length * TEXTAREA_TAB_CHARACTER.length
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
var outdentSelectedLines = (value, selectionStart, selectionEnd) => {
|
|
116
|
+
const lineStart = value.lastIndexOf("\n", Math.max(0, selectionStart - 1)) + 1;
|
|
117
|
+
const lineEndIndex = value.indexOf("\n", selectionEnd);
|
|
118
|
+
const lineEnd = lineEndIndex === -1 ? value.length : lineEndIndex;
|
|
119
|
+
const selectedBlock = value.slice(lineStart, lineEnd);
|
|
120
|
+
const lines = selectedBlock.split("\n");
|
|
121
|
+
const updatedLines = lines.map((line) => line.startsWith(TEXTAREA_TAB_CHARACTER) ? line.slice(TEXTAREA_TAB_CHARACTER.length) : line);
|
|
122
|
+
const removedBeforeSelectionStart = selectionStart === lineStart && !lines[0].startsWith(TEXTAREA_TAB_CHARACTER) ? 0 : lines[0].startsWith(TEXTAREA_TAB_CHARACTER) ? TEXTAREA_TAB_CHARACTER.length : 0;
|
|
123
|
+
const removedTotal = lines.reduce((count, line) => count + (line.startsWith(TEXTAREA_TAB_CHARACTER) ? TEXTAREA_TAB_CHARACTER.length : 0), 0);
|
|
124
|
+
return {
|
|
125
|
+
nextValue: `${value.slice(0, lineStart)}${updatedLines.join("\n")}${value.slice(lineEnd)}`,
|
|
126
|
+
selectionStart: Math.max(lineStart, selectionStart - removedBeforeSelectionStart),
|
|
127
|
+
selectionEnd: Math.max(lineStart, selectionEnd - removedTotal)
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
var isCodeBlockLanguage = (value) => CODE_BLOCK_LANGUAGES.includes(value);
|
|
131
|
+
var ToolbarButton = ({ label, active, disabled, onMouseDown }) => /* @__PURE__ */ jsx(
|
|
132
|
+
"button",
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
disabled,
|
|
136
|
+
onMouseDown,
|
|
137
|
+
className: twMerge(
|
|
138
|
+
"inline-flex min-w-8 items-center justify-center rounded border px-2 py-1 text-xs font-medium transition-colors",
|
|
139
|
+
active ? "border-primary bg-primary text-white" : "border-gray-300 bg-white text-gray-700 hover:border-gray-400 hover:bg-gray-50 dark:border-slate-600 dark:bg-slate-900 dark:text-gray-200 dark:hover:bg-slate-800",
|
|
140
|
+
disabled && "cursor-not-allowed opacity-50"
|
|
141
|
+
),
|
|
142
|
+
children: label
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
var TextArea = React.forwardRef(
|
|
146
|
+
({ variant = "outline", size = "medium", rounded = "md", success, error, warn, className, wrapperClassName, label, prepend, append, rows = 4, richText = false, toolbar = DEFAULT_TOOLBAR, ...props }, ref) => {
|
|
147
|
+
const { placeholder, onFocus, onBlur, onChange, onKeyDown, value, defaultValue, disabled, readOnly, ...textareaProps } = props;
|
|
148
|
+
const reactId = React.useId();
|
|
149
|
+
const hasLabel = Boolean(label);
|
|
150
|
+
const hasProvidedPlaceholder = typeof placeholder === "string" && placeholder.trim().length > 0;
|
|
151
|
+
const hidePlaceholderUntilFocus = hasLabel && hasProvidedPlaceholder;
|
|
152
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
153
|
+
const classBase = "textarea-base transition-colors duration-200 w-full has-[textarea:disabled]:opacity-50 has-[textarea:disabled]:cursor-not-allowed";
|
|
154
|
+
const textareaBase = "peer block w-full min-w-0 resize-y border-0 bg-transparent p-0 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:outline-none focus:ring-0";
|
|
155
|
+
const proseBase = "ProseMirror min-h-[7rem] w-full border-0 bg-transparent p-0 text-gray-900 dark:text-gray-100 focus:outline-none [&_blockquote]:border-l-4 [&_blockquote]:border-gray-300 [&_blockquote]:pl-3 [&_blockquote]:italic dark:[&_blockquote]:border-slate-600 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-black [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-white dark:[&_:not(pre)>code]:bg-black dark:[&_:not(pre)>code]:text-white [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-black [&_pre]:p-3 [&_pre]:text-white [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-white [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_h1]:text-2xl [&_h1]:font-semibold [&_h2]:text-xl [&_h2]:font-semibold";
|
|
156
|
+
const hiddenTextareaRef = React.useRef(null);
|
|
157
|
+
const forwardedRef = React.useRef(null);
|
|
158
|
+
const isControlled = value !== void 0;
|
|
159
|
+
const markdownValue = typeof value === "string" ? value : typeof defaultValue === "string" ? defaultValue : "";
|
|
160
|
+
const [internalMarkdown, setInternalMarkdown] = React.useState(markdownValue);
|
|
161
|
+
const resolvedMarkdownValue = isControlled ? typeof value === "string" ? value : "" : internalMarkdown;
|
|
162
|
+
const status = error ? { tone: "error", message: error } : warn ? { tone: "warn", message: warn } : success ? { tone: "success", message: success } : void 0;
|
|
163
|
+
const variantClass = variantClasses[variant] ?? variantClasses.outline;
|
|
164
|
+
const toneClass = status ? statusClasses[status.tone] : void 0;
|
|
165
|
+
const hasPrepend = typeof prepend === "string" ? prepend.trim().length > 0 : Boolean(prepend);
|
|
166
|
+
const hasAppend = typeof append === "string" ? append.trim().length > 0 : Boolean(append);
|
|
167
|
+
const sizeConfig = sizeClasses[size] ?? sizeClasses.medium;
|
|
168
|
+
const sizeClass = [sizeConfig.paddingY, sizeConfig.paddingX, sizeConfig.text].join(" ");
|
|
169
|
+
const roundedClass = variant === "sharp" || variant === "text" || variant === "underlined" ? "rounded-none" : roundedClasses[rounded];
|
|
170
|
+
const inputName = textareaProps.name || reactId;
|
|
171
|
+
const basePlaceholder = placeholder ?? (hasLabel ? " " : void 0);
|
|
172
|
+
const placeholderValue = hidePlaceholderUntilFocus ? isFocused ? placeholder : " " : basePlaceholder;
|
|
173
|
+
const placeholderClass = hidePlaceholderUntilFocus ? "placeholder-transparent focus:placeholder-gray-500 focus:dark:placeholder-gray-400" : void 0;
|
|
174
|
+
const editor = useEditor({
|
|
175
|
+
extensions: [
|
|
176
|
+
StarterKit.configure({ heading: { levels: [1, 2] }, codeBlock: false }),
|
|
177
|
+
CodeBlockLowlight.configure({
|
|
178
|
+
defaultLanguage: DEFAULT_CODE_BLOCK_LANGUAGE,
|
|
179
|
+
enableTabIndentation: true,
|
|
180
|
+
lowlight,
|
|
181
|
+
HTMLAttributes: {
|
|
182
|
+
class: "hljs"
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
Underline
|
|
186
|
+
],
|
|
187
|
+
content: markdownToHtml(resolvedMarkdownValue),
|
|
188
|
+
editable: richText && !disabled && !readOnly,
|
|
189
|
+
immediatelyRender: false,
|
|
190
|
+
editorProps: {
|
|
191
|
+
attributes: {
|
|
192
|
+
class: twMerge(proseBase, placeholderClass),
|
|
193
|
+
"data-placeholder": placeholderValue ?? ""
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
onFocus: () => {
|
|
197
|
+
if (!richText) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (hidePlaceholderUntilFocus) {
|
|
201
|
+
setIsFocused(true);
|
|
202
|
+
}
|
|
203
|
+
const target = hiddenTextareaRef.current;
|
|
204
|
+
if (target) {
|
|
205
|
+
onFocus?.(createChangeEvent(target));
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
onBlur: () => {
|
|
209
|
+
if (!richText) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (hidePlaceholderUntilFocus) {
|
|
213
|
+
setIsFocused(false);
|
|
214
|
+
}
|
|
215
|
+
const target = hiddenTextareaRef.current;
|
|
216
|
+
if (target) {
|
|
217
|
+
onBlur?.(createChangeEvent(target));
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
onUpdate: ({ editor: currentEditor }) => {
|
|
221
|
+
if (!richText) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const nextMarkdown = htmlToMarkdown(currentEditor.getHTML());
|
|
225
|
+
const target = hiddenTextareaRef.current;
|
|
226
|
+
setInternalMarkdown(nextMarkdown);
|
|
227
|
+
if (!target) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
target.value = nextMarkdown;
|
|
231
|
+
onChange?.(createChangeEvent(target));
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
const activeCodeBlockLanguage = (() => {
|
|
235
|
+
const language = editor?.getAttributes("codeBlock").language;
|
|
236
|
+
if (typeof language === "string" && isCodeBlockLanguage(language)) {
|
|
237
|
+
return language;
|
|
238
|
+
}
|
|
239
|
+
return DEFAULT_CODE_BLOCK_LANGUAGE;
|
|
240
|
+
})();
|
|
241
|
+
React.useEffect(() => {
|
|
242
|
+
if (!richText) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const target = hiddenTextareaRef.current;
|
|
246
|
+
if (!target) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
target.value = resolvedMarkdownValue;
|
|
250
|
+
forwardedRef.current = target;
|
|
251
|
+
assignRef(ref, target);
|
|
252
|
+
}, [ref, resolvedMarkdownValue, richText]);
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
if (!editor || !richText || !isControlled) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const nextMarkdown = typeof value === "string" ? value : "";
|
|
258
|
+
const currentMarkdown = htmlToMarkdown(editor.getHTML());
|
|
259
|
+
if (currentMarkdown === nextMarkdown) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
editor.commands.setContent(markdownToHtml(nextMarkdown), { emitUpdate: false });
|
|
263
|
+
}, [editor, isControlled, richText, value]);
|
|
264
|
+
React.useEffect(() => {
|
|
265
|
+
if (!isControlled) {
|
|
266
|
+
setInternalMarkdown(typeof defaultValue === "string" ? defaultValue : "");
|
|
267
|
+
}
|
|
268
|
+
}, [defaultValue, isControlled]);
|
|
269
|
+
React.useEffect(() => {
|
|
270
|
+
if (!editor || !richText) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
editor.setEditable(!disabled && !readOnly);
|
|
274
|
+
}, [disabled, editor, readOnly, richText]);
|
|
275
|
+
const renderPrepend = hasPrepend ? typeof prepend === "string" ? /* @__PURE__ */ jsx("span", { className: twMerge("text-gray-500 dark:text-gray-400", sizeConfig.text), children: prepend }) : prepend : null;
|
|
276
|
+
const renderAppend = hasAppend ? typeof append === "string" ? /* @__PURE__ */ jsx("span", { className: twMerge("text-gray-500 dark:text-gray-400", sizeConfig.text), children: append }) : append : null;
|
|
277
|
+
const handleFocus = (event) => {
|
|
278
|
+
if (hidePlaceholderUntilFocus) setIsFocused(true);
|
|
279
|
+
onFocus?.(event);
|
|
280
|
+
};
|
|
281
|
+
const handleBlur = (event) => {
|
|
282
|
+
if (hidePlaceholderUntilFocus) setIsFocused(false);
|
|
283
|
+
onBlur?.(event);
|
|
284
|
+
};
|
|
285
|
+
const handleKeyDown = (event) => {
|
|
286
|
+
onKeyDown?.(event);
|
|
287
|
+
if (event.defaultPrevented || event.key !== "Tab" || disabled || readOnly) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const target = event.currentTarget;
|
|
291
|
+
const { selectionStart, selectionEnd, value: currentValue } = target;
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
if (selectionStart !== selectionEnd && currentValue.slice(selectionStart, selectionEnd).includes("\n")) {
|
|
294
|
+
const nextState = event.shiftKey ? outdentSelectedLines(currentValue, selectionStart, selectionEnd) : indentSelectedLines(currentValue, selectionStart, selectionEnd);
|
|
295
|
+
updateTextareaValue(target, nextState.nextValue, nextState.selectionStart, nextState.selectionEnd);
|
|
296
|
+
onChange?.(createChangeEvent(target));
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (event.shiftKey) {
|
|
300
|
+
const lineStart = currentValue.lastIndexOf("\n", Math.max(0, selectionStart - 1)) + 1;
|
|
301
|
+
if (currentValue.slice(lineStart, selectionStart).endsWith(TEXTAREA_TAB_CHARACTER)) {
|
|
302
|
+
const nextValue2 = `${currentValue.slice(0, selectionStart - TEXTAREA_TAB_CHARACTER.length)}${currentValue.slice(selectionEnd)}`;
|
|
303
|
+
const nextPosition2 = selectionStart - TEXTAREA_TAB_CHARACTER.length;
|
|
304
|
+
updateTextareaValue(target, nextValue2, nextPosition2, nextPosition2);
|
|
305
|
+
onChange?.(createChangeEvent(target));
|
|
306
|
+
}
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const nextValue = `${currentValue.slice(0, selectionStart)}${TEXTAREA_TAB_CHARACTER}${currentValue.slice(selectionEnd)}`;
|
|
310
|
+
const nextPosition = selectionStart + TEXTAREA_TAB_CHARACTER.length;
|
|
311
|
+
updateTextareaValue(target, nextValue, nextPosition, nextPosition);
|
|
312
|
+
onChange?.(createChangeEvent(target));
|
|
313
|
+
};
|
|
314
|
+
return /* @__PURE__ */ jsxs("div", { className: twMerge("flex flex-col gap-1", wrapperClassName), children: [
|
|
315
|
+
/* @__PURE__ */ jsxs("div", { className: twMerge("flex w-full items-start gap-2", classBase, variantClass, roundedClass, toneClass, sizeClass, className), children: [
|
|
316
|
+
hasPrepend && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-start pt-0.5", children: renderPrepend }),
|
|
317
|
+
/* @__PURE__ */ jsxs("div", { className: "relative min-w-0 flex-1", children: [
|
|
318
|
+
richText ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
319
|
+
/* @__PURE__ */ jsx(
|
|
320
|
+
"textarea",
|
|
321
|
+
{
|
|
322
|
+
...textareaProps,
|
|
323
|
+
ref: (node) => {
|
|
324
|
+
hiddenTextareaRef.current = node;
|
|
325
|
+
forwardedRef.current = node;
|
|
326
|
+
if (node) {
|
|
327
|
+
assignRef(ref, node);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
id: inputName,
|
|
331
|
+
name: inputName,
|
|
332
|
+
rows,
|
|
333
|
+
value: isControlled ? value : void 0,
|
|
334
|
+
defaultValue: !isControlled ? defaultValue : void 0,
|
|
335
|
+
disabled,
|
|
336
|
+
readOnly: true,
|
|
337
|
+
tabIndex: -1,
|
|
338
|
+
"aria-hidden": true,
|
|
339
|
+
className: "sr-only"
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1 border-b border-gray-200 pb-2 dark:border-slate-700", children: [
|
|
343
|
+
toolbar.includes("bold") && /* @__PURE__ */ jsx(
|
|
344
|
+
ToolbarButton,
|
|
345
|
+
{
|
|
346
|
+
label: "B",
|
|
347
|
+
disabled: !editor?.isEditable,
|
|
348
|
+
active: editor?.isActive("bold"),
|
|
349
|
+
onMouseDown: (event) => {
|
|
350
|
+
event.preventDefault();
|
|
351
|
+
editor?.chain().focus().toggleBold().run();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
toolbar.includes("italic") && /* @__PURE__ */ jsx(
|
|
356
|
+
ToolbarButton,
|
|
357
|
+
{
|
|
358
|
+
label: "I",
|
|
359
|
+
disabled: !editor?.isEditable,
|
|
360
|
+
active: editor?.isActive("italic"),
|
|
361
|
+
onMouseDown: (event) => {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
editor?.chain().focus().toggleItalic().run();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
toolbar.includes("underline") && /* @__PURE__ */ jsx(
|
|
368
|
+
ToolbarButton,
|
|
369
|
+
{
|
|
370
|
+
label: "U",
|
|
371
|
+
disabled: !editor?.isEditable,
|
|
372
|
+
active: editor?.isActive("underline"),
|
|
373
|
+
onMouseDown: (event) => {
|
|
374
|
+
event.preventDefault();
|
|
375
|
+
editor?.chain().focus().toggleUnderline().run();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
toolbar.includes("strike") && /* @__PURE__ */ jsx(
|
|
380
|
+
ToolbarButton,
|
|
381
|
+
{
|
|
382
|
+
label: "S",
|
|
383
|
+
disabled: !editor?.isEditable,
|
|
384
|
+
active: editor?.isActive("strike"),
|
|
385
|
+
onMouseDown: (event) => {
|
|
386
|
+
event.preventDefault();
|
|
387
|
+
editor?.chain().focus().toggleStrike().run();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
toolbar.includes("heading") && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
392
|
+
/* @__PURE__ */ jsx(
|
|
393
|
+
ToolbarButton,
|
|
394
|
+
{
|
|
395
|
+
label: "H1",
|
|
396
|
+
disabled: !editor?.isEditable,
|
|
397
|
+
active: editor?.isActive("heading", { level: 1 }),
|
|
398
|
+
onMouseDown: (event) => {
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
editor?.chain().focus().toggleHeading({ level: 1 }).run();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
/* @__PURE__ */ jsx(
|
|
405
|
+
ToolbarButton,
|
|
406
|
+
{
|
|
407
|
+
label: "H2",
|
|
408
|
+
disabled: !editor?.isEditable,
|
|
409
|
+
active: editor?.isActive("heading", { level: 2 }),
|
|
410
|
+
onMouseDown: (event) => {
|
|
411
|
+
event.preventDefault();
|
|
412
|
+
editor?.chain().focus().toggleHeading({ level: 2 }).run();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
] }),
|
|
417
|
+
toolbar.includes("bulletList") && /* @__PURE__ */ jsx(
|
|
418
|
+
ToolbarButton,
|
|
419
|
+
{
|
|
420
|
+
label: "List",
|
|
421
|
+
disabled: !editor?.isEditable,
|
|
422
|
+
active: editor?.isActive("bulletList"),
|
|
423
|
+
onMouseDown: (event) => {
|
|
424
|
+
event.preventDefault();
|
|
425
|
+
editor?.chain().focus().toggleBulletList().run();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
toolbar.includes("orderedList") && /* @__PURE__ */ jsx(
|
|
430
|
+
ToolbarButton,
|
|
431
|
+
{
|
|
432
|
+
label: "1.",
|
|
433
|
+
disabled: !editor?.isEditable,
|
|
434
|
+
active: editor?.isActive("orderedList"),
|
|
435
|
+
onMouseDown: (event) => {
|
|
436
|
+
event.preventDefault();
|
|
437
|
+
editor?.chain().focus().toggleOrderedList().run();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
),
|
|
441
|
+
toolbar.includes("blockquote") && /* @__PURE__ */ jsx(
|
|
442
|
+
ToolbarButton,
|
|
443
|
+
{
|
|
444
|
+
label: "Quote",
|
|
445
|
+
disabled: !editor?.isEditable,
|
|
446
|
+
active: editor?.isActive("blockquote"),
|
|
447
|
+
onMouseDown: (event) => {
|
|
448
|
+
event.preventDefault();
|
|
449
|
+
editor?.chain().focus().toggleBlockquote().run();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
toolbar.includes("codeBlock") && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
454
|
+
/* @__PURE__ */ jsx(
|
|
455
|
+
ToolbarButton,
|
|
456
|
+
{
|
|
457
|
+
label: "Code",
|
|
458
|
+
disabled: !editor?.isEditable,
|
|
459
|
+
active: editor?.isActive("codeBlock"),
|
|
460
|
+
onMouseDown: (event) => {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
editor?.chain().focus().toggleCodeBlock({ language: activeCodeBlockLanguage }).run();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
/* @__PURE__ */ jsx("label", { className: "sr-only", htmlFor: `${inputName}-code-language`, children: "Code language" }),
|
|
467
|
+
/* @__PURE__ */ jsx(
|
|
468
|
+
"select",
|
|
469
|
+
{
|
|
470
|
+
id: `${inputName}-code-language`,
|
|
471
|
+
value: activeCodeBlockLanguage,
|
|
472
|
+
disabled: !editor?.isEditable,
|
|
473
|
+
className: "min-w-24 rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-700 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-600 dark:bg-slate-900 dark:text-gray-200",
|
|
474
|
+
onChange: (event) => {
|
|
475
|
+
const language = event.target.value;
|
|
476
|
+
if (!isCodeBlockLanguage(language)) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
editor?.chain().focus().setCodeBlock({ language }).run();
|
|
480
|
+
},
|
|
481
|
+
children: CODE_BLOCK_LANGUAGES.map((language) => /* @__PURE__ */ jsx("option", { value: language, children: language }, language))
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
] })
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ jsx(EditorContent, { editor, className: "pt-3" })
|
|
487
|
+
] }) : /* @__PURE__ */ jsx(
|
|
488
|
+
"textarea",
|
|
489
|
+
{
|
|
490
|
+
...textareaProps,
|
|
491
|
+
ref: (node) => {
|
|
492
|
+
forwardedRef.current = node;
|
|
493
|
+
assignRef(ref, node);
|
|
494
|
+
},
|
|
495
|
+
id: inputName,
|
|
496
|
+
name: inputName,
|
|
497
|
+
rows,
|
|
498
|
+
placeholder: placeholderValue,
|
|
499
|
+
onFocus: handleFocus,
|
|
500
|
+
onBlur: handleBlur,
|
|
501
|
+
onKeyDown: handleKeyDown,
|
|
502
|
+
onChange,
|
|
503
|
+
disabled,
|
|
504
|
+
readOnly,
|
|
505
|
+
value,
|
|
506
|
+
defaultValue,
|
|
507
|
+
className: twMerge(textareaBase, placeholderClass)
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
label && /* @__PURE__ */ jsx(
|
|
511
|
+
"label",
|
|
512
|
+
{
|
|
513
|
+
htmlFor: inputName,
|
|
514
|
+
className: twMerge(
|
|
515
|
+
"absolute left-0 z-10 transition-all duration-150 pointer-events-none text-gray-700 dark:text-gray-200",
|
|
516
|
+
"-top-2 -translate-y-full text-xs bg-white px-1 dark:bg-slate-900",
|
|
517
|
+
!richText && "peer-focus:left-0 peer-focus:-top-5 peer-focus:-translate-y-full peer-focus:text-xs peer-focus:text-gray-600 dark:peer-focus:text-gray-300",
|
|
518
|
+
!richText && "peer-placeholder-shown:top-3 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:text-sm peer-placeholder-shown:bg-transparent peer-placeholder-shown:px-0 peer-placeholder-shown:text-gray-500 dark:peer-placeholder-shown:text-gray-400",
|
|
519
|
+
!richText && "peer-[&:not(:placeholder-shown)]:left-0 peer-[&:not(:placeholder-shown)]:-top-2 peer-[&:not(:placeholder-shown)]:-translate-y-full peer-[&:not(:placeholder-shown)]:text-xs peer-[&:not(:placeholder-shown)]:bg-white peer-[&:not(:placeholder-shown)]:px-1 peer-[&:not(:placeholder-shown)]:text-gray-700 dark:peer-[&:not(:placeholder-shown)]:bg-slate-900 dark:peer-[&:not(:placeholder-shown)]:text-gray-200",
|
|
520
|
+
richText && (isFocused || resolvedMarkdownValue) && "-top-2 -translate-y-full text-xs",
|
|
521
|
+
richText && !(isFocused || resolvedMarkdownValue) && "top-3 translate-y-0 text-sm bg-transparent px-0 text-gray-500 dark:text-gray-400"
|
|
522
|
+
),
|
|
523
|
+
children: label
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
] }),
|
|
527
|
+
hasAppend && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-start pt-0.5", children: renderAppend })
|
|
528
|
+
] }),
|
|
529
|
+
status?.message && /* @__PURE__ */ jsx("span", { className: twMerge("text-sm", statusMessageClasses[status.tone]), children: status.message })
|
|
530
|
+
] });
|
|
531
|
+
}
|
|
532
|
+
);
|
|
533
|
+
TextArea.displayName = "TextArea";
|
|
534
|
+
var TextArea_default = TextArea;
|
|
535
|
+
|
|
536
|
+
export { TextArea_default };
|
|
537
|
+
//# sourceMappingURL=chunk-3J6Y3EQW.js.map
|
|
538
|
+
//# sourceMappingURL=chunk-3J6Y3EQW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Form/TextArea/index.tsx"],"names":["nextValue","nextPosition"],"mappings":";;;;;;;;;;;;AAYA,IAAM,cAAA,GAAiB;AAAA,EACrB,KAAA,EACE,kQAAA;AAAA,EACF,KAAA,EACE,uQAAA;AAAA,EACF,OAAA,EACE,sNAAA;AAAA,EACF,IAAA,EAAM,gNAAA;AAAA,EACN,KAAA,EACE,ySAAA;AAAA,EACF,MAAA,EACE,sOAAA;AAAA,EACF,UAAA,EACE;AACJ,CAAA;AAEA,IAAM,cAAA,GAAiB;AAAA,EACrB,EAAA,EAAI,YAAA;AAAA,EACJ,EAAA,EAAI,YAAA;AAAA,EACJ,EAAA,EAAI,YAAA;AAAA,EACJ,EAAA,EAAI,YAAA;AAAA,EACJ,KAAA,EAAO,aAAA;AAAA,EACP,KAAA,EAAO;AACT,CAAA;AAEA,IAAM,WAAA,GAAc;AAAA,EAClB,SAAA,EAAW;AAAA,IACT,QAAA,EAAU,MAAA;AAAA,IACV,QAAA,EAAU,MAAA;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA,KAAA,EAAO;AAAA,IACL,QAAA,EAAU,QAAA;AAAA,IACV,QAAA,EAAU,QAAA;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA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AA;AAAA,WACnD;AAAA,UAGD,KAAA,oBACC,GAAA;AAAA,YAAC,OAAA;AAAA,YAAA;AAAA,cACC,OAAA,EAAS,SAAA;AAAA,cACT,SAAA,EAAW,OAAA;AAAA,gBACT,uGAAA;AAAA,gBACA,kEAAA;AAAA,gBACA,CAAC,QAAA,IAAY,4IAAA;AAAA,gBACb,CAAC,QAAA,IACC,mPAAA;AAAA,gBACF,CAAC,QAAA,IACC,mZAAA;AAAA,gBACF,QAAA,KAAa,aAAa,qBAAA,CAAA,IAA0B,kCAAA;AAAA,gBACpD,QAAA,IAAY,EAAE,SAAA,IAAa,qBAAA,CAAA,IAA0B;AAAA,eACvD;AAAA,cAEC,QAAA,EAAA;AAAA;AAAA;AACH,SAAA,EAEJ,CAAA;AAAA,QAEC,SAAA,oBAAa,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,oCAAoC,QAAA,EAAA,YAAA,EAAa;AAAA,OAAA,EACjF,CAAA;AAAA,MACC,MAAA,EAAQ,OAAA,oBAAW,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAW,OAAA,CAAQ,SAAA,EAAW,oBAAA,CAAqB,MAAA,CAAO,IAAI,CAAC,CAAA,EAAI,iBAAO,OAAA,EAAQ;AAAA,KAAA,EAC9G,CAAA;AAAA,EAEJ;AACF,CAAA;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA;AAGvB,IAAO,gBAAA,GAAQ","file":"chunk-3J6Y3EQW.js","sourcesContent":["import React from 'react';\nimport CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';\nimport StarterKit from '@tiptap/starter-kit';\nimport Underline from '@tiptap/extension-underline';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport { common, createLowlight } from 'lowlight';\nimport TurndownService from 'turndown';\nimport { marked } from 'marked';\nimport { twMerge } from 'tailwind-merge';\nimport type { InputRounded, InputSize, InputVariant } from '../Input/types';\nimport type { TextAreaFormattingToolbar, TextAreaProps } from './types.textarea';\n\nconst variantClasses = {\n solid:\n 'rounded border border-gray-400 bg-white shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-within:border-primary/70 dark:focus-within:ring-primary/40',\n sharp:\n 'rounded-none border border-gray-400 bg-white shadow-sm focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/30 dark:border-gray-600 dark:bg-slate-900 dark:shadow-black/20 dark:focus-within:border-primary/70 dark:focus-within:ring-primary/40',\n outline:\n 'rounded border-2 border-black bg-white focus-within:border-black focus-within:ring-2 focus-within:ring-black/30 dark:border-black dark:bg-transparent dark:focus-within:border-black dark:focus-within:ring-black/40',\n text: 'rounded-none border-0 border-b border-transparent px-0 bg-transparent focus-within:border-primary focus-within:ring-0 focus-within:ring-transparent dark:border-b-gray-600 dark:focus-within:border-primary/70',\n ghost:\n 'rounded border border-transparent bg-gray-50 text-gray-900 focus-within:bg-white focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/15 dark:bg-slate-800 dark:text-gray-100 dark:focus-within:bg-slate-700 dark:focus-within:border-primary/60 dark:focus-within:ring-primary/25',\n filled:\n 'rounded border border-gray-200 bg-gray-100 focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/25 dark:border-gray-700 dark:bg-slate-800 dark:focus-within:border-primary/60 dark:focus-within:ring-primary/30',\n underlined:\n 'rounded-none border-0 border-b border-gray-300 px-0 bg-transparent focus-within:border-primary focus-within:ring-0 focus-within:ring-transparent dark:border-b-gray-600 dark:focus-within:border-primary/70'\n} satisfies Record<InputVariant, string>;\n\nconst roundedClasses = {\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg',\n xl: 'rounded-xl',\n '2xl': 'rounded-2xl',\n '3xl': 'rounded-3xl'\n} satisfies Record<InputRounded, string>;\n\nconst sizeClasses = {\n 'x-small': {\n paddingY: 'py-2',\n paddingX: 'px-2',\n text: 'text-xs'\n },\n small: {\n paddingY: 'py-2.5',\n paddingX: 'px-2.5',\n text: 'text-sm'\n },\n medium: {\n paddingY: 'py-3',\n paddingX: 'px-3',\n text: 'text-base'\n },\n large: {\n paddingY: 'py-3.5',\n paddingX: 'px-3.5',\n text: 'text-lg'\n },\n 'x-large': {\n paddingY: 'py-4',\n paddingX: 'px-4',\n text: 'text-xl'\n }\n} satisfies Record<\n InputSize,\n {\n paddingY: string;\n paddingX: string;\n text: string;\n }\n>;\n\nconst statusClasses = {\n error: 'border-red-500 focus:border-red-500 focus:ring-red-400',\n warn: 'border-amber-500 focus:border-amber-500 focus:ring-amber-400',\n success: 'border-emerald-500 focus:border-emerald-500 focus:ring-emerald-400'\n} as const;\n\nconst statusMessageClasses = {\n error: 'text-red-600 dark:text-red-300',\n warn: 'text-amber-600 dark:text-amber-300',\n success: 'text-emerald-600 dark:text-emerald-300'\n} as const;\n\nconst DEFAULT_TOOLBAR: TextAreaFormattingToolbar[] = ['bold', 'italic', 'underline', 'strike', 'heading', 'bulletList', 'orderedList', 'blockquote', 'codeBlock'];\nconst CODE_BLOCK_LANGUAGES = ['ts', 'json', 'python', 'bash'] as const;\nconst DEFAULT_CODE_BLOCK_LANGUAGE = CODE_BLOCK_LANGUAGES[0];\nconst TEXTAREA_TAB_CHARACTER = '\\t';\nconst lowlight = createLowlight(common);\nlowlight.registerAlias({ ts: 'typescript' });\nconst turndown = new TurndownService({\n codeBlockStyle: 'fenced',\n headingStyle: 'atx',\n bulletListMarker: '-'\n});\n\nconst markdownToHtml = (markdown?: string) => {\n if (!markdown) {\n return '<p></p>';\n }\n\n return marked.parse(markdown) as string;\n};\n\nconst htmlToMarkdown = (html: string) => turndown.turndown(html).trim();\n\nconst createChangeEvent = (element: HTMLTextAreaElement): React.ChangeEvent<HTMLTextAreaElement> =>\n ({\n target: element,\n currentTarget: element\n }) as React.ChangeEvent<HTMLTextAreaElement>;\n\nconst assignRef = <T,>(ref: React.ForwardedRef<T>, value: T | null) => {\n if (typeof ref === 'function') {\n ref(value);\n return;\n }\n\n if (ref) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n};\n\nconst updateTextareaValue = (element: HTMLTextAreaElement, nextValue: string, selectionStart: number, selectionEnd: number) => {\n element.value = nextValue;\n element.setSelectionRange(selectionStart, selectionEnd);\n};\n\nconst indentSelectedLines = (value: string, selectionStart: number, selectionEnd: number) => {\n const lineStart = value.lastIndexOf('\\n', Math.max(0, selectionStart - 1)) + 1;\n const lineEndIndex = value.indexOf('\\n', selectionEnd);\n const lineEnd = lineEndIndex === -1 ? value.length : lineEndIndex;\n const selectedBlock = value.slice(lineStart, lineEnd);\n const lines = selectedBlock.split('\\n');\n const indentedBlock = lines.map(line => `${TEXTAREA_TAB_CHARACTER}${line}`).join('\\n');\n\n return {\n nextValue: `${value.slice(0, lineStart)}${indentedBlock}${value.slice(lineEnd)}`,\n selectionStart: selectionStart + TEXTAREA_TAB_CHARACTER.length,\n selectionEnd: selectionEnd + lines.length * TEXTAREA_TAB_CHARACTER.length\n };\n};\n\nconst outdentSelectedLines = (value: string, selectionStart: number, selectionEnd: number) => {\n const lineStart = value.lastIndexOf('\\n', Math.max(0, selectionStart - 1)) + 1;\n const lineEndIndex = value.indexOf('\\n', selectionEnd);\n const lineEnd = lineEndIndex === -1 ? value.length : lineEndIndex;\n const selectedBlock = value.slice(lineStart, lineEnd);\n const lines = selectedBlock.split('\\n');\n const updatedLines = lines.map(line => (line.startsWith(TEXTAREA_TAB_CHARACTER) ? line.slice(TEXTAREA_TAB_CHARACTER.length) : line));\n const removedBeforeSelectionStart = selectionStart === lineStart && !lines[0].startsWith(TEXTAREA_TAB_CHARACTER) ? 0 : lines[0].startsWith(TEXTAREA_TAB_CHARACTER) ? TEXTAREA_TAB_CHARACTER.length : 0;\n const removedTotal = lines.reduce((count, line) => count + (line.startsWith(TEXTAREA_TAB_CHARACTER) ? TEXTAREA_TAB_CHARACTER.length : 0), 0);\n\n return {\n nextValue: `${value.slice(0, lineStart)}${updatedLines.join('\\n')}${value.slice(lineEnd)}`,\n selectionStart: Math.max(lineStart, selectionStart - removedBeforeSelectionStart),\n selectionEnd: Math.max(lineStart, selectionEnd - removedTotal)\n };\n};\n\ntype ToolbarButtonProps = {\n label: string;\n active?: boolean;\n disabled?: boolean;\n onMouseDown: React.MouseEventHandler<HTMLButtonElement>;\n};\n\ntype CodeBlockLanguage = (typeof CODE_BLOCK_LANGUAGES)[number];\n\nconst isCodeBlockLanguage = (value: string): value is CodeBlockLanguage => CODE_BLOCK_LANGUAGES.includes(value as CodeBlockLanguage);\n\nconst ToolbarButton = ({ label, active, disabled, onMouseDown }: ToolbarButtonProps) => (\n <button\n type='button'\n disabled={disabled}\n onMouseDown={onMouseDown}\n className={twMerge(\n 'inline-flex min-w-8 items-center justify-center rounded border px-2 py-1 text-xs font-medium transition-colors',\n active\n ? 'border-primary bg-primary text-white'\n : 'border-gray-300 bg-white text-gray-700 hover:border-gray-400 hover:bg-gray-50 dark:border-slate-600 dark:bg-slate-900 dark:text-gray-200 dark:hover:bg-slate-800',\n disabled && 'cursor-not-allowed opacity-50'\n )}\n >\n {label}\n </button>\n);\n\n/**\n * Multiline text input matching Input variants, sizing and status messaging.\n */\nconst TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n { variant = 'outline', size = 'medium', rounded = 'md', success, error, warn, className, wrapperClassName, label, prepend, append, rows = 4, richText = false, toolbar = DEFAULT_TOOLBAR, ...props },\n ref\n ) => {\n const { placeholder, onFocus, onBlur, onChange, onKeyDown, value, defaultValue, disabled, readOnly, ...textareaProps } = props;\n const reactId = React.useId();\n const hasLabel = Boolean(label);\n const hasProvidedPlaceholder = typeof placeholder === 'string' && placeholder.trim().length > 0;\n const hidePlaceholderUntilFocus = hasLabel && hasProvidedPlaceholder;\n const [isFocused, setIsFocused] = React.useState(false);\n const classBase = 'textarea-base transition-colors duration-200 w-full has-[textarea:disabled]:opacity-50 has-[textarea:disabled]:cursor-not-allowed';\n const textareaBase =\n 'peer block w-full min-w-0 resize-y border-0 bg-transparent p-0 text-gray-900 dark:text-gray-100 placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:outline-none focus:ring-0';\n const proseBase =\n 'ProseMirror min-h-[7rem] w-full border-0 bg-transparent p-0 text-gray-900 dark:text-gray-100 focus:outline-none [&_blockquote]:border-l-4 [&_blockquote]:border-gray-300 [&_blockquote]:pl-3 [&_blockquote]:italic dark:[&_blockquote]:border-slate-600 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-black [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-white dark:[&_:not(pre)>code]:bg-black dark:[&_:not(pre)>code]:text-white [&_pre]:overflow-x-auto [&_pre]:rounded [&_pre]:bg-black [&_pre]:p-3 [&_pre]:text-white [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-white [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_h1]:text-2xl [&_h1]:font-semibold [&_h2]:text-xl [&_h2]:font-semibold';\n const hiddenTextareaRef = React.useRef<HTMLTextAreaElement | null>(null);\n const forwardedRef = React.useRef<HTMLTextAreaElement | null>(null);\n const isControlled = value !== undefined;\n const markdownValue = typeof value === 'string' ? value : typeof defaultValue === 'string' ? defaultValue : '';\n const [internalMarkdown, setInternalMarkdown] = React.useState(markdownValue);\n const resolvedMarkdownValue = isControlled ? (typeof value === 'string' ? value : '') : internalMarkdown;\n\n const status = error\n ? { tone: 'error' as const, message: error }\n : warn\n ? { tone: 'warn' as const, message: warn }\n : success\n ? { tone: 'success' as const, message: success }\n : undefined;\n\n const variantClass = variantClasses[variant] ?? variantClasses.outline;\n const toneClass = status ? statusClasses[status.tone] : undefined;\n const hasPrepend = typeof prepend === 'string' ? prepend.trim().length > 0 : Boolean(prepend);\n const hasAppend = typeof append === 'string' ? append.trim().length > 0 : Boolean(append);\n const sizeConfig = sizeClasses[size] ?? sizeClasses.medium;\n const sizeClass = [sizeConfig.paddingY, sizeConfig.paddingX, sizeConfig.text].join(' ');\n const roundedClass = variant === 'sharp' || variant === 'text' || variant === 'underlined' ? 'rounded-none' : roundedClasses[rounded];\n\n const inputName = textareaProps.name || reactId;\n const basePlaceholder = placeholder ?? (hasLabel ? ' ' : undefined);\n const placeholderValue = hidePlaceholderUntilFocus ? (isFocused ? placeholder : ' ') : basePlaceholder;\n const placeholderClass = hidePlaceholderUntilFocus\n ? 'placeholder-transparent focus:placeholder-gray-500 focus:dark:placeholder-gray-400'\n : undefined;\n const editor = useEditor({\n extensions: [\n StarterKit.configure({ heading: { levels: [1, 2] }, codeBlock: false }),\n CodeBlockLowlight.configure({\n defaultLanguage: DEFAULT_CODE_BLOCK_LANGUAGE,\n enableTabIndentation: true,\n lowlight,\n HTMLAttributes: {\n class: 'hljs'\n }\n }),\n Underline\n ],\n content: markdownToHtml(resolvedMarkdownValue),\n editable: richText && !disabled && !readOnly,\n immediatelyRender: false,\n editorProps: {\n attributes: {\n class: twMerge(proseBase, placeholderClass),\n 'data-placeholder': placeholderValue ?? ''\n }\n },\n onFocus: () => {\n if (!richText) {\n return;\n }\n\n if (hidePlaceholderUntilFocus) {\n setIsFocused(true);\n }\n const target = hiddenTextareaRef.current;\n if (target) {\n onFocus?.(createChangeEvent(target) as unknown as React.FocusEvent<HTMLTextAreaElement>);\n }\n },\n onBlur: () => {\n if (!richText) {\n return;\n }\n\n if (hidePlaceholderUntilFocus) {\n setIsFocused(false);\n }\n const target = hiddenTextareaRef.current;\n if (target) {\n onBlur?.(createChangeEvent(target) as unknown as React.FocusEvent<HTMLTextAreaElement>);\n }\n },\n onUpdate: ({ editor: currentEditor }) => {\n if (!richText) {\n return;\n }\n\n const nextMarkdown = htmlToMarkdown(currentEditor.getHTML());\n const target = hiddenTextareaRef.current;\n\n setInternalMarkdown(nextMarkdown);\n\n if (!target) {\n return;\n }\n\n target.value = nextMarkdown;\n onChange?.(createChangeEvent(target));\n }\n });\n const activeCodeBlockLanguage = (() => {\n const language = editor?.getAttributes('codeBlock').language;\n if (typeof language === 'string' && isCodeBlockLanguage(language)) {\n return language;\n }\n\n return DEFAULT_CODE_BLOCK_LANGUAGE;\n })();\n\n React.useEffect(() => {\n if (!richText) {\n return;\n }\n\n const target = hiddenTextareaRef.current;\n if (!target) {\n return;\n }\n\n target.value = resolvedMarkdownValue;\n forwardedRef.current = target;\n assignRef(ref, target);\n }, [ref, resolvedMarkdownValue, richText]);\n\n React.useEffect(() => {\n if (!editor || !richText || !isControlled) {\n return;\n }\n\n const nextMarkdown = typeof value === 'string' ? value : '';\n const currentMarkdown = htmlToMarkdown(editor.getHTML());\n if (currentMarkdown === nextMarkdown) {\n return;\n }\n\n editor.commands.setContent(markdownToHtml(nextMarkdown), { emitUpdate: false });\n }, [editor, isControlled, richText, value]);\n\n React.useEffect(() => {\n if (!isControlled) {\n setInternalMarkdown(typeof defaultValue === 'string' ? defaultValue : '');\n }\n }, [defaultValue, isControlled]);\n\n React.useEffect(() => {\n if (!editor || !richText) {\n return;\n }\n\n editor.setEditable(!disabled && !readOnly);\n }, [disabled, editor, readOnly, richText]);\n\n const renderPrepend = hasPrepend ? (\n typeof prepend === 'string' ? (\n <span className={twMerge('text-gray-500 dark:text-gray-400', sizeConfig.text)}>{prepend}</span>\n ) : (\n prepend\n )\n ) : null;\n const renderAppend = hasAppend ? (\n typeof append === 'string' ? (\n <span className={twMerge('text-gray-500 dark:text-gray-400', sizeConfig.text)}>{append}</span>\n ) : (\n append\n )\n ) : null;\n\n const handleFocus: React.FocusEventHandler<HTMLTextAreaElement> = event => {\n if (hidePlaceholderUntilFocus) setIsFocused(true);\n onFocus?.(event);\n };\n\n const handleBlur: React.FocusEventHandler<HTMLTextAreaElement> = event => {\n if (hidePlaceholderUntilFocus) setIsFocused(false);\n onBlur?.(event);\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLTextAreaElement> = event => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented || event.key !== 'Tab' || disabled || readOnly) {\n return;\n }\n\n const target = event.currentTarget;\n const { selectionStart, selectionEnd, value: currentValue } = target;\n\n event.preventDefault();\n\n if (selectionStart !== selectionEnd && currentValue.slice(selectionStart, selectionEnd).includes('\\n')) {\n const nextState = event.shiftKey\n ? outdentSelectedLines(currentValue, selectionStart, selectionEnd)\n : indentSelectedLines(currentValue, selectionStart, selectionEnd);\n\n updateTextareaValue(target, nextState.nextValue, nextState.selectionStart, nextState.selectionEnd);\n onChange?.(createChangeEvent(target));\n return;\n }\n\n if (event.shiftKey) {\n const lineStart = currentValue.lastIndexOf('\\n', Math.max(0, selectionStart - 1)) + 1;\n if (currentValue.slice(lineStart, selectionStart).endsWith(TEXTAREA_TAB_CHARACTER)) {\n const nextValue = `${currentValue.slice(0, selectionStart - TEXTAREA_TAB_CHARACTER.length)}${currentValue.slice(selectionEnd)}`;\n const nextPosition = selectionStart - TEXTAREA_TAB_CHARACTER.length;\n\n updateTextareaValue(target, nextValue, nextPosition, nextPosition);\n onChange?.(createChangeEvent(target));\n }\n return;\n }\n\n const nextValue = `${currentValue.slice(0, selectionStart)}${TEXTAREA_TAB_CHARACTER}${currentValue.slice(selectionEnd)}`;\n const nextPosition = selectionStart + TEXTAREA_TAB_CHARACTER.length;\n\n updateTextareaValue(target, nextValue, nextPosition, nextPosition);\n onChange?.(createChangeEvent(target));\n };\n\n return (\n <div className={twMerge('flex flex-col gap-1', wrapperClassName)}>\n <div className={twMerge('flex w-full items-start gap-2', classBase, variantClass, roundedClass, toneClass, sizeClass, className)}>\n {hasPrepend && <span className='flex shrink-0 items-start pt-0.5'>{renderPrepend}</span>}\n\n <div className='relative min-w-0 flex-1'>\n {richText ? (\n <>\n <textarea\n {...textareaProps}\n ref={node => {\n hiddenTextareaRef.current = node;\n forwardedRef.current = node;\n if (node) {\n assignRef(ref, node);\n }\n }}\n id={inputName}\n name={inputName}\n rows={rows}\n value={isControlled ? value : undefined}\n defaultValue={!isControlled ? defaultValue : undefined}\n disabled={disabled}\n readOnly\n tabIndex={-1}\n aria-hidden\n className='sr-only'\n />\n <div className='flex flex-wrap gap-1 border-b border-gray-200 pb-2 dark:border-slate-700'>\n {toolbar.includes('bold') && (\n <ToolbarButton\n label='B'\n disabled={!editor?.isEditable}\n active={editor?.isActive('bold')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleBold().run();\n }}\n />\n )}\n {toolbar.includes('italic') && (\n <ToolbarButton\n label='I'\n disabled={!editor?.isEditable}\n active={editor?.isActive('italic')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleItalic().run();\n }}\n />\n )}\n {toolbar.includes('underline') && (\n <ToolbarButton\n label='U'\n disabled={!editor?.isEditable}\n active={editor?.isActive('underline')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleUnderline().run();\n }}\n />\n )}\n {toolbar.includes('strike') && (\n <ToolbarButton\n label='S'\n disabled={!editor?.isEditable}\n active={editor?.isActive('strike')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleStrike().run();\n }}\n />\n )}\n {toolbar.includes('heading') && (\n <>\n <ToolbarButton\n label='H1'\n disabled={!editor?.isEditable}\n active={editor?.isActive('heading', { level: 1 })}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleHeading({ level: 1 }).run();\n }}\n />\n <ToolbarButton\n label='H2'\n disabled={!editor?.isEditable}\n active={editor?.isActive('heading', { level: 2 })}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleHeading({ level: 2 }).run();\n }}\n />\n </>\n )}\n {toolbar.includes('bulletList') && (\n <ToolbarButton\n label='List'\n disabled={!editor?.isEditable}\n active={editor?.isActive('bulletList')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleBulletList().run();\n }}\n />\n )}\n {toolbar.includes('orderedList') && (\n <ToolbarButton\n label='1.'\n disabled={!editor?.isEditable}\n active={editor?.isActive('orderedList')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleOrderedList().run();\n }}\n />\n )}\n {toolbar.includes('blockquote') && (\n <ToolbarButton\n label='Quote'\n disabled={!editor?.isEditable}\n active={editor?.isActive('blockquote')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleBlockquote().run();\n }}\n />\n )}\n {toolbar.includes('codeBlock') && (\n <>\n <ToolbarButton\n label='Code'\n disabled={!editor?.isEditable}\n active={editor?.isActive('codeBlock')}\n onMouseDown={event => {\n event.preventDefault();\n editor?.chain().focus().toggleCodeBlock({ language: activeCodeBlockLanguage }).run();\n }}\n />\n <label className='sr-only' htmlFor={`${inputName}-code-language`}>\n Code language\n </label>\n <select\n id={`${inputName}-code-language`}\n value={activeCodeBlockLanguage}\n disabled={!editor?.isEditable}\n className='min-w-24 rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-700 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-600 dark:bg-slate-900 dark:text-gray-200'\n onChange={event => {\n const language = event.target.value;\n if (!isCodeBlockLanguage(language)) {\n return;\n }\n\n editor?.chain().focus().setCodeBlock({ language }).run();\n }}\n >\n {CODE_BLOCK_LANGUAGES.map(language => (\n <option key={language} value={language}>\n {language}\n </option>\n ))}\n </select>\n </>\n )}\n </div>\n <EditorContent editor={editor} className='pt-3' />\n </>\n ) : (\n <textarea\n {...textareaProps}\n ref={node => {\n forwardedRef.current = node;\n assignRef(ref, node);\n }}\n id={inputName}\n name={inputName}\n rows={rows}\n placeholder={placeholderValue}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onChange={onChange}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n defaultValue={defaultValue}\n className={twMerge(textareaBase, placeholderClass)}\n />\n )}\n\n {label && (\n <label\n htmlFor={inputName}\n className={twMerge(\n 'absolute left-0 z-10 transition-all duration-150 pointer-events-none text-gray-700 dark:text-gray-200',\n '-top-2 -translate-y-full text-xs bg-white px-1 dark:bg-slate-900',\n !richText && 'peer-focus:left-0 peer-focus:-top-5 peer-focus:-translate-y-full peer-focus:text-xs peer-focus:text-gray-600 dark:peer-focus:text-gray-300',\n !richText &&\n 'peer-placeholder-shown:top-3 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:text-sm peer-placeholder-shown:bg-transparent peer-placeholder-shown:px-0 peer-placeholder-shown:text-gray-500 dark:peer-placeholder-shown:text-gray-400',\n !richText &&\n 'peer-[&:not(:placeholder-shown)]:left-0 peer-[&:not(:placeholder-shown)]:-top-2 peer-[&:not(:placeholder-shown)]:-translate-y-full peer-[&:not(:placeholder-shown)]:text-xs peer-[&:not(:placeholder-shown)]:bg-white peer-[&:not(:placeholder-shown)]:px-1 peer-[&:not(:placeholder-shown)]:text-gray-700 dark:peer-[&:not(:placeholder-shown)]:bg-slate-900 dark:peer-[&:not(:placeholder-shown)]:text-gray-200',\n richText && (isFocused || resolvedMarkdownValue) && '-top-2 -translate-y-full text-xs',\n richText && !(isFocused || resolvedMarkdownValue) && 'top-3 translate-y-0 text-sm bg-transparent px-0 text-gray-500 dark:text-gray-400'\n )}\n >\n {label}\n </label>\n )}\n </div>\n\n {hasAppend && <span className='flex shrink-0 items-start pt-0.5'>{renderAppend}</span>}\n </div>\n {status?.message && <span className={twMerge('text-sm', statusMessageClasses[status.tone])}>{status.message}</span>}\n </div>\n );\n }\n);\n\nTextArea.displayName = 'TextArea';\n\nexport type { TextAreaProps } from './types.textarea';\nexport default TextArea;\n"]}
|