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