@rotorjs/react 0.0.0 → 0.2.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/Dashboard.d.ts +2 -3
- package/dist/DashboardContext.d.ts +4 -3
- package/dist/DashboardLayout.d.ts +1 -1
- package/dist/DashboardLayoutContext.d.ts +6 -0
- package/dist/DashboardLayoutError.d.ts +6 -0
- package/dist/DashboardTileError.d.ts +5 -0
- package/dist/DashboardTiles.d.ts +1 -1
- package/dist/main.d.ts +3 -2
- package/dist/main.js +56 -38
- package/package.json +3 -4
- package/dist/DashboardLayoutNode.d.ts +0 -4
- package/dist/DashboardTileNode.d.ts +0 -4
package/dist/Dashboard.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DashboardEventTarget, DashboardFact, DashboardVar } from '@rotorjs/dashboards';
|
|
1
|
+
import { DashboardEventTarget, DashboardFact, DashboardLayoutNode, DashboardTileNode, DashboardVar } from '@rotorjs/dashboards';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { DashboardLayoutMap,
|
|
4
|
-
import { DashboardTileMap, DashboardTileNode } from './DashboardTileNode';
|
|
3
|
+
import { DashboardLayoutMap, DashboardTileMap } from './DashboardContext';
|
|
5
4
|
export type DashboardProps = {
|
|
6
5
|
engine: DashboardEventTarget;
|
|
7
6
|
initialVars?: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DashboardEventTarget, DashboardFact, DashboardVar } from '@rotorjs/dashboards';
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { DashboardEventTarget, DashboardFact, DashboardLayoutNode, DashboardTileNode, DashboardVar } from '@rotorjs/dashboards';
|
|
2
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
3
|
+
export type DashboardLayoutMap = Record<string, ComponentType<PropsWithChildren<DashboardLayoutNode>>>;
|
|
4
|
+
export type DashboardTileMap = Record<string, ComponentType<DashboardTileNode>>;
|
|
4
5
|
export type DashboardContextValue = {
|
|
5
6
|
engine: DashboardEventTarget;
|
|
6
7
|
vars: {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
export type DashboardLayoutContextValue = {
|
|
3
|
+
type: string;
|
|
4
|
+
tileContainer?: ComponentType<PropsWithChildren>;
|
|
5
|
+
};
|
|
6
|
+
export declare const DashboardLayoutContext: import('react').Context<DashboardLayoutContextValue>;
|
package/dist/DashboardTiles.d.ts
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ export * from './Dashboard';
|
|
|
2
2
|
export * from './DashboardContext';
|
|
3
3
|
export * from './DashboardError';
|
|
4
4
|
export * from './DashboardLayout';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './DashboardLayoutContext';
|
|
6
|
+
export * from './DashboardLayoutError';
|
|
7
|
+
export * from './DashboardTileError';
|
|
7
8
|
export * from './DashboardTiles';
|
|
8
9
|
export * from './getKey';
|
|
9
10
|
export * from './useDashboardState';
|
package/dist/main.js
CHANGED
|
@@ -64,56 +64,74 @@ function S(e, t = 0) {
|
|
|
64
64
|
return `${encodeURIComponent(e.type)}:${e.id ? `id:${encodeURIComponent(e.id)}` : `idx:${t}`}`;
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
|
+
//#region lib/DashboardLayoutContext.ts
|
|
68
|
+
var C = e(void 0), w = { type: "error" };
|
|
69
|
+
function T({ id: e, error: r, children: i }) {
|
|
70
|
+
let { layouts: a } = n(b), o = a.error ?? x, c = {
|
|
71
|
+
type: "error",
|
|
72
|
+
id: e,
|
|
73
|
+
error: r
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ s(C.Provider, {
|
|
76
|
+
value: w,
|
|
77
|
+
children: /* @__PURE__ */ t(o, {
|
|
78
|
+
...c,
|
|
79
|
+
key: S(c)
|
|
80
|
+
}, i)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
67
84
|
//#region lib/DashboardLayout.tsx
|
|
68
|
-
function
|
|
69
|
-
let { layouts: a, defaultLayout: o } = n(b),
|
|
85
|
+
function E({ layout: e, children: r }) {
|
|
86
|
+
let { layouts: a, defaultLayout: o } = n(b), c = i(() => ({
|
|
70
87
|
error: x,
|
|
71
88
|
...a
|
|
72
|
-
}), [a]),
|
|
73
|
-
if (!
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
}), [a]), l = e ?? o, u = l?.type, d = i(() => ({ type: u }), [u]);
|
|
90
|
+
if (!l?.type) return null;
|
|
91
|
+
let f = c[l.type];
|
|
92
|
+
return f ? /* @__PURE__ */ s(C.Provider, {
|
|
93
|
+
value: d,
|
|
94
|
+
children: /* @__PURE__ */ t(f, {
|
|
95
|
+
...l,
|
|
96
|
+
key: S(l)
|
|
97
|
+
}, r)
|
|
98
|
+
}) : /* @__PURE__ */ s(T, {
|
|
99
|
+
error: `Invalid layout type "${l.type}"`,
|
|
100
|
+
children: r
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region lib/DashboardTileError.tsx
|
|
105
|
+
function D({ id: e, error: r }) {
|
|
106
|
+
let { tiles: i } = n(b), a = i.error ?? x, o = {
|
|
107
|
+
type: "error",
|
|
108
|
+
id: e,
|
|
109
|
+
error: r
|
|
110
|
+
};
|
|
111
|
+
return /* @__PURE__ */ t(a, {
|
|
112
|
+
...o,
|
|
113
|
+
key: S(o)
|
|
114
|
+
});
|
|
89
115
|
}
|
|
90
116
|
//#endregion
|
|
91
117
|
//#region lib/DashboardTiles.tsx
|
|
92
|
-
function
|
|
118
|
+
function O({ content: e }) {
|
|
93
119
|
let { tiles: r } = n(b), a = i(() => ({
|
|
94
120
|
error: x,
|
|
95
121
|
...r
|
|
96
122
|
}), [r]);
|
|
97
123
|
return /* @__PURE__ */ s(o, { children: e.map((e, n) => {
|
|
98
|
-
if (!e) return null;
|
|
124
|
+
if (!e?.type) return null;
|
|
99
125
|
let r = a[e.type];
|
|
100
|
-
|
|
101
|
-
let r = a.error;
|
|
102
|
-
return /* @__PURE__ */ t(r, {
|
|
103
|
-
type: "error",
|
|
104
|
-
error: `Invalid tile type "${e.type}"`,
|
|
105
|
-
key: S(e, n)
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return /* @__PURE__ */ t(r, {
|
|
126
|
+
return r ? /* @__PURE__ */ t(r, {
|
|
109
127
|
...e,
|
|
110
128
|
key: S(e, n)
|
|
111
|
-
});
|
|
129
|
+
}) : /* @__PURE__ */ s(D, { error: `Invalid tile type "${e.type}"` }, S({ type: "error" }, n));
|
|
112
130
|
}) });
|
|
113
131
|
}
|
|
114
132
|
//#endregion
|
|
115
133
|
//#region lib/Dashboard.tsx
|
|
116
|
-
function
|
|
134
|
+
function k({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayout: l, tiles: d, layout: f, content: p, children: m }) {
|
|
117
135
|
let [h] = a(t ?? {}), [g, v] = a(h), [y] = a(n ?? {}), [x, S] = a(y);
|
|
118
136
|
r(() => {
|
|
119
137
|
let t = _(), n = new AbortController(), r = n.signal;
|
|
@@ -164,7 +182,7 @@ function T({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayo
|
|
|
164
182
|
h,
|
|
165
183
|
y
|
|
166
184
|
]);
|
|
167
|
-
let
|
|
185
|
+
let C = i(() => ({
|
|
168
186
|
engine: e,
|
|
169
187
|
vars: g,
|
|
170
188
|
facts: x,
|
|
@@ -180,16 +198,16 @@ function T({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayo
|
|
|
180
198
|
d
|
|
181
199
|
]);
|
|
182
200
|
return /* @__PURE__ */ s(b.Provider, {
|
|
183
|
-
value:
|
|
184
|
-
children: /* @__PURE__ */ c(
|
|
201
|
+
value: C,
|
|
202
|
+
children: /* @__PURE__ */ c(E, {
|
|
185
203
|
layout: f,
|
|
186
|
-
children: [/* @__PURE__ */ s(
|
|
204
|
+
children: [/* @__PURE__ */ s(O, { content: p }), m]
|
|
187
205
|
})
|
|
188
206
|
});
|
|
189
207
|
}
|
|
190
208
|
//#endregion
|
|
191
209
|
//#region lib/useDashboardState.ts
|
|
192
|
-
function
|
|
210
|
+
function A(e, t = []) {
|
|
193
211
|
let { engine: i } = n(b), [o, s] = a(t);
|
|
194
212
|
return r(() => {
|
|
195
213
|
let t = _(), n = new AbortController(), r = n.signal;
|
|
@@ -201,4 +219,4 @@ function E(e, t = []) {
|
|
|
201
219
|
}, [e, i]), o;
|
|
202
220
|
}
|
|
203
221
|
//#endregion
|
|
204
|
-
export {
|
|
222
|
+
export { k as Dashboard, b as DashboardContext, x as DashboardError, E as DashboardLayout, C as DashboardLayoutContext, T as DashboardLayoutError, D as DashboardTileError, O as DashboardTiles, S as getKey, A as useDashboardState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rotorjs/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Rotor",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aaron Burmeister"
|
|
@@ -44,9 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@eslint/js": "^10.0.1",
|
|
47
|
-
"@jplorg/jpl": "^2.0.0",
|
|
48
47
|
"@rotorjs/core": "^0.5.1",
|
|
49
|
-
"@rotorjs/dashboards": "^0.
|
|
48
|
+
"@rotorjs/dashboards": "^0.12.0",
|
|
50
49
|
"@types/react": "^19.1.12",
|
|
51
50
|
"@types/react-dom": "^19.1.9",
|
|
52
51
|
"@vitejs/plugin-react": "^6.0.1",
|
|
@@ -68,7 +67,7 @@
|
|
|
68
67
|
},
|
|
69
68
|
"peerDependencies": {
|
|
70
69
|
"@rotorjs/core": "^0.5.0",
|
|
71
|
-
"@rotorjs/dashboards": "^0.
|
|
70
|
+
"@rotorjs/dashboards": "^0.12.0"
|
|
72
71
|
},
|
|
73
72
|
"dependencies": {
|
|
74
73
|
"uuid": "^14.0.0"
|