@revisium/schema-toolkit-ui 0.2.2 → 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/README.md +55 -0
- package/dist/index.cjs +1976 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +252 -43
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +252 -43
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1972 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -86,6 +86,61 @@ vm.isTableIdChanged // was table renamed?
|
|
|
86
86
|
vm.initialTableId // original name (for rename API)
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
### Editing row data
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { RowEditorVM, RowEditor } from '@revisium/schema-toolkit-ui';
|
|
93
|
+
|
|
94
|
+
const vm = new RowEditorVM(tableSchema, existingRowData, {
|
|
95
|
+
mode: 'editing',
|
|
96
|
+
rowId: 'my-row-id',
|
|
97
|
+
refSchemas: { ... },
|
|
98
|
+
callbacks: {
|
|
99
|
+
onSearchForeignKey: async (tableId, search) => { ... },
|
|
100
|
+
onUploadFile: async (fileId, file) => { ... },
|
|
101
|
+
onOpenFile: (url) => window.open(url, '_blank', 'noopener,noreferrer'),
|
|
102
|
+
onNavigateToForeignKey: (tableId, rowId) => { ... },
|
|
103
|
+
},
|
|
104
|
+
onSave: (rowId, value, patches) => {
|
|
105
|
+
// save logic
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// In React component:
|
|
110
|
+
<RowEditor vm={vm} />
|
|
111
|
+
|
|
112
|
+
// Read results:
|
|
113
|
+
vm.rowId // current row name
|
|
114
|
+
vm.isRowIdChanged // was row renamed?
|
|
115
|
+
vm.initialRowId // original name (for rename API)
|
|
116
|
+
vm.isDirty // data changed?
|
|
117
|
+
vm.hasChanges // data or name changed?
|
|
118
|
+
vm.getValue() // plain JSON value
|
|
119
|
+
vm.patches // JSON Patch operations
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Creating a new row
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
const vm = new RowEditorVM(tableSchema, undefined, {
|
|
126
|
+
mode: 'creating',
|
|
127
|
+
rowId: 'auto-generated-id',
|
|
128
|
+
callbacks: { ... },
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
<RowEditor vm={vm} />
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Read-only mode
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
const vm = new RowEditorVM(tableSchema, rowData, {
|
|
138
|
+
mode: 'reading',
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
<RowEditor vm={vm} />
|
|
142
|
+
```
|
|
143
|
+
|
|
89
144
|
### Cleanup
|
|
90
145
|
|
|
91
146
|
Call `vm.dispose()` when the editor is unmounted.
|