@companix/uikit 0.1.12 → 0.1.14
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/WriteBar/Editor.d.ts +5 -0
- package/dist/WriteBar/utils.d.ts +0 -2
- package/dist/__hooks/use-local-storage.d.ts +13 -1
- package/dist/bundle.es.js +57 -56
- package/dist/bundle.es41.js +27 -19
- package/dist/bundle.es46.js +48 -9
- package/dist/bundle.es66.js +1 -1
- package/dist/bundle.es67.js +2 -2
- package/dist/bundle.es72.js +29 -30
- package/dist/bundle.es76.js +13 -74
- package/dist/bundle.es77.js +71 -45
- package/dist/bundle.es78.js +48 -13
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/WriteBar/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const isTextNode: (node: Node) => node is Text;
|
|
2
|
-
export declare const isElementNode: (node: Node) => node is Element;
|
|
3
1
|
export declare const getNodeTextContent: (node: Node) => string;
|
|
4
2
|
export declare const getEditorSelection: (root: HTMLElement) => {
|
|
5
3
|
range: Range;
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { EventEmmiter } from '@companix/utils-js';
|
|
2
|
+
export declare class LocalStorageService<T> {
|
|
3
|
+
emmiter: EventEmmiter<T>;
|
|
4
|
+
constructor(emmiter: EventEmmiter<T>);
|
|
5
|
+
getStorageValue(token: string, defaultValue: T): any;
|
|
6
|
+
setValue(token: string, value: T): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const useLocalStorage: <T>(token: string, defaultValue: T) => readonly [T, (value: T) => void];
|
|
9
|
+
interface LocalStorageProviderProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const LocalStorageProvider: ({ children }: LocalStorageProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
package/dist/bundle.es.js
CHANGED
|
@@ -6,14 +6,14 @@ import { ButtonGroup as l } from "./bundle.es6.js";
|
|
|
6
6
|
import { Spinner as S } from "./bundle.es7.js";
|
|
7
7
|
import { Scrollable as g } from "./bundle.es8.js";
|
|
8
8
|
import { ImitateScroll as d } from "./bundle.es9.js";
|
|
9
|
-
import { Segments as
|
|
9
|
+
import { Segments as P } from "./bundle.es10.js";
|
|
10
10
|
import { Popover as y } from "./bundle.es11.js";
|
|
11
11
|
import { Tooltip as T } from "./bundle.es12.js";
|
|
12
|
-
import { Select as
|
|
12
|
+
import { Select as v } from "./bundle.es13.js";
|
|
13
13
|
import { SelectTags as A } from "./bundle.es14.js";
|
|
14
14
|
import { Input as R } from "./bundle.es15.js";
|
|
15
|
-
import { OptionItem as
|
|
16
|
-
import { NumberInput as
|
|
15
|
+
import { OptionItem as L } from "./bundle.es16.js";
|
|
16
|
+
import { NumberInput as C } from "./bundle.es17.js";
|
|
17
17
|
import { OptionsList as F } from "./bundle.es18.js";
|
|
18
18
|
import { Checkbox as G } from "./bundle.es19.js";
|
|
19
19
|
import { Switch as E } from "./bundle.es20.js";
|
|
@@ -33,28 +33,28 @@ import { FormGroup as ce } from "./bundle.es33.js";
|
|
|
33
33
|
import { TimePicker as ue } from "./bundle.es34.js";
|
|
34
34
|
import { Icon as De } from "./bundle.es35.js";
|
|
35
35
|
import { ProgressBar as he } from "./bundle.es36.js";
|
|
36
|
-
import { Skeleton as
|
|
36
|
+
import { Skeleton as Be } from "./bundle.es37.js";
|
|
37
37
|
import { Blank as Ie } from "./bundle.es38.js";
|
|
38
38
|
import { ProgressRing as ke } from "./bundle.es39.js";
|
|
39
|
-
import { WriteBar as
|
|
39
|
+
import { WriteBar as be } from "./bundle.es40.js";
|
|
40
40
|
import { Editor as Oe } from "./bundle.es41.js";
|
|
41
|
-
import { DropArea as ze, DropAreaProvider as
|
|
41
|
+
import { DropArea as ze, DropAreaProvider as Le, useDragEnter as we } from "./bundle.es42.js";
|
|
42
42
|
import { Table as Me } from "./bundle.es43.js";
|
|
43
43
|
import { ThemeProvider as Ne, useTheme as Ge } from "./bundle.es44.js";
|
|
44
44
|
import { ColorSchemeScript as Ee, colorSchemeScript as Ye } from "./bundle.es45.js";
|
|
45
|
-
import {
|
|
46
|
-
import { useBooleanState as
|
|
47
|
-
import { useResizeTextarea as
|
|
48
|
-
import { useLoading as
|
|
49
|
-
import { NowContextProvider as
|
|
50
|
-
import { createAlertAgent as
|
|
51
|
-
import { createToaster as
|
|
52
|
-
import { Toast as
|
|
53
|
-
import { DialogShell as
|
|
54
|
-
import { createPopoversRegistry as
|
|
55
|
-
import { createScope as
|
|
56
|
-
import { RemoveListener as
|
|
57
|
-
import { MONDAY as
|
|
45
|
+
import { LocalStorageProvider as qe, useLocalStorage as He } from "./bundle.es46.js";
|
|
46
|
+
import { useBooleanState as Ke } from "./bundle.es47.js";
|
|
47
|
+
import { useResizeTextarea as Ue } from "./bundle.es48.js";
|
|
48
|
+
import { useLoading as Xe } from "./bundle.es49.js";
|
|
49
|
+
import { NowContextProvider as _e, useNow as $e } from "./bundle.es50.js";
|
|
50
|
+
import { createAlertAgent as rr } from "./bundle.es51.js";
|
|
51
|
+
import { createToaster as tr } from "./bundle.es52.js";
|
|
52
|
+
import { Toast as mr } from "./bundle.es53.js";
|
|
53
|
+
import { DialogShell as xr, DrawerShell as fr, createPopupRegistry as ir, usePopup as sr } from "./bundle.es54.js";
|
|
54
|
+
import { createPopoversRegistry as lr } from "./bundle.es55.js";
|
|
55
|
+
import { createScope as Sr, createStaticScope as ur } from "./bundle.es56.js";
|
|
56
|
+
import { RemoveListener as Dr } from "./bundle.es57.js";
|
|
57
|
+
import { MONDAY as hr, addMonths as Pr, createDayDisableChecker as Br, endOfDay as yr, endOfWeek as Ir, isDayMinMaxRestricted as Tr, isSameDate as kr, setMonth as vr, setYear as br, startOfDay as Ar, startOfWeek as Or, subMonths as Rr, useDayDisableCheker as zr } from "./bundle.es58.js";
|
|
58
58
|
export {
|
|
59
59
|
Z as AlertDialog,
|
|
60
60
|
o as Avatar,
|
|
@@ -67,11 +67,11 @@ export {
|
|
|
67
67
|
ie as DateInput,
|
|
68
68
|
xe as DatePicker,
|
|
69
69
|
Q as Dialog,
|
|
70
|
-
|
|
70
|
+
xr as DialogShell,
|
|
71
71
|
J as Drawer,
|
|
72
|
-
|
|
72
|
+
fr as DrawerShell,
|
|
73
73
|
ze as DropArea,
|
|
74
|
-
|
|
74
|
+
Le as DropAreaProvider,
|
|
75
75
|
Oe as Editor,
|
|
76
76
|
ne as FileOverlay,
|
|
77
77
|
ce as FormGroup,
|
|
@@ -79,10 +79,11 @@ export {
|
|
|
79
79
|
d as ImitateScroll,
|
|
80
80
|
R as Input,
|
|
81
81
|
$ as LoadingButton,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
qe as LocalStorageProvider,
|
|
83
|
+
hr as MONDAY,
|
|
84
|
+
_e as NowContextProvider,
|
|
85
|
+
C as NumberInput,
|
|
86
|
+
L as OptionItem,
|
|
86
87
|
F as OptionsList,
|
|
87
88
|
y as Popover,
|
|
88
89
|
V as PopupLayout,
|
|
@@ -90,12 +91,12 @@ export {
|
|
|
90
91
|
ke as ProgressRing,
|
|
91
92
|
j as Radio,
|
|
92
93
|
q as RadioGroup,
|
|
93
|
-
|
|
94
|
+
Dr as RemoveListener,
|
|
94
95
|
g as Scrollable,
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
P as Segments,
|
|
97
|
+
v as Select,
|
|
97
98
|
A as SelectTags,
|
|
98
|
-
|
|
99
|
+
Be as Skeleton,
|
|
99
100
|
S as Spinner,
|
|
100
101
|
E as Switch,
|
|
101
102
|
Me as Table,
|
|
@@ -103,38 +104,38 @@ export {
|
|
|
103
104
|
me as TextArea,
|
|
104
105
|
Ne as ThemeProvider,
|
|
105
106
|
ue as TimePicker,
|
|
106
|
-
|
|
107
|
+
mr as Toast,
|
|
107
108
|
T as Tooltip,
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
be as WriteBar,
|
|
110
|
+
Pr as addMonths,
|
|
110
111
|
p as avatarSizes,
|
|
111
112
|
Ye as colorSchemeScript,
|
|
112
|
-
|
|
113
|
+
rr as createAlertAgent,
|
|
113
114
|
Br as createDayDisableChecker,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
lr as createPopoversRegistry,
|
|
116
|
+
ir as createPopupRegistry,
|
|
117
|
+
Sr as createScope,
|
|
118
|
+
ur as createStaticScope,
|
|
119
|
+
tr as createToaster,
|
|
120
|
+
yr as endOfDay,
|
|
121
|
+
Ir as endOfWeek,
|
|
121
122
|
a as getBadgeIconSizeByImageBaseSize,
|
|
122
123
|
x as getFallbackIconSizeByImageBaseSize,
|
|
123
124
|
f as getInitialsFontSize,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
Tr as isDayMinMaxRestricted,
|
|
126
|
+
kr as isSameDate,
|
|
127
|
+
vr as setMonth,
|
|
127
128
|
br as setYear,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
Ar as startOfDay,
|
|
130
|
+
Or as startOfWeek,
|
|
131
|
+
Rr as subMonths,
|
|
132
|
+
Ke as useBooleanState,
|
|
133
|
+
zr as useDayDisableCheker,
|
|
134
|
+
we as useDragEnter,
|
|
135
|
+
Xe as useLoading,
|
|
136
|
+
He as useLocalStorage,
|
|
137
|
+
$e as useNow,
|
|
138
|
+
sr as usePopup,
|
|
139
|
+
Ue as useResizeTextarea,
|
|
139
140
|
Ge as useTheme
|
|
140
141
|
};
|
package/dist/bundle.es41.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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 {
|
|
4
5
|
element;
|
|
5
6
|
prevText = "";
|
|
6
7
|
prevTextSelection = { from: 0, to: 0 };
|
|
@@ -21,7 +22,7 @@ class C {
|
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
onKeyCombo(e) {
|
|
24
|
-
const t =
|
|
25
|
+
const t = v(e);
|
|
25
26
|
return this.element.addEventListener("keydown", t), this.handlers.keyCombo = e, () => {
|
|
26
27
|
this.handlers.keyCombo = void 0, this.element.removeEventListener("keydown", t);
|
|
27
28
|
};
|
|
@@ -42,13 +43,18 @@ class C {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
setSelection(e) {
|
|
45
|
-
const t =
|
|
46
|
+
const t = l(this.element);
|
|
46
47
|
if (!("selection" in t)) return;
|
|
47
48
|
const n = document.createRange(), s = this.resolveDomPosition(e.from), o = this.resolveDomPosition(e.to);
|
|
48
49
|
n.setStart(s.container, s.offset), n.setEnd(o.container, o.offset), t.selection.removeAllRanges(), t.selection.addRange(n);
|
|
49
50
|
}
|
|
51
|
+
// вставить переданный текст в текущую выделенную область/позицию курсора внутри contenteditable
|
|
50
52
|
insertAtSelection(e, t) {
|
|
51
|
-
t && this.setSelection(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();
|
|
52
58
|
}
|
|
53
59
|
removeFormat() {
|
|
54
60
|
document.execCommand("removeFormat");
|
|
@@ -57,7 +63,7 @@ class C {
|
|
|
57
63
|
const s = !this.isFocused() && !n;
|
|
58
64
|
this.element.innerText = "";
|
|
59
65
|
const o = document.activeElement, i = this.element.inputMode;
|
|
60
|
-
s && (this.element.inputMode = "none"), this.element.focus(), document.execCommand("removeFormat"), t ? document.execCommand("inserthtml", !1, e) : this.insertAtSelection(
|
|
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();
|
|
61
67
|
}
|
|
62
68
|
getText() {
|
|
63
69
|
let e = "";
|
|
@@ -67,7 +73,7 @@ class C {
|
|
|
67
73
|
);
|
|
68
74
|
for (; t.nextNode(); )
|
|
69
75
|
e += h(t.currentNode);
|
|
70
|
-
return
|
|
76
|
+
return a(e);
|
|
71
77
|
}
|
|
72
78
|
getHtml() {
|
|
73
79
|
return this.element.innerHTML;
|
|
@@ -76,18 +82,18 @@ class C {
|
|
|
76
82
|
const e = this.element.innerHTML, t = /<img class="Emoji .+?" src=".+?" alt=".+?">/, n = /alt=".+?"/, s = (o) => {
|
|
77
83
|
const i = o.match(t);
|
|
78
84
|
if (!i?.[0]) return o;
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
82
|
-
return s(o.replace(i[0],
|
|
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));
|
|
83
89
|
};
|
|
84
90
|
return s(e);
|
|
85
91
|
}
|
|
86
92
|
focus(e = !1) {
|
|
87
93
|
if (this.isFocused()) return;
|
|
88
94
|
this.element.focus();
|
|
89
|
-
const t =
|
|
90
|
-
"selection" in t && (t.selection.selectAllChildren(this.element), e ? t.selection.collapseToStart() : t.selection.collapseToEnd(),
|
|
95
|
+
const t = l(this.element);
|
|
96
|
+
"selection" in t && (t.selection.selectAllChildren(this.element), e ? t.selection.collapseToStart() : t.selection.collapseToEnd(), d());
|
|
91
97
|
}
|
|
92
98
|
isFocused() {
|
|
93
99
|
return document.activeElement === this.element;
|
|
@@ -101,7 +107,7 @@ class C {
|
|
|
101
107
|
if (!t) return;
|
|
102
108
|
const n = t.getData("text");
|
|
103
109
|
if (n) {
|
|
104
|
-
this.insertAtSelection(n),
|
|
110
|
+
this.insertAtSelection(n), d();
|
|
105
111
|
return;
|
|
106
112
|
}
|
|
107
113
|
};
|
|
@@ -117,9 +123,9 @@ class C {
|
|
|
117
123
|
n && (t.selectNode(e.target), t.collapse(e.offsetX <= 8), n.removeAllRanges(), n.addRange(t));
|
|
118
124
|
};
|
|
119
125
|
checkContentChanged = () => {
|
|
120
|
-
const e =
|
|
126
|
+
const e = a(this.getText()), t = l(this.element);
|
|
121
127
|
if (!("range" in t)) return;
|
|
122
|
-
const n =
|
|
128
|
+
const n = E(this.element, t.range);
|
|
123
129
|
if (e === this.prevText && n.from === this.prevTextSelection.from && n.to === this.prevTextSelection.to)
|
|
124
130
|
return;
|
|
125
131
|
const s = e === `
|
|
@@ -139,7 +145,7 @@ class C {
|
|
|
139
145
|
for (; t.nextNode(); ) {
|
|
140
146
|
const s = t.currentNode, o = h(s).length;
|
|
141
147
|
if (o >= n)
|
|
142
|
-
return
|
|
148
|
+
return g(s) && s.nodeName === "BR" && (n -= 1), {
|
|
143
149
|
container: s,
|
|
144
150
|
offset: Math.max(n, 0)
|
|
145
151
|
};
|
|
@@ -151,6 +157,8 @@ class C {
|
|
|
151
157
|
};
|
|
152
158
|
}
|
|
153
159
|
}
|
|
160
|
+
const C = (r) => r ? [{ kind: "Text", text: r }] : [];
|
|
154
161
|
export {
|
|
155
|
-
|
|
162
|
+
k as Editor,
|
|
163
|
+
C as toTextChunksLite
|
|
156
164
|
};
|
package/dist/bundle.es46.js
CHANGED
|
@@ -1,13 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
|
4
12
|
const r = localStorage.getItem(e);
|
|
5
|
-
return r ? JSON.parse(r) :
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
localStorage.setItem(e, JSON.stringify(t));
|
|
9
|
-
}
|
|
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 });
|
|
10
47
|
};
|
|
11
48
|
export {
|
|
12
|
-
|
|
49
|
+
y as LocalStorageProvider,
|
|
50
|
+
d as LocalStorageService,
|
|
51
|
+
x as useLocalStorage
|
|
13
52
|
};
|
package/dist/bundle.es66.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs as b, jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import h from "classnames";
|
|
3
3
|
import { attr as e } from "@companix/utils-browser";
|
|
4
4
|
import { forwardRef as x } from "react";
|
|
5
|
-
import { useInputPadding as N } from "./bundle.
|
|
5
|
+
import { useInputPadding as N } from "./bundle.es76.js";
|
|
6
6
|
const v = x(
|
|
7
7
|
({
|
|
8
8
|
required: s,
|
package/dist/bundle.es67.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as D, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { dateToFormat as $, weeks as g, createVoids as p, getDayIndex as b, getFirstDay as u, getMonthMaxDay as k } from "./bundle.es64.js";
|
|
3
|
-
import { CalendarHeader as F } from "./bundle.
|
|
4
|
-
import { useCalendar as j } from "./bundle.
|
|
3
|
+
import { CalendarHeader as F } from "./bundle.es77.js";
|
|
4
|
+
import { useCalendar as j } from "./bundle.es78.js";
|
|
5
5
|
import { attr as m } from "@companix/utils-browser";
|
|
6
6
|
import { isSameDate as f } from "./bundle.es58.js";
|
|
7
7
|
import { useLayoutEffect as I } from "react";
|
package/dist/bundle.es72.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { isTextNode as s, isElementNode as i } from "@companix/utils-browser";
|
|
2
|
+
const a = (t) => s(t) ? t.nodeValue || "" : i(t) && t.nodeName === "IMG" ? t.getAttribute("alt") || "" : i(t) && t.nodeName === "DIV" || i(t) && t.nodeName === "BR" && !(t.parentElement && i(t.parentElement) && t.parentElement.nodeName === "DIV" && t.parentElement.getAttribute("contenteditable") !== "true") ? `
|
|
3
|
+
` : "", m = (t) => {
|
|
4
|
+
const e = document.getSelection();
|
|
5
|
+
if (!e || e.rangeCount === 0)
|
|
5
6
|
return {};
|
|
6
|
-
const n =
|
|
7
|
-
return n &&
|
|
8
|
-
},
|
|
9
|
-
let r = n, o =
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
for (;
|
|
13
|
-
if (
|
|
7
|
+
const n = e.getRangeAt(0);
|
|
8
|
+
return n && t.contains(n.commonAncestorContainer) ? { range: n, selection: e } : {};
|
|
9
|
+
}, l = (t, e, n) => {
|
|
10
|
+
let r = n, o = e;
|
|
11
|
+
t === e && (r = 0, o = t.childNodes[n]);
|
|
12
|
+
const c = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);
|
|
13
|
+
for (; c.nextNode(); ) {
|
|
14
|
+
if (c.currentNode === o)
|
|
14
15
|
return r;
|
|
15
|
-
r += a(
|
|
16
|
+
r += a(c.currentNode).length;
|
|
16
17
|
}
|
|
17
18
|
return r;
|
|
18
|
-
},
|
|
19
|
-
const n =
|
|
19
|
+
}, f = (t, e) => {
|
|
20
|
+
const n = l(t, e.startContainer, e.startOffset);
|
|
20
21
|
return {
|
|
21
22
|
from: n,
|
|
22
|
-
to:
|
|
23
|
+
to: e.collapsed ? n : l(t, e.endContainer, e.endOffset)
|
|
23
24
|
};
|
|
24
|
-
},
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const n =
|
|
25
|
+
}, g = () => {
|
|
26
|
+
const t = window.getSelection();
|
|
27
|
+
if (!t || !t.rangeCount) return;
|
|
28
|
+
const e = t.getRangeAt(0);
|
|
29
|
+
if (e.commonAncestorContainer === document) return;
|
|
30
|
+
const n = e.commonAncestorContainer.parentElement;
|
|
30
31
|
if (!n) return;
|
|
31
|
-
const r = n.getBoundingClientRect(), o =
|
|
32
|
+
const r = n.getBoundingClientRect(), o = e.getBoundingClientRect().bottom - r.bottom;
|
|
32
33
|
o > 0 && n.scrollBy({ top: o });
|
|
33
|
-
}, d = (
|
|
34
|
+
}, d = (t) => t.replace(/ /gi, " ").replace(/<br\s*\/?>/gi, `
|
|
34
35
|
`);
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
m as getEditorSelection,
|
|
37
38
|
a as getNodeTextContent,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
c as isElementNode,
|
|
41
|
-
l as isTextNode,
|
|
39
|
+
l as getPlainTextOffset,
|
|
40
|
+
f as getTextSelectionOffsets,
|
|
42
41
|
d as normalizeEditorText,
|
|
43
|
-
|
|
42
|
+
g as scrollSelectionIntoView
|
|
44
43
|
};
|
package/dist/bundle.es76.js
CHANGED
|
@@ -1,77 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onNextMonth: N,
|
|
14
|
-
onPrevMonth: v
|
|
15
|
-
}) => {
|
|
16
|
-
const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
|
|
17
|
-
(t) => {
|
|
18
|
-
c(_(n, t));
|
|
19
|
-
},
|
|
20
|
-
[c, n]
|
|
21
|
-
), x = u(
|
|
22
|
-
(t) => {
|
|
23
|
-
c(F(n, t));
|
|
24
|
-
},
|
|
25
|
-
[c, n]
|
|
26
|
-
), A = h(() => k(s).map((t) => ({
|
|
27
|
-
...t,
|
|
28
|
-
className: "capitalize",
|
|
29
|
-
disabled: a && a(t.value)
|
|
30
|
-
})), [s, a]), Y = h(() => z(e, 100).map((t) => ({
|
|
31
|
-
...t,
|
|
32
|
-
disabled: m && m(t.value)
|
|
33
|
-
})), [e, m]);
|
|
34
|
-
let l = r === 11 && e === f;
|
|
35
|
-
a && !l && (l = a(
|
|
36
|
-
r === 11 ? 0 : r + 1,
|
|
37
|
-
r === 11 ? Math.min(e + 1, f) : e
|
|
38
|
-
));
|
|
39
|
-
let i = r === 0 && e === g;
|
|
40
|
-
return a && !i && (i = a(
|
|
41
|
-
r === 0 ? 11 : r - 1,
|
|
42
|
-
r === 0 ? Math.max(e - 1, g) : e
|
|
43
|
-
)), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
|
|
44
|
-
!i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
|
|
45
|
-
/* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
|
|
46
|
-
/* @__PURE__ */ o(
|
|
47
|
-
p,
|
|
48
|
-
{
|
|
49
|
-
fill: !0,
|
|
50
|
-
options: Y,
|
|
51
|
-
size: "sm",
|
|
52
|
-
value: e,
|
|
53
|
-
minimalOptions: !0,
|
|
54
|
-
matchTarget: "min-width",
|
|
55
|
-
onChange: (t) => x(t)
|
|
56
|
-
}
|
|
57
|
-
),
|
|
58
|
-
/* @__PURE__ */ o(
|
|
59
|
-
p,
|
|
60
|
-
{
|
|
61
|
-
fill: !0,
|
|
62
|
-
options: A,
|
|
63
|
-
size: "sm",
|
|
64
|
-
className: "capitalize",
|
|
65
|
-
value: r,
|
|
66
|
-
minimalOptions: !0,
|
|
67
|
-
matchTarget: "min-width",
|
|
68
|
-
onChange: (t) => M(t)
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
] }),
|
|
72
|
-
!l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
|
|
73
|
-
] });
|
|
1
|
+
import { useRef as l, useCallback as p } from "react";
|
|
2
|
+
import { useEffectWithLayout as d } from "./bundle.es79.js";
|
|
3
|
+
const g = (r, f) => {
|
|
4
|
+
const c = l(null), i = l(null), o = { Right: c, Left: i }, u = p((t) => {
|
|
5
|
+
if (r.current) {
|
|
6
|
+
const n = r.current.style, e = o[t];
|
|
7
|
+
e.current && e.current.clientWidth ? n[`padding${t}`] !== `${e.current.clientWidth}px` && (n[`padding${t}`] = `${e.current.clientWidth}px`) : n[`padding${t}`] && (n[`padding${t}`] = "");
|
|
8
|
+
}
|
|
9
|
+
}, []);
|
|
10
|
+
return d(() => {
|
|
11
|
+
u("Left"), u("Right");
|
|
12
|
+
}, f), { rightRef: c, leftRef: i };
|
|
74
13
|
};
|
|
75
14
|
export {
|
|
76
|
-
|
|
15
|
+
g as useInputPadding
|
|
77
16
|
};
|
package/dist/bundle.es77.js
CHANGED
|
@@ -1,51 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsxs as d, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as u, useMemo as h } from "react";
|
|
3
|
+
import { Select as p } from "./bundle.es13.js";
|
|
4
|
+
import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es64.js";
|
|
5
|
+
import { Icon as C } from "./bundle.es35.js";
|
|
6
|
+
import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
|
|
7
|
+
import { setMonth as _, setYear as F } from "./bundle.es58.js";
|
|
8
|
+
const y = ({
|
|
9
|
+
viewDate: n,
|
|
10
|
+
onChange: c,
|
|
11
|
+
isMonthDisabled: a,
|
|
12
|
+
isYearDisabled: m,
|
|
13
|
+
onNextMonth: N,
|
|
14
|
+
onPrevMonth: v
|
|
11
15
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
u(N(e, 1));
|
|
16
|
-
}, [e]), D = R({
|
|
17
|
-
disableFuture: c,
|
|
18
|
-
disablePast: r,
|
|
19
|
-
shouldDisableDate: E,
|
|
20
|
-
minDateTime: l,
|
|
21
|
-
maxDateTime: s
|
|
22
|
-
}), k = M(
|
|
23
|
-
(o, t) => {
|
|
24
|
-
const n = /* @__PURE__ */ new Date();
|
|
25
|
-
t = t || e.getFullYear();
|
|
26
|
-
const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
|
|
27
|
-
let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
|
|
28
|
-
return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
|
|
16
|
+
const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
|
|
17
|
+
(t) => {
|
|
18
|
+
c(_(n, t));
|
|
29
19
|
},
|
|
30
|
-
[c,
|
|
31
|
-
),
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
let Y = n > o || o > h;
|
|
35
|
-
return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
|
|
20
|
+
[c, n]
|
|
21
|
+
), x = u(
|
|
22
|
+
(t) => {
|
|
23
|
+
c(F(n, t));
|
|
36
24
|
},
|
|
37
|
-
[c,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
[c, n]
|
|
26
|
+
), A = h(() => k(s).map((t) => ({
|
|
27
|
+
...t,
|
|
28
|
+
className: "capitalize",
|
|
29
|
+
disabled: a && a(t.value)
|
|
30
|
+
})), [s, a]), Y = h(() => z(e, 100).map((t) => ({
|
|
31
|
+
...t,
|
|
32
|
+
disabled: m && m(t.value)
|
|
33
|
+
})), [e, m]);
|
|
34
|
+
let l = r === 11 && e === f;
|
|
35
|
+
a && !l && (l = a(
|
|
36
|
+
r === 11 ? 0 : r + 1,
|
|
37
|
+
r === 11 ? Math.min(e + 1, f) : e
|
|
38
|
+
));
|
|
39
|
+
let i = r === 0 && e === g;
|
|
40
|
+
return a && !i && (i = a(
|
|
41
|
+
r === 0 ? 11 : r - 1,
|
|
42
|
+
r === 0 ? Math.max(e - 1, g) : e
|
|
43
|
+
)), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
|
|
44
|
+
!i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
|
|
45
|
+
/* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
|
|
46
|
+
/* @__PURE__ */ o(
|
|
47
|
+
p,
|
|
48
|
+
{
|
|
49
|
+
fill: !0,
|
|
50
|
+
options: Y,
|
|
51
|
+
size: "sm",
|
|
52
|
+
value: e,
|
|
53
|
+
minimalOptions: !0,
|
|
54
|
+
matchTarget: "min-width",
|
|
55
|
+
onChange: (t) => x(t)
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ o(
|
|
59
|
+
p,
|
|
60
|
+
{
|
|
61
|
+
fill: !0,
|
|
62
|
+
options: A,
|
|
63
|
+
size: "sm",
|
|
64
|
+
className: "capitalize",
|
|
65
|
+
value: r,
|
|
66
|
+
minimalOptions: !0,
|
|
67
|
+
matchTarget: "min-width",
|
|
68
|
+
onChange: (t) => M(t)
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }),
|
|
72
|
+
!l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
|
|
73
|
+
] });
|
|
48
74
|
};
|
|
49
75
|
export {
|
|
50
|
-
|
|
76
|
+
y as CalendarHeader
|
|
51
77
|
};
|
package/dist/bundle.es78.js
CHANGED
|
@@ -1,16 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es58.js";
|
|
2
|
+
import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es64.js";
|
|
3
|
+
import { useState as U, useCallback as M } from "react";
|
|
4
|
+
const X = ({
|
|
5
|
+
value: p,
|
|
6
|
+
disablePast: r,
|
|
7
|
+
disableFuture: c,
|
|
8
|
+
shouldDisableDate: E,
|
|
9
|
+
minDateTime: l,
|
|
10
|
+
maxDateTime: s
|
|
11
|
+
}) => {
|
|
12
|
+
const [e, u] = U(p || /* @__PURE__ */ new Date()), _ = M(() => {
|
|
13
|
+
u(L(e, 1));
|
|
14
|
+
}, [e]), C = M(() => {
|
|
15
|
+
u(N(e, 1));
|
|
16
|
+
}, [e]), D = R({
|
|
17
|
+
disableFuture: c,
|
|
18
|
+
disablePast: r,
|
|
19
|
+
shouldDisableDate: E,
|
|
20
|
+
minDateTime: l,
|
|
21
|
+
maxDateTime: s
|
|
22
|
+
}), k = M(
|
|
23
|
+
(o, t) => {
|
|
24
|
+
const n = /* @__PURE__ */ new Date();
|
|
25
|
+
t = t || e.getFullYear();
|
|
26
|
+
const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
|
|
27
|
+
let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
|
|
28
|
+
return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
|
|
29
|
+
},
|
|
30
|
+
[c, r, e, l, s]
|
|
31
|
+
), v = M(
|
|
32
|
+
(o) => {
|
|
33
|
+
const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
|
|
34
|
+
let Y = n > o || o > h;
|
|
35
|
+
return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
|
|
36
|
+
},
|
|
37
|
+
[c, r, l, s]
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
viewDate: e,
|
|
41
|
+
setViewDate: u,
|
|
42
|
+
setPrevMonth: _,
|
|
43
|
+
setNextMonth: C,
|
|
44
|
+
isDayDisabled: D,
|
|
45
|
+
isMonthDisabled: k,
|
|
46
|
+
isYearDisabled: v
|
|
47
|
+
};
|
|
13
48
|
};
|
|
14
49
|
export {
|
|
15
|
-
|
|
50
|
+
X as useCalendar
|
|
16
51
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export { Table } from './Table';
|
|
|
81
81
|
export type { TableProps } from './Table';
|
|
82
82
|
export { ThemeProvider, useTheme } from './ThemeProvider';
|
|
83
83
|
export { ColorSchemeScript, colorSchemeScript } from './ThemeProvider/script';
|
|
84
|
-
export { useLocalStorage } from './__hooks/use-local-storage';
|
|
84
|
+
export { useLocalStorage, LocalStorageProvider } from './__hooks/use-local-storage';
|
|
85
85
|
export { useBooleanState } from './__hooks/use-boolean-state';
|
|
86
86
|
export { useResizeTextarea } from './__hooks/use-resize';
|
|
87
87
|
export { useLoading } from './__hooks/use-loading';
|