@vkzstudio/muza-ui 1.0.34 → 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.
@@ -1,17 +1,19 @@
1
- import { jsx as s, jsxs as k } from "react/jsx-runtime";
2
- import { forwardRef as O, useEffect as _, useImperativeHandle as $, useRef as I } from "react";
3
- import { Link as K } from "../../node_modules/@tiptap/extension-link/dist/index.js";
4
- import { Placeholder as W } from "../../node_modules/@tiptap/extension-placeholder/dist/index.js";
5
- import { useEditor as q, EditorContent as D } from "../../node_modules/@tiptap/react/dist/index.js";
6
- import { StarterKit as G } from "../../node_modules/@tiptap/starter-kit/dist/index.js";
7
- import { cva as J } from "class-variance-authority";
8
- import { EditorToolbar as Q } from "./EditorToolbar.js";
9
- import { LinkBubbleMenu as X } from "./LinkBubbleMenu.js";
10
- import { useLinkEditor as Y } from "./useLinkEditor.js";
11
- import { useMuzaTranslations as Z } from "../../translations/TranslationContext.js";
12
- import { FormField as tt } from "../FormField/FormField.js";
13
- import { cn as b } from "../../utils/cn.js";
14
- const et = J(
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
- ), rt = O(
35
+ ), dt = D(
34
36
  ({
35
- value: i,
36
- defaultValue: g,
37
- onChange: c,
38
- onBlur: y,
39
- onFocus: v,
40
- placeholder: L = "",
41
- label: E,
42
- hint: T,
43
- infoTooltip: C,
44
- disabled: o = !1,
45
- readOnly: d = !1,
46
- required: M,
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: l,
49
- toolbar: n = {},
50
- toolbarExtra: f,
51
- extensions: w = [],
52
- minHeight: z = 200,
53
- maxHeight: a,
54
- resizable: P = !0,
55
- className: R,
56
- contentClassName: U,
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: N
59
- }, S) => {
60
- const p = Z(), m = {
61
- history: n.history ?? !0,
62
- headings: n.headings ?? !0,
63
- formatting: n.formatting ?? !0,
64
- lists: n.lists ?? !0,
65
- link: n.link ?? !0,
66
- clearFormatting: n.clearFormatting ?? !0
67
- }, V = !!f || Object.values(m).some((e) => e !== !1), t = q({
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
- G.configure({
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
- K.configure({
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
- W.configure({
90
- placeholder: ({ editor: e }) => e.state.doc.textContent.length === 0 ? L : ""
93
+ Z.configure({
94
+ placeholder: ({ editor: e }) => e.state.doc.textContent.length === 0 ? E : ""
91
95
  }),
92
- ...w
96
+ ...o != null ? [X.configure({ limit: o, mode: "textSize" })] : [],
97
+ ...N
93
98
  ],
94
- content: i ?? g ?? "",
95
- editable: !o && !d,
99
+ content: n ?? v ?? "",
100
+ editable: !i && !f,
96
101
  onUpdate: ({ editor: e }) => {
97
- const x = e.getText().trim(), h = e.getHTML();
98
- c == null || c(x.length === 0 ? "" : h);
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: y,
101
- onFocus: v,
105
+ onBlur: C,
106
+ onFocus: T,
102
107
  editorProps: {
103
108
  attributes: {
104
- class: b(
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
- N
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 && i !== void 0) {
140
+ u(() => {
141
+ if (t && n !== void 0) {
137
142
  const e = t.getHTML();
138
- (i || "<p></p>") !== (e || "<p></p>") && t.commands.setContent(i, !1);
143
+ (n || "<p></p>") !== (e || "<p></p>") && t.commands.setContent(n, !1);
139
144
  }
140
- }, [t, i]), _(() => {
141
- t && t.setEditable(!o && !d);
142
- }, [t, o, d]), $(
143
- S,
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 = Y(t), u = I(null), j = o ? "disabled" : l ? "error" : "default", A = typeof l == "string" ? l : void 0, B = {
156
- minHeight: `${Math.max(z, 200)}px`,
157
- maxHeight: a ? typeof a == "number" ? `${a}px` : a : void 0,
158
- resize: P && !o ? "vertical" : "none"
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__ */ s("div", { ref: u, children: /* @__PURE__ */ s(
161
- tt,
184
+ return /* @__PURE__ */ l("div", { ref: _, children: /* @__PURE__ */ l(
185
+ at,
162
186
  {
163
- label: E,
164
- hint: A || T,
165
- error: !!l,
166
- required: M,
187
+ label: L,
188
+ hint: I || M,
189
+ error: !!a,
190
+ required: z,
167
191
  disableRequiredAsterisk: H,
168
- className: R,
169
- infoTooltip: C,
170
- children: /* @__PURE__ */ k("div", { className: et({ state: j }), children: [
171
- V && /* @__PURE__ */ s(
172
- Q,
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: o,
177
- translations: p.textEditor,
201
+ disabled: i,
202
+ translations: k.textEditor,
178
203
  onLinkClick: r.handleLinkToolbarClick,
179
- toolbarExtra: f
204
+ toolbarExtra: h
180
205
  }
181
206
  ),
182
- /* @__PURE__ */ k(
207
+ /* @__PURE__ */ p(
183
208
  "div",
184
209
  {
185
- className: b(
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
- U
215
+ V
191
216
  ),
192
- style: B,
217
+ style: q,
193
218
  children: [
194
- /* @__PURE__ */ s(D, { editor: t, className: "h-full w-full" }),
195
- t && m.link && /* @__PURE__ */ s(
196
- X,
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: u,
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: p.textEditor
238
+ translations: k.textEditor
208
239
  }
209
240
  )
210
241
  ]
@@ -215,7 +246,7 @@ const et = J(
215
246
  ) });
216
247
  }
217
248
  );
218
- rt.displayName = "TextEditor";
249
+ dt.displayName = "TextEditor";
219
250
  export {
220
- rt as TextEditor
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,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAA;AAGx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B,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: {