@revisium/schema-toolkit-ui 0.4.0 → 0.5.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 +25 -1
- package/dist/index.cjs +488 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -52
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +138 -52
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +491 -141
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ const vm = new RowEditorVM(tableSchema, existingRowData, {
|
|
|
97
97
|
refSchemas: { ... },
|
|
98
98
|
callbacks: {
|
|
99
99
|
onSearchForeignKey: async (tableId, search) => { ... },
|
|
100
|
-
onUploadFile: async (fileId, file) => { ... },
|
|
100
|
+
onUploadFile: async ({ rowId, fileId, file }) => { ... },
|
|
101
101
|
onOpenFile: (url) => window.open(url, '_blank', 'noopener,noreferrer'),
|
|
102
102
|
onNavigateToForeignKey: (tableId, rowId) => { ... },
|
|
103
103
|
},
|
|
@@ -238,10 +238,34 @@ All callbacks are optional and passed via `TableEditorOptions.callbacks`:
|
|
|
238
238
|
| `onOpenRow` | `(rowId: string) => void` | Navigate to row detail view |
|
|
239
239
|
| `onDuplicateRow` | `(rowId: string) => void` | Duplicate a row |
|
|
240
240
|
| `onSearchForeignKey` | `SearchForeignKeySearchFn` | Foreign key search handler |
|
|
241
|
+
| `onUploadFile` | `(params: { rowId: string; fileId: string; file: File }) => Promise<Record<string, unknown> \| null>` | Upload a file for a file field |
|
|
242
|
+
| `onOpenFile` | `(url: string) => void` | Open/preview a file URL |
|
|
241
243
|
| `onCopyPath` | `(path: string) => void` | Copy JSON path to clipboard |
|
|
242
244
|
|
|
243
245
|
In read-only mode (`fetchMetadata` returns `readonly: true`), delete and duplicate actions are hidden automatically. Open row still works.
|
|
244
246
|
|
|
247
|
+
#### File columns
|
|
248
|
+
|
|
249
|
+
File fields (`$ref` to the File schema) are automatically resolved into:
|
|
250
|
+
- A **parent file column** (`FilterFieldType.File`) that displays the `fileName` and supports inline editing of the file name
|
|
251
|
+
- **Sub-field columns** (e.g., `avatar.status`, `avatar.url`) for each primitive property of the file object
|
|
252
|
+
|
|
253
|
+
Sub-field columns are hidden by default but can be added via the "+" column button. File columns are excluded from filters and sorts.
|
|
254
|
+
|
|
255
|
+
To enable file upload/preview in the table, pass `onUploadFile` and `onOpenFile` in `TableEditorCallbacks`. The file cell shows upload and preview buttons on hover when these callbacks are provided. File schemas must be passed through `fetchMetadata` as `refSchemas` in the `TableMetadata` return value:
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
async fetchMetadata() {
|
|
259
|
+
return {
|
|
260
|
+
schema,
|
|
261
|
+
columns,
|
|
262
|
+
viewState,
|
|
263
|
+
readonly: false,
|
|
264
|
+
refSchemas: { [SystemSchemaIds.File]: fileSchema },
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
245
269
|
#### View model API
|
|
246
270
|
|
|
247
271
|
```tsx
|