@ryuzaki13/react-foundation-ui 1.0.12 → 1.0.14

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.
@@ -1,1178 +0,0 @@
1
- import { n as e } from "./button-CC0Jdx1j.js";
2
- import { r as t } from "./grid-ByIIytjh.js";
3
- import { n } from "./input-CZLUUggm.js";
4
- import { i as r, n as i, r as a } from "./modal-C0j0hEIt.js";
5
- import { t as o } from "./check-box-BowNqqd3.js";
6
- import { n as s } from "./radio-group-B9XjkcOy.js";
7
- import { t as c } from "./editorModel-DCJRgzlr.js";
8
- import { i as l, r as u, t as d } from "./toolbar-XCDeS2Li.js";
9
- import { a as f, i as p, n as m, r as h, t as g } from "./plugins-BqaLckPx.js";
10
- import { useCallback as _, useEffect as v, useEffectEvent as y, useMemo as b, useState as x } from "react";
11
- import { cn as S } from "@ryuzaki13/react-foundation-lib/utils";
12
- import { isSafe as C, validateUrl as w } from "@ryuzaki13/react-foundation-lib/validators";
13
- import { formatPhone as T } from "@ryuzaki13/react-foundation-lib/formatters";
14
- import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
15
- import { $generateHtmlFromNodes as k } from "@lexical/html";
16
- import { $applyNodeReplacement as A, $createParagraphNode as j, $createTextNode as M, $getSelection as N, $isRangeSelection as P, ElementNode as F, FORMAT_ELEMENT_COMMAND as ee, FORMAT_TEXT_COMMAND as te, REDO_COMMAND as ne, UNDO_COMMAND as re } from "lexical";
17
- import { INSERT_ORDERED_LIST_COMMAND as ie, INSERT_UNORDERED_LIST_COMMAND as ae, ListItemNode as oe, ListNode as se, REMOVE_LIST_COMMAND as I } from "@lexical/list";
18
- import { $createHeadingNode as ce, $createQuoteNode as le, HeadingNode as ue, QuoteNode as de } from "@lexical/rich-text";
19
- import { LexicalComposer as L } from "@lexical/react/LexicalComposer";
20
- import { ContentEditable as R } from "@lexical/react/LexicalContentEditable";
21
- import { LexicalErrorBoundary as z } from "@lexical/react/LexicalErrorBoundary";
22
- import { HistoryPlugin as B } from "@lexical/react/LexicalHistoryPlugin";
23
- import { ListPlugin as V } from "@lexical/react/LexicalListPlugin";
24
- import { OnChangePlugin as H } from "@lexical/react/LexicalOnChangePlugin";
25
- import { RichTextPlugin as fe } from "@lexical/react/LexicalRichTextPlugin";
26
- import { $isLinkNode as U, LinkNode as pe } from "@lexical/link";
27
- import { $setBlocksType as W } from "@lexical/selection";
28
- import { $findMatchingParent as me } from "@lexical/utils";
29
- //#region src/text-editor/lib/serialization/createLexicalRaw.ts
30
- var he = (e) => ({
31
- format: "lexical",
32
- version: 1,
33
- editorState: e.toJSON()
34
- }), G = (e) => {
35
- let t = 0, n = e;
36
- for (; n;) t += 1, n = n.getParent();
37
- return t;
38
- }, ge = (e) => {
39
- if (!(e instanceof HTMLAnchorElement)) return { node: null };
40
- let t = e.textContent;
41
- return (t === null || t === "") && e.children.length === 0 ? { node: null } : { node: q(e.getAttribute("href") || "", {
42
- rel: e.getAttribute("rel"),
43
- target: e.getAttribute("target"),
44
- title: e.getAttribute("title"),
45
- ariaLabel: e.getAttribute("aria-label"),
46
- qrCode: e.getAttribute("data-qr-code") === "true",
47
- add: null,
48
- text: t
49
- }) };
50
- }, K = class e extends pe {
51
- __ariaLabel;
52
- __qrCode;
53
- __add;
54
- __text;
55
- static getType() {
56
- return "accessible-link";
57
- }
58
- static clone(t) {
59
- return new e(t.__url, {
60
- rel: t.__rel,
61
- target: t.__target,
62
- title: t.__title,
63
- ariaLabel: t.__ariaLabel,
64
- qrCode: t.__qrCode,
65
- add: t.__add,
66
- text: t.__text
67
- }, t.__key);
68
- }
69
- constructor(e = "", t = {}, n) {
70
- super(e, t, n);
71
- let { ariaLabel: r = null, qrCode: i = !1, add: a = null, text: o = null } = t;
72
- this.__ariaLabel = r, this.__qrCode = i, this.__add = a, this.__text = o;
73
- }
74
- static importDOM() {
75
- return { a: () => ({
76
- conversion: ge,
77
- priority: 2
78
- }) };
79
- }
80
- static importJSON(e) {
81
- return q().updateFromJSON(e);
82
- }
83
- updateFromJSON(e) {
84
- return super.updateFromJSON(e).setAriaLabel(e.ariaLabel || null).setQrCode(!!e.qrCode).setAdd(e.add || null).setText(e.text || null);
85
- }
86
- exportJSON() {
87
- return {
88
- ...super.exportJSON(),
89
- type: "accessible-link",
90
- version: 1,
91
- ariaLabel: this.getAriaLabel(),
92
- qrCode: this.getQrCode(),
93
- add: this.getAdd(),
94
- text: this.getText()
95
- };
96
- }
97
- createDOM(e) {
98
- let t = super.createDOM(e);
99
- return this.applyAccessibleAttributes(null, t), t;
100
- }
101
- updateDOM(e, t, n) {
102
- let r = super.updateDOM(e, t, n);
103
- return this.applyAccessibleAttributes(e, t), r;
104
- }
105
- applyAccessibleAttributes(e, t) {
106
- t instanceof HTMLAnchorElement && ((!e || e.__ariaLabel !== this.__ariaLabel) && (this.__ariaLabel ? t.setAttribute("aria-label", this.__ariaLabel) : t.removeAttribute("aria-label")), (!e || e.__qrCode !== this.__qrCode) && t.setAttribute("data-qr-code", this.__qrCode ? "true" : "false"));
107
- }
108
- insertNewAfter(e, t = !0) {
109
- let n = q(this.__url, {
110
- rel: this.__rel,
111
- target: this.__target,
112
- title: this.__title,
113
- ariaLabel: this.__ariaLabel,
114
- qrCode: this.__qrCode,
115
- add: this.__add,
116
- text: this.__text
117
- });
118
- return this.insertAfter(n, t), n;
119
- }
120
- getAriaLabel() {
121
- return this.getLatest().__ariaLabel;
122
- }
123
- setAriaLabel(e) {
124
- let t = this.getWritable();
125
- return t.__ariaLabel = e, this;
126
- }
127
- getQrCode() {
128
- return this.getLatest().__qrCode;
129
- }
130
- setQrCode(e) {
131
- let t = this.getWritable();
132
- return t.__qrCode = e, this;
133
- }
134
- getAdd() {
135
- return this.getLatest().__add;
136
- }
137
- setAdd(e) {
138
- let t = this.getWritable();
139
- return t.__add = e, this;
140
- }
141
- getText() {
142
- return this.getLatest().__text;
143
- }
144
- setText(e) {
145
- let t = this.getWritable();
146
- return t.__text = e, this;
147
- }
148
- }, q = (e = "", t) => A(new K(e, t)), J = (e) => e instanceof K, _e = (e) => {
149
- let t = {};
150
- return Array.from(e.attributes).forEach((e) => {
151
- e.name !== "class" && (t[e.name] = e.value);
152
- }), t;
153
- }, Y = (e) => {
154
- if (!(e instanceof HTMLElement)) return { node: null };
155
- let t = e.tagName.toLowerCase();
156
- if (![
157
- "abbr",
158
- "span",
159
- "time",
160
- "cite",
161
- "del",
162
- "ins"
163
- ].includes(t)) return { node: null };
164
- let n = e.textContent;
165
- return (n === null || n === "") && e.children.length === 0 ? { node: null } : { node: Z(t, _e(e), n) };
166
- }, X = class e extends F {
167
- __tag;
168
- __attributes;
169
- __text;
170
- static getType() {
171
- return "semantic-tag";
172
- }
173
- static clone(t) {
174
- return new e(t.__tag, t.__attributes, t.__text, t.__key);
175
- }
176
- constructor(e = "span", t = {}, n = null, r) {
177
- super(r), this.__tag = e, this.__attributes = t, this.__text = n;
178
- }
179
- static importDOM() {
180
- return {
181
- abbr: () => ({
182
- conversion: Y,
183
- priority: 2
184
- }),
185
- span: () => ({
186
- conversion: Y,
187
- priority: 2
188
- }),
189
- time: () => ({
190
- conversion: Y,
191
- priority: 2
192
- }),
193
- cite: () => ({
194
- conversion: Y,
195
- priority: 2
196
- }),
197
- del: () => ({
198
- conversion: Y,
199
- priority: 2
200
- }),
201
- ins: () => ({
202
- conversion: Y,
203
- priority: 2
204
- })
205
- };
206
- }
207
- static importJSON(e) {
208
- return Z(e.tag, e.attributes, e.text).updateFromJSON(e);
209
- }
210
- updateFromJSON(e) {
211
- return super.updateFromJSON(e).setTag(e.tag).setAttributes(e.attributes || {}).setText(e.text || null);
212
- }
213
- exportJSON() {
214
- return {
215
- ...super.exportJSON(),
216
- type: "semantic-tag",
217
- version: 1,
218
- tag: this.getTag(),
219
- attributes: this.getAttributes(),
220
- text: this.getText()
221
- };
222
- }
223
- createDOM(e) {
224
- let t = document.createElement(this.__tag);
225
- return this.applyEditorAttributes(t), t;
226
- }
227
- updateDOM(e, t) {
228
- return e.__tag === this.__tag ? (this.applyEditorAttributes(t), !1) : !0;
229
- }
230
- exportDOM() {
231
- let e = document.createElement(this.__tag);
232
- return Object.entries(this.__attributes).forEach(([t, n]) => {
233
- e.setAttribute(t, n);
234
- }), { element: e };
235
- }
236
- applyEditorAttributes(e) {
237
- e.classList.add("custom-tag-highlight"), Array.from(e.attributes).forEach((t) => {
238
- t.name !== "class" && e.removeAttribute(t.name);
239
- }), Object.entries(this.__attributes).forEach(([t, n]) => {
240
- e.setAttribute(t, n);
241
- });
242
- }
243
- insertNewAfter(e, t = !0) {
244
- let n = Z(this.__tag, this.__attributes, this.__text);
245
- return this.insertAfter(n, t), n;
246
- }
247
- canInsertTextBefore() {
248
- return !1;
249
- }
250
- canInsertTextAfter() {
251
- return !1;
252
- }
253
- canBeEmpty() {
254
- return !1;
255
- }
256
- isInline() {
257
- return !0;
258
- }
259
- getTag() {
260
- return this.getLatest().__tag;
261
- }
262
- setTag(e) {
263
- let t = this.getWritable();
264
- return t.__tag = e, this;
265
- }
266
- getAttributes() {
267
- return this.getLatest().__attributes;
268
- }
269
- setAttributes(e) {
270
- let t = this.getWritable();
271
- return t.__attributes = e, this;
272
- }
273
- getText() {
274
- return this.getLatest().__text;
275
- }
276
- setText(e) {
277
- let t = this.getWritable();
278
- return t.__text = e, this;
279
- }
280
- }, Z = (e, t = {}, n = null) => A(new X(e, t, n)), ve = (e) => e instanceof X;
281
- //#endregion
282
- //#region src/text-editor/model/hooks/useTextEditorLexicalActions.ts
283
- function ye({ editor: e, toolbarState: t, hasLocalLinkDialog: n, onOpenLinkDialog: r, onOpenTagDialog: i }) {
284
- let a = _((n) => {
285
- if (e) {
286
- if (n === "unordered-list-item") {
287
- if (t.blockType === "unordered-list-item") {
288
- e.dispatchCommand(I, void 0);
289
- return;
290
- }
291
- e.dispatchCommand(ae, void 0);
292
- return;
293
- }
294
- if (n === "ordered-list-item") {
295
- if (t.blockType === "ordered-list-item") {
296
- e.dispatchCommand(I, void 0);
297
- return;
298
- }
299
- e.dispatchCommand(ie, void 0);
300
- return;
301
- }
302
- e.update(() => {
303
- let e = N();
304
- if (!P(e)) return;
305
- if (n === "unstyled" || n === "paragraph") {
306
- W(e, () => j());
307
- return;
308
- }
309
- if (n === "blockquote") {
310
- W(e, () => le());
311
- return;
312
- }
313
- let t = m(n);
314
- t && W(e, () => ce(t));
315
- });
316
- }
317
- }, [e, t.blockType]), o = _((t) => {
318
- if (!e) return;
319
- let n = h(t);
320
- n && e.dispatchCommand(te, n);
321
- }, [e]), s = _((t) => {
322
- e && e.dispatchCommand(ee, t);
323
- }, [e]), c = _(() => {
324
- e && e.dispatchCommand(re, void 0);
325
- }, [e]), l = _(() => {
326
- e && e.dispatchCommand(ne, void 0);
327
- }, [e]), d = _(() => {
328
- if (!e) return "";
329
- let t = "";
330
- return e.getEditorState().read(() => {
331
- let e = N();
332
- P(e) && (t = e.getTextContent());
333
- }), t;
334
- }, [e]), f = _((t) => {
335
- e && (e.update(() => {
336
- let e = N();
337
- if (!P(e)) return;
338
- let n = e.getTextContent(), r = t.text.length > 0 ? t.text : n;
339
- if (!r.trim()) return;
340
- let i = q(t.url, {
341
- target: "_blank",
342
- rel: "noopener noreferrer",
343
- ariaLabel: t.ariaLabel || n || r,
344
- qrCode: t.qrCode,
345
- add: t.add || null,
346
- text: r
347
- }), a = M(r);
348
- i.append(a), e.insertNodes([i]);
349
- }), requestAnimationFrame(() => {
350
- e.focus();
351
- }));
352
- }, [e]), p = _((e, t, n, r, i) => {
353
- f({
354
- url: e,
355
- text: t,
356
- add: n,
357
- ariaLabel: r,
358
- qrCode: i
359
- });
360
- }, [f]), g = _((e, t) => {
361
- f({
362
- url: e,
363
- text: t,
364
- add: "",
365
- ariaLabel: "Внутренняя ссылка на статью: " + t,
366
- qrCode: !1
367
- });
368
- }, [f]), v = _(() => {
369
- if (!e) return "";
370
- let t = "";
371
- return e.getEditorState().read(() => {
372
- let e = N();
373
- if (!P(e)) {
374
- t = "";
375
- return;
376
- }
377
- let n = e.getTextContent(), r = me(e.anchor.getNode(), (e) => J(e) || U(e));
378
- if (J(r)) {
379
- t = {
380
- url: r.getURL(),
381
- ariaLabel: r.getAriaLabel() || "",
382
- text: r.getText() || n,
383
- add: r.getAdd() || "",
384
- qrCode: r.getQrCode()
385
- };
386
- return;
387
- }
388
- if (U(r)) {
389
- t = {
390
- url: r.getURL(),
391
- ariaLabel: "",
392
- text: n,
393
- add: "",
394
- qrCode: !1
395
- };
396
- return;
397
- }
398
- t = n;
399
- }), t;
400
- }, [e]), y = _((e) => {
401
- e === u.LOCAL_LINK && !n || r(e);
402
- }, [n, r]), b = _((t, n, r) => {
403
- e && (e.update(() => {
404
- let e = N();
405
- if (!P(e)) return;
406
- let i = e.getTextContent().trim(), a = n || i || r.title || r["aria-label"] || Object.values(r).join(" ") || t;
407
- if (!a.trim()) return;
408
- let o = Z(t, r, a);
409
- o.append(M(a)), e.insertNodes([o]);
410
- }), requestAnimationFrame(() => {
411
- e.focus();
412
- }));
413
- }, [e]);
414
- return {
415
- handleAddLink: p,
416
- handleAddLocalLink: g,
417
- handleAlignmentChange: s,
418
- handleBlockStyleToggle: a,
419
- handleCleanSemanticTag: _(() => {
420
- e && e.update(() => {
421
- let e = N();
422
- if (!P(e) || e.isCollapsed()) return;
423
- let t = e.getNodes(), n = /* @__PURE__ */ new Set();
424
- t.forEach((e) => {
425
- let t = e;
426
- for (; t;) ve(t) && n.add(t), t = t.getParent();
427
- }), Array.from(n).sort((e, t) => G(t) - G(e)).forEach((e) => {
428
- e.isAttached() && (e.getChildren().forEach((t) => e.insertBefore(t)), e.remove());
429
- });
430
- });
431
- }, [e]),
432
- handleInlineStyleToggle: o,
433
- handleLinkClick: y,
434
- handleRedo: l,
435
- handleTagClick: _((e) => {
436
- i(e);
437
- }, [i]),
438
- handleUndo: c,
439
- getCurrentSelectionText: d,
440
- getSelectedLinkState: v,
441
- insertSemanticTagAtSelection: b
442
- };
443
- }
444
- var Q = {
445
- textEditor: "_75LW3N",
446
- textEditorContent: "PLiHsN",
447
- focused: "m-jmCu",
448
- wrapper: "_4NWAs0"
449
- };
450
- //#endregion
451
- //#region src/text-editor/EmailDialog.tsx
452
- function be({ isOpen: t, onClose: o, onConfirm: s, initialState: c }) {
453
- let [l, u] = x(""), [d, f] = x(""), [p, m] = x(null), [h] = x(() => C(c) && typeof c == "string" ? {
454
- text: "",
455
- add: "",
456
- ariaLabel: "",
457
- url: c
458
- } : c);
459
- v(() => {
460
- t && C(h) && (u(h.url ?? ""), f(h.ariaLabel ?? ""));
461
- }, [t, h]);
462
- let g = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) ? !0 : (m("Некорректный email адрес"), !1), _ = (e) => {
463
- if (e.preventDefault(), g(l)) {
464
- if (!d) {
465
- m("Добавьте описание для email");
466
- return;
467
- }
468
- s(`mailto:${l}`, "", "", d, !1), y();
469
- }
470
- }, y = () => {
471
- u(""), f(""), m(null), o();
472
- };
473
- return /* @__PURE__ */ O(i, {
474
- isOpen: t,
475
- onClose: y,
476
- title: "Ссылка на email",
477
- size: "md",
478
- children: [/* @__PURE__ */ D(a, { children: /* @__PURE__ */ O("div", {
479
- className: S("flexColumn", "gapMd"),
480
- children: [
481
- /* @__PURE__ */ D(n, {
482
- label: "Email адрес",
483
- value: l,
484
- onChange: u,
485
- placeholder: "some_email@mail.ru"
486
- }),
487
- p && /* @__PURE__ */ O("div", {
488
- className: "textColorDanger",
489
- children: [
490
- /* @__PURE__ */ D("strong", { children: "Ошибка ввода:" }),
491
- " ",
492
- /* @__PURE__ */ D("span", {
493
- className: "fontItalic",
494
- children: p
495
- })
496
- ]
497
- }),
498
- /* @__PURE__ */ D(n, {
499
- label: "Текст для экранных читалок",
500
- value: d,
501
- onChange: f,
502
- placeholder: "Электронная почта руководителя городской думмы"
503
- })
504
- ]
505
- }) }), /* @__PURE__ */ O(r, { children: [/* @__PURE__ */ D(e, {
506
- appearance: "outline",
507
- tone: "error",
508
- onClick: y,
509
- children: "Отмена"
510
- }), /* @__PURE__ */ D(e, {
511
- appearance: "outline",
512
- tone: "success",
513
- onClick: _,
514
- disabled: !l || !d,
515
- children: "Подтвердить"
516
- })] })]
517
- });
518
- }
519
- //#endregion
520
- //#region src/text-editor/LinkDialog.tsx
521
- function $({ isOpen: s, onClose: c, onConfirm: l, initialState: u }) {
522
- let [d, f] = x(""), [p, m] = x(""), [h, g] = x(null), [_, y] = x(!1), [b] = x(() => C(u) && typeof u == "string" ? {
523
- text: "",
524
- add: "",
525
- ariaLabel: "",
526
- url: u
527
- } : u);
528
- v(() => {
529
- s && C(b) && (f(b.url ?? ""), m(b.ariaLabel ?? ""));
530
- }, [s, b]);
531
- let S = (e) => {
532
- f(e), h && g(null);
533
- }, T = (e) => {
534
- e.preventDefault();
535
- let t = w(d);
536
- if (!t.isValid) {
537
- g(t.error);
538
- return;
539
- }
540
- if (!p) {
541
- g("добавьте описание для ссылки");
542
- return;
543
- }
544
- l(d.startsWith("http") ? d : `https://${d}`, "", "", p, _), E();
545
- }, E = () => {
546
- f(""), m(""), g(null), c();
547
- };
548
- return /* @__PURE__ */ O(i, {
549
- isOpen: s,
550
- onClose: E,
551
- title: "Ссылка на внешний url",
552
- size: "md",
553
- children: [/* @__PURE__ */ D(a, { children: /* @__PURE__ */ O(t, {
554
- gap: "md",
555
- children: [
556
- /* @__PURE__ */ D(n, {
557
- label: "Полный URL адрес",
558
- value: d,
559
- onChange: S,
560
- placeholder: "https://somesite.ru"
561
- }),
562
- h && /* @__PURE__ */ O("div", {
563
- className: "textColorDanger",
564
- children: [
565
- /* @__PURE__ */ D("strong", { children: "Ошибка ввода:" }),
566
- " ",
567
- /* @__PURE__ */ D("span", {
568
- className: "fontItalic",
569
- children: h
570
- })
571
- ]
572
- }),
573
- /* @__PURE__ */ D(n, {
574
- label: "Текст для экранных читалок",
575
- value: p,
576
- onChange: m,
577
- placeholder: "Ссылка на официальный сайт городской думмы"
578
- }),
579
- /* @__PURE__ */ D(o, {
580
- title: "Показать кнопку для генерации QR кода ссылки",
581
- value: _,
582
- onChange: y
583
- })
584
- ]
585
- }) }), /* @__PURE__ */ O(r, { children: [/* @__PURE__ */ D(e, {
586
- appearance: "outline",
587
- tone: "error",
588
- onClick: E,
589
- children: "Отмена"
590
- }), /* @__PURE__ */ D(e, {
591
- appearance: "outline",
592
- tone: "success",
593
- onClick: T,
594
- disabled: !d || !p,
595
- children: "Подтвердить"
596
- })] })]
597
- });
598
- }
599
- //#endregion
600
- //#region src/text-editor/PhoneDialog.tsx
601
- function xe({ isOpen: o, onClose: s, onConfirm: c, initialState: l }) {
602
- let [u, d] = x(""), [f, p] = x(""), [m, h] = x(""), [g, _] = x(null), [y] = x(() => C(l) && typeof l == "string" ? {
603
- text: "",
604
- add: "",
605
- ariaLabel: "",
606
- url: l
607
- } : l);
608
- v(() => {
609
- o && C(y) && (d((y.url ?? "").replace(/\D/g, "").slice(0, 11).replace(/^7/, "")), y.add ? p((y.add ?? "").replace(/\D/g, "")) : p((y.url ?? "").replace(/\D/g, "").slice(11)), h(y.ariaLabel ?? ""));
610
- }, [o, y]);
611
- let b = (e) => {
612
- e = e.replace(/\D/g, ""), e.length <= 10 ? (d(e), _(null)) : _("нельзя ввести более 10 цифр");
613
- }, w = (e) => e.length === 10 ? !0 : (_("номер телефона должен содержать 10 цифр"), !1), E = (e) => {
614
- if (e.preventDefault(), !w(u)) return;
615
- if (!m) {
616
- _("добавьте описание для телефона");
617
- return;
618
- }
619
- let t = T(u);
620
- c(`tel:${`+7${u}`}`, f ? `${t} доб. ${f}` : t, f, m, !1), k();
621
- }, k = () => {
622
- d(""), h(""), _(null), s();
623
- };
624
- return /* @__PURE__ */ O(i, {
625
- isOpen: o,
626
- onClose: k,
627
- title: "Ссылка на телефон",
628
- size: "md",
629
- children: [/* @__PURE__ */ D(a, { children: /* @__PURE__ */ O(t, {
630
- gap: "md",
631
- children: [
632
- /* @__PURE__ */ O("div", {
633
- className: S("flex", "alignItemsEnd", "gapSm"),
634
- children: [/* @__PURE__ */ D(n, {
635
- label: "Номер телефона без 7-ки",
636
- description: "Вводится только номер (10) цифр без каких-либо дополнительных символов. Ссылка будет привязана к текущему выделенному фрагменту текста. Поэтому текст самой ссылки можно оформить грамотно, например: +7 (3522) 12-34-56 доб. 100",
637
- value: u,
638
- onChange: b,
639
- placeholder: "3522123456",
640
- className: "flex1"
641
- }), /* @__PURE__ */ D(n, {
642
- label: "Добавочный номер",
643
- value: f,
644
- onChange: p,
645
- placeholder: "100"
646
- })]
647
- }),
648
- g && /* @__PURE__ */ O("div", {
649
- className: "textColorDanger",
650
- children: [
651
- /* @__PURE__ */ D("strong", { children: "Ошибка ввода:" }),
652
- " ",
653
- /* @__PURE__ */ D("span", {
654
- className: "fontItalic",
655
- children: g
656
- })
657
- ]
658
- }),
659
- /* @__PURE__ */ D(n, {
660
- label: "Текст для экранных читалок",
661
- description: "Обязательное поле для организации доступности ссылки для лиц с ОВЗ, использующих скринридеры",
662
- value: m,
663
- onChange: h,
664
- placeholder: "Контактный телефон директора"
665
- })
666
- ]
667
- }) }), /* @__PURE__ */ O(r, { children: [/* @__PURE__ */ D(e, {
668
- appearance: "solid",
669
- tone: "error",
670
- onClick: k,
671
- children: "Отмена"
672
- }), /* @__PURE__ */ D(e, {
673
- appearance: "solid",
674
- tone: "success",
675
- onClick: E,
676
- disabled: !u || !m,
677
- children: "Подтвердить"
678
- })] })]
679
- });
680
- }
681
- //#endregion
682
- //#region src/text-editor/SemanticDialog.tsx
683
- function Se({ isOpen: o, onClose: s, onConfirm: c, config: l, initialText: u = "", initialState: d = {} }) {
684
- let [f, p] = x(u), [m, h] = x({}), [g, _] = x({}), [y, b] = x(!1);
685
- v(() => {
686
- if (o && !y) {
687
- let e = l.fields.reduce((e, t) => (e[t.name] = d[t.name] ?? "", e), {});
688
- h(e), _({}), b(!0);
689
- } else !o && y && b(!1);
690
- }, [
691
- o,
692
- l.fields,
693
- d,
694
- y
695
- ]);
696
- let S = (e, t) => {
697
- h((n) => ({
698
- ...n,
699
- [e]: t
700
- })), _((t) => ({
701
- ...t,
702
- [e]: null
703
- }));
704
- }, C = () => {
705
- let e = {}, t = !0;
706
- f.trim() || (e.text = "Обязательное поле", t = !1);
707
- for (let n of l.fields) {
708
- let r = m[n.name]?.trim();
709
- if (n.required && !r) e[n.name] = "Обязательное поле", t = !1;
710
- else if (n.validate) {
711
- let i = n.validate(r);
712
- i && (e[n.name] = i, t = !1);
713
- }
714
- }
715
- return _(e), t;
716
- };
717
- return /* @__PURE__ */ O(i, {
718
- isOpen: o,
719
- onClose: s,
720
- title: `Вставка <${l.tagName}>`,
721
- size: "md",
722
- children: [/* @__PURE__ */ D(a, { children: /* @__PURE__ */ O(t, {
723
- gap: "md",
724
- children: [
725
- /* @__PURE__ */ O("div", { children: [
726
- l.description,
727
- ".",
728
- /* @__PURE__ */ D("br", {})
729
- ] }),
730
- /* @__PURE__ */ O("div", { children: [
731
- /* @__PURE__ */ D("strong", { children: "Пример:" }),
732
- " ",
733
- l.example
734
- ] }),
735
- /* @__PURE__ */ D(n, {
736
- label: l.title,
737
- description: `Данный текст будет вставлен в редактор и обёрнуть в специальный семантический тег ${l.tagName}`,
738
- value: f,
739
- onChange: p,
740
- error: g.text ?? void 0,
741
- required: !0
742
- }),
743
- l.fields.map((e) => /* @__PURE__ */ D(n, {
744
- label: e.label,
745
- description: e.description,
746
- placeholder: e.placeholder,
747
- value: m[e.name] ?? "",
748
- onChange: (t) => S(e.name, t),
749
- error: g[e.name] ?? void 0,
750
- required: e.required
751
- }, e.name))
752
- ]
753
- }) }), /* @__PURE__ */ O(r, { children: [/* @__PURE__ */ D(e, {
754
- appearance: "solid",
755
- tone: "error",
756
- onClick: s,
757
- children: "Отмена"
758
- }), /* @__PURE__ */ D(e, {
759
- appearance: "solid",
760
- tone: "success",
761
- onClick: () => {
762
- C() && (c(l.tagName, f.trim(), m), s());
763
- },
764
- children: "Подтвердить"
765
- })] })]
766
- });
767
- }
768
- //#endregion
769
- //#region src/text-editor/semanticTagConfigs.tsx
770
- var Ce = {
771
- [l.abbr]: {
772
- tagName: "abbr",
773
- title: "Аббревиатура",
774
- description: "Обозначает аббревиатуры и сокращения, при наведении покажет расшифровку",
775
- example: /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("abbr", {
776
- title: "Национальное управление по аэронавтике и исследованию космического пространства",
777
- children: "НАСА"
778
- }), /* @__PURE__ */ D("div", {
779
- className: "marginTopMd",
780
- children: /* @__PURE__ */ D("code", { children: "<abbr title=\"Национальное управление по аэронавтике и исследованию космического пространства\">НАСА</abbr>" })
781
- })] }),
782
- fields: [{
783
- name: "title",
784
- label: "Расшифровка",
785
- description: "Появится как подсказка и будет прочитана скринридером",
786
- placeholder: "например: HyperText Markup Language",
787
- required: !0
788
- }]
789
- },
790
- [l.lang]: {
791
- tagName: "span",
792
- title: "Текст на другом языке",
793
- description: "Указывает язык фрагмента текста, если он отличается от основного языка страницы, скринридер прочитает это слово с французским произношением",
794
- example: /* @__PURE__ */ O(E, { children: [
795
- /* @__PURE__ */ D("span", {
796
- lang: "fr",
797
- children: "Bonjour!"
798
- }),
799
- " — сказал турист.",
800
- /* @__PURE__ */ D("div", {
801
- className: "marginTopMd",
802
- children: /* @__PURE__ */ D("code", { children: "<span lang=\"fr\">Bonjour!</span> — сказал турист." })
803
- })
804
- ] }),
805
- fields: [{
806
- name: "lang",
807
- label: "Код языка",
808
- placeholder: "en, fr, ru",
809
- required: !0,
810
- validate: (e) => /^[a-z]{2,3}(-[A-Z]{2})?$/.test(e) ? null : "Неверный код языка (например, en или en-US)"
811
- }]
812
- },
813
- [l.time]: {
814
- tagName: "time",
815
- title: "Дата/время",
816
- description: "",
817
- example: "",
818
- fields: [{
819
- name: "datetime",
820
- label: "Дата/время (machine-readable)",
821
- description: "Формат ISO 8601: 2025-05-18, 14:30, 2025-05-18T14:30",
822
- placeholder: "например: 2025-05-18T14:30",
823
- required: !0
824
- }]
825
- },
826
- [l.cite]: {
827
- tagName: "cite",
828
- title: "Цитата источника",
829
- description: "Обозначает название книги, статьи, фильма или другого произведения, на которое вы ссылаетесь",
830
- example: /* @__PURE__ */ O(E, { children: [
831
- "По словам Эйнштейна: ",
832
- /* @__PURE__ */ D("cite", { children: "«Воображение важнее знания»" }),
833
- ".",
834
- /* @__PURE__ */ D("div", {
835
- className: "marginTopMd",
836
- children: /* @__PURE__ */ D("code", { children: "По словам Эйнштейна: <cite>«Воображение важнее знания»</cite>." })
837
- })
838
- ] }),
839
- fields: [{
840
- name: "title",
841
- label: "Название источника",
842
- description: "Будет отображаться как подсказка",
843
- placeholder: "например: Википедия",
844
- required: !1
845
- }]
846
- },
847
- [l.del]: {
848
- tagName: "del",
849
- title: "Изменения в тексте",
850
- description: "Удаленный фрагмент",
851
- example: /* @__PURE__ */ O(E, { children: [
852
- "Проект сдачи: ",
853
- /* @__PURE__ */ D("del", { children: "1 июня" }),
854
- " ",
855
- /* @__PURE__ */ D("ins", { children: "15 июня" }),
856
- /* @__PURE__ */ D("div", {
857
- className: "marginTopMd",
858
- children: /* @__PURE__ */ D("code", { children: "Проект сдачи: <del>1 июня</del> <ins>15 июня</ins>" })
859
- })
860
- ] }),
861
- fields: [{
862
- name: "datetime",
863
- label: "Когда был удалён",
864
- description: "Формат ISO 8601: 2025-05-18T14:30",
865
- placeholder: "например: 2025-05-18T14:30",
866
- required: !1
867
- }, {
868
- name: "cite",
869
- label: "Источник/обоснование",
870
- description: "Ссылка на объяснение причины",
871
- placeholder: "например: https://example.com/edit-log",
872
- required: !1
873
- }]
874
- },
875
- [l.ins]: {
876
- tagName: "ins",
877
- title: "Изменения в тексте",
878
- description: "Новый добавленный текст",
879
- example: /* @__PURE__ */ O(E, { children: [
880
- "Проект сдачи: ",
881
- /* @__PURE__ */ D("del", { children: "1 июня" }),
882
- " ",
883
- /* @__PURE__ */ D("ins", { children: "15 июня" }),
884
- /* @__PURE__ */ D("div", {
885
- className: "marginTopMd",
886
- children: /* @__PURE__ */ D("code", { children: "Проект сдачи: <del>1 июня</del> <ins>15 июня</ins>" })
887
- })
888
- ] }),
889
- fields: [{
890
- name: "datetime",
891
- label: "Когда был добавлен",
892
- description: "Формат ISO 8601: 2025-05-18T14:30",
893
- placeholder: "например: 2025-05-18T14:30",
894
- required: !1
895
- }, {
896
- name: "cite",
897
- label: "Источник/обоснование",
898
- description: "Ссылка на объяснение причины",
899
- placeholder: "например: https://example.com/edit-log",
900
- required: !1
901
- }]
902
- }
903
- };
904
- //#endregion
905
- //#region src/text-editor/TimeDialog.tsx
906
- function we({ isOpen: o, onClose: c, onConfirm: l, initialState: u }) {
907
- let [d, f] = x("date"), [p, m] = x(""), [h, g] = x(""), [_, b] = x({}), S = y((e) => {
908
- f(e?.mode ?? "date"), m(e?.from ?? ""), g(e?.to ?? ""), b({});
909
- });
910
- v(() => {
911
- o && S(u);
912
- }, [o, u]);
913
- let C = () => {
914
- let e = {}, t = (e) => /^\d{4}-\d{2}-\d{2}$/.test(e), n = (e) => /^\d{2}:\d{2}$/.test(e), r = (e) => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(e), i = (e, i, a) => {
915
- if (!i) return `${e} обязательно`;
916
- if (a === "date" && !t(i)) return "Неверный формат даты (ГГГГ-ММ-ДД)";
917
- if (a === "time" && !n(i)) return "Неверный формат времени (ЧЧ:ММ)";
918
- if (a === "datetime" && !r(i)) return "Неверный формат даты и времени (ГГГГ-ММ-ДДTЧЧ:ММ)";
919
- };
920
- switch (d) {
921
- case "date":
922
- e.from = i("Дата", p, "date");
923
- break;
924
- case "time":
925
- e.from = i("Время", p, "time");
926
- break;
927
- case "datetime":
928
- e.from = i("Дата и время", p, "datetime");
929
- break;
930
- case "range-time":
931
- e.from = i("Время начала", p, "time"), e.to = i("Время окончания", h, "time");
932
- break;
933
- case "range-date":
934
- e.from = i("Дата начала", p, "date"), e.to = i("Дата окончания", h, "date");
935
- break;
936
- case "range-datetime":
937
- e.from = i("Начало", p, "datetime"), e.to = i("Окончание", h, "datetime");
938
- break;
939
- }
940
- return b(e), Object.values(e).every((e) => !e);
941
- };
942
- return /* @__PURE__ */ O(i, {
943
- isOpen: o,
944
- onClose: c,
945
- title: "Вставка <time>",
946
- size: "md",
947
- children: [/* @__PURE__ */ D(a, { children: /* @__PURE__ */ O(t, {
948
- gap: "md",
949
- children: [/* @__PURE__ */ O(s, {
950
- label: "Тип значения",
951
- value: d,
952
- onChange: f,
953
- children: [
954
- /* @__PURE__ */ D(s.Option, {
955
- label: "Дата",
956
- value: "date"
957
- }),
958
- /* @__PURE__ */ D(s.Option, {
959
- label: "Дата и время",
960
- value: "datetime"
961
- }),
962
- /* @__PURE__ */ D(s.Option, {
963
- label: "Время",
964
- value: "time"
965
- }),
966
- /* @__PURE__ */ D(s.Option, {
967
- label: "Диапазон дат",
968
- value: "range-date"
969
- }),
970
- /* @__PURE__ */ D(s.Option, {
971
- label: "Диапазон времени",
972
- value: "range-time"
973
- }),
974
- /* @__PURE__ */ D(s.Option, {
975
- label: "Диапазон даты и времени",
976
- value: "range-datetime"
977
- })
978
- ]
979
- }), /* @__PURE__ */ D(t, {
980
- gap: "md",
981
- children: (() => {
982
- switch (d) {
983
- case "date":
984
- case "datetime":
985
- case "time": return /* @__PURE__ */ D(n, {
986
- label: "Значение",
987
- placeholder: d === "time" ? "09:00" : d === "date" ? "2025-05-18" : "2025-05-18T09:00",
988
- value: p,
989
- onChange: m,
990
- error: _.from
991
- });
992
- case "range-time":
993
- case "range-date":
994
- case "range-datetime": return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(n, {
995
- label: "С",
996
- placeholder: d.includes("time") ? "09:00" : d.includes("date") ? "2025-05-18" : "2025-05-18T09:00",
997
- value: p,
998
- onChange: m,
999
- error: _.from
1000
- }), /* @__PURE__ */ D(n, {
1001
- label: "По",
1002
- placeholder: d.includes("time") ? "17:00" : d.includes("date") ? "2025-05-22" : "2025-05-22T17:00",
1003
- value: h,
1004
- onChange: m,
1005
- error: _.to
1006
- })] });
1007
- }
1008
- })()
1009
- })]
1010
- }) }), /* @__PURE__ */ O(r, { children: [/* @__PURE__ */ D(e, {
1011
- appearance: "solid",
1012
- tone: "error",
1013
- onClick: c,
1014
- children: "Отмена"
1015
- }), /* @__PURE__ */ D(e, {
1016
- appearance: "solid",
1017
- tone: "success",
1018
- onClick: () => {
1019
- if (!C()) return;
1020
- let e = h ? `${p}/${h}` : p;
1021
- l("time", e, { datetime: e }), c();
1022
- },
1023
- children: "Подтвердить"
1024
- })] })]
1025
- });
1026
- }
1027
- //#endregion
1028
- //#region src/text-editor/TextEditorDialogs.tsx
1029
- function Te({ linkTypeDialog: e, tagTypeDialog: t, localLinkDialogComponent: n, onCloseLinkDialog: r, onCloseTagDialog: i, onAddLink: a, onAddLocalLink: o, onInsertSemanticTag: s, getCurrentSelectionText: c, getSelectedLinkState: d }) {
1030
- let f = n;
1031
- return /* @__PURE__ */ O(E, { children: [e && /* @__PURE__ */ O(E, { children: [
1032
- f && /* @__PURE__ */ D(f, {
1033
- isOpen: e === u.LOCAL_LINK,
1034
- onClose: r,
1035
- onConfirm: o
1036
- }),
1037
- /* @__PURE__ */ D($, {
1038
- isOpen: e === u.LINK,
1039
- initialState: d(),
1040
- onClose: r,
1041
- onConfirm: a
1042
- }),
1043
- /* @__PURE__ */ D(xe, {
1044
- isOpen: e === u.PHONE,
1045
- initialState: d(),
1046
- onClose: r,
1047
- onConfirm: a
1048
- }),
1049
- /* @__PURE__ */ D(be, {
1050
- isOpen: e === u.EMAIL,
1051
- initialState: d(),
1052
- onClose: r,
1053
- onConfirm: a
1054
- })
1055
- ] }), t && (t === l.time ? /* @__PURE__ */ D(we, {
1056
- isOpen: !0,
1057
- onClose: i,
1058
- onConfirm: s
1059
- }) : /* @__PURE__ */ D(Se, {
1060
- isOpen: !0,
1061
- onClose: i,
1062
- onConfirm: s,
1063
- config: Ce[t],
1064
- initialText: c()
1065
- }))] });
1066
- }
1067
- //#endregion
1068
- //#region src/text-editor/TextEditorLexicalClient.tsx
1069
- function Ee({ initialData: e, onChange: t, toolbarComponents: n, businessAdapters: r }) {
1070
- let i = r?.LocalLinkDialogComponent, [a, o] = x(!1), [s, l] = x(p), [u, m] = x(null), [h, v] = x(null), [y, C] = x(null), w = c(e?.raw) ? e.raw : null, T = !!w, E = b(() => {
1071
- if (w) return JSON.stringify(w.editorState);
1072
- }, [w]), A = _((e) => {
1073
- console.error("Ошибка редактора Lexical", e);
1074
- }, []), j = _((e, n) => {
1075
- let r = "";
1076
- e.read(() => {
1077
- r = k(n, null);
1078
- }), t({
1079
- raw: he(e),
1080
- html: r
1081
- });
1082
- }, [t]), M = _((e) => {
1083
- v(e);
1084
- }, []), N = _((e) => {
1085
- C(e);
1086
- }, []), P = ye({
1087
- editor: u,
1088
- toolbarState: s,
1089
- hasLocalLinkDialog: !!i,
1090
- onOpenLinkDialog: M,
1091
- onOpenTagDialog: N
1092
- }), F = b(() => ({
1093
- namespace: "KtkTextEditorLexical",
1094
- onError: A,
1095
- theme: {
1096
- paragraph: "paragraph",
1097
- text: {
1098
- code: "lexicalTextCode",
1099
- highlight: "lexicalTextHighlight",
1100
- underline: "lexicalTextUnderline",
1101
- strikethrough: "lexicalTextStrikethrough"
1102
- }
1103
- },
1104
- nodes: [
1105
- ue,
1106
- de,
1107
- se,
1108
- oe,
1109
- K,
1110
- X
1111
- ],
1112
- editorState: E
1113
- }), [A, E]);
1114
- return /* @__PURE__ */ O("div", {
1115
- className: Q.textEditor,
1116
- children: [/* @__PURE__ */ D("div", {
1117
- className: S(Q.textEditorContent, { [Q.focused]: a }),
1118
- children: /* @__PURE__ */ O(L, {
1119
- initialConfig: F,
1120
- children: [
1121
- /* @__PURE__ */ D(d, {
1122
- toolbarComponents: n,
1123
- state: s,
1124
- onBlockStyleToggle: P.handleBlockStyleToggle,
1125
- onInlineStyleToggle: P.handleInlineStyleToggle,
1126
- onAlignmentChange: P.handleAlignmentChange,
1127
- onLinkClick: P.handleLinkClick,
1128
- onTagClick: P.handleTagClick,
1129
- onUndo: P.handleUndo,
1130
- onRedo: P.handleRedo,
1131
- onCleanTag: P.handleCleanSemanticTag
1132
- }),
1133
- /* @__PURE__ */ D(fe, {
1134
- contentEditable: /* @__PURE__ */ D(R, {
1135
- className: "lexicalEditorContentEditable",
1136
- onFocus: () => o(!0),
1137
- onBlur: () => o(!1)
1138
- }),
1139
- placeholder: /* @__PURE__ */ D("div", {
1140
- className: "lexicalEditorPlaceholder",
1141
- children: "Введите текст..."
1142
- }),
1143
- ErrorBoundary: z
1144
- }),
1145
- /* @__PURE__ */ D(B, {}),
1146
- /* @__PURE__ */ D(V, {}),
1147
- /* @__PURE__ */ D(g, {
1148
- onEditorReady: m,
1149
- onStateChange: l
1150
- }),
1151
- /* @__PURE__ */ D(f, {
1152
- initialHTML: e?.html,
1153
- shouldSkip: T
1154
- }),
1155
- /* @__PURE__ */ D(H, {
1156
- onChange: j,
1157
- ignoreSelectionChange: !0
1158
- })
1159
- ]
1160
- })
1161
- }), /* @__PURE__ */ D(Te, {
1162
- linkTypeDialog: h,
1163
- tagTypeDialog: y,
1164
- localLinkDialogComponent: i,
1165
- onCloseLinkDialog: () => v(null),
1166
- onCloseTagDialog: () => C(null),
1167
- onAddLink: P.handleAddLink,
1168
- onAddLocalLink: P.handleAddLocalLink,
1169
- onInsertSemanticTag: P.insertSemanticTagAtSelection,
1170
- getCurrentSelectionText: P.getCurrentSelectionText,
1171
- getSelectedLinkState: P.getSelectedLinkState
1172
- })]
1173
- });
1174
- }
1175
- //#endregion
1176
- export { Ee as TextEditorLexicalClient };
1177
-
1178
- //# sourceMappingURL=TextEditorLexicalClient-Bca3FOUs.js.map