Skip to content
Merged
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
51 changes: 36 additions & 15 deletions packages/plugin-calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,29 @@ fields when they differ.

### With ObjectQL Integration

Every key below is one `ObjectCalendarSchema` declares. Spelling the start-date
key anything else is not a partial failure: `getCalendarConfig` gates the whole
configuration on it, so a calendar whose title and end keys are spelled correctly
still renders the "Calendar configuration required" refusal screen and never
reads them.

```typescript
const schema = {
import type { ObjectCalendarSchema } from '@object-ui/types';

// What this annotation buys, and what it does not - measured, objectui#7925.
// It type-checks the VALUES of the declared keys: `defaultView: 'agenda'` and
// `titleField: 42` are both compile errors, and `check:doc-snippets` re-runs
// that check on every commit. It does NOT check key NAMES - this interface
// extends `BaseSchema`, whose `[key: string]: any` admits any spelling, so a
// misspelt key still compiles clean. Read the block as type-checked values,
// never as a guarded key set.
const schema: ObjectCalendarSchema = {
type: 'object-calendar',
object: 'events',
objectName: 'events',
titleField: 'name',
startField: 'startDate',
endField: 'endDate',
colorField: 'category.color'
startDateField: 'startDate',
endDateField: 'endDate',
defaultView: 'month'
};
```

Expand Down Expand Up @@ -298,29 +313,35 @@ Authored JSON reacts to clicks through the node's action channel instead

## ObjectQL Integration

When using with ObjectStack, the calendar can automatically fetch and display events:
When using with ObjectStack, the calendar can automatically fetch and display
events. The adapter is **not** a schema key: `ObjectCalendarRenderer` reads it
from the renderer context that `SchemaRendererProvider` supplies. The schema
names the object and its fields with the same flat keys as above - there is no
`fields` container.

```typescript
import { createObjectStackAdapter } from '@object-ui/data-objectstack';
import type { ObjectCalendarSchema } from '@object-ui/types';

const dataSource = createObjectStackAdapter({
baseUrl: 'https://api.example.com',
token: 'your-auth-token'
});

const schema = {
// The annotation checks the values of the declared keys, not the key names -
// see the note on the first `object-calendar` block above.
const schema: ObjectCalendarSchema = {
type: 'object-calendar',
dataSource,
object: 'calendar_events',
fields: {
title: 'title',
start: 'start_time',
end: 'end_time',
color: 'category_color'
}
objectName: 'calendar_events',
titleField: 'title',
startDateField: 'start_time',
endDateField: 'end_time',
defaultView: 'month'
};
```

Pass the adapter to `SchemaRendererProvider` to wire the fetch up.

## Customization

Style the calendar with Tailwind classes:
Expand Down