@companix/uikit 0.1.9 → 0.1.11

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 (61) hide show
  1. package/dist/WriteBar/Editor.d.ts +33 -0
  2. package/dist/WriteBar/Input.d.ts +14 -0
  3. package/dist/WriteBar/WireBar.scss +44 -46
  4. package/dist/WriteBar/index.d.ts +6 -6
  5. package/dist/WriteBar/utils.d.ts +14 -0
  6. package/dist/bundle.es.js +59 -57
  7. package/dist/bundle.es10.js +1 -1
  8. package/dist/bundle.es13.js +4 -4
  9. package/dist/bundle.es14.js +3 -3
  10. package/dist/bundle.es15.js +2 -2
  11. package/dist/bundle.es17.js +1 -1
  12. package/dist/bundle.es24.js +1 -1
  13. package/dist/bundle.es25.js +1 -1
  14. package/dist/bundle.es26.js +1 -1
  15. package/dist/bundle.es27.js +1 -1
  16. package/dist/bundle.es29.js +1 -1
  17. package/dist/bundle.es30.js +4 -4
  18. package/dist/bundle.es31.js +2 -2
  19. package/dist/bundle.es32.js +34 -23
  20. package/dist/bundle.es34.js +2 -2
  21. package/dist/bundle.es40.js +48 -92
  22. package/dist/bundle.es41.js +154 -79
  23. package/dist/bundle.es42.js +81 -7
  24. package/dist/bundle.es43.js +7 -35
  25. package/dist/bundle.es44.js +33 -20
  26. package/dist/bundle.es45.js +21 -10
  27. package/dist/bundle.es46.js +10 -11
  28. package/dist/bundle.es47.js +11 -13
  29. package/dist/bundle.es48.js +13 -13
  30. package/dist/bundle.es49.js +13 -30
  31. package/dist/bundle.es50.js +29 -25
  32. package/dist/bundle.es51.js +17 -29
  33. package/dist/bundle.es52.js +36 -48
  34. package/dist/bundle.es53.js +49 -50
  35. package/dist/bundle.es54.js +51 -8
  36. package/dist/bundle.es55.js +8 -26
  37. package/dist/bundle.es56.js +27 -5
  38. package/dist/bundle.es57.js +5 -66
  39. package/dist/bundle.es58.js +66 -23
  40. package/dist/bundle.es59.js +22 -23
  41. package/dist/bundle.es60.js +24 -88
  42. package/dist/bundle.es61.js +88 -18
  43. package/dist/bundle.es62.js +17 -92
  44. package/dist/bundle.es63.js +92 -73
  45. package/dist/bundle.es64.js +73 -23
  46. package/dist/bundle.es65.js +20 -35
  47. package/dist/bundle.es66.js +37 -68
  48. package/dist/bundle.es67.js +68 -9
  49. package/dist/bundle.es68.js +10 -42
  50. package/dist/bundle.es69.js +42 -14
  51. package/dist/bundle.es70.js +32 -31
  52. package/dist/bundle.es71.js +41 -69
  53. package/dist/bundle.es72.js +14 -74
  54. package/dist/bundle.es73.js +30 -47
  55. package/dist/bundle.es74.js +69 -13
  56. package/dist/bundle.es75.js +74 -13
  57. package/dist/bundle.es76.js +51 -0
  58. package/dist/bundle.es77.js +16 -0
  59. package/dist/bundle.es78.js +16 -0
  60. package/dist/index.d.ts +1 -0
  61. package/package.json +1 -1
@@ -1,103 +1,59 @@
1
- import { jsxs as c, jsx as e } from "react/jsx-runtime";
2
- import d from "classnames";
3
- import { Spinner as F } from "./bundle.es7.js";
4
- import { Icon as G } from "./bundle.es35.js";
5
- import { useResizeTextarea as H } from "./bundle.es47.js";
6
- import { callMultiple as J, attr as K } from "@companix/utils-browser";
7
- import { mergeRefs as L } from "react-merge-refs";
8
- import { useEffect as O } from "react";
9
- const P = ({
10
- // WriteBarProps
11
- before: r,
12
- inlineAfter: s,
13
- after: i,
14
- onHeightChange: t,
15
- shadow: m = !1,
16
- containerRef: a,
17
- attachbar: f,
18
- contentClassName: l,
19
- // textarea props
20
- textareaRef: p,
21
- autoComplete: h,
22
- cols: x,
23
- dirName: Q,
24
- disabled: b,
25
- maxLength: u,
26
- minLength: w,
27
- name: N,
28
- placeholder: z,
29
- readOnly: v,
30
- required: R,
31
- value: n,
32
- wrap: g,
33
- rows: j,
34
- onChange: B,
35
- onFocus: I,
36
- onBlur: T,
37
- id: A,
38
- inputMode: C,
39
- defaultValue: E,
40
- autoFocus: M,
41
- tabIndex: S,
42
- spellCheck: W,
43
- className: k,
44
- onKeyDown: q,
45
- ...y
46
- }) => {
47
- const [D, o] = H(t, !0);
48
- return O(o, [o, n]), /* @__PURE__ */ c("div", { ref: a, ...y, className: d("write-bar", k), children: [
49
- f,
50
- /* @__PURE__ */ c("div", { className: d("write-bar-content", l), children: [
51
- r && /* @__PURE__ */ e("div", { className: "write-bar-before", children: r }),
52
- /* @__PURE__ */ e("div", { className: "write-bar-form", children: /* @__PURE__ */ e(
53
- "textarea",
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,
54
26
  {
55
- ref: L([p, D]),
56
- id: A,
57
- onChange: J(B, o),
58
- autoComplete: h,
59
- cols: x,
60
- disabled: b,
61
- maxLength: u,
62
- minLength: w,
63
- name: N,
64
- placeholder: z,
65
- readOnly: v,
66
- required: R,
67
- value: n,
68
- wrap: g,
69
- rows: j,
70
- onFocus: I,
71
- onBlur: T,
72
- inputMode: C,
73
- defaultValue: E,
74
- autoFocus: M,
75
- tabIndex: S,
76
- spellCheck: W,
77
- onKeyDown: q
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
78
34
  }
79
- ) }),
80
- i && /* @__PURE__ */ e("div", { className: "write-bar-after", children: i })
35
+ ),
36
+ t && /* @__PURE__ */ r("div", { className: "write-bar-after", children: t })
81
37
  ] })
82
38
  ] });
83
39
  };
84
- P.IconButton = ({
85
- Component: r = "button",
86
- icon: s,
87
- mode: i,
88
- onClick: t,
89
- isLoading: m,
90
- isHidden: a
91
- }) => /* @__PURE__ */ e(
92
- r,
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,
93
49
  {
94
- onClick: t,
50
+ onClick: i,
95
51
  className: "write-bar-icon",
96
- "data-mode": i,
97
- "data-hidden": K(a),
98
- children: m ? /* @__PURE__ */ e(F, { size: 18 }) : /* @__PURE__ */ e(G, { icon: s, size: "xxs" })
52
+ "data-mode": t,
53
+ "data-hidden": N(n),
54
+ children: o ? /* @__PURE__ */ r(b, { size: 18 }) : /* @__PURE__ */ r(h, { icon: e, size: "xxs" })
99
55
  }
100
56
  );
101
57
  export {
102
- P as WriteBar
58
+ w as WriteBar
103
59
  };
@@ -1,83 +1,158 @@
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 { getEditorSelection as r, normalizeEditorText as l, getNodeTextContent as h, scrollSelectionIntoView as c, getTextSelectionOffsets as m, isElementNode as u } from "./bundle.es71.js";
2
+ class v {
3
+ element;
4
+ prevText = "";
5
+ prevTextSelection = { from: 0, to: 0 };
6
+ handlers = {
7
+ contentChange: /* @__PURE__ */ new Set()
8
+ };
9
+ constructor(e) {
10
+ if (e.contentEditable !== "true")
11
+ throw new Error("Элемент эдитора должен быть contentEditable");
12
+ e.tagName !== "SPAN" && console.warn("Используйте элемент span"), this.element = e, this.element.translate = !1;
13
+ }
14
+ getElement() {
15
+ return this.element;
16
+ }
17
+ onPaste(e) {
18
+ return this.handlers.paste || this.element.addEventListener("paste", this.handlePaste), this.handlers.paste = e, () => {
19
+ this.handlers.paste = void 0, this.element.removeEventListener("paste", this.handlePaste);
20
+ };
21
+ }
22
+ // onKeyCombo(handler: (combo: string, event: KeyboardEvent) => void): () => void {
23
+ // const listener = onElementKeyDownFactory(handler) as EventListener
24
+ // this.element.addEventListener('keydown', listener)
25
+ // this.handlers.keyCombo = handler
26
+ // return () => {
27
+ // this.handlers.keyCombo = undefined
28
+ // this.element.removeEventListener('keydown', listener)
29
+ // }
30
+ // }
31
+ onFocusChange(e) {
32
+ return this.handlers.focusChange || (this.element.addEventListener("focus", this.handleFocus), this.element.addEventListener("blur", this.handleBlur)), this.handlers.focusChange = e, () => {
33
+ this.handlers.focusChange = void 0, this.element.removeEventListener("focus", this.handleFocus), this.element.removeEventListener("blur", this.handleBlur);
34
+ };
35
+ }
36
+ onContentChange(e) {
37
+ return this.handlers.contentChange.size === 0 && (this.element.addEventListener("keyup", this.checkContentChanged), document.addEventListener("selectionchange", this.checkContentChanged)), this.handlers.contentChange.add(e), () => {
38
+ this.handlers.contentChange.delete(e), this.handlers.contentChange.size === 0 && (this.element.removeEventListener("keyup", this.checkContentChanged), document.removeEventListener("selectionchange", this.checkContentChanged));
39
+ };
40
+ }
41
+ onMouseDown() {
42
+ return this.element.addEventListener("mousedown", this.handleMouseDown), () => {
43
+ this.element.removeEventListener("mousedown", this.handleMouseDown);
44
+ };
45
+ }
46
+ setSelection(e) {
47
+ const t = r(this.element);
48
+ if (!("selection" in t)) return;
49
+ const n = document.createRange(), s = this.resolveDomPosition(e.from), o = this.resolveDomPosition(e.to);
50
+ n.setStart(s.container, s.offset), n.setEnd(o.container, o.offset), t.selection.removeAllRanges(), t.selection.addRange(n);
51
+ }
52
+ insertAtSelection(e, t) {
53
+ t && this.setSelection(t), this.checkContentChanged();
54
+ }
55
+ removeFormat() {
56
+ document.execCommand("removeFormat");
57
+ }
58
+ resetText(e = "", t = !1, n = !0) {
59
+ const s = !this.isFocused() && !n;
60
+ this.element.innerText = "";
61
+ const o = document.activeElement, i = this.element.inputMode;
62
+ s && (this.element.inputMode = "none"), this.element.focus(), document.execCommand("removeFormat"), t ? document.execCommand("inserthtml", !1, e) : this.insertAtSelection(l(e)), s && (this.element.blur(), this.element.inputMode = i, o?.focus?.()), this.checkContentChanged();
63
+ }
64
+ getText() {
65
+ let e = "";
66
+ const t = document.createTreeWalker(
67
+ this.element,
68
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
69
+ );
70
+ for (; t.nextNode(); )
71
+ e += h(t.currentNode);
72
+ return l(e);
73
+ }
74
+ getHtml() {
75
+ return this.element.innerHTML;
76
+ }
77
+ getHtmlWithEmojisAsText() {
78
+ const e = this.element.innerHTML, t = /<img class="Emoji .+?" src=".+?" alt=".+?">/, n = /alt=".+?"/, s = (o) => {
79
+ const i = o.match(t);
80
+ if (!i?.[0]) return o;
81
+ const a = i[0].match(n);
82
+ if (!a?.[0]) return o;
83
+ const d = a[0].replace("alt=", "").replaceAll('"', "");
84
+ return s(o.replace(i[0], d));
85
+ };
86
+ return s(e);
87
+ }
88
+ focus(e = !1) {
89
+ if (this.isFocused()) return;
90
+ this.element.focus();
91
+ const t = r(this.element);
92
+ "selection" in t && (t.selection.selectAllChildren(this.element), e ? t.selection.collapseToStart() : t.selection.collapseToEnd(), c());
93
+ }
94
+ isFocused() {
95
+ return document.activeElement === this.element;
96
+ }
97
+ setDisabled(e) {
98
+ this.element.contentEditable = e ? "false" : "true";
99
+ }
100
+ handlePaste = async (e) => {
101
+ e.preventDefault();
102
+ const { clipboardData: t } = e;
103
+ if (!t) return;
104
+ const n = t.getData("text");
105
+ if (n) {
106
+ this.insertAtSelection(n), c();
107
+ return;
25
108
  }
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 })
109
+ };
110
+ handleFocus = () => {
111
+ this.handlers.focusChange?.(!0);
112
+ };
113
+ handleBlur = () => {
114
+ this.handlers.focusChange?.(!1);
115
+ };
116
+ handleMouseDown = (e) => {
117
+ if (!(e.target instanceof HTMLImageElement)) return;
118
+ const t = new Range(), n = window.getSelection();
119
+ n && (t.selectNode(e.target), t.collapse(e.offsetX <= 8), n.removeAllRanges(), n.addRange(t));
120
+ };
121
+ checkContentChanged = () => {
122
+ const e = l(this.getText()), t = r(this.element);
123
+ if (!("range" in t)) return;
124
+ const n = m(this.element, t.range);
125
+ if (e === this.prevText && n.from === this.prevTextSelection.from && n.to === this.prevTextSelection.to)
126
+ return;
127
+ const s = e === `
128
+ ` && this.prevText.length > 0;
129
+ if (this.prevText = e, this.prevTextSelection = n, s) {
130
+ this.resetText("");
131
+ return;
59
132
  }
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
- };
133
+ this.handlers.contentChange.forEach((o) => o(e, n));
134
+ };
135
+ resolveDomPosition(e) {
136
+ const t = document.createTreeWalker(
137
+ this.element,
138
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
139
+ );
140
+ let n = e;
141
+ for (; t.nextNode(); ) {
142
+ const s = t.currentNode, o = h(s).length;
143
+ if (o >= n)
144
+ return u(s) && s.nodeName === "BR" && (n -= 1), {
145
+ container: s,
146
+ offset: Math.max(n, 0)
147
+ };
148
+ n -= o;
149
+ }
150
+ return {
151
+ container: this.element,
152
+ offset: this.element.childNodes.length
153
+ };
154
+ }
155
+ }
79
156
  export {
80
- C as DropArea,
81
- H as DropAreaProvider,
82
- T as useDragEnter
157
+ v as Editor
83
158
  };
@@ -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,37 +1,9 @@
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.es69.js";
4
- const i = f({
5
- setColorScheme: () => {
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
- p as ThemeProvider,
36
- y as useTheme
8
+ b as Table
37
9
  };
@@ -1,24 +1,37 @@
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
- }
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.es72.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
- i as ColorSchemeScript,
23
- a as colorSchemeScript
35
+ p as ThemeProvider,
36
+ y as useTheme
24
37
  };
@@ -1,13 +1,24 @@
1
- import { useState as s, useEffect as c } from "react";
2
- const l = (e, a) => {
3
- const [t, o] = s(() => {
4
- const r = localStorage.getItem(e);
5
- return r ? JSON.parse(r) : a;
6
- });
7
- return c(() => {
8
- localStorage.setItem(e, JSON.stringify(t));
9
- }, [t]), [t, o];
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
+ }
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 {
19
+ }
10
20
  };
11
21
  export {
12
- l as useLocalStorage
22
+ i as ColorSchemeScript,
23
+ a as colorSchemeScript
13
24
  };
@@ -1,14 +1,13 @@
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];
1
+ import { useState as s, useEffect as c } from "react";
2
+ const l = (e, a) => {
3
+ const [t, o] = s(() => {
4
+ const r = localStorage.getItem(e);
5
+ return r ? JSON.parse(r) : a;
6
+ });
7
+ return c(() => {
8
+ localStorage.setItem(e, JSON.stringify(t));
9
+ }, [t]), [t, o];
11
10
  };
12
11
  export {
13
- f as useBooleanState
12
+ l as useLocalStorage
14
13
  };