@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.
- package/dist/DrawerMobile/MobileDrawer.scss +71 -0
- package/dist/DrawerMobile/constants.d.ts +9 -0
- package/dist/DrawerMobile/context.d.ts +18 -0
- package/dist/DrawerMobile/helpers.d.ts +13 -0
- package/dist/DrawerMobile/index.d.ts +17 -0
- package/dist/DrawerMobile/types.d.ts +5 -0
- package/dist/DrawerMobile/use-prevent-scroll.d.ts +5 -0
- package/dist/Popup/index.d.ts +4 -2
- package/dist/Tabs/index.d.ts +4 -4
- package/dist/__helpers/createPopupRegistry.d.ts +4 -0
- package/dist/bundle.es.js +112 -109
- package/dist/bundle.es10.js +1 -1
- package/dist/bundle.es13.js +4 -4
- package/dist/bundle.es14.js +4 -4
- package/dist/bundle.es15.js +2 -2
- package/dist/bundle.es16.js +1 -1
- package/dist/bundle.es17.js +1 -1
- package/dist/bundle.es19.js +1 -1
- package/dist/bundle.es22.js +1 -1
- package/dist/bundle.es23.js +260 -13
- package/dist/bundle.es24.js +14 -21
- package/dist/bundle.es25.js +20 -37
- package/dist/bundle.es26.js +38 -21
- package/dist/bundle.es27.js +20 -18
- package/dist/bundle.es28.js +18 -20
- package/dist/bundle.es29.js +20 -43
- package/dist/bundle.es30.js +37 -114
- package/dist/bundle.es31.js +119 -72
- package/dist/bundle.es32.js +68 -38
- package/dist/bundle.es33.js +42 -10
- package/dist/bundle.es34.js +11 -85
- package/dist/bundle.es35.js +85 -19
- package/dist/bundle.es36.js +20 -7
- package/dist/bundle.es37.js +7 -3
- package/dist/bundle.es38.js +3 -23
- package/dist/bundle.es39.js +16 -45
- package/dist/bundle.es40.js +51 -56
- package/dist/bundle.es41.js +57 -162
- package/dist/bundle.es42.js +160 -79
- package/dist/bundle.es43.js +81 -7
- package/dist/bundle.es44.js +7 -35
- package/dist/bundle.es45.js +33 -20
- package/dist/bundle.es46.js +19 -47
- package/dist/bundle.es47.js +49 -11
- package/dist/bundle.es48.js +11 -13
- package/dist/bundle.es49.js +13 -13
- package/dist/bundle.es50.js +13 -30
- package/dist/bundle.es51.js +29 -25
- package/dist/bundle.es52.js +17 -29
- package/dist/bundle.es53.js +36 -48
- package/dist/bundle.es54.js +49 -50
- package/dist/bundle.es55.js +56 -8
- package/dist/bundle.es56.js +8 -26
- package/dist/bundle.es57.js +27 -5
- package/dist/bundle.es58.js +5 -66
- package/dist/bundle.es59.js +66 -23
- package/dist/bundle.es60.js +22 -23
- package/dist/bundle.es61.js +24 -88
- package/dist/bundle.es62.js +88 -18
- package/dist/bundle.es63.js +17 -92
- package/dist/bundle.es64.js +92 -73
- package/dist/bundle.es65.js +73 -23
- package/dist/bundle.es66.js +20 -35
- package/dist/bundle.es67.js +37 -68
- package/dist/bundle.es68.js +23 -10
- package/dist/bundle.es69.js +78 -42
- package/dist/bundle.es70.js +93 -33
- package/dist/bundle.es71.js +10 -66
- package/dist/bundle.es72.js +69 -40
- package/dist/bundle.es73.js +10 -14
- package/dist/bundle.es74.js +43 -32
- package/dist/bundle.es75.js +32 -69
- package/dist/bundle.es76.js +65 -74
- package/dist/bundle.es77.js +39 -47
- package/dist/bundle.es78.js +14 -13
- package/dist/bundle.es79.js +32 -14
- package/dist/bundle.es80.js +72 -0
- package/dist/bundle.es81.js +16 -0
- package/dist/bundle.es82.js +77 -0
- package/dist/bundle.es83.js +51 -0
- package/dist/bundle.es84.js +16 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.scss +1 -0
- package/package.json +1 -1
package/dist/bundle.es35.js
CHANGED
|
@@ -1,22 +1,88 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
87
|
+
Y as TimePicker
|
|
22
88
|
};
|
package/dist/bundle.es36.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
21
|
+
g as Icon
|
|
9
22
|
};
|
package/dist/bundle.es37.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
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
|
-
|
|
8
|
+
i as ProgressBar
|
|
5
9
|
};
|
package/dist/bundle.es38.js
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
-
|
|
4
|
+
l as Skeleton
|
|
25
5
|
};
|
package/dist/bundle.es39.js
CHANGED
|
@@ -1,54 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
appearance: o =
|
|
6
|
-
|
|
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
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
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__ */
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
24
|
+
b as Blank
|
|
54
25
|
};
|
package/dist/bundle.es40.js
CHANGED
|
@@ -1,59 +1,54 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
53
|
+
u as ProgressRing
|
|
59
54
|
};
|
package/dist/bundle.es41.js
CHANGED
|
@@ -1,164 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
163
|
-
C as toTextChunksLite
|
|
58
|
+
w as WriteBar
|
|
164
59
|
};
|