@alixpartners/ui-components 2.5.5 → 2.5.7

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.
@@ -0,0 +1,477 @@
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), 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
+ };
@@ -1 +1 @@
1
- .CorusHeader-module__navbar-wrapper___1KxAb{background-color:#333;width:100%;height:56px;padding:8px 20px;box-sizing:border-box}.CorusHeader-module__navbar-container___E75C0{display:flex;align-items:center;justify-content:space-between;height:100%;margin-left:auto;margin-right:auto}.CorusHeader-module__navbar-logo-container___va-bi{display:flex;align-items:center;gap:12px}.CorusHeader-module__navbar-logo-link___c96t1{display:flex;align-items:center;cursor:pointer}.CorusHeader-module__navbar-project-name___TmX-b{font-size:18px;font-weight:500;color:#fff}.CorusHeader-module__navbar-module-name___GKW5y{font-size:18px;font-weight:500;color:#8dca7e}.CorusHeader-module__navbar-menu___t4hvB{display:flex;align-items:center;height:100%}.CorusHeader-module__navbar-menu-list___avqIc button{all:unset}.CorusHeader-module__navbar-menu-list___avqIc{display:flex;align-items:center;gap:16px;padding:0;margin:0;height:100%}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr{cursor:pointer;text-decoration:none;color:#fff;line-height:1;height:100%;display:flex;align-items:center}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr .CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr .CorusHeader-module__navbar-menu-list-item-action___Fd2Kz{display:flex;align-items:center;gap:4px;box-sizing:border-box;padding-top:16px;padding-bottom:16px;font-size:13px;font-weight:500;height:100%}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr:hover .CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr:hover .CorusHeader-module__navbar-menu-list-item-action___Fd2Kz,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-action___Fd2Kz,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr:hover .CorusHeader-module__navbar-menu-list-item-arrow___-peqY,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-arrow___-peqY{color:#8dca7e}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-arrow___-peqY{transform:rotate(180deg)}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr a{text-decoration:none;color:#fff}.CorusHeader-module__navbar-menu-list-item-arrow___-peqY{color:#fff;font-size:16px;width:16px;height:16px;transition:transform .2s ease}.CorusHeader-module__navbar-menu-list-item-submenu___XdiI1{margin-top:6px;padding:2px;background-color:#fff;border:1px solid #cccccc;border-radius:4px;z-index:1000;max-height:300px;overflow:hidden;display:flex;flex-direction:column;width:fit-content;box-sizing:border-box;box-shadow:0 0 4px #00000029}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo{width:100%;padding:8px 12px;border:none;background:none;cursor:pointer;display:flex;align-items:center;transition:background-color .2s ease;text-align:left;font-size:13px;color:#4a4a4a;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:4px;font-family:Roboto,sans-serif;min-height:24px;box-sizing:border-box}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo:hover{background-color:#dff0db}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo:focus{outline:none}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo a{text-decoration:none;color:inherit;width:100%}.CorusHeader-module__navbar-action-button___Db8zx{margin-right:8px}.CorusHeader-module__navbar-menu-additional___00q5q{display:flex;align-items:center;gap:8px;margin-left:24px}.CorusHeader-module__navbar-menu-additional-trigger___HZmWR{all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;height:47px;box-sizing:border-box}.CorusHeader-module__navbar-menu-additional-icon___4EDq9{width:24px;height:24px}.CorusHeader-module__navbar-settings-icon___TeGCJ{color:#fff;font-size:20px;width:20px;height:20px}.CorusHeader-module__navbar-profile-icon___I2WA2{color:#fff;width:17px;height:17px}.CorusHeader-module__navbar-menu-additional-trigger___HZmWR:hover .CorusHeader-module__navbar-settings-icon___TeGCJ,.CorusHeader-module__navbar-menu-additional-trigger___HZmWR[data-state=open] .CorusHeader-module__navbar-settings-icon___TeGCJ{color:#8dca7e}.CorusHeader-module__mega-menu-content___W-xjj{margin-top:-4px;background-color:#fff;border-radius:4px;box-shadow:0 4px 8px #00000029;display:flex;flex-direction:row;z-index:1000;box-sizing:border-box;padding:0 8px}.CorusHeader-module__mega-menu-column-wrapper___1ZgWq{display:flex;flex-direction:row;align-items:stretch}.CorusHeader-module__mega-menu-divider___6nYcz{width:1px;align-self:stretch;background-color:#dff0db;flex-shrink:0}.CorusHeader-module__mega-menu-column___yHh9s{display:flex;flex-direction:column;padding:24px;min-width:200px;width:200px;gap:0}.CorusHeader-module__mega-menu-items___hJQSC{display:flex;flex-direction:column;gap:8px;flex:1}.CorusHeader-module__mega-menu-heading___aPj3a{padding:8px 0;font-size:12px;font-weight:400;font-family:Roboto,sans-serif;color:#727272;text-transform:uppercase;letter-spacing:.5px;line-height:14px;white-space:nowrap}.CorusHeader-module__mega-menu-item___WxCN-{display:flex;flex-direction:column;padding:8px;border-radius:4px;cursor:pointer;text-decoration:none;color:inherit;transition:background-color .15s ease;box-sizing:border-box}.CorusHeader-module__mega-menu-item___WxCN-:hover{background-color:#dff0db}.CorusHeader-module__mega-menu-item___WxCN-:focus{outline:none;background-color:#dff0db}.CorusHeader-module__mega-menu-item-label___TyZiu{display:block;font-size:13px;font-weight:500;font-family:Roboto,sans-serif;color:#28292c;line-height:19px}.CorusHeader-module__mega-menu-item-description___e3-s2{display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;white-space:normal;width:100%;font-size:12px;font-weight:400;font-family:Roboto,sans-serif;color:#727272;line-height:14px;margin-top:2px}.CorusHeader-module__dropdown-item-row___pBKtB{display:flex;align-items:flex-start;gap:4px;width:100%}.CorusHeader-module__dropdown-item-icon___cPSQk{flex-shrink:0;width:16px;height:16px;font-size:16px;color:#28292c;margin-top:1px}.CorusHeader-module__dropdown-item-content___z4wRj{display:flex;flex-direction:column;flex:1;min-width:0}.CorusHeader-module__mega-menu-footer___sBd8B{margin-top:32px}
1
+ .CorusHeader-module__navbar-wrapper___1KxAb{background-color:#333;width:100%;height:56px;padding:8px 20px;box-sizing:border-box}.CorusHeader-module__navbar-container___E75C0{display:flex;align-items:center;justify-content:space-between;height:100%;margin-left:auto;margin-right:auto}.CorusHeader-module__navbar-logo-container___va-bi{display:flex;align-items:center;gap:12px}.CorusHeader-module__navbar-logo-link___c96t1{display:flex;align-items:center;cursor:pointer}.CorusHeader-module__navbar-project-name___TmX-b{font-size:18px;font-weight:500;color:#fff}.CorusHeader-module__navbar-module-name___GKW5y{font-size:18px;font-weight:500;color:#8dca7e}.CorusHeader-module__navbar-menu___t4hvB{display:flex;align-items:center;height:100%}.CorusHeader-module__navbar-menu-list___avqIc button{all:unset}.CorusHeader-module__navbar-menu-list___avqIc{display:flex;align-items:center;gap:16px;padding:0;margin:0;height:100%}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr{cursor:pointer;text-decoration:none;color:#fff;line-height:1;height:100%;display:flex;align-items:center}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr .CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr .CorusHeader-module__navbar-menu-list-item-action___Fd2Kz{display:flex;align-items:center;gap:4px;box-sizing:border-box;padding-top:16px;padding-bottom:16px;font-size:13px;font-weight:500;height:100%}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr:hover .CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr:hover .CorusHeader-module__navbar-menu-list-item-action___Fd2Kz,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-action___Fd2Kz,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr:hover .CorusHeader-module__navbar-menu-list-item-arrow___-peqY,.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-arrow___-peqY{color:#8dca7e}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr[data-state=open] .CorusHeader-module__navbar-menu-list-item-arrow___-peqY{transform:rotate(180deg)}.CorusHeader-module__navbar-menu-list___avqIc .CorusHeader-module__navbar-menu-list-item___EvvFr a{text-decoration:none;color:#fff}.CorusHeader-module__navbar-menu-list-item-arrow___-peqY{color:#fff;font-size:16px!important;width:16px;height:16px;transition:transform .2s ease}.CorusHeader-module__navbar-menu-list-item-submenu___XdiI1{margin-top:6px;padding:2px;background-color:#fff;border:1px solid #cccccc;border-radius:4px;z-index:1000;max-height:300px;overflow:hidden;display:flex;flex-direction:column;width:fit-content;box-sizing:border-box;box-shadow:0 0 4px #00000029}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo{width:100%;padding:8px 12px;border:none;background:none;cursor:pointer;display:flex;align-items:center;transition:background-color .2s ease;text-align:left;font-size:13px;color:#4a4a4a;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:4px;font-family:Roboto,sans-serif;min-height:24px;box-sizing:border-box}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo:hover{background-color:#dff0db}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo:focus{outline:none}.CorusHeader-module__navbar-menu-list-item-submenu-item___Y-PRo a{text-decoration:none;color:inherit;width:100%}.CorusHeader-module__navbar-action-button___Db8zx{margin-right:8px}.CorusHeader-module__navbar-menu-additional___00q5q{display:flex;align-items:center;gap:8px;margin-left:24px}.CorusHeader-module__navbar-menu-additional-trigger___HZmWR{all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;height:47px;box-sizing:border-box}.CorusHeader-module__navbar-menu-additional-icon___4EDq9{width:24px;height:24px}.CorusHeader-module__navbar-settings-icon___TeGCJ{color:#fff;font-size:20px!important;width:20px;height:20px}.CorusHeader-module__navbar-profile-icon___I2WA2{color:#fff;width:17px;height:17px}.CorusHeader-module__navbar-menu-additional-trigger___HZmWR:hover .CorusHeader-module__navbar-settings-icon___TeGCJ,.CorusHeader-module__navbar-menu-additional-trigger___HZmWR[data-state=open] .CorusHeader-module__navbar-settings-icon___TeGCJ{color:#8dca7e}.CorusHeader-module__mega-menu-content___W-xjj{margin-top:-4px;background-color:#fff;border-radius:4px;box-shadow:0 4px 8px #00000029;display:flex;flex-direction:row;z-index:1000;box-sizing:border-box;padding:0 8px}.CorusHeader-module__mega-menu-column-wrapper___1ZgWq{display:flex;flex-direction:row;align-items:stretch}.CorusHeader-module__mega-menu-divider___6nYcz{width:1px;align-self:stretch;background-color:#dff0db;flex-shrink:0}.CorusHeader-module__mega-menu-column___yHh9s{display:flex;flex-direction:column;padding:24px;min-width:200px;width:200px;gap:0}.CorusHeader-module__mega-menu-items___hJQSC{display:flex;flex-direction:column;gap:8px;flex:1}.CorusHeader-module__mega-menu-heading___aPj3a{padding:8px 0;font-size:12px;font-weight:400;font-family:Roboto,sans-serif;color:#727272;text-transform:uppercase;letter-spacing:.5px;line-height:14px;white-space:nowrap}.CorusHeader-module__mega-menu-item___WxCN-{display:flex;flex-direction:column;padding:8px;border-radius:4px;cursor:pointer;text-decoration:none;color:inherit;transition:background-color .15s ease;box-sizing:border-box}.CorusHeader-module__mega-menu-item___WxCN-:hover{background-color:#dff0db}.CorusHeader-module__mega-menu-item___WxCN-:focus{outline:none;background-color:#dff0db}.CorusHeader-module__mega-menu-item___WxCN-[data-disabled]{cursor:not-allowed;pointer-events:none}.CorusHeader-module__mega-menu-item___WxCN-[data-disabled] .CorusHeader-module__mega-menu-item-label___TyZiu{color:#b0b0b0}.CorusHeader-module__mega-menu-item___WxCN-[data-disabled] .CorusHeader-module__mega-menu-item-description___e3-s2{color:#c8c8c8}.CorusHeader-module__mega-menu-item___WxCN-[data-disabled]:hover{background-color:transparent}.CorusHeader-module__mega-menu-item-label___TyZiu{display:block;font-size:13px;font-weight:500;font-family:Roboto,sans-serif;color:#28292c;line-height:19px}.CorusHeader-module__mega-menu-item-description___e3-s2{display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;white-space:normal;width:100%;font-size:12px;font-weight:400;font-family:Roboto,sans-serif;color:#727272;line-height:14px;margin-top:2px}.CorusHeader-module__dropdown-item-row___pBKtB{display:flex;align-items:flex-start;gap:4px;width:100%}.CorusHeader-module__dropdown-item-icon___cPSQk{flex-shrink:0;width:16px;height:16px;font-size:16px;color:#28292c;margin-top:1px}.CorusHeader-module__dropdown-item-content___z4wRj{display:flex;flex-direction:column;flex:1;min-width:0}.CorusHeader-module__mega-menu-footer___sBd8B{margin-top:32px}.CorusHeader-module__mega-menu-footer___sBd8B button{width:100%!important}
@@ -1,3 +1,3 @@
1
1
  import { CorusHeaderProps } from './CorusHeader.types';
2
- export type { CorusHeaderNavItem, CorusHeaderNavGroup, CorusHeaderMenuItem, CorusHeaderDropdownItem, CorusHeaderProps, } from './CorusHeader.types';
3
- export default function CorusHeader({ projectName, projectLogoIcon, projectLogoOnClick, moduleName, menuItems, actionButton, additionalItems, className, maxWidth, ...props }: CorusHeaderProps): import("react/jsx-runtime").JSX.Element;
2
+ export type { CorusHeaderNavItem, CorusHeaderNavGroup, CorusHeaderMenuItem, CorusHeaderDropdownItem, CorusHeaderFooterAction, CorusHeaderAdditionalItems, CorusHeaderMenuConfig, CorusHeaderProps, } from './CorusHeader.types';
3
+ export default function CorusHeader({ projectName, projectLogoIcon, projectLogoOnClick, moduleName, menuConfig, className, maxWidth, ...props }: CorusHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,65 +1,66 @@
1
- import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
- import { useState as P, useRef as k } from "react";
3
- import { c as w } from "../../clsx-OuTLNxxd.js";
4
- import x from "../Logo/Logo.js";
5
- import g from "../Icon/Icon.js";
6
- import y from "../Button/Button.js";
1
+ import { jsx as r, jsxs as a } from "react/jsx-runtime";
2
+ import { useState as M, useRef as P } from "react";
3
+ import { c as k } from "../../clsx-OuTLNxxd.js";
4
+ import w from "../Logo/Logo.js";
5
+ import u from "../Icon/Icon.js";
6
+ import x from "../Button/Button.js";
7
7
  import { s as o } from "../../CorusHeader.module-xOp6ZX_M.js";
8
- import b from "./DropdownMenu.js";
9
- import D from "./MegaMenuContent.js";
10
- import R from "./UserProfileIcon.js";
11
- import { R as j, M as O, T } from "../../index-D_L0ncPJ.js";
12
- const z = {
8
+ import p from "./DropdownMenu.js";
9
+ import y from "./MegaMenuContent.js";
10
+ import B from "./UserProfileIcon.js";
11
+ import { R as D, M as R, T as j } from "../../index-D_L0ncPJ.js";
12
+ const O = {
13
13
  type: "primary",
14
14
  size: "sm",
15
15
  icon: "ap-icon-person-add",
16
16
  iconPosition: "left"
17
17
  };
18
- function Q({
19
- projectName: f,
20
- projectLogoIcon: h = "ap-icon-logo-corus",
21
- projectLogoOnClick: v,
18
+ function J({
19
+ projectName: m,
20
+ projectLogoIcon: g = "ap-icon-logo-corus",
21
+ projectLogoOnClick: b,
22
22
  moduleName: i,
23
- menuItems: s,
24
- actionButton: a,
25
- additionalItems: n,
26
- className: t,
27
- maxWidth: N,
28
- ...m
23
+ menuConfig: f,
24
+ className: h,
25
+ maxWidth: v,
26
+ ...N
29
27
  }) {
30
- const [c, p] = P(null), u = k(null), C = a || (n == null ? void 0 : n.settings) && n.settings.length > 0 || (n == null ? void 0 : n.userProfile);
31
- return /* @__PURE__ */ r("div", { className: w(o["navbar-wrapper"], t), ...m, children: /* @__PURE__ */ l("div", { className: o["navbar-container"], style: {
32
- maxWidth: N
28
+ const [s, l] = M(null), c = P(null), {
29
+ items: t,
30
+ additionalItems: n
31
+ } = f ?? {}, d = (n == null ? void 0 : n.actionButton) || (n == null ? void 0 : n.settings) && n.settings.length > 0 || (n == null ? void 0 : n.userProfile);
32
+ return /* @__PURE__ */ r("div", { className: k(o["navbar-wrapper"], h), ...N, children: /* @__PURE__ */ a("div", { className: o["navbar-container"], style: {
33
+ maxWidth: v
33
34
  }, children: [
34
- /* @__PURE__ */ l("div", { className: o["navbar-logo-container"], children: [
35
- /* @__PURE__ */ r("a", { onClick: v, className: o["navbar-logo-link"], children: /* @__PURE__ */ r(x, { logo: h, color: "lightGreen" }) }),
36
- /* @__PURE__ */ r("span", { className: o["navbar-project-name"], children: f }),
35
+ /* @__PURE__ */ a("div", { className: o["navbar-logo-container"], children: [
36
+ /* @__PURE__ */ r("a", { onClick: b, className: o["navbar-logo-link"], children: /* @__PURE__ */ r(w, { logo: g, color: "lightGreen" }) }),
37
+ /* @__PURE__ */ r("span", { className: o["navbar-project-name"], children: m }),
37
38
  i && /* @__PURE__ */ r("span", { className: o["navbar-module-name"], children: i })
38
39
  ] }),
39
- /* @__PURE__ */ l("div", { className: o["navbar-menu"], children: [
40
- /* @__PURE__ */ r(j, { className: o["navbar-menu-list"], children: s == null ? void 0 : s.map((e) => /* @__PURE__ */ r("div", { children: /* @__PURE__ */ l(O, { open: c === e.label, onOpenChange: (M) => p(M ? e.label : null), children: [
41
- /* @__PURE__ */ r(T, { "data-state": c === e.label ? "open" : "closed", onPointerDown: () => {
42
- u.current = c === e.label ? e.label : null;
40
+ /* @__PURE__ */ a("div", { className: o["navbar-menu"], children: [
41
+ /* @__PURE__ */ r(D, { className: o["navbar-menu-list"], children: t == null ? void 0 : t.map((e) => /* @__PURE__ */ r("div", { children: /* @__PURE__ */ a(R, { open: s === e.label, onOpenChange: (C) => l(C ? e.label : null), children: [
42
+ /* @__PURE__ */ r(j, { "data-state": s === e.label ? "open" : "closed", onPointerDown: () => {
43
+ c.current = s === e.label ? e.label : null;
43
44
  }, onClick: () => {
44
- if (u.current === e.label) {
45
- u.current = null;
45
+ if (c.current === e.label) {
46
+ c.current = null;
46
47
  return;
47
48
  }
48
- e.groups && p(e.label);
49
- }, className: o["navbar-menu-list-item"], children: e.groups ? /* @__PURE__ */ l("span", { className: o["navbar-menu-list-item-trigger-container"], children: [
49
+ e.groups && l(e.label);
50
+ }, className: o["navbar-menu-list-item"], children: e.groups ? /* @__PURE__ */ a("span", { className: o["navbar-menu-list-item-trigger-container"], children: [
50
51
  /* @__PURE__ */ r("span", { children: e.label }),
51
- /* @__PURE__ */ r(g, { icon: "ap-icon-expand-more", className: o["navbar-menu-list-item-arrow"] })
52
+ /* @__PURE__ */ r(u, { icon: "ap-icon-expand-more", className: o["navbar-menu-list-item-arrow"] })
52
53
  ] }) : /* @__PURE__ */ r("a", { className: o["navbar-menu-list-item-action"], href: e.href, onClick: e.onClick, children: e.label }) }),
53
- e.groups && /* @__PURE__ */ r(D, { groups: e.groups, onClose: () => p(null) })
54
+ e.groups && /* @__PURE__ */ r(y, { groups: e.groups, onClose: () => l(null) })
54
55
  ] }) }, e.label)) }),
55
- C ? /* @__PURE__ */ l("div", { className: o["navbar-menu-additional"], children: [
56
- a && /* @__PURE__ */ r("div", { className: o["navbar-action-button"], children: /* @__PURE__ */ r(y, { ...z, ...a }) }),
57
- (n == null ? void 0 : n.settings) && n.settings.length > 0 && /* @__PURE__ */ r(b, { triggerContent: /* @__PURE__ */ r(g, { icon: "ap-icon-settings", className: o["navbar-settings-icon"] }), items: n.settings }),
58
- (n == null ? void 0 : n.userProfile) && /* @__PURE__ */ r(b, { triggerContent: /* @__PURE__ */ r(R, { className: o["navbar-profile-icon"] }), items: n.userProfile.items })
56
+ d ? /* @__PURE__ */ a("div", { className: o["navbar-menu-additional"], children: [
57
+ (n == null ? void 0 : n.actionButton) && /* @__PURE__ */ r("div", { className: o["navbar-action-button"], children: /* @__PURE__ */ r(x, { ...O, ...n.actionButton }) }),
58
+ (n == null ? void 0 : n.settings) && n.settings.length > 0 && /* @__PURE__ */ r(p, { triggerContent: /* @__PURE__ */ r(u, { icon: "ap-icon-settings", className: o["navbar-settings-icon"] }), items: n.settings }),
59
+ (n == null ? void 0 : n.userProfile) && /* @__PURE__ */ r(p, { triggerContent: /* @__PURE__ */ r(B, { className: o["navbar-profile-icon"] }), items: n.userProfile.items })
59
60
  ] }) : null
60
61
  ] })
61
62
  ] }) });
62
63
  }
63
64
  export {
64
- Q as default
65
+ J as default
65
66
  };
@@ -7,11 +7,18 @@ export type CorusHeaderNavItem = {
7
7
  description?: string;
8
8
  href?: string;
9
9
  onClick?: () => void;
10
+ disabled?: boolean;
11
+ };
12
+ export type CorusHeaderFooterAction = {
13
+ variant: 'add' | 'upload';
14
+ label: string;
15
+ onClick?: () => void;
16
+ disabled?: boolean;
10
17
  };
11
18
  export type CorusHeaderNavGroup = {
12
- heading: string;
19
+ heading?: string;
13
20
  items: CorusHeaderNavItem[];
14
- footerAction?: React.ReactNode;
21
+ footerAction?: CorusHeaderFooterAction;
15
22
  };
16
23
  export type CorusHeaderMenuItem = {
17
24
  label: string;
@@ -26,22 +33,26 @@ export type CorusHeaderDropdownItem = {
26
33
  href?: string;
27
34
  onClick?: () => void;
28
35
  };
36
+ export type CorusHeaderAdditionalItems = {
37
+ actionButton?: Omit<ButtonProps, 'type'> & {
38
+ type?: ButtonProps['type'];
39
+ };
40
+ settings?: CorusHeaderDropdownItem[];
41
+ userProfile?: {
42
+ initials: string;
43
+ items: CorusHeaderDropdownItem[];
44
+ };
45
+ };
46
+ export type CorusHeaderMenuConfig = {
47
+ items?: CorusHeaderMenuItem[];
48
+ additionalItems?: CorusHeaderAdditionalItems;
49
+ };
29
50
  export type CorusHeaderProps = {
30
51
  projectName: string;
31
52
  projectLogoIcon?: ApLogo;
32
53
  projectLogoOnClick?: () => void;
33
54
  moduleName?: string;
34
- menuItems?: CorusHeaderMenuItem[];
35
- actionButton?: Omit<ButtonProps, 'type'> & {
36
- type?: ButtonProps['type'];
37
- };
38
- additionalItems?: {
39
- settings?: CorusHeaderDropdownItem[];
40
- userProfile?: {
41
- initials: string;
42
- items: CorusHeaderDropdownItem[];
43
- };
44
- };
55
+ menuConfig?: CorusHeaderMenuConfig;
45
56
  className?: string;
46
57
  maxWidth?: string;
47
58
  } & DataAttributes;
@@ -1,24 +1,29 @@
1
- import { jsx as a, jsxs as s } from "react/jsx-runtime";
2
- import { s as e } from "../../CorusHeader.module-xOp6ZX_M.js";
3
- import { P as r, C as d, I as t } from "../../index-D_L0ncPJ.js";
4
- function g({
5
- groups: l,
6
- onClose: m
1
+ import { jsx as n, jsxs as l } from "react/jsx-runtime";
2
+ import { s as i } from "../../CorusHeader.module-xOp6ZX_M.js";
3
+ import o from "../Button/Button.js";
4
+ import { P as m, C as t, I as r } from "../../index-D_L0ncPJ.js";
5
+ const h = {
6
+ add: "ap-icon-add",
7
+ upload: "ap-icon-upload"
8
+ };
9
+ function b({
10
+ groups: d,
11
+ onClose: c
7
12
  }) {
8
- return /* @__PURE__ */ a(r, { children: /* @__PURE__ */ a(d, { align: "end", className: e["mega-menu-content"], children: l.map((n, c) => /* @__PURE__ */ s("div", { className: e["mega-menu-column-wrapper"], children: [
9
- c > 0 && /* @__PURE__ */ a("div", { className: e["mega-menu-divider"] }),
10
- /* @__PURE__ */ s("div", { className: e["mega-menu-column"], children: [
11
- /* @__PURE__ */ s("div", { className: e["mega-menu-items"], children: [
12
- /* @__PURE__ */ a("div", { className: e["mega-menu-heading"], children: n.heading }),
13
- n.items.map((i) => /* @__PURE__ */ a(t, { className: e["mega-menu-item"], asChild: !0, onSelect: m, children: /* @__PURE__ */ s("a", { href: i.href, onClick: i.onClick, children: [
14
- /* @__PURE__ */ a("span", { className: e["mega-menu-item-label"], children: i.label }),
15
- i.description && /* @__PURE__ */ a("span", { className: e["mega-menu-item-description"], children: i.description.length > 60 ? `${i.description.slice(0, 60)}…` : i.description })
16
- ] }) }, i.label))
13
+ return /* @__PURE__ */ n(m, { children: /* @__PURE__ */ n(t, { align: "end", className: i["mega-menu-content"], children: d.map((a, s) => /* @__PURE__ */ l("div", { className: i["mega-menu-column-wrapper"], children: [
14
+ s > 0 && /* @__PURE__ */ n("div", { className: i["mega-menu-divider"] }),
15
+ /* @__PURE__ */ l("div", { className: i["mega-menu-column"], children: [
16
+ /* @__PURE__ */ l("div", { className: i["mega-menu-items"], children: [
17
+ a.heading && /* @__PURE__ */ n("div", { className: i["mega-menu-heading"], children: a.heading }),
18
+ a.items.map((e) => /* @__PURE__ */ n(r, { className: i["mega-menu-item"], asChild: !0, disabled: e.disabled, onSelect: c, children: /* @__PURE__ */ l("a", { href: e.disabled ? void 0 : e.href, onClick: e.disabled ? void 0 : e.onClick, children: [
19
+ /* @__PURE__ */ n("span", { className: i["mega-menu-item-label"], children: e.label }),
20
+ e.description && /* @__PURE__ */ n("span", { className: i["mega-menu-item-description"], children: e.description.length > 60 ? `${e.description.slice(0, 60)}…` : e.description })
21
+ ] }) }, e.label))
17
22
  ] }),
18
- n.footerAction && /* @__PURE__ */ a("div", { className: e["mega-menu-footer"], children: n.footerAction })
23
+ a.footerAction && /* @__PURE__ */ n("div", { className: i["mega-menu-footer"], children: /* @__PURE__ */ n(o, { type: "secondary", size: "sm", icon: h[a.footerAction.variant], iconPosition: "left", onClick: a.footerAction.onClick, disabled: a.footerAction.disabled, children: a.footerAction.label }) })
19
24
  ] })
20
- ] }, n.heading)) }) });
25
+ ] }, a.heading ?? s)) }) });
21
26
  }
22
27
  export {
23
- g as default
28
+ b as default
24
29
  };
@@ -5,7 +5,7 @@ import "../Dialog/Dialog.js";
5
5
  import "../Icon/Icon.js";
6
6
  import "../Input/Input.js";
7
7
  import "../Tooltip/Tooltip.js";
8
- import { R as l } from "../../RichTextEditor-cvtLFe4t.js";
8
+ import { R as l } from "../../RichTextEditor-kTQEDSL0.js";
9
9
  import "../../index-CCFDXH-J.js";
10
10
  export {
11
11
  l as default
@@ -1,6 +1,6 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
2
  import { d, i as a, r, g as t, s as e, f as c, w as b, v as u } from "../../vi.bdSIJ99Y-017e_Pkz.js";
3
- import { s as i, R as n } from "../../RichTextEditor-cvtLFe4t.js";
3
+ import { s as i, R as n } from "../../RichTextEditor-kTQEDSL0.js";
4
4
  d("RichTextEditor", () => {
5
5
  d("Rendering", () => {
6
6
  a("renders label and required marker", () => {
package/dist/main.js CHANGED
@@ -12,7 +12,7 @@ import { default as B } from "./components/Dropdown/Dropdown.js";
12
12
  import { default as R, useFilePickerContext as v } from "./components/FilePicker/FilePicker.js";
13
13
  import { default as I } from "./components/Search/Search.js";
14
14
  import { default as S } from "./components/Datepicker/Datepicker.js";
15
- import { R as N } from "./RichTextEditor-cvtLFe4t.js";
15
+ import { R as N } from "./RichTextEditor-kTQEDSL0.js";
16
16
  import { default as w } from "./components/Toast/Toast.js";
17
17
  import { T as E } from "./ToastProvider-D5LImZ-Q.js";
18
18
  import { u as L } from "./useToast-Cz5MGKnw.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alixpartners/ui-components",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,443 +0,0 @@
1
- import { jsxs as c, jsx as o } from "react/jsx-runtime";
2
- import { c as b } from "./clsx-OuTLNxxd.js";
3
- import { useMemo as Ee, useId as ze, useRef as M, useState as u, useEffect as H } from "react";
4
- import qe from "./components/Dialog/Dialog.js";
5
- import U from "./components/Icon/Icon.js";
6
- import ve from "./components/Input/Input.js";
7
- import G from "./components/Tooltip/Tooltip.js";
8
- import { R as $e, T as We, P as Ke, C as Ve } from "./index-CCFDXH-J.js";
9
- import './assets/RichTextEditor.css';const Je = "RichTextEditor-module__container___AplP0", Ze = "RichTextEditor-module__label___vjzs-", Ge = "RichTextEditor-module__required___7duke", Ye = "RichTextEditor-module__frame___7OSyf", Xe = "RichTextEditor-module__frameFocused___GtJ2x", Qe = "RichTextEditor-module__frameDisabled___LubtU", et = "RichTextEditor-module__frameError___sPTiY", tt = "RichTextEditor-module__errorMessage___4VdKj", nt = "RichTextEditor-module__helpers___cpuz6", ot = "RichTextEditor-module__helperText___rFoU0", rt = "RichTextEditor-module__helpLink___7gYcv", it = "RichTextEditor-module__containerDisabled___6h9dd", at = "RichTextEditor-module__containerFullWidth___pOoeL", lt = "RichTextEditor-module__toolbarContent___YXKHD", ct = "RichTextEditor-module__toolbarPanel___OVGHO", st = "RichTextEditor-module__toolbarRow___f0xJR", dt = "RichTextEditor-module__editorBody___f8jPI", ut = "RichTextEditor-module__toolbar___m9-M-", mt = "RichTextEditor-module__toolbarStacked___6rB10", ht = "RichTextEditor-module__actions___ZAK9J", ft = "RichTextEditor-module__toolButton___IT2Kg", _t = "RichTextEditor-module__toolButtonActive___-HvZQ", pt = "RichTextEditor-module__toolIcon___Wndhd", gt = "RichTextEditor-module__formatControl___w4WcA", Tt = "RichTextEditor-module__toolbarLinkSlot___Gu-9l", bt = "RichTextEditor-module__selectTrigger___frv3x", xt = "RichTextEditor-module__selectIconBox___SYdTE", Rt = "RichTextEditor-module__selectTriggerOpen___tk2Pb", Et = "RichTextEditor-module__selectTriggerLabel___FkEv0", vt = "RichTextEditor-module__selectIcon___aJWUk", kt = "RichTextEditor-module__formatMenu___y-uBL", Mt = "RichTextEditor-module__formatMenuOptions___zcdlo", yt = "RichTextEditor-module__formatMenuOption___3ppTs", Ct = "RichTextEditor-module__formatMenuOptionSelected___bq9J9", Lt = "RichTextEditor-module__formatMenuOptionParagraph___4BLds", Ot = "RichTextEditor-module__formatMenuOptionHeading1___H1cKX", Nt = "RichTextEditor-module__formatMenuOptionHeading2___JdixR", Ht = "RichTextEditor-module__formatMenuOptionHeading3___NcwLr", wt = "RichTextEditor-module__formatMenuOptionHeading4___4mLbG", Bt = "RichTextEditor-module__formatMenuOptionPreformatted___cB0Ix", St = "RichTextEditor-module__editor___M32R7", Dt = "RichTextEditor-module__characterCount___gmUzj", It = "RichTextEditor-module__characterCountExceeded___vjIpc", Ft = "RichTextEditor-module__linkDialogForm___vOLO1", t = {
10
- container: Je,
11
- label: Ze,
12
- required: Ge,
13
- frame: Ye,
14
- frameFocused: Xe,
15
- frameDisabled: Qe,
16
- frameError: et,
17
- errorMessage: tt,
18
- helpers: nt,
19
- helperText: ot,
20
- helpLink: rt,
21
- containerDisabled: it,
22
- containerFullWidth: at,
23
- toolbarContent: lt,
24
- toolbarPanel: ct,
25
- toolbarRow: st,
26
- editorBody: dt,
27
- toolbar: ut,
28
- toolbarStacked: mt,
29
- actions: ht,
30
- toolButton: ft,
31
- toolButtonActive: _t,
32
- toolIcon: pt,
33
- formatControl: gt,
34
- toolbarLinkSlot: Tt,
35
- selectTrigger: bt,
36
- selectIconBox: xt,
37
- selectTriggerOpen: Rt,
38
- selectTriggerLabel: Et,
39
- selectIcon: vt,
40
- formatMenu: kt,
41
- formatMenuOptions: Mt,
42
- formatMenuOption: yt,
43
- formatMenuOptionSelected: Ct,
44
- formatMenuOptionParagraph: Lt,
45
- formatMenuOptionHeading1: Ot,
46
- formatMenuOptionHeading2: Nt,
47
- formatMenuOptionHeading3: Ht,
48
- formatMenuOptionHeading4: wt,
49
- formatMenuOptionPreformatted: Bt,
50
- editor: St,
51
- characterCount: Dt,
52
- characterCountExceeded: It,
53
- linkDialogForm: Ft
54
- }, At = {
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 Me(r) {
65
- return r.trim().length > 0 ? r : "<br>";
66
- }
67
- function Pt(r) {
68
- switch (r.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(r) {
89
- if (!r.trim())
90
- return {
91
- blocks: [{
92
- type: "paragraph",
93
- html: "<br>"
94
- }]
95
- };
96
- const f = new DOMParser().parseFromString(r, "text/html"), p = Array.from(f.body.childNodes), x = [];
97
- return p.forEach((a) => {
98
- var E;
99
- if (a.nodeType === Node.TEXT_NODE) {
100
- const y = (E = a.textContent) == null ? void 0 : E.trim();
101
- y && x.push({
102
- type: "paragraph",
103
- html: y
104
- });
105
- return;
106
- }
107
- if (a.nodeType !== Node.ELEMENT_NODE)
108
- return;
109
- const m = a, R = m.style.textAlign;
110
- x.push({
111
- type: Pt(m.tagName),
112
- html: Me(m.innerHTML),
113
- align: R || void 0
114
- });
115
- }), {
116
- blocks: x.length > 0 ? x : [{
117
- type: "paragraph",
118
- html: "<br>"
119
- }]
120
- };
121
- }
122
- function ke(r) {
123
- return r.blocks.length ? r.blocks.map((s) => {
124
- const f = At[s.type], p = s.align ? ` style="text-align:${s.align}"` : "";
125
- return `<${f}${p}>${Me(s.html)}</${f}>`;
126
- }).join("") : "<p><br></p>";
127
- }
128
- function Ut(r) {
129
- return r.blocks.map((f) => f.html.replace(/<[^>]+>/g, "")).join("").length;
130
- }
131
- const jt = ["bold", "italic", "underline", "align-left", "align-center", "align-right", "bulleted", "link", "format"], zt = [{
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
- }], qt = {
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 $t(r) {
163
- return r.trim().length > 0 ? r : X();
164
- }
165
- function Wt() {
166
- const r = document.queryCommandValue("formatBlock");
167
- switch (String(r || "").replace(/[<>]/g, "").toUpperCase()) {
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
- default:
179
- return "paragraph";
180
- }
181
- }
182
- function Kt(r) {
183
- switch (r) {
184
- case "heading1":
185
- return t.formatMenuOptionHeading1;
186
- case "heading2":
187
- return t.formatMenuOptionHeading2;
188
- case "heading3":
189
- return t.formatMenuOptionHeading3;
190
- case "heading4":
191
- return t.formatMenuOptionHeading4;
192
- case "preformatted":
193
- return t.formatMenuOptionPreformatted;
194
- default:
195
- return t.formatMenuOptionParagraph;
196
- }
197
- }
198
- function tn({
199
- className: r,
200
- label: s,
201
- required: f = !1,
202
- value: p,
203
- placeholder: x = "Content",
204
- disabled: a = !1,
205
- errorMessage: m,
206
- helpText: R,
207
- helpLink: E,
208
- helpLinkText: y,
209
- toolbarLayout: j = "inline",
210
- showToolbar: z = !0,
211
- showCharacterCount: ye = !0,
212
- maxCharacters: g,
213
- resizable: Ce = !0,
214
- rows: Le = 8,
215
- fullWidth: q = !1,
216
- tooltipEnabled: w = !0,
217
- formatOptions: Q = zt,
218
- toolbarOptions: ee = jt,
219
- onChange: $,
220
- onModelChange: W
221
- }) {
222
- const Oe = Ee(() => new Set(ee), [ee]), C = (e) => Oe.has(e), te = ze(), d = M(null), ne = M(null), oe = M(null), L = M(null), B = M(!1), [Ne, re] = u(!1), [S, ie] = u(!1), [He, we] = u(0), [ae, le] = u(null), [Be, ce] = u(!1), [se, de] = u(""), [ue, me] = u(""), [he, O] = u(""), [D, fe] = u(() => Y(p || X())), [_e, Se] = u("paragraph"), [T, De] = u({
223
- bold: !1,
224
- italic: !1,
225
- underline: !1,
226
- justifyLeft: !1,
227
- justifyCenter: !1,
228
- justifyRight: !1,
229
- insertUnorderedList: !1
230
- }), N = Ee(() => Ut(D), [D]), pe = M(N);
231
- pe.current = N;
232
- const K = () => {
233
- if (!d.current) return;
234
- const e = Y(d.current.innerHTML);
235
- fe(e), W == null || W(e), $ == null || $(ke(e));
236
- }, I = () => {
237
- Se(Wt()), De({
238
- bold: document.queryCommandState("bold"),
239
- italic: document.queryCommandState("italic"),
240
- underline: document.queryCommandState("underline"),
241
- justifyLeft: document.queryCommandState("justifyLeft"),
242
- justifyCenter: document.queryCommandState("justifyCenter"),
243
- justifyRight: document.queryCommandState("justifyRight"),
244
- insertUnorderedList: document.queryCommandState("insertUnorderedList")
245
- });
246
- }, V = () => {
247
- var e;
248
- a || (e = d.current) == null || e.focus();
249
- }, ge = (e, n) => {
250
- a || (V(), document.execCommand(e, !1, n), K(), I());
251
- }, Ie = (e) => {
252
- ge("formatBlock", qt[e]);
253
- }, Te = () => {
254
- var l, k;
255
- if (a) return;
256
- V();
257
- const e = window.getSelection();
258
- let n = "", i = "";
259
- if (e && e.rangeCount > 0) {
260
- const h = e.getRangeAt(0);
261
- L.current = h.cloneRange(), n = e.toString();
262
- const _ = ((l = h.startContainer.parentElement) == null ? void 0 : l.closest("a")) ?? ((k = h.endContainer.parentElement) == null ? void 0 : k.closest("a"));
263
- _ instanceof HTMLAnchorElement && (n = _.textContent ?? n, i = _.getAttribute("href") ?? "");
264
- } else
265
- L.current = null;
266
- de(n), me(i), O(""), ce(!0);
267
- }, J = () => {
268
- if (B.current) {
269
- B.current = !1;
270
- return;
271
- }
272
- ce(!1), O(""), L.current = null;
273
- }, Fe = (e) => {
274
- me(e), he && O("");
275
- }, Ae = (e) => {
276
- const n = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
277
- try {
278
- const i = /^https?:\/\//i.test(e), l = new URL(i ? e : `https://${e}`);
279
- return l.protocol !== "http:" && l.protocol !== "https:" ? !1 : n.test(l.hostname);
280
- } catch {
281
- return !1;
282
- }
283
- }, Pe = (e) => /^https?:\/\//i.test(e) ? e : `https://${/^www\./i.test(e) ? e : `www.${e}`}`, Ue = () => {
284
- const e = ue.trim();
285
- if (!e) {
286
- O("This field is required"), B.current = !0;
287
- return;
288
- }
289
- if (!Ae(e)) {
290
- O("Invalid link"), B.current = !0;
291
- return;
292
- }
293
- const n = Pe(e), i = se.trim() || e, l = (_) => _.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), k = `<a href="${l(n)}" target="_blank" rel="noopener noreferrer">${l(i)}</a>`;
294
- V();
295
- const h = window.getSelection();
296
- h && L.current && (h.removeAllRanges(), h.addRange(L.current)), document.execCommand("insertHTML", !1, k), K(), I(), J();
297
- }, je = (e) => {
298
- if (!e.ctrlKey && !e.metaKey) return;
299
- const n = e.target, i = n == null ? void 0 : n.closest("a");
300
- i instanceof HTMLAnchorElement && i.href && (e.preventDefault(), window.open(i.href, "_blank", "noopener,noreferrer"));
301
- };
302
- H(() => {
303
- const e = $t(p || X()), n = Y(e);
304
- fe(n), d.current && d.current.innerHTML !== e && (d.current.innerHTML = e);
305
- }, [p]), H(() => {
306
- d.current && (d.current.innerHTML.trim() || (d.current.innerHTML = ke(D)));
307
- }, [D]), H(() => {
308
- const e = d.current;
309
- if (!e || !g) return;
310
- const n = (i) => {
311
- var _;
312
- if (!i.inputType.startsWith("insert")) return;
313
- const l = window.getSelection(), k = l && !l.isCollapsed ? l.toString().length : 0, h = i.data ? i.data.length : ((_ = i.dataTransfer) == null ? void 0 : _.getData("text").length) ?? 0;
314
- pe.current - k + h > g && i.preventDefault();
315
- };
316
- return e.addEventListener("beforeinput", n), () => e.removeEventListener("beforeinput", n);
317
- }, [g]), H(() => {
318
- var n;
319
- const e = (n = ne.current) == null ? void 0 : n.getBoundingClientRect().width;
320
- e && we(e);
321
- }, [S]), H(() => {
322
- if (!z || q) {
323
- le(null);
324
- return;
325
- }
326
- const e = oe.current;
327
- if (!e) return;
328
- const n = () => {
329
- const l = e.getBoundingClientRect().width;
330
- l > 0 && le(l);
331
- };
332
- n();
333
- const i = new ResizeObserver(() => {
334
- n();
335
- });
336
- return i.observe(e), window.addEventListener("resize", n), () => {
337
- i.disconnect(), window.removeEventListener("resize", n);
338
- };
339
- }, [z, j, a, w, q]);
340
- const v = (e) => /* @__PURE__ */ o(G, { content: e.tooltip, size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: b(t.toolButton, e.active && t.toolButtonActive), onMouseDown: (n) => n.preventDefault(), onClick: () => ge(e.command, e.value), "aria-label": e.tooltip, disabled: a, children: /* @__PURE__ */ o(U, { icon: e.icon, className: t.toolIcon }) }) }, e.id), Z = [{
341
- id: "bold",
342
- icon: "ap-icon-bold",
343
- command: "bold",
344
- tooltip: "Bold (CTRL + B)",
345
- active: T.bold
346
- }, {
347
- id: "italic",
348
- icon: "ap-icon-italic",
349
- command: "italic",
350
- tooltip: "Italic (CTRL + I)",
351
- active: T.italic
352
- }, {
353
- id: "underline",
354
- icon: "ap-icon-underline",
355
- command: "underline",
356
- tooltip: "Underline (CTRL + U)",
357
- active: T.underline
358
- }, {
359
- id: "align-left",
360
- icon: "ap-icon-align-left",
361
- command: "justifyLeft",
362
- tooltip: "Align left",
363
- active: T.justifyLeft
364
- }, {
365
- id: "align-center",
366
- icon: "ap-icon-align-center",
367
- command: "justifyCenter",
368
- tooltip: "Align center",
369
- active: T.justifyCenter
370
- }, {
371
- id: "align-right",
372
- icon: "ap-icon-align-right",
373
- command: "justifyRight",
374
- tooltip: "Align right",
375
- active: T.justifyRight
376
- }, {
377
- id: "bulleted",
378
- icon: "ap-icon-list",
379
- command: "insertUnorderedList",
380
- tooltip: "Bulleted list",
381
- active: T.insertUnorderedList
382
- }], F = Z.filter((e) => ["bold", "italic", "underline"].includes(e.id) && C(e.id)), A = Z.filter((e) => ["align-left", "align-center", "align-right"].includes(e.id) && C(e.id)), P = Z.filter((e) => ["bulleted"].includes(e.id) && C(e.id)), be = C("link"), xe = C("format"), Re = () => {
383
- var e;
384
- return /* @__PURE__ */ o("div", { className: t.formatControl, children: /* @__PURE__ */ c($e, { open: S, onOpenChange: ie, children: [
385
- /* @__PURE__ */ c(We, { ref: ne, disabled: a, className: b(t.selectTrigger, S && t.selectTriggerOpen), children: [
386
- /* @__PURE__ */ o("span", { className: t.selectTriggerLabel, children: ((e = Q.find((n) => n.value === _e)) == null ? void 0 : e.label) || "Paragraph" }),
387
- /* @__PURE__ */ o("span", { className: t.selectIconBox, children: /* @__PURE__ */ o(U, { icon: S ? "ap-icon-expand-less" : "ap-icon-expand-more", className: t.selectIcon }) })
388
- ] }),
389
- /* @__PURE__ */ o(Ke, { children: /* @__PURE__ */ o(Ve, { align: "end", side: "bottom", sideOffset: 6, collisionPadding: 8, className: t.formatMenu, style: {
390
- minWidth: He || 180,
391
- zIndex: 9999
392
- }, children: /* @__PURE__ */ o("div", { className: t.formatMenuOptions, children: Q.map((n) => /* @__PURE__ */ o("button", { type: "button", className: b(t.formatMenuOption, Kt(n.value), n.value === _e && t.formatMenuOptionSelected), onMouseDown: (i) => i.preventDefault(), onClick: () => {
393
- Ie(n.value), ie(!1);
394
- }, children: n.label }, n.value)) }) }) })
395
- ] }) });
396
- };
397
- return /* @__PURE__ */ c("div", { className: b(t.container, a && t.containerDisabled, q && t.containerFullWidth, r), children: [
398
- s && /* @__PURE__ */ c("label", { className: t.label, htmlFor: te, children: [
399
- s,
400
- f && /* @__PURE__ */ o("span", { className: t.required, children: "*" })
401
- ] }),
402
- /* @__PURE__ */ c("div", { className: b(t.frame, Ne && t.frameFocused, a && t.frameDisabled, m && t.frameError), style: {
403
- width: ae ? `${ae}px` : void 0
404
- }, children: [
405
- z && /* @__PURE__ */ o("div", { className: b(t.toolbar, j === "stacked" && t.toolbarStacked), children: /* @__PURE__ */ o("div", { ref: oe, className: t.toolbarContent, children: j === "stacked" ? /* @__PURE__ */ c("div", { className: t.toolbarPanel, children: [
406
- /* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
407
- F.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: F.map(v) }),
408
- A.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: A.map(v) })
409
- ] }),
410
- /* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
411
- P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(v) }),
412
- be && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: Te, "aria-label": "Insert link", disabled: a, children: /* @__PURE__ */ o(U, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
413
- xe && Re()
414
- ] })
415
- ] }) : /* @__PURE__ */ o("div", { className: t.toolbarPanel, children: /* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
416
- F.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: F.map(v) }),
417
- A.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: A.map(v) }),
418
- P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(v) }),
419
- be && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: Te, "aria-label": "Insert link", disabled: a, children: /* @__PURE__ */ o(U, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
420
- xe && Re()
421
- ] }) }) }) }),
422
- /* @__PURE__ */ c("div", { className: t.editorBody, style: {
423
- minHeight: `${Le * 20}px`,
424
- resize: Ce && !a ? "vertical" : "none"
425
- }, children: [
426
- /* @__PURE__ */ o("div", { id: te, ref: d, className: t.editor, contentEditable: !a, suppressContentEditableWarning: !0, role: "textbox", "aria-multiline": "true", "aria-label": s || "Rich text editor", "data-placeholder": x, onInput: K, onFocus: () => re(!0), onBlur: () => re(!1), onKeyUp: I, onMouseUp: I, onClick: je }),
427
- ye && /* @__PURE__ */ o("div", { className: b(t.characterCount, g && N > g && t.characterCountExceeded), children: g ? `${N}/${g}` : N })
428
- ] })
429
- ] }),
430
- (m || R || E) && /* @__PURE__ */ c("div", { className: t.helpers, children: [
431
- m ? /* @__PURE__ */ o("span", { title: m, className: t.errorMessage, children: m }) : R && /* @__PURE__ */ o("span", { title: R, className: t.helperText, children: R }),
432
- E && y && /* @__PURE__ */ o("a", { href: E, className: t.helpLink, target: "_blank", rel: "noopener noreferrer", children: y })
433
- ] }),
434
- /* @__PURE__ */ o(qe, { isOpen: Be, onClose: J, title: "Attach link", cancelButtonText: "Cancel", cancelButtonType: "primary", cancelButtonVariant: "cancel", confirmButtonText: "Attach", confirmButtonType: "primary", onCancel: J, onConfirm: Ue, description: /* @__PURE__ */ c("div", { className: t.linkDialogForm, children: [
435
- /* @__PURE__ */ o(ve, { type: "text", label: "Displayed text", value: se, onChange: de, autofocus: !0 }),
436
- /* @__PURE__ */ o(ve, { type: "text", label: "Link", value: ue, placeholder: "https://example.com/", required: !0, errorMessage: he || void 0, onChange: Fe })
437
- ] }) })
438
- ] });
439
- }
440
- export {
441
- tn as R,
442
- t as s
443
- };