Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .changeset/7632-shared-record-source-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ input matrix, so a later edit to the shared reader that moves any site turns red

**Two divergences were measured rather than assumed, and both are preserved.**

`ObjectCalendar`'s `'data' in schema && schema.data` guards exist because its parameter is
the union `ObjectGridSchema | CalendarSchema` and `CalendarSchema` declares neither key.
`ObjectCalendar`'s `'data' in schema && schema.data` guards existed because its parameter was
at that time the union `ObjectGridSchema | CalendarSchema`, whose `CalendarSchema` arm declared
neither key. (objectui#8651 has since re-pointed that parameter at the published
`ObjectCalendarSchema`, so the union is gone; the CONCLUSION below — that the guard had no
runtime effect and removing it is behaviour-neutral — is unaffected.)
That is a TypeScript narrowing device with no runtime effect — an absent property reads
`undefined`, falsy either way — so the guard could never change which rung is taken. The
shared reader's optional-property parameter accepts the union directly, and the
Expand Down
13 changes: 13 additions & 0 deletions .changeset/olive-buckets-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@object-ui/plugin-calendar": minor
"@object-ui/types": minor
---

fix(plugin-calendar): type `ObjectCalendar` at the published `object-calendar` schema, and declare the `calendar` container

`ObjectCalendarComponentProps.schema` was the union `ObjectGridSchema | CalendarSchema` — a grid's schema, plus a plugin-local interface absent from this package's barrel. Neither arm is the schema of the element this renderer is registered as. Measured with the TypeScript checker: of the fifteen keys the renderer reads off the node, seven were undeclared on that union and had to be read through a cast, while five more resolved only through `ObjectGridSchema`'s index signature and were therefore typed `any` — admitted, never examined. `ObjectCalendarSchema` already declared eleven of the fifteen.

- `ObjectCalendarComponentProps.schema` is now `ObjectCalendarSchema`. **Breaking for a React host that passed an `object-grid` node or a `type: 'calendar'` literal to `ObjectCalendar`** — neither was ever a node this renderer is registered for. `ObjectCalendarProps`, the deprecated alias, follows it.
- `ObjectCalendarSchema.calendar` is declared on both published faces. The spec declares the KEY; it does **not** declare its shape — `ComponentPropsMap['object-calendar'].calendar` is `z.unknown().optional()` and accepts anything at that position — so the member list is objectui's own: the four `CalendarConfigSchema` names plus objectui's `allDayField`, which is what the renderer reads out of the block. The container keeps `.passthrough()`, so no KEY that parsed before is refused — an unexamined key inside the block still parses, and so do `calendar.dateField` and `calendar.defaultView`. What is new is VALUE validation: `calendar: 42` and `calendar: { startDateField: 42 }` are refused where both were admitted unexamined.
- `@object-ui/types` now exports the type `ObjectCalendarBlockConfig`, so that published member has a name an importer can write.
- ⚠️ The `dateField` / `endField` alias rungs in `getCalendarConfig` are **kept**, and routed to the producer. An earlier revision of this change retired them on a census that was false: `ListView` flattens an authored `calendar` block onto the node it emits, and `resolveTimelineDateBinding` in that same file documents `dateField` as the pre-#2231 alias for `startDateField` and honours it — so a view authored that way renders today and would have drawn "Calendar configuration required". (objectui's own `ListViewSchema` also accepts `calendar.dateField`, but only weakly: that block is `.passthrough()` and admits nonsense too, so the load-bearing half is the producer and the read site, not the accept.) No behaviour changes for either spelling. The alias question already has a carrier — objectui#8355, open and undecided — and the producer-side remedy belongs in `ListView`'s calendar branch.
2 changes: 1 addition & 1 deletion content/docs/plugins/plugin-calendar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ const taskCalendar: ObjectCalendarSchema = {

You can also import and use the components directly in React:

{/* doc-snippet: fragment — the `ObjectCalendar` half cannot compile against the SHIPPED prop type: `ObjectCalendarComponentProps.schema` is declared `ObjectGridSchema | CalendarSchema`, and neither admits an `object-calendar` node — `ObjectGridSchema.type` is the literal `'object-grid'` and `CalendarSchema` is the FORM date picker (`type: 'calendar'`). The renderer registered for `object-calendar` passes exactly this shape (`index.tsx`), and `ObjectCalendar.tsx` reads `objectName` / `calendar` / `staticData` off it, so the runtime path is real and the declaration is the stale half — filed as objectui#7311 rather than papered over with a cast (measured: TS2322 x1) */}
{/* doc-snippet: fragment — the `ObjectCalendar` half cannot compile as written, because the `schema` literal below omits the required `type: 'object-calendar'` discriminant. The SHIPPED prop type is `ObjectCalendarComponentProps.schema: ObjectCalendarSchema` (`plugin-calendar/dist/ObjectCalendar.d.ts`), whose `type` member is the literal `'object-calendar'`. Compiling this exact block against the built workspace measures TS2741 x1 (Property 'type' is missing) and TS2322 x0. ⚠️ This reason was rewritten by objectui#8651: it previously said the prop was declared a grid/date-picker union and that neither arm admitted an `object-calendar` node, with a measurement of TS2322 x1. Every clause of that reason is false at this head, because objectui#8651 re-pointed the prop at the published element schema — which is also why the objectui#7311 'stale declaration' framing is gone. ⛔ Whether the old TS2322 x1 held when it was written is NOT asserted here: that would need a build of the old tree, which was not done. The fix for the block itself is to add the discriminant, not a cast. */}
```tsx
import { CalendarView, ObjectCalendar } from '@object-ui/plugin-calendar';
import type { DataSource } from '@object-ui/types';
Expand Down
Loading
Loading