@companix/uikit 0.1.42 → 0.1.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/CounterInput/CounterInput.scss +29 -0
  2. package/dist/CounterInput/index.d.ts +14 -0
  3. package/dist/Select/index.d.ts +9 -1
  4. package/dist/bundle.es.js +122 -120
  5. package/dist/bundle.es10.js +1 -1
  6. package/dist/bundle.es13.js +82 -76
  7. package/dist/bundle.es14.js +4 -4
  8. package/dist/bundle.es15.js +2 -2
  9. package/dist/bundle.es16.js +1 -1
  10. package/dist/bundle.es17.js +1 -1
  11. package/dist/bundle.es18.js +105 -19
  12. package/dist/bundle.es19.js +21 -34
  13. package/dist/bundle.es20.js +33 -24
  14. package/dist/bundle.es21.js +24 -45
  15. package/dist/bundle.es22.js +46 -26
  16. package/dist/bundle.es23.js +24 -259
  17. package/dist/bundle.es24.js +260 -13
  18. package/dist/bundle.es25.js +14 -21
  19. package/dist/bundle.es26.js +20 -37
  20. package/dist/bundle.es27.js +38 -21
  21. package/dist/bundle.es28.js +20 -18
  22. package/dist/bundle.es29.js +18 -21
  23. package/dist/bundle.es30.js +21 -43
  24. package/dist/bundle.es31.js +37 -114
  25. package/dist/bundle.es32.js +119 -72
  26. package/dist/bundle.es33.js +68 -38
  27. package/dist/bundle.es34.js +42 -10
  28. package/dist/bundle.es35.js +11 -85
  29. package/dist/bundle.es36.js +85 -19
  30. package/dist/bundle.es37.js +20 -7
  31. package/dist/bundle.es38.js +7 -3
  32. package/dist/bundle.es39.js +3 -23
  33. package/dist/bundle.es40.js +16 -45
  34. package/dist/bundle.es41.js +51 -56
  35. package/dist/bundle.es42.js +57 -162
  36. package/dist/bundle.es43.js +160 -79
  37. package/dist/bundle.es44.js +81 -7
  38. package/dist/bundle.es45.js +7 -59
  39. package/dist/bundle.es46.js +58 -33
  40. package/dist/bundle.es47.js +33 -20
  41. package/dist/bundle.es48.js +19 -47
  42. package/dist/bundle.es49.js +49 -11
  43. package/dist/bundle.es50.js +11 -13
  44. package/dist/bundle.es51.js +13 -13
  45. package/dist/bundle.es52.js +13 -30
  46. package/dist/bundle.es53.js +30 -11
  47. package/dist/bundle.es54.js +10 -25
  48. package/dist/bundle.es55.js +17 -29
  49. package/dist/bundle.es56.js +36 -48
  50. package/dist/bundle.es57.js +49 -55
  51. package/dist/bundle.es58.js +56 -8
  52. package/dist/bundle.es59.js +8 -26
  53. package/dist/bundle.es60.js +27 -5
  54. package/dist/bundle.es61.js +5 -66
  55. package/dist/bundle.es62.js +66 -23
  56. package/dist/bundle.es63.js +22 -23
  57. package/dist/bundle.es64.js +24 -90
  58. package/dist/bundle.es65.js +90 -18
  59. package/dist/bundle.es66.js +17 -93
  60. package/dist/bundle.es67.js +93 -73
  61. package/dist/bundle.es68.js +73 -23
  62. package/dist/bundle.es69.js +20 -35
  63. package/dist/bundle.es70.js +39 -24
  64. package/dist/bundle.es71.js +24 -79
  65. package/dist/bundle.es72.js +71 -85
  66. package/dist/bundle.es73.js +93 -10
  67. package/dist/bundle.es74.js +10 -6
  68. package/dist/bundle.es75.js +5 -69
  69. package/dist/bundle.es76.js +68 -10
  70. package/dist/bundle.es77.js +11 -42
  71. package/dist/bundle.es78.js +42 -32
  72. package/dist/bundle.es79.js +31 -64
  73. package/dist/bundle.es80.js +65 -40
  74. package/dist/bundle.es81.js +40 -14
  75. package/dist/bundle.es82.js +15 -32
  76. package/dist/bundle.es83.js +23 -61
  77. package/dist/bundle.es84.js +69 -13
  78. package/dist/bundle.es85.js +13 -74
  79. package/dist/bundle.es86.js +71 -45
  80. package/dist/bundle.es87.js +48 -13
  81. package/dist/bundle.es88.js +16 -0
  82. package/dist/index.d.ts +3 -1
  83. package/dist/index.scss +1 -0
  84. package/package.json +1 -1
@@ -1,164 +1,59 @@
1
- import { escape as u, unescape as f, isElementNode as g } from "@companix/utils-browser";
2
- import { onElementKeyDownFactory as v } from "./bundle.es79.js";
3
- import { getEditorSelection as l, normalizeEditorText as a, getNodeTextContent as h, scrollSelectionIntoView as d, getTextSelectionOffsets as E } from "./bundle.es80.js";
4
- class k {
5
- element;
6
- prevText = "";
7
- prevTextSelection = { from: 0, to: 0 };
8
- handlers = {
9
- contentChange: /* @__PURE__ */ new Set()
10
- };
11
- constructor(e) {
12
- if (e.contentEditable !== "true")
13
- throw new Error("Элемент эдитора должен быть contentEditable");
14
- e.tagName !== "SPAN" && console.warn("Используйте элемент span"), this.element = e, this.element.translate = !1;
15
- }
16
- getElement() {
17
- return this.element;
18
- }
19
- onPaste(e) {
20
- return this.handlers.paste || this.element.addEventListener("paste", this.handlePaste), this.handlers.paste = e, () => {
21
- this.handlers.paste = void 0, this.element.removeEventListener("paste", this.handlePaste);
22
- };
23
- }
24
- onKeyCombo(e) {
25
- const t = v(e);
26
- return this.element.addEventListener("keydown", t), this.handlers.keyCombo = e, () => {
27
- this.handlers.keyCombo = void 0, this.element.removeEventListener("keydown", t);
28
- };
29
- }
30
- onFocusChange(e) {
31
- return this.handlers.focusChange || (this.element.addEventListener("focus", this.handleFocus), this.element.addEventListener("blur", this.handleBlur)), this.handlers.focusChange = e, () => {
32
- this.handlers.focusChange = void 0, this.element.removeEventListener("focus", this.handleFocus), this.element.removeEventListener("blur", this.handleBlur);
33
- };
34
- }
35
- onContentChange(e) {
36
- return this.handlers.contentChange.size === 0 && (this.element.addEventListener("keyup", this.checkContentChanged), document.addEventListener("selectionchange", this.checkContentChanged)), this.handlers.contentChange.add(e), () => {
37
- this.handlers.contentChange.delete(e), this.handlers.contentChange.size === 0 && (this.element.removeEventListener("keyup", this.checkContentChanged), document.removeEventListener("selectionchange", this.checkContentChanged));
38
- };
39
- }
40
- onMouseDown() {
41
- return this.element.addEventListener("mousedown", this.handleMouseDown), () => {
42
- this.element.removeEventListener("mousedown", this.handleMouseDown);
43
- };
44
- }
45
- setSelection(e) {
46
- const t = l(this.element);
47
- if (!("selection" in t)) return;
48
- const n = document.createRange(), s = this.resolveDomPosition(e.from), o = this.resolveDomPosition(e.to);
49
- n.setStart(s.container, s.offset), n.setEnd(o.container, o.offset), t.selection.removeAllRanges(), t.selection.addRange(n);
50
- }
51
- // вставить переданный текст в текущую выделенную область/позицию курсора внутри contenteditable
52
- insertAtSelection(e, t) {
53
- t && this.setSelection(t);
54
- const n = C(u(e));
55
- for (const s of n)
56
- s.kind === "Text" && document.execCommand("insertText", !1, f(s.text));
57
- this.checkContentChanged();
58
- }
59
- removeFormat() {
60
- document.execCommand("removeFormat");
61
- }
62
- resetText(e = "", t = !1, n = !0) {
63
- const s = !this.isFocused() && !n;
64
- this.element.innerText = "";
65
- const o = document.activeElement, i = this.element.inputMode;
66
- s && (this.element.inputMode = "none"), this.element.focus(), document.execCommand("removeFormat"), t ? document.execCommand("inserthtml", !1, e) : this.insertAtSelection(a(e)), s && (this.element.blur(), this.element.inputMode = i, o?.focus?.()), this.checkContentChanged();
67
- }
68
- getText() {
69
- let e = "";
70
- const t = document.createTreeWalker(
71
- this.element,
72
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
73
- );
74
- for (; t.nextNode(); )
75
- e += h(t.currentNode);
76
- return a(e);
77
- }
78
- getHtml() {
79
- return this.element.innerHTML;
80
- }
81
- getHtmlWithEmojisAsText() {
82
- const e = this.element.innerHTML, t = /<img class="Emoji .+?" src=".+?" alt=".+?">/, n = /alt=".+?"/, s = (o) => {
83
- const i = o.match(t);
84
- if (!i?.[0]) return o;
85
- const c = i[0].match(n);
86
- if (!c?.[0]) return o;
87
- const m = c[0].replace("alt=", "").replaceAll('"', "");
88
- return s(o.replace(i[0], m));
89
- };
90
- return s(e);
91
- }
92
- focus(e = !1) {
93
- if (this.isFocused()) return;
94
- this.element.focus();
95
- const t = l(this.element);
96
- "selection" in t && (t.selection.selectAllChildren(this.element), e ? t.selection.collapseToStart() : t.selection.collapseToEnd(), d());
97
- }
98
- isFocused() {
99
- return document.activeElement === this.element;
100
- }
101
- setDisabled(e) {
102
- this.element.contentEditable = e ? "false" : "true";
103
- }
104
- handlePaste = async (e) => {
105
- e.preventDefault();
106
- const { clipboardData: t } = e;
107
- if (!t) return;
108
- const n = t.getData("text");
109
- if (n) {
110
- this.insertAtSelection(n), d();
111
- return;
112
- }
113
- };
114
- handleFocus = () => {
115
- this.handlers.focusChange?.(!0);
116
- };
117
- handleBlur = () => {
118
- this.handlers.focusChange?.(!1);
119
- };
120
- handleMouseDown = (e) => {
121
- if (!(e.target instanceof HTMLImageElement)) return;
122
- const t = new Range(), n = window.getSelection();
123
- n && (t.selectNode(e.target), t.collapse(e.offsetX <= 8), n.removeAllRanges(), n.addRange(t));
124
- };
125
- checkContentChanged = () => {
126
- const e = a(this.getText()), t = l(this.element);
127
- if (!("range" in t)) return;
128
- const n = E(this.element, t.range);
129
- if (e === this.prevText && n.from === this.prevTextSelection.from && n.to === this.prevTextSelection.to)
130
- return;
131
- const s = e === `
132
- ` && this.prevText.length > 0;
133
- if (this.prevText = e, this.prevTextSelection = n, s) {
134
- this.resetText("");
135
- return;
136
- }
137
- this.handlers.contentChange.forEach((o) => o(e, n));
138
- };
139
- resolveDomPosition(e) {
140
- const t = document.createTreeWalker(
141
- this.element,
142
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
143
- );
144
- let n = e;
145
- for (; t.nextNode(); ) {
146
- const s = t.currentNode, o = h(s).length;
147
- if (o >= n)
148
- return g(s) && s.nodeName === "BR" && (n -= 1), {
149
- container: s,
150
- offset: Math.max(n, 0)
151
- };
152
- n -= o;
153
- }
154
- return {
155
- container: this.element,
156
- offset: this.element.childNodes.length
157
- };
158
- }
159
- }
160
- const C = (r) => r ? [{ kind: "Text", text: r }] : [];
1
+ import { jsxs as s, jsx as r } from "react/jsx-runtime";
2
+ import c from "classnames";
3
+ import { Spinner as b } from "./bundle.es7.js";
4
+ import { Icon as h } from "./bundle.es37.js";
5
+ import { attr as N } from "@companix/utils-browser";
6
+ import { WriteBarInput as u } from "./bundle.es79.js";
7
+ const w = (a) => {
8
+ const {
9
+ before: e,
10
+ after: t,
11
+ containerRef: i,
12
+ header: o,
13
+ contentClassName: n,
14
+ placeholder: m,
15
+ id: l,
16
+ onCreate: d,
17
+ className: p,
18
+ ...f
19
+ } = a;
20
+ return /* @__PURE__ */ s("div", { ref: i, ...f, className: c("write-bar", p), children: [
21
+ o,
22
+ /* @__PURE__ */ s("div", { className: c("write-bar-content", n), children: [
23
+ e && /* @__PURE__ */ r("div", { className: "write-bar-before", children: e }),
24
+ /* @__PURE__ */ r(
25
+ u,
26
+ {
27
+ className: "write-bar-input-wrapper",
28
+ placeholder: m,
29
+ placeholderClassName: "write-bar-placeholder",
30
+ inputClassName: "write-bar-input",
31
+ inputMode: "text",
32
+ id: l,
33
+ onCreate: d
34
+ }
35
+ ),
36
+ t && /* @__PURE__ */ r("div", { className: "write-bar-after", children: t })
37
+ ] })
38
+ ] });
39
+ };
40
+ w.IconButton = ({
41
+ Component: a = "button",
42
+ icon: e,
43
+ mode: t,
44
+ onClick: i,
45
+ isLoading: o,
46
+ isHidden: n
47
+ }) => /* @__PURE__ */ r(
48
+ a,
49
+ {
50
+ onClick: i,
51
+ className: "write-bar-icon",
52
+ "data-mode": t,
53
+ "data-hidden": N(n),
54
+ children: o ? /* @__PURE__ */ r(b, { size: 18 }) : /* @__PURE__ */ r(h, { icon: e, size: "xxs" })
55
+ }
56
+ );
161
57
  export {
162
- k as Editor,
163
- C as toTextChunksLite
58
+ w as WriteBar
164
59
  };
@@ -1,83 +1,164 @@
1
- import { jsx as r, jsxs as p } from "react/jsx-runtime";
2
- import f from "classnames";
3
- import { useContext as m, createContext as u, useState as h, useCallback as c, useMemo as w } from "react";
4
- const E = ({ title: t, icon: i, text: e, onDrop: s }) => {
5
- const [l, n] = h(!1);
6
- return /* @__PURE__ */ p(
7
- "div",
8
- {
9
- onDrop: s,
10
- onDragEnter: () => n(!0),
11
- onDragLeave: () => n(!1),
12
- className: f("drop-target", {
13
- "drop-target-hovered": l
14
- }),
15
- children: [
16
- /* @__PURE__ */ r("div", { className: "drop-target-border", children: /* @__PURE__ */ r("svg", { width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "none", children: /* @__PURE__ */ r("rect", { x: "0", y: "0", rx: "8px", ry: "8px", width: "100%", height: "100%" }) }) }),
17
- /* @__PURE__ */ p("div", { className: "drop-target-area", children: [
18
- /* @__PURE__ */ r("i", { className: "drop-target-icon", children: i }),
19
- /* @__PURE__ */ p("div", { className: "drop-target-info", children: [
20
- /* @__PURE__ */ r("span", { className: "drop-target-title", children: t }),
21
- /* @__PURE__ */ r("span", { className: "drop-target-text", children: e })
22
- ] })
23
- ] })
24
- ]
1
+ import { escape as u, unescape as f, isElementNode as g } from "@companix/utils-browser";
2
+ import { onElementKeyDownFactory as v } from "./bundle.es80.js";
3
+ import { getEditorSelection as l, normalizeEditorText as a, getNodeTextContent as h, scrollSelectionIntoView as d, getTextSelectionOffsets as E } from "./bundle.es81.js";
4
+ class k {
5
+ element;
6
+ prevText = "";
7
+ prevTextSelection = { from: 0, to: 0 };
8
+ handlers = {
9
+ contentChange: /* @__PURE__ */ new Set()
10
+ };
11
+ constructor(e) {
12
+ if (e.contentEditable !== "true")
13
+ throw new Error("Элемент эдитора должен быть contentEditable");
14
+ e.tagName !== "SPAN" && console.warn("Используйте элемент span"), this.element = e, this.element.translate = !1;
15
+ }
16
+ getElement() {
17
+ return this.element;
18
+ }
19
+ onPaste(e) {
20
+ return this.handlers.paste || this.element.addEventListener("paste", this.handlePaste), this.handlers.paste = e, () => {
21
+ this.handlers.paste = void 0, this.element.removeEventListener("paste", this.handlePaste);
22
+ };
23
+ }
24
+ onKeyCombo(e) {
25
+ const t = v(e);
26
+ return this.element.addEventListener("keydown", t), this.handlers.keyCombo = e, () => {
27
+ this.handlers.keyCombo = void 0, this.element.removeEventListener("keydown", t);
28
+ };
29
+ }
30
+ onFocusChange(e) {
31
+ return this.handlers.focusChange || (this.element.addEventListener("focus", this.handleFocus), this.element.addEventListener("blur", this.handleBlur)), this.handlers.focusChange = e, () => {
32
+ this.handlers.focusChange = void 0, this.element.removeEventListener("focus", this.handleFocus), this.element.removeEventListener("blur", this.handleBlur);
33
+ };
34
+ }
35
+ onContentChange(e) {
36
+ return this.handlers.contentChange.size === 0 && (this.element.addEventListener("keyup", this.checkContentChanged), document.addEventListener("selectionchange", this.checkContentChanged)), this.handlers.contentChange.add(e), () => {
37
+ this.handlers.contentChange.delete(e), this.handlers.contentChange.size === 0 && (this.element.removeEventListener("keyup", this.checkContentChanged), document.removeEventListener("selectionchange", this.checkContentChanged));
38
+ };
39
+ }
40
+ onMouseDown() {
41
+ return this.element.addEventListener("mousedown", this.handleMouseDown), () => {
42
+ this.element.removeEventListener("mousedown", this.handleMouseDown);
43
+ };
44
+ }
45
+ setSelection(e) {
46
+ const t = l(this.element);
47
+ if (!("selection" in t)) return;
48
+ const n = document.createRange(), s = this.resolveDomPosition(e.from), o = this.resolveDomPosition(e.to);
49
+ n.setStart(s.container, s.offset), n.setEnd(o.container, o.offset), t.selection.removeAllRanges(), t.selection.addRange(n);
50
+ }
51
+ // вставить переданный текст в текущую выделенную область/позицию курсора внутри contenteditable
52
+ insertAtSelection(e, t) {
53
+ t && this.setSelection(t);
54
+ const n = C(u(e));
55
+ for (const s of n)
56
+ s.kind === "Text" && document.execCommand("insertText", !1, f(s.text));
57
+ this.checkContentChanged();
58
+ }
59
+ removeFormat() {
60
+ document.execCommand("removeFormat");
61
+ }
62
+ resetText(e = "", t = !1, n = !0) {
63
+ const s = !this.isFocused() && !n;
64
+ this.element.innerText = "";
65
+ const o = document.activeElement, i = this.element.inputMode;
66
+ s && (this.element.inputMode = "none"), this.element.focus(), document.execCommand("removeFormat"), t ? document.execCommand("inserthtml", !1, e) : this.insertAtSelection(a(e)), s && (this.element.blur(), this.element.inputMode = i, o?.focus?.()), this.checkContentChanged();
67
+ }
68
+ getText() {
69
+ let e = "";
70
+ const t = document.createTreeWalker(
71
+ this.element,
72
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
73
+ );
74
+ for (; t.nextNode(); )
75
+ e += h(t.currentNode);
76
+ return a(e);
77
+ }
78
+ getHtml() {
79
+ return this.element.innerHTML;
80
+ }
81
+ getHtmlWithEmojisAsText() {
82
+ const e = this.element.innerHTML, t = /<img class="Emoji .+?" src=".+?" alt=".+?">/, n = /alt=".+?"/, s = (o) => {
83
+ const i = o.match(t);
84
+ if (!i?.[0]) return o;
85
+ const c = i[0].match(n);
86
+ if (!c?.[0]) return o;
87
+ const m = c[0].replace("alt=", "").replaceAll('"', "");
88
+ return s(o.replace(i[0], m));
89
+ };
90
+ return s(e);
91
+ }
92
+ focus(e = !1) {
93
+ if (this.isFocused()) return;
94
+ this.element.focus();
95
+ const t = l(this.element);
96
+ "selection" in t && (t.selection.selectAllChildren(this.element), e ? t.selection.collapseToStart() : t.selection.collapseToEnd(), d());
97
+ }
98
+ isFocused() {
99
+ return document.activeElement === this.element;
100
+ }
101
+ setDisabled(e) {
102
+ this.element.contentEditable = e ? "false" : "true";
103
+ }
104
+ handlePaste = async (e) => {
105
+ e.preventDefault();
106
+ const { clipboardData: t } = e;
107
+ if (!t) return;
108
+ const n = t.getData("text");
109
+ if (n) {
110
+ this.insertAtSelection(n), d();
111
+ return;
25
112
  }
26
- );
27
- }, v = u({}), x = u({}), C = ({ onFilesAdd: t, ...i }) => {
28
- const { onHide: e, isVisable: s } = m(v), [l, n] = h(!1), d = c((a) => {
29
- a.preventDefault();
30
- }, []), g = c(
31
- (a) => {
32
- a.stopPropagation();
33
- const { relatedTarget: o } = a;
34
- o instanceof HTMLElement && o?.matches(".drop-target, .drop-area") || e();
35
- },
36
- [l, e]
37
- ), D = c(
38
- (a) => {
39
- a.preventDefault();
40
- const o = [...Array.from(a.dataTransfer.files)];
41
- o.length && t(o), e();
42
- },
43
- [t, e]
44
- );
45
- return /* @__PURE__ */ r(
46
- "div",
47
- {
48
- onDragStart: () => n(!0),
49
- onDragEnter: () => n(!0),
50
- onDragOver: d,
51
- onDragLeave: g,
52
- className: f("drop-area", {
53
- "drop-area-hidden": !s
54
- }),
55
- onDrop: () => {
56
- e(), n(!1);
57
- },
58
- children: s && /* @__PURE__ */ r(E, { ...i, onDrop: D })
113
+ };
114
+ handleFocus = () => {
115
+ this.handlers.focusChange?.(!0);
116
+ };
117
+ handleBlur = () => {
118
+ this.handlers.focusChange?.(!1);
119
+ };
120
+ handleMouseDown = (e) => {
121
+ if (!(e.target instanceof HTMLImageElement)) return;
122
+ const t = new Range(), n = window.getSelection();
123
+ n && (t.selectNode(e.target), t.collapse(e.offsetX <= 8), n.removeAllRanges(), n.addRange(t));
124
+ };
125
+ checkContentChanged = () => {
126
+ const e = a(this.getText()), t = l(this.element);
127
+ if (!("range" in t)) return;
128
+ const n = E(this.element, t.range);
129
+ if (e === this.prevText && n.from === this.prevTextSelection.from && n.to === this.prevTextSelection.to)
130
+ return;
131
+ const s = e === `
132
+ ` && this.prevText.length > 0;
133
+ if (this.prevText = e, this.prevTextSelection = n, s) {
134
+ this.resetText("");
135
+ return;
59
136
  }
60
- );
61
- }, H = ({ children: t }) => {
62
- const [i, e] = h(!1), s = c(() => {
63
- e(!1);
64
- }, []), l = c((d) => {
65
- const { items: g } = d.dataTransfer;
66
- Array.from(g).filter(
67
- ({ type: a, kind: o }) => a !== "text/uri-list" && o !== "string"
68
- ).length && e(!0);
69
- }, []), n = w(() => ({
70
- onDragEnter: l
71
- }), []);
72
- return /* @__PURE__ */ r(v.Provider, { value: { isVisable: i, onHide: s }, children: /* @__PURE__ */ r(x.Provider, { value: n, children: t }) });
73
- }, T = () => {
74
- const { onDragEnter: t } = m(x);
75
- if (!t)
76
- throw new Error("useDragContext should be within context");
77
- return t;
78
- };
137
+ this.handlers.contentChange.forEach((o) => o(e, n));
138
+ };
139
+ resolveDomPosition(e) {
140
+ const t = document.createTreeWalker(
141
+ this.element,
142
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
143
+ );
144
+ let n = e;
145
+ for (; t.nextNode(); ) {
146
+ const s = t.currentNode, o = h(s).length;
147
+ if (o >= n)
148
+ return g(s) && s.nodeName === "BR" && (n -= 1), {
149
+ container: s,
150
+ offset: Math.max(n, 0)
151
+ };
152
+ n -= o;
153
+ }
154
+ return {
155
+ container: this.element,
156
+ offset: this.element.childNodes.length
157
+ };
158
+ }
159
+ }
160
+ const C = (r) => r ? [{ kind: "Text", text: r }] : [];
79
161
  export {
80
- C as DropArea,
81
- H as DropAreaProvider,
82
- T as useDragEnter
162
+ k as Editor,
163
+ C as toTextChunksLite
83
164
  };
@@ -1,9 +1,83 @@
1
- import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
- const b = ({ header: c, items: e, getItemLayout: d, className: o, onRowClick: h }) => /* @__PURE__ */ p("table", { className: o, children: [
3
- /* @__PURE__ */ r("colgroup", { children: c.map(({ style: t }, l) => /* @__PURE__ */ r("col", { style: t }, `colgroup-col-${l}`)) }),
4
- /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ r("tr", { children: c.map(({ content: t }, l) => /* @__PURE__ */ r("th", { children: t }, `header-th-${l}`)) }) }),
5
- /* @__PURE__ */ r("tbody", { children: e.map((t, l) => /* @__PURE__ */ r("tr", { onClick: () => h?.(t), children: d(t, l).map((n, a) => /* @__PURE__ */ r("td", { children: n }, `table-td-${l}-${a}`)) }, `table-tr-${l}`)) })
6
- ] });
1
+ import { jsx as r, jsxs as p } from "react/jsx-runtime";
2
+ import f from "classnames";
3
+ import { useContext as m, createContext as u, useState as h, useCallback as c, useMemo as w } from "react";
4
+ const E = ({ title: t, icon: i, text: e, onDrop: s }) => {
5
+ const [l, n] = h(!1);
6
+ return /* @__PURE__ */ p(
7
+ "div",
8
+ {
9
+ onDrop: s,
10
+ onDragEnter: () => n(!0),
11
+ onDragLeave: () => n(!1),
12
+ className: f("drop-target", {
13
+ "drop-target-hovered": l
14
+ }),
15
+ children: [
16
+ /* @__PURE__ */ r("div", { className: "drop-target-border", children: /* @__PURE__ */ r("svg", { width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "none", children: /* @__PURE__ */ r("rect", { x: "0", y: "0", rx: "8px", ry: "8px", width: "100%", height: "100%" }) }) }),
17
+ /* @__PURE__ */ p("div", { className: "drop-target-area", children: [
18
+ /* @__PURE__ */ r("i", { className: "drop-target-icon", children: i }),
19
+ /* @__PURE__ */ p("div", { className: "drop-target-info", children: [
20
+ /* @__PURE__ */ r("span", { className: "drop-target-title", children: t }),
21
+ /* @__PURE__ */ r("span", { className: "drop-target-text", children: e })
22
+ ] })
23
+ ] })
24
+ ]
25
+ }
26
+ );
27
+ }, v = u({}), x = u({}), C = ({ onFilesAdd: t, ...i }) => {
28
+ const { onHide: e, isVisable: s } = m(v), [l, n] = h(!1), d = c((a) => {
29
+ a.preventDefault();
30
+ }, []), g = c(
31
+ (a) => {
32
+ a.stopPropagation();
33
+ const { relatedTarget: o } = a;
34
+ o instanceof HTMLElement && o?.matches(".drop-target, .drop-area") || e();
35
+ },
36
+ [l, e]
37
+ ), D = c(
38
+ (a) => {
39
+ a.preventDefault();
40
+ const o = [...Array.from(a.dataTransfer.files)];
41
+ o.length && t(o), e();
42
+ },
43
+ [t, e]
44
+ );
45
+ return /* @__PURE__ */ r(
46
+ "div",
47
+ {
48
+ onDragStart: () => n(!0),
49
+ onDragEnter: () => n(!0),
50
+ onDragOver: d,
51
+ onDragLeave: g,
52
+ className: f("drop-area", {
53
+ "drop-area-hidden": !s
54
+ }),
55
+ onDrop: () => {
56
+ e(), n(!1);
57
+ },
58
+ children: s && /* @__PURE__ */ r(E, { ...i, onDrop: D })
59
+ }
60
+ );
61
+ }, H = ({ children: t }) => {
62
+ const [i, e] = h(!1), s = c(() => {
63
+ e(!1);
64
+ }, []), l = c((d) => {
65
+ const { items: g } = d.dataTransfer;
66
+ Array.from(g).filter(
67
+ ({ type: a, kind: o }) => a !== "text/uri-list" && o !== "string"
68
+ ).length && e(!0);
69
+ }, []), n = w(() => ({
70
+ onDragEnter: l
71
+ }), []);
72
+ return /* @__PURE__ */ r(v.Provider, { value: { isVisable: i, onHide: s }, children: /* @__PURE__ */ r(x.Provider, { value: n, children: t }) });
73
+ }, T = () => {
74
+ const { onDragEnter: t } = m(x);
75
+ if (!t)
76
+ throw new Error("useDragContext should be within context");
77
+ return t;
78
+ };
7
79
  export {
8
- b as Table
80
+ C as DropArea,
81
+ H as DropAreaProvider,
82
+ T as useDragEnter
9
83
  };
@@ -1,61 +1,9 @@
1
- import { jsxs as b, jsx as i } from "react/jsx-runtime";
2
- import y from "classnames";
3
- import { useRef as F, useMemo as I, useState as o } from "react";
4
- const C = (a) => {
5
- const {
6
- previewSrc: e,
7
- maskHeight: s,
8
- maskWidth: t,
9
- className: m,
10
- src: l,
11
- children: d,
12
- enableAspectRatio: g,
13
- imgAttrs: p,
14
- ...f
15
- } = a, h = F(null), u = I(() => N(t, s), [t, s]), [r, v] = o(!1), [x, n] = o(!1), [w, c] = o(!1), $ = () => {
16
- x && (n(!1), c(!1));
17
- };
18
- return /* @__PURE__ */ b(
19
- "div",
20
- {
21
- className: y("image-base", { "image-base-loading": !r }, m),
22
- style: g ? { aspectRatio: t / s } : {},
23
- onClickCapture: $,
24
- ...f,
25
- children: [
26
- !r && /* @__PURE__ */ i("img", { className: "image-base-placeholder", src: u, alt: "" }),
27
- e && e !== l && !r && !w && /* @__PURE__ */ i(
28
- "img",
29
- {
30
- className: "image-base-preview",
31
- src: e,
32
- style: { maxWidth: `${t}px`, maxHeight: `${s}px` },
33
- loading: "lazy",
34
- decoding: "async",
35
- onError: () => c(!0),
36
- alt: ""
37
- }
38
- ),
39
- /* @__PURE__ */ i(
40
- "img",
41
- {
42
- ref: h,
43
- className: "image-base-img",
44
- src: l,
45
- decoding: "async",
46
- onLoad: () => v(!0),
47
- onError: () => n(!0),
48
- ...p
49
- }
50
- ),
51
- d
52
- ]
53
- }
54
- );
55
- }, N = (a, e) => {
56
- const s = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${e}" width="${a}" height="${e}" />`;
57
- return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`;
58
- };
1
+ import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
+ const b = ({ header: c, items: e, getItemLayout: d, className: o, onRowClick: h }) => /* @__PURE__ */ p("table", { className: o, children: [
3
+ /* @__PURE__ */ r("colgroup", { children: c.map(({ style: t }, l) => /* @__PURE__ */ r("col", { style: t }, `colgroup-col-${l}`)) }),
4
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ r("tr", { children: c.map(({ content: t }, l) => /* @__PURE__ */ r("th", { children: t }, `header-th-${l}`)) }) }),
5
+ /* @__PURE__ */ r("tbody", { children: e.map((t, l) => /* @__PURE__ */ r("tr", { onClick: () => h?.(t), children: d(t, l).map((n, a) => /* @__PURE__ */ r("td", { children: n }, `table-td-${l}-${a}`)) }, `table-tr-${l}`)) })
6
+ ] });
59
7
  export {
60
- C as ImageBase
8
+ b as Table
61
9
  };