@rotorjs/react 0.7.0 → 0.9.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.
@@ -20,4 +20,4 @@ export type DashboardProps = {
20
20
  };
21
21
  children?: ReactNode;
22
22
  };
23
- export declare function Dashboard({ engine, initialVars: rawInitialVars, initialFacts: rawInitialFacts, layouts, defaultLayout, tiles, layout, content, onAction, allowedNavigateOrigins: rawAllowedNavigateOrigins, children, }: DashboardProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function Dashboard({ engine, initialVars: rawInitialVars, initialFacts: rawInitialFacts, layouts, defaultLayout, tiles, layout, content, onAction, allowedNavigateOrigins: rawAllowedNavigateOrigins, children, }: DashboardProps): import("react").JSX.Element;
@@ -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/jsx-runtime").JSX.Element | null;
7
+ export declare function DashboardLayout({ layout, children }: DashboardLayoutProps): import("react").JSX.Element | null;
@@ -3,4 +3,4 @@ export declare function DashboardLayoutError({ id, error, children, }: PropsWith
3
3
  type?: 'error';
4
4
  id?: string;
5
5
  error: unknown;
6
- }>): import("react/jsx-runtime").JSX.Element;
6
+ }>): import("react").JSX.Element;
@@ -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/jsx-runtime").JSX.Element | null | undefined;
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;
@@ -2,4 +2,4 @@ export declare function DashboardTileError({ id, error, }: {
2
2
  type?: 'error';
3
3
  id?: string;
4
4
  error: unknown;
5
- }): import("react/jsx-runtime").JSX.Element;
5
+ }): import("react").JSX.Element;
@@ -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/jsx-runtime").JSX.Element;
5
+ export declare function DashboardTiles({ content }: DashboardTilesProps): import("react").JSX.Element;
package/dist/main.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './DashboardTileError';
9
9
  export * from './DashboardTiles';
10
10
  export * from './getNodeKey';
11
11
  export * from './useDashboardState';
12
+ export * from './useNumberFormatter';
package/dist/main.js CHANGED
@@ -1,122 +1,122 @@
1
1
  import { ActionEvent as e } from "@rotorjs/state";
2
2
  import t from "fast-deep-equal";
3
- import { createContext as n, createElement as r, useContext as i, useEffect as a, useMemo as o, useState as s } from "react";
4
- import { v7 as c } from "uuid";
5
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
6
- import { DashboardStateConsumer as f } from "@rotorjs/dashboard";
3
+ import { createContext as n, createElement as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useState as c } from "react";
4
+ import { v7 as l } from "uuid";
5
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
6
+ import { DashboardStateConsumer as p, NumberFormatter as m } from "@rotorjs/dashboard";
7
7
  //#region lib/DashboardContext.ts
8
- var p = n(void 0);
8
+ var h = n(void 0);
9
9
  //#endregion
10
10
  //#region lib/DashboardError.tsx
11
- function m({ error: e }) {
11
+ function g({ error: e }) {
12
12
  throw e;
13
13
  }
14
14
  //#endregion
15
15
  //#region lib/DashboardLayoutContext.ts
16
- var h = n(void 0);
16
+ var _ = n(void 0);
17
17
  //#endregion
18
18
  //#region lib/getNodeKey.ts
19
- function g(e, t = 0) {
19
+ function v(e, t = 0) {
20
20
  return `${encodeURIComponent(e.type)}:${e.id ? `id:${encodeURIComponent(e.id)}` : `idx:${t}`}`;
21
21
  }
22
22
  //#endregion
23
23
  //#region lib/DashboardLayoutError.tsx
24
- var _ = { type: "error" };
25
- function v({ id: e, error: t, children: n }) {
26
- let { layouts: a } = i(p), o = a.error ?? m, s = {
24
+ var y = { type: "error" };
25
+ function b({ id: e, error: t, children: n }) {
26
+ let { layouts: i } = a(h), o = i.error ?? g, s = {
27
27
  type: "error",
28
28
  id: e,
29
29
  error: t
30
30
  };
31
- return /* @__PURE__ */ u(h.Provider, {
32
- value: _,
31
+ return /* @__PURE__ */ d(_.Provider, {
32
+ value: y,
33
33
  children: /* @__PURE__ */ r(o, {
34
34
  ...s,
35
- key: g(s)
35
+ key: v(s)
36
36
  }, n)
37
37
  });
38
38
  }
39
39
  //#endregion
40
40
  //#region lib/DashboardLayout.tsx
41
- function y({ layout: e, children: t }) {
42
- let { layouts: n, defaultLayout: a } = i(p), s = o(() => ({
43
- error: m,
41
+ function x({ layout: e, children: t }) {
42
+ let { layouts: n, defaultLayout: i } = a(h), o = s(() => ({
43
+ error: g,
44
44
  ...n
45
- }), [n]), c = e ?? a, l = c?.type, d = o(() => ({ type: l }), [l]);
45
+ }), [n]), c = e ?? i, l = c?.type, u = s(() => ({ type: l }), [l]);
46
46
  if (!c?.type) return null;
47
- let f = s[c.type];
48
- return f ? /* @__PURE__ */ u(h.Provider, {
49
- value: d,
47
+ let f = o[c.type];
48
+ return f ? /* @__PURE__ */ d(_.Provider, {
49
+ value: u,
50
50
  children: /* @__PURE__ */ r(f, {
51
51
  ...c,
52
- key: g(c)
52
+ key: v(c)
53
53
  }, t)
54
- }) : /* @__PURE__ */ u(v, {
54
+ }) : /* @__PURE__ */ d(b, {
55
55
  error: `Invalid layout type "${c.type}"`,
56
56
  children: t
57
57
  });
58
58
  }
59
59
  //#endregion
60
60
  //#region lib/DashboardTileError.tsx
61
- function b({ id: e, error: t }) {
62
- let { tiles: n } = i(p), a = n.error ?? m, o = {
61
+ function S({ id: e, error: t }) {
62
+ let { tiles: n } = a(h), i = n.error ?? g, o = {
63
63
  type: "error",
64
64
  id: e,
65
65
  error: t
66
66
  };
67
- return /* @__PURE__ */ r(a, {
67
+ return /* @__PURE__ */ r(i, {
68
68
  ...o,
69
- key: g(o)
69
+ key: v(o)
70
70
  });
71
71
  }
72
72
  //#endregion
73
73
  //#region lib/DashboardTiles.tsx
74
- function x({ content: e }) {
75
- let { tiles: t } = i(p), n = o(() => ({
76
- error: m,
74
+ function C({ content: e }) {
75
+ let { tiles: t } = a(h), n = s(() => ({
76
+ error: g,
77
77
  ...t
78
78
  }), [t]);
79
- return /* @__PURE__ */ u(l, { children: e.map((e, t) => {
79
+ return /* @__PURE__ */ d(u, { children: e.map((e, t) => {
80
80
  if (!e?.type) return null;
81
81
  let i = n[e.type];
82
82
  return i ? /* @__PURE__ */ r(i, {
83
83
  ...e,
84
- key: g(e, t)
85
- }) : /* @__PURE__ */ u(b, { error: `Invalid tile type "${e.type}"` }, g({ type: "error" }, t));
84
+ key: v(e, t)
85
+ }) : /* @__PURE__ */ d(S, { error: `Invalid tile type "${e.type}"` }, v({ type: "error" }, t));
86
86
  }) });
87
87
  }
88
88
  //#endregion
89
89
  //#region lib/Dashboard.tsx
90
- var S = { [window.location.origin]: !0 };
91
- function C({ engine: n, initialVars: r, initialFacts: i, layouts: l, defaultLayout: f, tiles: m, layout: h, content: g, onAction: _, allowedNavigateOrigins: v = S, children: b }) {
92
- let [C] = s(() => c()), [w] = s(r ?? {}), [T] = s(i ?? {}), [E, D] = s(v), [O, k] = s(w), [A, j] = s(T);
93
- t(E, v) || D(v), a(() => {
94
- Object.entries(w).forEach(([t, { value: r, exposed: i }]) => {
90
+ var w = { [window.location.origin]: !0 };
91
+ function T({ engine: n, initialVars: r, initialFacts: i, layouts: a, defaultLayout: u, tiles: p, layout: m, content: g, onAction: _, allowedNavigateOrigins: v = w, children: y }) {
92
+ let [b] = c(() => l()), [S] = c(r ?? {}), [T] = c(i ?? {}), [E, D] = c(v), [O, k] = c(S), [A, j] = c(T);
93
+ t(E, v) || D(v), o(() => {
94
+ Object.entries(S).forEach(([t, { value: r, exposed: i }]) => {
95
95
  let a = new e({
96
96
  type: "var",
97
97
  name: t,
98
98
  value: r,
99
99
  exposed: i
100
100
  });
101
- a.emitter = C, n.dispatchEvent(a);
101
+ a.emitter = b, n.dispatchEvent(a);
102
102
  }), Object.entries(T).forEach(([t, { value: r }]) => {
103
103
  let i = new e({
104
104
  type: "fact",
105
105
  name: t,
106
106
  value: r
107
107
  });
108
- i.emitter = C, n.dispatchEvent(i);
108
+ i.emitter = b, n.dispatchEvent(i);
109
109
  });
110
110
  }, [
111
- C,
111
+ b,
112
112
  n,
113
- w,
113
+ S,
114
114
  T
115
- ]), a(() => {
115
+ ]), o(() => {
116
116
  let e = new AbortController(), t = e.signal;
117
117
  return n.addEventListener("action", (e) => {
118
118
  let t = e.action;
119
- if (e.emitter !== C) switch (t.type) {
119
+ if (e.emitter !== b) switch (t.type) {
120
120
  case "var":
121
121
  k((e) => {
122
122
  let n = e[t.name];
@@ -154,55 +154,61 @@ function C({ engine: n, initialVars: r, initialFacts: i, layouts: l, defaultLayo
154
154
  e.abort();
155
155
  };
156
156
  }, [
157
- C,
157
+ b,
158
158
  n,
159
159
  _,
160
160
  E
161
161
  ]);
162
- let M = o(() => ({
162
+ let M = s(() => ({
163
163
  engine: n,
164
164
  vars: O,
165
165
  facts: A,
166
- layouts: l,
167
- defaultLayout: f,
168
- tiles: m
166
+ layouts: a,
167
+ defaultLayout: u,
168
+ tiles: p
169
169
  }), [
170
170
  n,
171
171
  O,
172
172
  A,
173
- l,
174
- f,
175
- m
173
+ a,
174
+ u,
175
+ p
176
176
  ]);
177
- return /* @__PURE__ */ u(p.Provider, {
177
+ return /* @__PURE__ */ d(h.Provider, {
178
178
  value: M,
179
- children: /* @__PURE__ */ d(y, {
180
- layout: h,
181
- children: [/* @__PURE__ */ u(x, { content: g }), b]
179
+ children: /* @__PURE__ */ f(x, {
180
+ layout: m,
181
+ children: [/* @__PURE__ */ d(C, { content: g }), y]
182
182
  })
183
183
  });
184
184
  }
185
185
  //#endregion
186
186
  //#region lib/DashboardTileContainer.tsx
187
- function w({ layout: e, children: t }) {
188
- let { tileContainer: n } = i(h);
189
- return n ? /* @__PURE__ */ u(n, {
187
+ function E({ layout: e, children: t }) {
188
+ let { tileContainer: n } = a(_);
189
+ return n ? /* @__PURE__ */ d(n, {
190
190
  layout: e,
191
191
  children: t
192
192
  }) : t({});
193
193
  }
194
194
  //#endregion
195
195
  //#region lib/useDashboardState.ts
196
- function T(e, n = []) {
197
- let { engine: r } = i(p), [o, c] = s(e), [l, u] = s(n);
198
- return t(o, e) || c(e), a(() => {
199
- let e = new f(r, o, (e) => {
196
+ function D(e, n = []) {
197
+ let { engine: r } = a(h), [i, s] = c(e), [l, u] = c(n);
198
+ return t(i, e) || s(e), o(() => {
199
+ let e = new p(r, i, (e) => {
200
200
  u((n) => t(e, n) ? n : e);
201
201
  });
202
202
  return () => {
203
203
  e.stop();
204
204
  };
205
- }, [r, o]), l;
205
+ }, [r, i]), l;
206
+ }
207
+ //#endregion
208
+ //#region lib/useNumberFormatter.ts
209
+ function O(e) {
210
+ let { locale: t } = e ?? {}, n = s(() => new m({ locale: t }), [t]);
211
+ return i((e, t) => n.format(e, t), [n]);
206
212
  }
207
213
  //#endregion
208
- export { C as Dashboard, p as DashboardContext, m as DashboardError, y as DashboardLayout, h as DashboardLayoutContext, v as DashboardLayoutError, w as DashboardTileContainer, b as DashboardTileError, x as DashboardTiles, g as getNodeKey, T as useDashboardState };
214
+ 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 };
@@ -0,0 +1,5 @@
1
+ import { NumberFormat } from '@rotorjs/dashboard';
2
+ export type NumberFormatterOptions = {
3
+ locale?: Intl.UnicodeBCP47LocaleIdentifier;
4
+ };
5
+ export declare function useNumberFormatter(init?: NumberFormatterOptions): (value: number, format?: NumberFormat) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotorjs/react",
3
- "version": "0.7.0",
3
+ "version": "0.9.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.1.0",
48
- "@types/react": "^19.1.12",
47
+ "@rotorjs/dashboard": "^0.3.1",
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.0",
51
+ "eslint": "^10.4.1",
52
52
  "eslint-config-prettier": "^10.1.8",
53
- "eslint-import-resolver-typescript": "^4.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.4",
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.3",
60
- "react": "^19.2.6",
61
- "react-dom": "^19.2.6",
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.59.4",
64
- "unplugin-dts": "^1.0.1",
65
- "vite": "^8.0.13"
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.1.0",
68
+ "@rotorjs/dashboard": "^0.3.1",
69
69
  "react": "^19.0.0"
70
70
  },
71
71
  "dependencies": {
72
- "@rotorjs/state": "^0.3.0",
72
+ "@rotorjs/state": "^0.6.1",
73
73
  "fast-deep-equal": "^3.1.3",
74
74
  "uuid": "^14.0.0"
75
75
  }