@vkzstudio/muza-ui 1.0.35 → 1.0.36
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/FileUpload/FileItem.d.ts.map +1 -1
- package/dist/components/FileUpload/FileItem.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +83 -62
- package/dist/components/TextEditor/TextEditor.d.ts +4 -0
- package/dist/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/components/TextEditor/TextEditor.js +128 -97
- package/dist/components/TextEditor/TextEditor.stories.d.ts +1 -0
- package/dist/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/components/Textarea/Textarea.js +1 -1
- package/dist/muza-ui.css +1 -1
- package/dist/node_modules/@tiptap/extension-character-count/dist/index.js +73 -0
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["../../../src/components/FileUpload/FileItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA8C9B,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,sEAAsE;IACtE,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC/B,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,KAAK,IA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,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,KAAK,aAAa,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAsEzD,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,4CAoO5C,CAAA"}
|
|
@@ -88,7 +88,7 @@ const D = (e, l, i) => {
|
|
|
88
88
|
secondaryText: g,
|
|
89
89
|
onDelete: y,
|
|
90
90
|
onError: L
|
|
91
|
-
} = e, m = _(), [v, w] = p.useState(!1), N = e.source === "file" ? e.file.name : e.name, b = e.source === "url" ? (e.type ?? "").startsWith("image/") || A.test(e.name) : e.file.type.startsWith("image/"), T = e.source === "url" ? E.includes(e.type ?? "") || z.test(e.name) : E.includes(e.file.type) || z.test(e.file.name), d = e.source === "file" ? e.file : e.url, C = p.useMemo(() => o ? "disabled" : s ? "error" : typeof i == "number" && i > 0 ? "loading" : "default", [o, s, i]), x = p.useMemo(() => {
|
|
91
|
+
} = e, m = _(), [v, w] = p.useState(!1), N = e.source === "file" ? e.file.name : e.name, b = e.source === "url" ? (e.type ?? "").startsWith("image/") || A.test(e.name) : e.file.type.startsWith("image/"), T = e.source === "url" ? E.includes(e.type ?? "") || z.test(e.name) : E.includes(e.file.type) || z.test(e.file.name), d = e.source === "file" ? e.file : e.url, C = p.useMemo(() => o ? "disabled" : s ? "error" : typeof i == "number" && i > 0 && i < 100 ? "loading" : "default", [o, s, i]), x = p.useMemo(() => {
|
|
92
92
|
if (b)
|
|
93
93
|
return typeof d == "string" ? d : URL.createObjectURL(d);
|
|
94
94
|
}, [b, d]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../src/components/MultiSelect/MultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"MultiSelect.d.ts","sourceRo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AgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,eAAO,MAAM,WAAW,6FAiNvB,CAAA"}
|
|
@@ -1,100 +1,121 @@
|
|
|
1
1
|
import { jsx as r, jsxs as u } from "react/jsx-runtime";
|
|
2
|
-
import f, { forwardRef as
|
|
3
|
-
import { triggerWrapperVariants as
|
|
4
|
-
import { useMuzaTranslations as
|
|
2
|
+
import f, { forwardRef as P, useId as _, useMemo as T, useRef as B, useEffect as L } from "react";
|
|
3
|
+
import { triggerWrapperVariants as U } from "../Select/utils.js";
|
|
4
|
+
import { useMuzaTranslations as G } from "../../translations/TranslationContext.js";
|
|
5
5
|
import { Tag as p } from "../Tag/Tag.js";
|
|
6
|
-
import { FormField as
|
|
7
|
-
import { DropdownMenu as
|
|
8
|
-
import { Typography as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
6
|
+
import { FormField as H } from "../FormField/FormField.js";
|
|
7
|
+
import { DropdownMenu as J, DropdownMenuTrigger as K, DropdownMenuContent as Q, DropdownMenuCheckboxItem as X } from "../DropdownMenu/DropdownMenu.js";
|
|
8
|
+
import { Typography as Y } from "../Typography/Typography.js";
|
|
9
|
+
import { Flex as k } from "../Flex/Flex.js";
|
|
10
|
+
import { AltArrowUpOutline as Z } from "@solar-icons/react-perf";
|
|
11
|
+
import { cn as ee } from "../../utils/cn.js";
|
|
12
|
+
const re = P(
|
|
12
13
|
(I, h) => {
|
|
13
|
-
const z =
|
|
14
|
-
label:
|
|
15
|
-
hint:
|
|
14
|
+
const z = G(), {
|
|
15
|
+
label: g,
|
|
16
|
+
hint: x,
|
|
16
17
|
error: b,
|
|
17
18
|
options: o,
|
|
18
|
-
onChange:
|
|
19
|
+
onChange: i,
|
|
19
20
|
value: t,
|
|
20
21
|
disabled: c,
|
|
21
22
|
prefix: d,
|
|
22
|
-
maxNumberOfVisibleTags:
|
|
23
|
+
maxNumberOfVisibleTags: a = 2,
|
|
23
24
|
size: D,
|
|
24
25
|
placeholder: S,
|
|
25
|
-
required:
|
|
26
|
+
required: w,
|
|
26
27
|
disableRequiredAsterisk: W,
|
|
27
|
-
labelExtra:
|
|
28
|
+
labelExtra: j,
|
|
28
29
|
infoTooltip: A,
|
|
29
30
|
collisionPadding: C
|
|
30
|
-
} = I,
|
|
31
|
-
const e = t && t.map((n) =>
|
|
32
|
-
return e != null && e.length ? e.length <=
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
s
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
} = I, v = S ?? z.select.placeholder, N = _(), F = g ? `${N}-label` : void 0, O = x ? `${N}-hint` : void 0, y = T(() => new Map(o.map((e) => [e.value, e.label])), [o]), q = T(() => {
|
|
32
|
+
const e = t && t.map((n) => y.get(n));
|
|
33
|
+
return e != null && e.length ? e.length <= a ? /* @__PURE__ */ r(
|
|
34
|
+
k,
|
|
35
|
+
{
|
|
36
|
+
gap: "xs",
|
|
37
|
+
justify: "start",
|
|
38
|
+
align: "start",
|
|
39
|
+
flex: 1,
|
|
40
|
+
className: "min-w-0",
|
|
41
|
+
children: e.map((n, s) => /* @__PURE__ */ r(p, { variant: "info", className: "min-w-[50px] shrink-1", children: n }, s))
|
|
42
|
+
}
|
|
43
|
+
) : /* @__PURE__ */ r(
|
|
44
|
+
k,
|
|
45
|
+
{
|
|
46
|
+
gap: "xs",
|
|
47
|
+
justify: "start",
|
|
48
|
+
align: "start",
|
|
49
|
+
flex: 1,
|
|
50
|
+
className: "min-w-0",
|
|
51
|
+
children: [
|
|
52
|
+
...e.slice(0, a).map((n, s) => /* @__PURE__ */ r(
|
|
53
|
+
p,
|
|
54
|
+
{
|
|
55
|
+
variant: "info",
|
|
56
|
+
className: "min-w-[50px] shrink-1 overflow-hidden",
|
|
57
|
+
children: /* @__PURE__ */ r("span", { className: "truncate", children: n })
|
|
58
|
+
},
|
|
59
|
+
s
|
|
60
|
+
)),
|
|
61
|
+
/* @__PURE__ */ u(p, { variant: "info", children: [
|
|
62
|
+
e.length - a,
|
|
63
|
+
"+"
|
|
64
|
+
] }, "more")
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
) : /* @__PURE__ */ r(
|
|
68
|
+
Y,
|
|
48
69
|
{
|
|
49
70
|
size: "input",
|
|
50
71
|
className: "grow-1 fix-y-text truncate text-left text-comp-select-text-placeholder",
|
|
51
72
|
weight: "regular",
|
|
52
73
|
component: "span",
|
|
53
|
-
children:
|
|
74
|
+
children: v
|
|
54
75
|
}
|
|
55
76
|
);
|
|
56
|
-
}, [t,
|
|
57
|
-
return
|
|
77
|
+
}, [t, v, a, y]), [M, E] = f.useState(!1), [R, V] = f.useState(0), m = f.useRef(!1), $ = B(null), l = (typeof h == "function" ? null : h) ?? $;
|
|
78
|
+
return L(() => {
|
|
58
79
|
const e = () => {
|
|
59
|
-
|
|
80
|
+
l.current && V(l.current.offsetWidth);
|
|
60
81
|
};
|
|
61
82
|
e();
|
|
62
83
|
const n = new ResizeObserver(e);
|
|
63
|
-
return
|
|
84
|
+
return l.current && n.observe(l.current), () => {
|
|
64
85
|
n.disconnect();
|
|
65
86
|
};
|
|
66
|
-
}, [
|
|
67
|
-
|
|
87
|
+
}, [l]), /* @__PURE__ */ r(
|
|
88
|
+
H,
|
|
68
89
|
{
|
|
69
|
-
label:
|
|
70
|
-
hint:
|
|
90
|
+
label: g,
|
|
91
|
+
hint: x,
|
|
71
92
|
error: b,
|
|
72
|
-
required:
|
|
93
|
+
required: w,
|
|
73
94
|
disableRequiredAsterisk: W,
|
|
74
|
-
labelId:
|
|
75
|
-
hintId:
|
|
76
|
-
labelExtra:
|
|
95
|
+
labelId: F,
|
|
96
|
+
hintId: O,
|
|
97
|
+
labelExtra: j,
|
|
77
98
|
infoTooltip: A,
|
|
78
99
|
children: /* @__PURE__ */ u(
|
|
79
|
-
|
|
100
|
+
J,
|
|
80
101
|
{
|
|
81
102
|
onOpenChange: (e) => {
|
|
82
103
|
E(e);
|
|
83
104
|
},
|
|
84
105
|
children: [
|
|
85
|
-
/* @__PURE__ */ r(
|
|
106
|
+
/* @__PURE__ */ r(K, { disabled: c, asChild: !0, children: /* @__PURE__ */ r(
|
|
86
107
|
"button",
|
|
87
108
|
{
|
|
88
|
-
ref:
|
|
109
|
+
ref: l,
|
|
89
110
|
type: "button",
|
|
90
111
|
role: "input",
|
|
91
112
|
tabIndex: 0,
|
|
92
113
|
disabled: c,
|
|
93
|
-
"aria-required":
|
|
94
|
-
className:
|
|
114
|
+
"aria-required": w,
|
|
115
|
+
className: U({
|
|
95
116
|
size: D,
|
|
96
117
|
error: b,
|
|
97
|
-
expanded:
|
|
118
|
+
expanded: M,
|
|
98
119
|
hasIcon: !!d || (t == null ? void 0 : t.length) === 0
|
|
99
120
|
}),
|
|
100
121
|
children: /* @__PURE__ */ u("div", { className: "flex min-w-0 flex-1 items-center gap-sm", children: [
|
|
@@ -107,11 +128,11 @@ const ee = $(
|
|
|
107
128
|
),
|
|
108
129
|
q,
|
|
109
130
|
/* @__PURE__ */ r(
|
|
110
|
-
|
|
131
|
+
Z,
|
|
111
132
|
{
|
|
112
|
-
className:
|
|
113
|
-
"transition-transform duration-200",
|
|
114
|
-
|
|
133
|
+
className: ee(
|
|
134
|
+
"shrink-0 transition-transform duration-200",
|
|
135
|
+
M ? "rotate-0" : "rotate-180"
|
|
115
136
|
)
|
|
116
137
|
}
|
|
117
138
|
)
|
|
@@ -119,7 +140,7 @@ const ee = $(
|
|
|
119
140
|
}
|
|
120
141
|
) }),
|
|
121
142
|
/* @__PURE__ */ r(
|
|
122
|
-
|
|
143
|
+
Q,
|
|
123
144
|
{
|
|
124
145
|
className: "mt-1",
|
|
125
146
|
style: {
|
|
@@ -130,13 +151,13 @@ const ee = $(
|
|
|
130
151
|
},
|
|
131
152
|
collisionPadding: C,
|
|
132
153
|
children: o.map((e) => /* @__PURE__ */ r(
|
|
133
|
-
|
|
154
|
+
X,
|
|
134
155
|
{
|
|
135
156
|
checked: t == null ? void 0 : t.includes(e.value),
|
|
136
157
|
disabled: e.disabled,
|
|
137
158
|
icon: e.icon,
|
|
138
159
|
onCheckedChange: (n) => {
|
|
139
|
-
n ?
|
|
160
|
+
n ? i == null || i([...t || [], e.value]) : i == null || i((t || []).filter((s) => s !== e.value)), m.current = !0;
|
|
140
161
|
},
|
|
141
162
|
children: e.label
|
|
142
163
|
},
|
|
@@ -151,7 +172,7 @@ const ee = $(
|
|
|
151
172
|
);
|
|
152
173
|
}
|
|
153
174
|
);
|
|
154
|
-
|
|
175
|
+
re.displayName = "MultiSelect";
|
|
155
176
|
export {
|
|
156
|
-
|
|
177
|
+
re as MultiSelect
|
|
157
178
|
};
|
|
@@ -135,6 +135,10 @@ export interface TextEditorProps {
|
|
|
135
135
|
unstyled?: boolean;
|
|
136
136
|
/** Additional class name for the TipTap editor element */
|
|
137
137
|
editorClassName?: string;
|
|
138
|
+
/** Maximum character count. Blocks input past this limit and enables the counter when `showCharacterCount` is true. */
|
|
139
|
+
maxLength?: number;
|
|
140
|
+
/** Displays a character counter (currentCount/maxLength) in the label row. Requires `maxLength` to be set. @default false */
|
|
141
|
+
showCharacterCount?: boolean;
|
|
138
142
|
}
|
|
139
143
|
declare const TextEditor: import('react').ForwardRefExoticComponent<TextEditorProps & import('react').RefAttributes<TextEditorRef>>;
|
|
140
144
|
export { TextEditor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/TextEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/TextEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,Y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AgB,CAAC,EAAE,MAAM,CAAA;IACzB,uGAAuG;IACvG,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uHAAuH;IACvH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6HAA6H;IAC7H,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAwBD,QAAA,MAAM,UAAU,2GA6Qf,CAAA;AAID,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
import { jsxs as p, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as D, useState as G, useEffect as u, useImperativeHandle as J, useRef as Q } from "react";
|
|
3
|
+
import { CharacterCount as X } from "../../node_modules/@tiptap/extension-character-count/dist/index.js";
|
|
4
|
+
import { Link as Y } from "../../node_modules/@tiptap/extension-link/dist/index.js";
|
|
5
|
+
import { Placeholder as Z } from "../../node_modules/@tiptap/extension-placeholder/dist/index.js";
|
|
6
|
+
import { useEditor as tt, EditorContent as et } from "../../node_modules/@tiptap/react/dist/index.js";
|
|
7
|
+
import { StarterKit as rt } from "../../node_modules/@tiptap/starter-kit/dist/index.js";
|
|
8
|
+
import { cva as ot } from "class-variance-authority";
|
|
9
|
+
import { EditorToolbar as nt } from "./EditorToolbar.js";
|
|
10
|
+
import { LinkBubbleMenu as it } from "./LinkBubbleMenu.js";
|
|
11
|
+
import { useLinkEditor as st } from "./useLinkEditor.js";
|
|
12
|
+
import { useMuzaTranslations as lt } from "../../translations/TranslationContext.js";
|
|
13
|
+
import { FormField as at } from "../FormField/FormField.js";
|
|
14
|
+
import { cn as x } from "../../utils/cn.js";
|
|
15
|
+
import { typographyVariants as ct } from "../Typography/Typography.js";
|
|
16
|
+
const mt = ot(
|
|
15
17
|
[
|
|
16
18
|
"overflow-hidden rounded-xl border bg-surface-base-secondary transition-colors",
|
|
17
19
|
"focus-within:border-comp-input-stroke-focused",
|
|
@@ -23,50 +25,52 @@ const et = J(
|
|
|
23
25
|
state: {
|
|
24
26
|
default: "border-comp-input-stroke-def hover:border-comp-input-stroke-hover",
|
|
25
27
|
disabled: "cursor-not-allowed border-comp-input-stroke-disabled opacity-60",
|
|
26
|
-
error: "border-comp-input-stroke-error"
|
|
28
|
+
error: "border-comp-input-stroke-error-def"
|
|
27
29
|
}
|
|
28
30
|
},
|
|
29
31
|
defaultVariants: {
|
|
30
32
|
state: "default"
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
),
|
|
35
|
+
), dt = D(
|
|
34
36
|
({
|
|
35
|
-
value:
|
|
36
|
-
defaultValue:
|
|
37
|
-
onChange:
|
|
38
|
-
onBlur:
|
|
39
|
-
onFocus:
|
|
40
|
-
placeholder:
|
|
41
|
-
label:
|
|
42
|
-
hint:
|
|
43
|
-
infoTooltip:
|
|
44
|
-
disabled:
|
|
45
|
-
readOnly:
|
|
46
|
-
required:
|
|
37
|
+
value: n,
|
|
38
|
+
defaultValue: v,
|
|
39
|
+
onChange: d,
|
|
40
|
+
onBlur: C,
|
|
41
|
+
onFocus: T,
|
|
42
|
+
placeholder: E = "",
|
|
43
|
+
label: L,
|
|
44
|
+
hint: M,
|
|
45
|
+
infoTooltip: w,
|
|
46
|
+
disabled: i = !1,
|
|
47
|
+
readOnly: f = !1,
|
|
48
|
+
required: z,
|
|
47
49
|
disableRequiredAsterisk: H,
|
|
48
|
-
error:
|
|
49
|
-
toolbar:
|
|
50
|
-
toolbarExtra:
|
|
51
|
-
extensions:
|
|
52
|
-
minHeight:
|
|
53
|
-
maxHeight:
|
|
54
|
-
resizable:
|
|
55
|
-
className:
|
|
56
|
-
contentClassName:
|
|
50
|
+
error: a,
|
|
51
|
+
toolbar: s = {},
|
|
52
|
+
toolbarExtra: h,
|
|
53
|
+
extensions: N = [],
|
|
54
|
+
minHeight: R = 200,
|
|
55
|
+
maxHeight: c,
|
|
56
|
+
resizable: S = !0,
|
|
57
|
+
className: U,
|
|
58
|
+
contentClassName: V,
|
|
57
59
|
unstyled: F = !1,
|
|
58
|
-
editorClassName:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
editorClassName: P,
|
|
61
|
+
maxLength: o,
|
|
62
|
+
showCharacterCount: j
|
|
63
|
+
}, A) => {
|
|
64
|
+
const k = lt(), [B, y] = G(0), m = {
|
|
65
|
+
history: s.history ?? !0,
|
|
66
|
+
headings: s.headings ?? !0,
|
|
67
|
+
formatting: s.formatting ?? !0,
|
|
68
|
+
lists: s.lists ?? !0,
|
|
69
|
+
link: s.link ?? !0,
|
|
70
|
+
clearFormatting: s.clearFormatting ?? !0
|
|
71
|
+
}, O = !!h || Object.values(m).some((e) => e !== !1), t = tt({
|
|
68
72
|
extensions: [
|
|
69
|
-
|
|
73
|
+
rt.configure({
|
|
70
74
|
heading: { levels: [1, 2, 3] },
|
|
71
75
|
bulletList: {
|
|
72
76
|
HTMLAttributes: { class: "list-disc ml-6" }
|
|
@@ -76,7 +80,7 @@ const et = J(
|
|
|
76
80
|
}
|
|
77
81
|
}),
|
|
78
82
|
...m.link ? [
|
|
79
|
-
|
|
83
|
+
Y.configure({
|
|
80
84
|
openOnClick: !1,
|
|
81
85
|
autolink: !0,
|
|
82
86
|
linkOnPaste: !0,
|
|
@@ -86,22 +90,23 @@ const et = J(
|
|
|
86
90
|
}
|
|
87
91
|
})
|
|
88
92
|
] : [],
|
|
89
|
-
|
|
90
|
-
placeholder: ({ editor: e }) => e.state.doc.textContent.length === 0 ?
|
|
93
|
+
Z.configure({
|
|
94
|
+
placeholder: ({ editor: e }) => e.state.doc.textContent.length === 0 ? E : ""
|
|
91
95
|
}),
|
|
92
|
-
...
|
|
96
|
+
...o != null ? [X.configure({ limit: o, mode: "textSize" })] : [],
|
|
97
|
+
...N
|
|
93
98
|
],
|
|
94
|
-
content:
|
|
95
|
-
editable: !
|
|
99
|
+
content: n ?? v ?? "",
|
|
100
|
+
editable: !i && !f,
|
|
96
101
|
onUpdate: ({ editor: e }) => {
|
|
97
|
-
const
|
|
98
|
-
|
|
102
|
+
const b = e.getText().trim(), g = e.getHTML();
|
|
103
|
+
o != null && y(e.storage.characterCount.characters()), d == null || d(b.length === 0 ? "" : g);
|
|
99
104
|
},
|
|
100
|
-
onBlur:
|
|
101
|
-
onFocus:
|
|
105
|
+
onBlur: C,
|
|
106
|
+
onFocus: T,
|
|
102
107
|
editorProps: {
|
|
103
108
|
attributes: {
|
|
104
|
-
class:
|
|
109
|
+
class: x(
|
|
105
110
|
"outline-none text-sm",
|
|
106
111
|
!F && [
|
|
107
112
|
// Headings
|
|
@@ -123,7 +128,7 @@ const et = J(
|
|
|
123
128
|
],
|
|
124
129
|
// Placeholder (only when the entire editor is empty — controlled via placeholder function)
|
|
125
130
|
"[&_.is-empty]:before:content-[attr(data-placeholder)] [&_.is-empty]:before:text-comp-input-text-placeholder [&_.is-empty]:before:float-left [&_.is-empty]:before:h-0 [&_.is-empty]:before:pointer-events-none",
|
|
126
|
-
|
|
131
|
+
P
|
|
127
132
|
),
|
|
128
133
|
// Inline styles needed because Tailwind CSS 4 JIT doesn't apply to dynamically created elements
|
|
129
134
|
style: "width: 100%; min-height: 100%; max-width: none;",
|
|
@@ -132,15 +137,17 @@ const et = J(
|
|
|
132
137
|
}
|
|
133
138
|
}
|
|
134
139
|
});
|
|
135
|
-
|
|
136
|
-
if (t &&
|
|
140
|
+
u(() => {
|
|
141
|
+
if (t && n !== void 0) {
|
|
137
142
|
const e = t.getHTML();
|
|
138
|
-
(
|
|
143
|
+
(n || "<p></p>") !== (e || "<p></p>") && t.commands.setContent(n, !1);
|
|
139
144
|
}
|
|
140
|
-
}, [t,
|
|
141
|
-
t && t.setEditable(!
|
|
142
|
-
}, [t,
|
|
143
|
-
|
|
145
|
+
}, [t, n]), u(() => {
|
|
146
|
+
t && t.setEditable(!i && !f);
|
|
147
|
+
}, [t, i, f]), u(() => {
|
|
148
|
+
t && o != null && y(t.storage.characterCount.characters());
|
|
149
|
+
}, [t, o, n]), J(
|
|
150
|
+
A,
|
|
144
151
|
() => ({
|
|
145
152
|
editor: t,
|
|
146
153
|
focus: () => t == null ? void 0 : t.commands.focus(),
|
|
@@ -152,51 +159,75 @@ const et = J(
|
|
|
152
159
|
}),
|
|
153
160
|
[t]
|
|
154
161
|
);
|
|
155
|
-
const r =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
const r = st(t), _ = Q(null), $ = i ? "disabled" : a ? "error" : "default", I = typeof a == "string" ? a : void 0, K = `${Math.max(R, 200)}px`, W = j && o != null ? /* @__PURE__ */ p(
|
|
163
|
+
"span",
|
|
164
|
+
{
|
|
165
|
+
className: x(
|
|
166
|
+
ct({
|
|
167
|
+
variant: "body",
|
|
168
|
+
weight: "regular",
|
|
169
|
+
size: "sm"
|
|
170
|
+
}),
|
|
171
|
+
"text-comp-input-text-secondary"
|
|
172
|
+
),
|
|
173
|
+
children: [
|
|
174
|
+
B,
|
|
175
|
+
"/",
|
|
176
|
+
o
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
) : void 0, q = {
|
|
180
|
+
minHeight: K,
|
|
181
|
+
maxHeight: c ? typeof c == "number" ? `${c}px` : c : void 0,
|
|
182
|
+
resize: S && !i ? "vertical" : "none"
|
|
159
183
|
};
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
|
|
184
|
+
return /* @__PURE__ */ l("div", { ref: _, children: /* @__PURE__ */ l(
|
|
185
|
+
at,
|
|
162
186
|
{
|
|
163
|
-
label:
|
|
164
|
-
hint:
|
|
165
|
-
error: !!
|
|
166
|
-
required:
|
|
187
|
+
label: L,
|
|
188
|
+
hint: I || M,
|
|
189
|
+
error: !!a,
|
|
190
|
+
required: z,
|
|
167
191
|
disableRequiredAsterisk: H,
|
|
168
|
-
className:
|
|
169
|
-
infoTooltip:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
192
|
+
className: U,
|
|
193
|
+
infoTooltip: w,
|
|
194
|
+
labelRight: W,
|
|
195
|
+
children: /* @__PURE__ */ p("div", { className: mt({ state: $ }), children: [
|
|
196
|
+
O && /* @__PURE__ */ l(
|
|
197
|
+
nt,
|
|
173
198
|
{
|
|
174
199
|
editor: t,
|
|
175
200
|
toolbarConfig: m,
|
|
176
|
-
disabled:
|
|
177
|
-
translations:
|
|
201
|
+
disabled: i,
|
|
202
|
+
translations: k.textEditor,
|
|
178
203
|
onLinkClick: r.handleLinkToolbarClick,
|
|
179
|
-
toolbarExtra:
|
|
204
|
+
toolbarExtra: h
|
|
180
205
|
}
|
|
181
206
|
),
|
|
182
|
-
/* @__PURE__ */
|
|
207
|
+
/* @__PURE__ */ p(
|
|
183
208
|
"div",
|
|
184
209
|
{
|
|
185
|
-
className:
|
|
186
|
-
"relative overflow-auto px-2xl py-xl",
|
|
210
|
+
className: x(
|
|
211
|
+
"relative flex flex-col overflow-auto px-2xl py-xl",
|
|
187
212
|
"mr-[calc(var(--spacing-xl)/2)]",
|
|
188
213
|
"pr-[calc(var(--spacing-2xl)-var(--spacing-xl)/2)]",
|
|
189
214
|
// Compensate for scrollbar offset
|
|
190
|
-
|
|
215
|
+
V
|
|
191
216
|
),
|
|
192
|
-
style:
|
|
217
|
+
style: q,
|
|
193
218
|
children: [
|
|
194
|
-
/* @__PURE__ */
|
|
195
|
-
|
|
196
|
-
|
|
219
|
+
/* @__PURE__ */ l(
|
|
220
|
+
et,
|
|
221
|
+
{
|
|
222
|
+
editor: t,
|
|
223
|
+
className: "flex w-full flex-1 [&_div]:grow-1"
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
t && m.link && /* @__PURE__ */ l(
|
|
227
|
+
it,
|
|
197
228
|
{
|
|
198
229
|
editor: t,
|
|
199
|
-
containerRef:
|
|
230
|
+
containerRef: _,
|
|
200
231
|
linkUrl: r.linkUrl,
|
|
201
232
|
isEditingLink: r.isEditingLink,
|
|
202
233
|
onUrlChange: r.setLinkUrl,
|
|
@@ -204,7 +235,7 @@ const et = J(
|
|
|
204
235
|
onSave: r.handleSaveLink,
|
|
205
236
|
onRemove: r.handleRemoveLink,
|
|
206
237
|
onCancel: r.handleCancelEdit,
|
|
207
|
-
translations:
|
|
238
|
+
translations: k.textEditor
|
|
208
239
|
}
|
|
209
240
|
)
|
|
210
241
|
]
|
|
@@ -215,7 +246,7 @@ const et = J(
|
|
|
215
246
|
) });
|
|
216
247
|
}
|
|
217
248
|
);
|
|
218
|
-
|
|
249
|
+
dt.displayName = "TextEditor";
|
|
219
250
|
export {
|
|
220
|
-
|
|
251
|
+
dt as TextEditor
|
|
221
252
|
};
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof TextEditor>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof TextEditor>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
+
export declare const WithCharacterCounter: Story;
|
|
7
8
|
export declare const Controlled: Story;
|
|
8
9
|
export declare const WithFormIntegration: Story;
|
|
9
10
|
export declare const AllStates: Story;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/TextEditor.stories.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAO3D,OAAO,EACL,UAAU,EAIX,MAAM,SAAS,CAAA;AAEhB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAgIjC,CAAA;AAED,eAA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AAA;AAGD,eAAO,MAAM,mBAAmB,EAAE,KAmCjC,CAAA;AAGD,eAAO,MAAM,SAAS,EAAE,KA6DvB,CAAA;AAGD,eAAO,MAAM,kBAAkB,EAAE,KAsBhC,CAAA;AAGD,eAAO,MAAM,cAAc,EAAE,KAsB5B,CAAA;AAGD,eAAO,MAAM,gBAAgB,EAAE,KAsC9B,CAAA;AAGD,eAAO,MAAM,YAAY,EAAE,KAmC1B,CAAA;AAGD,eAAO,MAAM,mBAAmB,EAAE,KAsCjC,CAAA;AAqKD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,KAwD1B,CAAA;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,EAAE,KA0DjC,CAAA;AAGD,eAAO,MAAM,QAAQ,EAAE,KA6CtB,CAAA;AAGD,eAAO,MAAM,mBAAmB,EAAE,KA0CjC,CAAA"}
|
|
@@ -49,7 +49,7 @@ const E = x(
|
|
|
49
49
|
state: {
|
|
50
50
|
default: "border-comp-input-stroke-def hover:border-comp-input-stroke-hover",
|
|
51
51
|
disabled: "cursor-not-allowed border-comp-input-stroke-disabled bg-comp-input-fill-disabled",
|
|
52
|
-
error: "border-comp-input-stroke-error"
|
|
52
|
+
error: "border-comp-input-stroke-error-def"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
defaultVariants: {
|