@rotorjs/react 0.8.0 → 0.10.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 -2
- package/dist/DashboardContext.d.ts +1 -1
- package/dist/DashboardLayout.d.ts +1 -1
- package/dist/DashboardLayoutError.d.ts +1 -1
- package/dist/DashboardTileContainer.d.ts +1 -1
- package/dist/DashboardTileError.d.ts +1 -1
- package/dist/DashboardTiles.d.ts +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +113 -128
- package/dist/useNumberFormatter.d.ts +5 -0
- package/package.json +14 -14
package/dist/Dashboard.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DashboardAction, DashboardEventTarget, DashboardFact, DashboardLayoutNo
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { DashboardLayoutMap, DashboardTileMap } from './DashboardContext';
|
|
4
4
|
export type DashboardProps = {
|
|
5
|
-
|
|
5
|
+
target: DashboardEventTarget;
|
|
6
6
|
initialVars?: {
|
|
7
7
|
[name: string]: DashboardVar;
|
|
8
8
|
};
|
|
@@ -20,4 +20,4 @@ export type DashboardProps = {
|
|
|
20
20
|
};
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
};
|
|
23
|
-
export declare function Dashboard({
|
|
23
|
+
export declare function Dashboard({ target, initialVars, initialFacts, layouts, defaultLayout, tiles, layout, content, onAction, allowedNavigateOrigins: rawAllowedNavigateOrigins, children, }: DashboardProps): import("react").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { ComponentType, PropsWithChildren } from 'react';
|
|
|
3
3
|
export type DashboardLayoutMap = Record<string, ComponentType<PropsWithChildren<DashboardLayoutNode>>>;
|
|
4
4
|
export type DashboardTileMap = Record<string, ComponentType<DashboardTileNode>>;
|
|
5
5
|
export type DashboardContextValue = {
|
|
6
|
-
|
|
6
|
+
target: DashboardEventTarget;
|
|
7
7
|
vars: {
|
|
8
8
|
[name: string]: DashboardVar;
|
|
9
9
|
};
|
|
@@ -4,4 +4,4 @@ export type DashboardLayoutProps = {
|
|
|
4
4
|
layout?: DashboardLayoutNode;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
};
|
|
7
|
-
export declare function DashboardLayout({ layout, children }: DashboardLayoutProps): import("react
|
|
7
|
+
export declare function DashboardLayout({ layout, children }: DashboardLayoutProps): import("react").JSX.Element | null;
|
|
@@ -7,4 +7,4 @@ export type DashboardTileContainerProps = {
|
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
}) => ReactNode;
|
|
9
9
|
};
|
|
10
|
-
export declare function DashboardTileContainer({ layout, children, }: DashboardTileContainerProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react
|
|
10
|
+
export declare function DashboardTileContainer({ layout, children, }: DashboardTileContainerProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
package/dist/DashboardTiles.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { DashboardTileNode } from '@rotorjs/dashboard';
|
|
|
2
2
|
export type DashboardTilesProps = {
|
|
3
3
|
content: DashboardTileNode[];
|
|
4
4
|
};
|
|
5
|
-
export declare function DashboardTiles({ content }: DashboardTilesProps): import("react
|
|
5
|
+
export declare function DashboardTiles({ content }: DashboardTilesProps): import("react").JSX.Element;
|
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,148 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { createContext as
|
|
4
|
-
import {
|
|
5
|
-
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
|
-
import { DashboardStateConsumer as f } from "@rotorjs/dashboard";
|
|
1
|
+
import { DashboardEnvironment as e, DashboardStateConsumer as t, NumberFormatter as n, dashboardLocaleFact as r } from "@rotorjs/dashboard";
|
|
2
|
+
import i from "fast-deep-equal";
|
|
3
|
+
import { createContext as a, createElement as o, useCallback as s, useContext as c, useEffect as l, useMemo as u, useState as d } from "react";
|
|
4
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
7
5
|
//#region lib/DashboardContext.ts
|
|
8
|
-
var
|
|
6
|
+
var h = a(void 0);
|
|
9
7
|
//#endregion
|
|
10
8
|
//#region lib/DashboardError.tsx
|
|
11
|
-
function
|
|
9
|
+
function g({ error: e }) {
|
|
12
10
|
throw e;
|
|
13
11
|
}
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region lib/DashboardLayoutContext.ts
|
|
16
|
-
var
|
|
14
|
+
var _ = a(void 0);
|
|
17
15
|
//#endregion
|
|
18
16
|
//#region lib/getNodeKey.ts
|
|
19
|
-
function
|
|
17
|
+
function v(e, t = 0) {
|
|
20
18
|
return `${encodeURIComponent(e.type)}:${e.id ? `id:${encodeURIComponent(e.id)}` : `idx:${t}`}`;
|
|
21
19
|
}
|
|
22
20
|
//#endregion
|
|
23
21
|
//#region lib/DashboardLayoutError.tsx
|
|
24
|
-
var
|
|
25
|
-
function
|
|
26
|
-
let { layouts:
|
|
22
|
+
var y = { type: "error" };
|
|
23
|
+
function b({ id: e, error: t, children: n }) {
|
|
24
|
+
let { layouts: r } = c(h), i = r.error ?? g, a = {
|
|
27
25
|
type: "error",
|
|
28
26
|
id: e,
|
|
29
27
|
error: t
|
|
30
28
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
value:
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
-
...
|
|
35
|
-
key:
|
|
29
|
+
return /* @__PURE__ */ p(_.Provider, {
|
|
30
|
+
value: y,
|
|
31
|
+
children: /* @__PURE__ */ o(i, {
|
|
32
|
+
...a,
|
|
33
|
+
key: v(a)
|
|
36
34
|
}, n)
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
//#endregion
|
|
40
38
|
//#region lib/DashboardLayout.tsx
|
|
41
|
-
function
|
|
42
|
-
let { layouts: n, defaultLayout:
|
|
43
|
-
error:
|
|
39
|
+
function x({ layout: e, children: t }) {
|
|
40
|
+
let { layouts: n, defaultLayout: r } = c(h), i = u(() => ({
|
|
41
|
+
error: g,
|
|
44
42
|
...n
|
|
45
|
-
}), [n]),
|
|
46
|
-
if (!
|
|
47
|
-
let
|
|
48
|
-
return
|
|
49
|
-
value:
|
|
50
|
-
children: /* @__PURE__ */
|
|
51
|
-
...
|
|
52
|
-
key:
|
|
43
|
+
}), [n]), a = e ?? r, s = a?.type, l = u(() => ({ type: s }), [s]);
|
|
44
|
+
if (!a?.type) return null;
|
|
45
|
+
let d = i[a.type];
|
|
46
|
+
return d ? /* @__PURE__ */ p(_.Provider, {
|
|
47
|
+
value: l,
|
|
48
|
+
children: /* @__PURE__ */ o(d, {
|
|
49
|
+
...a,
|
|
50
|
+
key: v(a)
|
|
53
51
|
}, t)
|
|
54
|
-
}) : /* @__PURE__ */
|
|
55
|
-
error: `Invalid layout type "${
|
|
52
|
+
}) : /* @__PURE__ */ p(b, {
|
|
53
|
+
error: `Invalid layout type "${a.type}"`,
|
|
56
54
|
children: t
|
|
57
55
|
});
|
|
58
56
|
}
|
|
59
57
|
//#endregion
|
|
60
58
|
//#region lib/DashboardTileError.tsx
|
|
61
|
-
function
|
|
62
|
-
let { tiles: n } =
|
|
59
|
+
function S({ id: e, error: t }) {
|
|
60
|
+
let { tiles: n } = c(h), r = n.error ?? g, i = {
|
|
63
61
|
type: "error",
|
|
64
62
|
id: e,
|
|
65
63
|
error: t
|
|
66
64
|
};
|
|
67
|
-
return /* @__PURE__ */ r
|
|
68
|
-
...
|
|
69
|
-
key:
|
|
65
|
+
return /* @__PURE__ */ o(r, {
|
|
66
|
+
...i,
|
|
67
|
+
key: v(i)
|
|
70
68
|
});
|
|
71
69
|
}
|
|
72
70
|
//#endregion
|
|
73
71
|
//#region lib/DashboardTiles.tsx
|
|
74
|
-
function
|
|
75
|
-
let { tiles: t } =
|
|
76
|
-
error:
|
|
72
|
+
function C({ content: e }) {
|
|
73
|
+
let { tiles: t } = c(h), n = u(() => ({
|
|
74
|
+
error: g,
|
|
77
75
|
...t
|
|
78
76
|
}), [t]);
|
|
79
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ p(f, { children: e.map((e, t) => {
|
|
80
78
|
if (!e?.type) return null;
|
|
81
|
-
let
|
|
82
|
-
return
|
|
79
|
+
let r = n[e.type];
|
|
80
|
+
return r ? /* @__PURE__ */ o(r, {
|
|
83
81
|
...e,
|
|
84
|
-
key:
|
|
85
|
-
}) : /* @__PURE__ */
|
|
82
|
+
key: v(e, t)
|
|
83
|
+
}) : /* @__PURE__ */ p(S, { error: `Invalid tile type "${e.type}"` }, v({ type: "error" }, t));
|
|
86
84
|
}) });
|
|
87
85
|
}
|
|
88
86
|
//#endregion
|
|
89
87
|
//#region lib/Dashboard.tsx
|
|
90
|
-
var
|
|
91
|
-
function
|
|
92
|
-
let [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
var w = { [window.location.origin]: !0 };
|
|
89
|
+
function T({ target: t, initialVars: n, initialFacts: r, layouts: a, defaultLayout: o, tiles: s, layout: c, content: f, onAction: g, allowedNavigateOrigins: _ = w, children: v }) {
|
|
90
|
+
let [y, b] = d(_), [S, T] = d(n ?? {}), [E, D] = d(r ?? {});
|
|
91
|
+
i(y, _) || b(_), l(() => {
|
|
92
|
+
let n = new e(t, {
|
|
93
|
+
vars: S,
|
|
94
|
+
facts: E
|
|
95
|
+
});
|
|
96
|
+
return n.addEventListener("var", (e) => {
|
|
97
|
+
T((t) => {
|
|
98
|
+
let n = t[e.name], r = {
|
|
99
|
+
value: e.value,
|
|
100
|
+
exposed: e.exposed
|
|
101
|
+
};
|
|
102
|
+
return Object.hasOwn(t, e.name) && i(n, r) ? t : {
|
|
103
|
+
...t,
|
|
104
|
+
[e.name]: r
|
|
105
|
+
};
|
|
100
106
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
}), n.addEventListener("fact", (e) => {
|
|
108
|
+
D((t) => {
|
|
109
|
+
let n = t[e.name], r = { value: e.value };
|
|
110
|
+
return Object.hasOwn(t, e.name) && i(n, r) ? t : {
|
|
111
|
+
...t,
|
|
112
|
+
[e.name]: r
|
|
113
|
+
};
|
|
107
114
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
n
|
|
113
|
-
|
|
114
|
-
T
|
|
115
|
-
]), a(() => {
|
|
116
|
-
let e = new AbortController(), t = e.signal;
|
|
117
|
-
return n.addEventListener("action", (e) => {
|
|
115
|
+
}), () => {
|
|
116
|
+
n.stop();
|
|
117
|
+
};
|
|
118
|
+
}, [t]), l(() => {
|
|
119
|
+
let e = new AbortController(), n = e.signal;
|
|
120
|
+
return t.addEventListener("action", (e) => {
|
|
118
121
|
let t = e.action;
|
|
119
|
-
if (e.
|
|
120
|
-
case "var":
|
|
121
|
-
k((e) => {
|
|
122
|
-
let n = e[t.name];
|
|
123
|
-
return Object.hasOwn(e, t.name) && n.value === t.value && n.exposed === (t.exposed ?? !1) ? e : {
|
|
124
|
-
...e,
|
|
125
|
-
[t.name]: {
|
|
126
|
-
value: t.value,
|
|
127
|
-
exposed: t.exposed ?? !1
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
break;
|
|
132
|
-
case "fact":
|
|
133
|
-
j((e) => {
|
|
134
|
-
let n = e[t.name];
|
|
135
|
-
return Object.hasOwn(e, t.name) && n.value === t.value ? e : {
|
|
136
|
-
...e,
|
|
137
|
-
[t.name]: { value: t.value }
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
if (!_?.(e.action)) switch (t.type) {
|
|
122
|
+
if (!g?.(e.action)) switch (t.type) {
|
|
143
123
|
case "navigate": {
|
|
144
124
|
let e = new URL(t.href, window.location.href).origin;
|
|
145
|
-
if (!
|
|
125
|
+
if (!y["*"] && (!Object.hasOwn(y, e) || !y[e])) {
|
|
146
126
|
console.warn(`Dashboard navigation blocked: origin "${e}" is not allowed`);
|
|
147
127
|
break;
|
|
148
128
|
}
|
|
@@ -150,59 +130,64 @@ function C({ engine: n, initialVars: r, initialFacts: i, layouts: l, defaultLayo
|
|
|
150
130
|
break;
|
|
151
131
|
}
|
|
152
132
|
}
|
|
153
|
-
}, { signal:
|
|
133
|
+
}, { signal: n }), () => {
|
|
154
134
|
e.abort();
|
|
155
135
|
};
|
|
156
136
|
}, [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
E
|
|
137
|
+
t,
|
|
138
|
+
g,
|
|
139
|
+
y
|
|
161
140
|
]);
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
vars:
|
|
165
|
-
facts:
|
|
166
|
-
layouts:
|
|
167
|
-
defaultLayout:
|
|
168
|
-
tiles:
|
|
141
|
+
let O = u(() => ({
|
|
142
|
+
target: t,
|
|
143
|
+
vars: S,
|
|
144
|
+
facts: E,
|
|
145
|
+
layouts: a,
|
|
146
|
+
defaultLayout: o,
|
|
147
|
+
tiles: s
|
|
169
148
|
}), [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
149
|
+
t,
|
|
150
|
+
S,
|
|
151
|
+
E,
|
|
152
|
+
a,
|
|
153
|
+
o,
|
|
154
|
+
s
|
|
176
155
|
]);
|
|
177
|
-
return /* @__PURE__ */
|
|
178
|
-
value:
|
|
179
|
-
children: /* @__PURE__ */
|
|
180
|
-
layout:
|
|
181
|
-
children: [/* @__PURE__ */
|
|
156
|
+
return /* @__PURE__ */ p(h.Provider, {
|
|
157
|
+
value: O,
|
|
158
|
+
children: /* @__PURE__ */ m(x, {
|
|
159
|
+
layout: c,
|
|
160
|
+
children: [/* @__PURE__ */ p(C, { content: f }), v]
|
|
182
161
|
})
|
|
183
162
|
});
|
|
184
163
|
}
|
|
185
164
|
//#endregion
|
|
186
165
|
//#region lib/DashboardTileContainer.tsx
|
|
187
|
-
function
|
|
188
|
-
let { tileContainer: n } =
|
|
189
|
-
return n ? /* @__PURE__ */
|
|
166
|
+
function E({ layout: e, children: t }) {
|
|
167
|
+
let { tileContainer: n } = c(_);
|
|
168
|
+
return n ? /* @__PURE__ */ p(n, {
|
|
190
169
|
layout: e,
|
|
191
170
|
children: t
|
|
192
171
|
}) : t({});
|
|
193
172
|
}
|
|
194
173
|
//#endregion
|
|
195
174
|
//#region lib/useDashboardState.ts
|
|
196
|
-
function
|
|
197
|
-
let {
|
|
198
|
-
return
|
|
199
|
-
let e = new
|
|
200
|
-
u((
|
|
175
|
+
function D(e, n = []) {
|
|
176
|
+
let { target: r } = c(h), [a, o] = d(e), [s, u] = d(n);
|
|
177
|
+
return i(a, e) || o(e), l(() => {
|
|
178
|
+
let e = new t(r, a, (e) => {
|
|
179
|
+
u((t) => i(e, t) ? t : e);
|
|
201
180
|
});
|
|
202
181
|
return () => {
|
|
203
182
|
e.stop();
|
|
204
183
|
};
|
|
205
|
-
}, [r,
|
|
184
|
+
}, [r, a]), s;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region lib/useNumberFormatter.ts
|
|
188
|
+
function O(e) {
|
|
189
|
+
let { facts: t } = c(h), i = t[r], a = e?.locale || (typeof i == "string" && i ? i : void 0), o = u(() => new n({ locale: a }), [a]);
|
|
190
|
+
return s((e, t) => o.format(e, t), [o]);
|
|
206
191
|
}
|
|
207
192
|
//#endregion
|
|
208
|
-
export {
|
|
193
|
+
export { T as Dashboard, h as DashboardContext, g as DashboardError, x as DashboardLayout, _ as DashboardLayoutContext, b as DashboardLayoutError, E as DashboardTileContainer, S as DashboardTileError, C as DashboardTiles, v as getNodeKey, D as useDashboardState, O as useNumberFormatter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rotorjs/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Rotor",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aaron Burmeister"
|
|
@@ -44,32 +44,32 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@eslint/js": "^10.0.1",
|
|
47
|
-
"@rotorjs/dashboard": "^0.2
|
|
48
|
-
"@types/react": "^19.
|
|
47
|
+
"@rotorjs/dashboard": "^0.5.2",
|
|
48
|
+
"@types/react": "^19.2.17",
|
|
49
49
|
"@types/react-dom": "^19.1.9",
|
|
50
50
|
"@vitejs/plugin-react": "^6.0.2",
|
|
51
|
-
"eslint": "^10.4.
|
|
51
|
+
"eslint": "^10.4.1",
|
|
52
52
|
"eslint-config-prettier": "^10.1.8",
|
|
53
|
-
"eslint-import-resolver-typescript": "^4.4.
|
|
53
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
54
54
|
"eslint-plugin-import-x": "^4.16.2",
|
|
55
|
-
"eslint-plugin-prettier": "^5.5.
|
|
55
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
56
56
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
57
57
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
58
58
|
"globals": "^17.6.0",
|
|
59
|
-
"prettier": "^3.8.
|
|
60
|
-
"react": "^19.2.
|
|
61
|
-
"react-dom": "^19.2.
|
|
59
|
+
"prettier": "^3.8.4",
|
|
60
|
+
"react": "^19.2.7",
|
|
61
|
+
"react-dom": "^19.2.7",
|
|
62
62
|
"typescript": "^6.0.3",
|
|
63
|
-
"typescript-eslint": "^8.
|
|
64
|
-
"unplugin-dts": "^1.0.
|
|
65
|
-
"vite": "^8.0.
|
|
63
|
+
"typescript-eslint": "^8.61.0",
|
|
64
|
+
"unplugin-dts": "^1.0.2",
|
|
65
|
+
"vite": "^8.0.16"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@rotorjs/dashboard": "^0.
|
|
68
|
+
"@rotorjs/dashboard": "^0.5.0",
|
|
69
69
|
"react": "^19.0.0"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@rotorjs/state": "^0.
|
|
72
|
+
"@rotorjs/state": "^0.7.0",
|
|
73
73
|
"fast-deep-equal": "^3.1.3",
|
|
74
74
|
"uuid": "^14.0.0"
|
|
75
75
|
}
|