@companix/uikit 0.1.15 → 0.1.17

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/DrawerMobile/MobileDrawer.scss +71 -0
  2. package/dist/DrawerMobile/constants.d.ts +9 -0
  3. package/dist/DrawerMobile/context.d.ts +18 -0
  4. package/dist/DrawerMobile/helpers.d.ts +13 -0
  5. package/dist/DrawerMobile/index.d.ts +17 -0
  6. package/dist/DrawerMobile/types.d.ts +5 -0
  7. package/dist/DrawerMobile/use-prevent-scroll.d.ts +5 -0
  8. package/dist/Popup/index.d.ts +4 -2
  9. package/dist/Tabs/index.d.ts +4 -4
  10. package/dist/__helpers/createPopupRegistry.d.ts +4 -0
  11. package/dist/bundle.es.js +112 -109
  12. package/dist/bundle.es10.js +1 -1
  13. package/dist/bundle.es13.js +4 -4
  14. package/dist/bundle.es14.js +4 -4
  15. package/dist/bundle.es15.js +2 -2
  16. package/dist/bundle.es16.js +1 -1
  17. package/dist/bundle.es17.js +1 -1
  18. package/dist/bundle.es19.js +1 -1
  19. package/dist/bundle.es22.js +1 -1
  20. package/dist/bundle.es23.js +260 -13
  21. package/dist/bundle.es24.js +14 -21
  22. package/dist/bundle.es25.js +20 -37
  23. package/dist/bundle.es26.js +38 -21
  24. package/dist/bundle.es27.js +20 -18
  25. package/dist/bundle.es28.js +18 -20
  26. package/dist/bundle.es29.js +20 -43
  27. package/dist/bundle.es30.js +37 -114
  28. package/dist/bundle.es31.js +119 -72
  29. package/dist/bundle.es32.js +68 -38
  30. package/dist/bundle.es33.js +42 -10
  31. package/dist/bundle.es34.js +11 -85
  32. package/dist/bundle.es35.js +85 -19
  33. package/dist/bundle.es36.js +20 -7
  34. package/dist/bundle.es37.js +7 -3
  35. package/dist/bundle.es38.js +3 -23
  36. package/dist/bundle.es39.js +16 -45
  37. package/dist/bundle.es40.js +51 -56
  38. package/dist/bundle.es41.js +57 -162
  39. package/dist/bundle.es42.js +160 -79
  40. package/dist/bundle.es43.js +81 -7
  41. package/dist/bundle.es44.js +7 -35
  42. package/dist/bundle.es45.js +33 -20
  43. package/dist/bundle.es46.js +19 -47
  44. package/dist/bundle.es47.js +49 -11
  45. package/dist/bundle.es48.js +11 -13
  46. package/dist/bundle.es49.js +13 -13
  47. package/dist/bundle.es50.js +13 -30
  48. package/dist/bundle.es51.js +29 -25
  49. package/dist/bundle.es52.js +17 -29
  50. package/dist/bundle.es53.js +36 -48
  51. package/dist/bundle.es54.js +49 -50
  52. package/dist/bundle.es55.js +56 -8
  53. package/dist/bundle.es56.js +8 -26
  54. package/dist/bundle.es57.js +27 -5
  55. package/dist/bundle.es58.js +5 -66
  56. package/dist/bundle.es59.js +66 -23
  57. package/dist/bundle.es60.js +22 -23
  58. package/dist/bundle.es61.js +24 -88
  59. package/dist/bundle.es62.js +88 -18
  60. package/dist/bundle.es63.js +17 -92
  61. package/dist/bundle.es64.js +92 -73
  62. package/dist/bundle.es65.js +73 -23
  63. package/dist/bundle.es66.js +20 -35
  64. package/dist/bundle.es67.js +37 -68
  65. package/dist/bundle.es68.js +23 -10
  66. package/dist/bundle.es69.js +78 -42
  67. package/dist/bundle.es70.js +93 -33
  68. package/dist/bundle.es71.js +10 -66
  69. package/dist/bundle.es72.js +69 -40
  70. package/dist/bundle.es73.js +10 -14
  71. package/dist/bundle.es74.js +43 -32
  72. package/dist/bundle.es75.js +32 -69
  73. package/dist/bundle.es76.js +65 -74
  74. package/dist/bundle.es77.js +39 -47
  75. package/dist/bundle.es78.js +14 -13
  76. package/dist/bundle.es79.js +32 -14
  77. package/dist/bundle.es80.js +72 -0
  78. package/dist/bundle.es81.js +16 -0
  79. package/dist/bundle.es82.js +77 -0
  80. package/dist/bundle.es83.js +51 -0
  81. package/dist/bundle.es84.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,22 +1,88 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import m from "classnames";
3
- import { forwardRef as s } from "react";
4
- const g = s(
5
- ({ icon: r, className: t, size: i = "m", ...e }, n) => {
6
- const [c, a, , , l] = r;
7
- return /* @__PURE__ */ o(
8
- "svg",
9
- {
10
- ref: n,
11
- viewBox: `0 0 ${c} ${a}`,
12
- className: m(`icon icon-size-${i}`, t),
13
- ...e,
14
- role: "img",
15
- children: /* @__PURE__ */ o(f, { paths: l })
16
- }
17
- );
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { useRef as b, useMemo as I, useState as E, useCallback as A } from "react";
3
+ import { getNum as S } from "@companix/utils-js";
4
+ import { getTimesOptions as W, getTimeValue as q, removeDigits as w, convertTimeToOption as y } from "./bundle.es65.js";
5
+ import { SelectRightElements as z } from "./bundle.es73.js";
6
+ import { Select as F } from "./bundle.es13.js";
7
+ import { Input as G } from "./bundle.es15.js";
8
+ const o = {
9
+ char: ":",
10
+ toString: (s) => s ? y(s, o.char) : "",
11
+ toValue: (s) => {
12
+ const n = s.split(o.char);
13
+ if (n.length === 2) {
14
+ const [e, u] = [S(n[0]), S(n[1])];
15
+ if (e !== null && u !== null && e < 24 && e >= 0 && u < 60 && u >= 0)
16
+ return { hours: e, minutes: u };
17
+ }
18
+ return null;
18
19
  }
19
- ), f = ({ paths: r }) => Array.isArray(r) ? /* @__PURE__ */ o("g", { children: r.map((t, i) => /* @__PURE__ */ o("path", { fill: "currentColor", d: t }, `-d-${i}`)) }) : /* @__PURE__ */ o("path", { fill: "currentColor", d: r });
20
+ }, Y = (s) => {
21
+ const { value: n, onChange: e, clearButton: u, clearButtonIcon: _, disabled: a, ...T } = s, m = b(null), p = b(null), h = I(() => W(10), []), k = I(() => {
22
+ if (n && !n.minutes.toString().endsWith("0")) {
23
+ const t = n.hours * 6 + Math.trunc(n.minutes / 10), r = [...h];
24
+ return r.splice(t + 1, 0, q(n)), r;
25
+ }
26
+ return h;
27
+ }, [h, n]), [i, l] = E(() => o.toString(n)), v = (t) => {
28
+ l(t), N(t);
29
+ const r = o.toValue(t);
30
+ r && e?.(r);
31
+ }, x = (t) => {
32
+ a || m.current && m.current.getAttribute("data-state") === "open" && t.preventDefault();
33
+ }, B = () => {
34
+ o.toValue(i) === null && l(o.toString(n ?? null));
35
+ }, O = (t) => {
36
+ e?.(o.toValue(t)), l(t);
37
+ }, R = (t) => {
38
+ t.stopPropagation(), l(""), e?.(null);
39
+ }, N = A((t) => {
40
+ if (t && t !== "__:__") {
41
+ const [r, M] = t.split(":"), d = (c) => {
42
+ const [C, V] = c.split(""), [j, D] = [C === "_" ? "0" : C, V === "_" ? "0" : V];
43
+ return j + D;
44
+ }, P = [d(r), d(M)].join(":"), f = o.toValue(P);
45
+ if (f) {
46
+ const c = f.hours * 6 + Math.trunc(f.minutes / 10);
47
+ c !== -1 && p.current && p.current.scrollTo(c);
48
+ }
49
+ }
50
+ }, []);
51
+ return /* @__PURE__ */ g(
52
+ F,
53
+ {
54
+ minimalOptions: !0,
55
+ options: k,
56
+ onChange: O,
57
+ value: i,
58
+ popoverRef: m,
59
+ scrollRef: p,
60
+ disabled: a,
61
+ children: /* @__PURE__ */ g(
62
+ G,
63
+ {
64
+ ...T,
65
+ value: i,
66
+ disabled: a,
67
+ onClick: x,
68
+ onValueChange: v,
69
+ onBlur: B,
70
+ mask: "99:99",
71
+ placeholder: "00:00",
72
+ rightElement: /* @__PURE__ */ g(
73
+ z,
74
+ {
75
+ clearButton: u,
76
+ clearButtonIcon: _,
77
+ value: !!w(i, [":", "_"]),
78
+ onClear: R
79
+ }
80
+ )
81
+ }
82
+ )
83
+ }
84
+ );
85
+ };
20
86
  export {
21
- g as Icon
87
+ Y as TimePicker
22
88
  };
@@ -1,9 +1,22 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { clamp as o, pc as p } from "@companix/utils-browser";
3
- const i = ({ appearance: a = "primary", value: e }) => {
4
- const s = 100 * o(e, 0, 1);
5
- return /* @__PURE__ */ r("div", { "aria-valuemax": 100, "aria-valuemin": 0, role: "progressbar", className: "progress-bar", children: /* @__PURE__ */ r("div", { className: "progress-bar-thumb", "data-appearance": a, style: { width: p(s) } }) });
6
- };
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import m from "classnames";
3
+ import { forwardRef as s } from "react";
4
+ const g = s(
5
+ ({ icon: r, className: t, size: i = "m", ...e }, n) => {
6
+ const [c, a, , , l] = r;
7
+ return /* @__PURE__ */ o(
8
+ "svg",
9
+ {
10
+ ref: n,
11
+ viewBox: `0 0 ${c} ${a}`,
12
+ className: m(`icon icon-size-${i}`, t),
13
+ ...e,
14
+ role: "img",
15
+ children: /* @__PURE__ */ o(f, { paths: l })
16
+ }
17
+ );
18
+ }
19
+ ), f = ({ paths: r }) => Array.isArray(r) ? /* @__PURE__ */ o("g", { children: r.map((t, i) => /* @__PURE__ */ o("path", { fill: "currentColor", d: t }, `-d-${i}`)) }) : /* @__PURE__ */ o("path", { fill: "currentColor", d: r });
7
20
  export {
8
- i as ProgressBar
21
+ g as Icon
9
22
  };
@@ -1,5 +1,9 @@
1
- import { jsx as e, Fragment as t } from "react/jsx-runtime";
2
- const l = ({ ...r }) => /* @__PURE__ */ e("div", { className: "skeleton", style: r, children: /* @__PURE__ */ e(t, { children: "‌" }) });
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { clamp as o, pc as p } from "@companix/utils-browser";
3
+ const i = ({ appearance: a = "primary", value: e }) => {
4
+ const s = 100 * o(e, 0, 1);
5
+ return /* @__PURE__ */ r("div", { "aria-valuemax": 100, "aria-valuemin": 0, role: "progressbar", className: "progress-bar", children: /* @__PURE__ */ r("div", { className: "progress-bar-thumb", "data-appearance": a, style: { width: p(s) } }) });
6
+ };
3
7
  export {
4
- l as Skeleton
8
+ i as ProgressBar
5
9
  };
@@ -1,25 +1,5 @@
1
- import { jsxs as i, jsx as a } from "react/jsx-runtime";
2
- import m from "classnames";
3
- import { Icon as p } from "./bundle.es35.js";
4
- const b = (c) => {
5
- const { appearance: l, icon: s, className: r, iconSize: t, title: e, description: n, children: o, style: d } = c;
6
- return /* @__PURE__ */ i(
7
- "div",
8
- {
9
- className: m("blank", r),
10
- "data-appearance": l ?? "neutral",
11
- style: d,
12
- children: [
13
- /* @__PURE__ */ a("div", { className: "blank-icon", children: /* @__PURE__ */ a(p, { icon: s, size: t }) }),
14
- (e || n) && /* @__PURE__ */ i("div", { className: "blank-text", children: [
15
- e && /* @__PURE__ */ a("h4", { className: "blank-title", children: e }),
16
- n && /* @__PURE__ */ a("div", { className: "blank-description", children: n })
17
- ] }),
18
- o
19
- ]
20
- }
21
- );
22
- };
1
+ import { jsx as e, Fragment as t } from "react/jsx-runtime";
2
+ const l = ({ ...r }) => /* @__PURE__ */ e("div", { className: "skeleton", style: r, children: /* @__PURE__ */ e(t, { children: "‌" }) });
23
3
  export {
24
- b as Blank
4
+ l as Skeleton
25
5
  };
@@ -1,54 +1,25 @@
1
- import { jsxs as e, jsx as s } from "react/jsx-runtime";
2
- import { getInitialsFontSize as l } from "./bundle.es4.js";
3
- import { clamp as i, customCSS as m, px as n } from "@companix/utils-browser";
4
- const u = ({
5
- appearance: o = "primary",
6
- hint: t,
7
- size: a = 80,
8
- width: c = 6,
9
- value: g
10
- }) => {
11
- const r = 100 * i(g, 0, 1);
12
- return /* @__PURE__ */ e(
1
+ import { jsxs as i, jsx as a } from "react/jsx-runtime";
2
+ import m from "classnames";
3
+ import { Icon as p } from "./bundle.es36.js";
4
+ const b = (c) => {
5
+ const { appearance: l, icon: s, className: r, iconSize: t, title: e, description: n, children: o, style: d } = c;
6
+ return /* @__PURE__ */ i(
13
7
  "div",
14
8
  {
15
- "aria-valuemax": 100,
16
- "aria-valuemin": 0,
17
- "aria-valuenow": r,
18
- role: "progressbar",
19
- className: "progress-ring",
20
- "data-appearance": o,
9
+ className: m("blank", r),
10
+ "data-appearance": l ?? "neutral",
11
+ style: d,
21
12
  children: [
22
- /* @__PURE__ */ e(
23
- "svg",
24
- {
25
- className: "progress-ring-image",
26
- style: m({
27
- "--percentage": r / 100,
28
- "--size": n(a),
29
- "--track-width": n(c)
30
- }),
31
- children: [
32
- /* @__PURE__ */ s("circle", { className: "progress-ring-track" }),
33
- /* @__PURE__ */ s("circle", { className: "progress-ring-indicator" })
34
- ]
35
- }
36
- ),
37
- t && /* @__PURE__ */ e(
38
- "div",
39
- {
40
- className: "progress-ring-hint",
41
- style: { fontSize: i(l(a) - 4, 0, 18) },
42
- children: [
43
- Math.round(r),
44
- "%"
45
- ]
46
- }
47
- )
13
+ /* @__PURE__ */ a("div", { className: "blank-icon", children: /* @__PURE__ */ a(p, { icon: s, size: t }) }),
14
+ (e || n) && /* @__PURE__ */ i("div", { className: "blank-text", children: [
15
+ e && /* @__PURE__ */ a("h4", { className: "blank-title", children: e }),
16
+ n && /* @__PURE__ */ a("div", { className: "blank-description", children: n })
17
+ ] }),
18
+ o
48
19
  ]
49
20
  }
50
21
  );
51
22
  };
52
23
  export {
53
- u as ProgressRing
24
+ b as Blank
54
25
  };
@@ -1,59 +1,54 @@
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.es35.js";
5
- import { attr as N } from "@companix/utils-browser";
6
- import { WriteBarInput as u } from "./bundle.es70.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
- ] });
1
+ import { jsxs as e, jsx as s } from "react/jsx-runtime";
2
+ import { getInitialsFontSize as l } from "./bundle.es4.js";
3
+ import { clamp as i, customCSS as m, px as n } from "@companix/utils-browser";
4
+ const u = ({
5
+ appearance: o = "primary",
6
+ hint: t,
7
+ size: a = 80,
8
+ width: c = 6,
9
+ value: g
10
+ }) => {
11
+ const r = 100 * i(g, 0, 1);
12
+ return /* @__PURE__ */ e(
13
+ "div",
14
+ {
15
+ "aria-valuemax": 100,
16
+ "aria-valuemin": 0,
17
+ "aria-valuenow": r,
18
+ role: "progressbar",
19
+ className: "progress-ring",
20
+ "data-appearance": o,
21
+ children: [
22
+ /* @__PURE__ */ e(
23
+ "svg",
24
+ {
25
+ className: "progress-ring-image",
26
+ style: m({
27
+ "--percentage": r / 100,
28
+ "--size": n(a),
29
+ "--track-width": n(c)
30
+ }),
31
+ children: [
32
+ /* @__PURE__ */ s("circle", { className: "progress-ring-track" }),
33
+ /* @__PURE__ */ s("circle", { className: "progress-ring-indicator" })
34
+ ]
35
+ }
36
+ ),
37
+ t && /* @__PURE__ */ e(
38
+ "div",
39
+ {
40
+ className: "progress-ring-hint",
41
+ style: { fontSize: i(l(a) - 4, 0, 18) },
42
+ children: [
43
+ Math.round(r),
44
+ "%"
45
+ ]
46
+ }
47
+ )
48
+ ]
49
+ }
50
+ );
39
51
  };
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
- );
57
52
  export {
58
- w as WriteBar
53
+ u as ProgressRing
59
54
  };
@@ -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.es71.js";
3
- import { getEditorSelection as l, normalizeEditorText as a, getNodeTextContent as h, scrollSelectionIntoView as d, getTextSelectionOffsets as E } from "./bundle.es72.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.es36.js";
5
+ import { attr as N } from "@companix/utils-browser";
6
+ import { WriteBarInput as u } from "./bundle.es75.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
  };