@baishuyun/ui-base 6.7.3 → 6.8.2

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 (102) hide show
  1. package/dist/Amap/AmapCircle/index.js +1 -1
  2. package/dist/Amap/AmapMarker/index.js +1 -1
  3. package/dist/Amap/AmapMarkerCluster/index.js +1 -1
  4. package/dist/Amap/AmapProvider/index.js +4 -4
  5. package/dist/Amap/{AmapProvider-DSjQj2oA.js → AmapProvider-Cwi6WOe0.js} +1 -1
  6. package/dist/Amap/hooks/index.js +1 -1
  7. package/dist/Amap/index.js +4 -4
  8. package/dist/Calendar/{Calendar-C2iO_3cX.js → Calendar-DnQrN8KB.js} +2 -2
  9. package/dist/Calendar/context/index.js +1 -1
  10. package/dist/Calendar/index.js +5 -5
  11. package/dist/Calendar/subcomponents/AllDaySection/index.js +1 -1
  12. package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +1 -1
  13. package/dist/Calendar/subcomponents/EventCard/index.js +1 -1
  14. package/dist/Calendar/subcomponents/TimeAxis/index.js +1 -1
  15. package/dist/Calendar/subcomponents/TimeGrid/index.js +1 -1
  16. package/dist/Calendar/utils/index.js +1 -1
  17. package/dist/Calendar/utils/layout/index.js +1 -1
  18. package/dist/Calendar/utils/theme/index.js +1 -1
  19. package/dist/Card/index.js +1 -1
  20. package/dist/CheckBox/index.js +1 -1
  21. package/dist/ColorPicker/{ColorPicker-BtTIb9tX.js → ColorPicker-CL57cSDG.js} +2 -1
  22. package/dist/ColorPicker/index.js +4 -4
  23. package/dist/ConfigProvider/index.js +3 -3
  24. package/dist/DatePicker/{DatePicker-BMTK0Phw.js → DatePicker-C0XbZmrZ.js} +2 -2
  25. package/dist/DatePicker/{DatePickerPanel-BH_Z4e88.js → DatePickerPanel-BEn16cat.js} +3 -3
  26. package/dist/DatePicker/index.js +4 -4
  27. package/dist/DatePicker/style/index.js +1 -1
  28. package/dist/DropDown/{DropDown-CdTjlySd.js → DropDown-yDH9V_9Y.js} +2 -2
  29. package/dist/DropDown/index.js +5 -5
  30. package/dist/DropDown/style/index.js +1 -1
  31. package/dist/Editor/{Buttons-BcP66z6E.js → Buttons-BivKInBV.js} +144 -124
  32. package/dist/Editor/ToolbarPlugin/Buttons/index.js +7 -7
  33. package/dist/Editor/constants/index.js +1 -1
  34. package/dist/Editor/index.js +274 -164
  35. package/dist/Gantt/GanttChart/index.js +7 -7
  36. package/dist/Gantt/{GanttChart-BYzMKcZ2.js → GanttChart-CDw1IQ4F.js} +2 -2
  37. package/dist/Gantt/GanttTable/index.js +5 -5
  38. package/dist/Gantt/{GanttTable-DqJziqML.js → GanttTable-xbXD_PWI.js} +1 -1
  39. package/dist/Gantt/GanttToolBar/index.js +6 -6
  40. package/dist/Gantt/{GanttToolBar-C50n7PD9.js → GanttToolBar-BTeTsR6Z.js} +2 -2
  41. package/dist/Gantt/index.js +9 -9
  42. package/dist/Gantt/utils/index.js +1 -1
  43. package/dist/Gantt/utils/theme/index.js +1 -1
  44. package/dist/Icon/index.js +1 -1
  45. package/dist/InputTag/InputTag-hzCCJQ1z.js +144 -0
  46. package/dist/InputTag/index.js +4 -2
  47. package/dist/Loading/Loading-DiywS7ex.js +19 -0
  48. package/dist/Loading/index.js +4 -2
  49. package/dist/Modal/index.js +1 -1
  50. package/dist/NotFoundContent/index.js +1 -1
  51. package/dist/Radio/{Radio-DSoZotcs.js → Radio-CX9cUqb7.js} +12 -12
  52. package/dist/Radio/index.js +2 -2
  53. package/dist/ScrollBar/index.js +1 -1
  54. package/dist/Segmented/index.js +1 -1
  55. package/dist/Select/{Select-DujgkkUp.js → Select-D6EK7whJ.js} +195 -194
  56. package/dist/Select/{SelectInputSearch-Bikrj3FI.js → SelectInputSearch-COUzreau.js} +1 -1
  57. package/dist/Select/index.js +7 -7
  58. package/dist/Table/{Table-k9wdWm6V.js → Table-yQXQEk6d.js} +1 -1
  59. package/dist/Table/hooks/index.js +1 -1
  60. package/dist/Table/index.js +4 -4
  61. package/dist/Table/style/index.js +1 -1
  62. package/dist/Table/utils/index.js +1 -1
  63. package/dist/Tabs/Tabs-BiKW70CL.js +398 -0
  64. package/dist/Tabs/index.js +4 -2
  65. package/dist/Tooltip/index.js +1 -1
  66. package/dist/Tree/index.js +3 -3
  67. package/dist/Tree/utils/index.js +1 -1
  68. package/dist/components/DropDown/interface.d.ts +167 -169
  69. package/dist/components/Editor/LengthBadge.d.ts +6 -0
  70. package/dist/components/Editor/ToolbarPlugin/BaseButton/BaseButton.d.ts +1 -1
  71. package/dist/components/Editor/ToolbarPlugin/ToolbarPlugin.d.ts +5 -1
  72. package/dist/components/Editor/ToolbarPlugin/context/EditorToolbarThemeContext.d.ts +6 -0
  73. package/dist/components/Editor/ToolbarPlugin/interface.d.ts +30 -32
  74. package/dist/components/Editor/index.d.ts +1 -1
  75. package/dist/components/Editor/interface.d.ts +118 -60
  76. package/dist/components/Editor/plugins/MaxLengthPlugin.d.ts +7 -0
  77. package/dist/components/Editor/utils/resolveEditorToolbarThemeVars.d.ts +5 -0
  78. package/dist/components/Editor/utils/textLength.d.ts +4 -0
  79. package/dist/components/InputTag/interface.d.ts +32 -32
  80. package/dist/components/Radio/interface.d.ts +95 -97
  81. package/dist/components/Tabs/TabSelect/interface.d.ts +23 -25
  82. package/dist/components/Tabs/interface.d.ts +58 -60
  83. package/dist/components/Tree/types/node.d.ts +19 -19
  84. package/dist/components/Tree/types/tree.d.ts +81 -83
  85. package/dist/components/index.d.ts +2 -0
  86. package/dist/index.js +18 -18
  87. package/dist/locale/index.d.ts +1 -1
  88. package/dist/locale/lang/en-US.json.d.ts +177 -166
  89. package/dist/locale/lang/zh-CN.json.d.ts +177 -166
  90. package/dist/locale/lang/zh-TW.json.d.ts +177 -166
  91. package/dist/style.css +1 -1
  92. package/dist/vendors/{ConfigProvider-C3Uwzinj.js → ConfigProvider-DxrZpdIb.js} +23 -1
  93. package/dist/vendors/{LocaleContext-B1HuhJc-.js → LocaleContext-Dcw6C1LX.js} +11 -0
  94. package/dist/vendors/{Tree-DQkpLl6f.js → Tree-DXmVRDn0.js} +8 -7
  95. package/dist/vendors/{useLocale-BYtF5pxt.js → useLocale-BKZX2_zw.js} +1 -1
  96. package/dist/vendors/{version-Dkos5Cha.js → version-4HBYLKDL.js} +1 -1
  97. package/dist/vite-env.d.ts +13 -13
  98. package/dist/vitest-matchers.d.ts +0 -1
  99. package/package.json +8 -8
  100. package/dist/InputTag/InputTag-LnUqz0Hz.js +0 -143
  101. package/dist/Loading/Loading-CcTZogVx.js +0 -15
  102. package/dist/Tabs/Tabs-Ctgg45Ox.js +0 -410
@@ -1,76 +1,91 @@
1
- import "../vendors/version-Dkos5Cha.js";
1
+ import "../vendors/version-4HBYLKDL.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
3
  import "../Icon/Icon-BBDcb-yw.js";
4
- import "../vendors/LocaleContext-B1HuhJc-.js";
4
+ import "../vendors/LocaleContext-Dcw6C1LX.js";
5
5
  import "../Modal/Modal-LiztSF7x.js";
6
- import "../ColorPicker/ColorPicker-BtTIb9tX.js";
6
+ import "../ColorPicker/ColorPicker-CL57cSDG.js";
7
7
  import "../vendors/useFloatingOverlay-BApqkHSu.js";
8
- import "../vendors/useLocale-BYtF5pxt.js";
8
+ import "../vendors/useLocale-BKZX2_zw.js";
9
9
  import "../vendors/color-D6XBXROa.js";
10
10
  import "../vendors/useLatchedPopupPortalRoot-4fVhqVT4.js";
11
- import "../Select/SelectInputSearch-Bikrj3FI.js";
11
+ import { t as e } from "../vendors/cssVars-BYg1matG.js";
12
+ import "../Select/SelectInputSearch-COUzreau.js";
12
13
  import "../CheckBox/CheckBox-ByWSy9Yr.js";
13
14
  import "../CheckBox/CheckBox-nBm0u6zX.js";
14
15
  import "../NotFoundContent/NotFoundContent-BLmzWNBi.js";
15
16
  import "../ScrollBar/ScrollBar-QhXVe8zd.js";
16
17
  import "../vendors/useFloatingPortal-CmVJbuRm.js";
17
- import "../DropDown/DropDown-CdTjlySd.js";
18
+ import "../DropDown/DropDown-yDH9V_9Y.js";
18
19
  import "../DropDown/style-Fdp-U4md.js";
19
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s } from "./Buttons-BcP66z6E.js";
20
- import { DEFAULT_BACKGROUND_COLOR as c, DEFAULT_FONT_COLOR as l, DEFAULT_FONT_SIZE as u } from "./constants/index.js";
21
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
22
- import m, { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
23
- import b from "clsx";
24
- import { LexicalComposer as x } from "@lexical/react/LexicalComposer";
25
- import { RichTextPlugin as S } from "@lexical/react/LexicalRichTextPlugin";
26
- import { ContentEditable as C } from "@lexical/react/LexicalContentEditable";
27
- import { HistoryPlugin as w } from "@lexical/react/LexicalHistoryPlugin";
28
- import { OnChangePlugin as T } from "@lexical/react/LexicalOnChangePlugin";
29
- import { LexicalErrorBoundary as E } from "@lexical/react/LexicalErrorBoundary";
30
- import { $generateHtmlFromNodes as D, $generateNodesFromDOM as O } from "@lexical/html";
31
- import { $applyNodeReplacement as ee, $createParagraphNode as te, $getNodeByKey as ne, $getRoot as re, $getRoot as k, $getSelection as A, $insertNodes as j, $isElementNode as M, $isRangeSelection as N, $isRootOrShadowRoot as ie, $isTextNode as P, COMMAND_PRIORITY_EDITOR as ae, COMMAND_PRIORITY_LOW as oe, DecoratorNode as se, KEY_ENTER_COMMAND as ce, TextNode as F } from "lexical";
32
- import { useLexicalComposerContext as I, useLexicalComposerContext as L } from "@lexical/react/LexicalComposerContext";
33
- import { $getSelectionStyleValueForProperty as R, $patchStyleText as z } from "@lexical/selection";
34
- import { $findMatchingParent as B } from "@lexical/utils";
35
- import { $isLinkNode as V, AutoLinkNode as H, LinkNode as U } from "@lexical/link";
36
- import { LinkPlugin as W } from "@lexical/react/LexicalLinkPlugin";
37
- //#region src/components/Editor/ToolbarPlugin/ToolbarPlugin.module.scss
38
- var G = {
39
- "bsy-lexical__toolbar": "_bsy-lexical__toolbar_n60av_1",
40
- "bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_n60av_9",
41
- "bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_n60av_15"
20
+ import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, u as l } from "./Buttons-BivKInBV.js";
21
+ import { DEFAULT_BACKGROUND_COLOR as u, DEFAULT_FONT_COLOR as d, DEFAULT_FONT_SIZE as f } from "./constants/index.js";
22
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
23
+ import g, { useCallback as _, useEffect as v, useMemo as y, useRef as b, useState as x } from "react";
24
+ import S from "clsx";
25
+ import { LexicalComposer as C } from "@lexical/react/LexicalComposer";
26
+ import { RichTextPlugin as w } from "@lexical/react/LexicalRichTextPlugin";
27
+ import { ContentEditable as T } from "@lexical/react/LexicalContentEditable";
28
+ import { HistoryPlugin as E } from "@lexical/react/LexicalHistoryPlugin";
29
+ import { OnChangePlugin as ee } from "@lexical/react/LexicalOnChangePlugin";
30
+ import { LexicalErrorBoundary as te } from "@lexical/react/LexicalErrorBoundary";
31
+ import { $generateHtmlFromNodes as ne, $generateNodesFromDOM as re } from "@lexical/html";
32
+ import { $applyNodeReplacement as D, $createParagraphNode as O, $getNodeByKey as k, $getRoot as ie, $getRoot as A, $getSelection as j, $insertNodes as M, $isElementNode as ae, $isRangeSelection as N, $isRootOrShadowRoot as oe, $isTextNode as se, COMMAND_PRIORITY_EDITOR as ce, COMMAND_PRIORITY_LOW as le, DecoratorNode as ue, KEY_ENTER_COMMAND as P, RootNode as F, TextNode as I } from "lexical";
33
+ import { useLexicalComposerContext as de, useLexicalComposerContext as L } from "@lexical/react/LexicalComposerContext";
34
+ import { $getSelectionStyleValueForProperty as R, $patchStyleText as fe, $trimTextContentFromAnchor as z } from "@lexical/selection";
35
+ import { $findMatchingParent as B, $restoreEditorState as V } from "@lexical/utils";
36
+ import { $isLinkNode as pe, AutoLinkNode as me, LinkNode as he } from "@lexical/link";
37
+ import { useLexicalEditable as ge } from "@lexical/react/useLexicalEditable";
38
+ import { LinkPlugin as _e } from "@lexical/react/LexicalLinkPlugin";
39
+ //#region src/components/Editor/utils/resolveEditorToolbarThemeVars.ts
40
+ var H = (e) => {
41
+ if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
42
+ }, ve = (t) => {
43
+ if (!t) return {};
44
+ let n = {};
45
+ return e(n, "--bsy-editor-toolbar-bg", t.bg), e(n, "--bsy-editor-toolbar-border-color", t.borderColor), e(n, "--bsy-editor-toolbar-padding", t.padding), e(n, "--bsy-editor-toolbar-gap", H(t.gap)), e(n, "--bsy-editor-toolbar-group-gap", H(t.groupGap)), e(n, "--bsy-editor-toolbar-divider-color", t.dividerColor), e(n, "--bsy-editor-toolbar-divider-size", H(t.dividerSize)), e(n, "--bsy-editor-toolbar-divider-margin", H(t.dividerMargin)), e(n, "--bsy-editor-toolbar-color-icon", t.colorIcon), e(n, "--bsy-editor-toolbar-item-hover-bg", t.itemHoverBg), e(n, "--bsy-editor-toolbar-item-hover-color", t.itemHoverColor), e(n, "--bsy-editor-toolbar-item-active-bg", t.itemActiveBg), e(n, "--bsy-editor-toolbar-item-active-color", t.itemActiveColor), e(n, "--bsy-editor-toolbar-item-padding", H(t.itemPadding)), e(n, "--bsy-editor-toolbar-item-border-radius", H(t.itemBorderRadius)), e(n, "--bsy-editor-toolbar-icon-size", H(t.iconSize)), n;
46
+ }, U = (e) => {
47
+ if (typeof e == "number" && Number.isFinite(e)) return e;
48
+ if (typeof e == "string") {
49
+ let t = Number.parseFloat(e);
50
+ if (Number.isFinite(t)) return t;
51
+ }
52
+ return 14;
53
+ }, W = {
54
+ "bsy-lexical__toolbar": "_bsy-lexical__toolbar_1tygc_1",
55
+ "bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_1tygc_10",
56
+ "bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_1tygc_16"
42
57
  };
43
58
  //#endregion
44
59
  //#region src/components/Editor/hooks/useTextFormatsState.ts
45
- function le() {
46
- let [e] = L(), [t, n] = y({
60
+ function ye() {
61
+ let [e] = L(), [t, n] = x({
47
62
  bold: !1,
48
63
  italic: !1,
49
64
  underline: !1,
50
- fontSize: u,
51
- fontColor: l,
52
- backgroundColor: c,
65
+ fontSize: f,
66
+ fontColor: d,
67
+ backgroundColor: u,
53
68
  align: "left",
54
69
  link: void 0
55
70
  });
56
- return g(() => e.registerUpdateListener(({ editorState: e }) => {
71
+ return v(() => e.registerUpdateListener(({ editorState: e }) => {
57
72
  e.read(() => {
58
- let e = A();
73
+ let e = j();
59
74
  if (N(e)) {
60
- let t = R(e, "font-size", u), r = R(e, "color", l), i = R(e, "background-color", c), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : B(a, (e) => {
75
+ let t = R(e, "font-size", f), r = R(e, "color", d), i = R(e, "background-color", u), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : B(a, (e) => {
61
76
  let t = e.getParent();
62
- return t !== null && ie(t);
77
+ return t !== null && oe(t);
63
78
  });
64
79
  o === null && (o = a.getTopLevelElementOrThrow());
65
- let s = {}, d = B(a, V);
66
- d ? (s.link = d.getURL(), s.linkText = d.getTextContent(), s.newBlank = d.getTarget() === "_blank") : s.linkText = e.getTextContent(), n({
80
+ let s = {}, c = B(a, pe);
81
+ c ? (s.link = c.getURL(), s.linkText = c.getTextContent(), s.newBlank = c.getTarget() === "_blank") : s.linkText = e.getTextContent(), n({
67
82
  bold: e.hasFormat("bold"),
68
83
  italic: e.hasFormat("italic"),
69
84
  underline: e.hasFormat("underline"),
70
85
  fontSize: t,
71
86
  fontColor: r,
72
87
  backgroundColor: i,
73
- align: M(o) ? o.getFormatType() : "left",
88
+ align: ae(o) ? o.getFormatType() : "left",
74
89
  link: s
75
90
  });
76
91
  }
@@ -79,30 +94,39 @@ function le() {
79
94
  }
80
95
  //#endregion
81
96
  //#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
82
- var ue = (e) => {
83
- let t = le();
84
- return /* @__PURE__ */ f(r.Provider, {
97
+ var be = (e) => {
98
+ let t = ye();
99
+ return /* @__PURE__ */ m(l.Provider, {
85
100
  value: t,
86
101
  children: e.children
87
102
  });
88
- }, de = (e) => {
89
- let { config: t = [], style: n } = e, r = (e, t) => {
90
- let n = typeof e == "string" ? e : e.name, r = i(n);
91
- return r ? typeof e == "string" ? /* @__PURE__ */ f(r, {}, `${n}-${t}`) : /* @__PURE__ */ f(r, { ...e.props }, `${n}-${t}`) : (console.warn(`[ToolbarPlugin] Button "${n}" is not registered.`), null);
103
+ }, xe = (e) => {
104
+ let { config: t = [], style: n, theme: r } = e, o = y(() => ve(r), [r]), s = y(() => ({ iconSize: U(r?.iconSize) }), [r?.iconSize]), c = (e, t) => {
105
+ let n = typeof e == "string" ? e : e.name, r = a(n);
106
+ return r ? typeof e == "string" ? /* @__PURE__ */ m(r, {}, `${n}-${t}`) : /* @__PURE__ */ m(r, { ...e.props }, `${n}-${t}`) : (console.warn(`[ToolbarPlugin] Button "${n}" is not registered.`), null);
92
107
  };
93
- return /* @__PURE__ */ f(ue, { children: /* @__PURE__ */ f("div", {
94
- className: G["bsy-lexical__toolbar"],
95
- style: n,
96
- children: t.map((e, n) => /* @__PURE__ */ p("div", {
97
- className: G["bsy-lexical__toolbar-group"],
98
- "data-group": e.key,
99
- children: [e.buttons.map((e, t) => r(e, t)), n < t.length - 1 && /* @__PURE__ */ f("div", { className: G["bsy-lexical__toolbar-divider"] })]
100
- }, e.key + n))
101
- }) });
108
+ return /* @__PURE__ */ m(i, {
109
+ value: s,
110
+ children: /* @__PURE__ */ m(be, { children: /* @__PURE__ */ m("div", {
111
+ className: W["bsy-lexical__toolbar"],
112
+ style: {
113
+ ...o,
114
+ ...n
115
+ },
116
+ children: t.map((e, n) => /* @__PURE__ */ h("div", {
117
+ className: W["bsy-lexical__toolbar-group"],
118
+ "data-group": e.key,
119
+ children: [e.buttons.map((e, t) => c(e, t)), n < t.length - 1 && /* @__PURE__ */ m("div", { className: W["bsy-lexical__toolbar-divider"] })]
120
+ }, e.key + n))
121
+ }) })
122
+ });
123
+ }, G = {
124
+ "bsy-lexical-editor": "_bsy-lexical-editor_tsu2x_1",
125
+ "bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_tsu2x_7",
126
+ "bsy-lexical-editor__content-editable--with-length-badge": "_bsy-lexical-editor__content-editable--with-length-badge_tsu2x_14",
127
+ "bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_tsu2x_17",
128
+ "bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_tsu2x_33"
102
129
  }, K = {
103
- "bsy-lexical-editor": "_bsy-lexical-editor_19ssw_1",
104
- "bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_19ssw_6"
105
- }, q = {
106
130
  imageWrapper: "_imageWrapper_y06h3_1",
107
131
  selected: "_selected_y06h3_8",
108
132
  resizing: "_resizing_y06h3_12",
@@ -112,19 +136,19 @@ var ue = (e) => {
112
136
  topRight: "_topRight_y06h3_49",
113
137
  bottomLeft: "_bottomLeft_y06h3_54",
114
138
  bottomRight: "_bottomRight_y06h3_59"
115
- }, fe = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
116
- let [a] = L(), [o, s] = y(!1), [c, l] = y(null), u = v(null), [_, x] = y({
139
+ }, Se = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
140
+ let [a] = L(), [o, s] = x(!1), [c, l] = x(null), u = b(null), [d, f] = x({
117
141
  width: n || void 0,
118
142
  height: r || void 0
119
- }), S = h(() => {
120
- n && r && x({
143
+ }), y = _(() => {
144
+ n && r && f({
121
145
  width: n,
122
146
  height: r
123
147
  });
124
- }, [n, r]), C = h((e, t) => {
148
+ }, [n, r]), C = _((e, t) => {
125
149
  if (e.preventDefault(), e.stopPropagation(), !u.current) return;
126
- let n = _.width || u.current.offsetWidth, r = _.height || u.current.offsetHeight, i = n / r;
127
- (!_.width || !_.height) && x({
150
+ let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
151
+ (!d.width || !d.height) && f({
128
152
  width: n,
129
153
  height: r
130
154
  }), l({
@@ -136,7 +160,7 @@ var ue = (e) => {
136
160
  aspectRatio: i,
137
161
  direction: t
138
162
  });
139
- }, [_]), w = h((e) => {
163
+ }, [d]), w = _((e) => {
140
164
  if (!c?.isResizing) return;
141
165
  let t = e.clientX - c.startX, n;
142
166
  switch (c.direction) {
@@ -155,22 +179,22 @@ var ue = (e) => {
155
179
  default: n = Math.max(50, c.startWidth + t);
156
180
  }
157
181
  let r = n / c.aspectRatio;
158
- x({
182
+ f({
159
183
  width: n,
160
184
  height: r
161
185
  });
162
- }, [c]), T = h(() => {
186
+ }, [c]), T = _(() => {
163
187
  c?.isResizing && (a.update(() => {
164
- let e = ne(i);
165
- pe(e) && e.setWidthAndHeight(_.width, _.height);
188
+ let e = k(i);
189
+ Ce(e) && e.setWidthAndHeight(d.width, d.height);
166
190
  }), l(null));
167
191
  }, [
168
192
  a,
169
193
  i,
170
- _,
194
+ d,
171
195
  c
172
196
  ]);
173
- m.useEffect(() => {
197
+ g.useEffect(() => {
174
198
  if (c?.isResizing) return document.addEventListener("mousemove", w), document.addEventListener("mouseup", T), () => {
175
199
  document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", T);
176
200
  };
@@ -179,62 +203,62 @@ var ue = (e) => {
179
203
  w,
180
204
  T
181
205
  ]);
182
- let E = h(() => {
206
+ let E = _(() => {
183
207
  s(!0);
184
208
  }, []);
185
- return g(() => a.registerUpdateListener(({ editorState: e }) => {
209
+ return v(() => a.registerUpdateListener(({ editorState: e }) => {
186
210
  e.read(() => {
187
- let e = A();
211
+ let e = j();
188
212
  N(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
189
213
  });
190
214
  }), [
191
215
  a,
192
216
  i,
193
217
  o
194
- ]), g(() => {
218
+ ]), v(() => {
195
219
  let e = (e) => {
196
220
  o && u.current && !u.current.contains(e.target) && s(!1);
197
221
  };
198
222
  if (o) return document.addEventListener("mousedown", e), () => {
199
223
  document.removeEventListener("mousedown", e);
200
224
  };
201
- }, [o]), /* @__PURE__ */ p("div", {
202
- className: b(q.imageWrapper, {
203
- [q.selected]: o,
204
- [q.resizing]: c?.isResizing
225
+ }, [o]), /* @__PURE__ */ h("div", {
226
+ className: S(K.imageWrapper, {
227
+ [K.selected]: o,
228
+ [K.resizing]: c?.isResizing
205
229
  }),
206
- children: [/* @__PURE__ */ f("img", {
230
+ children: [/* @__PURE__ */ m("img", {
207
231
  ref: u,
208
232
  src: e,
209
233
  alt: t,
210
- className: q.image,
234
+ className: K.image,
211
235
  style: {
212
- width: _.width,
213
- height: _.height
236
+ width: d.width,
237
+ height: d.height
214
238
  },
215
- onLoad: S,
239
+ onLoad: y,
216
240
  onClick: E,
217
241
  draggable: !1
218
- }), o && /* @__PURE__ */ p(d, { children: [
219
- /* @__PURE__ */ f("div", {
220
- className: b(q.resizeHandle, q.bottomRight),
242
+ }), o && /* @__PURE__ */ h(p, { children: [
243
+ /* @__PURE__ */ m("div", {
244
+ className: S(K.resizeHandle, K.bottomRight),
221
245
  onMouseDown: (e) => C(e, "bottom-right")
222
246
  }),
223
- /* @__PURE__ */ f("div", {
224
- className: b(q.resizeHandle, q.bottomLeft),
247
+ /* @__PURE__ */ m("div", {
248
+ className: S(K.resizeHandle, K.bottomLeft),
225
249
  onMouseDown: (e) => C(e, "bottom-left")
226
250
  }),
227
- /* @__PURE__ */ f("div", {
228
- className: b(q.resizeHandle, q.topRight),
251
+ /* @__PURE__ */ m("div", {
252
+ className: S(K.resizeHandle, K.topRight),
229
253
  onMouseDown: (e) => C(e, "top-right")
230
254
  }),
231
- /* @__PURE__ */ f("div", {
232
- className: b(q.resizeHandle, q.topLeft),
255
+ /* @__PURE__ */ m("div", {
256
+ className: S(K.resizeHandle, K.topLeft),
233
257
  onMouseDown: (e) => C(e, "top-left")
234
258
  })
235
259
  ] })]
236
260
  });
237
- }, J = class e extends se {
261
+ }, q = class e extends ue {
238
262
  static getType() {
239
263
  return "image";
240
264
  }
@@ -280,7 +304,7 @@ var ue = (e) => {
280
304
  n.__width = e, n.__height = t;
281
305
  }
282
306
  decorate() {
283
- return /* @__PURE__ */ f(fe, {
307
+ return /* @__PURE__ */ m(Se, {
284
308
  src: this.__src,
285
309
  altText: this.__altText,
286
310
  width: this.__width,
@@ -290,13 +314,13 @@ var ue = (e) => {
290
314
  }
291
315
  static importDOM() {
292
316
  return { img: () => ({
293
- conversion: me,
317
+ conversion: we,
294
318
  priority: 0
295
319
  }) };
296
320
  }
297
321
  static importJSON(e) {
298
322
  let { src: t, altText: n, width: r, height: i } = e;
299
- return Y({
323
+ return J({
300
324
  src: t,
301
325
  altText: n,
302
326
  width: r,
@@ -317,13 +341,13 @@ var ue = (e) => {
317
341
  return !0;
318
342
  }
319
343
  };
320
- function Y({ src: e, altText: t, width: n, height: r, key: i }) {
321
- return new J(e, t, n, r, i);
344
+ function J({ src: e, altText: t, width: n, height: r, key: i }) {
345
+ return new q(e, t, n, r, i);
322
346
  }
323
- function pe(e) {
324
- return e instanceof J;
347
+ function Ce(e) {
348
+ return e instanceof q;
325
349
  }
326
- function me(e) {
350
+ function we(e) {
327
351
  if (e instanceof HTMLImageElement) {
328
352
  let { src: t, alt: n, style: r } = e, i, a;
329
353
  if (r.width) {
@@ -334,7 +358,7 @@ function me(e) {
334
358
  let e = parseInt(r.height, 10);
335
359
  isNaN(e) || (a = e);
336
360
  }
337
- return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: Y({
361
+ return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: J({
338
362
  src: t,
339
363
  altText: n,
340
364
  width: i,
@@ -345,23 +369,23 @@ function me(e) {
345
369
  }
346
370
  //#endregion
347
371
  //#region src/components/Editor/plugins/ImagePlugin.tsx
348
- function he() {
372
+ function Te() {
349
373
  let [e] = L();
350
- return g(() => e.registerCommand(a, (e) => (j([Y(e)]), !0), ae), [e]), null;
374
+ return v(() => e.registerCommand(o, (e) => (M([J(e)]), !0), ce), [e]), null;
351
375
  }
352
376
  //#endregion
353
377
  //#region src/components/Editor/plugins/EnterKeyPlugin.tsx
354
- function ge() {
355
- let [e] = L(), t = v(0);
356
- return g(() => e.registerCommand(ce, (n) => {
378
+ function Ee() {
379
+ let [e] = L(), t = b(0);
380
+ return v(() => e.registerCommand(P, (n) => {
357
381
  let r = Date.now(), i = r - t.current;
358
382
  return t.current = r, i < 250 && i > 0 ? (e.update(() => {
359
- let e = A();
383
+ let e = j();
360
384
  if (N(e)) {
361
385
  let t = e.anchor.getNode().getTopLevelElement();
362
386
  if (t && t.getTextContent().trim() === "") {
363
- let n = te();
364
- z(e, {
387
+ let n = O();
388
+ fe(e, {
365
389
  "background-color": "",
366
390
  color: "",
367
391
  "font-size": "",
@@ -374,57 +398,143 @@ function ge() {
374
398
  }
375
399
  }
376
400
  }), n?.preventDefault(), !0) : !1;
377
- }, oe), [e]), null;
401
+ }, le), [e]), null;
402
+ }
403
+ //#endregion
404
+ //#region src/components/Editor/plugins/MaxLengthPlugin.tsx
405
+ function De({ maxLength: e, onMaxLengthExceed: t }) {
406
+ let [n] = L(), r = b(t);
407
+ return r.current = t, v(() => {
408
+ let t = null;
409
+ return n.registerNodeTransform(F, (i) => {
410
+ let a = i.getTextContentSize();
411
+ if (a <= e) return;
412
+ let o = n.getEditorState(), s = o.read(() => i.getTextContentSize()), c = a - e, l = j();
413
+ if (s === e && t !== o) {
414
+ t = o, V(n, o), r.current?.();
415
+ return;
416
+ }
417
+ if (N(l) && l.isCollapsed()) {
418
+ z(n, l.anchor, c), r.current?.();
419
+ return;
420
+ }
421
+ i.selectEnd();
422
+ let u = j();
423
+ N(u) && (z(n, u.anchor, c), r.current?.());
424
+ });
425
+ }, [n, e]), null;
426
+ }
427
+ //#endregion
428
+ //#region src/components/Editor/LengthBadge.tsx
429
+ var Y = ({ current: e, maxLength: t }) => {
430
+ let n = e > t;
431
+ return /* @__PURE__ */ h("div", {
432
+ className: S(G["bsy-lexical-editor__length-badge"], n && G["bsy-lexical-editor__length-badge--exceeded"]),
433
+ "aria-live": "polite",
434
+ children: [
435
+ e,
436
+ "/",
437
+ t
438
+ ]
439
+ });
440
+ };
441
+ Y.displayName = "BsyLexicalEditorLengthBadge";
442
+ //#endregion
443
+ //#region src/components/Editor/utils/textLength.ts
444
+ function Oe(e) {
445
+ return typeof e == "number" && Number.isFinite(e) && e > 0;
446
+ }
447
+ function ke(e, t) {
448
+ let n = A(), r = n.getTextContentSize();
449
+ if (r <= t) return !1;
450
+ let i = r - t;
451
+ n.selectEnd();
452
+ let a = j();
453
+ return N(a) ? z(e, a.anchor, i) : Ae(i), !0;
454
+ }
455
+ function Ae(e) {
456
+ let t = e, n = A().getAllTextNodes();
457
+ for (let e = n.length - 1; e >= 0 && t > 0; e--) {
458
+ let r = n[e], i = r.getTextContent();
459
+ i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
460
+ }
378
461
  }
379
462
  //#endregion
380
463
  //#region src/components/Editor/EditorCore.tsx
381
464
  var X = (e) => {
382
- let { height: t = 126, onChange: n, toolbar: r } = e, [i] = L(), a = v(null), o = v(null), c = _(() => ({
383
- containerRef: a,
384
- getPopupContainer: () => a.current || document.body
385
- }), []), l = h((e) => {
465
+ let { height: t = 126, onChange: n, toolbar: r, theme: i, maxLength: a, onMaxLengthExceed: o } = e, [s] = L(), l = b(null), u = b(null), d = b(o);
466
+ d.current = o;
467
+ let f = Oe(a) ? a : void 0, [p, g] = x(0), C = y(() => ({
468
+ containerRef: l,
469
+ getPopupContainer: () => l.current || document.body
470
+ }), []), D = _((e) => {
386
471
  e.read(() => {
387
- let t = k().getTextContent(), r = D(i, null), a = !t.trim() && (r === "<p><br></p>" || r === "<p></p>" || r === "" || /^<p>\s*<br>\s*<\/p>$/.test(r)) ? null : r;
388
- o.current = a, n({
472
+ let t = A().getTextContent(), r = ne(s, null), i = !t.trim() && (r === "<p><br></p>" || r === "<p></p>" || r === "" || /^<p>\s*<br>\s*<\/p>$/.test(r)) ? null : r;
473
+ u.current = i, f !== void 0 && g(t.length), n({
389
474
  text: t,
390
- html: a
475
+ html: i
391
476
  }, e);
392
- });
393
- }, [n, i]);
394
- g(() => {
395
- e.value !== void 0 && e.value !== o.current && i.update(() => {
396
- k().clear(), e.value && e.value.trim() && j(O(i, new DOMParser().parseFromString(e.value, "text/html")));
397
- });
398
- }, [e.value, i]);
399
- let u = r?.config?.length ? r?.config : [], d = i.isEditable();
400
- return /* @__PURE__ */ f(s.Provider, {
401
- value: c,
402
- children: /* @__PURE__ */ p("div", {
403
- ref: a,
404
- className: K["bsy-lexical-editor"],
405
- onClick: () => {
406
- d || (i.setEditable(!0), i.focus(() => {}, { defaultSelection: "rootEnd" }));
477
+ }, { editor: s });
478
+ }, [
479
+ n,
480
+ s,
481
+ f
482
+ ]);
483
+ v(() => {
484
+ f !== void 0 && s.getEditorState().read(() => {
485
+ g(A().getTextContentSize());
486
+ }, { editor: s });
487
+ }, [s, f]), v(() => {
488
+ if (e.value !== void 0 && e.value !== u.current) {
489
+ let t = !1;
490
+ s.update(() => {
491
+ A().clear(), e.value && e.value.trim() && (M(re(s, new DOMParser().parseFromString(e.value, "text/html"))), f !== void 0 && (t = ke(s, f)));
492
+ }), t && d.current?.();
493
+ }
494
+ }, [
495
+ e.value,
496
+ s,
497
+ f
498
+ ]);
499
+ let O = r?.config?.length ? r?.config : [], k = ge();
500
+ return /* @__PURE__ */ m(c.Provider, {
501
+ value: C,
502
+ children: /* @__PURE__ */ h("div", {
503
+ ref: l,
504
+ className: G["bsy-lexical-editor"],
505
+ onClick: (e) => {
506
+ let t = s.getRootElement(), n = e.target;
507
+ !t || !n || !t.contains(n) || s.isEditable() || s.setEditable(!0);
407
508
  },
408
509
  children: [
409
- u.length > 0 && /* @__PURE__ */ f(de, {
410
- config: u,
411
- style: { ...r?.style }
510
+ O.length > 0 && /* @__PURE__ */ m(xe, {
511
+ config: O,
512
+ theme: i?.toolbar,
513
+ style: r?.style
412
514
  }),
413
- /* @__PURE__ */ f(S, {
414
- contentEditable: /* @__PURE__ */ f(C, {
415
- className: K["bsy-lexical-editor__content-editable"],
515
+ /* @__PURE__ */ m(w, {
516
+ contentEditable: /* @__PURE__ */ m(T, {
517
+ className: S(G["bsy-lexical-editor__content-editable"], f !== void 0 && G["bsy-lexical-editor__content-editable--with-length-badge"]),
416
518
  style: {
417
519
  height: t,
418
- cursor: d ? "auto" : "text"
520
+ cursor: k ? "auto" : "text"
419
521
  }
420
522
  }),
421
- ErrorBoundary: E
523
+ ErrorBoundary: te
524
+ }),
525
+ /* @__PURE__ */ m(_e, {}),
526
+ /* @__PURE__ */ m(Te, {}),
527
+ /* @__PURE__ */ m(Ee, {}),
528
+ f !== void 0 && /* @__PURE__ */ m(De, {
529
+ maxLength: f,
530
+ onMaxLengthExceed: o
422
531
  }),
423
- /* @__PURE__ */ f(W, {}),
424
- /* @__PURE__ */ f(he, {}),
425
- /* @__PURE__ */ f(ge, {}),
426
- /* @__PURE__ */ f(w, {}),
427
- /* @__PURE__ */ f(T, { onChange: l })
532
+ /* @__PURE__ */ m(E, {}),
533
+ /* @__PURE__ */ m(ee, { onChange: D }),
534
+ f !== void 0 && /* @__PURE__ */ m(Y, {
535
+ current: p,
536
+ maxLength: f
537
+ })
428
538
  ]
429
539
  })
430
540
  });
@@ -432,7 +542,7 @@ var X = (e) => {
432
542
  X.displayName = "BsyLexicalEditorCore";
433
543
  //#endregion
434
544
  //#region src/components/Editor/nodes/ExtendedTextNode.tsx
435
- var Z = class e extends F {
545
+ var Z = class e extends I {
436
546
  constructor(e, t) {
437
547
  super(e, t);
438
548
  }
@@ -443,7 +553,7 @@ var Z = class e extends F {
443
553
  return new e(t.__text, t.__key);
444
554
  }
445
555
  static importDOM() {
446
- let e = F.importDOM();
556
+ let e = I.importDOM();
447
557
  return {
448
558
  ...e,
449
559
  code: () => ({
@@ -473,14 +583,14 @@ var Z = class e extends F {
473
583
  };
474
584
  }
475
585
  static importJSON(e) {
476
- return _e().updateFromJSON(e);
586
+ return je().updateFromJSON(e);
477
587
  }
478
588
  isSimpleText() {
479
589
  return this.__type === "extended-text" && this.__mode === 0;
480
590
  }
481
591
  };
482
- function _e(e = "") {
483
- return ee(new Z(e));
592
+ function je(e = "") {
593
+ return D(new Z(e));
484
594
  }
485
595
  function Q(e) {
486
596
  return (t) => {
@@ -493,7 +603,7 @@ function Q(e) {
493
603
  ...r,
494
604
  forChild: (e, t) => {
495
605
  let n = (r?.forChild ?? ((e) => e))(e, t);
496
- if (P(n)) {
606
+ if (se(n)) {
497
607
  let e = [
498
608
  i ? `background-color: ${i}` : null,
499
609
  a ? `color: ${a}` : null,
@@ -513,8 +623,8 @@ function Q(e) {
513
623
  //#region src/components/Editor/Editor.tsx
514
624
  var $ = (e) => {
515
625
  let { autoFocus: t = !1 } = e;
516
- return /* @__PURE__ */ f(x, {
517
- initialConfig: _(() => ({
626
+ return /* @__PURE__ */ m(C, {
627
+ initialConfig: y(() => ({
518
628
  namespace: "bsyLexicalEditor",
519
629
  onError: (e) => {
520
630
  console.error("Lexical error", e);
@@ -529,20 +639,20 @@ var $ = (e) => {
529
639
  link: "editor-link"
530
640
  },
531
641
  nodes: [
532
- U,
533
- H,
534
- J,
642
+ he,
643
+ me,
644
+ q,
535
645
  Z,
536
646
  {
537
- replace: F,
647
+ replace: I,
538
648
  with: (e) => new Z(e.__text),
539
649
  withKlass: Z
540
650
  }
541
651
  ]
542
652
  }), [t]),
543
- children: /* @__PURE__ */ f(X, { ...e })
653
+ children: /* @__PURE__ */ m(X, { ...e })
544
654
  });
545
655
  };
546
656
  $.displayName = "BsyLexicalEditor";
547
657
  //#endregion
548
- export { re as $getRoot, t as BaseButton, $ as default, o as listRegisteredToolbarButtons, n as registerToolbarButton, e as unregisterToolbarButton, I as useLexicalComposerContext };
658
+ export { ie as $getRoot, n as BaseButton, $ as default, s as listRegisteredToolbarButtons, r as registerToolbarButton, t as unregisterToolbarButton, de as useLexicalComposerContext };