@revisium/schema-toolkit-ui 0.1.2 → 0.2.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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![GitHub License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/revisium/schema-toolkit-ui/blob/master/LICENSE)
9
9
  [![GitHub Release](https://img.shields.io/github/v/release/revisium/schema-toolkit-ui)](https://github.com/revisium/schema-toolkit-ui/releases)
10
10
 
11
- React UI components for JSON Schema manipulation and data editing. Built on top of [@revisium/schema-toolkit](https://github.com/revisium/schema-toolkit).
11
+ React UI components for JSON Schema editing with visual diff/patch generation. Built on top of [@revisium/schema-toolkit](https://github.com/revisium/schema-toolkit).
12
12
 
13
13
  </div>
14
14
 
@@ -20,27 +20,76 @@ npm install @revisium/schema-toolkit-ui
20
20
 
21
21
  **Peer dependencies:**
22
22
  ```bash
23
- npm install react react-dom @chakra-ui/react @emotion/react next-themes
23
+ npm install react react-dom @chakra-ui/react @emotion/react next-themes mobx mobx-react-lite
24
24
  ```
25
25
 
26
- ## Features
26
+ ## Setup
27
27
 
28
- - React components for schema-based data editing
29
- - TypeScript support with full type definitions
30
- - Tree-shakeable ESM and CommonJS builds
31
- - Chakra UI integration
32
- - Storybook documentation
28
+ Wrap your app with Chakra UI Provider. The MobX reactivity provider is initialized automatically.
33
29
 
34
30
  ## Usage
35
31
 
32
+ ### Creating a new table schema
33
+
36
34
  ```tsx
37
- import { Button } from '@revisium/schema-toolkit-ui';
35
+ import { CreatingEditorVM, CreatingSchemaEditor } from '@revisium/schema-toolkit-ui';
36
+ import type { JsonObjectSchema } from '@revisium/schema-toolkit-ui';
37
+
38
+ const emptySchema: JsonObjectSchema = {
39
+ type: 'object',
40
+ properties: {},
41
+ required: [],
42
+ additionalProperties: false,
43
+ };
44
+
45
+ const vm = new CreatingEditorVM(emptySchema, {
46
+ tableId: 'my-table',
47
+ onApprove: async () => {
48
+ // save logic
49
+ return true;
50
+ },
51
+ onCancel: () => {
52
+ // cancel logic
53
+ },
54
+ });
55
+
56
+ // In React component:
57
+ <CreatingSchemaEditor vm={vm} />
38
58
 
39
- function App() {
40
- return <Button variant="primary">Click me</Button>;
41
- }
59
+ // Read results:
60
+ vm.tableId // current table name
61
+ vm.getPlainSchema() // JSON Schema output
42
62
  ```
43
63
 
64
+ ### Updating an existing table schema
65
+
66
+ ```tsx
67
+ import { UpdatingEditorVM, UpdatingSchemaEditor } from '@revisium/schema-toolkit-ui';
68
+
69
+ const vm = new UpdatingEditorVM(existingSchema, {
70
+ tableId: 'my-table',
71
+ onApprove: async () => {
72
+ // save logic
73
+ return true;
74
+ },
75
+ onCancel: () => {
76
+ // cancel logic
77
+ },
78
+ });
79
+
80
+ // In React component:
81
+ <UpdatingSchemaEditor vm={vm} />
82
+
83
+ // Read results:
84
+ vm.getJsonPatches() // JSON Patch operations
85
+ vm.isTableIdChanged // was table renamed?
86
+ vm.initialTableId // original name (for rename API)
87
+ ```
88
+
89
+ ### Cleanup
90
+
91
+ Call `vm.dispose()` when the editor is unmounted.
92
+
44
93
  ## License
45
94
 
46
95
  MIT