Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…filter bar, column resize - Add lookupFilters prop to RecordPickerDialog for injecting base filters into $filter - Add cellRenderer prop for type-aware cell formatting (currency, date, select, boolean) - Add filterColumns prop for inline filter bar with text/number/select/date/boolean inputs - Add column resize handles with drag-to-resize support - Create _cell-renderer-bridge.ts to break circular dependency for getCellRenderer - LookupField now passes lookup_filters, getCellRenderer, and derived filterColumns - Add 11 comprehensive tests for all new features Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…eToFilterType helper Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估是否已经完成了任务中要求的所有开发 |
…ters from lookupFilters - Add renderFilterBar slot prop for FilterUI injection from plugin-view - Add renderGrid slot prop for ObjectGrid injection from plugin-grid - Auto-generate filterColumns from lookupFilters when no explicit ones given - Export RecordPickerFilterBarProps and RecordPickerGridSlotProps interfaces - Add 6 new tests for slot props and auto-generation - Total: 37 record-picker tests, 412 fields tests passing Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
评估后发现两个架构性缺口已补齐(commit 3. FilterUI 集成:之前只有内置 filter bar,未提供 FilterUI 注入能力。现在新增 4. ObjectGrid 复用:之前只有列宽调整,未提供 ObjectGrid 注入能力。现在新增 由于 四项需求完成状态:
新增 6 个测试覆盖 slot 注入和自动推导,共 37 个 record-picker 测试全部通过。 |
There was a problem hiding this comment.
Pull request overview
This PR upgrades RecordPickerDialog and LookupField in @object-ui/fields to support schema-driven base filters (lookup_filters), type-aware cell formatting, pluggable FilterUI/ObjectGrid integration via render slots, and column resizing for the built-in table fallback.
Changes:
- Add
lookupFilters,cellRenderer,filterColumns,renderFilterBar, andrenderGridcapabilities toRecordPickerDialog, including filter injection intoDataSource.find(). - Add a bridge module to break the
index.tsx↔RecordPickerDialogcircular dependency forgetCellRenderer. - Extend
LookupFieldto passlookup_filters, derived filter columns, and the bridgedcellRendererintoRecordPickerDialog, plus add comprehensive tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/fields/src/widgets/_cell-renderer-bridge.ts | Adds singleton bridge to share getCellRenderer without circular imports. |
| packages/fields/src/widgets/RecordPickerDialog.tsx | Implements lookup filter injection, filter bar + slots, cell formatting hook, and resize handles. |
| packages/fields/src/widgets/LookupField.tsx | Passes lookup_filters through and derives filter columns/cell renderer for the picker dialog. |
| packages/fields/src/record-picker.test.tsx | Adds test coverage for new RecordPicker features (filters, slots, formatting, resize). |
| packages/fields/src/index.tsx | Registers the cell renderer resolver into the bridge at module init. |
| <Select | ||
| value={val !== undefined && val !== null ? String(val) : ''} | ||
| onValueChange={v => handleFilterChange(col.field, v)} | ||
| > |
| const styleWidth = w ? { width: `${w}px`, minWidth: `${w}px` } : col.width ? { width: col.width } : undefined; | ||
| return ( | ||
| <TableHead | ||
| key={col.field} | ||
| style={styleWidth} |
| select: 'select', | ||
| status: 'select', |
| // Register getCellRenderer in the bridge so RecordPickerDialog can access it | ||
| // via LookupField without circular imports. | ||
| import { setCellRendererResolver } from './widgets/_cell-renderer-bridge'; | ||
| setCellRendererResolver(getCellRenderer); |
| const userFilter = effectiveFilterColumns?.length | ||
| ? filterValuesToRecord(filterValues, effectiveFilterColumns) | ||
| : {}; | ||
| const combined = { ...baseFilter, ...userFilter }; |
| {col.options?.map(opt => ( | ||
| <SelectItem key={String(opt.value)} value={String(opt.value)}> | ||
| {opt.label} | ||
| </SelectItem> | ||
| ))} |
| document.addEventListener('mousemove', handleMouseMove); | ||
| document.addEventListener('mouseup', handleMouseUp); | ||
| }, |
| role="grid" | ||
| aria-label="Records" | ||
| > | ||
| <Table style={Object.keys(columnWidths).length > 0 ? { tableLayout: 'fixed' } : undefined}> |
| options: (f.value as any[]).map(v => { | ||
| if (v != null && typeof v === 'object') { | ||
| const obj = v as Record<string, unknown>; | ||
| return { label: String(obj.name || obj.label || obj.title || v), value: v }; | ||
| } | ||
| return { label: String(v), value: v }; | ||
| }), |
Implements four high-priority RecordPicker features to complete the enterprise Record Picker upgrade: schema-driven filter injection, type-aware cell rendering, FilterUI integration via slot architecture, and ObjectGrid reuse via render prop injection.
lookup_filters consumption
RecordPickerDialogacceptslookupFilters: LookupFilterDef[], converts operators (eq→direct,ne→$ne,in→$in, etc.) to$filterRecord, injected into everyDataSource.find()callLookupFieldreadslookup_filtersfrom field metadata and passes throughCell Type Formatter
RecordPickerDialogaccepts optionalcellRenderer: CellRendererResolverproptypeproperty (e.g.currency,date,select,boolean) are rendered via the resolver; falls back to plain textindex.tsx→LookupField→RecordPickerDialog→index.tsx) broken via_cell-renderer-bridge.tssingleton patternFilterUI filter bar integration
lookupFiltersLookupFieldauto-derivesfilterColumnsfromlookup_columnsentries that havetypeviamapFieldTypeToFilterType()renderFilterBarslot prop allows injecting the actualFilterUIcomponent from@object-ui/plugin-view(avoids circular dependency sinceplugin-viewdepends onfields)RecordPickerFilterBarPropsinterface withfilterColumns,values,onChange,onClear,activeCountfilterColumnsfromlookupFilterswhen no explicitfilterColumnsprop is provided, inferring input types from value types and operatorsObjectGrid table reuse
cursor-col-resize, min-width 60px),table-layout: fixedwhen resizedrenderGridslot prop allows injectingObjectGridfrom@object-ui/plugin-grid(avoids circular dependency sinceplugin-griddepends onfields)RecordPickerGridSlotPropsinterface withcolumns,records,loading,totalCount,currentPage,pageSize,sortField,sortDirection,onSort,onPageChange,onRowClick,isSelected,multiple,idField,cellRendererrenderGridis providedTests
37 record-picker tests (17 new) covering filter injection (3), cell formatting (3), filter bar rendering (3), column resize handles (2), renderFilterBar slot (2), renderGrid slot (2), and auto-generated filter bar from lookupFilters (2). All 412 existing tests continue to pass.
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.