-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor views to Shadcn UI primitives and extract visualization plugins #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0a576e
ddbed06
6bde96d
ee1863a
2214df2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "@object-ui/plugin-calendar", | ||
| "version": "0.3.0", | ||
| "type": "module", | ||
| "license": "MIT", | ||
| "description": "Calendar view plugin for Object UI", | ||
| "homepage": "https://www.objectui.org", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/objectstack-ai/objectui.git", | ||
| "directory": "packages/plugin-calendar" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/objectstack-ai/objectui/issues" | ||
| }, | ||
| "main": "dist/index.umd.cjs", | ||
| "module": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.umd.cjs" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "type-check": "tsc --noEmit", | ||
| "lint": "eslint ." | ||
| }, | ||
| "dependencies": { | ||
| "@object-ui/components": "workspace:*", | ||
| "@object-ui/core": "workspace:*", | ||
| "@object-ui/react": "workspace:*", | ||
| "@object-ui/types": "workspace:*", | ||
| "lucide-react": "^0.563.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^18.0.0 || ^19.0.0", | ||
| "react-dom": "^18.0.0 || ^19.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^19.2.9", | ||
| "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-react": "^4.2.1", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^7.3.1", | ||
| "vite-plugin-dts": "^4.5.4" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * ObjectUI | ||
| * Copyright (c) 2024-present ObjectStack Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { ComponentRegistry } from '@object-ui/core'; | ||
| import { ObjectCalendar } from './ObjectCalendar'; | ||
| import type { ObjectCalendarProps } from './ObjectCalendar'; | ||
|
|
||
| export { ObjectCalendar }; | ||
| export type { ObjectCalendarProps }; | ||
|
|
||
| // Register component | ||
| const ObjectCalendarRenderer: React.FC<{ schema: any }> = ({ schema }) => { | ||
| return <ObjectCalendar schema={schema} dataSource={null as any} />; | ||
| }; | ||
|
|
||
| ComponentRegistry.register('object-calendar', ObjectCalendarRenderer, { | ||
| label: 'Object Calendar', | ||
| category: 'plugin', | ||
| inputs: [ | ||
| { name: 'objectName', type: 'string', label: 'Object Name', required: true }, | ||
| { name: 'calendar', type: 'object', label: 'Calendar Config', description: 'startDateField, endDateField, titleField, colorField' }, | ||
| ], | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "extends": "../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "dist", | ||
| "jsx": "react-jsx", | ||
| "baseUrl": ".", | ||
| "paths": { | ||
| "@/*": ["src/*"] | ||
| }, | ||
| "noEmit": false, | ||
| "declaration": true, | ||
| "composite": true, | ||
| "declarationMap": true, | ||
| "skipLibCheck": true | ||
| }, | ||
| "include": ["src"], | ||
| "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * ObjectUI | ||
| * Copyright (c) 2024-present ObjectStack Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import { defineConfig } from 'vite'; | ||
| import react from '@vitejs/plugin-react'; | ||
| import dts from 'vite-plugin-dts'; | ||
| import { resolve } from 'path'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| react(), | ||
| dts({ | ||
| insertTypesEntry: true, | ||
| include: ['src'], | ||
| exclude: ['**/*.test.ts', '**/*.test.tsx', 'node_modules'], | ||
| skipDiagnostics: true, | ||
| }), | ||
| ], | ||
| resolve: { | ||
| alias: { | ||
| '@': resolve(__dirname, './src'), | ||
| }, | ||
| }, | ||
| build: { | ||
| lib: { | ||
| entry: resolve(__dirname, 'src/index.tsx'), | ||
| name: 'ObjectUIPluginCalendar', | ||
| fileName: 'index', | ||
| }, | ||
| rollupOptions: { | ||
| external: ['react', 'react-dom', '@object-ui/components', '@object-ui/core', '@object-ui/react', '@object-ui/types', 'lucide-react'], | ||
| output: { | ||
| globals: { | ||
| react: 'React', | ||
| 'react-dom': 'ReactDOM', | ||
| '@object-ui/components': 'ObjectUIComponents', | ||
| '@object-ui/core': 'ObjectUICore', | ||
| '@object-ui/react': 'ObjectUIReact', | ||
| '@object-ui/types': 'ObjectUITypes', | ||
| 'lucide-react': 'LucideReact', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "@object-ui/plugin-gantt", | ||
| "version": "0.3.0", | ||
| "type": "module", | ||
| "license": "MIT", | ||
| "description": "Gantt chart plugin for Object UI", | ||
| "homepage": "https://www.objectui.org", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/objectstack-ai/objectui.git", | ||
| "directory": "packages/plugin-gantt" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/objectstack-ai/objectui/issues" | ||
| }, | ||
| "main": "dist/index.umd.cjs", | ||
| "module": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.umd.cjs" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "type-check": "tsc --noEmit", | ||
| "lint": "eslint ." | ||
| }, | ||
| "dependencies": { | ||
| "@object-ui/components": "workspace:*", | ||
| "@object-ui/core": "workspace:*", | ||
| "@object-ui/react": "workspace:*", | ||
| "@object-ui/types": "workspace:*", | ||
| "lucide-react": "^0.563.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^18.0.0 || ^19.0.0", | ||
| "react-dom": "^18.0.0 || ^19.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^19.2.9", | ||
| "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-react": "^4.2.1", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^7.3.1", | ||
| "vite-plugin-dts": "^4.5.4" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * ObjectUI | ||||||||||||||||||||||||||||||||
| * Copyright (c) 2024-present ObjectStack Inc. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * This source code is licensed under the MIT license found in the | ||||||||||||||||||||||||||||||||
| * LICENSE file in the root directory of this source tree. | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||||||||
| import { ComponentRegistry } from '@object-ui/core'; | ||||||||||||||||||||||||||||||||
| import { ObjectGantt } from './ObjectGantt'; | ||||||||||||||||||||||||||||||||
| import type { ObjectGanttProps } from './ObjectGantt'; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export { ObjectGantt }; | ||||||||||||||||||||||||||||||||
| export type { ObjectGanttProps }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Register component | ||||||||||||||||||||||||||||||||
| const ObjectGanttRenderer: React.FC<{ schema: any }> = ({ schema }) => { | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| const ObjectGanttRenderer: React.FC<{ schema: any }> = ({ schema }) => { | |
| const ObjectGanttRenderer: React.FC<{ schema: any }> = ({ schema }) => { | |
| const provider = schema?.data?.provider; | |
| // When used as a standalone plugin renderer, we only support inline data (provider: 'value') | |
| // because no external DataSource is injected here. This mirrors the guard logic used in | |
| // the views package to fail fast with a clearer error message. | |
| if (provider && provider !== 'value') { | |
| return ( | |
| <div className="text-sm text-destructive"> | |
| ObjectGantt plugin requires inline data (schema.data.provider === "value") when no | |
| DataSource is provided. Use a views renderer or supply inline data for this plugin. | |
| </div> | |
| ); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "extends": "../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "dist", | ||
| "jsx": "react-jsx", | ||
| "baseUrl": ".", | ||
| "paths": { | ||
| "@/*": ["src/*"] | ||
| }, | ||
| "noEmit": false, | ||
| "declaration": true, | ||
| "composite": true, | ||
| "declarationMap": true, | ||
| "skipLibCheck": true | ||
| }, | ||
| "include": ["src"], | ||
| "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * ObjectUI | ||
| * Copyright (c) 2024-present ObjectStack Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import { defineConfig } from 'vite'; | ||
| import react from '@vitejs/plugin-react'; | ||
| import dts from 'vite-plugin-dts'; | ||
| import { resolve } from 'path'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| react(), | ||
| dts({ | ||
| insertTypesEntry: true, | ||
| include: ['src'], | ||
| exclude: ['**/*.test.ts', '**/*.test.tsx', 'node_modules'], | ||
| skipDiagnostics: true, | ||
| }), | ||
| ], | ||
| resolve: { | ||
| alias: { | ||
| '@': resolve(__dirname, './src'), | ||
| }, | ||
| }, | ||
| build: { | ||
| lib: { | ||
| entry: resolve(__dirname, 'src/index.tsx'), | ||
| name: 'ObjectUIPluginGantt', | ||
| fileName: 'index', | ||
| }, | ||
| rollupOptions: { | ||
| external: ['react', 'react-dom', '@object-ui/components', '@object-ui/core', '@object-ui/react', '@object-ui/types', 'lucide-react'], | ||
| output: { | ||
| globals: { | ||
| react: 'React', | ||
| 'react-dom': 'ReactDOM', | ||
| '@object-ui/components': 'ObjectUIComponents', | ||
| '@object-ui/core': 'ObjectUICore', | ||
| '@object-ui/react': 'ObjectUIReact', | ||
| '@object-ui/types': 'ObjectUITypes', | ||
| 'lucide-react': 'LucideReact', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "@object-ui/plugin-map", | ||
| "version": "0.3.0", | ||
| "type": "module", | ||
| "license": "MIT", | ||
| "description": "Map visualization plugin for Object UI", | ||
| "homepage": "https://www.objectui.org", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/objectstack-ai/objectui.git", | ||
| "directory": "packages/plugin-map" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/objectstack-ai/objectui/issues" | ||
| }, | ||
| "main": "dist/index.umd.cjs", | ||
| "module": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.umd.cjs" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "type-check": "tsc --noEmit", | ||
| "lint": "eslint ." | ||
| }, | ||
| "dependencies": { | ||
| "@object-ui/components": "workspace:*", | ||
| "@object-ui/core": "workspace:*", | ||
| "@object-ui/react": "workspace:*", | ||
| "@object-ui/types": "workspace:*", | ||
| "lucide-react": "^0.563.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^18.0.0 || ^19.0.0", | ||
| "react-dom": "^18.0.0 || ^19.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^19.2.9", | ||
| "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-react": "^4.2.1", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^7.3.1", | ||
| "vite-plugin-dts": "^4.5.4" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * ObjectUI | ||||||||||||||||||||||||||||||||
| * Copyright (c) 2024-present ObjectStack Inc. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * This source code is licensed under the MIT license found in the | ||||||||||||||||||||||||||||||||
| * LICENSE file in the root directory of this source tree. | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||||||||
| import { ComponentRegistry } from '@object-ui/core'; | ||||||||||||||||||||||||||||||||
| import { ObjectMap } from './ObjectMap'; | ||||||||||||||||||||||||||||||||
| import type { ObjectMapProps } from './ObjectMap'; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export { ObjectMap }; | ||||||||||||||||||||||||||||||||
| export type { ObjectMapProps }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Register component | ||||||||||||||||||||||||||||||||
| const ObjectMapRenderer: React.FC<{ schema: any }> = ({ schema }) => { | ||||||||||||||||||||||||||||||||
| return <ObjectMap schema={schema} dataSource={null as any} />; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| return <ObjectMap schema={schema} dataSource={null as any} />; | |
| const provider = schema?.data?.provider; | |
| const hasInlineData = provider === 'value'; | |
| const inlineData = hasInlineData ? schema?.data?.value : undefined; | |
| if (!hasInlineData) { | |
| return ( | |
| <div className="text-sm text-red-500"> | |
| Object Map plugin requires inline data. Set <code>schema.data.provider = "value"</code> and provide | |
| inline data to use this renderer. | |
| </div> | |
| ); | |
| } | |
| return <ObjectMap schema={schema} dataSource={inlineData} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin renderers (ObjectCalendarRenderer, ObjectGanttRenderer, ObjectMapRenderer) pass
dataSource={null as any}to their components without checking if the schema has inline data first. This differs from the pattern used in the views package where ObjectGridRenderer, ObjectFormRenderer, and ObjectViewRenderer check for inline data before rendering.If these components are rendered without inline data (i.e., when
schema.data.provideris not 'value'), they will throw an error "DataSource required for object/api providers" which will be displayed as an error state. While this is handled gracefully, it would be more consistent to add the same inline data guards that exist in the views package renderers.Consider adding the same pattern used in packages/views/src/index.tsx lines 68-84 to provide a clearer error message upfront.