|
22 | 22 | */ |
23 | 23 |
|
24 | 24 | import React, { useEffect, useState, useCallback, useMemo } from 'react'; |
25 | | -import type { ObjectGridSchema, DataSource, DependsOnInput, ListColumn, TableSortItem, DataTableSchema, ListViewExportFormat, RecordNavigateAction } from '@object-ui/types'; |
| 25 | +import type { ObjectGridSchema, DataSource, DependsOnInput, ListColumn, ViewData, TableSortItem, DataTableSchema, ListViewExportFormat, RecordNavigateAction } from '@object-ui/types'; |
26 | 26 | import { isSystemManagedField, normalizeTableColumnType } from '@object-ui/types'; |
27 | 27 | import { parseFilterAST, resolveFieldScale, type FilterCondition } from '@objectstack/spec/data'; |
28 | 28 | import { SchemaRenderer, useDataScope, useNavigationOverlay, useAction, useSafeFieldLabel, usePredicateScope, useCapabilityGate, useDataInvalidation, notifyDataChanged, useFilterScope, useMetadata } from '@object-ui/react'; |
@@ -58,7 +58,7 @@ import { |
58 | 58 | toast, |
59 | 59 | } from '@object-ui/components'; |
60 | 60 | import { usePullToRefresh } from '@object-ui/mobile'; |
61 | | -import { resolveConditionalFormatting, resolveDependsOnFields, isDeadlineSettled, leadWithNameField, declaredNameField, buildExpandFields, buildExportFileName, columnIdentity, collectPredicateFieldRefs, collectGroupingFieldRefs, listViewPredicates, resolveAffordance, resolveFieldAffordance, type SchemaLike, isProjectableField, isExpandableFieldType, isUnmaterializedFieldType, readObjectSortability, isPlatformSortableField, filterPlatformSortableSort, toFilterNodeSafely, filterRefusalSubject, FilterOperatorError, convertSortToQueryParams, normalizeSortEntries, type QuerySortEntry, resolveRecordSourceObjectName, partitionRowsByPredicate, buildCategoryOrder, buildCategoryRank, toDisplayDate } from '@object-ui/core'; |
| 61 | +import { resolveConditionalFormatting, resolveDependsOnFields, isDeadlineSettled, leadWithNameField, declaredNameField, buildExpandFields, buildExportFileName, columnIdentity, collectPredicateFieldRefs, collectGroupingFieldRefs, listViewPredicates, resolveAffordance, resolveFieldAffordance, type SchemaLike, isProjectableField, isExpandableFieldType, isUnmaterializedFieldType, readObjectSortability, isPlatformSortableField, filterPlatformSortableSort, toFilterNodeSafely, filterRefusalSubject, FilterOperatorError, convertSortToQueryParams, normalizeSortEntries, type QuerySortEntry, resolveRecordSourceConfig, resolveRecordSourceObjectName, partitionRowsByPredicate, buildCategoryOrder, buildCategoryRank, toDisplayDate } from '@object-ui/core'; |
62 | 62 | import { usePermissions } from '@object-ui/permissions'; |
63 | 63 | import { |
64 | 64 | RECORD_OVERLAY_DEFAULT_WIDTH, |
@@ -87,7 +87,7 @@ import { BulkActionBar } from './components/BulkActionBar'; |
87 | 87 | import { BulkActionDialog } from './components/BulkActionDialog'; |
88 | 88 | import type { BulkResult } from './hooks/useBulkExecutor'; |
89 | 89 | import type { BulkActionDef } from '@object-ui/types'; |
90 | | -import { findParamsSignature, getDataConfig, useResolvedGridFilters } from './objectGridQuery'; |
| 90 | +import { findParamsSignature, useResolvedGridFilters } from './objectGridQuery'; |
91 | 91 | import { type ObjectGridColumn, type ObjectGridColumnDraft, isChipFieldType, normalizeColumns, resolveColumnLabel } from './objectGridColumns'; |
92 | 92 | import { LinkCell, recordPointerFace, rowRecordId } from './objectGridLinkCell'; |
93 | 93 | import { useGridTranslation } from './objectGridTranslations'; |
@@ -463,6 +463,55 @@ export interface ObjectGridComponentProps extends ObjectGridExternalPaginationPr |
463 | 463 | onAddRecord?: () => void; |
464 | 464 | } |
465 | 465 |
|
| 466 | +/** |
| 467 | + * Helper to get data configuration from schema. |
| 468 | + * |
| 469 | + * The ruled three-rung ladder itself (`data`, then `staticData`, then |
| 470 | + * `objectName`) is `resolveRecordSourceConfig` in `@object-ui/core` — ONE |
| 471 | + * implementation of a contract published on both faces (`77cb489b4`), which |
| 472 | + * this file used to hand-copy (`ce2aaefe1`). |
| 473 | + * |
| 474 | + * What used to stay here was the head above it: the bare-array `data` |
| 475 | + * shorthand, which lifted `data: [...]` to `{ provider: 'value', items }`. |
| 476 | + * ⛔ IT IS GONE (objectui#8348, decision batch #83, maintainer verbatim |
| 477 | + * 「8348 以协议为准」 — the contract decides). |
| 478 | + * |
| 479 | + * MEASURED on `@objectstack/spec` 17.4.0: |
| 480 | + * `ComponentPropsMap['object-grid'].data` is the `ViewData` union, and its own |
| 481 | + * description names the refusal — *"Static inline rows live at |
| 482 | + * `{ provider: 'value', items: [...] }`; the bare-array shortcut is refused — |
| 483 | + * see migration `object-grid-data-view-data-converged`"*. This block's own |
| 484 | + * registration publishes the same arm (`{ name: 'data', type: 'object' }` in |
| 485 | + * `index.tsx`), and `gridDataInputContract.test.ts` has pinned that declaration |
| 486 | + * since objectui#5090. The head was the last carrier of a spelling every one of |
| 487 | + * those faces refuses, so `data` is honoured here on the OBJECT arm only and |
| 488 | + * the shared rung is passed `'view-data'`. |
| 489 | + * |
| 490 | + * ⛔ WHAT THIS REACHES, measured per CARRIER — do NOT read it as "the array is |
| 491 | + * gone". An authored `data` array reaches this component TWICE: as |
| 492 | + * `schema.data`, which this function used to lift, and as the `data` PROP, |
| 493 | + * because `SchemaRenderer` spreads every non-metadata node key and |
| 494 | + * `index.tsx` forwards `{...rest}`. That prop is `passedData` below, and it |
| 495 | + * lifts an array to `{ provider: 'value', items }` at HIGHER priority than this |
| 496 | + * ladder — it is the channel a host such as `ListView` uses to hand down rows it |
| 497 | + * already fetched, and it is indistinguishable here from an authored key. |
| 498 | + * |
| 499 | + * ⇒ at the ladder the array is no longer a record source; through |
| 500 | + * `SchemaRenderer` an authored `data: [ …rows… ]` still draws, from the props |
| 501 | + * channel. Both halves are pinned in |
| 502 | + * `__tests__/gridBareArrayDataRefused-8348.test.tsx`, which had to correct its |
| 503 | + * own first draft on exactly this point. Collapsing the two carriers would take |
| 504 | + * the host path with it and is outside objectui#8348's scope — reported on the |
| 505 | + * card, not changed in passing. |
| 506 | + * |
| 507 | + * The declared spelling for inline rows is |
| 508 | + * `data: { provider: 'value', items: [...] }`, and the deprecated `staticData` |
| 509 | + * array still works as before. |
| 510 | + */ |
| 511 | +function getDataConfig(schema: ObjectGridSchema): ViewData | null { |
| 512 | + return resolveRecordSourceConfig(schema, 'view-data'); |
| 513 | +} |
| 514 | + |
466 | 515 | /** |
467 | 516 | * The relational copy set and `applyRelationalMeta` moved to |
468 | 517 | * `./relationalMetaKeys` for objectui#6875. The list there is DERIVED from a |
|
0 commit comments