@revisium/schema-toolkit-ui 0.4.0 → 0.6.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
@@ -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
  },
@@ -154,7 +154,7 @@ import type { ITableDataSource } from '@revisium/schema-toolkit-ui';
154
154
 
155
155
  const dataSource: ITableDataSource = {
156
156
  async fetchMetadata() {
157
- // Return { schema, columns, viewState, readonly }
157
+ // Return { schema, columns, viewState, readonly, refSchemas? }
158
158
  },
159
159
  async fetchRows(query) {
160
160
  // query: { where, orderBy, search, first, after }
@@ -168,7 +168,7 @@ const dataSource: ITableDataSource = {
168
168
  // Return { ok, error? }
169
169
  },
170
170
  async saveView(viewState) {
171
- // Persist column/filter/sort/search settings
171
+ // Persist column order, widths, pins, and sort settings
172
172
  // Return { ok, error? }
173
173
  },
174
174
  };
@@ -238,10 +238,35 @@ 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 |
244
+ | `onReadonlyEditAttempt` | `() => void` | Called when the user tries to edit a read-only cell (double-click, Enter, typing). Use this to show a toast/notification. Throttled internally (2 s). |
242
245
 
243
246
  In read-only mode (`fetchMetadata` returns `readonly: true`), delete and duplicate actions are hidden automatically. Open row still works.
244
247
 
248
+ #### File columns
249
+
250
+ File fields (`$ref` to the File schema) are automatically resolved into:
251
+ - A **parent file column** (`FilterFieldType.File`) that displays the `fileName` and supports inline editing of the file name
252
+ - **Sub-field columns** (e.g., `avatar.status`, `avatar.url`) for each primitive property of the file object
253
+
254
+ Sub-field columns are hidden by default but can be added via the "+" column button. File columns are excluded from filters and sorts.
255
+
256
+ 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:
257
+
258
+ ```tsx
259
+ async fetchMetadata() {
260
+ return {
261
+ schema,
262
+ columns,
263
+ viewState,
264
+ readonly: false,
265
+ refSchemas: { [SystemSchemaIds.File]: fileSchema },
266
+ };
267
+ }
268
+ ```
269
+
245
270
  #### View model API
246
271
 
247
272
  ```tsx