tekivex-ui 2.5.1 → 2.5.3
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/README.md +436 -83
- package/dist/TkxForm-DSMDo2Ol.js +388 -0
- package/dist/TkxForm-DwV_n-eE.cjs +12 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +396 -195
- package/dist/i18n.cjs +1 -0
- package/dist/i18n.js +757 -0
- package/dist/index.cjs +27 -22
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4994 -5089
- package/dist/quantum.cjs +91 -0
- package/dist/quantum.js +2312 -0
- package/dist/realtime.cjs +25 -0
- package/dist/realtime.js +944 -0
- package/dist/security-C369oOWH.cjs +1 -0
- package/dist/security-CzAmaMqa.js +97 -0
- package/dist/src/components/TkxDataGrid.d.ts +9 -1
- package/dist/src/components/TkxDataGrid.d.ts.map +1 -1
- package/dist/src/components/TkxDropdown.d.ts +41 -0
- package/dist/src/components/TkxDropdown.d.ts.map +1 -0
- package/dist/src/components/TkxLiveFeed.d.ts +891 -0
- package/dist/src/components/TkxLiveFeed.d.ts.map +1 -0
- package/dist/src/components/TkxLiveLog.d.ts +892 -0
- package/dist/src/components/TkxLiveLog.d.ts.map +1 -0
- package/dist/src/components/TkxLiveMetrics.d.ts +24 -0
- package/dist/src/components/TkxLiveMetrics.d.ts.map +1 -0
- package/dist/src/components/TkxPlayground.d.ts +15 -0
- package/dist/src/components/TkxPlayground.d.ts.map +1 -0
- package/dist/src/components/TkxQuantumForm.d.ts +20 -0
- package/dist/src/components/TkxQuantumForm.d.ts.map +1 -0
- package/dist/src/components/TkxRealTimeChart.d.ts +27 -0
- package/dist/src/components/TkxRealTimeChart.d.ts.map +1 -0
- package/dist/src/components/TkxTable.d.ts +11 -1
- package/dist/src/components/TkxTable.d.ts.map +1 -1
- package/dist/src/components/TkxThemeBuilder.d.ts +9 -0
- package/dist/src/components/TkxThemeBuilder.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/engine/index.d.ts +2 -0
- package/dist/src/engine/index.d.ts.map +1 -1
- package/dist/src/engine/quantum-ai.d.ts +201 -0
- package/dist/src/engine/quantum-ai.d.ts.map +1 -0
- package/dist/src/engine/tkx.d.ts.map +1 -1
- package/dist/src/headless/index.d.ts +6 -0
- package/dist/src/headless/index.d.ts.map +1 -1
- package/dist/src/headless/useInfiniteQuery.d.ts +35 -0
- package/dist/src/headless/useInfiniteQuery.d.ts.map +1 -0
- package/dist/src/headless/useSSE.d.ts +36 -0
- package/dist/src/headless/useSSE.d.ts.map +1 -0
- package/dist/src/headless/useWebSocket.d.ts +33 -0
- package/dist/src/headless/useWebSocket.d.ts.map +1 -0
- package/dist/src/quantum/index.d.ts +9 -0
- package/dist/src/quantum/index.d.ts.map +1 -0
- package/dist/src/realtime/index.d.ts +9 -0
- package/dist/src/realtime/index.d.ts.map +1 -0
- package/dist/{TkxForm-BWK4LqY3.js → tkx-BJ10JtMv.js} +372 -721
- package/dist/tkx-BeNyC0w7.cjs +4 -0
- package/package.json +16 -1
- package/src/components/TkxDataGrid.tsx +72 -0
- package/src/components/TkxDropdown.tsx +802 -0
- package/src/components/TkxLiveFeed.tsx +329 -0
- package/src/components/TkxLiveLog.tsx +470 -0
- package/src/components/TkxLiveMetrics.tsx +291 -0
- package/src/components/TkxPlayground.tsx +736 -0
- package/src/components/TkxQuantumForm.tsx +592 -0
- package/src/components/TkxRealTimeChart.tsx +381 -0
- package/src/components/TkxTable.tsx +351 -77
- package/src/components/TkxThemeBuilder.tsx +685 -0
- package/src/components/index.ts +4 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/quantum-ai.ts +1045 -0
- package/src/engine/tkx.ts +95 -4
- package/src/headless/index.ts +6 -0
- package/src/headless/useInfiniteQuery.ts +153 -0
- package/src/headless/useSSE.ts +165 -0
- package/src/headless/useWebSocket.ts +229 -0
- package/src/quantum/index.ts +39 -0
- package/src/realtime/index.ts +21 -0
- package/dist/TkxForm-ljQjX7KD.cjs +0 -15
package/dist/headless.js
CHANGED
|
@@ -1,258 +1,459 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { a as ge, d as me, c as he, b as ye, f as Se, u as pe, g as we } from "./TkxForm-DSMDo2Ol.js";
|
|
2
|
+
import { c as be, e as Ee, r as xe, b as Ie, d as Oe, f as De } from "./tkx-BJ10JtMv.js";
|
|
3
|
+
import { f as Te, l as Ae, m as Ce, q as Me, s as ke, t as Fe, F as Le } from "./index-eT_U4qB2.js";
|
|
4
|
+
import { b as Pe, s as Ne } from "./security-CzAmaMqa.js";
|
|
5
|
+
import { useState as S, useCallback as a, useRef as g, useMemo as X, useEffect as z } from "react";
|
|
6
|
+
function Z(e = !1) {
|
|
7
|
+
const [c, t] = S(e), r = a(() => t(!0), []), n = a(() => t(!1), []), o = a(() => t((s) => !s), []);
|
|
8
|
+
return { isOpen: c, open: r, close: n, toggle: o };
|
|
7
9
|
}
|
|
8
|
-
function
|
|
10
|
+
function _({
|
|
9
11
|
count: e,
|
|
10
|
-
initialIndex:
|
|
12
|
+
initialIndex: c = 0,
|
|
11
13
|
orientation: t = "horizontal",
|
|
12
|
-
loop:
|
|
14
|
+
loop: r = !0
|
|
13
15
|
}) {
|
|
14
|
-
const [
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
return
|
|
19
|
-
var
|
|
20
|
-
(
|
|
21
|
-
}),
|
|
16
|
+
const [n, o] = S(c), s = g([]), l = a(
|
|
17
|
+
(i) => {
|
|
18
|
+
o((d) => {
|
|
19
|
+
let p = d + i;
|
|
20
|
+
return r ? p = (p % e + e) % e : p = Math.max(0, Math.min(e - 1, p)), requestAnimationFrame(() => {
|
|
21
|
+
var I;
|
|
22
|
+
(I = s.current[p]) == null || I.focus();
|
|
23
|
+
}), p;
|
|
22
24
|
});
|
|
23
25
|
},
|
|
24
|
-
[e,
|
|
25
|
-
),
|
|
26
|
-
(
|
|
27
|
-
tabIndex:
|
|
28
|
-
"data-focused":
|
|
29
|
-
onFocus: () =>
|
|
30
|
-
onKeyDown: (
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
return (
|
|
35
|
-
})),
|
|
36
|
-
var
|
|
37
|
-
return (
|
|
26
|
+
[e, r]
|
|
27
|
+
), m = a(
|
|
28
|
+
(i) => ({
|
|
29
|
+
tabIndex: i === n ? 0 : -1,
|
|
30
|
+
"data-focused": i === n,
|
|
31
|
+
onFocus: () => o(i),
|
|
32
|
+
onKeyDown: (d) => {
|
|
33
|
+
const p = t === "horizontal" || t === "both", I = t === "vertical" || t === "both";
|
|
34
|
+
p && d.key === "ArrowRight" && (d.preventDefault(), l(1)), p && d.key === "ArrowLeft" && (d.preventDefault(), l(-1)), I && d.key === "ArrowDown" && (d.preventDefault(), l(1)), I && d.key === "ArrowUp" && (d.preventDefault(), l(-1)), d.key === "Home" && (d.preventDefault(), o(0), requestAnimationFrame(() => {
|
|
35
|
+
var w;
|
|
36
|
+
return (w = s.current[0]) == null ? void 0 : w.focus();
|
|
37
|
+
})), d.key === "End" && (d.preventDefault(), o(e - 1), requestAnimationFrame(() => {
|
|
38
|
+
var w;
|
|
39
|
+
return (w = s.current[e - 1]) == null ? void 0 : w.focus();
|
|
38
40
|
}));
|
|
39
41
|
}
|
|
40
42
|
}),
|
|
41
|
-
[
|
|
43
|
+
[n, l, t, e]
|
|
42
44
|
);
|
|
43
|
-
return { focusedIndex:
|
|
45
|
+
return { focusedIndex: n, setFocusedIndex: o, getItemProps: m };
|
|
44
46
|
}
|
|
45
|
-
function
|
|
47
|
+
function ee({
|
|
46
48
|
initialValues: e,
|
|
47
|
-
validate:
|
|
49
|
+
validate: c
|
|
48
50
|
}) {
|
|
49
|
-
const [t,
|
|
50
|
-
|
|
51
|
-
}, []),
|
|
52
|
-
|
|
53
|
-
}, []),
|
|
54
|
-
|
|
55
|
-
}, []),
|
|
56
|
-
if (!
|
|
57
|
-
const
|
|
58
|
-
Object.entries(
|
|
51
|
+
const [t, r] = S({ ...e }), [n, o] = S({}), [s, l] = S({}), m = g(e), i = a((f, y) => {
|
|
52
|
+
r((T) => ({ ...T, [f]: y }));
|
|
53
|
+
}, []), d = a((f) => {
|
|
54
|
+
r((y) => ({ ...y, ...f }));
|
|
55
|
+
}, []), p = a((f) => {
|
|
56
|
+
l((y) => ({ ...y, [f]: !0 }));
|
|
57
|
+
}, []), I = a(() => {
|
|
58
|
+
if (!c) return !0;
|
|
59
|
+
const f = c(t), y = Object.fromEntries(
|
|
60
|
+
Object.entries(f).filter(([, A]) => A != null)
|
|
59
61
|
);
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
Object.keys(t).map((
|
|
62
|
+
o(y);
|
|
63
|
+
const T = Object.fromEntries(
|
|
64
|
+
Object.keys(t).map((A) => [A, !0])
|
|
63
65
|
);
|
|
64
|
-
return
|
|
65
|
-
}, [t,
|
|
66
|
-
|
|
67
|
-
}, []),
|
|
68
|
-
(
|
|
69
|
-
),
|
|
70
|
-
(
|
|
71
|
-
value: t[
|
|
72
|
-
onChange: (
|
|
73
|
-
|
|
66
|
+
return l(T), Object.keys(y).length === 0;
|
|
67
|
+
}, [t, c]), w = a(() => {
|
|
68
|
+
r({ ...m.current }), o({}), l({});
|
|
69
|
+
}, []), h = Object.keys(t).some(
|
|
70
|
+
(f) => t[f] !== m.current[f]
|
|
71
|
+
), b = Object.keys(n).length === 0, u = a(
|
|
72
|
+
(f) => ({
|
|
73
|
+
value: t[f],
|
|
74
|
+
onChange: (y) => {
|
|
75
|
+
i(f, y.target.value);
|
|
74
76
|
},
|
|
75
|
-
onBlur: () =>
|
|
76
|
-
"aria-invalid":
|
|
77
|
-
"aria-describedby":
|
|
77
|
+
onBlur: () => p(f),
|
|
78
|
+
"aria-invalid": s[f] && n[f] ? !0 : void 0,
|
|
79
|
+
"aria-describedby": n[f] ? `${String(f)}-error` : void 0
|
|
78
80
|
}),
|
|
79
|
-
[t,
|
|
81
|
+
[t, n, s, i, p]
|
|
80
82
|
);
|
|
81
|
-
return { values: t, errors:
|
|
83
|
+
return { values: t, errors: n, touched: s, dirty: h, isValid: b, setValue: i, setValues: d, touchField: p, validate: I, reset: w, getFieldProps: u };
|
|
82
84
|
}
|
|
83
|
-
function
|
|
85
|
+
function te({
|
|
84
86
|
items: e,
|
|
85
|
-
initialSelected:
|
|
87
|
+
initialSelected: c = [],
|
|
86
88
|
multiple: t = !0
|
|
87
89
|
}) {
|
|
88
|
-
const [
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
return
|
|
90
|
+
const [r, n] = S(() => new Set(c)), o = a((h) => {
|
|
91
|
+
n((b) => {
|
|
92
|
+
const u = new Set(b);
|
|
93
|
+
return u.has(h) ? u.delete(h) : (t || u.clear(), u.add(h)), u;
|
|
92
94
|
});
|
|
93
|
-
}, [t]),
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
return
|
|
95
|
+
}, [t]), s = a((h) => {
|
|
96
|
+
n((b) => {
|
|
97
|
+
if (b.has(h)) return b;
|
|
98
|
+
const u = t ? new Set(b) : /* @__PURE__ */ new Set();
|
|
99
|
+
return u.add(h), u;
|
|
98
100
|
});
|
|
99
|
-
}, [t]),
|
|
100
|
-
|
|
101
|
-
if (!
|
|
102
|
-
const
|
|
103
|
-
return
|
|
101
|
+
}, [t]), l = a((h) => {
|
|
102
|
+
n((b) => {
|
|
103
|
+
if (!b.has(h)) return b;
|
|
104
|
+
const u = new Set(b);
|
|
105
|
+
return u.delete(h), u;
|
|
104
106
|
});
|
|
105
|
-
}, []),
|
|
106
|
-
t &&
|
|
107
|
-
}, [e, t]),
|
|
108
|
-
|
|
109
|
-
}, [e]),
|
|
107
|
+
}, []), m = a(() => {
|
|
108
|
+
t && n(new Set(e));
|
|
109
|
+
}, [e, t]), i = a(() => n(/* @__PURE__ */ new Set()), []), d = a(() => {
|
|
110
|
+
n((h) => e.every((u) => h.has(u)) ? /* @__PURE__ */ new Set() : new Set(e));
|
|
111
|
+
}, [e]), p = e.length > 0 && e.every((h) => r.has(h)), I = e.some((h) => r.has(h)), w = X(() => Array.from(r), [r]);
|
|
110
112
|
return {
|
|
111
|
-
selected:
|
|
112
|
-
isSelected:
|
|
113
|
-
toggle:
|
|
114
|
-
select:
|
|
115
|
-
deselect:
|
|
116
|
-
selectAll:
|
|
117
|
-
deselectAll:
|
|
118
|
-
toggleAll:
|
|
119
|
-
allSelected:
|
|
120
|
-
someSelected:
|
|
121
|
-
selectedCount:
|
|
122
|
-
selectedArray:
|
|
113
|
+
selected: r,
|
|
114
|
+
isSelected: a((h) => r.has(h), [r]),
|
|
115
|
+
toggle: o,
|
|
116
|
+
select: s,
|
|
117
|
+
deselect: l,
|
|
118
|
+
selectAll: m,
|
|
119
|
+
deselectAll: i,
|
|
120
|
+
toggleAll: d,
|
|
121
|
+
allSelected: p,
|
|
122
|
+
someSelected: I,
|
|
123
|
+
selectedCount: r.size,
|
|
124
|
+
selectedArray: w
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
|
-
function
|
|
126
|
-
const [t,
|
|
127
|
-
return
|
|
128
|
-
const
|
|
129
|
-
return () => clearTimeout(
|
|
130
|
-
}, [e,
|
|
127
|
+
function ne(e, c) {
|
|
128
|
+
const [t, r] = S(e);
|
|
129
|
+
return z(() => {
|
|
130
|
+
const n = setTimeout(() => r(e), c);
|
|
131
|
+
return () => clearTimeout(n);
|
|
132
|
+
}, [e, c]), t;
|
|
131
133
|
}
|
|
132
|
-
function
|
|
133
|
-
const [t,
|
|
134
|
-
return
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
|
|
134
|
+
function re(e, c) {
|
|
135
|
+
const [t, r] = S(e), n = g(Date.now());
|
|
136
|
+
return z(() => {
|
|
137
|
+
const o = Date.now(), s = c - (o - n.current);
|
|
138
|
+
if (s <= 0)
|
|
139
|
+
n.current = o, r(e);
|
|
138
140
|
else {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
return () => clearTimeout(
|
|
141
|
+
const l = setTimeout(() => {
|
|
142
|
+
n.current = Date.now(), r(e);
|
|
143
|
+
}, s);
|
|
144
|
+
return () => clearTimeout(l);
|
|
143
145
|
}
|
|
144
|
-
}, [e,
|
|
146
|
+
}, [e, c]), t;
|
|
145
147
|
}
|
|
146
|
-
function
|
|
148
|
+
function ce({
|
|
147
149
|
value: e,
|
|
148
|
-
onChange:
|
|
150
|
+
onChange: c,
|
|
149
151
|
defaultValue: t
|
|
150
152
|
}) {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
(
|
|
155
|
-
var
|
|
156
|
-
|
|
153
|
+
const r = e !== void 0, [n, o] = S(t), s = g(c);
|
|
154
|
+
s.current = c;
|
|
155
|
+
const l = a(
|
|
156
|
+
(m) => {
|
|
157
|
+
var i;
|
|
158
|
+
r || o(m), (i = s.current) == null || i.call(s, m);
|
|
157
159
|
},
|
|
158
|
-
[
|
|
160
|
+
[r]
|
|
159
161
|
);
|
|
160
|
-
return [
|
|
162
|
+
return [r ? e : n, l];
|
|
161
163
|
}
|
|
162
|
-
function
|
|
163
|
-
const [
|
|
164
|
-
return
|
|
164
|
+
function se(e) {
|
|
165
|
+
const [c, t] = S(() => typeof window > "u" ? !1 : window.matchMedia(e).matches);
|
|
166
|
+
return z(() => {
|
|
165
167
|
if (typeof window > "u") return;
|
|
166
|
-
const
|
|
167
|
-
t(
|
|
168
|
-
const
|
|
169
|
-
return
|
|
170
|
-
}, [e]),
|
|
168
|
+
const r = window.matchMedia(e);
|
|
169
|
+
t(r.matches);
|
|
170
|
+
const n = (o) => t(o.matches);
|
|
171
|
+
return r.addEventListener("change", n), () => r.removeEventListener("change", n);
|
|
172
|
+
}, [e]), c;
|
|
171
173
|
}
|
|
172
|
-
function
|
|
173
|
-
const [t,
|
|
174
|
-
if (typeof window > "u") return
|
|
174
|
+
function oe(e, c) {
|
|
175
|
+
const [t, r] = S(() => {
|
|
176
|
+
if (typeof window > "u") return c;
|
|
175
177
|
try {
|
|
176
|
-
const
|
|
177
|
-
return
|
|
178
|
+
const s = window.localStorage.getItem(e);
|
|
179
|
+
return s !== null ? JSON.parse(s) : c;
|
|
178
180
|
} catch {
|
|
179
|
-
return
|
|
181
|
+
return c;
|
|
180
182
|
}
|
|
181
|
-
}),
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
const
|
|
183
|
+
}), n = a(
|
|
184
|
+
(s) => {
|
|
185
|
+
r((l) => {
|
|
186
|
+
const m = typeof s == "function" ? s(l) : s;
|
|
185
187
|
if (typeof window < "u")
|
|
186
188
|
try {
|
|
187
|
-
window.localStorage.setItem(e, JSON.stringify(
|
|
189
|
+
window.localStorage.setItem(e, JSON.stringify(m));
|
|
188
190
|
} catch {
|
|
189
191
|
}
|
|
190
|
-
return
|
|
192
|
+
return m;
|
|
191
193
|
});
|
|
192
194
|
},
|
|
193
195
|
[e]
|
|
194
|
-
),
|
|
195
|
-
if (
|
|
196
|
+
), o = a(() => {
|
|
197
|
+
if (r(c), typeof window < "u")
|
|
196
198
|
try {
|
|
197
199
|
window.localStorage.removeItem(e);
|
|
198
200
|
} catch {
|
|
199
201
|
}
|
|
200
|
-
}, [e,
|
|
201
|
-
return [t,
|
|
202
|
+
}, [e, c]);
|
|
203
|
+
return [t, n, o];
|
|
202
204
|
}
|
|
203
|
-
function
|
|
205
|
+
function ue({
|
|
204
206
|
threshold: e = 0,
|
|
205
|
-
rootMargin:
|
|
207
|
+
rootMargin: c = "0px",
|
|
206
208
|
root: t = null,
|
|
207
|
-
once:
|
|
209
|
+
once: r = !1
|
|
208
210
|
} = {}) {
|
|
209
|
-
const
|
|
210
|
-
return
|
|
211
|
-
const
|
|
212
|
-
if (!(!
|
|
213
|
-
return
|
|
214
|
-
([
|
|
215
|
-
var
|
|
216
|
-
|
|
211
|
+
const n = g(null), [o, s] = S(null), l = g(null);
|
|
212
|
+
return z(() => {
|
|
213
|
+
const m = n.current;
|
|
214
|
+
if (!(!m || typeof IntersectionObserver > "u"))
|
|
215
|
+
return l.current = new IntersectionObserver(
|
|
216
|
+
([i]) => {
|
|
217
|
+
var d;
|
|
218
|
+
s(i), r && i.isIntersecting && ((d = l.current) == null || d.unobserve(m));
|
|
217
219
|
},
|
|
218
|
-
{ threshold: e, rootMargin:
|
|
219
|
-
),
|
|
220
|
-
var
|
|
221
|
-
return (
|
|
220
|
+
{ threshold: e, rootMargin: c, root: t }
|
|
221
|
+
), l.current.observe(m), () => {
|
|
222
|
+
var i;
|
|
223
|
+
return (i = l.current) == null ? void 0 : i.disconnect();
|
|
222
224
|
};
|
|
223
|
-
}, [e,
|
|
225
|
+
}, [e, c, t, r]), { ref: n, isIntersecting: (o == null ? void 0 : o.isIntersecting) ?? !1, entry: o };
|
|
226
|
+
}
|
|
227
|
+
function ae(e) {
|
|
228
|
+
const {
|
|
229
|
+
url: c,
|
|
230
|
+
protocols: t,
|
|
231
|
+
reconnect: r = !0,
|
|
232
|
+
reconnectDelay: n = 1e3,
|
|
233
|
+
reconnectAttempts: o = 10,
|
|
234
|
+
heartbeatInterval: s = 3e4,
|
|
235
|
+
heartbeatMessage: l = "ping",
|
|
236
|
+
onOpen: m,
|
|
237
|
+
onClose: i,
|
|
238
|
+
onError: d,
|
|
239
|
+
onMessage: p
|
|
240
|
+
} = e, [I, w] = S("disconnected"), [h, b] = S(null), [u, f] = S([]), [y, T] = S(0), [A, V] = S(null), v = g(null), k = g(0), j = g(null), F = g(null), P = g(null), O = g([]), E = g(!0), C = g(!1), x = g(m), L = g(i), N = g(d), W = g(p);
|
|
241
|
+
x.current = m, L.current = i, N.current = d, W.current = p;
|
|
242
|
+
const q = a(() => {
|
|
243
|
+
j.current && (clearTimeout(j.current), j.current = null), F.current && (clearInterval(F.current), F.current = null);
|
|
244
|
+
}, []), U = a((R) => {
|
|
245
|
+
for (; O.current.length > 0; ) {
|
|
246
|
+
const M = O.current.shift();
|
|
247
|
+
M !== void 0 && R.send(typeof M == "string" ? M : JSON.stringify(M));
|
|
248
|
+
}
|
|
249
|
+
}, []), Q = a(() => {
|
|
250
|
+
if (v.current && v.current.readyState === WebSocket.OPEN) return;
|
|
251
|
+
C.current = !1, q(), E.current && w("connecting");
|
|
252
|
+
const R = new WebSocket(c, t);
|
|
253
|
+
v.current = R, R.onopen = (M) => {
|
|
254
|
+
var D;
|
|
255
|
+
E.current && (w("connected"), k.current = 0, T(0), (D = x.current) == null || D.call(x, M), U(R), F.current = setInterval(() => {
|
|
256
|
+
if (R.readyState === WebSocket.OPEN) {
|
|
257
|
+
P.current = Date.now();
|
|
258
|
+
try {
|
|
259
|
+
R.send(JSON.stringify({ type: "ping", t: P.current }));
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, s));
|
|
264
|
+
}, R.onmessage = (M) => {
|
|
265
|
+
var H;
|
|
266
|
+
if (!E.current) return;
|
|
267
|
+
let D;
|
|
268
|
+
try {
|
|
269
|
+
D = JSON.parse(M.data);
|
|
270
|
+
} catch {
|
|
271
|
+
D = M.data;
|
|
272
|
+
}
|
|
273
|
+
const J = D;
|
|
274
|
+
if (J && typeof J == "object" && J.type === "pong" && typeof J.t == "number") {
|
|
275
|
+
V(Date.now() - J.t);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (D === l && P.current !== null) {
|
|
279
|
+
V(Date.now() - P.current), P.current = null;
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
b(D), f((G) => {
|
|
283
|
+
const K = [...G, D];
|
|
284
|
+
return K.length > 100 ? K.slice(K.length - 100) : K;
|
|
285
|
+
}), (H = W.current) == null || H.call(W, D);
|
|
286
|
+
}, R.onerror = (M) => {
|
|
287
|
+
var D;
|
|
288
|
+
E.current && (w("error"), (D = N.current) == null || D.call(N, M));
|
|
289
|
+
}, R.onclose = (M) => {
|
|
290
|
+
var D;
|
|
291
|
+
if (E.current && (q(), w("disconnected"), (D = L.current) == null || D.call(L, M), !C.current && r && k.current < o)) {
|
|
292
|
+
const J = k.current, H = n * Math.pow(1.5, J);
|
|
293
|
+
k.current += 1, T(k.current), j.current = setTimeout(() => {
|
|
294
|
+
E.current && Q();
|
|
295
|
+
}, H);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}, [c, t, r, n, o, s, l, q, U]), B = a(() => {
|
|
299
|
+
C.current = !0, q(), v.current && (v.current.close(), v.current = null), E.current && w("disconnected");
|
|
300
|
+
}, [q]), $ = a((R) => {
|
|
301
|
+
v.current && v.current.readyState === WebSocket.OPEN ? v.current.send(typeof R == "string" ? R : JSON.stringify(R)) : O.current.push(R);
|
|
302
|
+
}, []);
|
|
303
|
+
return z(() => (E.current = !0, Q(), () => {
|
|
304
|
+
E.current = !1, C.current = !0, q(), v.current && (v.current.close(), v.current = null);
|
|
305
|
+
}), []), { status: I, lastMessage: h, messages: u, send: $, connect: Q, disconnect: B, reconnectCount: y, latency: A };
|
|
306
|
+
}
|
|
307
|
+
function le(e) {
|
|
308
|
+
const {
|
|
309
|
+
url: c,
|
|
310
|
+
events: t = ["message"],
|
|
311
|
+
withCredentials: r = !1,
|
|
312
|
+
reconnect: n = !0,
|
|
313
|
+
reconnectDelay: o = 3e3,
|
|
314
|
+
onOpen: s,
|
|
315
|
+
onError: l
|
|
316
|
+
} = e, [m, i] = S("connecting"), [d, p] = S(null), [I, w] = S([]), [h, b] = S(0), u = g(null), f = g(null), y = g(!0), T = g(!1), A = g(s), V = g(l);
|
|
317
|
+
A.current = s, V.current = l;
|
|
318
|
+
const v = a(() => {
|
|
319
|
+
f.current && (clearTimeout(f.current), f.current = null);
|
|
320
|
+
}, []), k = a(() => {
|
|
321
|
+
if (typeof EventSource > "u") {
|
|
322
|
+
y.current && i("error");
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
T.current = !1, v(), u.current && (u.current.close(), u.current = null), y.current && i("connecting");
|
|
326
|
+
const F = new EventSource(c, { withCredentials: r });
|
|
327
|
+
u.current = F, F.onopen = () => {
|
|
328
|
+
var O;
|
|
329
|
+
y.current && (i("connected"), (O = A.current) == null || O.call(A));
|
|
330
|
+
}, F.onerror = (O) => {
|
|
331
|
+
var E;
|
|
332
|
+
y.current && (i("error"), (E = V.current) == null || E.call(V, O), !T.current && n && (v(), f.current = setTimeout(() => {
|
|
333
|
+
y.current && k();
|
|
334
|
+
}, o)));
|
|
335
|
+
};
|
|
336
|
+
const P = (O) => (E) => {
|
|
337
|
+
if (!y.current) return;
|
|
338
|
+
let C;
|
|
339
|
+
try {
|
|
340
|
+
C = JSON.parse(E.data);
|
|
341
|
+
} catch {
|
|
342
|
+
C = E.data;
|
|
343
|
+
}
|
|
344
|
+
const x = {
|
|
345
|
+
type: O,
|
|
346
|
+
data: C,
|
|
347
|
+
timestamp: Date.now(),
|
|
348
|
+
...E.lastEventId ? { id: E.lastEventId } : {}
|
|
349
|
+
};
|
|
350
|
+
p({ type: x.type, data: x.data, id: x.id }), w((L) => {
|
|
351
|
+
const N = [...L, x];
|
|
352
|
+
return N.length > 200 ? N.slice(N.length - 200) : N;
|
|
353
|
+
}), b((L) => L + 1);
|
|
354
|
+
};
|
|
355
|
+
for (const O of t)
|
|
356
|
+
F.addEventListener(O, P(O));
|
|
357
|
+
}, [c, r, n, o, v]), j = a(() => {
|
|
358
|
+
T.current = !0, v(), u.current && (u.current.close(), u.current = null), y.current && i("closed");
|
|
359
|
+
}, [v]);
|
|
360
|
+
return z(() => (y.current = !0, k(), () => {
|
|
361
|
+
y.current = !1, T.current = !0, v(), u.current && (u.current.close(), u.current = null);
|
|
362
|
+
}), []), {
|
|
363
|
+
status: m,
|
|
364
|
+
lastEvent: d,
|
|
365
|
+
events: I,
|
|
366
|
+
connect: k,
|
|
367
|
+
disconnect: j,
|
|
368
|
+
eventCount: h
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function ie(e) {
|
|
372
|
+
const {
|
|
373
|
+
queryFn: c,
|
|
374
|
+
initialCursor: t = null,
|
|
375
|
+
enabled: r = !0,
|
|
376
|
+
dedupKey: n
|
|
377
|
+
} = e, [o, s] = S([]), [l, m] = S("idle"), [i, d] = S(null), [p, I] = S(!1), [w, h] = S(0), b = g(t ?? null), u = g(!1), f = g(!0), y = g(void 0), T = g(c);
|
|
378
|
+
T.current = c;
|
|
379
|
+
const A = a(
|
|
380
|
+
async (P, O, E) => {
|
|
381
|
+
if (u.current || n !== void 0 && n === y.current) return;
|
|
382
|
+
u.current = !0;
|
|
383
|
+
let C = !1;
|
|
384
|
+
f.current && (m(E ? "loading" : "fetching-more"), d(null));
|
|
385
|
+
try {
|
|
386
|
+
const x = await T.current(P, O);
|
|
387
|
+
if (C || !f.current) return;
|
|
388
|
+
n !== void 0 && (y.current = n), b.current = x.nextCursor, s((L) => E ? [x.data] : [...L, x.data]), I(x.hasMore), h(O), m("success");
|
|
389
|
+
} catch (x) {
|
|
390
|
+
if (C || !f.current) return;
|
|
391
|
+
d(x instanceof Error ? x : new Error(String(x))), m("error");
|
|
392
|
+
} finally {
|
|
393
|
+
C || (u.current = !1);
|
|
394
|
+
}
|
|
395
|
+
return () => {
|
|
396
|
+
C = !0;
|
|
397
|
+
};
|
|
398
|
+
},
|
|
399
|
+
// dedupKey intentionally included to allow re-checking on each call
|
|
400
|
+
[n]
|
|
401
|
+
), V = a(() => {
|
|
402
|
+
!p || u.current || A(b.current, w + 1, !1);
|
|
403
|
+
}, [p, w, A]), v = a(() => {
|
|
404
|
+
u.current = !1, y.current = void 0, b.current = t ?? null, s([]), m("idle"), d(null), I(!1), h(0);
|
|
405
|
+
}, [t]);
|
|
406
|
+
z(() => (f.current = !0, r && A(t ?? null, 0, !0), () => {
|
|
407
|
+
f.current = !1;
|
|
408
|
+
}), [r]);
|
|
409
|
+
const k = o.flat(), j = l === "fetching-more", F = k.length;
|
|
410
|
+
return {
|
|
411
|
+
data: k,
|
|
412
|
+
pages: o,
|
|
413
|
+
status: l,
|
|
414
|
+
error: i,
|
|
415
|
+
hasMore: p,
|
|
416
|
+
isFetchingMore: j,
|
|
417
|
+
fetchMore: V,
|
|
418
|
+
reset: v,
|
|
419
|
+
pageIndex: w,
|
|
420
|
+
totalLoaded: F
|
|
421
|
+
};
|
|
224
422
|
}
|
|
225
423
|
export {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
424
|
+
Te as contrastRatio,
|
|
425
|
+
Ae as cssVar,
|
|
426
|
+
be as cx,
|
|
427
|
+
Ee as extractAtomicCSS,
|
|
428
|
+
Ce as extractCSS,
|
|
429
|
+
Me as injectStyles,
|
|
430
|
+
ke as meetsAA,
|
|
431
|
+
Fe as meetsAAA,
|
|
432
|
+
xe as resetAtomicCSS,
|
|
433
|
+
Le as resetStyles,
|
|
434
|
+
Pe as sanitizeProps,
|
|
435
|
+
Ne as sanitizeString,
|
|
436
|
+
Ie as tkxListPlugins,
|
|
437
|
+
Oe as tkxPlugin,
|
|
438
|
+
De as tkxRemovePlugin,
|
|
439
|
+
ge as useAnnounce,
|
|
440
|
+
me as useClickOutside,
|
|
441
|
+
ce as useControllable,
|
|
442
|
+
ne as useDebounce,
|
|
443
|
+
Z as useDisclosure,
|
|
444
|
+
he as useEscapeKey,
|
|
445
|
+
ye as useFocusTrap,
|
|
446
|
+
ee as useFormState,
|
|
447
|
+
Se as useHighContrast,
|
|
448
|
+
ie as useInfiniteQuery,
|
|
449
|
+
ue as useIntersectionObserver,
|
|
450
|
+
te as useListSelection,
|
|
451
|
+
oe as useLocalStorage,
|
|
452
|
+
se as useMediaQuery,
|
|
453
|
+
pe as useReducedMotion,
|
|
454
|
+
_ as useRovingTabIndex,
|
|
455
|
+
le as useSSE,
|
|
456
|
+
re as useThrottle,
|
|
457
|
+
we as useTkxForm,
|
|
458
|
+
ae as useWebSocket
|
|
258
459
|
};
|