@rotorjs/react 0.1.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.
@@ -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>;
@@ -0,0 +1,6 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare function DashboardLayoutError({ id, error, children, }: PropsWithChildren<{
3
+ type?: 'error';
4
+ id?: string;
5
+ error: unknown;
6
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare function DashboardTileError({ id, error, }: {
2
+ type?: 'error';
3
+ id?: string;
4
+ error: unknown;
5
+ }): import("react/jsx-runtime").JSX.Element;
package/dist/main.d.ts CHANGED
@@ -2,6 +2,9 @@ export * from './Dashboard';
2
2
  export * from './DashboardContext';
3
3
  export * from './DashboardError';
4
4
  export * from './DashboardLayout';
5
+ export * from './DashboardLayoutContext';
6
+ export * from './DashboardLayoutError';
7
+ export * from './DashboardTileError';
5
8
  export * from './DashboardTiles';
6
9
  export * from './getKey';
7
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 C({ layout: e, children: r }) {
69
- let { layouts: a, defaultLayout: o } = n(b), s = i(() => ({
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]), c = e ?? o;
73
- if (!c) return null;
74
- let l = s[c.type];
75
- if (!l) {
76
- let e = s.error, n = {
77
- type: "error",
78
- error: `Invalid layout type "${c.type}"`
79
- };
80
- return /* @__PURE__ */ t(e, {
81
- ...n,
82
- key: S(n)
83
- });
84
- }
85
- return /* @__PURE__ */ t(l, {
86
- ...c,
87
- key: S(c)
88
- }, r);
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 w({ content: e }) {
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
- if (!r) {
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 T({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayout: l, tiles: d, layout: f, content: p, children: m }) {
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 T = i(() => ({
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: T,
184
- children: /* @__PURE__ */ c(C, {
201
+ value: C,
202
+ children: /* @__PURE__ */ c(E, {
185
203
  layout: f,
186
- children: [/* @__PURE__ */ s(w, { content: p }), m]
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 E(e, t = []) {
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 { T as Dashboard, b as DashboardContext, x as DashboardError, C as DashboardLayout, w as DashboardTiles, S as getKey, E as useDashboardState };
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.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Rotor",
5
5
  "author": {
6
6
  "name": "Aaron Burmeister"