@object-ui/plugin-charts 3.1.5 → 3.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +24 -0
  3. package/dist/{AdvancedChartImpl-DmHTUUVD.js → AdvancedChartImpl-DxaZtNlE.js} +1214 -1206
  4. package/dist/{BarChart-XZkfLmcU.js → BarChart-BQS4sYHd.js} +3859 -3766
  5. package/dist/{ChartImpl-0VlpsMWG.js → ChartImpl-BaXisyXJ.js} +6 -6
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +207 -63
  8. package/dist/index.umd.cjs +19 -19
  9. package/dist/{jsx-runtime-C8d0IhUE.js → jsx-runtime-Caia9pQX.js} +1 -1
  10. package/dist/packages/plugin-charts/src/ObjectChart.d.ts +31 -0
  11. package/package.json +34 -10
  12. package/.turbo/turbo-build.log +0 -26
  13. package/dist/src/ObjectChart.d.ts +0 -12
  14. package/examples/chart-examples.ts +0 -54
  15. package/src/AdvancedChartImpl.tsx +0 -309
  16. package/src/ChartContainerImpl.tsx +0 -353
  17. package/src/ChartImpl.tsx +0 -91
  18. package/src/ChartRenderer.tsx +0 -112
  19. package/src/ObjectChart.stories.tsx +0 -104
  20. package/src/ObjectChart.tsx +0 -145
  21. package/src/__tests__/ObjectChart.aggregation.test.ts +0 -166
  22. package/src/__tests__/ObjectChart.dataFetch.test.tsx +0 -303
  23. package/src/index.test.ts +0 -136
  24. package/src/index.tsx +0 -172
  25. package/src/types.ts +0 -68
  26. package/tsconfig.json +0 -17
  27. package/vite.config.ts +0 -61
  28. package/vitest.config.ts +0 -13
  29. package/vitest.setup.ts +0 -1
  30. /package/dist/{src → packages/plugin-charts/src}/AdvancedChartImpl.d.ts +0 -0
  31. /package/dist/{src → packages/plugin-charts/src}/ChartContainerImpl.d.ts +0 -0
  32. /package/dist/{src → packages/plugin-charts/src}/ChartImpl.d.ts +0 -0
  33. /package/dist/{src → packages/plugin-charts/src}/ChartRenderer.d.ts +0 -0
  34. /package/dist/{src → packages/plugin-charts/src}/ObjectChart.stories.d.ts +0 -0
  35. /package/dist/{src → packages/plugin-charts/src}/index.d.ts +0 -0
  36. /package/dist/{src → packages/plugin-charts/src}/types.d.ts +0 -0
package/src/index.test.ts DELETED
@@ -1,136 +0,0 @@
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 { describe, it, expect, beforeAll } from 'vitest';
10
- import { ComponentRegistry } from '@object-ui/core';
11
-
12
- describe('Plugin Charts', () => {
13
- // Import all renderers to register them
14
- beforeAll(async () => {
15
- await import('./index');
16
- }, 60000);
17
-
18
- describe('bar-chart component', () => {
19
- it('should be registered in ComponentRegistry', () => {
20
- const chartBarRenderer = ComponentRegistry.get('bar-chart');
21
- expect(chartBarRenderer).toBeDefined();
22
- });
23
-
24
- it('should have proper metadata', () => {
25
- const config = ComponentRegistry.getConfig('bar-chart');
26
- expect(config).toBeDefined();
27
- expect(config?.label).toBe('Bar Chart');
28
- expect(config?.category).toBe('plugin');
29
- expect(config?.inputs).toBeDefined();
30
- expect(config?.defaultProps).toBeDefined();
31
- });
32
-
33
- it('should have expected inputs', () => {
34
- const config = ComponentRegistry.getConfig('bar-chart');
35
- const inputNames = config?.inputs?.map((input: any) => input.name) || [];
36
-
37
- expect(inputNames).toContain('data');
38
- expect(inputNames).toContain('dataKey');
39
- expect(inputNames).toContain('xAxisKey');
40
- expect(inputNames).toContain('height');
41
- expect(inputNames).toContain('color');
42
- });
43
-
44
- it('should have data as required input', () => {
45
- const config = ComponentRegistry.getConfig('bar-chart');
46
- const dataInput = config?.inputs?.find((input: any) => input.name === 'data');
47
-
48
- expect(dataInput).toBeDefined();
49
- expect(dataInput?.required).toBe(true);
50
- expect(dataInput?.type).toBe('array');
51
- });
52
-
53
- it('should have sensible default props', () => {
54
- const config = ComponentRegistry.getConfig('bar-chart');
55
- const defaults = config?.defaultProps;
56
-
57
- expect(defaults).toBeDefined();
58
- expect(defaults?.dataKey).toBe('value');
59
- expect(defaults?.xAxisKey).toBe('name');
60
- expect(defaults?.height).toBe(400);
61
- expect(defaults?.color).toBe('#8884d8');
62
- expect(defaults?.data).toBeDefined();
63
- expect(Array.isArray(defaults?.data)).toBe(true);
64
- expect(defaults?.data.length).toBeGreaterThan(0);
65
- });
66
- });
67
-
68
- describe('chart (advanced) component', () => {
69
- it('should be registered in ComponentRegistry', () => {
70
- const chartRenderer = ComponentRegistry.get('chart');
71
- expect(chartRenderer).toBeDefined();
72
- });
73
-
74
- it('should have proper metadata', () => {
75
- const config = ComponentRegistry.getConfig('chart');
76
- expect(config).toBeDefined();
77
- expect(config?.label).toBe('Chart');
78
- expect(config?.category).toBe('plugin');
79
- expect(config?.inputs).toBeDefined();
80
- expect(config?.defaultProps).toBeDefined();
81
- });
82
-
83
- it('should have expected inputs', () => {
84
- const config = ComponentRegistry.getConfig('chart');
85
- const inputNames = config?.inputs?.map((input: any) => input.name) || [];
86
-
87
- expect(inputNames).toContain('chartType');
88
- expect(inputNames).toContain('data');
89
- expect(inputNames).toContain('config');
90
- expect(inputNames).toContain('xAxisKey');
91
- expect(inputNames).toContain('series');
92
- expect(inputNames).toContain('className');
93
- });
94
-
95
- it('should have chartType as enum input', () => {
96
- const config = ComponentRegistry.getConfig('chart');
97
- const chartTypeInput = config?.inputs?.find((input: any) => input.name === 'chartType');
98
-
99
- expect(chartTypeInput).toBeDefined();
100
- expect(chartTypeInput?.type).toBe('enum');
101
- expect(chartTypeInput?.enum).toBeDefined();
102
- expect(Array.isArray(chartTypeInput?.enum)).toBe(true);
103
-
104
- const enumValues = chartTypeInput?.enum?.map((e: any) => e.value) || [];
105
- expect(enumValues).toContain('bar');
106
- expect(enumValues).toContain('line');
107
- expect(enumValues).toContain('area');
108
- });
109
-
110
- it('should have data and series as required inputs', () => {
111
- const config = ComponentRegistry.getConfig('chart');
112
- const dataInput = config?.inputs?.find((input: any) => input.name === 'data');
113
- const seriesInput = config?.inputs?.find((input: any) => input.name === 'series');
114
-
115
- expect(dataInput?.required).toBe(true);
116
- expect(seriesInput?.required).toBe(true);
117
- });
118
-
119
- it('should have sensible default props', () => {
120
- const config = ComponentRegistry.getConfig('chart');
121
- const defaults = config?.defaultProps;
122
-
123
- expect(defaults).toBeDefined();
124
- expect(defaults?.chartType).toBe('bar');
125
- expect(defaults?.xAxisKey).toBe('name');
126
- expect(defaults?.data).toBeDefined();
127
- expect(Array.isArray(defaults?.data)).toBe(true);
128
- expect(defaults?.data.length).toBeGreaterThan(0);
129
- expect(defaults?.config).toBeDefined();
130
- expect(typeof defaults?.config).toBe('object');
131
- expect(defaults?.series).toBeDefined();
132
- expect(Array.isArray(defaults?.series)).toBe(true);
133
- expect(defaults?.series.length).toBeGreaterThan(0);
134
- });
135
- });
136
- });
package/src/index.tsx DELETED
@@ -1,172 +0,0 @@
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 { ChartBarRenderer, ChartRenderer } from './ChartRenderer';
11
- import { ObjectChart } from './ObjectChart';
12
-
13
- // Export types for external use
14
- export type { BarChartSchema } from './types';
15
- export { ChartBarRenderer, ChartRenderer };
16
- export { ObjectChart } from './ObjectChart';
17
-
18
- // Standard Export Protocol - for manual integration
19
- export const chartComponents = {
20
- 'bar-chart': ChartBarRenderer,
21
- 'chart': ChartRenderer,
22
- };
23
-
24
- // Register the component with the ComponentRegistry
25
- ComponentRegistry.register(
26
- 'bar-chart',
27
- ChartBarRenderer,
28
- {
29
- namespace: 'plugin-charts',
30
- label: 'Bar Chart',
31
- category: 'plugin',
32
- inputs: [
33
- { name: 'data', type: 'array', label: 'Data', required: true },
34
- { name: 'dataKey', type: 'string', label: 'Data Key', defaultValue: 'value' },
35
- { name: 'xAxisKey', type: 'string', label: 'X-Axis Key', defaultValue: 'name' },
36
- { name: 'height', type: 'number', label: 'Height', defaultValue: 400 },
37
- { name: 'color', type: 'color', label: 'Color', defaultValue: '#8884d8' },
38
- ],
39
- defaultProps: {
40
- data: [
41
- { name: 'Jan', value: 400 },
42
- { name: 'Feb', value: 300 },
43
- { name: 'Mar', value: 600 },
44
- { name: 'Apr', value: 800 },
45
- { name: 'May', value: 500 },
46
- ],
47
- dataKey: 'value',
48
- xAxisKey: 'name',
49
- height: 400,
50
- color: '#8884d8',
51
- },
52
- }
53
- );
54
- // Alias for generic view
55
- ComponentRegistry.register('chart', ObjectChart, {
56
- namespace: 'view',
57
- category: 'view',
58
- label: 'Chart',
59
- inputs: [
60
- { name: 'objectName', type: 'string', label: 'Object Name', required: true },
61
- { name: 'type', type: 'string', label: 'Chart Type' },
62
- { name: 'categoryField', type: 'string', label: 'Category Field' },
63
- { name: 'valueField', type: 'string', label: 'Value Field' },
64
- ]
65
- });
66
- // Register the advanced chart component
67
- ComponentRegistry.register(
68
- 'chart',
69
- ChartRenderer,
70
- {
71
- namespace: 'plugin-charts',
72
- label: 'Chart',
73
- category: 'plugin',
74
- inputs: [
75
- {
76
- name: 'chartType',
77
- type: 'enum',
78
- label: 'Chart Type',
79
- enum: [
80
- { label: 'Bar', value: 'bar' },
81
- { label: 'Line', value: 'line' },
82
- { label: 'Area', value: 'area' },
83
- { label: 'Pie', value: 'pie' },
84
- { label: 'Donut', value: 'donut' },
85
- { label: 'Radar', value: 'radar' },
86
- { label: 'Scatter', value: 'scatter' }
87
- ],
88
- defaultValue: 'bar'
89
- },
90
- { name: 'data', type: 'code', label: 'Data (JSON)', required: true },
91
- { name: 'config', type: 'code', label: 'Config (JSON)' },
92
- { name: 'xAxisKey', type: 'string', label: 'X Axis Key', defaultValue: 'name' },
93
- { name: 'series', type: 'code', label: 'Series (JSON Array)', required: true },
94
- { name: 'className', type: 'string', label: 'CSS Class' }
95
- ],
96
- defaultProps: {
97
- chartType: 'bar',
98
- data: [
99
- { name: 'Jan', sales: 400, revenue: 240 },
100
- { name: 'Feb', sales: 300, revenue: 139 },
101
- { name: 'Mar', sales: 600, revenue: 380 },
102
- { name: 'Apr', sales: 800, revenue: 430 },
103
- { name: 'May', sales: 500, revenue: 220 },
104
- ],
105
- config: {
106
- sales: { label: 'Sales', color: '#8884d8' },
107
- revenue: { label: 'Revenue', color: '#82ca9d' }
108
- },
109
- xAxisKey: 'name',
110
- series: [
111
- { dataKey: 'sales' },
112
- { dataKey: 'revenue' }
113
- ]
114
- }
115
- }
116
- );
117
-
118
- // Alias for CRM App compatibility
119
- ComponentRegistry.register(
120
- 'chart:bar',
121
- ChartRenderer,
122
- {
123
- namespace: 'plugin-charts',
124
- label: 'Bar Chart (Alias)',
125
- category: 'plugin',
126
- defaultProps: { chartType: 'bar' }
127
- }
128
- );
129
-
130
- ComponentRegistry.register(
131
- 'pie-chart',
132
- ChartRenderer,
133
- {
134
- namespace: 'plugin-charts',
135
- label: 'Pie Chart',
136
- category: 'plugin',
137
- defaultProps: { chartType: 'pie' }
138
- }
139
- );
140
-
141
- ComponentRegistry.register(
142
- 'donut-chart',
143
- ChartRenderer,
144
- {
145
- namespace: 'plugin-charts',
146
- label: 'Donut Chart',
147
- category: 'plugin',
148
- defaultProps: { chartType: 'donut' }
149
- }
150
- );
151
-
152
- ComponentRegistry.register(
153
- 'radar-chart',
154
- ChartRenderer,
155
- {
156
- namespace: 'plugin-charts',
157
- label: 'Radar Chart',
158
- category: 'plugin',
159
- defaultProps: { chartType: 'radar' }
160
- }
161
- );
162
-
163
- ComponentRegistry.register(
164
- 'scatter-chart',
165
- ChartRenderer,
166
- {
167
- namespace: 'plugin-charts',
168
- label: 'Scatter Chart',
169
- category: 'plugin',
170
- defaultProps: { chartType: 'scatter' }
171
- }
172
- );
package/src/types.ts DELETED
@@ -1,68 +0,0 @@
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
- /**
10
- * TypeScript type definitions for @object-ui/plugin-charts
11
- *
12
- * These types can be imported by applications using this plugin
13
- * to get full TypeScript support for chart schemas.
14
- */
15
-
16
- import type { BaseSchema } from '@object-ui/types';
17
-
18
- /**
19
- * Bar Chart component schema.
20
- * Renders a bar chart using Recharts library.
21
- *
22
- * @example
23
- * ```typescript
24
- * import type { BarChartSchema } from '@object-ui/plugin-charts';
25
- *
26
- * const chartSchema: BarChartSchema = {
27
- * type: 'bar-chart',
28
- * data: [
29
- * { name: 'Jan', value: 400 },
30
- * { name: 'Feb', value: 300 }
31
- * ],
32
- * dataKey: 'value',
33
- * xAxisKey: 'name'
34
- * }
35
- * ```
36
- */
37
- export interface BarChartSchema extends BaseSchema {
38
- type: 'bar-chart';
39
-
40
- /**
41
- * Array of data points to display in the chart.
42
- */
43
- data?: Array<Record<string, any>>;
44
-
45
- /**
46
- * Key in the data object for the Y-axis values.
47
- * @default 'value'
48
- */
49
- dataKey?: string;
50
-
51
- /**
52
- * Key in the data object for the X-axis labels.
53
- * @default 'name'
54
- */
55
- xAxisKey?: string;
56
-
57
- /**
58
- * Height of the chart in pixels.
59
- * @default 400
60
- */
61
- height?: number;
62
-
63
- /**
64
- * Color of the bars.
65
- * @default '#8884d8'
66
- */
67
- color?: string;
68
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "jsx": "react-jsx",
6
- "baseUrl": ".",
7
- "paths": {
8
- "@/*": ["src/*"]
9
- },
10
- "noImplicitAny": true,
11
- "noEmit": false,
12
- "declaration": true,
13
- "composite": true,
14
- "skipLibCheck": true
15
- },
16
- "include": ["src"]
17
- }
package/vite.config.ts DELETED
@@ -1,61 +0,0 @@
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 { defineConfig } from 'vite';
10
- import react from '@vitejs/plugin-react';
11
- import dts from 'vite-plugin-dts';
12
- import { resolve } from 'path';
13
-
14
- export default defineConfig({
15
- plugins: [
16
- react(),
17
- dts({
18
- insertTypesEntry: true,
19
- include: ['src'],
20
- exclude: ['**/*.test.ts', '**/*.test.tsx', 'node_modules'],
21
- skipDiagnostics: true,
22
- }),
23
- ],
24
- resolve: {
25
- alias: {
26
- '@': resolve(__dirname, './src'),
27
- '@object-ui/core': resolve(__dirname, '../core/src'),
28
- '@object-ui/types': resolve(__dirname, '../types/src'),
29
- '@object-ui/react': resolve(__dirname, '../react/src'),
30
- '@object-ui/components': resolve(__dirname, '../components/src'),
31
- '@object-ui/fields': resolve(__dirname, '../fields/src'),
32
- '@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
33
- '@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
34
- },
35
- },
36
- build: {
37
- lib: {
38
- entry: resolve(__dirname, 'src/index.tsx'),
39
- name: 'ObjectUIPluginCharts',
40
- fileName: 'index',
41
- },
42
- rollupOptions: {
43
- external: ['react', 'react-dom', '@object-ui/components', '@object-ui/core', '@object-ui/react'],
44
- output: {
45
- globals: {
46
- react: 'React',
47
- 'react-dom': 'ReactDOM',
48
- '@object-ui/components': 'ObjectUIComponents',
49
- '@object-ui/core': 'ObjectUICore',
50
- '@object-ui/react': 'ObjectUIReact',
51
- },
52
- },
53
- },
54
- },
55
- test: {
56
- globals: true,
57
- environment: 'happy-dom',
58
- setupFiles: ['../../vitest.setup.tsx'],
59
- passWithNoTests: true,
60
- },
61
- });
package/vitest.config.ts DELETED
@@ -1,13 +0,0 @@
1
- /// <reference types="vitest" />
2
- import { defineConfig } from 'vite';
3
- import react from '@vitejs/plugin-react';
4
- import path from 'path';
5
-
6
- export default defineConfig({
7
- plugins: [react()],
8
- test: {
9
- environment: 'happy-dom',
10
- globals: true,
11
- setupFiles: ['./vitest.setup.ts'],
12
- },
13
- });
package/vitest.setup.ts DELETED
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';