@object-ui/plugin-charts 0.3.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/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/dist/AdvancedChartImpl-LUnT2ZAf.js +2320 -0
- package/dist/BarChart-CRc8MAtI.js +17766 -0
- package/dist/ChartImpl-DiqV9Evl.js +79 -0
- package/dist/index-BcjHuFVN.js +738 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -0
- package/dist/index.umd.cjs +85 -0
- package/dist/src/AdvancedChartImpl.d.ts +16 -0
- package/dist/src/ChartContainerImpl.d.ts +31 -0
- package/dist/src/ChartImpl.d.ts +13 -0
- package/dist/src/index.d.ts +42 -0
- package/dist/src/index.test.d.ts +1 -0
- package/dist/src/types.d.ts +47 -0
- package/package.json +42 -0
- package/src/AdvancedChartImpl.tsx +162 -0
- package/src/ChartContainerImpl.tsx +345 -0
- package/src/ChartImpl.tsx +83 -0
- package/src/index.test.ts +128 -0
- package/src/index.tsx +201 -0
- package/src/types.ts +60 -0
- package/tsconfig.json +17 -0
- package/vite.config.ts +38 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @object-ui/plugin-charts
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Unified version across all packages to 0.3.0 for consistent versioning
|
|
8
|
+
|
|
9
|
+
## 0.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- New plugin-object and ObjectQL SDK updates
|
|
14
|
+
|
|
15
|
+
**Added:**
|
|
16
|
+
- New Plugin: @object-ui/plugin-object - ObjectQL plugin for automatic table and form generation
|
|
17
|
+
- ObjectTable: Auto-generates tables from ObjectQL object schemas
|
|
18
|
+
- ObjectForm: Auto-generates forms from ObjectQL object schemas with create/edit/view modes
|
|
19
|
+
- Full TypeScript support with comprehensive type definitions
|
|
20
|
+
- Type Definitions: Added ObjectTableSchema and ObjectFormSchema to @object-ui/types
|
|
21
|
+
- ObjectQL Integration: Enhanced ObjectQLDataSource with getObjectSchema() method using MetadataApiClient
|
|
22
|
+
|
|
23
|
+
**Changed:**
|
|
24
|
+
- Updated @objectql/sdk from ^1.8.3 to ^1.9.1
|
|
25
|
+
- Updated @objectql/types from ^1.8.3 to ^1.9.1
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- @object-ui/types@0.3.0
|
|
29
|
+
- @object-ui/core@0.2.2
|
|
30
|
+
- @object-ui/react@0.2.2
|
|
31
|
+
- @object-ui/components@0.2.2
|
|
32
|
+
|
|
33
|
+
## 0.2.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Patch release: Add automated changeset workflow and CI/CD improvements
|
|
38
|
+
|
|
39
|
+
This release includes infrastructure improvements:
|
|
40
|
+
- Added changeset-based version management
|
|
41
|
+
- Enhanced CI/CD workflows with GitHub Actions
|
|
42
|
+
- Improved documentation for contributing and releasing
|
|
43
|
+
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
- @object-ui/types@0.2.1
|
|
46
|
+
- @object-ui/core@0.2.1
|
|
47
|
+
- @object-ui/react@0.2.1
|
|
48
|
+
- @object-ui/components@0.2.1
|
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,121 @@
|
|
|
1
|
+
# Plugin Charts - Lazy-Loaded Recharts Components
|
|
2
|
+
|
|
3
|
+
A lazy-loaded charting component for Object UI based on Recharts.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Internal Lazy Loading**: Recharts is loaded on-demand using `React.lazy()` and `Suspense`
|
|
8
|
+
- **Zero Configuration**: Just import the package and use `type: 'chart-bar'` in your schema
|
|
9
|
+
- **Automatic Registration**: Components auto-register with the ComponentRegistry
|
|
10
|
+
- **Skeleton Loading**: Shows a skeleton while Recharts loads
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @object-ui/plugin-charts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Automatic Registration (Side-Effect Import)
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
// In your app entry point (e.g., App.tsx or main.tsx)
|
|
24
|
+
import '@object-ui/plugin-charts';
|
|
25
|
+
|
|
26
|
+
// Now you can use chart-bar type in your schemas
|
|
27
|
+
const schema = {
|
|
28
|
+
type: 'chart-bar',
|
|
29
|
+
data: [
|
|
30
|
+
{ name: 'Jan', value: 400 },
|
|
31
|
+
{ name: 'Feb', value: 300 },
|
|
32
|
+
{ name: 'Mar', value: 600 }
|
|
33
|
+
],
|
|
34
|
+
dataKey: 'value',
|
|
35
|
+
xAxisKey: 'name',
|
|
36
|
+
height: 400
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Manual Integration
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { chartComponents } from '@object-ui/plugin-charts';
|
|
44
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
45
|
+
|
|
46
|
+
// Manually register if needed
|
|
47
|
+
Object.entries(chartComponents).forEach(([type, component]) => {
|
|
48
|
+
ComponentRegistry.register(type, component);
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### TypeScript Support
|
|
53
|
+
|
|
54
|
+
The plugin exports TypeScript types for full type safety:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import type { BarChartSchema } from '@object-ui/plugin-charts';
|
|
58
|
+
|
|
59
|
+
const schema: BarChartSchema = {
|
|
60
|
+
type: 'chart-bar',
|
|
61
|
+
data: [
|
|
62
|
+
{ name: 'Jan', value: 400 },
|
|
63
|
+
{ name: 'Feb', value: 300 }
|
|
64
|
+
],
|
|
65
|
+
dataKey: 'value',
|
|
66
|
+
xAxisKey: 'name',
|
|
67
|
+
height: 400
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Schema API
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
{
|
|
75
|
+
type: 'chart-bar',
|
|
76
|
+
data?: Array<Record<string, any>>, // Chart data
|
|
77
|
+
dataKey?: string, // Y-axis data key (default: 'value')
|
|
78
|
+
xAxisKey?: string, // X-axis label key (default: 'name')
|
|
79
|
+
height?: number, // Chart height in pixels (default: 400)
|
|
80
|
+
color?: string, // Bar color (default: '#8884d8')
|
|
81
|
+
className?: string // Tailwind classes
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Lazy Loading Architecture
|
|
86
|
+
|
|
87
|
+
The plugin uses a two-file pattern for optimal code splitting:
|
|
88
|
+
|
|
89
|
+
1. **`ChartImpl.tsx`**: Contains the actual Recharts import (heavy ~541 KB)
|
|
90
|
+
2. **`index.tsx`**: Entry point with `React.lazy()` wrapper (light)
|
|
91
|
+
|
|
92
|
+
When bundled, Vite automatically creates separate chunks:
|
|
93
|
+
- `index.js` (~200 bytes) - The entry point
|
|
94
|
+
- `ChartImpl-xxx.js` (~541 KB minified, ~136 KB gzipped) - The lazy-loaded implementation
|
|
95
|
+
|
|
96
|
+
The Recharts library is only downloaded when a `chart-bar` component is actually rendered, not on initial page load.
|
|
97
|
+
|
|
98
|
+
## Build Output Example
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
dist/index.js 0.19 kB # Entry point
|
|
102
|
+
dist/ChartImpl-BJBP1UnW.js 541.17 kB # Lazy chunk (loaded on demand)
|
|
103
|
+
dist/index.umd.cjs 393.20 kB # UMD bundle
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Development
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Build the plugin
|
|
110
|
+
pnpm build
|
|
111
|
+
|
|
112
|
+
# The package will generate proper ESM and UMD builds with lazy loading preserved
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Bundle Size Impact
|
|
116
|
+
|
|
117
|
+
By using lazy loading, the main application bundle stays lean:
|
|
118
|
+
- Without lazy loading: +541 KB on initial load
|
|
119
|
+
- With lazy loading: +0.19 KB on initial load, +541 KB only when chart is rendered
|
|
120
|
+
|
|
121
|
+
This results in significantly faster initial page loads for applications that don't use charts on every page.
|