@object-ui/plugin-dashboard 0.1.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/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +362 -0
- package/dist/index.umd.cjs +6 -0
- package/dist/src/DashboardRenderer.d.ts +7 -0
- package/dist/src/DashboardRenderer.d.ts.map +1 -0
- package/dist/src/MetricWidget.d.ts +15 -0
- package/dist/src/MetricWidget.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +43 -0
- package/src/DashboardRenderer.tsx +49 -0
- package/src/MetricWidget.tsx +59 -0
- package/src/index.tsx +47 -0
- package/tsconfig.json +19 -0
- package/vite.config.ts +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ObjectQL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# @object-ui/plugin-dashboard
|
|
2
|
+
|
|
3
|
+
Dashboard plugin for Object UI - Create beautiful dashboards with metrics, charts, and widgets.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Dashboard Layouts** - Grid-based dashboard layouts
|
|
8
|
+
- **Metric Cards** - Display KPIs and statistics
|
|
9
|
+
- **Widget System** - Modular widget components
|
|
10
|
+
- **Responsive** - Mobile-friendly dashboard grids
|
|
11
|
+
- **Customizable** - Tailwind CSS styling support
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @object-ui/plugin-dashboard
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Automatic Registration (Side-Effect Import)
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// In your app entry point (e.g., App.tsx or main.tsx)
|
|
25
|
+
import '@object-ui/plugin-dashboard';
|
|
26
|
+
|
|
27
|
+
// Now you can use dashboard types in your schemas
|
|
28
|
+
const schema = {
|
|
29
|
+
type: 'dashboard',
|
|
30
|
+
widgets: [
|
|
31
|
+
{
|
|
32
|
+
type: 'metric-card',
|
|
33
|
+
title: 'Total Sales',
|
|
34
|
+
value: '$123,456',
|
|
35
|
+
trend: 'up',
|
|
36
|
+
trendValue: '+12%'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Manual Registration
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { dashboardComponents } from '@object-ui/plugin-dashboard';
|
|
46
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
47
|
+
|
|
48
|
+
// Register dashboard components
|
|
49
|
+
Object.entries(dashboardComponents).forEach(([type, component]) => {
|
|
50
|
+
ComponentRegistry.register(type, component);
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Schema API
|
|
55
|
+
|
|
56
|
+
### Dashboard
|
|
57
|
+
|
|
58
|
+
Container for dashboard widgets:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
{
|
|
62
|
+
type: 'dashboard',
|
|
63
|
+
widgets: Widget[],
|
|
64
|
+
columns?: number, // Grid columns (default: 3)
|
|
65
|
+
gap?: number, // Gap between widgets
|
|
66
|
+
className?: string
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Metric Card
|
|
71
|
+
|
|
72
|
+
Display a single metric or KPI:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
{
|
|
76
|
+
type: 'metric-card',
|
|
77
|
+
title: string,
|
|
78
|
+
value: string | number,
|
|
79
|
+
icon?: string, // Lucide icon name
|
|
80
|
+
trend?: 'up' | 'down' | 'neutral',
|
|
81
|
+
trendValue?: string,
|
|
82
|
+
description?: string,
|
|
83
|
+
className?: string
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
### Basic Dashboard
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const schema = {
|
|
93
|
+
type: 'dashboard',
|
|
94
|
+
columns: 3,
|
|
95
|
+
gap: 4,
|
|
96
|
+
widgets: [
|
|
97
|
+
{
|
|
98
|
+
type: 'metric-card',
|
|
99
|
+
title: 'Total Users',
|
|
100
|
+
value: '1,234',
|
|
101
|
+
icon: 'users',
|
|
102
|
+
trend: 'up',
|
|
103
|
+
trendValue: '+12%',
|
|
104
|
+
description: 'vs last month'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'metric-card',
|
|
108
|
+
title: 'Revenue',
|
|
109
|
+
value: '$56,789',
|
|
110
|
+
icon: 'dollar-sign',
|
|
111
|
+
trend: 'up',
|
|
112
|
+
trendValue: '+8.2%',
|
|
113
|
+
description: 'vs last month'
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: 'metric-card',
|
|
117
|
+
title: 'Active Sessions',
|
|
118
|
+
value: '432',
|
|
119
|
+
icon: 'activity',
|
|
120
|
+
trend: 'down',
|
|
121
|
+
trendValue: '-3%',
|
|
122
|
+
description: 'vs last month'
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Dashboard with Charts
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const schema = {
|
|
132
|
+
type: 'dashboard',
|
|
133
|
+
widgets: [
|
|
134
|
+
{
|
|
135
|
+
type: 'metric-card',
|
|
136
|
+
title: 'Total Revenue',
|
|
137
|
+
value: '$123,456'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: 'card',
|
|
141
|
+
title: 'Sales Trend',
|
|
142
|
+
body: {
|
|
143
|
+
type: 'line-chart',
|
|
144
|
+
data: [/* chart data */],
|
|
145
|
+
height: 300
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'card',
|
|
150
|
+
title: 'Category Distribution',
|
|
151
|
+
body: {
|
|
152
|
+
type: 'pie-chart',
|
|
153
|
+
data: [/* chart data */]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Responsive Dashboard
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const schema = {
|
|
164
|
+
type: 'dashboard',
|
|
165
|
+
columns: 4,
|
|
166
|
+
gap: 6,
|
|
167
|
+
className: 'lg:grid-cols-4 md:grid-cols-2 sm:grid-cols-1',
|
|
168
|
+
widgets: [/* widgets */]
|
|
169
|
+
};
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Integration with Data Sources
|
|
173
|
+
|
|
174
|
+
Connect dashboard to live data:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { createObjectStackAdapter } from '@object-ui/data-objectstack';
|
|
178
|
+
|
|
179
|
+
const dataSource = createObjectStackAdapter({
|
|
180
|
+
baseUrl: 'https://api.example.com',
|
|
181
|
+
token: 'your-auth-token'
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const schema = {
|
|
185
|
+
type: 'dashboard',
|
|
186
|
+
dataSource,
|
|
187
|
+
widgets: [
|
|
188
|
+
{
|
|
189
|
+
type: 'metric-card',
|
|
190
|
+
title: 'Total Users',
|
|
191
|
+
value: '${data.metrics.totalUsers}',
|
|
192
|
+
trend: '${data.metrics.userTrend}'
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## TypeScript Support
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import type { DashboardSchema, MetricCardSchema } from '@object-ui/plugin-dashboard';
|
|
202
|
+
|
|
203
|
+
const metricCard: MetricCardSchema = {
|
|
204
|
+
type: 'metric-card',
|
|
205
|
+
title: 'Revenue',
|
|
206
|
+
value: '$123,456',
|
|
207
|
+
trend: 'up',
|
|
208
|
+
trendValue: '+12%'
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const dashboard: DashboardSchema = {
|
|
212
|
+
type: 'dashboard',
|
|
213
|
+
columns: 3,
|
|
214
|
+
widgets: [metricCard]
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Customization
|
|
219
|
+
|
|
220
|
+
All components support Tailwind CSS classes:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
const schema = {
|
|
224
|
+
type: 'metric-card',
|
|
225
|
+
title: 'Custom Metric',
|
|
226
|
+
value: '100',
|
|
227
|
+
className: 'bg-gradient-to-r from-blue-500 to-purple-600 text-white'
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { ComponentRegistry as L } from "@object-ui/core";
|
|
2
|
+
import te, { forwardRef as ae } from "react";
|
|
3
|
+
import { SchemaRenderer as ne } from "@object-ui/react";
|
|
4
|
+
import { cn as x, Card as oe, CardHeader as se, CardTitle as le, CardContent as ue } from "@object-ui/components";
|
|
5
|
+
import { ArrowUpIcon as ce, ArrowDownIcon as ie, MinusIcon as fe } from "lucide-react";
|
|
6
|
+
var v = { exports: {} }, b = {};
|
|
7
|
+
var D;
|
|
8
|
+
function me() {
|
|
9
|
+
if (D) return b;
|
|
10
|
+
D = 1;
|
|
11
|
+
var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), m = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
12
|
+
function o(f, s, l) {
|
|
13
|
+
var u = null;
|
|
14
|
+
if (l !== void 0 && (u = "" + l), s.key !== void 0 && (u = "" + s.key), "key" in s) {
|
|
15
|
+
l = {};
|
|
16
|
+
for (var p in s)
|
|
17
|
+
p !== "key" && (l[p] = s[p]);
|
|
18
|
+
} else l = s;
|
|
19
|
+
return s = l.ref, {
|
|
20
|
+
$$typeof: i,
|
|
21
|
+
type: f,
|
|
22
|
+
key: u,
|
|
23
|
+
ref: s !== void 0 ? s : null,
|
|
24
|
+
props: l
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return b.Fragment = m, b.jsx = o, b.jsxs = o, b;
|
|
28
|
+
}
|
|
29
|
+
var _ = {};
|
|
30
|
+
var F;
|
|
31
|
+
function de() {
|
|
32
|
+
return F || (F = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
33
|
+
function i(e) {
|
|
34
|
+
if (e == null) return null;
|
|
35
|
+
if (typeof e == "function")
|
|
36
|
+
return e.$$typeof === K ? null : e.displayName || e.name || null;
|
|
37
|
+
if (typeof e == "string") return e;
|
|
38
|
+
switch (e) {
|
|
39
|
+
case T:
|
|
40
|
+
return "Fragment";
|
|
41
|
+
case J:
|
|
42
|
+
return "Profiler";
|
|
43
|
+
case q:
|
|
44
|
+
return "StrictMode";
|
|
45
|
+
case H:
|
|
46
|
+
return "Suspense";
|
|
47
|
+
case B:
|
|
48
|
+
return "SuspenseList";
|
|
49
|
+
case Q:
|
|
50
|
+
return "Activity";
|
|
51
|
+
}
|
|
52
|
+
if (typeof e == "object")
|
|
53
|
+
switch (typeof e.tag == "number" && console.error(
|
|
54
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
55
|
+
), e.$$typeof) {
|
|
56
|
+
case V:
|
|
57
|
+
return "Portal";
|
|
58
|
+
case G:
|
|
59
|
+
return e.displayName || "Context";
|
|
60
|
+
case z:
|
|
61
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
62
|
+
case X:
|
|
63
|
+
var r = e.render;
|
|
64
|
+
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
65
|
+
case Z:
|
|
66
|
+
return r = e.displayName || null, r !== null ? r : i(e.type) || "Memo";
|
|
67
|
+
case h:
|
|
68
|
+
r = e._payload, e = e._init;
|
|
69
|
+
try {
|
|
70
|
+
return i(e(r));
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function m(e) {
|
|
77
|
+
return "" + e;
|
|
78
|
+
}
|
|
79
|
+
function o(e) {
|
|
80
|
+
try {
|
|
81
|
+
m(e);
|
|
82
|
+
var r = !1;
|
|
83
|
+
} catch {
|
|
84
|
+
r = !0;
|
|
85
|
+
}
|
|
86
|
+
if (r) {
|
|
87
|
+
r = console;
|
|
88
|
+
var t = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
89
|
+
return t.call(
|
|
90
|
+
r,
|
|
91
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
92
|
+
a
|
|
93
|
+
), m(e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function f(e) {
|
|
97
|
+
if (e === T) return "<>";
|
|
98
|
+
if (typeof e == "object" && e !== null && e.$$typeof === h)
|
|
99
|
+
return "<...>";
|
|
100
|
+
try {
|
|
101
|
+
var r = i(e);
|
|
102
|
+
return r ? "<" + r + ">" : "<...>";
|
|
103
|
+
} catch {
|
|
104
|
+
return "<...>";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function s() {
|
|
108
|
+
var e = y.A;
|
|
109
|
+
return e === null ? null : e.getOwner();
|
|
110
|
+
}
|
|
111
|
+
function l() {
|
|
112
|
+
return Error("react-stack-top-frame");
|
|
113
|
+
}
|
|
114
|
+
function u(e) {
|
|
115
|
+
if (S.call(e, "key")) {
|
|
116
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
117
|
+
if (r && r.isReactWarning) return !1;
|
|
118
|
+
}
|
|
119
|
+
return e.key !== void 0;
|
|
120
|
+
}
|
|
121
|
+
function p(e, r) {
|
|
122
|
+
function t() {
|
|
123
|
+
P || (P = !0, console.error(
|
|
124
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
125
|
+
r
|
|
126
|
+
));
|
|
127
|
+
}
|
|
128
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
129
|
+
get: t,
|
|
130
|
+
configurable: !0
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function W() {
|
|
134
|
+
var e = i(this.type);
|
|
135
|
+
return C[e] || (C[e] = !0, console.error(
|
|
136
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
137
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
138
|
+
}
|
|
139
|
+
function U(e, r, t, a, R, j) {
|
|
140
|
+
var n = t.ref;
|
|
141
|
+
return e = {
|
|
142
|
+
$$typeof: O,
|
|
143
|
+
type: e,
|
|
144
|
+
key: r,
|
|
145
|
+
props: t,
|
|
146
|
+
_owner: a
|
|
147
|
+
}, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
|
|
148
|
+
enumerable: !1,
|
|
149
|
+
get: W
|
|
150
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
151
|
+
configurable: !1,
|
|
152
|
+
enumerable: !1,
|
|
153
|
+
writable: !0,
|
|
154
|
+
value: 0
|
|
155
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
156
|
+
configurable: !1,
|
|
157
|
+
enumerable: !1,
|
|
158
|
+
writable: !0,
|
|
159
|
+
value: null
|
|
160
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
161
|
+
configurable: !1,
|
|
162
|
+
enumerable: !1,
|
|
163
|
+
writable: !0,
|
|
164
|
+
value: R
|
|
165
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
166
|
+
configurable: !1,
|
|
167
|
+
enumerable: !1,
|
|
168
|
+
writable: !0,
|
|
169
|
+
value: j
|
|
170
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
171
|
+
}
|
|
172
|
+
function k(e, r, t, a, R, j) {
|
|
173
|
+
var n = r.children;
|
|
174
|
+
if (n !== void 0)
|
|
175
|
+
if (a)
|
|
176
|
+
if (ee(n)) {
|
|
177
|
+
for (a = 0; a < n.length; a++)
|
|
178
|
+
N(n[a]);
|
|
179
|
+
Object.freeze && Object.freeze(n);
|
|
180
|
+
} else
|
|
181
|
+
console.error(
|
|
182
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
183
|
+
);
|
|
184
|
+
else N(n);
|
|
185
|
+
if (S.call(r, "key")) {
|
|
186
|
+
n = i(e);
|
|
187
|
+
var d = Object.keys(r).filter(function(re) {
|
|
188
|
+
return re !== "key";
|
|
189
|
+
});
|
|
190
|
+
a = 0 < d.length ? "{key: someKey, " + d.join(": ..., ") + ": ...}" : "{key: someKey}", I[n + a] || (d = 0 < d.length ? "{" + d.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
191
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
192
|
+
let props = %s;
|
|
193
|
+
<%s {...props} />
|
|
194
|
+
React keys must be passed directly to JSX without using spread:
|
|
195
|
+
let props = %s;
|
|
196
|
+
<%s key={someKey} {...props} />`,
|
|
197
|
+
a,
|
|
198
|
+
n,
|
|
199
|
+
d,
|
|
200
|
+
n
|
|
201
|
+
), I[n + a] = !0);
|
|
202
|
+
}
|
|
203
|
+
if (n = null, t !== void 0 && (o(t), n = "" + t), u(r) && (o(r.key), n = "" + r.key), "key" in r) {
|
|
204
|
+
t = {};
|
|
205
|
+
for (var w in r)
|
|
206
|
+
w !== "key" && (t[w] = r[w]);
|
|
207
|
+
} else t = r;
|
|
208
|
+
return n && p(
|
|
209
|
+
t,
|
|
210
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
211
|
+
), U(
|
|
212
|
+
e,
|
|
213
|
+
n,
|
|
214
|
+
t,
|
|
215
|
+
s(),
|
|
216
|
+
R,
|
|
217
|
+
j
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
function N(e) {
|
|
221
|
+
A(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === h && (e._payload.status === "fulfilled" ? A(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
222
|
+
}
|
|
223
|
+
function A(e) {
|
|
224
|
+
return typeof e == "object" && e !== null && e.$$typeof === O;
|
|
225
|
+
}
|
|
226
|
+
var E = te, O = /* @__PURE__ */ Symbol.for("react.transitional.element"), V = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), J = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), G = /* @__PURE__ */ Symbol.for("react.context"), X = /* @__PURE__ */ Symbol.for("react.forward_ref"), H = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), Z = /* @__PURE__ */ Symbol.for("react.memo"), h = /* @__PURE__ */ Symbol.for("react.lazy"), Q = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), y = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, S = Object.prototype.hasOwnProperty, ee = Array.isArray, g = console.createTask ? console.createTask : function() {
|
|
227
|
+
return null;
|
|
228
|
+
};
|
|
229
|
+
E = {
|
|
230
|
+
react_stack_bottom_frame: function(e) {
|
|
231
|
+
return e();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var P, C = {}, $ = E.react_stack_bottom_frame.bind(
|
|
235
|
+
E,
|
|
236
|
+
l
|
|
237
|
+
)(), Y = g(f(l)), I = {};
|
|
238
|
+
_.Fragment = T, _.jsx = function(e, r, t) {
|
|
239
|
+
var a = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
240
|
+
return k(
|
|
241
|
+
e,
|
|
242
|
+
r,
|
|
243
|
+
t,
|
|
244
|
+
!1,
|
|
245
|
+
a ? Error("react-stack-top-frame") : $,
|
|
246
|
+
a ? g(f(e)) : Y
|
|
247
|
+
);
|
|
248
|
+
}, _.jsxs = function(e, r, t) {
|
|
249
|
+
var a = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
250
|
+
return k(
|
|
251
|
+
e,
|
|
252
|
+
r,
|
|
253
|
+
t,
|
|
254
|
+
!0,
|
|
255
|
+
a ? Error("react-stack-top-frame") : $,
|
|
256
|
+
a ? g(f(e)) : Y
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
})()), _;
|
|
260
|
+
}
|
|
261
|
+
var M;
|
|
262
|
+
function pe() {
|
|
263
|
+
return M || (M = 1, process.env.NODE_ENV === "production" ? v.exports = me() : v.exports = de()), v.exports;
|
|
264
|
+
}
|
|
265
|
+
var c = pe();
|
|
266
|
+
const be = ae(
|
|
267
|
+
({ schema: i, className: m, ...o }, f) => {
|
|
268
|
+
const s = i.columns || 3, l = i.gap || 4;
|
|
269
|
+
return /* @__PURE__ */ c.jsx(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
ref: f,
|
|
273
|
+
className: x("grid", m),
|
|
274
|
+
style: {
|
|
275
|
+
gridTemplateColumns: `repeat(${s}, minmax(0, 1fr))`,
|
|
276
|
+
gap: `${l * 0.25}rem`
|
|
277
|
+
},
|
|
278
|
+
...o,
|
|
279
|
+
children: i.widgets?.map((u) => /* @__PURE__ */ c.jsxs(
|
|
280
|
+
"div",
|
|
281
|
+
{
|
|
282
|
+
className: x("border rounded-lg p-4 bg-card text-card-foreground shadow-sm"),
|
|
283
|
+
style: u.layout ? {
|
|
284
|
+
gridColumn: `span ${u.layout.w}`,
|
|
285
|
+
gridRow: `span ${u.layout.h}`
|
|
286
|
+
} : void 0,
|
|
287
|
+
children: [
|
|
288
|
+
u.title && /* @__PURE__ */ c.jsx("h3", { className: "font-semibold mb-2", children: u.title }),
|
|
289
|
+
/* @__PURE__ */ c.jsx(ne, { schema: u.component })
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
u.id
|
|
293
|
+
))
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
), _e = ({
|
|
298
|
+
label: i,
|
|
299
|
+
value: m,
|
|
300
|
+
trend: o,
|
|
301
|
+
icon: f,
|
|
302
|
+
className: s,
|
|
303
|
+
description: l,
|
|
304
|
+
...u
|
|
305
|
+
}) => /* @__PURE__ */ c.jsxs(oe, { className: x("h-full", s), ...u, children: [
|
|
306
|
+
/* @__PURE__ */ c.jsxs(se, { className: "flex flex-row items-center justify-between space-y-0 pb-2", children: [
|
|
307
|
+
/* @__PURE__ */ c.jsx(le, { className: "text-sm font-medium", children: i }),
|
|
308
|
+
f && /* @__PURE__ */ c.jsx("div", { className: "h-4 w-4 text-muted-foreground", children: f })
|
|
309
|
+
] }),
|
|
310
|
+
/* @__PURE__ */ c.jsxs(ue, { children: [
|
|
311
|
+
/* @__PURE__ */ c.jsx("div", { className: "text-2xl font-bold", children: m }),
|
|
312
|
+
(o || l) && /* @__PURE__ */ c.jsxs("p", { className: "text-xs text-muted-foreground flex items-center mt-1", children: [
|
|
313
|
+
o && /* @__PURE__ */ c.jsxs("span", { className: x(
|
|
314
|
+
"flex items-center mr-2",
|
|
315
|
+
o.direction === "up" && "text-green-500",
|
|
316
|
+
o.direction === "down" && "text-red-500",
|
|
317
|
+
o.direction === "neutral" && "text-yellow-500"
|
|
318
|
+
), children: [
|
|
319
|
+
o.direction === "up" && /* @__PURE__ */ c.jsx(ce, { className: "h-3 w-3 mr-1" }),
|
|
320
|
+
o.direction === "down" && /* @__PURE__ */ c.jsx(ie, { className: "h-3 w-3 mr-1" }),
|
|
321
|
+
o.direction === "neutral" && /* @__PURE__ */ c.jsx(fe, { className: "h-3 w-3 mr-1" }),
|
|
322
|
+
o.value,
|
|
323
|
+
"%"
|
|
324
|
+
] }),
|
|
325
|
+
l || o?.label
|
|
326
|
+
] })
|
|
327
|
+
] })
|
|
328
|
+
] });
|
|
329
|
+
L.register(
|
|
330
|
+
"dashboard",
|
|
331
|
+
be,
|
|
332
|
+
{
|
|
333
|
+
label: "Dashboard",
|
|
334
|
+
category: "Complex",
|
|
335
|
+
icon: "layout-dashboard",
|
|
336
|
+
inputs: [
|
|
337
|
+
{ name: "columns", type: "number", label: "Columns", defaultValue: 3 },
|
|
338
|
+
{ name: "gap", type: "number", label: "Gap", defaultValue: 4 },
|
|
339
|
+
{ name: "className", type: "string", label: "CSS Class" }
|
|
340
|
+
],
|
|
341
|
+
defaultProps: {
|
|
342
|
+
columns: 3,
|
|
343
|
+
widgets: []
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
L.register(
|
|
348
|
+
"metric",
|
|
349
|
+
_e,
|
|
350
|
+
{
|
|
351
|
+
label: "Metric Card",
|
|
352
|
+
category: "Dashboard",
|
|
353
|
+
inputs: [
|
|
354
|
+
{ name: "label", type: "string", label: "Label" },
|
|
355
|
+
{ name: "value", type: "string", label: "Value" }
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
export {
|
|
360
|
+
be as DashboardRenderer,
|
|
361
|
+
_e as MetricWidget
|
|
362
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(f,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@object-ui/core"),require("react"),require("@object-ui/react"),require("@object-ui/components"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","@object-ui/core","react","@object-ui/react","@object-ui/components","lucide-react"],p):(f=typeof globalThis<"u"?globalThis:f||self,p(f.ObjectUIPluginDashboard={},f.ObjectUICore,f.React,f.ObjectUIReact,f.ObjectUIComponents,f.lucideReact))})(this,(function(f,p,N,z,m,h){"use strict";var x={exports:{}},E={};var A;function G(){if(A)return E;A=1;var i=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function o(d,l,c){var u=null;if(c!==void 0&&(u=""+c),l.key!==void 0&&(u=""+l.key),"key"in l){c={};for(var v in l)v!=="key"&&(c[v]=l[v])}else c=l;return l=c.ref,{$$typeof:i,type:d,key:u,ref:l!==void 0?l:null,props:c}}return E.Fragment=b,E.jsx=o,E.jsxs=o,E}var R={};var P;function X(){return P||(P=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case ee:return"Profiler";case K:return"StrictMode";case ne:return"Suspense";case oe:return"SuspenseList";case le:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Q:return"Portal";case te:return e.displayName||"Context";case re:return(e._context.displayName||"Context")+".Consumer";case ae:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return r=e.displayName||null,r!==null?r:i(e.type)||"Memo";case g:r=e._payload,e=e._init;try{return i(e(r))}catch{}}return null}function b(e){return""+e}function o(e){try{b(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),b(e)}}function d(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===g)return"<...>";try{var r=i(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=w.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function u(e){if(F.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function v(e,r){function t(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function B(){var e=i(this.type);return L[e]||(L[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function Z(e,r,t,a,j,k){var n=t.ref;return e={$$typeof:U,type:e,key:r,props:t,_owner:a},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:B}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:j}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:k}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function D(e,r,t,a,j,k){var n=r.children;if(n!==void 0)if(a)if(ue(n)){for(a=0;a<n.length;a++)$(n[a]);Object.freeze&&Object.freeze(n)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $(n);if(F.call(r,"key")){n=i(e);var _=Object.keys(r).filter(function(ie){return ie!=="key"});a=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",J[n+a]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,a,n,_,n),J[n+a]=!0)}if(n=null,t!==void 0&&(o(t),n=""+t),u(r)&&(o(r.key),n=""+r.key),"key"in r){t={};for(var S in r)S!=="key"&&(t[S]=r[S])}else t=r;return n&&v(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),Z(e,n,t,l(),j,k)}function $(e){M(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===g&&(e._payload.status==="fulfilled"?M(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function M(e){return typeof e=="object"&&e!==null&&e.$$typeof===U}var T=N,U=Symbol.for("react.transitional.element"),Q=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),te=Symbol.for("react.context"),ae=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),le=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),w=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,ue=Array.isArray,O=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(e){return e()}};var W,L={},q=T.react_stack_bottom_frame.bind(T,c)(),V=O(d(c)),J={};R.Fragment=y,R.jsx=function(e,r,t){var a=1e4>w.recentlyCreatedOwnerStacks++;return D(e,r,t,!1,a?Error("react-stack-top-frame"):q,a?O(d(e)):V)},R.jsxs=function(e,r,t){var a=1e4>w.recentlyCreatedOwnerStacks++;return D(e,r,t,!0,a?Error("react-stack-top-frame"):q,a?O(d(e)):V)}})()),R}var C;function H(){return C||(C=1,process.env.NODE_ENV==="production"?x.exports=G():x.exports=X()),x.exports}var s=H();const I=N.forwardRef(({schema:i,className:b,...o},d)=>{const l=i.columns||3,c=i.gap||4;return s.jsx("div",{ref:d,className:m.cn("grid",b),style:{gridTemplateColumns:`repeat(${l}, minmax(0, 1fr))`,gap:`${c*.25}rem`},...o,children:i.widgets?.map(u=>s.jsxs("div",{className:m.cn("border rounded-lg p-4 bg-card text-card-foreground shadow-sm"),style:u.layout?{gridColumn:`span ${u.layout.w}`,gridRow:`span ${u.layout.h}`}:void 0,children:[u.title&&s.jsx("h3",{className:"font-semibold mb-2",children:u.title}),s.jsx(z.SchemaRenderer,{schema:u.component})]},u.id))})}),Y=({label:i,value:b,trend:o,icon:d,className:l,description:c,...u})=>s.jsxs(m.Card,{className:m.cn("h-full",l),...u,children:[s.jsxs(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[s.jsx(m.CardTitle,{className:"text-sm font-medium",children:i}),d&&s.jsx("div",{className:"h-4 w-4 text-muted-foreground",children:d})]}),s.jsxs(m.CardContent,{children:[s.jsx("div",{className:"text-2xl font-bold",children:b}),(o||c)&&s.jsxs("p",{className:"text-xs text-muted-foreground flex items-center mt-1",children:[o&&s.jsxs("span",{className:m.cn("flex items-center mr-2",o.direction==="up"&&"text-green-500",o.direction==="down"&&"text-red-500",o.direction==="neutral"&&"text-yellow-500"),children:[o.direction==="up"&&s.jsx(h.ArrowUpIcon,{className:"h-3 w-3 mr-1"}),o.direction==="down"&&s.jsx(h.ArrowDownIcon,{className:"h-3 w-3 mr-1"}),o.direction==="neutral"&&s.jsx(h.MinusIcon,{className:"h-3 w-3 mr-1"}),o.value,"%"]}),c||o?.label]})]})]});p.ComponentRegistry.register("dashboard",I,{label:"Dashboard",category:"Complex",icon:"layout-dashboard",inputs:[{name:"columns",type:"number",label:"Columns",defaultValue:3},{name:"gap",type:"number",label:"Gap",defaultValue:4},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{columns:3,widgets:[]}}),p.ComponentRegistry.register("metric",Y,{label:"Metric Card",category:"Dashboard",inputs:[{name:"label",type:"string",label:"Label"},{name:"value",type:"string",label:"Value"}]}),f.DashboardRenderer=I,f.MetricWidget=Y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DashboardSchema } from '@object-ui/types';
|
|
2
|
+
export declare const DashboardRenderer: import('react').ForwardRefExoticComponent<Omit<{
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
schema: DashboardSchema;
|
|
5
|
+
className?: string;
|
|
6
|
+
}, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
7
|
+
//# sourceMappingURL=DashboardRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardRenderer.d.ts","sourceRoot":"","sources":["../../src/DashboardRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,kBAAkB,CAAC;AAK/E,eAAO,MAAM,iBAAiB;;YAAwC,eAAe;gBAAc,MAAM;0DAkCxG,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface MetricWidgetProps {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
trend?: {
|
|
6
|
+
value: number;
|
|
7
|
+
label?: string;
|
|
8
|
+
direction?: 'up' | 'down' | 'neutral';
|
|
9
|
+
};
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const MetricWidget: ({ label, value, trend, icon, className, description, ...props }: MetricWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=MetricWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricWidget.d.ts","sourceRoot":"","sources":["../../src/MetricWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;KACvC,CAAC;IACF,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,iEAQ1B,iBAAiB,4CAgCnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@object-ui/plugin-dashboard",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Dashboard plugin for Object UI",
|
|
7
|
+
"main": "dist/index.umd.cjs",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.umd.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"clsx": "^2.1.0",
|
|
19
|
+
"lucide-react": "^0.563.0",
|
|
20
|
+
"react": "^18.2.0",
|
|
21
|
+
"react-dom": "^18.2.0",
|
|
22
|
+
"tailwind-merge": "^2.2.1",
|
|
23
|
+
"@object-ui/components": "0.3.0",
|
|
24
|
+
"@object-ui/core": "0.3.0",
|
|
25
|
+
"@object-ui/react": "0.3.0",
|
|
26
|
+
"@object-ui/types": "0.3.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.0.0",
|
|
30
|
+
"react-dom": "^18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vite": "^7.3.1",
|
|
36
|
+
"vite-plugin-dts": "^4.5.4"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"lint": "eslint ."
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
10
|
+
import type { DashboardSchema, DashboardWidgetSchema } from '@object-ui/types';
|
|
11
|
+
import { SchemaRenderer } from '@object-ui/react';
|
|
12
|
+
import { cn } from '@object-ui/components';
|
|
13
|
+
import { forwardRef } from 'react';
|
|
14
|
+
|
|
15
|
+
export const DashboardRenderer = forwardRef<HTMLDivElement, { schema: DashboardSchema; className?: string; [key: string]: any }>(
|
|
16
|
+
({ schema, className, ...props }, ref) => {
|
|
17
|
+
const columns = schema.columns || 3;
|
|
18
|
+
const gap = schema.gap || 4;
|
|
19
|
+
|
|
20
|
+
// Use style to convert gap number to pixels or use tailwind classes if possible
|
|
21
|
+
// Here using inline style for grid gap which maps to 0.25rem * 4 * gap = gap rem
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn("grid", className)}
|
|
27
|
+
style={{
|
|
28
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
|
|
29
|
+
gap: `${gap * 0.25}rem`
|
|
30
|
+
}}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{schema.widgets?.map((widget: DashboardWidgetSchema) => (
|
|
34
|
+
<div
|
|
35
|
+
key={widget.id}
|
|
36
|
+
className={cn("border rounded-lg p-4 bg-card text-card-foreground shadow-sm")}
|
|
37
|
+
style={widget.layout ? {
|
|
38
|
+
gridColumn: `span ${widget.layout.w}`,
|
|
39
|
+
gridRow: `span ${widget.layout.h}`
|
|
40
|
+
}: undefined}
|
|
41
|
+
>
|
|
42
|
+
{widget.title && <h3 className="font-semibold mb-2">{widget.title}</h3>}
|
|
43
|
+
<SchemaRenderer schema={widget.component} />
|
|
44
|
+
</div>
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@object-ui/components';
|
|
3
|
+
import { cn } from '@object-ui/components';
|
|
4
|
+
import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from 'lucide-react';
|
|
5
|
+
|
|
6
|
+
export interface MetricWidgetProps {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string | number;
|
|
9
|
+
trend?: {
|
|
10
|
+
value: number;
|
|
11
|
+
label?: string;
|
|
12
|
+
direction?: 'up' | 'down' | 'neutral';
|
|
13
|
+
};
|
|
14
|
+
icon?: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const MetricWidget = ({
|
|
20
|
+
label,
|
|
21
|
+
value,
|
|
22
|
+
trend,
|
|
23
|
+
icon,
|
|
24
|
+
className,
|
|
25
|
+
description,
|
|
26
|
+
...props
|
|
27
|
+
}: MetricWidgetProps) => {
|
|
28
|
+
return (
|
|
29
|
+
<Card className={cn("h-full", className)} {...props}>
|
|
30
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
31
|
+
<CardTitle className="text-sm font-medium">
|
|
32
|
+
{label}
|
|
33
|
+
</CardTitle>
|
|
34
|
+
{icon && <div className="h-4 w-4 text-muted-foreground">{icon}</div>}
|
|
35
|
+
</CardHeader>
|
|
36
|
+
<CardContent>
|
|
37
|
+
<div className="text-2xl font-bold">{value}</div>
|
|
38
|
+
{(trend || description) && (
|
|
39
|
+
<p className="text-xs text-muted-foreground flex items-center mt-1">
|
|
40
|
+
{trend && (
|
|
41
|
+
<span className={cn(
|
|
42
|
+
"flex items-center mr-2",
|
|
43
|
+
trend.direction === 'up' && "text-green-500",
|
|
44
|
+
trend.direction === 'down' && "text-red-500",
|
|
45
|
+
trend.direction === 'neutral' && "text-yellow-500"
|
|
46
|
+
)}>
|
|
47
|
+
{trend.direction === 'up' && <ArrowUpIcon className="h-3 w-3 mr-1" />}
|
|
48
|
+
{trend.direction === 'down' && <ArrowDownIcon className="h-3 w-3 mr-1" />}
|
|
49
|
+
{trend.direction === 'neutral' && <MinusIcon className="h-3 w-3 mr-1" />}
|
|
50
|
+
{trend.value}%
|
|
51
|
+
</span>
|
|
52
|
+
)}
|
|
53
|
+
{description || trend?.label}
|
|
54
|
+
</p>
|
|
55
|
+
)}
|
|
56
|
+
</CardContent>
|
|
57
|
+
</Card>
|
|
58
|
+
);
|
|
59
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
10
|
+
import { DashboardRenderer } from './DashboardRenderer';
|
|
11
|
+
import { MetricWidget } from './MetricWidget';
|
|
12
|
+
|
|
13
|
+
export { DashboardRenderer, MetricWidget };
|
|
14
|
+
|
|
15
|
+
// Register dashboard component
|
|
16
|
+
ComponentRegistry.register(
|
|
17
|
+
'dashboard',
|
|
18
|
+
DashboardRenderer,
|
|
19
|
+
{
|
|
20
|
+
label: 'Dashboard',
|
|
21
|
+
category: 'Complex',
|
|
22
|
+
icon: 'layout-dashboard',
|
|
23
|
+
inputs: [
|
|
24
|
+
{ name: 'columns', type: 'number', label: 'Columns', defaultValue: 3 },
|
|
25
|
+
{ name: 'gap', type: 'number', label: 'Gap', defaultValue: 4 },
|
|
26
|
+
{ name: 'className', type: 'string', label: 'CSS Class' }
|
|
27
|
+
],
|
|
28
|
+
defaultProps: {
|
|
29
|
+
columns: 3,
|
|
30
|
+
widgets: []
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Register metric component
|
|
36
|
+
ComponentRegistry.register(
|
|
37
|
+
'metric',
|
|
38
|
+
MetricWidget,
|
|
39
|
+
{
|
|
40
|
+
label: 'Metric Card',
|
|
41
|
+
category: 'Dashboard',
|
|
42
|
+
inputs: [
|
|
43
|
+
{ name: 'label', type: 'string', label: 'Label' },
|
|
44
|
+
{ name: 'value', type: 'string', label: 'Value' },
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"jsx": "react-jsx",
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/*": ["src/*"]
|
|
9
|
+
},
|
|
10
|
+
// Removed explicit rootDir to prevent file not under rootDir errors when importing from workspace dependencies
|
|
11
|
+
"noEmit": false,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"],
|
|
18
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]
|
|
19
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [
|
|
8
|
+
react(),
|
|
9
|
+
dts({
|
|
10
|
+
insertTypesEntry: true,
|
|
11
|
+
include: ['src'],
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
build: {
|
|
15
|
+
lib: {
|
|
16
|
+
entry: resolve(__dirname, 'src/index.tsx'),
|
|
17
|
+
name: 'ObjectUIPluginDashboard',
|
|
18
|
+
fileName: 'index',
|
|
19
|
+
},
|
|
20
|
+
rollupOptions: {
|
|
21
|
+
external: [
|
|
22
|
+
'react',
|
|
23
|
+
'react-dom',
|
|
24
|
+
'@object-ui/components',
|
|
25
|
+
'@object-ui/core',
|
|
26
|
+
'@object-ui/react',
|
|
27
|
+
'@object-ui/types',
|
|
28
|
+
'tailwind-merge',
|
|
29
|
+
'clsx',
|
|
30
|
+
'lucide-react'
|
|
31
|
+
],
|
|
32
|
+
output: {
|
|
33
|
+
globals: {
|
|
34
|
+
react: 'React',
|
|
35
|
+
'react-dom': 'ReactDOM',
|
|
36
|
+
'@object-ui/components': 'ObjectUIComponents',
|
|
37
|
+
'@object-ui/core': 'ObjectUICore',
|
|
38
|
+
'@object-ui/react': 'ObjectUIReact',
|
|
39
|
+
'@object-ui/types': 'ObjectUITypes',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|