@object-ui/plugin-view 3.3.0 → 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.
- package/CHANGELOG.md +12 -0
- package/README.md +21 -1
- package/dist/index.js +2679 -2936
- package/dist/index.umd.cjs +1 -5
- package/dist/packages/plugin-view/src/config/view-config-schema.d.ts +20 -0
- package/dist/packages/plugin-view/src/config/view-config-utils.d.ts +58 -0
- package/dist/packages/plugin-view/src/index.d.ts +4 -0
- package/package.json +41 -9
- package/.turbo/turbo-build.log +0 -39
- package/src/FilterUI.tsx +0 -350
- package/src/ObjectView.tsx +0 -1133
- package/src/SharedViewLink.tsx +0 -199
- package/src/SortUI.tsx +0 -210
- package/src/ViewSwitcher.tsx +0 -379
- package/src/ViewTabBar.tsx +0 -656
- package/src/__tests__/FilterUI.test.tsx +0 -641
- package/src/__tests__/ObjectView.test.tsx +0 -705
- package/src/__tests__/SharedViewLinkPassword.test.tsx +0 -172
- package/src/__tests__/SortUI.test.tsx +0 -380
- package/src/__tests__/ViewTabBar.test.tsx +0 -710
- package/src/__tests__/config-sync-integration.test.tsx +0 -588
- package/src/__tests__/toolbar-consistency.test.tsx +0 -755
- package/src/index.tsx +0 -197
- package/tsconfig.json +0 -8
- package/vite.config.ts +0 -48
- package/vitest.config.ts +0 -12
- package/vitest.setup.ts +0 -1
package/src/index.tsx
DELETED
|
@@ -1,197 +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 React, { useContext } from 'react';
|
|
10
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
11
|
-
import { SchemaRendererContext as ImportedSchemaRendererContext } from '@object-ui/react';
|
|
12
|
-
import { ObjectView } from './ObjectView';
|
|
13
|
-
import { ViewSwitcher } from './ViewSwitcher';
|
|
14
|
-
import { FilterUI } from './FilterUI';
|
|
15
|
-
import { SortUI } from './SortUI';
|
|
16
|
-
import { SharedViewLink } from './SharedViewLink';
|
|
17
|
-
|
|
18
|
-
export { ObjectView, ViewSwitcher, FilterUI, SortUI, SharedViewLink };
|
|
19
|
-
export { ViewTabBar } from './ViewTabBar';
|
|
20
|
-
export type { ObjectViewProps } from './ObjectView';
|
|
21
|
-
export type { ViewSwitcherProps } from './ViewSwitcher';
|
|
22
|
-
export type { ViewTabBarProps, ViewTabItem, AvailableViewType } from './ViewTabBar';
|
|
23
|
-
export type { FilterUIProps } from './FilterUI';
|
|
24
|
-
export type { SortUIProps } from './SortUI';
|
|
25
|
-
export type { SharedViewLinkProps } from './SharedViewLink';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* SchemaRendererContext is created by @object-ui/react.
|
|
29
|
-
* The context value provides { dataSource }.
|
|
30
|
-
*/
|
|
31
|
-
const SchemaRendererContext: React.Context<any> = ImportedSchemaRendererContext;
|
|
32
|
-
|
|
33
|
-
// Register object-view component
|
|
34
|
-
const ObjectViewRenderer: React.FC<{ schema: any }> = ({ schema }) => {
|
|
35
|
-
// Resolve dataSource from SchemaRendererProvider context
|
|
36
|
-
const ctx = useContext(SchemaRendererContext);
|
|
37
|
-
const dataSource = ctx?.dataSource ?? null;
|
|
38
|
-
|
|
39
|
-
return <ObjectView schema={schema} dataSource={dataSource} />;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
ComponentRegistry.register('object-view', ObjectViewRenderer, {
|
|
43
|
-
namespace: 'plugin-view',
|
|
44
|
-
label: 'Object View',
|
|
45
|
-
category: 'view',
|
|
46
|
-
icon: 'LayoutDashboard',
|
|
47
|
-
inputs: [
|
|
48
|
-
{ name: 'objectName', type: 'string', label: 'Object Name', required: true },
|
|
49
|
-
{ name: 'title', type: 'string', label: 'Title' },
|
|
50
|
-
{ name: 'description', type: 'string', label: 'Description' },
|
|
51
|
-
{ name: 'layout', type: 'enum', label: 'Form Layout', enum: ['drawer', 'modal', 'page'] },
|
|
52
|
-
{ name: 'defaultViewType', type: 'enum', label: 'Default View Type', enum: ['grid', 'kanban', 'gallery', 'calendar', 'timeline', 'gantt', 'map'] },
|
|
53
|
-
{ name: 'defaultListView', type: 'string', label: 'Default Named View' },
|
|
54
|
-
{ name: 'showSearch', type: 'boolean', label: 'Show Search' },
|
|
55
|
-
{ name: 'showFilters', type: 'boolean', label: 'Show Filters' },
|
|
56
|
-
{ name: 'showCreate', type: 'boolean', label: 'Show Create Button' },
|
|
57
|
-
{ name: 'showRefresh', type: 'boolean', label: 'Show Refresh Button' },
|
|
58
|
-
{ name: 'showViewSwitcher', type: 'boolean', label: 'Show View Switcher' },
|
|
59
|
-
{ name: 'listViews', type: 'object', label: 'Named List Views' },
|
|
60
|
-
{ name: 'navigation', type: 'object', label: 'Navigation Config' },
|
|
61
|
-
{ name: 'searchableFields', type: 'array', label: 'Searchable Fields' },
|
|
62
|
-
{ name: 'filterableFields', type: 'array', label: 'Filterable Fields' },
|
|
63
|
-
],
|
|
64
|
-
defaultProps: {
|
|
65
|
-
layout: 'drawer',
|
|
66
|
-
defaultViewType: 'grid',
|
|
67
|
-
showSearch: true,
|
|
68
|
-
showFilters: true,
|
|
69
|
-
showCreate: true,
|
|
70
|
-
showRefresh: true,
|
|
71
|
-
showViewSwitcher: true,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Register alias 'view' → same renderer
|
|
76
|
-
ComponentRegistry.register('view', ObjectViewRenderer, {
|
|
77
|
-
namespace: 'plugin-view',
|
|
78
|
-
label: 'View',
|
|
79
|
-
category: 'view',
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
ComponentRegistry.register('view-switcher', ViewSwitcher, {
|
|
83
|
-
namespace: 'view',
|
|
84
|
-
label: 'View Switcher',
|
|
85
|
-
category: 'view',
|
|
86
|
-
icon: 'LayoutGrid',
|
|
87
|
-
inputs: [
|
|
88
|
-
{ name: 'views', type: 'array', label: 'Views', required: true },
|
|
89
|
-
{ name: 'defaultView', type: 'string', label: 'Default View' },
|
|
90
|
-
{ name: 'activeView', type: 'string', label: 'Active View' },
|
|
91
|
-
{ name: 'variant', type: 'enum', label: 'Variant', enum: ['tabs', 'buttons', 'dropdown'] },
|
|
92
|
-
{ name: 'position', type: 'enum', label: 'Position', enum: ['top', 'bottom', 'left', 'right'] },
|
|
93
|
-
{ name: 'persistPreference', type: 'boolean', label: 'Persist Preference' },
|
|
94
|
-
{ name: 'storageKey', type: 'string', label: 'Storage Key' },
|
|
95
|
-
{ name: 'onViewChange', type: 'string', label: 'On View Change Event' },
|
|
96
|
-
],
|
|
97
|
-
defaultProps: {
|
|
98
|
-
variant: 'tabs',
|
|
99
|
-
position: 'top',
|
|
100
|
-
defaultView: 'grid',
|
|
101
|
-
views: [
|
|
102
|
-
{ type: 'grid', label: 'Grid', schema: { type: 'text', content: 'Grid view' } },
|
|
103
|
-
{ type: 'list', label: 'List', schema: { type: 'text', content: 'List view' } },
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
ComponentRegistry.register('filter-ui', FilterUI, {
|
|
109
|
-
namespace: 'view',
|
|
110
|
-
label: 'Filter UI',
|
|
111
|
-
category: 'view',
|
|
112
|
-
icon: 'SlidersHorizontal',
|
|
113
|
-
inputs: [
|
|
114
|
-
{ name: 'filters', type: 'array', label: 'Filters', required: true },
|
|
115
|
-
{ name: 'values', type: 'object', label: 'Values' },
|
|
116
|
-
{ name: 'onChange', type: 'string', label: 'On Change Event' },
|
|
117
|
-
{ name: 'showClear', type: 'boolean', label: 'Show Clear Button' },
|
|
118
|
-
{ name: 'showApply', type: 'boolean', label: 'Show Apply Button' },
|
|
119
|
-
{ name: 'layout', type: 'enum', label: 'Layout', enum: ['inline', 'popover', 'drawer'] },
|
|
120
|
-
],
|
|
121
|
-
defaultProps: {
|
|
122
|
-
layout: 'inline',
|
|
123
|
-
showApply: false,
|
|
124
|
-
showClear: true,
|
|
125
|
-
filters: [
|
|
126
|
-
{ field: 'name', label: 'Name', type: 'text', placeholder: 'Search name' },
|
|
127
|
-
{ field: 'status', label: 'Status', type: 'select', options: [
|
|
128
|
-
{ label: 'Open', value: 'open' },
|
|
129
|
-
{ label: 'Closed', value: 'closed' },
|
|
130
|
-
] },
|
|
131
|
-
{ field: 'created_at', label: 'Created', type: 'date' },
|
|
132
|
-
],
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
ComponentRegistry.register('sort-ui', SortUI, {
|
|
137
|
-
namespace: 'view',
|
|
138
|
-
label: 'Sort UI',
|
|
139
|
-
category: 'view',
|
|
140
|
-
icon: 'ArrowUpDown',
|
|
141
|
-
inputs: [
|
|
142
|
-
{ name: 'fields', type: 'array', label: 'Fields', required: true },
|
|
143
|
-
{ name: 'sort', type: 'array', label: 'Sort' },
|
|
144
|
-
{ name: 'onChange', type: 'string', label: 'On Change Event' },
|
|
145
|
-
{ name: 'multiple', type: 'boolean', label: 'Allow Multiple' },
|
|
146
|
-
{ name: 'variant', type: 'enum', label: 'Variant', enum: ['dropdown', 'buttons'] },
|
|
147
|
-
],
|
|
148
|
-
defaultProps: {
|
|
149
|
-
variant: 'dropdown',
|
|
150
|
-
multiple: true,
|
|
151
|
-
fields: [
|
|
152
|
-
{ field: 'name', label: 'Name' },
|
|
153
|
-
{ field: 'created_at', label: 'Created At' },
|
|
154
|
-
],
|
|
155
|
-
sort: [{ field: 'name', direction: 'asc' }],
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
ComponentRegistry.register('shared-view-link', SharedViewLink, {
|
|
160
|
-
namespace: 'view',
|
|
161
|
-
label: 'Shared View Link',
|
|
162
|
-
category: 'view',
|
|
163
|
-
icon: 'Share2',
|
|
164
|
-
inputs: [
|
|
165
|
-
{ name: 'objectName', type: 'string', label: 'Object Name', required: true },
|
|
166
|
-
{ name: 'viewId', type: 'string', label: 'View ID' },
|
|
167
|
-
{ name: 'baseUrl', type: 'string', label: 'Base URL' },
|
|
168
|
-
],
|
|
169
|
-
defaultProps: {
|
|
170
|
-
objectName: 'objects',
|
|
171
|
-
viewId: 'default',
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Simple View Renderer (Container)
|
|
176
|
-
const SimpleViewRenderer: React.FC<any> = ({ schema, className, children, dataSource, ...props }) => {
|
|
177
|
-
// If columns prop is present, use grid layout
|
|
178
|
-
const style = schema.props?.columns
|
|
179
|
-
? { display: 'grid', gridTemplateColumns: `repeat(${schema.props.columns}, 1fr)`, gap: '1rem' }
|
|
180
|
-
: undefined;
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<div
|
|
184
|
-
className={className}
|
|
185
|
-
style={style}
|
|
186
|
-
{...props}
|
|
187
|
-
>
|
|
188
|
-
{children}
|
|
189
|
-
</div>
|
|
190
|
-
);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
ComponentRegistry.register('view:simple', SimpleViewRenderer, {
|
|
194
|
-
namespace: 'plugin-view',
|
|
195
|
-
label: 'Simple View',
|
|
196
|
-
category: 'view'
|
|
197
|
-
});
|
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
define: {
|
|
8
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
|
|
9
|
-
},
|
|
10
|
-
plugins: [
|
|
11
|
-
react(),
|
|
12
|
-
dts({
|
|
13
|
-
insertTypesEntry: true,
|
|
14
|
-
compilerOptions: { rootDir: resolve(__dirname, '../..') },
|
|
15
|
-
include: ['src'],
|
|
16
|
-
exclude: ['**/*.test.ts', '**/*.test.tsx'],
|
|
17
|
-
}),
|
|
18
|
-
],
|
|
19
|
-
build: {
|
|
20
|
-
lib: {
|
|
21
|
-
entry: resolve(__dirname, 'src/index.tsx'),
|
|
22
|
-
name: 'ObjectUIPluginView',
|
|
23
|
-
fileName: 'index',
|
|
24
|
-
},
|
|
25
|
-
rollupOptions: {
|
|
26
|
-
external: [
|
|
27
|
-
'react',
|
|
28
|
-
'react-dom',
|
|
29
|
-
'@object-ui/components',
|
|
30
|
-
'@object-ui/core',
|
|
31
|
-
'@object-ui/plugin-form',
|
|
32
|
-
'@object-ui/plugin-grid',
|
|
33
|
-
'@object-ui/react',
|
|
34
|
-
'@object-ui/types',
|
|
35
|
-
'lucide-react'
|
|
36
|
-
],
|
|
37
|
-
output: {
|
|
38
|
-
globals: {
|
|
39
|
-
react: 'React',
|
|
40
|
-
'react-dom': 'ReactDOM',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
test: {
|
|
46
|
-
passWithNoTests: true,
|
|
47
|
-
},
|
|
48
|
-
});
|
package/vitest.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest" />
|
|
2
|
-
import { defineConfig } from 'vite';
|
|
3
|
-
import react from '@vitejs/plugin-react';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [react()],
|
|
7
|
-
test: {
|
|
8
|
-
environment: 'happy-dom',
|
|
9
|
-
globals: true,
|
|
10
|
-
setupFiles: ['./vitest.setup.ts'],
|
|
11
|
-
},
|
|
12
|
-
});
|
package/vitest.setup.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|