@companix/uikit 0.1.14 → 0.1.16
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/Scrollable/Scrollable.scss +0 -5
- 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 +64 -12
- package/dist/bundle.es77.js +41 -75
- package/dist/bundle.es78.js +14 -48
- package/dist/bundle.es79.js +32 -14
- package/dist/bundle.es80.js +72 -0
- package/dist/bundle.es81.js +77 -0
- package/dist/bundle.es82.js +51 -0
- package/dist/bundle.es83.js +16 -0
- package/dist/bundle.es84.js +16 -0
- package/dist/bundle.es9.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.scss +1 -0
- package/package.json +1 -1
package/dist/bundle.es42.js
CHANGED
|
@@ -1,83 +1,164 @@
|
|
|
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
|
-
|
|
1
|
+
import { escape as u, unescape as f, isElementNode as g } from "@companix/utils-browser";
|
|
2
|
+
import { onElementKeyDownFactory as v } from "./bundle.es76.js";
|
|
3
|
+
import { getEditorSelection as l, normalizeEditorText as a, getNodeTextContent as h, scrollSelectionIntoView as d, getTextSelectionOffsets as E } from "./bundle.es77.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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
T as useDragEnter
|
|
162
|
+
k as Editor,
|
|
163
|
+
C as toTextChunksLite
|
|
83
164
|
};
|
package/dist/bundle.es43.js
CHANGED
|
@@ -1,9 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
80
|
+
C as DropArea,
|
|
81
|
+
H as DropAreaProvider,
|
|
82
|
+
T as useDragEnter
|
|
9
83
|
};
|
package/dist/bundle.es44.js
CHANGED
|
@@ -1,37 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}), y = () => w(i), p = (d) => {
|
|
8
|
-
const { defaultColorScheme: o = "system", storageKey: n = "theme", children: l } = d, [r, a] = h(() => v(n, o)), s = (e) => {
|
|
9
|
-
a(e), localStorage.setItem(n, e);
|
|
10
|
-
};
|
|
11
|
-
return c(() => {
|
|
12
|
-
const e = window ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
|
|
13
|
-
if (!e)
|
|
14
|
-
return;
|
|
15
|
-
const t = () => {
|
|
16
|
-
r === "system" && m("system");
|
|
17
|
-
};
|
|
18
|
-
return e.addEventListener?.("change", t), t(), () => {
|
|
19
|
-
e.removeEventListener?.("change", t);
|
|
20
|
-
};
|
|
21
|
-
}, [r]), c(() => {
|
|
22
|
-
if (!window)
|
|
23
|
-
return;
|
|
24
|
-
const e = (t) => {
|
|
25
|
-
t.key === n && (t.newValue ? a(t.newValue) : s(o));
|
|
26
|
-
};
|
|
27
|
-
return window.addEventListener("storage", e), () => {
|
|
28
|
-
window.removeEventListener("storage", e);
|
|
29
|
-
};
|
|
30
|
-
}, [s, o]), c(() => {
|
|
31
|
-
m(r);
|
|
32
|
-
}, [r]), /* @__PURE__ */ u(i.Provider, { value: { colorScheme: r, setColorScheme: s }, children: l });
|
|
33
|
-
};
|
|
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
|
+
] });
|
|
34
7
|
export {
|
|
35
|
-
|
|
36
|
-
y as useTheme
|
|
8
|
+
b as Table
|
|
37
9
|
};
|
package/dist/bundle.es45.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{
|
|
6
|
-
suppressHydrationWarning: !0,
|
|
7
|
-
dangerouslySetInnerHTML: {
|
|
8
|
-
__html: `(${a.toString()})("${t}", "${o}")`
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
)), a = (t, o) => {
|
|
12
|
-
const [r, c] = ["theme-light", "theme-dark"];
|
|
13
|
-
try {
|
|
14
|
-
let e = localStorage.getItem(t) || o;
|
|
15
|
-
e === "system" && (e = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
16
|
-
const s = e === "dark" ? c : r;
|
|
17
|
-
document.documentElement.classList.remove(r, c), document.documentElement.classList.add(s), document.documentElement.style.colorScheme = e;
|
|
18
|
-
} catch {
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as c, createContext as f, useContext as w } from "react";
|
|
3
|
+
import { getColorScheme as v, updateDOM as m } from "./bundle.es78.js";
|
|
4
|
+
const i = f({
|
|
5
|
+
setColorScheme: () => {
|
|
19
6
|
}
|
|
7
|
+
}), y = () => w(i), p = (d) => {
|
|
8
|
+
const { defaultColorScheme: o = "system", storageKey: n = "theme", children: l } = d, [r, a] = h(() => v(n, o)), s = (e) => {
|
|
9
|
+
a(e), localStorage.setItem(n, e);
|
|
10
|
+
};
|
|
11
|
+
return c(() => {
|
|
12
|
+
const e = window ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
|
|
13
|
+
if (!e)
|
|
14
|
+
return;
|
|
15
|
+
const t = () => {
|
|
16
|
+
r === "system" && m("system");
|
|
17
|
+
};
|
|
18
|
+
return e.addEventListener?.("change", t), t(), () => {
|
|
19
|
+
e.removeEventListener?.("change", t);
|
|
20
|
+
};
|
|
21
|
+
}, [r]), c(() => {
|
|
22
|
+
if (!window)
|
|
23
|
+
return;
|
|
24
|
+
const e = (t) => {
|
|
25
|
+
t.key === n && (t.newValue ? a(t.newValue) : s(o));
|
|
26
|
+
};
|
|
27
|
+
return window.addEventListener("storage", e), () => {
|
|
28
|
+
window.removeEventListener("storage", e);
|
|
29
|
+
};
|
|
30
|
+
}, [s, o]), c(() => {
|
|
31
|
+
m(r);
|
|
32
|
+
}, [r]), /* @__PURE__ */ u(i.Provider, { value: { colorScheme: r, setColorScheme: s }, children: l });
|
|
20
33
|
};
|
|
21
34
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
p as ThemeProvider,
|
|
36
|
+
y as useTheme
|
|
24
37
|
};
|
package/dist/bundle.es46.js
CHANGED
|
@@ -1,52 +1,24 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { memo as n } from "react";
|
|
3
|
+
const i = n(({ storageKey: t, defaultColorScheme: o }) => /* @__PURE__ */ l(
|
|
4
|
+
"script",
|
|
5
|
+
{
|
|
6
|
+
suppressHydrationWarning: !0,
|
|
7
|
+
dangerouslySetInnerHTML: {
|
|
8
|
+
__html: `(${a.toString()})("${t}", "${o}")`
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
)), a = (t, o) => {
|
|
12
|
+
const [r, c] = ["theme-light", "theme-dark"];
|
|
13
|
+
try {
|
|
14
|
+
let e = localStorage.getItem(t) || o;
|
|
15
|
+
e === "system" && (e = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
16
|
+
const s = e === "dark" ? c : r;
|
|
17
|
+
document.documentElement.classList.remove(r, c), document.documentElement.classList.add(s), document.documentElement.style.colorScheme = e;
|
|
18
|
+
} catch {
|
|
14
19
|
}
|
|
15
|
-
setValue(e, t) {
|
|
16
|
-
localStorage.setItem(e, JSON.stringify(t)), this.emmiter.emit(e, t);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const x = (o, e) => {
|
|
20
|
-
const t = S(a), [r, i] = f(() => t.getStorageValue(o, e));
|
|
21
|
-
n(() => {
|
|
22
|
-
i(t.getStorageValue(o, e));
|
|
23
|
-
}, [o]);
|
|
24
|
-
const c = (s) => {
|
|
25
|
-
t.setValue(o, s);
|
|
26
|
-
};
|
|
27
|
-
return n(() => {
|
|
28
|
-
const s = t.emmiter.subscribe(o, (u) => {
|
|
29
|
-
i(u);
|
|
30
|
-
});
|
|
31
|
-
return () => {
|
|
32
|
-
s();
|
|
33
|
-
};
|
|
34
|
-
}, [o]), [r, c];
|
|
35
|
-
}, y = ({ children: o }) => {
|
|
36
|
-
const e = w(new d(new g()));
|
|
37
|
-
return n(() => {
|
|
38
|
-
if (!window || !e.current)
|
|
39
|
-
return;
|
|
40
|
-
const t = (r) => {
|
|
41
|
-
r.key && e.current.emmiter.store[r.key] && r.newValue && e.current.emmiter.emit(r.key, JSON.parse(r.newValue));
|
|
42
|
-
};
|
|
43
|
-
return window.addEventListener("storage", t), () => {
|
|
44
|
-
window.removeEventListener("storage", t);
|
|
45
|
-
};
|
|
46
|
-
}, []), /* @__PURE__ */ m(a.Provider, { value: e.current, children: o });
|
|
47
20
|
};
|
|
48
21
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
x as useLocalStorage
|
|
22
|
+
i as ColorSchemeScript,
|
|
23
|
+
a as colorSchemeScript
|
|
52
24
|
};
|
package/dist/bundle.es47.js
CHANGED
|
@@ -1,14 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { EventEmmiter as g } from "@companix/utils-js";
|
|
3
|
+
import { useContext as S, createContext as l, useState as f, useEffect as n, useRef as w } from "react";
|
|
4
|
+
const a = l({});
|
|
5
|
+
class d {
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.emmiter = e;
|
|
8
|
+
}
|
|
9
|
+
getStorageValue(e, t) {
|
|
10
|
+
if (typeof window > "u")
|
|
11
|
+
return t;
|
|
12
|
+
const r = localStorage.getItem(e);
|
|
13
|
+
return r ? JSON.parse(r) : t;
|
|
14
|
+
}
|
|
15
|
+
setValue(e, t) {
|
|
16
|
+
localStorage.setItem(e, JSON.stringify(t)), this.emmiter.emit(e, t);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const x = (o, e) => {
|
|
20
|
+
const t = S(a), [r, i] = f(() => t.getStorageValue(o, e));
|
|
21
|
+
n(() => {
|
|
22
|
+
i(t.getStorageValue(o, e));
|
|
23
|
+
}, [o]);
|
|
24
|
+
const c = (s) => {
|
|
25
|
+
t.setValue(o, s);
|
|
26
|
+
};
|
|
27
|
+
return n(() => {
|
|
28
|
+
const s = t.emmiter.subscribe(o, (u) => {
|
|
29
|
+
i(u);
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
s();
|
|
33
|
+
};
|
|
34
|
+
}, [o]), [r, c];
|
|
35
|
+
}, y = ({ children: o }) => {
|
|
36
|
+
const e = w(new d(new g()));
|
|
37
|
+
return n(() => {
|
|
38
|
+
if (!window || !e.current)
|
|
39
|
+
return;
|
|
40
|
+
const t = (r) => {
|
|
41
|
+
r.key && e.current.emmiter.store[r.key] && r.newValue && e.current.emmiter.emit(r.key, JSON.parse(r.newValue));
|
|
42
|
+
};
|
|
43
|
+
return window.addEventListener("storage", t), () => {
|
|
44
|
+
window.removeEventListener("storage", t);
|
|
45
|
+
};
|
|
46
|
+
}, []), /* @__PURE__ */ m(a.Provider, { value: e.current, children: o });
|
|
11
47
|
};
|
|
12
48
|
export {
|
|
13
|
-
|
|
49
|
+
y as LocalStorageProvider,
|
|
50
|
+
d as LocalStorageService,
|
|
51
|
+
x as useLocalStorage
|
|
14
52
|
};
|
package/dist/bundle.es48.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const f = (
|
|
3
|
-
const
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, [r, n]);
|
|
12
|
-
return [r, l];
|
|
1
|
+
import { useState as r, useCallback as t } from "react";
|
|
2
|
+
const f = (s = !1) => {
|
|
3
|
+
const [o, e] = r(s), a = t(() => {
|
|
4
|
+
e(!0);
|
|
5
|
+
}, []), l = t(() => {
|
|
6
|
+
e(!1);
|
|
7
|
+
}, []), u = t(() => {
|
|
8
|
+
e((n) => !n);
|
|
9
|
+
}, []);
|
|
10
|
+
return [o, a, l, u];
|
|
13
11
|
};
|
|
14
12
|
export {
|
|
15
|
-
f as
|
|
13
|
+
f as useBooleanState
|
|
16
14
|
};
|
package/dist/bundle.es49.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { useRef as i, useCallback as o } from "react";
|
|
2
|
+
const f = (e, s) => {
|
|
3
|
+
const r = i(null), c = i(void 0), n = o(
|
|
4
|
+
(t) => {
|
|
5
|
+
s && t.offsetParent && (t.style.height = "", t.style.height = `${t.scrollHeight}px`, t.scrollHeight !== c.current && e && (e(t), c.current = t.scrollHeight));
|
|
6
|
+
},
|
|
7
|
+
[s, e]
|
|
8
|
+
), l = o(() => {
|
|
9
|
+
const t = r.current;
|
|
10
|
+
t && n(t);
|
|
11
|
+
}, [r, n]);
|
|
12
|
+
return [r, l];
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
f as useResizeTextarea
|
|
16
16
|
};
|