@rotorjs/react 0.4.1 → 0.5.0
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/DashboardLayoutContext.d.ts +3 -2
- package/dist/DashboardTileContainer.d.ts +6 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +119 -192
- package/package.json +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ComponentType
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { DashboardTileContainerProps } from './DashboardTileContainer';
|
|
2
3
|
export type DashboardLayoutContextValue = {
|
|
3
4
|
type: string;
|
|
4
|
-
tileContainer?: ComponentType<
|
|
5
|
+
tileContainer?: ComponentType<DashboardTileContainerProps>;
|
|
5
6
|
};
|
|
6
7
|
export declare const DashboardLayoutContext: import('react').Context<DashboardLayoutContextValue>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DashboardLayoutConfig } from '@rotorjs/dashboards';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
export type DashboardTileContainerProps = PropsWithChildren<{
|
|
4
|
+
layout?: DashboardLayoutConfig;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function DashboardTileContainer({ layout, children, }: DashboardTileContainerProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
package/dist/main.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './DashboardError';
|
|
|
4
4
|
export * from './DashboardLayout';
|
|
5
5
|
export * from './DashboardLayoutContext';
|
|
6
6
|
export * from './DashboardLayoutError';
|
|
7
|
+
export * from './DashboardTileContainer';
|
|
7
8
|
export * from './DashboardTileError';
|
|
8
9
|
export * from './DashboardTiles';
|
|
9
10
|
export * from './getKey';
|
package/dist/main.js
CHANGED
|
@@ -1,259 +1,186 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
get: ((e) => t[e]).bind(null, s),
|
|
7
|
-
enumerable: !(r = d(t, s)) || r.enumerable
|
|
8
|
-
});
|
|
9
|
-
return e;
|
|
10
|
-
}, _ = (e, t, n) => (n = e == null ? {} : l(p(e)), g(t || !e || !e.__esModule ? u(n, "default", {
|
|
11
|
-
value: e,
|
|
12
|
-
enumerable: !0
|
|
13
|
-
}) : n, e)), v = class extends Event {
|
|
14
|
-
emitter;
|
|
15
|
-
constructor(e, t) {
|
|
16
|
-
super(e, t);
|
|
17
|
-
}
|
|
18
|
-
}, y = class extends v {
|
|
19
|
-
#e;
|
|
20
|
-
constructor(e) {
|
|
21
|
-
super("action"), this.#e = e;
|
|
22
|
-
}
|
|
23
|
-
get action() {
|
|
24
|
-
return this.#e;
|
|
25
|
-
}
|
|
26
|
-
}, b = [];
|
|
27
|
-
for (let e = 0; e < 256; ++e) b.push((e + 256).toString(16).slice(1));
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region node_modules/uuid/dist/stringify.js
|
|
30
|
-
var x = [];
|
|
31
|
-
for (let e = 0; e < 256; ++e) x.push((e + 256).toString(16).slice(1));
|
|
32
|
-
function S(e, t = 0) {
|
|
33
|
-
return (x[e[t + 0]] + x[e[t + 1]] + x[e[t + 2]] + x[e[t + 3]] + "-" + x[e[t + 4]] + x[e[t + 5]] + "-" + x[e[t + 6]] + x[e[t + 7]] + "-" + x[e[t + 8]] + x[e[t + 9]] + "-" + x[e[t + 10]] + x[e[t + 11]] + x[e[t + 12]] + x[e[t + 13]] + x[e[t + 14]] + x[e[t + 15]]).toLowerCase();
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region node_modules/uuid/dist/rng.js
|
|
37
|
-
var C = new Uint8Array(16);
|
|
38
|
-
function w() {
|
|
39
|
-
return crypto.getRandomValues(C);
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region node_modules/uuid/dist/v7.js
|
|
43
|
-
var T = {};
|
|
44
|
-
function E(e, t, n) {
|
|
45
|
-
let r;
|
|
46
|
-
if (e) r = O(e.random ?? e.rng?.() ?? w(), e.msecs, e.seq, t, n);
|
|
47
|
-
else {
|
|
48
|
-
let e = Date.now(), i = w();
|
|
49
|
-
D(T, e, i), r = O(i, T.msecs, T.seq, t, n);
|
|
50
|
-
}
|
|
51
|
-
return t ?? S(r);
|
|
52
|
-
}
|
|
53
|
-
function D(e, t, n) {
|
|
54
|
-
return e.msecs ??= -Infinity, e.seq ??= 0, t > e.msecs ? (e.seq = n[6] << 23 | n[7] << 16 | n[8] << 8 | n[9], e.msecs = t) : (e.seq = e.seq + 1 | 0, e.seq === 0 && e.msecs++), e;
|
|
55
|
-
}
|
|
56
|
-
function O(e, t, n, r, i = 0) {
|
|
57
|
-
if (e.length < 16) throw Error("Random bytes length must be >= 16");
|
|
58
|
-
if (!r) r = new Uint8Array(16), i = 0;
|
|
59
|
-
else if (i < 0 || i + 16 > r.length) throw RangeError(`UUID byte range ${i}:${i + 15} is out of buffer bounds`);
|
|
60
|
-
return t ??= Date.now(), n ??= e[6] * 127 << 24 | e[7] << 16 | e[8] << 8 | e[9], r[i++] = t / 1099511627776 & 255, r[i++] = t / 4294967296 & 255, r[i++] = t / 16777216 & 255, r[i++] = t / 65536 & 255, r[i++] = t / 256 & 255, r[i++] = t & 255, r[i++] = 112 | n >>> 28 & 15, r[i++] = n >>> 20 & 255, r[i++] = 128 | n >>> 14 & 63, r[i++] = n >>> 6 & 255, r[i++] = n << 2 & 255 | e[10] & 3, r[i++] = e[11], r[i++] = e[12], r[i++] = e[13], r[i++] = e[14], r[i++] = e[15], r;
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
1
|
+
import { ActionEvent as e } from "@rotorjs/core";
|
|
2
|
+
import { createContext as t, createElement as n, useContext as r, useEffect as i, useMemo as a, useState as o } from "react";
|
|
3
|
+
import { v7 as s } from "uuid";
|
|
4
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
+
import d from "fast-deep-equal";
|
|
63
6
|
//#region lib/DashboardContext.ts
|
|
64
|
-
var
|
|
7
|
+
var f = t(void 0);
|
|
65
8
|
//#endregion
|
|
66
9
|
//#region lib/DashboardError.tsx
|
|
67
|
-
function
|
|
10
|
+
function p({ error: e }) {
|
|
68
11
|
throw e;
|
|
69
12
|
}
|
|
70
13
|
//#endregion
|
|
71
14
|
//#region lib/DashboardLayoutContext.ts
|
|
72
|
-
var
|
|
15
|
+
var m = t(void 0);
|
|
73
16
|
//#endregion
|
|
74
17
|
//#region lib/getKey.ts
|
|
75
|
-
function
|
|
18
|
+
function h(e, t = 0) {
|
|
76
19
|
return `${encodeURIComponent(e.type)}:${e.id ? `id:${encodeURIComponent(e.id)}` : `idx:${t}`}`;
|
|
77
20
|
}
|
|
78
21
|
//#endregion
|
|
79
22
|
//#region lib/DashboardLayoutError.tsx
|
|
80
|
-
var
|
|
81
|
-
function
|
|
82
|
-
let { layouts: a } =
|
|
23
|
+
var g = { type: "error" };
|
|
24
|
+
function _({ id: e, error: t, children: i }) {
|
|
25
|
+
let { layouts: a } = r(f), o = a.error ?? p, s = {
|
|
83
26
|
type: "error",
|
|
84
27
|
id: e,
|
|
85
|
-
error:
|
|
28
|
+
error: t
|
|
86
29
|
};
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
value:
|
|
89
|
-
children: /* @__PURE__ */
|
|
90
|
-
...
|
|
91
|
-
key:
|
|
30
|
+
return /* @__PURE__ */ l(m.Provider, {
|
|
31
|
+
value: g,
|
|
32
|
+
children: /* @__PURE__ */ n(o, {
|
|
33
|
+
...s,
|
|
34
|
+
key: h(s)
|
|
92
35
|
}, i)
|
|
93
36
|
});
|
|
94
37
|
}
|
|
95
38
|
//#endregion
|
|
96
39
|
//#region lib/DashboardLayout.tsx
|
|
97
|
-
function
|
|
98
|
-
let { layouts:
|
|
99
|
-
error:
|
|
100
|
-
...
|
|
101
|
-
}), [
|
|
102
|
-
if (!
|
|
103
|
-
let
|
|
104
|
-
return
|
|
40
|
+
function v({ layout: e, children: t }) {
|
|
41
|
+
let { layouts: i, defaultLayout: o } = r(f), s = a(() => ({
|
|
42
|
+
error: p,
|
|
43
|
+
...i
|
|
44
|
+
}), [i]), c = e ?? o, u = c?.type, d = a(() => ({ type: u }), [u]);
|
|
45
|
+
if (!c?.type) return null;
|
|
46
|
+
let g = s[c.type];
|
|
47
|
+
return g ? /* @__PURE__ */ l(m.Provider, {
|
|
105
48
|
value: d,
|
|
106
|
-
children: /* @__PURE__ */
|
|
107
|
-
...
|
|
108
|
-
key:
|
|
109
|
-
},
|
|
110
|
-
}) : /* @__PURE__ */
|
|
111
|
-
error: `Invalid layout type "${
|
|
112
|
-
children:
|
|
49
|
+
children: /* @__PURE__ */ n(g, {
|
|
50
|
+
...c,
|
|
51
|
+
key: h(c)
|
|
52
|
+
}, t)
|
|
53
|
+
}) : /* @__PURE__ */ l(_, {
|
|
54
|
+
error: `Invalid layout type "${c.type}"`,
|
|
55
|
+
children: t
|
|
113
56
|
});
|
|
114
57
|
}
|
|
115
58
|
//#endregion
|
|
116
59
|
//#region lib/DashboardTileError.tsx
|
|
117
|
-
function
|
|
118
|
-
let { tiles: i } =
|
|
60
|
+
function y({ id: e, error: t }) {
|
|
61
|
+
let { tiles: i } = r(f), a = i.error ?? p, o = {
|
|
119
62
|
type: "error",
|
|
120
63
|
id: e,
|
|
121
|
-
error:
|
|
64
|
+
error: t
|
|
122
65
|
};
|
|
123
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ n(a, {
|
|
124
67
|
...o,
|
|
125
|
-
key:
|
|
68
|
+
key: h(o)
|
|
126
69
|
});
|
|
127
70
|
}
|
|
128
71
|
//#endregion
|
|
129
72
|
//#region lib/DashboardTiles.tsx
|
|
130
|
-
function
|
|
131
|
-
let { tiles:
|
|
132
|
-
error:
|
|
133
|
-
...
|
|
134
|
-
}), [
|
|
135
|
-
return /* @__PURE__ */
|
|
73
|
+
function b({ content: e }) {
|
|
74
|
+
let { tiles: t } = r(f), i = a(() => ({
|
|
75
|
+
error: p,
|
|
76
|
+
...t
|
|
77
|
+
}), [t]);
|
|
78
|
+
return /* @__PURE__ */ l(c, { children: e.map((e, t) => {
|
|
136
79
|
if (!e?.type) return null;
|
|
137
|
-
let r =
|
|
138
|
-
return r ? /* @__PURE__ */
|
|
80
|
+
let r = i[e.type];
|
|
81
|
+
return r ? /* @__PURE__ */ n(r, {
|
|
139
82
|
...e,
|
|
140
|
-
key:
|
|
141
|
-
}) : /* @__PURE__ */
|
|
83
|
+
key: h(e, t)
|
|
84
|
+
}) : /* @__PURE__ */ l(y, { error: `Invalid tile type "${e.type}"` }, h({ type: "error" }, t));
|
|
142
85
|
}) });
|
|
143
86
|
}
|
|
144
87
|
//#endregion
|
|
145
88
|
//#region lib/Dashboard.tsx
|
|
146
|
-
function
|
|
147
|
-
let [
|
|
148
|
-
|
|
149
|
-
let
|
|
150
|
-
return Object.entries(
|
|
151
|
-
let
|
|
89
|
+
function x({ engine: t, initialVars: n, initialFacts: r, layouts: c, defaultLayout: d, tiles: p, layout: m, content: h, children: g }) {
|
|
90
|
+
let [_] = o(n ?? {}), [y, x] = o(_), [S] = o(r ?? {}), [C, w] = o(S);
|
|
91
|
+
i(() => {
|
|
92
|
+
let n = s(), r = new AbortController(), i = r.signal;
|
|
93
|
+
return Object.entries(_).forEach(([r, { value: i, exposed: a }]) => {
|
|
94
|
+
let o = new e({
|
|
152
95
|
type: "var",
|
|
153
|
-
name:
|
|
154
|
-
value:
|
|
155
|
-
exposed:
|
|
96
|
+
name: r,
|
|
97
|
+
value: i,
|
|
98
|
+
exposed: a
|
|
156
99
|
});
|
|
157
|
-
|
|
158
|
-
}), Object.entries(
|
|
159
|
-
let
|
|
100
|
+
o.emitter = n, t.dispatchEvent(o);
|
|
101
|
+
}), Object.entries(S).forEach(([r, { value: i }]) => {
|
|
102
|
+
let a = new e({
|
|
160
103
|
type: "fact",
|
|
161
|
-
name:
|
|
162
|
-
value:
|
|
104
|
+
name: r,
|
|
105
|
+
value: i
|
|
163
106
|
});
|
|
164
|
-
|
|
165
|
-
}),
|
|
166
|
-
if (e.emitter ===
|
|
167
|
-
let
|
|
168
|
-
switch (
|
|
107
|
+
a.emitter = n, t.dispatchEvent(a);
|
|
108
|
+
}), t.addEventListener("action", (e) => {
|
|
109
|
+
if (e.emitter === n) return;
|
|
110
|
+
let t = e.action;
|
|
111
|
+
switch (t.type) {
|
|
169
112
|
case "var":
|
|
170
|
-
|
|
171
|
-
let
|
|
172
|
-
return Object.hasOwn(e,
|
|
113
|
+
x((e) => {
|
|
114
|
+
let n = e[t.name];
|
|
115
|
+
return Object.hasOwn(e, t.name) && n.value === t.value && n.exposed === (t.exposed ?? !1) ? e : {
|
|
173
116
|
...e,
|
|
174
|
-
[
|
|
175
|
-
value:
|
|
176
|
-
exposed:
|
|
117
|
+
[t.name]: {
|
|
118
|
+
value: t.value,
|
|
119
|
+
exposed: t.exposed ?? !1
|
|
177
120
|
}
|
|
178
121
|
};
|
|
179
122
|
});
|
|
180
123
|
return;
|
|
181
|
-
case "fact":
|
|
182
|
-
let
|
|
183
|
-
return Object.hasOwn(e,
|
|
124
|
+
case "fact": w((e) => {
|
|
125
|
+
let n = e[t.name];
|
|
126
|
+
return Object.hasOwn(e, t.name) && n.value === t.value ? e : {
|
|
184
127
|
...e,
|
|
185
|
-
[
|
|
128
|
+
[t.name]: { value: t.value }
|
|
186
129
|
};
|
|
187
130
|
});
|
|
188
131
|
}
|
|
189
|
-
}, { signal:
|
|
190
|
-
|
|
132
|
+
}, { signal: i }), () => {
|
|
133
|
+
r.abort();
|
|
191
134
|
};
|
|
192
135
|
}, [
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
136
|
+
t,
|
|
137
|
+
_,
|
|
138
|
+
S
|
|
196
139
|
]);
|
|
197
|
-
let
|
|
198
|
-
engine:
|
|
199
|
-
vars:
|
|
200
|
-
facts:
|
|
201
|
-
layouts:
|
|
202
|
-
defaultLayout:
|
|
203
|
-
tiles:
|
|
140
|
+
let T = a(() => ({
|
|
141
|
+
engine: t,
|
|
142
|
+
vars: y,
|
|
143
|
+
facts: C,
|
|
144
|
+
layouts: c,
|
|
145
|
+
defaultLayout: d,
|
|
146
|
+
tiles: p
|
|
204
147
|
}), [
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
148
|
+
t,
|
|
149
|
+
y,
|
|
150
|
+
C,
|
|
151
|
+
c,
|
|
152
|
+
d,
|
|
153
|
+
p
|
|
211
154
|
]);
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
value:
|
|
214
|
-
children: /* @__PURE__ */
|
|
215
|
-
layout:
|
|
216
|
-
children: [/* @__PURE__ */
|
|
155
|
+
return /* @__PURE__ */ l(f.Provider, {
|
|
156
|
+
value: T,
|
|
157
|
+
children: /* @__PURE__ */ u(v, {
|
|
158
|
+
layout: m,
|
|
159
|
+
children: [/* @__PURE__ */ l(b, { content: h }), g]
|
|
217
160
|
})
|
|
218
161
|
});
|
|
219
162
|
}
|
|
220
163
|
//#endregion
|
|
164
|
+
//#region lib/DashboardTileContainer.tsx
|
|
165
|
+
function S({ layout: e, children: t }) {
|
|
166
|
+
let { tileContainer: n } = r(m);
|
|
167
|
+
return n ? /* @__PURE__ */ l(n, {
|
|
168
|
+
layout: e,
|
|
169
|
+
children: t
|
|
170
|
+
}) : t;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
221
173
|
//#region lib/useDashboardState.ts
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
for (i = r; i-- !== 0;) if (!e(t[i], n[i])) return !1;
|
|
231
|
-
return !0;
|
|
232
|
-
}
|
|
233
|
-
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
234
|
-
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
235
|
-
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
236
|
-
if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
|
|
237
|
-
for (i = r; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(n, a[i])) return !1;
|
|
238
|
-
for (i = r; i-- !== 0;) {
|
|
239
|
-
var o = a[i];
|
|
240
|
-
if (!e(t[o], n[o])) return !1;
|
|
241
|
-
}
|
|
242
|
-
return !0;
|
|
243
|
-
}
|
|
244
|
-
return t !== t && n !== n;
|
|
245
|
-
};
|
|
246
|
-
})))(), 1);
|
|
247
|
-
function B(e, t = []) {
|
|
248
|
-
let { engine: i } = n(k), [o, s] = a(e), [c, l] = a(t);
|
|
249
|
-
return (0, z.default)(e, o) || s(o), r(() => {
|
|
250
|
-
let e = E(), t = new AbortController(), n = t.signal;
|
|
251
|
-
return i.addEventListener("state", (t) => {
|
|
252
|
-
t.id === e && l(t.state);
|
|
253
|
-
}, { signal: n }), i.registerReducer(e, o), () => {
|
|
254
|
-
t.abort(), i.removeReducer(e);
|
|
174
|
+
function C(e, t = []) {
|
|
175
|
+
let { engine: n } = r(f), [a, c] = o(e), [l, u] = o(t);
|
|
176
|
+
return d(e, a) || c(a), i(() => {
|
|
177
|
+
let e = s(), t = new AbortController(), r = t.signal;
|
|
178
|
+
return n.addEventListener("state", (t) => {
|
|
179
|
+
t.id === e && u(t.state);
|
|
180
|
+
}, { signal: r }), n.registerReducer(e, a), () => {
|
|
181
|
+
t.abort(), n.removeReducer(e);
|
|
255
182
|
};
|
|
256
|
-
}, [
|
|
183
|
+
}, [a, n]), l;
|
|
257
184
|
}
|
|
258
185
|
//#endregion
|
|
259
|
-
export {
|
|
186
|
+
export { x as Dashboard, f as DashboardContext, p as DashboardError, v as DashboardLayout, m as DashboardLayoutContext, _ as DashboardLayoutError, S as DashboardTileContainer, y as DashboardTileError, b as DashboardTiles, h as getKey, C as useDashboardState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rotorjs/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Rotor",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aaron Burmeister"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@eslint/js": "^10.0.1",
|
|
47
|
-
"@rotorjs/dashboards": "^0.13.
|
|
47
|
+
"@rotorjs/dashboards": "^0.13.3",
|
|
48
48
|
"@types/react": "^19.1.12",
|
|
49
49
|
"@types/react-dom": "^19.1.9",
|
|
50
50
|
"@vitejs/plugin-react": "^6.0.1",
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"typescript": "^6.0.3",
|
|
63
63
|
"typescript-eslint": "^8.59.3",
|
|
64
64
|
"unplugin-dts": "^1.0.0",
|
|
65
|
-
"vite": "^8.0.
|
|
65
|
+
"vite": "^8.0.13"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@rotorjs/dashboards": "^0.13.0",
|
|
69
69
|
"react": "^19.0.0"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@rotorjs/core": "^0.5.
|
|
72
|
+
"@rotorjs/core": "^0.5.3",
|
|
73
73
|
"fast-deep-equal": "^3.1.3",
|
|
74
74
|
"uuid": "^14.0.0"
|
|
75
75
|
}
|