@12-apps/ui 6.10.0 → 6.11.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/TextareaRichEditor-ZFB44VWZ.js +303 -0
- package/dist/TextareaRichEditor-ZFB44VWZ.js.map +1 -0
- package/dist/chunk-FKWNB4LW.js +111 -0
- package/dist/chunk-FKWNB4LW.js.map +1 -0
- package/dist/chunk-PQWPMIGH.js +94 -0
- package/dist/chunk-PQWPMIGH.js.map +1 -0
- package/dist/data-display/DataViews.js +1 -1
- package/dist/form/DateRangePicker.js +5 -4
- package/dist/form/DateRangePicker.js.map +1 -1
- package/dist/form/Textarea.js +46 -414
- package/dist/form/Textarea.js.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-day-input.d.ts +16 -12
- package/dist/types/components/data-display/DataViews/data-views-day-input.d.ts.map +1 -1
- package/dist/types/components/form/DateRangePicker/DateRangePicker.range.d.ts.map +1 -1
- package/dist/types/components/form/Textarea/Textarea.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/data-display/DataViews/data-views-day-input.tsx +104 -29
- package/src/components/form/DateRangePicker/DateRangePicker.range.ts +8 -3
- package/src/components/form/Textarea/Textarea.tsx +60 -14
- package/dist/chunk-TSG5C7MP.js +0 -78
- package/dist/chunk-TSG5C7MP.js.map +0 -1
package/dist/form/Textarea.js
CHANGED
|
@@ -1,401 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getColorFromTheme,
|
|
3
|
+
textareaEmphasisStyles
|
|
4
|
+
} from "../chunk-PQWPMIGH.js";
|
|
1
5
|
import "../chunk-PZ5AY32C.js";
|
|
2
6
|
|
|
3
7
|
// src/components/form/Textarea/Textarea.tsx
|
|
4
8
|
import {
|
|
5
|
-
alpha
|
|
6
|
-
Box
|
|
9
|
+
alpha,
|
|
10
|
+
Box,
|
|
7
11
|
FormHelperText,
|
|
8
12
|
InputLabel,
|
|
9
13
|
TextareaAutosize
|
|
10
14
|
} from "@mui/material";
|
|
11
|
-
import { styled as styled2 } from "@mui/material";
|
|
12
|
-
import { useState as useState2 } from "react";
|
|
13
|
-
|
|
14
|
-
// src/components/form/Textarea/Textarea.styles.ts
|
|
15
|
-
import { alpha, keyframes } from "@mui/material";
|
|
16
|
-
var glowAnimation = keyframes`
|
|
17
|
-
0% {
|
|
18
|
-
box-shadow: 0 0 5px currentColor;
|
|
19
|
-
}
|
|
20
|
-
50% {
|
|
21
|
-
box-shadow: 0 0 20px currentColor, 0 0 30px currentColor;
|
|
22
|
-
}
|
|
23
|
-
100% {
|
|
24
|
-
box-shadow: 0 0 5px currentColor;
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
var floatAnimation = keyframes`
|
|
28
|
-
0% {
|
|
29
|
-
transform: translateY(0px);
|
|
30
|
-
}
|
|
31
|
-
50% {
|
|
32
|
-
transform: translateY(-3px);
|
|
33
|
-
}
|
|
34
|
-
100% {
|
|
35
|
-
transform: translateY(0px);
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
var neutralPalette = (theme) => {
|
|
39
|
-
const grey = theme.palette.grey;
|
|
40
|
-
return {
|
|
41
|
-
main: grey?.[700] || "#616161",
|
|
42
|
-
dark: grey?.[800] || "#424242",
|
|
43
|
-
light: grey?.[500] || "#9e9e9e",
|
|
44
|
-
contrastText: "#fff"
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
var pick = (...candidates) => candidates.find(Boolean) ?? "";
|
|
48
|
-
var withFallbacks = (theme, palette) => ({
|
|
49
|
-
main: pick(palette?.main, theme.palette.primary.main),
|
|
50
|
-
dark: pick(palette?.dark, palette?.main, theme.palette.primary.dark),
|
|
51
|
-
light: pick(palette?.light, palette?.main, theme.palette.primary.light),
|
|
52
|
-
contrastText: pick(palette?.contrastText, "#fff")
|
|
53
|
-
});
|
|
54
|
-
var getColorFromTheme = (theme, color) => {
|
|
55
|
-
if (color === "neutral") return neutralPalette(theme);
|
|
56
|
-
const colorMap = {
|
|
57
|
-
primary: theme.palette.primary,
|
|
58
|
-
secondary: theme.palette.secondary,
|
|
59
|
-
success: theme.palette.success,
|
|
60
|
-
warning: theme.palette.warning,
|
|
61
|
-
info: theme.palette.info,
|
|
62
|
-
danger: theme.palette.error
|
|
63
|
-
};
|
|
64
|
-
return withFallbacks(theme, colorMap[color] || theme.palette.primary);
|
|
65
|
-
};
|
|
66
|
-
var textareaEmphasisStyles = ({
|
|
67
|
-
theme,
|
|
68
|
-
colorPalette,
|
|
69
|
-
glass,
|
|
70
|
-
gradient,
|
|
71
|
-
glow
|
|
72
|
-
}) => {
|
|
73
|
-
const glassStyles = glass ? {
|
|
74
|
-
backgroundColor: alpha(theme.palette.background.paper, 0.1),
|
|
75
|
-
backdropFilter: "blur(20px)",
|
|
76
|
-
border: `1px solid ${alpha(theme.palette.divider, 0.2)}`,
|
|
77
|
-
"&:hover": {
|
|
78
|
-
backgroundColor: alpha(theme.palette.background.paper, 0.15),
|
|
79
|
-
backdropFilter: "blur(25px)"
|
|
80
|
-
},
|
|
81
|
-
"&:focus": {
|
|
82
|
-
backgroundColor: alpha(theme.palette.background.paper, 0.2),
|
|
83
|
-
backdropFilter: "blur(30px)"
|
|
84
|
-
}
|
|
85
|
-
} : {};
|
|
86
|
-
const gradientStyles = gradient ? {
|
|
87
|
-
background: `linear-gradient(${theme.palette.background.paper}, ${theme.palette.background.paper}) padding-box,
|
|
88
|
-
linear-gradient(135deg, ${colorPalette.main}, ${colorPalette.light}) border-box`,
|
|
89
|
-
border: "2px solid transparent",
|
|
90
|
-
"&:focus": {
|
|
91
|
-
background: `linear-gradient(${theme.palette.background.paper}, ${theme.palette.background.paper}) padding-box,
|
|
92
|
-
linear-gradient(135deg, ${colorPalette.main}, ${colorPalette.dark}) border-box`
|
|
93
|
-
}
|
|
94
|
-
} : {};
|
|
95
|
-
const glowStyles = glow ? {
|
|
96
|
-
animation: `${glowAnimation} 2s ease-in-out infinite`,
|
|
97
|
-
boxShadow: `0 0 10px ${alpha(colorPalette.main, 0.3)}`
|
|
98
|
-
} : {};
|
|
99
|
-
return { ...glassStyles, ...gradientStyles, ...glowStyles };
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/components/form/Textarea/TextareaRichEditor.tsx
|
|
103
|
-
import Code from "@mui/icons-material/Code";
|
|
104
|
-
import FormatBold from "@mui/icons-material/FormatBold";
|
|
105
|
-
import FormatColorFill from "@mui/icons-material/FormatColorFill";
|
|
106
|
-
import FormatColorText from "@mui/icons-material/FormatColorText";
|
|
107
|
-
import FormatItalic from "@mui/icons-material/FormatItalic";
|
|
108
|
-
import FormatListBulleted from "@mui/icons-material/FormatListBulleted";
|
|
109
|
-
import FormatListNumbered from "@mui/icons-material/FormatListNumbered";
|
|
110
|
-
import FormatQuote from "@mui/icons-material/FormatQuote";
|
|
111
|
-
import FormatUnderlined from "@mui/icons-material/FormatUnderlined";
|
|
112
|
-
import Link from "@mui/icons-material/Link";
|
|
113
|
-
import { alpha as alpha2, Box, Divider, IconButton, Tooltip } from "@mui/material";
|
|
114
15
|
import { styled } from "@mui/material";
|
|
115
|
-
import {
|
|
116
|
-
import {
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
alignItems: "center",
|
|
120
|
-
gap: theme.spacing(0.5),
|
|
121
|
-
padding: theme.spacing(1),
|
|
122
|
-
borderRadius: `${theme.spacing(1)} ${theme.spacing(1)} 0 0`,
|
|
123
|
-
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
124
|
-
background: glass ? alpha2(theme.palette.background.paper, 0.1) : theme.palette.background.paper,
|
|
125
|
-
...glass && {
|
|
126
|
-
backdropFilter: "blur(15px)"
|
|
127
|
-
},
|
|
128
|
-
"& .MuiDivider-root": {
|
|
129
|
-
height: 24,
|
|
130
|
-
margin: `0 ${theme.spacing(1)}`
|
|
131
|
-
}
|
|
132
|
-
}));
|
|
133
|
-
var ToolbarButton = styled(IconButton, {
|
|
134
|
-
shouldForwardProp: (prop) => prop !== "active"
|
|
135
|
-
})(({ theme, active }) => ({
|
|
136
|
-
padding: theme.spacing(0.75),
|
|
137
|
-
borderRadius: theme.spacing(0.5),
|
|
138
|
-
color: active ? theme.palette.primary.main : theme.palette.text.secondary,
|
|
139
|
-
backgroundColor: active ? alpha2(theme.palette.primary.main, 0.1) : "transparent",
|
|
140
|
-
transition: "all 0.2s ease",
|
|
141
|
-
position: "relative",
|
|
142
|
-
overflow: "hidden",
|
|
143
|
-
"&::before": {
|
|
144
|
-
content: '""',
|
|
145
|
-
position: "absolute",
|
|
146
|
-
top: "50%",
|
|
147
|
-
left: "50%",
|
|
148
|
-
width: 0,
|
|
149
|
-
height: 0,
|
|
150
|
-
borderRadius: "50%",
|
|
151
|
-
backgroundColor: alpha2(theme.palette.primary.main, 0.3),
|
|
152
|
-
transform: "translate(-50%, -50%)",
|
|
153
|
-
transition: "width 0.3s, height 0.3s"
|
|
154
|
-
},
|
|
155
|
-
"&:hover": {
|
|
156
|
-
color: theme.palette.primary.main,
|
|
157
|
-
backgroundColor: alpha2(theme.palette.primary.main, 0.15),
|
|
158
|
-
transform: "translateY(-1px)",
|
|
159
|
-
animation: `${floatAnimation} 1.5s ease-in-out infinite`,
|
|
160
|
-
"&::before": {
|
|
161
|
-
width: "100%",
|
|
162
|
-
height: "100%"
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
"&:active": {
|
|
166
|
-
transform: "scale(0.95)"
|
|
167
|
-
}
|
|
16
|
+
import { lazy, Suspense, useState } from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var TextareaRichEditor = lazy(async () => ({
|
|
19
|
+
default: (await import("../TextareaRichEditor-ZFB44VWZ.js")).TextareaRichEditor
|
|
168
20
|
}));
|
|
169
|
-
var
|
|
170
|
-
const isWarning = limit && count > limit * 0.8;
|
|
171
|
-
const isError = limit && count > limit;
|
|
172
|
-
return {
|
|
173
|
-
position: "absolute",
|
|
174
|
-
bottom: theme.spacing(1),
|
|
175
|
-
right: theme.spacing(1),
|
|
176
|
-
fontSize: "0.75rem",
|
|
177
|
-
color: isError ? theme.palette.error.main : isWarning ? theme.palette.warning.main : theme.palette.text.secondary,
|
|
178
|
-
padding: "2px 6px",
|
|
179
|
-
borderRadius: theme.spacing(0.5),
|
|
180
|
-
backgroundColor: alpha2(theme.palette.background.paper, 0.8),
|
|
181
|
-
backdropFilter: "blur(10px)",
|
|
182
|
-
transition: "all 0.3s ease"
|
|
183
|
-
};
|
|
184
|
-
});
|
|
185
|
-
var ContentEditableDiv = styled("div")(({ theme, error, focused, glass, customColor = "primary" }) => {
|
|
186
|
-
if (!theme) return {};
|
|
187
|
-
const colorPalette = getColorFromTheme(theme, customColor);
|
|
188
|
-
const errorColor = theme.palette.error;
|
|
189
|
-
return {
|
|
190
|
-
minHeight: "120px",
|
|
191
|
-
padding: theme.spacing(1.5),
|
|
192
|
-
borderRadius: `0 0 ${theme.spacing(1)} ${theme.spacing(1)}`,
|
|
193
|
-
border: `2px solid ${error ? errorColor.main : focused ? colorPalette.main : theme.palette.divider}`,
|
|
194
|
-
borderTop: "none",
|
|
195
|
-
backgroundColor: glass ? alpha2(theme.palette.background.paper, 0.1) : theme.palette.background.paper,
|
|
196
|
-
color: theme.palette.text.primary,
|
|
197
|
-
fontFamily: theme.typography.fontFamily,
|
|
198
|
-
fontSize: "1rem",
|
|
199
|
-
lineHeight: 1.5,
|
|
200
|
-
outline: "none",
|
|
201
|
-
transition: "all 0.3s ease",
|
|
202
|
-
cursor: "text",
|
|
203
|
-
...glass && {
|
|
204
|
-
backdropFilter: "blur(20px)"
|
|
205
|
-
},
|
|
206
|
-
"&:hover": {
|
|
207
|
-
backgroundColor: glass ? alpha2(theme.palette.background.paper, 0.15) : alpha2(theme.palette.background.paper, 0.9)
|
|
208
|
-
},
|
|
209
|
-
"&:focus": {
|
|
210
|
-
borderColor: error ? errorColor.main : colorPalette.main,
|
|
211
|
-
boxShadow: `0 0 0 3px ${alpha2(error ? errorColor.main : colorPalette.main, 0.1)}`
|
|
212
|
-
},
|
|
213
|
-
"& > *": {
|
|
214
|
-
margin: "0.5em 0"
|
|
215
|
-
},
|
|
216
|
-
'&[contenteditable="true"]:empty::before': {
|
|
217
|
-
content: "attr(data-placeholder)",
|
|
218
|
-
color: theme.palette.text.secondary,
|
|
219
|
-
opacity: 0.6
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
var formatText = (command, value) => {
|
|
224
|
-
document.execCommand(command, false, value);
|
|
225
|
-
};
|
|
226
|
-
var useRichEditorState = ({
|
|
227
|
-
value,
|
|
228
|
-
onChange
|
|
229
|
-
}) => {
|
|
230
|
-
const [focused, setFocused] = useState(false);
|
|
231
|
-
const [characterCount, setCharacterCount] = useState(0);
|
|
232
|
-
const [activeFormats, setActiveFormats] = useState({
|
|
233
|
-
bold: false,
|
|
234
|
-
italic: false,
|
|
235
|
-
underline: false,
|
|
236
|
-
list: false,
|
|
237
|
-
orderedList: false,
|
|
238
|
-
quote: false,
|
|
239
|
-
code: false
|
|
240
|
-
});
|
|
241
|
-
const contentRef = useRef(null);
|
|
242
|
-
useEffect(() => {
|
|
243
|
-
if (contentRef.current && value !== void 0) {
|
|
244
|
-
if (contentRef.current.innerHTML !== value) {
|
|
245
|
-
contentRef.current.innerHTML = value;
|
|
246
|
-
}
|
|
247
|
-
setCharacterCount(contentRef.current.innerText.length);
|
|
248
|
-
}
|
|
249
|
-
}, [value]);
|
|
250
|
-
const handleInput = () => {
|
|
251
|
-
if (contentRef.current) {
|
|
252
|
-
const html = contentRef.current.innerHTML;
|
|
253
|
-
onChange?.(html);
|
|
254
|
-
setCharacterCount(contentRef.current.innerText.length);
|
|
255
|
-
updateActiveFormats();
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
const updateActiveFormats = () => {
|
|
259
|
-
setActiveFormats({
|
|
260
|
-
bold: document.queryCommandState("bold"),
|
|
261
|
-
italic: document.queryCommandState("italic"),
|
|
262
|
-
underline: document.queryCommandState("underline"),
|
|
263
|
-
list: document.queryCommandState("insertUnorderedList"),
|
|
264
|
-
orderedList: document.queryCommandState("insertOrderedList"),
|
|
265
|
-
quote: false,
|
|
266
|
-
code: false
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
const handleFormat = (command, value2) => {
|
|
270
|
-
formatText(command, value2);
|
|
271
|
-
updateActiveFormats();
|
|
272
|
-
contentRef.current?.focus();
|
|
273
|
-
};
|
|
274
|
-
return {
|
|
275
|
-
focused,
|
|
276
|
-
setFocused,
|
|
277
|
-
characterCount,
|
|
278
|
-
activeFormats,
|
|
279
|
-
contentRef,
|
|
280
|
-
handleInput,
|
|
281
|
-
handleFormat,
|
|
282
|
-
updateActiveFormats
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
var InlineFormatButtons = ({ copy, activeFormats, onCommand }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
286
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.bold, arrow: true, children: /* @__PURE__ */ jsx(
|
|
287
|
-
ToolbarButton,
|
|
288
|
-
{
|
|
289
|
-
size: "small",
|
|
290
|
-
active: activeFormats.bold,
|
|
291
|
-
onClick: () => onCommand("bold"),
|
|
292
|
-
children: /* @__PURE__ */ jsx(FormatBold, { fontSize: "small" })
|
|
293
|
-
}
|
|
294
|
-
) }),
|
|
295
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.italic, arrow: true, children: /* @__PURE__ */ jsx(
|
|
296
|
-
ToolbarButton,
|
|
297
|
-
{
|
|
298
|
-
size: "small",
|
|
299
|
-
active: activeFormats.italic,
|
|
300
|
-
onClick: () => onCommand("italic"),
|
|
301
|
-
children: /* @__PURE__ */ jsx(FormatItalic, { fontSize: "small" })
|
|
302
|
-
}
|
|
303
|
-
) }),
|
|
304
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.underline, arrow: true, children: /* @__PURE__ */ jsx(
|
|
305
|
-
ToolbarButton,
|
|
306
|
-
{
|
|
307
|
-
size: "small",
|
|
308
|
-
active: activeFormats.underline,
|
|
309
|
-
onClick: () => onCommand("underline"),
|
|
310
|
-
children: /* @__PURE__ */ jsx(FormatUnderlined, { fontSize: "small" })
|
|
311
|
-
}
|
|
312
|
-
) })
|
|
313
|
-
] });
|
|
314
|
-
var BlockFormatButtons = ({ copy, activeFormats, onCommand }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
315
|
-
/* @__PURE__ */ jsx(Divider, { orientation: "vertical", flexItem: true }),
|
|
316
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.bulletList, arrow: true, children: /* @__PURE__ */ jsx(
|
|
317
|
-
ToolbarButton,
|
|
318
|
-
{
|
|
319
|
-
size: "small",
|
|
320
|
-
active: activeFormats.list,
|
|
321
|
-
onClick: () => onCommand("insertUnorderedList"),
|
|
322
|
-
children: /* @__PURE__ */ jsx(FormatListBulleted, { fontSize: "small" })
|
|
323
|
-
}
|
|
324
|
-
) }),
|
|
325
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.numberedList, arrow: true, children: /* @__PURE__ */ jsx(
|
|
326
|
-
ToolbarButton,
|
|
327
|
-
{
|
|
328
|
-
size: "small",
|
|
329
|
-
active: activeFormats.orderedList,
|
|
330
|
-
onClick: () => onCommand("insertOrderedList"),
|
|
331
|
-
children: /* @__PURE__ */ jsx(FormatListNumbered, { fontSize: "small" })
|
|
332
|
-
}
|
|
333
|
-
) }),
|
|
334
|
-
/* @__PURE__ */ jsx(Divider, { orientation: "vertical", flexItem: true }),
|
|
335
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.quote, arrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { size: "small", onClick: () => onCommand("formatBlock", "blockquote"), children: /* @__PURE__ */ jsx(FormatQuote, { fontSize: "small" }) }) }),
|
|
336
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.code, arrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { size: "small", onClick: () => onCommand("formatBlock", "pre"), children: /* @__PURE__ */ jsx(Code, { fontSize: "small" }) }) }),
|
|
337
|
-
/* @__PURE__ */ jsx(Divider, { orientation: "vertical", flexItem: true }),
|
|
338
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.insertLink, arrow: true, children: /* @__PURE__ */ jsx(
|
|
339
|
-
ToolbarButton,
|
|
340
|
-
{
|
|
341
|
-
size: "small",
|
|
342
|
-
onClick: () => {
|
|
343
|
-
const url = window.prompt(copy.linkPrompt);
|
|
344
|
-
if (url) onCommand("createLink", url);
|
|
345
|
-
},
|
|
346
|
-
children: /* @__PURE__ */ jsx(Link, { fontSize: "small" })
|
|
347
|
-
}
|
|
348
|
-
) }),
|
|
349
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.textColor, arrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { size: "small", children: /* @__PURE__ */ jsx(FormatColorText, { fontSize: "small" }) }) }),
|
|
350
|
-
/* @__PURE__ */ jsx(Tooltip, { title: copy.backgroundColor, arrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { size: "small", children: /* @__PURE__ */ jsx(FormatColorFill, { fontSize: "small" }) }) })
|
|
351
|
-
] });
|
|
352
|
-
var EditorToolbar = ({ copy, glass, activeFormats, onCommand }) => /* @__PURE__ */ jsxs(RichToolbar, { glass, children: [
|
|
353
|
-
/* @__PURE__ */ jsx(InlineFormatButtons, { copy, activeFormats, onCommand }),
|
|
354
|
-
/* @__PURE__ */ jsx(BlockFormatButtons, { copy, activeFormats, onCommand })
|
|
355
|
-
] });
|
|
356
|
-
var TextareaRichEditor = ({ copy, value, onChange, placeholder, error, glass, color, characterLimit }) => {
|
|
357
|
-
const {
|
|
358
|
-
focused,
|
|
359
|
-
setFocused,
|
|
360
|
-
characterCount,
|
|
361
|
-
activeFormats,
|
|
362
|
-
contentRef,
|
|
363
|
-
handleInput,
|
|
364
|
-
handleFormat,
|
|
365
|
-
updateActiveFormats
|
|
366
|
-
} = useRichEditorState({ value, onChange });
|
|
367
|
-
return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
|
|
368
|
-
/* @__PURE__ */ jsx(EditorToolbar, { copy, glass, activeFormats, onCommand: handleFormat }),
|
|
369
|
-
/* @__PURE__ */ jsx(
|
|
370
|
-
ContentEditableDiv,
|
|
371
|
-
{
|
|
372
|
-
ref: contentRef,
|
|
373
|
-
contentEditable: true,
|
|
374
|
-
"data-placeholder": placeholder,
|
|
375
|
-
error,
|
|
376
|
-
focused,
|
|
377
|
-
glass,
|
|
378
|
-
customColor: color,
|
|
379
|
-
onFocus: () => setFocused(true),
|
|
380
|
-
onBlur: () => setFocused(false),
|
|
381
|
-
onInput: handleInput,
|
|
382
|
-
onKeyUp: updateActiveFormats,
|
|
383
|
-
onMouseUp: updateActiveFormats,
|
|
384
|
-
role: "textbox",
|
|
385
|
-
"aria-multiline": "true",
|
|
386
|
-
"aria-label": placeholder || "Rich text editor"
|
|
387
|
-
}
|
|
388
|
-
),
|
|
389
|
-
characterLimit && /* @__PURE__ */ jsxs(CharacterCount, { limit: characterLimit, count: characterCount, children: [
|
|
390
|
-
characterCount,
|
|
391
|
-
characterLimit ? `/${characterLimit}` : ""
|
|
392
|
-
] })
|
|
393
|
-
] });
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
// src/components/form/Textarea/Textarea.tsx
|
|
397
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
398
|
-
var StyledTextarea = styled2(TextareaAutosize, {
|
|
21
|
+
var StyledTextarea = styled(TextareaAutosize, {
|
|
399
22
|
shouldForwardProp: (prop) => !["customVariant", "customColor", "customSize", "glow", "glass", "gradient", "error"].includes(
|
|
400
23
|
prop
|
|
401
24
|
)
|
|
@@ -436,12 +59,12 @@ var StyledTextarea = styled2(TextareaAutosize, {
|
|
|
436
59
|
},
|
|
437
60
|
"&:hover": {
|
|
438
61
|
borderColor: error ? errorColor.dark : colorPalette.main,
|
|
439
|
-
backgroundColor:
|
|
62
|
+
backgroundColor: alpha(theme.palette.background.paper, 0.8)
|
|
440
63
|
},
|
|
441
64
|
"&:focus": {
|
|
442
65
|
borderColor: error ? errorColor.main : colorPalette.main,
|
|
443
66
|
backgroundColor: theme.palette.background.paper,
|
|
444
|
-
boxShadow: `0 0 0 3px ${
|
|
67
|
+
boxShadow: `0 0 0 3px ${alpha(error ? errorColor.main : colorPalette.main, 0.1)}`
|
|
445
68
|
}
|
|
446
69
|
};
|
|
447
70
|
return {
|
|
@@ -449,18 +72,18 @@ var StyledTextarea = styled2(TextareaAutosize, {
|
|
|
449
72
|
...textareaEmphasisStyles({ theme, colorPalette, glass, gradient, glow })
|
|
450
73
|
};
|
|
451
74
|
});
|
|
452
|
-
var StyledLabel =
|
|
75
|
+
var StyledLabel = styled(InputLabel, {
|
|
453
76
|
shouldForwardProp: (prop) => !["glass", "error"].includes(prop)
|
|
454
77
|
})(({ theme, glass, error }) => ({
|
|
455
78
|
marginBottom: theme.spacing(1),
|
|
456
79
|
fontWeight: 500,
|
|
457
80
|
color: error ? theme.palette.error.main : theme.palette.text.primary,
|
|
458
81
|
...glass && {
|
|
459
|
-
backgroundColor:
|
|
82
|
+
backgroundColor: alpha(theme.palette.background.paper, 0.1),
|
|
460
83
|
backdropFilter: "blur(10px)",
|
|
461
84
|
padding: "4px 8px",
|
|
462
85
|
borderRadius: "4px",
|
|
463
|
-
border: `1px solid ${
|
|
86
|
+
border: `1px solid ${alpha(theme.palette.divider, 0.2)}`,
|
|
464
87
|
display: "inline-block"
|
|
465
88
|
}
|
|
466
89
|
}));
|
|
@@ -480,20 +103,20 @@ var TEXTAREA_DEFAULTS = {
|
|
|
480
103
|
var definedProps = (props) => Object.fromEntries(
|
|
481
104
|
Object.entries(props).filter(([, value]) => value !== void 0)
|
|
482
105
|
);
|
|
483
|
-
var TextareaShell = ({ testId, label, glassLabel, error, helperText, children }) => /* @__PURE__ */
|
|
484
|
-
|
|
106
|
+
var TextareaShell = ({ testId, label, glassLabel, error, helperText, children }) => /* @__PURE__ */ jsxs(
|
|
107
|
+
Box,
|
|
485
108
|
{
|
|
486
109
|
sx: { position: "relative", width: "100%" },
|
|
487
110
|
"data-testid": testId ? `${testId}-wrapper` : void 0,
|
|
488
111
|
children: [
|
|
489
|
-
label && /* @__PURE__ */
|
|
112
|
+
label && /* @__PURE__ */ jsx(StyledLabel, { glass: glassLabel, error, children: label }),
|
|
490
113
|
children,
|
|
491
|
-
helperText && /* @__PURE__ */
|
|
114
|
+
helperText && /* @__PURE__ */ jsx(FormHelperText, { error, sx: { mt: 1 }, children: helperText })
|
|
492
115
|
]
|
|
493
116
|
}
|
|
494
117
|
);
|
|
495
|
-
var TextareaIcon = ({ icon, iconPosition }) => /* @__PURE__ */
|
|
496
|
-
|
|
118
|
+
var TextareaIcon = ({ icon, iconPosition }) => /* @__PURE__ */ jsx(
|
|
119
|
+
Box,
|
|
497
120
|
{
|
|
498
121
|
sx: {
|
|
499
122
|
position: "absolute",
|
|
@@ -506,6 +129,12 @@ var TextareaIcon = ({ icon, iconPosition }) => /* @__PURE__ */ jsx2(
|
|
|
506
129
|
children: icon
|
|
507
130
|
}
|
|
508
131
|
);
|
|
132
|
+
function RichVariant({
|
|
133
|
+
shell,
|
|
134
|
+
editor
|
|
135
|
+
}) {
|
|
136
|
+
return /* @__PURE__ */ jsx(TextareaShell, { ...shell, children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(TextareaRichEditor, { ...editor }) }) });
|
|
137
|
+
}
|
|
509
138
|
var Textarea = (textareaProps) => {
|
|
510
139
|
const {
|
|
511
140
|
variant,
|
|
@@ -528,7 +157,7 @@ var Textarea = (textareaProps) => {
|
|
|
528
157
|
...props
|
|
529
158
|
} = { ...TEXTAREA_DEFAULTS, ...definedProps(textareaProps) };
|
|
530
159
|
const { richEditorCopy } = textareaProps;
|
|
531
|
-
const [richTextValue, setRichTextValue] =
|
|
160
|
+
const [richTextValue, setRichTextValue] = useState("");
|
|
532
161
|
const hasIcon = Boolean(icon);
|
|
533
162
|
const testId = dataTestId || dataTestIdCamelCase;
|
|
534
163
|
const textareaStyle = {
|
|
@@ -541,23 +170,26 @@ var Textarea = (textareaProps) => {
|
|
|
541
170
|
}
|
|
542
171
|
};
|
|
543
172
|
if (variant === "rich" && richEditorCopy) {
|
|
544
|
-
return /* @__PURE__ */
|
|
545
|
-
|
|
173
|
+
return /* @__PURE__ */ jsx(
|
|
174
|
+
RichVariant,
|
|
546
175
|
{
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
176
|
+
shell: { testId, label, glassLabel, error, helperText },
|
|
177
|
+
editor: {
|
|
178
|
+
copy: richEditorCopy,
|
|
179
|
+
value: richTextValue,
|
|
180
|
+
onChange: setRichTextValue,
|
|
181
|
+
placeholder: props.placeholder,
|
|
182
|
+
error,
|
|
183
|
+
glass,
|
|
184
|
+
color,
|
|
185
|
+
characterLimit: props.maxLength
|
|
186
|
+
}
|
|
555
187
|
}
|
|
556
|
-
)
|
|
188
|
+
);
|
|
557
189
|
}
|
|
558
|
-
return /* @__PURE__ */
|
|
559
|
-
hasIcon && /* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsx(TextareaShell, { testId, label, glassLabel, error, helperText, children: /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
|
|
191
|
+
hasIcon && /* @__PURE__ */ jsx(TextareaIcon, { icon, iconPosition }),
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
561
193
|
StyledTextarea,
|
|
562
194
|
{
|
|
563
195
|
customVariant: variant,
|