@object-ui/plugin-charts 0.3.0 → 0.3.1
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/CHANGELOG.md +11 -0
- package/README.md +4 -4
- package/dist/AdvancedChartImpl-DJcN3TPx.js +2530 -0
- package/dist/BarChart-RKJxvg5Y.js +18218 -0
- package/dist/ChartImpl-CE1UGkNR.js +275 -0
- package/dist/index-CTfEtwhn.js +387 -0
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +50 -74
- package/dist/src/ChartContainerImpl.d.ts +7 -0
- package/dist/src/ChartImpl.d.ts +7 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/types.d.ts +2 -2
- package/package.json +18 -8
- package/src/AdvancedChartImpl.tsx +8 -0
- package/src/ChartContainerImpl.tsx +8 -0
- package/src/ChartImpl.tsx +8 -0
- package/src/index.test.ts +14 -6
- package/src/index.tsx +14 -4
- package/src/types.ts +10 -2
- package/vite.config.ts +10 -0
- package/dist/AdvancedChartImpl-LUnT2ZAf.js +0 -2320
- package/dist/BarChart-CRc8MAtI.js +0 -17766
- package/dist/ChartImpl-DiqV9Evl.js +0 -79
- package/dist/index-BcjHuFVN.js +0 -738
- package/dist/src/index.test.d.ts +0 -1
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ResponsiveContainer, Tooltip, Legend } from 'recharts';
|
|
2
|
+
/**
|
|
3
|
+
* ObjectUI
|
|
4
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
2
9
|
import * as React from "react";
|
|
3
10
|
declare const THEMES: {
|
|
4
11
|
readonly light: "";
|
package/dist/src/ChartImpl.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export interface ChartImplProps {
|
|
2
9
|
data?: Array<Record<string, any>>;
|
|
3
10
|
dataKey?: string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -37,6 +37,6 @@ export interface ChartRendererProps {
|
|
|
37
37
|
*/
|
|
38
38
|
export declare const ChartRenderer: React.FC<ChartRendererProps>;
|
|
39
39
|
export declare const chartComponents: {
|
|
40
|
-
'chart
|
|
40
|
+
'bar-chart': React.FC<ChartBarRendererProps>;
|
|
41
41
|
chart: React.FC<ChartRendererProps>;
|
|
42
42
|
};
|
package/dist/src/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { BaseSchema } from '@object-ui/types';
|
|
|
8
8
|
* import type { BarChartSchema } from '@object-ui/plugin-charts';
|
|
9
9
|
*
|
|
10
10
|
* const chartSchema: BarChartSchema = {
|
|
11
|
-
* type: 'chart
|
|
11
|
+
* type: 'bar-chart',
|
|
12
12
|
* data: [
|
|
13
13
|
* { name: 'Jan', value: 400 },
|
|
14
14
|
* { name: 'Feb', value: 300 }
|
|
@@ -19,7 +19,7 @@ import { BaseSchema } from '@object-ui/types';
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export interface BarChartSchema extends BaseSchema {
|
|
22
|
-
type: 'chart
|
|
22
|
+
type: 'bar-chart';
|
|
23
23
|
/**
|
|
24
24
|
* Array of data points to display in the chart.
|
|
25
25
|
*/
|
package/package.json
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-charts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"description": "Chart components plugin for Object UI, powered by Recharts",
|
|
7
|
+
"homepage": "https://www.objectui.org",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/objectstack-ai/objectui.git",
|
|
11
|
+
"directory": "packages/plugin-charts"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/objectstack-ai/objectui/issues"
|
|
15
|
+
},
|
|
6
16
|
"main": "dist/index.umd.cjs",
|
|
7
17
|
"module": "dist/index.js",
|
|
8
18
|
"types": "dist/index.d.ts",
|
|
@@ -14,19 +24,19 @@
|
|
|
14
24
|
}
|
|
15
25
|
},
|
|
16
26
|
"dependencies": {
|
|
17
|
-
"recharts": "^
|
|
18
|
-
"@object-ui/components": "0.3.
|
|
19
|
-
"@object-ui/core": "0.3.
|
|
20
|
-
"@object-ui/react": "0.3.
|
|
21
|
-
"@object-ui/types": "0.3.
|
|
27
|
+
"recharts": "^3.7.0",
|
|
28
|
+
"@object-ui/components": "0.3.1",
|
|
29
|
+
"@object-ui/core": "0.3.1",
|
|
30
|
+
"@object-ui/react": "0.3.1",
|
|
31
|
+
"@object-ui/types": "0.3.1"
|
|
22
32
|
},
|
|
23
33
|
"peerDependencies": {
|
|
24
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
25
35
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
26
36
|
},
|
|
27
37
|
"devDependencies": {
|
|
28
|
-
"@types/react": "^
|
|
29
|
-
"@types/react-dom": "^
|
|
38
|
+
"@types/react": "^19.2.9",
|
|
39
|
+
"@types/react-dom": "^19.2.3",
|
|
30
40
|
"@vitejs/plugin-react": "^4.2.1",
|
|
31
41
|
"typescript": "^5.9.3",
|
|
32
42
|
"vite": "^7.3.1",
|
package/src/ChartImpl.tsx
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
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
|
+
|
|
1
9
|
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
|
2
10
|
|
|
3
11
|
export interface ChartImplProps {
|
package/src/index.test.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
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
|
+
|
|
1
9
|
import { describe, it, expect, beforeAll } from 'vitest';
|
|
2
10
|
import { ComponentRegistry } from '@object-ui/core';
|
|
3
11
|
|
|
@@ -7,14 +15,14 @@ describe('Plugin Charts', () => {
|
|
|
7
15
|
await import('./index');
|
|
8
16
|
});
|
|
9
17
|
|
|
10
|
-
describe('chart
|
|
18
|
+
describe('bar-chart component', () => {
|
|
11
19
|
it('should be registered in ComponentRegistry', () => {
|
|
12
|
-
const chartBarRenderer = ComponentRegistry.get('chart
|
|
20
|
+
const chartBarRenderer = ComponentRegistry.get('bar-chart');
|
|
13
21
|
expect(chartBarRenderer).toBeDefined();
|
|
14
22
|
});
|
|
15
23
|
|
|
16
24
|
it('should have proper metadata', () => {
|
|
17
|
-
const config = ComponentRegistry.getConfig('chart
|
|
25
|
+
const config = ComponentRegistry.getConfig('bar-chart');
|
|
18
26
|
expect(config).toBeDefined();
|
|
19
27
|
expect(config?.label).toBe('Bar Chart');
|
|
20
28
|
expect(config?.category).toBe('plugin');
|
|
@@ -23,7 +31,7 @@ describe('Plugin Charts', () => {
|
|
|
23
31
|
});
|
|
24
32
|
|
|
25
33
|
it('should have expected inputs', () => {
|
|
26
|
-
const config = ComponentRegistry.getConfig('chart
|
|
34
|
+
const config = ComponentRegistry.getConfig('bar-chart');
|
|
27
35
|
const inputNames = config?.inputs?.map((input: any) => input.name) || [];
|
|
28
36
|
|
|
29
37
|
expect(inputNames).toContain('data');
|
|
@@ -34,7 +42,7 @@ describe('Plugin Charts', () => {
|
|
|
34
42
|
});
|
|
35
43
|
|
|
36
44
|
it('should have data as required input', () => {
|
|
37
|
-
const config = ComponentRegistry.getConfig('chart
|
|
45
|
+
const config = ComponentRegistry.getConfig('bar-chart');
|
|
38
46
|
const dataInput = config?.inputs?.find((input: any) => input.name === 'data');
|
|
39
47
|
|
|
40
48
|
expect(dataInput).toBeDefined();
|
|
@@ -43,7 +51,7 @@ describe('Plugin Charts', () => {
|
|
|
43
51
|
});
|
|
44
52
|
|
|
45
53
|
it('should have sensible default props', () => {
|
|
46
|
-
const config = ComponentRegistry.getConfig('chart
|
|
54
|
+
const config = ComponentRegistry.getConfig('bar-chart');
|
|
47
55
|
const defaults = config?.defaultProps;
|
|
48
56
|
|
|
49
57
|
expect(defaults).toBeDefined();
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
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
|
+
|
|
1
9
|
import React, { Suspense } from 'react';
|
|
2
10
|
import { ComponentRegistry } from '@object-ui/core';
|
|
3
11
|
import { Skeleton } from '@object-ui/components';
|
|
12
|
+
import type { ChartConfig } from './ChartContainerImpl';
|
|
4
13
|
|
|
5
14
|
// Export types for external use
|
|
6
15
|
export type { BarChartSchema } from './types';
|
|
@@ -44,7 +53,7 @@ export const ChartBarRenderer: React.FC<ChartBarRendererProps> = ({ schema }) =>
|
|
|
44
53
|
|
|
45
54
|
// Register the component with the ComponentRegistry
|
|
46
55
|
ComponentRegistry.register(
|
|
47
|
-
'chart
|
|
56
|
+
'bar-chart',
|
|
48
57
|
ChartBarRenderer,
|
|
49
58
|
{
|
|
50
59
|
label: 'Bar Chart',
|
|
@@ -116,10 +125,11 @@ export const ChartRenderer: React.FC<ChartRendererProps> = ({ schema }) => {
|
|
|
116
125
|
// 3. Auto-generate config/colors if missing
|
|
117
126
|
if (!config && series) {
|
|
118
127
|
const colors = (schema as any).colors || ['hsl(var(--chart-1))', 'hsl(var(--chart-2))', 'hsl(var(--chart-3))'];
|
|
119
|
-
|
|
128
|
+
const newConfig: ChartConfig = {};
|
|
120
129
|
series.forEach((s: any, idx: number) => {
|
|
121
|
-
|
|
130
|
+
newConfig[s.dataKey] = { label: s.dataKey, color: colors[idx % colors.length] };
|
|
122
131
|
});
|
|
132
|
+
config = newConfig;
|
|
123
133
|
}
|
|
124
134
|
|
|
125
135
|
return {
|
|
@@ -196,6 +206,6 @@ ComponentRegistry.register(
|
|
|
196
206
|
|
|
197
207
|
// Standard Export Protocol - for manual integration
|
|
198
208
|
export const chartComponents = {
|
|
199
|
-
'chart
|
|
209
|
+
'bar-chart': ChartBarRenderer,
|
|
200
210
|
'chart': ChartRenderer,
|
|
201
211
|
};
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
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
|
+
|
|
1
9
|
/**
|
|
2
10
|
* TypeScript type definitions for @object-ui/plugin-charts
|
|
3
11
|
*
|
|
@@ -16,7 +24,7 @@ import type { BaseSchema } from '@object-ui/types';
|
|
|
16
24
|
* import type { BarChartSchema } from '@object-ui/plugin-charts';
|
|
17
25
|
*
|
|
18
26
|
* const chartSchema: BarChartSchema = {
|
|
19
|
-
* type: 'chart
|
|
27
|
+
* type: 'bar-chart',
|
|
20
28
|
* data: [
|
|
21
29
|
* { name: 'Jan', value: 400 },
|
|
22
30
|
* { name: 'Feb', value: 300 }
|
|
@@ -27,7 +35,7 @@ import type { BaseSchema } from '@object-ui/types';
|
|
|
27
35
|
* ```
|
|
28
36
|
*/
|
|
29
37
|
export interface BarChartSchema extends BaseSchema {
|
|
30
|
-
type: 'chart
|
|
38
|
+
type: 'bar-chart';
|
|
31
39
|
|
|
32
40
|
/**
|
|
33
41
|
* Array of data points to display in the chart.
|
package/vite.config.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
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
|
+
|
|
1
9
|
import { defineConfig } from 'vite';
|
|
2
10
|
import react from '@vitejs/plugin-react';
|
|
3
11
|
import dts from 'vite-plugin-dts';
|
|
@@ -9,6 +17,8 @@ export default defineConfig({
|
|
|
9
17
|
dts({
|
|
10
18
|
insertTypesEntry: true,
|
|
11
19
|
include: ['src'],
|
|
20
|
+
exclude: ['**/*.test.ts', '**/*.test.tsx', 'node_modules'],
|
|
21
|
+
skipDiagnostics: true,
|
|
12
22
|
}),
|
|
13
23
|
],
|
|
14
24
|
resolve: {
|