@forgedevstack/bear 1.1.0 → 1.1.3

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.
Files changed (60) hide show
  1. package/dist/components/AlertDialog/AlertDialog.cjs +1 -0
  2. package/dist/components/AlertDialog/AlertDialog.const.cjs +1 -0
  3. package/dist/components/AlertDialog/AlertDialog.const.d.ts +5 -0
  4. package/dist/components/AlertDialog/AlertDialog.const.js +8 -0
  5. package/dist/components/AlertDialog/AlertDialog.d.ts +4 -0
  6. package/dist/components/AlertDialog/AlertDialog.js +107 -0
  7. package/dist/components/AlertDialog/AlertDialog.types.d.ts +34 -0
  8. package/dist/components/AlertDialog/index.d.ts +3 -0
  9. package/dist/components/AspectRatio/AspectRatio.cjs +1 -0
  10. package/dist/components/AspectRatio/AspectRatio.d.ts +3 -0
  11. package/dist/components/AspectRatio/AspectRatio.js +29 -0
  12. package/dist/components/AspectRatio/AspectRatio.types.d.ts +9 -0
  13. package/dist/components/AspectRatio/index.d.ts +2 -0
  14. package/dist/components/Button/Button.cjs +1 -1
  15. package/dist/components/Button/Button.constants.cjs +2 -2
  16. package/dist/components/Button/Button.constants.d.ts +1 -0
  17. package/dist/components/Button/Button.constants.js +10 -3
  18. package/dist/components/Button/Button.js +92 -84
  19. package/dist/components/Button/Button.types.d.ts +2 -0
  20. package/dist/components/FormField/FormField.cjs +1 -0
  21. package/dist/components/FormField/FormField.const.cjs +1 -0
  22. package/dist/components/FormField/FormField.const.d.ts +20 -0
  23. package/dist/components/FormField/FormField.const.js +23 -0
  24. package/dist/components/FormField/FormField.d.ts +3 -0
  25. package/dist/components/FormField/FormField.js +127 -0
  26. package/dist/components/FormField/FormField.types.d.ts +23 -0
  27. package/dist/components/FormField/index.d.ts +2 -0
  28. package/dist/components/Input/Input.cjs +1 -1
  29. package/dist/components/Input/Input.js +81 -44
  30. package/dist/components/Input/Input.types.d.ts +10 -0
  31. package/dist/components/Input/components/ClearIcon/ClearIcon.cjs +1 -0
  32. package/dist/components/Input/components/ClearIcon/ClearIcon.d.ts +7 -0
  33. package/dist/components/Input/components/ClearIcon/ClearIcon.js +25 -0
  34. package/dist/components/Input/components/ClearIcon/index.d.ts +1 -0
  35. package/dist/components/InputGroup/InputGroup.cjs +1 -0
  36. package/dist/components/InputGroup/InputGroup.d.ts +4 -0
  37. package/dist/components/InputGroup/InputGroup.js +63 -0
  38. package/dist/components/InputGroup/InputGroup.types.d.ts +23 -0
  39. package/dist/components/InputGroup/index.d.ts +2 -0
  40. package/dist/components/PasswordInput/PasswordInput.cjs +1 -0
  41. package/dist/components/PasswordInput/PasswordInput.d.ts +3 -0
  42. package/dist/components/PasswordInput/PasswordInput.js +61 -0
  43. package/dist/components/PasswordInput/PasswordInput.types.d.ts +18 -0
  44. package/dist/components/PasswordInput/index.d.ts +2 -0
  45. package/dist/components/ResizableTextarea/ResizableTextarea.cjs +1 -1
  46. package/dist/components/ResizableTextarea/ResizableTextarea.js +90 -54
  47. package/dist/components/ResizableTextarea/ResizableTextarea.types.d.ts +10 -0
  48. package/dist/components/RichEditor/RichEditor.cjs +1 -1
  49. package/dist/components/RichEditor/RichEditor.js +186 -169
  50. package/dist/components/RichEditor/RichEditor.types.d.ts +4 -0
  51. package/dist/components/Typewriter/Typewriter.cjs +1 -1
  52. package/dist/components/Typewriter/Typewriter.js +59 -65
  53. package/dist/components/index.cjs +1 -1
  54. package/dist/components/index.d.ts +10 -0
  55. package/dist/components/index.js +44 -34
  56. package/dist/index.cjs +1 -1
  57. package/dist/index.js +126 -116
  58. package/dist/styles.css +1 -1
  59. package/dist/types/component.types.d.ts +13 -0
  60. package/package.json +1 -4
@@ -1,173 +1,176 @@
1
- import { jsxs as Re, jsx as t } from "react/jsx-runtime";
2
- import { useRef as Te, useState as I, useEffect as y, useCallback as d } from "react";
3
- import { cn as R } from "../../utils/cn.js";
4
- import { getActiveFormats as be, queryCommandValue as _e, execCommand as u, insertLink as Ee, setTextColor as x, setHighlightColor as A, fileToDataUrl as S, insertImage as v } from "./helpers/formatHelpers.js";
5
- import { RICH_EDITOR_MIN_HEIGHT as ye, RICH_EDITOR_DEFAULT_TOOLBAR as Le, RICH_EDITOR_CONTENT_STYLES as He, RICH_EDITOR_BUTTON_CONFIG as B, RICH_EDITOR_MOBILE_TOOLBAR as Oe, RICH_EDITOR_TOOLBAR_CLASSES as ze, RICH_EDITOR_CONTENT_CLASSES as ke, RICH_EDITOR_ROOT_CLASSES as xe, RICH_EDITOR_DIVIDER_CLASSES as Ae, RICH_EDITOR_HEADING_OPTIONS as Se, RICH_EDITOR_MOBILE_MORE_ITEMS as ve, RICH_EDITOR_MOBILE_BREAKPOINT as Be } from "./RichEditor.const.js";
6
- import { useMediaQuery as De } from "../../hooks/useMediaQuery.js";
1
+ import { jsxs as S, jsx as t } from "react/jsx-runtime";
2
+ import { useRef as ye, useState as C, useEffect as x, useCallback as d } from "react";
3
+ import { cn as p } from "../../utils/cn.js";
4
+ import { getActiveFormats as Le, queryCommandValue as xe, execCommand as u, insertLink as He, setTextColor as B, setHighlightColor as D, fileToDataUrl as N, insertImage as F } from "./helpers/formatHelpers.js";
5
+ import { RICH_EDITOR_MIN_HEIGHT as Oe, RICH_EDITOR_DEFAULT_TOOLBAR as ke, RICH_EDITOR_CONTENT_STYLES as ze, RICH_EDITOR_BUTTON_CONFIG as M, RICH_EDITOR_MOBILE_TOOLBAR as ve, RICH_EDITOR_TOOLBAR_CLASSES as Ae, RICH_EDITOR_CONTENT_CLASSES as Se, RICH_EDITOR_ROOT_CLASSES as Be, RICH_EDITOR_DIVIDER_CLASSES as De, RICH_EDITOR_HEADING_OPTIONS as Ne, RICH_EDITOR_MOBILE_MORE_ITEMS as Fe, RICH_EDITOR_MOBILE_BREAKPOINT as Me } from "./RichEditor.const.js";
6
+ import { useMediaQuery as we } from "../../hooks/useMediaQuery.js";
7
7
  import { ToolbarButton as f } from "./components/ToolbarButton/ToolbarButton.js";
8
- import { ToolbarDropdown as Ne } from "./components/ToolbarDropdown/ToolbarDropdown.js";
9
- import { ToolbarColorPicker as D } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
10
- import { ToolbarMore as Fe } from "./components/ToolbarMore/ToolbarMore.js";
11
- import { TextIcon as Me, InsertLinkIcon as N, InsertPhotoIcon as F, AlignLeftIcon as M, AlignCenterIcon as w, AlignRightIcon as U, AlignJustifyIcon as V, IndentIncreaseIcon as P, IndentDecreaseIcon as j, FormatClearIcon as J, TableIcon as we, CodeIcon as Ue, QuoteIcon as Ve, ListNumberedIcon as Pe, ListBulletIcon as je, Heading3Icon as Je, Heading2Icon as $e, Heading1Icon as qe, StrikethroughIcon as Ge, UnderlineIcon as Ke, ItalicIcon as Qe, BoldIcon as Ye } from "../Icon/icons/editor.js";
12
- const We = 6, ct = ($) => {
8
+ import { ToolbarDropdown as Ue } from "./components/ToolbarDropdown/ToolbarDropdown.js";
9
+ import { ToolbarColorPicker as w } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
10
+ import { ToolbarMore as Ve } from "./components/ToolbarMore/ToolbarMore.js";
11
+ import { TextIcon as Pe, InsertLinkIcon as U, InsertPhotoIcon as V, AlignLeftIcon as P, AlignCenterIcon as j, AlignRightIcon as J, AlignJustifyIcon as $, IndentIncreaseIcon as q, IndentDecreaseIcon as G, FormatClearIcon as K, TableIcon as je, CodeIcon as Je, QuoteIcon as $e, ListNumberedIcon as qe, ListBulletIcon as Ge, Heading3Icon as Ke, Heading2Icon as Qe, Heading1Icon as Ye, StrikethroughIcon as We, UnderlineIcon as Xe, ItalicIcon as Ze, BoldIcon as et } from "../Icon/icons/editor.js";
12
+ const tt = 6, gt = (Q) => {
13
13
  const {
14
- value: C,
15
- defaultValue: L = "",
16
- onChange: T,
17
- placeholder: q = "Start typing...",
18
- disabled: i = !1,
14
+ value: I,
15
+ defaultValue: H = "",
16
+ onChange: R,
17
+ placeholder: Y = "Start typing...",
18
+ disabled: r = !1,
19
19
  readOnly: o = !1,
20
- minHeight: b = ye,
20
+ minHeight: T = Oe,
21
21
  maxHeight: m,
22
- toolbar: G = Le,
23
- className: K = "",
24
- testId: Q,
25
- id: Y,
26
- allowImagePaste: H = !0,
27
- ...W
28
- } = $, a = Te(null), _ = De(`(max-width: ${Be}px)`), O = _ ? Oe : G, [X, Z] = I(/* @__PURE__ */ new Set()), [ee, z] = I("p"), [te, ne] = I("#000000"), [ie, oe] = I("#fef08a"), [re, le] = I([]), [ae, se] = I([]);
29
- y(() => {
22
+ toolbar: W = ke,
23
+ className: X = "",
24
+ testId: Z,
25
+ id: ee,
26
+ allowImagePaste: O = !0,
27
+ showCharCount: _ = !1,
28
+ charCountMax: E,
29
+ ...te
30
+ } = Q, l = ye(null), y = we(`(max-width: ${Me}px)`), k = y ? ve : W, [ne, re] = C(/* @__PURE__ */ new Set()), [oe, z] = C("p"), [v, ie] = C(0), [ae, le] = C("#000000"), [se, ce] = C("#fef08a"), [de, ue] = C([]), [fe, ge] = C([]);
31
+ x(() => {
30
32
  const e = "bear-rich-editor-styles";
31
33
  if (!document.getElementById(e)) {
32
34
  const n = document.createElement("style");
33
- n.id = e, n.textContent = He, document.head.appendChild(n);
35
+ n.id = e, n.textContent = ze, document.head.appendChild(n);
34
36
  }
35
- }, []), y(() => {
36
- a.current && C !== void 0 && a.current.innerHTML !== C && (a.current.innerHTML = C);
37
- }, [C]), y(() => {
38
- a.current && L && !C && (a.current.innerHTML = L);
37
+ }, []), x(() => {
38
+ l.current && I !== void 0 && l.current.innerHTML !== I && (l.current.innerHTML = I);
39
+ }, [I]), x(() => {
40
+ l.current && H && !I && (l.current.innerHTML = H);
39
41
  }, []);
40
42
  const h = d(() => {
41
- Z(be());
42
- const e = _e("formatBlock");
43
+ re(Le());
44
+ const e = xe("formatBlock");
43
45
  e && z(e.toLowerCase().replace(/[<>]/g, ""));
44
- }, []), l = d(() => {
45
- a.current && T && T(a.current.innerHTML), h();
46
- }, [T, h]), ce = d((e) => {
46
+ }, []), a = d(() => {
47
+ var e;
48
+ l.current && (R && R(l.current.innerHTML), _ && ie(((e = l.current.textContent) == null ? void 0 : e.length) ?? 0)), h();
49
+ }, [R, h, _]), he = d((e) => {
47
50
  var s;
48
- if (i || o) return;
49
- (s = a.current) == null || s.focus();
50
- const n = B[e];
51
+ if (r || o) return;
52
+ (s = l.current) == null || s.focus();
53
+ const n = M[e];
51
54
  if (!n) return;
52
55
  const c = "value" in n ? n.value : void 0;
53
- c ? u(n.command, c) : u(n.command), h(), l();
54
- }, [i, o, h, l]), de = d((e) => {
56
+ c ? u(n.command, c) : u(n.command), h(), a();
57
+ }, [r, o, h, a]), Ce = d((e) => {
55
58
  var n;
56
- i || o || ((n = a.current) == null || n.focus(), u("formatBlock", e), z(e), l());
57
- }, [i, o, l]), ue = d(() => {
59
+ r || o || ((n = l.current) == null || n.focus(), u("formatBlock", e), z(e), a());
60
+ }, [r, o, a]), Ie = d(() => {
58
61
  var s;
59
- if (i || o) return;
62
+ if (r || o) return;
60
63
  const e = window.getSelection(), n = e && e.toString().length > 0, c = prompt("Enter URL:", n ? "" : "https://");
61
- c && ((s = a.current) == null || s.focus(), Ee(c), l());
62
- }, [i, o, l]), p = d((e, n) => {
64
+ c && ((s = l.current) == null || s.focus(), He(c), a());
65
+ }, [r, o, a]), b = d((e, n) => {
63
66
  if (!e) return;
64
- (n === "text" ? le : se)((s) => {
65
- const r = s.filter((g) => g !== e);
66
- return [e, ...r].slice(0, We);
67
+ (n === "text" ? ue : ge)((s) => {
68
+ const i = s.filter((g) => g !== e);
69
+ return [e, ...i].slice(0, tt);
67
70
  });
68
- }, []), fe = d((e) => {
71
+ }, []), me = d((e) => {
69
72
  var n;
70
- i || o || ((n = a.current) == null || n.focus(), x(e), ne(e), p(e, "text"), l());
71
- }, [i, o, l, p]), ge = d((e) => {
73
+ r || o || ((n = l.current) == null || n.focus(), B(e), le(e), b(e, "text"), a());
74
+ }, [r, o, a, b]), pe = d((e) => {
72
75
  var n;
73
- i || o || ((n = a.current) == null || n.focus(), A(e), oe(e), p(e, "highlight"), l());
74
- }, [i, o, l, p]), he = d((e) => {
76
+ r || o || ((n = l.current) == null || n.focus(), D(e), ce(e), b(e, "highlight"), a());
77
+ }, [r, o, a, b]), be = d((e) => {
75
78
  var n;
76
- i || o || ((n = a.current) == null || n.focus(), x(e), l());
77
- }, [i, o, l]), Ie = d((e) => {
79
+ r || o || ((n = l.current) == null || n.focus(), B(e), a());
80
+ }, [r, o, a]), Re = d((e) => {
78
81
  var n;
79
- i || o || ((n = a.current) == null || n.focus(), A(e), l());
80
- }, [i, o, l]), Ce = d(async (e) => {
82
+ r || o || ((n = l.current) == null || n.focus(), D(e), a());
83
+ }, [r, o, a]), Te = d(async (e) => {
81
84
  var c;
82
- if (!H) return;
85
+ if (!O) return;
83
86
  const n = (c = e.clipboardData) == null ? void 0 : c.items;
84
87
  if (n)
85
88
  for (let s = 0; s < n.length; s++) {
86
- const r = n[s];
87
- if (r.type.startsWith("image/")) {
89
+ const i = n[s];
90
+ if (i.type.startsWith("image/")) {
88
91
  e.preventDefault();
89
- const g = r.getAsFile();
92
+ const g = i.getAsFile();
90
93
  if (g) {
91
- const E = await S(g);
92
- v(E), l();
94
+ const L = await N(g);
95
+ F(L), a();
93
96
  }
94
97
  return;
95
98
  }
96
99
  }
97
- }, [H, l]), me = d(() => {
98
- if (i || o) return;
100
+ }, [O, a]), _e = d(() => {
101
+ if (r || o) return;
99
102
  const e = document.createElement("input");
100
103
  e.type = "file", e.accept = "image/*", e.onchange = async (n) => {
101
- var s, r;
104
+ var s, i;
102
105
  const c = (s = n.target.files) == null ? void 0 : s[0];
103
106
  if (c) {
104
- const g = await S(c);
105
- (r = a.current) == null || r.focus(), v(g), l();
107
+ const g = await N(c);
108
+ (i = l.current) == null || i.focus(), F(g), a();
106
109
  }
107
110
  }, e.click();
108
- }, [i, o, l]), pe = {
109
- bold: /* @__PURE__ */ t(Ye, { size: 16 }),
110
- italic: /* @__PURE__ */ t(Qe, { size: 16 }),
111
- underline: /* @__PURE__ */ t(Ke, { size: 16 }),
112
- strikethrough: /* @__PURE__ */ t(Ge, { size: 16 }),
113
- heading1: /* @__PURE__ */ t(qe, { size: 16 }),
114
- heading2: /* @__PURE__ */ t($e, { size: 16 }),
115
- heading3: /* @__PURE__ */ t(Je, { size: 16 }),
116
- bulletList: /* @__PURE__ */ t(je, { size: 16 }),
117
- orderedList: /* @__PURE__ */ t(Pe, { size: 16 }),
118
- blockquote: /* @__PURE__ */ t(Ve, { size: 16 }),
119
- code: /* @__PURE__ */ t(Ue, { size: 16 }),
120
- link: /* @__PURE__ */ t(N, { size: 16 }),
121
- alignLeft: /* @__PURE__ */ t(M, { size: 16 }),
122
- alignCenter: /* @__PURE__ */ t(w, { size: 16 }),
123
- alignRight: /* @__PURE__ */ t(U, { size: 16 }),
124
- alignJustify: /* @__PURE__ */ t(V, { size: 16 }),
125
- image: /* @__PURE__ */ t(F, { size: 16 }),
126
- indent: /* @__PURE__ */ t(P, { size: 16 }),
127
- outdent: /* @__PURE__ */ t(j, { size: 16 }),
128
- clearFormat: /* @__PURE__ */ t(J, { size: 16 }),
129
- table: /* @__PURE__ */ t(we, { size: 16 })
130
- }, k = (e, n) => {
111
+ }, [r, o, a]), Ee = {
112
+ bold: /* @__PURE__ */ t(et, { size: 16 }),
113
+ italic: /* @__PURE__ */ t(Ze, { size: 16 }),
114
+ underline: /* @__PURE__ */ t(Xe, { size: 16 }),
115
+ strikethrough: /* @__PURE__ */ t(We, { size: 16 }),
116
+ heading1: /* @__PURE__ */ t(Ye, { size: 16 }),
117
+ heading2: /* @__PURE__ */ t(Qe, { size: 16 }),
118
+ heading3: /* @__PURE__ */ t(Ke, { size: 16 }),
119
+ bulletList: /* @__PURE__ */ t(Ge, { size: 16 }),
120
+ orderedList: /* @__PURE__ */ t(qe, { size: 16 }),
121
+ blockquote: /* @__PURE__ */ t($e, { size: 16 }),
122
+ code: /* @__PURE__ */ t(Je, { size: 16 }),
123
+ link: /* @__PURE__ */ t(U, { size: 16 }),
124
+ alignLeft: /* @__PURE__ */ t(P, { size: 16 }),
125
+ alignCenter: /* @__PURE__ */ t(j, { size: 16 }),
126
+ alignRight: /* @__PURE__ */ t(J, { size: 16 }),
127
+ alignJustify: /* @__PURE__ */ t($, { size: 16 }),
128
+ image: /* @__PURE__ */ t(V, { size: 16 }),
129
+ indent: /* @__PURE__ */ t(q, { size: 16 }),
130
+ outdent: /* @__PURE__ */ t(G, { size: 16 }),
131
+ clearFormat: /* @__PURE__ */ t(K, { size: 16 }),
132
+ table: /* @__PURE__ */ t(je, { size: 16 })
133
+ }, A = (e, n) => {
131
134
  if (e === "divider")
132
- return /* @__PURE__ */ t("div", { className: R("Bear-RichEditor__divider", Ae) }, `divider-${n}`);
135
+ return /* @__PURE__ */ t("div", { className: p("Bear-RichEditor__divider", De) }, `divider-${n}`);
133
136
  if (e === "headingDropdown")
134
137
  return /* @__PURE__ */ t(
135
- Ne,
138
+ Ue,
136
139
  {
137
- options: Se,
138
- value: ee,
139
- onChange: de,
140
+ options: Ne,
141
+ value: oe,
142
+ onChange: Ce,
140
143
  title: "Text Style",
141
- disabled: i || o,
142
- icon: /* @__PURE__ */ t(Me, { size: 16 })
144
+ disabled: r || o,
145
+ icon: /* @__PURE__ */ t(Pe, { size: 16 })
143
146
  },
144
147
  "heading-dropdown"
145
148
  );
146
149
  if (e === "textColor")
147
150
  return /* @__PURE__ */ t(
148
- D,
151
+ w,
149
152
  {
150
- value: te,
151
- onChange: fe,
153
+ value: ae,
154
+ onChange: me,
152
155
  title: "Text Color",
153
- disabled: i || o,
156
+ disabled: r || o,
154
157
  type: "text",
155
- recentColors: re,
156
- onApplyLast: he
158
+ recentColors: de,
159
+ onApplyLast: be
157
160
  },
158
161
  "text-color"
159
162
  );
160
163
  if (e === "highlightColor")
161
164
  return /* @__PURE__ */ t(
162
- D,
165
+ w,
163
166
  {
164
- value: ie,
165
- onChange: ge,
167
+ value: se,
168
+ onChange: pe,
166
169
  title: "Highlight Color",
167
- disabled: i || o,
170
+ disabled: r || o,
168
171
  type: "highlight",
169
- recentColors: ae,
170
- onApplyLast: Ie
172
+ recentColors: fe,
173
+ onApplyLast: Re
171
174
  },
172
175
  "highlight-color"
173
176
  );
@@ -175,10 +178,10 @@ const We = 6, ct = ($) => {
175
178
  return /* @__PURE__ */ t(
176
179
  f,
177
180
  {
178
- icon: /* @__PURE__ */ t(N, { size: 16 }),
181
+ icon: /* @__PURE__ */ t(U, { size: 16 }),
179
182
  title: "Insert Link",
180
- onClick: ue,
181
- disabled: i || o
183
+ onClick: Ie,
184
+ disabled: r || o
182
185
  },
183
186
  "link"
184
187
  );
@@ -186,10 +189,10 @@ const We = 6, ct = ($) => {
186
189
  return /* @__PURE__ */ t(
187
190
  f,
188
191
  {
189
- icon: /* @__PURE__ */ t(F, { size: 16 }),
192
+ icon: /* @__PURE__ */ t(V, { size: 16 }),
190
193
  title: "Insert Image",
191
- onClick: me,
192
- disabled: i || o
194
+ onClick: _e,
195
+ disabled: r || o
193
196
  },
194
197
  "image"
195
198
  );
@@ -197,13 +200,13 @@ const We = 6, ct = ($) => {
197
200
  return /* @__PURE__ */ t(
198
201
  f,
199
202
  {
200
- icon: /* @__PURE__ */ t(M, { size: 16 }),
203
+ icon: /* @__PURE__ */ t(P, { size: 16 }),
201
204
  title: "Align Left",
202
205
  onClick: () => {
203
- var r;
204
- (r = a.current) == null || r.focus(), u("justifyLeft"), l();
206
+ var i;
207
+ (i = l.current) == null || i.focus(), u("justifyLeft"), a();
205
208
  },
206
- disabled: i || o
209
+ disabled: r || o
207
210
  },
208
211
  "alignLeft"
209
212
  );
@@ -211,13 +214,13 @@ const We = 6, ct = ($) => {
211
214
  return /* @__PURE__ */ t(
212
215
  f,
213
216
  {
214
- icon: /* @__PURE__ */ t(w, { size: 16 }),
217
+ icon: /* @__PURE__ */ t(j, { size: 16 }),
215
218
  title: "Align Center",
216
219
  onClick: () => {
217
- var r;
218
- (r = a.current) == null || r.focus(), u("justifyCenter"), l();
220
+ var i;
221
+ (i = l.current) == null || i.focus(), u("justifyCenter"), a();
219
222
  },
220
- disabled: i || o
223
+ disabled: r || o
221
224
  },
222
225
  "alignCenter"
223
226
  );
@@ -225,13 +228,13 @@ const We = 6, ct = ($) => {
225
228
  return /* @__PURE__ */ t(
226
229
  f,
227
230
  {
228
- icon: /* @__PURE__ */ t(U, { size: 16 }),
231
+ icon: /* @__PURE__ */ t(J, { size: 16 }),
229
232
  title: "Align Right",
230
233
  onClick: () => {
231
- var r;
232
- (r = a.current) == null || r.focus(), u("justifyRight"), l();
234
+ var i;
235
+ (i = l.current) == null || i.focus(), u("justifyRight"), a();
233
236
  },
234
- disabled: i || o
237
+ disabled: r || o
235
238
  },
236
239
  "alignRight"
237
240
  );
@@ -239,13 +242,13 @@ const We = 6, ct = ($) => {
239
242
  return /* @__PURE__ */ t(
240
243
  f,
241
244
  {
242
- icon: /* @__PURE__ */ t(V, { size: 16 }),
245
+ icon: /* @__PURE__ */ t($, { size: 16 }),
243
246
  title: "Justify",
244
247
  onClick: () => {
245
- var r;
246
- (r = a.current) == null || r.focus(), u("justifyFull"), l();
248
+ var i;
249
+ (i = l.current) == null || i.focus(), u("justifyFull"), a();
247
250
  },
248
- disabled: i || o
251
+ disabled: r || o
249
252
  },
250
253
  "alignJustify"
251
254
  );
@@ -253,13 +256,13 @@ const We = 6, ct = ($) => {
253
256
  return /* @__PURE__ */ t(
254
257
  f,
255
258
  {
256
- icon: /* @__PURE__ */ t(P, { size: 16 }),
259
+ icon: /* @__PURE__ */ t(q, { size: 16 }),
257
260
  title: "Increase Indent",
258
261
  onClick: () => {
259
- var r;
260
- (r = a.current) == null || r.focus(), u("indent"), l();
262
+ var i;
263
+ (i = l.current) == null || i.focus(), u("indent"), a();
261
264
  },
262
- disabled: i || o
265
+ disabled: r || o
263
266
  },
264
267
  "indent"
265
268
  );
@@ -267,13 +270,13 @@ const We = 6, ct = ($) => {
267
270
  return /* @__PURE__ */ t(
268
271
  f,
269
272
  {
270
- icon: /* @__PURE__ */ t(j, { size: 16 }),
273
+ icon: /* @__PURE__ */ t(G, { size: 16 }),
271
274
  title: "Decrease Indent",
272
275
  onClick: () => {
273
- var r;
274
- (r = a.current) == null || r.focus(), u("outdent"), l();
276
+ var i;
277
+ (i = l.current) == null || i.focus(), u("outdent"), a();
275
278
  },
276
- disabled: i || o
279
+ disabled: r || o
277
280
  },
278
281
  "outdent"
279
282
  );
@@ -281,18 +284,18 @@ const We = 6, ct = ($) => {
281
284
  return /* @__PURE__ */ t(
282
285
  f,
283
286
  {
284
- icon: /* @__PURE__ */ t(J, { size: 16 }),
287
+ icon: /* @__PURE__ */ t(K, { size: 16 }),
285
288
  title: "Clear Formatting",
286
289
  onClick: () => {
287
- var r;
288
- (r = a.current) == null || r.focus(), u("removeFormat"), l();
290
+ var i;
291
+ (i = l.current) == null || i.focus(), u("removeFormat"), a();
289
292
  },
290
- disabled: i || o
293
+ disabled: r || o
291
294
  },
292
295
  "clearFormat"
293
296
  );
294
297
  if (e === "more")
295
- return /* @__PURE__ */ t(Fe, { disabled: i || o, isMobile: _, children: (_ ? ve : [
298
+ return /* @__PURE__ */ t(Ve, { disabled: r || o, isMobile: y, children: (y ? Fe : [
296
299
  "alignLeft",
297
300
  "alignCenter",
298
301
  "alignRight",
@@ -302,63 +305,77 @@ const We = 6, ct = ($) => {
302
305
  "blockquote",
303
306
  "code",
304
307
  "clearFormat"
305
- ]).map((g, E) => k(g, E + 1e3)) }, "more");
306
- const c = B[e], s = pe[e];
308
+ ]).map((g, L) => A(g, L + 1e3)) }, "more");
309
+ const c = M[e], s = Ee[e];
307
310
  return !c || !s ? null : /* @__PURE__ */ t(
308
311
  f,
309
312
  {
310
313
  icon: s,
311
314
  title: c.title,
312
- active: X.has(e),
313
- onClick: () => ce(e),
314
- disabled: i || o
315
+ active: ne.has(e),
316
+ onClick: () => he(e),
317
+ disabled: r || o
315
318
  },
316
319
  e
317
320
  );
318
321
  };
319
- return /* @__PURE__ */ Re(
322
+ return /* @__PURE__ */ S(
320
323
  "div",
321
324
  {
322
- id: Y,
323
- "data-testid": Q,
324
- className: R(
325
+ id: ee,
326
+ "data-testid": Z,
327
+ className: p(
325
328
  "Bear-RichEditor",
326
- xe,
327
- i && "Bear-RichEditor--disabled",
329
+ Be,
330
+ r && "Bear-RichEditor--disabled",
328
331
  o && "Bear-RichEditor--readonly",
329
- K
332
+ X
330
333
  ),
331
- ...W,
334
+ ...te,
332
335
  children: [
333
- O.length > 0 && /* @__PURE__ */ t("div", { className: R("Bear-RichEditor__toolbar", ze), children: O.map((e, n) => k(e, n)) }),
336
+ k.length > 0 && /* @__PURE__ */ t("div", { className: p("Bear-RichEditor__toolbar", Ae), children: k.map((e, n) => A(e, n)) }),
334
337
  /* @__PURE__ */ t(
335
338
  "div",
336
339
  {
337
- ref: a,
338
- contentEditable: !i && !o,
339
- onInput: l,
340
+ ref: l,
341
+ contentEditable: !r && !o,
342
+ onInput: a,
340
343
  onSelect: h,
341
344
  onKeyUp: h,
342
345
  onMouseUp: h,
343
- onPaste: Ce,
344
- "data-placeholder": q,
345
- className: R(
346
+ onPaste: Te,
347
+ "data-placeholder": Y,
348
+ className: p(
346
349
  "Bear-RichEditor__content",
347
- ke,
350
+ Se,
348
351
  "[&:empty]:before:bear-content-[attr(data-placeholder)] [&:empty]:before:bear-text-gray-400 [&:empty]:before:bear-pointer-events-none",
349
- i && "Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"
352
+ r && "Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"
350
353
  ),
351
354
  style: {
352
- minHeight: typeof b == "number" ? `${b}px` : b,
355
+ minHeight: typeof T == "number" ? `${T}px` : T,
353
356
  maxHeight: m ? typeof m == "number" ? `${m}px` : m : void 0,
354
357
  overflowY: m ? "auto" : void 0
355
358
  }
356
359
  }
360
+ ),
361
+ _ && E != null && /* @__PURE__ */ S(
362
+ "div",
363
+ {
364
+ className: p(
365
+ "Bear-RichEditor__char-count bear-text-xs bear-tabular-nums bear-px-3 bear-py-1.5 bear-text-right bear-border-t bear-border-gray-200 dark:bear-border-gray-700",
366
+ v > E ? "bear-text-red-500" : "bear-text-gray-400 dark:bear-text-gray-500"
367
+ ),
368
+ children: [
369
+ v,
370
+ "/",
371
+ E
372
+ ]
373
+ }
357
374
  )
358
375
  ]
359
376
  }
360
377
  );
361
378
  };
362
379
  export {
363
- ct as RichEditor
380
+ gt as RichEditor
364
381
  };
@@ -24,6 +24,10 @@ export interface RichEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'o
24
24
  id?: string;
25
25
  /** Enable image paste support */
26
26
  allowImagePaste?: boolean;
27
+ /** Show live character count (plain-text length, HTML tags excluded) */
28
+ showCharCount?: boolean;
29
+ /** Max chars for counter display */
30
+ charCountMax?: number;
27
31
  }
28
32
  export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'headingDropdown' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'image' | 'textColor' | 'highlightColor' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'indent' | 'outdent' | 'clearFormat' | 'table' | 'divider' | 'more';
29
33
  export interface ToolbarButtonProps {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),t=require("react"),R=require("../../utils/cn.cjs"),r=require("./Typewriter.const.cjs"),X=b=>{const{text:f,speed:i=r.DEFAULT_SPEED,startDelay:N=r.DEFAULT_START_DELAY,deleteDelay:x=r.DEFAULT_DELETE_DELAY,deleteSpeed:d=r.DEFAULT_DELETE_SPEED,loop:_=!1,cursor:I=!0,cursorChar:h=r.DEFAULT_CURSOR_CHAR,cursorBlinkSpeed:A=r.DEFAULT_CURSOR_BLINK_SPEED,onComplete:n,onWordComplete:o,as:g="span",className:U,style:j,testId:w}=b,u=Array.isArray(f)?f:[f],[F,m]=t.useState(""),[a,p]=t.useState(r.INITIAL_TEXT_INDEX),[l,S]=t.useState(r.INITIAL_CHAR_INDEX),[E,L]=t.useState(!1),[v,B]=t.useState(!0),e=t.useRef(),D=t.useRef(!1);t.useEffect(()=>{if(!I)return;const T=setInterval(()=>B(s=>!s),A);return()=>clearInterval(T)},[I,A]);const c=t.useCallback(()=>{const T=u[a];if(E)if(l>0)S(s=>s-1),m(T.slice(0,l-1)),e.current=setTimeout(c,d);else{L(!1);const s=a+1;s>=u.length?_?(p(r.INITIAL_TEXT_INDEX),e.current=setTimeout(c,i)):n==null||n():(p(s),e.current=setTimeout(c,i))}else if(l<T.length)m(T.slice(0,l+1)),S(s=>s+1),e.current=setTimeout(c,i);else{if(o==null||o(a),u.length===1&&!_){n==null||n();return}e.current=setTimeout(()=>{L(!0),c()},x)}},[u,a,l,E,i,d,x,_,n,o]);return t.useEffect(()=>{if(!D.current)return D.current=!0,e.current=setTimeout(c,N),()=>{e.current&&clearTimeout(e.current)}},[]),t.useEffect(()=>{if(D.current)return e.current&&clearTimeout(e.current),e.current=setTimeout(c,E?d:i),()=>{e.current&&clearTimeout(e.current)}},[E,a]),y.jsxs(g,{className:R.cn("Bear-Typewriter","bear-inline",U),style:j,"data-testid":w,"aria-label":u.join(", "),children:[y.jsx("span",{className:"Bear-Typewriter__text",children:F}),I&&y.jsx("span",{className:R.cn("Bear-Typewriter__cursor","bear-inline-block bear-ml-0.5","bear-text-[var(--bear-primary-500)]"),style:{opacity:v?1:0},"aria-hidden":"true",children:h})]})};exports.Typewriter=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),t=require("react"),X=require("../../utils/cn.cjs"),e=require("./Typewriter.const.cjs"),k=g=>{const{text:I,speed:T=e.DEFAULT_SPEED,startDelay:C=e.DEFAULT_START_DELAY,deleteDelay:N=e.DEFAULT_DELETE_DELAY,deleteSpeed:R=e.DEFAULT_DELETE_SPEED,loop:d=!1,cursor:f=!0,cursorChar:U=e.DEFAULT_CURSOR_CHAR,cursorBlinkSpeed:y=e.DEFAULT_CURSOR_BLINK_SPEED,onComplete:n,onWordComplete:o,as:j="span",className:w,style:F,testId:H}=g,a=t.useMemo(()=>Array.isArray(I)?I:[I],[I]),[v,L]=t.useState(""),[p,S]=t.useState(e.INITIAL_TEXT_INDEX),[m,E]=t.useState(e.INITIAL_CHAR_INDEX),[b,h]=t.useState(!1),[B,q]=t.useState(!0),s=t.useRef(),_=t.useRef(p),c=t.useRef(m),D=t.useRef(b);_.current=p,c.current=m,D.current=b,t.useEffect(()=>{if(!f)return;const l=setInterval(()=>q(i=>!i),y);return()=>clearInterval(l)},[f,y]);const u=t.useCallback(()=>{const l=_.current,i=c.current,P=D.current,A=a[l];if(P)if(i>0){const r=i-1;E(r),c.current=r,L(A.slice(0,r)),s.current=setTimeout(u,R)}else{h(!1),D.current=!1;const r=l+1;r>=a.length?d?(S(e.INITIAL_TEXT_INDEX),_.current=e.INITIAL_TEXT_INDEX,E(e.INITIAL_CHAR_INDEX),c.current=e.INITIAL_CHAR_INDEX,s.current=setTimeout(u,T)):n==null||n():(S(r),_.current=r,E(e.INITIAL_CHAR_INDEX),c.current=e.INITIAL_CHAR_INDEX,s.current=setTimeout(u,T))}else if(i<A.length){const r=i+1;L(A.slice(0,r)),E(r),c.current=r,s.current=setTimeout(u,T)}else{if(o==null||o(l),a.length===1&&!d){n==null||n();return}s.current=setTimeout(()=>{h(!0),D.current=!0,u()},N)}},[a,T,R,N,d,n,o]);return t.useEffect(()=>(s.current=setTimeout(u,C),()=>{s.current&&clearTimeout(s.current)}),[]),x.jsxs(j,{className:X.cn("Bear-Typewriter","bear-inline",w),style:F,"data-testid":H,"aria-label":a.join(", "),children:[x.jsx("span",{className:"Bear-Typewriter__text",children:v}),f&&x.jsx("span",{className:X.cn("Bear-Typewriter__cursor","bear-inline-block bear-ml-0.5","bear-text-[var(--bear-primary-500)]"),style:{opacity:B?1:0},"aria-hidden":"true",children:U})]})};exports.Typewriter=k;