@alixpartners/ui-components 2.5.7 → 2.6.1
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/README.md +97 -97
- package/dist/RichTextEditor-JH6YBGiw.js +541 -0
- package/dist/{ToastProvider-D5LImZ-Q.js → ToastProvider-DVycF0zU.js} +26 -26
- package/dist/assets/CorusHeader.css +1 -1
- package/dist/assets/Dialog.css +1 -1
- package/dist/assets/Tab.css +1 -1
- package/dist/assets/Tag.css +1 -1
- package/dist/assets/ap-icons-types.d.ts +1 -1
- package/dist/assets/ap-icons.d.ts +1 -1
- package/dist/assets/main.css +1 -1
- package/dist/components/Banner/Banner.d.ts +1 -1
- package/dist/components/Banner/Banner.test.js +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.test.js +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +3 -3
- package/dist/components/Checkbox/Checkbox.test.js +1 -1
- package/dist/components/CorusHeader/CorusHeader.d.ts +1 -1
- package/dist/components/CorusHeader/CorusHeader.js +45 -44
- package/dist/components/CorusHeader/CorusHeader.types.d.ts +1 -0
- package/dist/components/CorusHeader/DropdownItemContent.d.ts +1 -1
- package/dist/components/CorusHeader/DropdownMenu.d.ts +2 -1
- package/dist/components/CorusHeader/DropdownMenu.js +6 -5
- package/dist/components/CorusHeader/MegaMenuContent.d.ts +2 -1
- package/dist/components/CorusHeader/MegaMenuContent.js +11 -10
- package/dist/components/CorusHeader/UserProfileIcon.d.ts +1 -1
- package/dist/components/Creatable/Creatable.d.ts +1 -1
- package/dist/components/Creatable/Creatable.js +1 -1
- package/dist/components/Datepicker/Datepicker.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.js +1 -1
- package/dist/components/Datepicker/Datepicker.test.js +1 -1
- package/dist/components/Dialog/Dialog.d.ts +8 -2
- package/dist/components/Dialog/Dialog.js +183 -203
- package/dist/components/Dialog/Dialog.test.js +227 -202
- package/dist/components/DragAndDrop/DragAndDrop.d.ts +1 -1
- package/dist/components/DragAndDrop/DragAndDrop.test.js +2 -2
- package/dist/components/Dropdown/Dropdown.d.ts +3 -1
- package/dist/components/Dropdown/Dropdown.js +179 -172
- package/dist/components/FilePicker/FilePicker.d.ts +9 -9
- package/dist/components/FilePicker/FilePicker.test.js +2 -2
- package/dist/components/Ghost/Ghost.d.ts +1 -1
- package/dist/components/Ghost/Ghost.test.js +1 -1
- package/dist/components/Icon/Icon.d.ts +1 -1
- package/dist/components/Icons/IconsGallery.d.ts +1 -1
- package/dist/components/Icons/IconsGallery.js +1 -1
- package/dist/components/Illustration/Illustration.d.ts +1 -1
- package/dist/components/Illustration/Illustration.test.js +1 -1
- package/dist/components/Input/Input.test.js +1 -1
- package/dist/components/Logo/Logo.d.ts +1 -1
- package/dist/components/Logos/LogosGallery.d.ts +1 -1
- package/dist/components/NavBar/NavBar.d.ts +1 -1
- package/dist/components/NavBar/NavBar.js +1 -1
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/Radio/Radio.js +9 -9
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.js +11 -11
- package/dist/components/RadioGroup/RadioGroup.test.js +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.js +2 -2
- package/dist/components/RichTextEditor/RichTextEditor.test.js +2 -2
- package/dist/components/Search/Search.d.ts +1 -1
- package/dist/components/Search/Search.test.js +1 -1
- package/dist/components/Spinner/Spinner.d.ts +1 -1
- package/dist/components/SplitButton/SplitButton.d.ts +1 -1
- package/dist/components/SplitButton/SplitButton.js +3 -3
- package/dist/components/SplitButton/SplitButton.test.js +1 -1
- package/dist/components/Tab/Tab.d.ts +5 -1
- package/dist/components/Tab/Tab.js +28 -24
- package/dist/components/TabNavigation/TabNavigation.d.ts +1 -1
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/components/Tag/Tag.js +1 -1
- package/dist/components/Tag/Tag.test.js +1 -1
- package/dist/components/TagsFields/TagsFields.d.ts +1 -1
- package/dist/components/TagsFields/TagsFields.js +1 -1
- package/dist/components/Textarea/Textarea.d.ts +1 -1
- package/dist/components/Textarea/Textarea.test.js +1 -1
- package/dist/components/Toast/Toast.test.js +1 -1
- package/dist/components/ToastProvider/ToastProvider.d.ts +2 -1
- package/dist/components/ToastProvider/ToastProvider.js +1 -1
- package/dist/components/ToastProvider/ToastProvider.test.js +4 -4
- package/dist/components/Toggle/Toggle.d.ts +1 -1
- package/dist/components/Toggle/Toggle.js +211 -126
- package/dist/components/Toggle/Toggle.test.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.js +60 -61
- package/dist/{index-C2s_VtSb.js → index-6DGSlWJb.js} +3 -3
- package/dist/{index-Nyh2Wa71.js → index-6j3vTf--.js} +5 -5
- package/dist/index-B4szHVNJ.js +248 -0
- package/dist/{index-CFqDEbIR.js → index-BVZdJVFB.js} +192 -191
- package/dist/index-Bq1FiX6B.js +93 -0
- package/dist/index-CE9NpYQR.js +604 -0
- package/dist/index-CHy8gqvu.js +353 -0
- package/dist/index-CarlZuEo.js +1610 -0
- package/dist/{index-CCFDXH-J.js → index-CcsZYEYy.js} +29 -28
- package/dist/index-DH9SO8qV.js +221 -0
- package/dist/{index-D_L0ncPJ.js → index-IR8HlW5P.js} +4 -4
- package/dist/{index-DkTDHhag.js → index-banDzeKa.js} +1 -1
- package/dist/index-kgC_DL6e.js +216 -0
- package/dist/main.js +3 -3
- package/dist/storybook-docs-page.d.ts +1 -1
- package/dist/{useToast-Cz5MGKnw.js → useToast-CpwrYPvx.js} +1 -1
- package/dist/{vi.bdSIJ99Y-017e_Pkz.js → vi.bdSIJ99Y-DWCVXj6K.js} +3 -3
- package/dist/web.config +8 -8
- package/package.json +94 -94
- package/dist/RichTextEditor-kTQEDSL0.js +0 -477
- package/dist/index-C8H9A55g.js +0 -222
- package/dist/index-CCnm5-ML.js +0 -230
- package/dist/index-CfIcUHKK.js +0 -70
- package/dist/index-ChQc_Cm6.js +0 -1544
- package/dist/index-CmGGeUr0.js +0 -142
- package/dist/index-Ii4UOx3H.js +0 -599
- package/dist/index-z_kiwVc3.js +0 -237
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { c as R } from "./clsx-OuTLNxxd.js";
|
|
3
|
-
import { useMemo as ve, useId as Je, useRef as k, useState as u, useEffect as w } from "react";
|
|
4
|
-
import Ve from "./components/Dialog/Dialog.js";
|
|
5
|
-
import z from "./components/Icon/Icon.js";
|
|
6
|
-
import Me from "./components/Input/Input.js";
|
|
7
|
-
import G from "./components/Tooltip/Tooltip.js";
|
|
8
|
-
import { R as Ze, T as Ge, P as Ye, C as Xe } from "./index-CCFDXH-J.js";
|
|
9
|
-
import './assets/RichTextEditor.css';const Qe = "RichTextEditor-module__container___AplP0", et = "RichTextEditor-module__label___vjzs-", tt = "RichTextEditor-module__required___7duke", nt = "RichTextEditor-module__frame___7OSyf", ot = "RichTextEditor-module__frameFocused___GtJ2x", rt = "RichTextEditor-module__frameDisabled___LubtU", it = "RichTextEditor-module__frameError___sPTiY", at = "RichTextEditor-module__errorMessage___4VdKj", lt = "RichTextEditor-module__helpers___cpuz6", ct = "RichTextEditor-module__helperText___rFoU0", st = "RichTextEditor-module__helpLink___7gYcv", dt = "RichTextEditor-module__containerDisabled___6h9dd", ut = "RichTextEditor-module__containerFullWidth___pOoeL", mt = "RichTextEditor-module__toolbarContent___YXKHD", ht = "RichTextEditor-module__toolbarPanel___OVGHO", ft = "RichTextEditor-module__toolbarRow___f0xJR", pt = "RichTextEditor-module__editorBody___f8jPI", _t = "RichTextEditor-module__toolbar___m9-M-", gt = "RichTextEditor-module__toolbarStacked___6rB10", Tt = "RichTextEditor-module__actions___ZAK9J", bt = "RichTextEditor-module__toolButton___IT2Kg", Rt = "RichTextEditor-module__toolButtonActive___-HvZQ", xt = "RichTextEditor-module__toolIcon___Wndhd", Et = "RichTextEditor-module__formatControl___w4WcA", vt = "RichTextEditor-module__toolbarLinkSlot___Gu-9l", Mt = "RichTextEditor-module__selectTrigger___frv3x", kt = "RichTextEditor-module__selectIconBox___SYdTE", Ct = "RichTextEditor-module__selectTriggerOpen___tk2Pb", Lt = "RichTextEditor-module__selectTriggerLabel___FkEv0", yt = "RichTextEditor-module__selectIcon___aJWUk", Ot = "RichTextEditor-module__formatMenu___y-uBL", Nt = "RichTextEditor-module__formatMenuOptions___zcdlo", Ht = "RichTextEditor-module__formatMenuOption___3ppTs", wt = "RichTextEditor-module__formatMenuOptionSelected___bq9J9", Bt = "RichTextEditor-module__formatMenuOptionParagraph___4BLds", St = "RichTextEditor-module__formatMenuOptionHeading1___H1cKX", At = "RichTextEditor-module__formatMenuOptionHeading2___JdixR", Dt = "RichTextEditor-module__formatMenuOptionHeading3___NcwLr", It = "RichTextEditor-module__formatMenuOptionHeading4___4mLbG", Ft = "RichTextEditor-module__formatMenuOptionPreformatted___cB0Ix", Pt = "RichTextEditor-module__editor___M32R7", Ut = "RichTextEditor-module__characterCount___gmUzj", jt = "RichTextEditor-module__characterCountExceeded___vjIpc", zt = "RichTextEditor-module__linkDialogForm___vOLO1", t = {
|
|
10
|
-
container: Qe,
|
|
11
|
-
label: et,
|
|
12
|
-
required: tt,
|
|
13
|
-
frame: nt,
|
|
14
|
-
frameFocused: ot,
|
|
15
|
-
frameDisabled: rt,
|
|
16
|
-
frameError: it,
|
|
17
|
-
errorMessage: at,
|
|
18
|
-
helpers: lt,
|
|
19
|
-
helperText: ct,
|
|
20
|
-
helpLink: st,
|
|
21
|
-
containerDisabled: dt,
|
|
22
|
-
containerFullWidth: ut,
|
|
23
|
-
toolbarContent: mt,
|
|
24
|
-
toolbarPanel: ht,
|
|
25
|
-
toolbarRow: ft,
|
|
26
|
-
editorBody: pt,
|
|
27
|
-
toolbar: _t,
|
|
28
|
-
toolbarStacked: gt,
|
|
29
|
-
actions: Tt,
|
|
30
|
-
toolButton: bt,
|
|
31
|
-
toolButtonActive: Rt,
|
|
32
|
-
toolIcon: xt,
|
|
33
|
-
formatControl: Et,
|
|
34
|
-
toolbarLinkSlot: vt,
|
|
35
|
-
selectTrigger: Mt,
|
|
36
|
-
selectIconBox: kt,
|
|
37
|
-
selectTriggerOpen: Ct,
|
|
38
|
-
selectTriggerLabel: Lt,
|
|
39
|
-
selectIcon: yt,
|
|
40
|
-
formatMenu: Ot,
|
|
41
|
-
formatMenuOptions: Nt,
|
|
42
|
-
formatMenuOption: Ht,
|
|
43
|
-
formatMenuOptionSelected: wt,
|
|
44
|
-
formatMenuOptionParagraph: Bt,
|
|
45
|
-
formatMenuOptionHeading1: St,
|
|
46
|
-
formatMenuOptionHeading2: At,
|
|
47
|
-
formatMenuOptionHeading3: Dt,
|
|
48
|
-
formatMenuOptionHeading4: It,
|
|
49
|
-
formatMenuOptionPreformatted: Ft,
|
|
50
|
-
editor: Pt,
|
|
51
|
-
characterCount: Ut,
|
|
52
|
-
characterCountExceeded: jt,
|
|
53
|
-
linkDialogForm: zt
|
|
54
|
-
}, qt = {
|
|
55
|
-
paragraph: "p",
|
|
56
|
-
heading1: "h1",
|
|
57
|
-
heading2: "h2",
|
|
58
|
-
heading3: "h3",
|
|
59
|
-
heading4: "h4",
|
|
60
|
-
preformatted: "pre",
|
|
61
|
-
"unordered-list": "ul",
|
|
62
|
-
"ordered-list": "ol"
|
|
63
|
-
};
|
|
64
|
-
function ye(a) {
|
|
65
|
-
return a.trim().length > 0 ? a : "<br>";
|
|
66
|
-
}
|
|
67
|
-
function $t(a) {
|
|
68
|
-
switch (a.toLowerCase()) {
|
|
69
|
-
case "h1":
|
|
70
|
-
return "heading1";
|
|
71
|
-
case "h2":
|
|
72
|
-
return "heading2";
|
|
73
|
-
case "h3":
|
|
74
|
-
return "heading3";
|
|
75
|
-
case "h4":
|
|
76
|
-
return "heading4";
|
|
77
|
-
case "pre":
|
|
78
|
-
return "preformatted";
|
|
79
|
-
case "ul":
|
|
80
|
-
return "unordered-list";
|
|
81
|
-
case "ol":
|
|
82
|
-
return "ordered-list";
|
|
83
|
-
case "p":
|
|
84
|
-
default:
|
|
85
|
-
return "paragraph";
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function Y(a) {
|
|
89
|
-
if (!a.trim())
|
|
90
|
-
return {
|
|
91
|
-
blocks: [{
|
|
92
|
-
type: "paragraph",
|
|
93
|
-
html: "<br>"
|
|
94
|
-
}]
|
|
95
|
-
};
|
|
96
|
-
const p = new DOMParser().parseFromString(a, "text/html"), g = Array.from(p.body.childNodes), x = [];
|
|
97
|
-
return g.forEach((l) => {
|
|
98
|
-
var v;
|
|
99
|
-
if (l.nodeType === Node.TEXT_NODE) {
|
|
100
|
-
const C = (v = l.textContent) == null ? void 0 : v.trim();
|
|
101
|
-
C && x.push({
|
|
102
|
-
type: "paragraph",
|
|
103
|
-
html: C
|
|
104
|
-
});
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (l.nodeType !== Node.ELEMENT_NODE)
|
|
108
|
-
return;
|
|
109
|
-
const f = l, E = f.style.textAlign;
|
|
110
|
-
x.push({
|
|
111
|
-
type: $t(f.tagName),
|
|
112
|
-
html: ye(f.innerHTML),
|
|
113
|
-
align: E || void 0
|
|
114
|
-
});
|
|
115
|
-
}), {
|
|
116
|
-
blocks: x.length > 0 ? x : [{
|
|
117
|
-
type: "paragraph",
|
|
118
|
-
html: "<br>"
|
|
119
|
-
}]
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function ke(a) {
|
|
123
|
-
return a.blocks.length ? a.blocks.map((m) => {
|
|
124
|
-
const p = qt[m.type], g = m.align ? ` style="text-align:${m.align}"` : "";
|
|
125
|
-
return `<${p}${g}>${ye(m.html)}</${p}>`;
|
|
126
|
-
}).join("") : "<p><br></p>";
|
|
127
|
-
}
|
|
128
|
-
function Wt(a) {
|
|
129
|
-
return a.blocks.map((p) => p.html.replace(/<[^>]+>/g, "")).join("").length;
|
|
130
|
-
}
|
|
131
|
-
const Kt = ["bold", "italic", "underline", "align-left", "align-center", "align-right", "bulleted", "link", "format"], Jt = [{
|
|
132
|
-
label: "Paragraph",
|
|
133
|
-
value: "paragraph"
|
|
134
|
-
}, {
|
|
135
|
-
label: "Heading 1",
|
|
136
|
-
value: "heading1"
|
|
137
|
-
}, {
|
|
138
|
-
label: "Heading 2",
|
|
139
|
-
value: "heading2"
|
|
140
|
-
}, {
|
|
141
|
-
label: "Heading 3",
|
|
142
|
-
value: "heading3"
|
|
143
|
-
}, {
|
|
144
|
-
label: "Heading 4",
|
|
145
|
-
value: "heading4"
|
|
146
|
-
}, {
|
|
147
|
-
label: "Preformatted",
|
|
148
|
-
value: "preformatted"
|
|
149
|
-
}], Ce = {
|
|
150
|
-
paragraph: "P",
|
|
151
|
-
heading1: "H1",
|
|
152
|
-
heading2: "H2",
|
|
153
|
-
heading3: "H3",
|
|
154
|
-
heading4: "H4",
|
|
155
|
-
preformatted: "PRE",
|
|
156
|
-
"unordered-list": "UL",
|
|
157
|
-
"ordered-list": "OL"
|
|
158
|
-
};
|
|
159
|
-
function X() {
|
|
160
|
-
return "<p><br></p>";
|
|
161
|
-
}
|
|
162
|
-
function Vt(a) {
|
|
163
|
-
return a.trim().length > 0 ? a : X();
|
|
164
|
-
}
|
|
165
|
-
function Le(a) {
|
|
166
|
-
switch (a) {
|
|
167
|
-
case "H1":
|
|
168
|
-
return "heading1";
|
|
169
|
-
case "H2":
|
|
170
|
-
return "heading2";
|
|
171
|
-
case "H3":
|
|
172
|
-
return "heading3";
|
|
173
|
-
case "H4":
|
|
174
|
-
return "heading4";
|
|
175
|
-
case "PRE":
|
|
176
|
-
return "preformatted";
|
|
177
|
-
case "P":
|
|
178
|
-
case "DIV":
|
|
179
|
-
return "paragraph";
|
|
180
|
-
default:
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function Zt(a) {
|
|
185
|
-
switch (a) {
|
|
186
|
-
case "heading1":
|
|
187
|
-
return t.formatMenuOptionHeading1;
|
|
188
|
-
case "heading2":
|
|
189
|
-
return t.formatMenuOptionHeading2;
|
|
190
|
-
case "heading3":
|
|
191
|
-
return t.formatMenuOptionHeading3;
|
|
192
|
-
case "heading4":
|
|
193
|
-
return t.formatMenuOptionHeading4;
|
|
194
|
-
case "preformatted":
|
|
195
|
-
return t.formatMenuOptionPreformatted;
|
|
196
|
-
default:
|
|
197
|
-
return t.formatMenuOptionParagraph;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function rn({
|
|
201
|
-
className: a,
|
|
202
|
-
label: m,
|
|
203
|
-
required: p = !1,
|
|
204
|
-
value: g,
|
|
205
|
-
placeholder: x = "Content",
|
|
206
|
-
disabled: l = !1,
|
|
207
|
-
errorMessage: f,
|
|
208
|
-
helpText: E,
|
|
209
|
-
helpLink: v,
|
|
210
|
-
helpLinkText: C,
|
|
211
|
-
toolbarLayout: q = "inline",
|
|
212
|
-
showToolbar: $ = !0,
|
|
213
|
-
showCharacterCount: Oe = !0,
|
|
214
|
-
maxCharacters: T,
|
|
215
|
-
resizable: Ne = !0,
|
|
216
|
-
rows: He = 8,
|
|
217
|
-
fullWidth: W = !1,
|
|
218
|
-
tooltipEnabled: B = !0,
|
|
219
|
-
formatOptions: Q = Jt,
|
|
220
|
-
toolbarOptions: ee = Kt,
|
|
221
|
-
onChange: K,
|
|
222
|
-
onModelChange: J
|
|
223
|
-
}) {
|
|
224
|
-
const we = ve(() => new Set(ee), [ee]), L = (e) => we.has(e), te = Je(), s = k(null), ne = k(null), oe = k(null), y = k(null), S = k(!1), [Be, re] = u(!1), [A, ie] = u(!1), [Se, Ae] = u(0), [ae, le] = u(null), [De, ce] = u(!1), [se, de] = u(""), [ue, me] = u(""), [he, O] = u(""), [D, fe] = u(() => Y(g || X())), [pe, Ie] = u("paragraph"), [b, Fe] = u({
|
|
225
|
-
bold: !1,
|
|
226
|
-
italic: !1,
|
|
227
|
-
underline: !1,
|
|
228
|
-
justifyLeft: !1,
|
|
229
|
-
justifyCenter: !1,
|
|
230
|
-
justifyRight: !1,
|
|
231
|
-
insertUnorderedList: !1
|
|
232
|
-
}), N = ve(() => Wt(D), [D]), _e = k(N);
|
|
233
|
-
_e.current = N;
|
|
234
|
-
const I = () => {
|
|
235
|
-
if (!s.current) return;
|
|
236
|
-
const e = Y(s.current.innerHTML);
|
|
237
|
-
fe(e), J == null || J(e), K == null || K(ke(e));
|
|
238
|
-
}, ge = () => {
|
|
239
|
-
const e = window.getSelection();
|
|
240
|
-
return e && e.rangeCount > 0 ? e.getRangeAt(0) : null;
|
|
241
|
-
}, Te = (e, n) => {
|
|
242
|
-
const i = s.current;
|
|
243
|
-
let r = e instanceof HTMLElement ? e : (e == null ? void 0 : e.parentElement) ?? null;
|
|
244
|
-
for (; r && r !== i; ) {
|
|
245
|
-
if (n ? r.tagName === n : Le(r.tagName))
|
|
246
|
-
return r;
|
|
247
|
-
r = r.parentElement;
|
|
248
|
-
}
|
|
249
|
-
return null;
|
|
250
|
-
}, Pe = () => {
|
|
251
|
-
const e = ge(), n = Te((e == null ? void 0 : e.startContainer) ?? null);
|
|
252
|
-
return n && Le(n.tagName) || "paragraph";
|
|
253
|
-
}, H = () => {
|
|
254
|
-
Ie(Pe()), Fe({
|
|
255
|
-
bold: document.queryCommandState("bold"),
|
|
256
|
-
italic: document.queryCommandState("italic"),
|
|
257
|
-
underline: document.queryCommandState("underline"),
|
|
258
|
-
justifyLeft: document.queryCommandState("justifyLeft"),
|
|
259
|
-
justifyCenter: document.queryCommandState("justifyCenter"),
|
|
260
|
-
justifyRight: document.queryCommandState("justifyRight"),
|
|
261
|
-
insertUnorderedList: document.queryCommandState("insertUnorderedList")
|
|
262
|
-
});
|
|
263
|
-
}, F = () => {
|
|
264
|
-
var e;
|
|
265
|
-
l || (e = s.current) == null || e.focus();
|
|
266
|
-
}, Ue = (e, n) => {
|
|
267
|
-
l || (F(), document.execCommand(e, !1, n), I(), H());
|
|
268
|
-
}, je = (e) => {
|
|
269
|
-
var n;
|
|
270
|
-
if (!l) {
|
|
271
|
-
if (F(), document.execCommand("formatBlock", !1, Ce[e]), e !== "preformatted") {
|
|
272
|
-
const i = Te(((n = ge()) == null ? void 0 : n.startContainer) ?? null, "PRE");
|
|
273
|
-
if (i) {
|
|
274
|
-
const r = document.createElement(Ce[e].toLowerCase());
|
|
275
|
-
r.innerHTML = i.innerHTML, i.replaceWith(r);
|
|
276
|
-
const h = document.createRange();
|
|
277
|
-
h.selectNodeContents(r), h.collapse(!1);
|
|
278
|
-
const c = window.getSelection();
|
|
279
|
-
c == null || c.removeAllRanges(), c == null || c.addRange(h);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
I(), H();
|
|
283
|
-
}
|
|
284
|
-
}, be = () => {
|
|
285
|
-
var r, h;
|
|
286
|
-
if (l) return;
|
|
287
|
-
F();
|
|
288
|
-
const e = window.getSelection();
|
|
289
|
-
let n = "", i = "";
|
|
290
|
-
if (e && e.rangeCount > 0) {
|
|
291
|
-
const c = e.getRangeAt(0);
|
|
292
|
-
y.current = c.cloneRange(), n = e.toString();
|
|
293
|
-
const _ = ((r = c.startContainer.parentElement) == null ? void 0 : r.closest("a")) ?? ((h = c.endContainer.parentElement) == null ? void 0 : h.closest("a"));
|
|
294
|
-
_ instanceof HTMLAnchorElement && (n = _.textContent ?? n, i = _.getAttribute("href") ?? "");
|
|
295
|
-
} else
|
|
296
|
-
y.current = null;
|
|
297
|
-
de(n), me(i), O(""), ce(!0);
|
|
298
|
-
}, V = () => {
|
|
299
|
-
if (S.current) {
|
|
300
|
-
S.current = !1;
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
ce(!1), O(""), y.current = null;
|
|
304
|
-
}, ze = (e) => {
|
|
305
|
-
me(e), he && O("");
|
|
306
|
-
}, qe = (e) => {
|
|
307
|
-
const n = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
308
|
-
try {
|
|
309
|
-
const i = /^https?:\/\//i.test(e), r = new URL(i ? e : `https://${e}`);
|
|
310
|
-
return r.protocol !== "http:" && r.protocol !== "https:" ? !1 : n.test(r.hostname);
|
|
311
|
-
} catch {
|
|
312
|
-
return !1;
|
|
313
|
-
}
|
|
314
|
-
}, $e = (e) => /^https?:\/\//i.test(e) ? e : `https://${/^www\./i.test(e) ? e : `www.${e}`}`, We = () => {
|
|
315
|
-
const e = ue.trim();
|
|
316
|
-
if (!e) {
|
|
317
|
-
O("This field is required"), S.current = !0;
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
if (!qe(e)) {
|
|
321
|
-
O("Invalid link"), S.current = !0;
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
const n = $e(e), i = se.trim() || e, r = (_) => _.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), h = `<a href="${r(n)}" target="_blank" rel="noopener noreferrer">${r(i)}</a>`;
|
|
325
|
-
F();
|
|
326
|
-
const c = window.getSelection();
|
|
327
|
-
c && y.current && (c.removeAllRanges(), c.addRange(y.current)), document.execCommand("insertHTML", !1, h), I(), H(), V();
|
|
328
|
-
}, Ke = (e) => {
|
|
329
|
-
if (!e.ctrlKey && !e.metaKey) return;
|
|
330
|
-
const n = e.target, i = n == null ? void 0 : n.closest("a");
|
|
331
|
-
i instanceof HTMLAnchorElement && i.href && (e.preventDefault(), window.open(i.href, "_blank", "noopener,noreferrer"));
|
|
332
|
-
};
|
|
333
|
-
w(() => {
|
|
334
|
-
if (!s.current || document.activeElement === s.current) return;
|
|
335
|
-
const e = Vt(g || X()), n = Y(e);
|
|
336
|
-
fe(n), s.current.innerHTML !== e && (s.current.innerHTML = e);
|
|
337
|
-
}, [g]), w(() => {
|
|
338
|
-
s.current && (s.current.innerHTML.trim() || (s.current.innerHTML = ke(D)));
|
|
339
|
-
}, [D]), w(() => {
|
|
340
|
-
const e = s.current;
|
|
341
|
-
if (!e || !T) return;
|
|
342
|
-
const n = (i) => {
|
|
343
|
-
var _;
|
|
344
|
-
if (!i.inputType.startsWith("insert")) return;
|
|
345
|
-
const r = window.getSelection(), h = r && !r.isCollapsed ? r.toString().length : 0, c = i.data ? i.data.length : ((_ = i.dataTransfer) == null ? void 0 : _.getData("text").length) ?? 0;
|
|
346
|
-
_e.current - h + c > T && i.preventDefault();
|
|
347
|
-
};
|
|
348
|
-
return e.addEventListener("beforeinput", n), () => e.removeEventListener("beforeinput", n);
|
|
349
|
-
}, [T]), w(() => {
|
|
350
|
-
var n;
|
|
351
|
-
const e = (n = ne.current) == null ? void 0 : n.getBoundingClientRect().width;
|
|
352
|
-
e && Ae(e);
|
|
353
|
-
}, [A]), w(() => {
|
|
354
|
-
if (!$ || W) {
|
|
355
|
-
le(null);
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
const e = oe.current;
|
|
359
|
-
if (!e) return;
|
|
360
|
-
const n = () => {
|
|
361
|
-
const r = e.getBoundingClientRect().width;
|
|
362
|
-
r > 0 && le(r);
|
|
363
|
-
};
|
|
364
|
-
n();
|
|
365
|
-
const i = new ResizeObserver(() => {
|
|
366
|
-
n();
|
|
367
|
-
});
|
|
368
|
-
return i.observe(e), window.addEventListener("resize", n), () => {
|
|
369
|
-
i.disconnect(), window.removeEventListener("resize", n);
|
|
370
|
-
};
|
|
371
|
-
}, [$, q, l, B, W]);
|
|
372
|
-
const M = (e) => /* @__PURE__ */ o(G, { content: e.tooltip, size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !B, children: /* @__PURE__ */ o("button", { type: "button", className: R(t.toolButton, e.active && t.toolButtonActive), onMouseDown: (n) => n.preventDefault(), onClick: () => Ue(e.command, e.value), "aria-label": e.tooltip, disabled: l, children: /* @__PURE__ */ o(z, { icon: e.icon, className: t.toolIcon }) }) }, e.id), Z = [{
|
|
373
|
-
id: "bold",
|
|
374
|
-
icon: "ap-icon-bold",
|
|
375
|
-
command: "bold",
|
|
376
|
-
tooltip: "Bold (CTRL + B)",
|
|
377
|
-
active: b.bold
|
|
378
|
-
}, {
|
|
379
|
-
id: "italic",
|
|
380
|
-
icon: "ap-icon-italic",
|
|
381
|
-
command: "italic",
|
|
382
|
-
tooltip: "Italic (CTRL + I)",
|
|
383
|
-
active: b.italic
|
|
384
|
-
}, {
|
|
385
|
-
id: "underline",
|
|
386
|
-
icon: "ap-icon-underline",
|
|
387
|
-
command: "underline",
|
|
388
|
-
tooltip: "Underline (CTRL + U)",
|
|
389
|
-
active: b.underline
|
|
390
|
-
}, {
|
|
391
|
-
id: "align-left",
|
|
392
|
-
icon: "ap-icon-align-left",
|
|
393
|
-
command: "justifyLeft",
|
|
394
|
-
tooltip: "Align left",
|
|
395
|
-
active: b.justifyLeft
|
|
396
|
-
}, {
|
|
397
|
-
id: "align-center",
|
|
398
|
-
icon: "ap-icon-align-center",
|
|
399
|
-
command: "justifyCenter",
|
|
400
|
-
tooltip: "Align center",
|
|
401
|
-
active: b.justifyCenter
|
|
402
|
-
}, {
|
|
403
|
-
id: "align-right",
|
|
404
|
-
icon: "ap-icon-align-right",
|
|
405
|
-
command: "justifyRight",
|
|
406
|
-
tooltip: "Align right",
|
|
407
|
-
active: b.justifyRight
|
|
408
|
-
}, {
|
|
409
|
-
id: "bulleted",
|
|
410
|
-
icon: "ap-icon-list",
|
|
411
|
-
command: "insertUnorderedList",
|
|
412
|
-
tooltip: "Bulleted list",
|
|
413
|
-
active: b.insertUnorderedList
|
|
414
|
-
}], P = Z.filter((e) => ["bold", "italic", "underline"].includes(e.id) && L(e.id)), U = Z.filter((e) => ["align-left", "align-center", "align-right"].includes(e.id) && L(e.id)), j = Z.filter((e) => ["bulleted"].includes(e.id) && L(e.id)), Re = L("link"), xe = L("format"), Ee = () => {
|
|
415
|
-
var e;
|
|
416
|
-
return /* @__PURE__ */ o("div", { className: t.formatControl, children: /* @__PURE__ */ d(Ze, { open: A, onOpenChange: ie, children: [
|
|
417
|
-
/* @__PURE__ */ d(Ge, { ref: ne, disabled: l, className: R(t.selectTrigger, A && t.selectTriggerOpen), children: [
|
|
418
|
-
/* @__PURE__ */ o("span", { className: t.selectTriggerLabel, children: ((e = Q.find((n) => n.value === pe)) == null ? void 0 : e.label) || "Paragraph" }),
|
|
419
|
-
/* @__PURE__ */ o("span", { className: t.selectIconBox, children: /* @__PURE__ */ o(z, { icon: A ? "ap-icon-expand-less" : "ap-icon-expand-more", className: t.selectIcon }) })
|
|
420
|
-
] }),
|
|
421
|
-
/* @__PURE__ */ o(Ye, { children: /* @__PURE__ */ o(Xe, { align: "end", side: "bottom", sideOffset: 6, collisionPadding: 8, className: t.formatMenu, style: {
|
|
422
|
-
minWidth: Se || 180,
|
|
423
|
-
zIndex: 9999
|
|
424
|
-
}, onCloseAutoFocus: (n) => {
|
|
425
|
-
n.preventDefault();
|
|
426
|
-
}, children: /* @__PURE__ */ o("div", { className: t.formatMenuOptions, children: Q.map((n) => /* @__PURE__ */ o("button", { type: "button", className: R(t.formatMenuOption, Zt(n.value), n.value === pe && t.formatMenuOptionSelected), onMouseDown: (i) => i.preventDefault(), onClick: () => {
|
|
427
|
-
je(n.value), ie(!1);
|
|
428
|
-
}, children: n.label }, n.value)) }) }) })
|
|
429
|
-
] }) });
|
|
430
|
-
};
|
|
431
|
-
return /* @__PURE__ */ d("div", { className: R(t.container, l && t.containerDisabled, W && t.containerFullWidth, a), children: [
|
|
432
|
-
m && /* @__PURE__ */ d("label", { className: t.label, htmlFor: te, children: [
|
|
433
|
-
m,
|
|
434
|
-
p && /* @__PURE__ */ o("span", { className: t.required, children: "*" })
|
|
435
|
-
] }),
|
|
436
|
-
/* @__PURE__ */ d("div", { className: R(t.frame, Be && t.frameFocused, l && t.frameDisabled, f && t.frameError), style: {
|
|
437
|
-
width: ae ? `${ae}px` : void 0
|
|
438
|
-
}, children: [
|
|
439
|
-
$ && /* @__PURE__ */ o("div", { className: R(t.toolbar, q === "stacked" && t.toolbarStacked), children: /* @__PURE__ */ o("div", { ref: oe, className: t.toolbarContent, children: q === "stacked" ? /* @__PURE__ */ d("div", { className: t.toolbarPanel, children: [
|
|
440
|
-
/* @__PURE__ */ d("div", { className: t.toolbarRow, children: [
|
|
441
|
-
P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(M) }),
|
|
442
|
-
U.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: U.map(M) })
|
|
443
|
-
] }),
|
|
444
|
-
/* @__PURE__ */ d("div", { className: t.toolbarRow, children: [
|
|
445
|
-
j.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: j.map(M) }),
|
|
446
|
-
Re && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !B, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: be, "aria-label": "Insert link", disabled: l, children: /* @__PURE__ */ o(z, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
|
|
447
|
-
xe && Ee()
|
|
448
|
-
] })
|
|
449
|
-
] }) : /* @__PURE__ */ o("div", { className: t.toolbarPanel, children: /* @__PURE__ */ d("div", { className: t.toolbarRow, children: [
|
|
450
|
-
P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(M) }),
|
|
451
|
-
U.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: U.map(M) }),
|
|
452
|
-
j.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: j.map(M) }),
|
|
453
|
-
Re && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !B, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: be, "aria-label": "Insert link", disabled: l, children: /* @__PURE__ */ o(z, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
|
|
454
|
-
xe && Ee()
|
|
455
|
-
] }) }) }) }),
|
|
456
|
-
/* @__PURE__ */ d("div", { className: t.editorBody, style: {
|
|
457
|
-
minHeight: `${He * 20}px`,
|
|
458
|
-
resize: Ne && !l ? "vertical" : "none"
|
|
459
|
-
}, children: [
|
|
460
|
-
/* @__PURE__ */ o("div", { id: te, ref: s, className: t.editor, contentEditable: !l, suppressContentEditableWarning: !0, role: "textbox", "aria-multiline": "true", "aria-label": m || "Rich text editor", "data-placeholder": x, onInput: I, onFocus: () => re(!0), onBlur: () => re(!1), onKeyUp: H, onMouseUp: H, onClick: Ke }),
|
|
461
|
-
Oe && /* @__PURE__ */ o("div", { className: R(t.characterCount, T && N > T && t.characterCountExceeded), children: T ? `${N}/${T}` : N })
|
|
462
|
-
] })
|
|
463
|
-
] }),
|
|
464
|
-
(f || E || v) && /* @__PURE__ */ d("div", { className: t.helpers, children: [
|
|
465
|
-
f ? /* @__PURE__ */ o("span", { title: f, className: t.errorMessage, children: f }) : E && /* @__PURE__ */ o("span", { title: E, className: t.helperText, children: E }),
|
|
466
|
-
v && C && /* @__PURE__ */ o("a", { href: v, className: t.helpLink, target: "_blank", rel: "noopener noreferrer", children: C })
|
|
467
|
-
] }),
|
|
468
|
-
/* @__PURE__ */ o(Ve, { isOpen: De, onClose: V, title: "Attach link", cancelButtonText: "Cancel", cancelButtonType: "primary", cancelButtonVariant: "cancel", confirmButtonText: "Attach", confirmButtonType: "primary", onCancel: V, onConfirm: We, description: /* @__PURE__ */ d("div", { className: t.linkDialogForm, children: [
|
|
469
|
-
/* @__PURE__ */ o(Me, { type: "text", label: "Displayed text", value: se, onChange: de, autofocus: !0 }),
|
|
470
|
-
/* @__PURE__ */ o(Me, { type: "text", label: "Link", value: ue, placeholder: "https://example.com/", required: !0, errorMessage: he || void 0, onChange: ze })
|
|
471
|
-
] }) })
|
|
472
|
-
] });
|
|
473
|
-
}
|
|
474
|
-
export {
|
|
475
|
-
rn as R,
|
|
476
|
-
t as s
|
|
477
|
-
};
|