@object-ui/plugin-calendar 17.6.0 → 18.0.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
@@ -19,6 +19,11 @@ Calendar view plugins for Object UI - includes both ObjectQL-integrated and stan
19
19
  option.
20
20
  - **ObjectQL Integration** - Connect to ObjectStack data sources
21
21
  - **Standalone Mode** - Use with static data or custom backends
22
+ - **Locale week start** - Every week starts on the first day of the week
23
+ of the calendar's locale (the `locale` prop, else the display locale):
24
+ Sunday under `en-US`, Monday under `en-GB` or `zh-CN`. The month grid,
25
+ its weekday heads, the week view's columns, the header's week range and
26
+ the date popover all start on that day.
22
27
  - **Responsive** - Mobile-friendly calendar layouts
23
28
  - **Customizable** - Tailwind CSS styling support
24
29
 
@@ -28,8 +33,8 @@ Calendar view plugins for Object UI - includes both ObjectQL-integrated and stan
28
33
 
29
34
  | Gesture | Effect |
30
35
  | --- | --- |
31
- | Drag the event pill body to another day cell | Shifts both `startDateField` and `endDateField` by the day delta. Grab cell → drop cell defines the delta, so dragging from any day of a multi-day span works as expected. |
32
- | Drag the right-edge handle of a multi-day pill | Adjusts only `endDateField`; start is preserved. Refuses drops earlier than start. |
36
+ | Drag the event pill body to another day cell | Moves both `startDateField` and `endDateField` by the calendar days from the grabbed cell to the drop cell, each keeping its time of day: a 10:00 event stays at 10:00, even across a DST change. Grab cell → drop cell defines the days, so dragging from any day of a multi-day span works as expected. |
37
+ | Drag the right-edge handle of a multi-day pill | Moves only `endDateField` to the drop day, keeping its time of day; start is preserved. Refuses drops earlier than start. |
33
38
 
34
39
  ### Week / Day view (time grid)
35
40
 
@@ -72,6 +77,32 @@ The new record is optimistically inserted into local state so it
72
77
  appears immediately. To override (e.g. open your own create form), pass
73
78
  `onDateClick={(day) => …}` — the default behaviour is skipped.
74
79
 
80
+ The dialog is offered only where that payload can succeed. If the object
81
+ has a required field outside the set above (a required lookup, a required
82
+ text field other than the title), the click — or a range drag in the
83
+ week/day grid — opens the host's full create form instead: the calendar
84
+ calls `onEdit` with a new record (no `id`) carrying the date values, e.g.
85
+ `onEdit({ due_date: '2026-10-20' })`, and the host pre-fills its create form
86
+ with them. The console does this already. Without an `onEdit`, the gesture
87
+ offers nothing on such an object. Required fields the server fills on insert
88
+ (`readonly`, `system`, `autonumber`) do not count.
89
+
90
+ ## Reporting the visible days
91
+
92
+ A host that fetches the calendar's records for it, and hands them over as
93
+ `data`, can fetch only the days on screen. `ObjectCalendar` reports them
94
+ through `onVisibleRangeChange={({ start, end }) => …}`: once on mount, and
95
+ again whenever navigation or a view change moves them. `start` is local
96
+ midnight of the first day drawn and `end` local midnight of the day after the
97
+ last, so the range is half-open. In the month view it covers the whole
98
+ six-week grid, including the leading and trailing days of the neighbouring
99
+ months, under the locale's first day of the week; in the week view it is the
100
+ week, and in the day view the day. An unchanged range is not reported again.
101
+
102
+ `ListView` (`@object-ui/plugin-list`) uses it to fetch a calendar view's
103
+ visible days instead of one batch of the object (objectui#12081). Like the
104
+ other host callbacks, it is forwarded only when the value is a function.
105
+
75
106
  ## Installation
76
107
 
77
108
  ```bash
@@ -149,30 +180,62 @@ ComponentRegistry.register('my-calendar', ObjectCalendarRenderer);
149
180
  ### CalendarView
150
181
 
151
182
  Display a calendar computed from the node's `data` records. This is the full
152
- authored surface: `CalendarViewSchema` in `@object-ui/types` declares 13 keys of
153
- its own, converged on what the registered `calendar-view` renderer actually
154
- reads (objectui#5667). Two of them — `data` and `className` — refine common
155
- `BaseSchema` keys; the rest of `BaseSchema` (`id`, `visible`, ...) applies as on
156
- any node.
183
+ authored surface: `CalendarViewSchema` in `@object-ui/types` declares 15 keys of
184
+ its own. **13 of them are authorable**, converged on what the registered
185
+ `calendar-view` renderer actually reads (objectui#5667), and they are the ones
186
+ listed below. Two of them — `data` and `className` — refine common `BaseSchema`
187
+ keys; the rest of `BaseSchema` (`id`, `visible`, ...) applies as on any node.
188
+
189
+ **The other two are REFUSALS, not keys you can write.** `body` and `children`
190
+ are declared `never` (objectui#9256): a read-site sweep of every package that
191
+ registers a component measured that no renderer read consumes either content
192
+ channel for a `calendar-view` node — it renders events computed from `data`, not
193
+ child nodes — so authoring one is now refused at `tsc` and at validation instead
194
+ of silently rendering nothing. They are counted above because the interface
195
+ declares them; they are absent from the listing below because the listing is the
196
+ *authorable* surface.
157
197
 
158
198
  ```typescript
159
- {
160
- type: 'calendar-view',
161
- data?: any, // records rendered as events (array, or a binding expression)
162
- titleField?: string, // default 'title'
163
- startDateField?: string, // default 'start'
164
- endDateField?: string, // default 'end'
165
- allDayField?: string, // default 'allDay'
166
- colorField?: string, // default 'color'
167
- view?: CalendarViewMode, // 'month' | 'week' | 'day' (default 'month')
168
- currentDate?: string | Date, // ISO string authored; Date from a React host
169
- allowCreate?: boolean, // default false — shows the "New event" button
170
- className?: string, // Tailwind classes for the container
171
- onEventClick?: (event: CalendarEvent) => void, // HOST-ONLY (see below)
172
- onViewChange?: (view: CalendarViewMode) => void // HOST-ONLY (see below)
173
- }
199
+ import type { CalendarViewSchema, CalendarViewMode, CalendarEvent } from '@object-ui/types';
200
+
201
+ type CalendarViewNode = {
202
+ type: 'calendar-view';
203
+ data?: any; // records rendered as events (array, or a binding expression)
204
+ titleField?: string; // default 'title'
205
+ startDateField?: string; // default 'start'
206
+ endDateField?: string; // default 'end'
207
+ allDayField?: string; // default 'allDay'
208
+ colorField?: string; // default 'color'
209
+ view?: CalendarViewMode; // 'month' | 'week' | 'day' (default 'month')
210
+ currentDate?: string | Date; // ISO string authored; Date from a React host
211
+ allowCreate?: boolean; // default false — shows the "New event" button
212
+ className?: string; // Tailwind classes for the container
213
+ onEventClick?: (event: CalendarEvent) => void; // HOST-ONLY (see below)
214
+ onViewChange?: (view: CalendarViewMode) => void; // HOST-ONLY (see below)
215
+ };
216
+
217
+ // The listing above is held to the shipped type BY THE COMPILER, both
218
+ // directions, rather than by this paragraph: a key whose type here disagrees
219
+ // with what `CalendarViewSchema` declares is a compile error.
220
+ declare const authored: CalendarViewNode;
221
+ declare const shipped: CalendarViewSchema;
222
+ const forwards: CalendarViewSchema = authored;
223
+ const backwards: CalendarViewNode = shipped;
174
224
  ```
175
225
 
226
+ > **What those two assignments do and do not buy.** They check every key's
227
+ > **type**, in both directions. They do **not** check a key's **spelling**:
228
+ > both assign a declared variable, not a fresh object literal, and TypeScript
229
+ > runs its excess-property check only on a fresh literal. So a key renamed in
230
+ > the listing is an extra optional member on one side and simply absent on the
231
+ > other, and both assignments still compile. A fresh literal IS checked:
232
+ > `CalendarViewSchema` extends `BaseSchema`, which carries no index signature
233
+ > since objectui#8347, so
234
+ > `const node: CalendarViewSchema = { type: 'calendar-view', titleFieldd: 'name' }`
235
+ > is a compile error. Metadata that arrives as data is a question for the zod
236
+ > faces (the strict `StrictAnyComponentSchema` refuses an unknown key), not for
237
+ > TypeScript.
238
+
176
239
  There is deliberately **no authorable `events` key**: the renderer computes its
177
240
  events from `data` plus the field-name keys, and drops an authored `events`
178
241
  (objectui#4433). Nine formerly declared keys — `events`, `defaultView`,
@@ -233,34 +296,93 @@ const schema = {
233
296
  ```
234
297
 
235
298
  The records above already use the default field names (`title`, `start`, `end`,
236
- `color`), so no field-name keys are needed; point `titleField` /
237
- `startDateField` / `endDateField` / `allDayField` / `colorField` at your own
238
- fields when they differ.
299
+ `color`), so no field-name keys are needed; on a `calendar-view` node, point
300
+ `titleField` / `startDateField` / `endDateField` / `allDayField` / `colorField`
301
+ at your own fields when they differ. They sit flat on this node because
302
+ `CalendarViewSchema` has no `calendar` block: here the flat keys are the only
303
+ spelling. An `object-calendar` takes the same five inside its `calendar` block
304
+ instead (next section).
239
305
 
240
306
  ### With ObjectQL Integration
241
307
 
308
+ Every key below is one `ObjectCalendarSchema` declares. The five field-name keys
309
+ go inside the `calendar` block: `getCalendarConfig` reads that block first and
310
+ returns it whole. A misspelt start-date key inside it is therefore not a partial
311
+ failure either: no record has a date to be placed by, so every one is counted
312
+ as unscheduled under the calendar instead of drawn.
313
+
314
+ `startDateField` is the only one of the five the calendar needs — `titleField`
315
+ is optional, and an event with no explicit title resolves one through the
316
+ ADR-0079 record display-name chain. A calendar authored with no `calendar`
317
+ block renders the "Calendar configuration required" refusal screen, which says
318
+ so and also names where the key belongs: the view's `calendar` block. That
319
+ matters on an **interface page**, whose `interfaceConfig` has no calendar slot
320
+ of its own — the only lever there is `sourceView`, pointed at a view that
321
+ declares the block (objectui#8170).
322
+
323
+ The same five keys written flat on the node are **not** a second way to author
324
+ this. That flat spelling is the runtime handoff — `ObjectView` and `ListView`
325
+ emit it on the node they build, and `getCalendarConfig` falls back to it only
326
+ when the node has no `calendar` block — so `ObjectCalendarSchema` declares it
327
+ because the renderer reads it. `@objectstack/spec` refuses it at authoring with
328
+ `unrecognized_keys` and names the `calendar` block in the same diagnostic (one
329
+ key per concept, its Prime Directive #12).
330
+
242
331
  ```typescript
243
- const schema = {
332
+ import type { ObjectCalendarSchema } from '@object-ui/types';
333
+
334
+ // What this annotation buys, and what it does not - measured, objectui#7925.
335
+ // It type-checks the VALUES of the declared keys: `defaultView: 'agenda'` and
336
+ // `calendar: { titleField: 42 }` are both compile errors, and
337
+ // `check:doc-snippets` re-runs that check on every commit. Top-level key NAMES
338
+ // are checked too since objectui#8347 removed `BaseSchema`'s `[key: string]: any`,
339
+ // and since objectui#6152 so are the key names inside the `calendar` block: its
340
+ // type is the spec's strict `object-calendar` slot, so a misspelt key there, or
341
+ // a block without `startDateField`, is a compile error as well as a parse error.
342
+ const schema: ObjectCalendarSchema = {
244
343
  type: 'object-calendar',
245
- object: 'events',
246
- titleField: 'name',
247
- startField: 'startDate',
248
- endField: 'endDate',
249
- colorField: 'category.color'
344
+ objectName: 'events',
345
+ calendar: {
346
+ titleField: 'name',
347
+ startDateField: 'startDate',
348
+ endDateField: 'endDate',
349
+ allDayField: 'isAllDay',
350
+ colorField: 'statusColor'
351
+ },
352
+ defaultView: 'month',
353
+ navigation: { mode: 'modal' } // what an event click opens - see below
250
354
  };
251
355
  ```
252
356
 
357
+ `navigation` is what an event click opens — the spec's `NavigationConfig` by
358
+ reference, `ViewNavigationConfig` in `@object-ui/types`, the type
359
+ `ObjectGridSchema.navigation` uses: `mode` (`page`, `drawer`, `modal`, `split`,
360
+ `popover`, `new_window` or `none`) with `size`, `openNewTab` and
361
+ `preventNavigation`. With the key absent a click opens the record in a drawer.
362
+ An overlay mode keeps the click from a parent view's `onRowClick` /
363
+ `onEventClick`; any other mode hands it to them. `page` — and a block written
364
+ without `mode`, which takes the spec's `page` default — opens the record page
365
+ through the record navigator the host publishes on `RelatedRecordActionsContext`
366
+ (objectui#11293); the console publishes one on its custom pages, record pages and
367
+ list views. Under a host that publishes none, such as an embedded renderer,
368
+ there is no record page to open and the click opens nothing.
369
+
253
370
  ### Interactive Calendar
254
371
 
255
372
  The handlers are host-only — a function can only come from a React host
256
373
  building the node in code, never from authored JSON:
257
374
 
258
375
  ```typescript
259
- const schema = {
376
+ import type { CalendarViewSchema } from '@object-ui/types';
377
+
378
+ // The annotation is what types the two handler parameters: `event` is
379
+ // `CalendarEvent` and `view` is `CalendarViewMode`, read off the shipped
380
+ // schema. Without it both are implicitly `any`.
381
+ const schema: CalendarViewSchema = {
260
382
  type: 'calendar-view',
261
383
  data: [],
262
384
  onEventClick: (event) => {
263
- console.log('Event clicked:', event);
385
+ console.log('Event clicked:', event.title);
264
386
  // Open event details modal
265
387
  },
266
388
  onViewChange: (view) => {
@@ -276,38 +398,66 @@ Authored JSON reacts to clicks through the node's action channel instead
276
398
 
277
399
  ## ObjectQL Integration
278
400
 
279
- When using with ObjectStack, the calendar can automatically fetch and display events:
401
+ When using with ObjectStack, the calendar can automatically fetch and display
402
+ events. The adapter is **not** a schema key: `ObjectCalendarRenderer` reads it
403
+ from the renderer context that `SchemaRendererProvider` supplies. The schema
404
+ names the object with `objectName` and its fields inside the same `calendar`
405
+ block as above - there is no `fields` container.
280
406
 
281
407
  ```typescript
282
408
  import { createObjectStackAdapter } from '@object-ui/data-objectstack';
409
+ import type { ObjectCalendarSchema } from '@object-ui/types';
283
410
 
284
411
  const dataSource = createObjectStackAdapter({
285
412
  baseUrl: 'https://api.example.com',
286
413
  token: 'your-auth-token'
287
414
  });
288
415
 
289
- const schema = {
416
+ // The annotation checks the values of the declared keys, not the key names -
417
+ // see the note on the first `object-calendar` block above.
418
+ const schema: ObjectCalendarSchema = {
290
419
  type: 'object-calendar',
291
- dataSource,
292
- object: 'calendar_events',
293
- fields: {
294
- title: 'title',
295
- start: 'start_time',
296
- end: 'end_time',
297
- color: 'category_color'
298
- }
420
+ objectName: 'calendar_events',
421
+ calendar: {
422
+ titleField: 'title',
423
+ startDateField: 'start_time',
424
+ endDateField: 'end_time'
425
+ },
426
+ defaultView: 'month'
299
427
  };
300
428
  ```
301
429
 
430
+ Pass the adapter to `SchemaRendererProvider` to wire the fetch up.
431
+
432
+ **The provider does not change which query keys apply** (objectui#9061, the port
433
+ of objectui#8769). An authored `filter` and `sort` narrow and order the records
434
+ on **every** provider, inline ones included — both `staticData` and
435
+ `data: { provider: 'value', items }` reach the same in-memory adapter the
436
+ `object` provider goes through, so `filter` is evaluated with the same matcher.
437
+ Before objectui#9061 the inline provider skipped that query and drew every
438
+ authored record with an authored `filter` silently dropped. The platform row
439
+ ceiling (2,000 drawn rows, with a footnote naming both numbers — objectui#7210,
440
+ ruling a′) applies to inline records too, and it is applied to the **filtered**
441
+ set, never to the raw one: a large inline array that a `filter` cuts below the
442
+ ceiling draws every matching record and shows no footnote.
443
+
444
+ ⚠️ Two consequences of routing inline records through the adapter. They reach the
445
+ calendar as that adapter's own deep copy rather than as the authored array's
446
+ object identities, so code comparing a record handed to `onEventClick` against
447
+ the authored array with `===` needs `id` equality instead; and the copy is a JSON
448
+ round-trip, so inline records must be JSON-serializable.
449
+
302
450
  ## Customization
303
451
 
304
452
  Style the calendar with Tailwind classes:
305
453
 
306
454
  ```typescript
307
- const schema = {
455
+ import type { CalendarViewSchema } from '@object-ui/types';
456
+
457
+ const schema: CalendarViewSchema = {
308
458
  type: 'calendar-view',
309
459
  className: 'border rounded-lg shadow-lg',
310
- data: [...]
460
+ data: [] // your records
311
461
  };
312
462
  ```
313
463
 
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarView.d.ts","sourceRoot":"","sources":["../src/CalendarView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AA0C9B;;;;;;;;;;GAUG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAUtG;AAsBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,IAAI,CAAA;IACX,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC5B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAA;IAC/B,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACjD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAA;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,UA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1
1
  import { default as React } from 'react';
2
- import { ObjectGridSchema, DataSource } from '@object-ui/types';
3
- export interface CalendarSchema {
4
- type: 'calendar';
5
- objectName?: string;
6
- dateField?: string;
7
- endField?: string;
8
- titleField?: string;
9
- colorField?: string;
10
- filter?: any;
11
- sort?: any;
12
- /** Initial view mode */
13
- defaultView?: 'month' | 'week' | 'day';
14
- }
2
+ import { ObjectCalendarSchema, DataSource } from '@object-ui/types';
3
+ /**
4
+ * ⛔ RETIRED (objectui#8651) — a plugin-local `CalendarSchema` used to sit here,
5
+ * and `ObjectCalendarComponentProps.schema` below was the union of it with
6
+ * `ObjectGridSchema`. Both arms are gone; the prop is now the published schema
7
+ * of the element this file is registered as (`index.tsx`, both tags).
8
+ *
9
+ * What the union cost, measured with the TypeScript checker on the merge-base
10
+ * (`getPropertyOfType`, never a grep — objectui#8410). Of the fifteen keys this
11
+ * renderer reads off the node, FOUR were declared on neither arm and EIGHT on
12
+ * exactly one, while `ObjectCalendarSchema` already declared ELEVEN of the
13
+ * fifteen.
14
+ *
15
+ * ⚠️ But the cast count is NOT twelve, and an earlier cut of this comment said
16
+ * it was. `ObjectGridSchema` carried `BaseSchema`'s `[key: string]: any` (until
17
+ * objectui#8347), so on the UNION the five `CalendarSchema`-only keys resolved through that index
18
+ * signature and compiled with no cast at all. The checker on the union itself:
19
+ * DECLARED 8 of 15 (`colorField` `dateField` `defaultView` `endField` `filter`
20
+ * `objectName` `sort` `titleField`), NOT declared 7 (`allDayField` `calendar`
21
+ * `data` `endDateField` `navigation` `startDateField` `staticData`), nonsense
22
+ * control `false`. ⇒ SEVEN reads needed a cast, not twelve.
23
+ *
24
+ * ⭐ That reading is worse for the old shape, not better: those five compiled
25
+ * silently as `any` — admitted through an index signature, never examined —
26
+ * which is the objectui#6914 defect itself rather than an absence of one. A
27
+ * cast at least announces the gap. The union's own index signature is `false`,
28
+ * which is why the other seven had to be cast.
29
+ *
30
+ * The two arms failed differently and neither was salvageable:
31
+ *
32
+ * - `ObjectGridSchema` is `type: 'object-grid'`. No producer hands this
33
+ * component one: the single call site is this package's `index.tsx`, whose
34
+ * two registrations both publish `OBJECT_CALENDAR_INPUTS`.
35
+ * - the local interface was absent from this package's barrel, so no importer
36
+ * could name it, and it SHADOWED `@object-ui/types`' own published
37
+ * `CalendarSchema` — the date-picker primitive reachable at `ui:calendar`
38
+ * only (objectui#8499). Its two distinctive members were the alias spellings
39
+ * `dateField` / `endField`, which objectui#8355 has since RETIRED at both
40
+ * faces — `getCalendarConfig` below reads the declared spellings only, and
41
+ * `@object-ui/types` refuses the two by name.
42
+ *
43
+ * The shape this leaves is the family's: `ObjectKanban` takes
44
+ * `ObjectKanbanSchema`, `ObjectGantt` takes `ObjectGanttSchema`, `ObjectMap`
45
+ * takes `ObjectMapSchema` — and `plugin-map` is registered under two tags with
46
+ * one published props type, exactly as this package is.
47
+ *
48
+ * Pinned in `__tests__/calendarUnionReads-8651.test.tsx`.
49
+ */
15
50
  /**
16
51
  * Props of the `ObjectCalendar` React component.
17
52
  *
@@ -29,7 +64,7 @@ export interface CalendarSchema {
29
64
  * no importer breaks. Tripwire: `__tests__/spec-symbol-4650.test.ts`.
30
65
  */
31
66
  export interface ObjectCalendarComponentProps {
32
- schema: ObjectGridSchema | CalendarSchema;
67
+ schema: ObjectCalendarSchema;
33
68
  dataSource?: DataSource;
34
69
  className?: string;
35
70
  /** Pre-fetched records passed by a parent (e.g. ObjectView). When provided, skips internal data fetching. */
@@ -37,12 +72,55 @@ export interface ObjectCalendarComponentProps {
37
72
  /** Loading state propagated from a parent. Respected only when `data` is also provided. */
38
73
  loading?: boolean;
39
74
  onEventClick?: (record: any) => void;
40
- onRowClick?: (record: any) => void;
75
+ /**
76
+ * TWO parameters since objectui#9357, and the second is not decoration: this
77
+ * prop reaches `useNavigationOverlay` as its `onRowClick`, and `handleClick`
78
+ * invokes it as `onRowClick(record, event)` — the modifier payload a host
79
+ * needs to implement Cmd/Ctrl/middle-click for itself. Declaring one
80
+ * parameter hid the second on the ONE line a host reads. Spelled `any` and
81
+ * not `HandleClickModifiers` for the reason objectui#9341 measured on
82
+ * `ObjectKanbanSchema.onCardClick`: that interface lives in
83
+ * `@object-ui/react`, the published twins in `@object-ui/types` may not name
84
+ * it, and a host that discovered the payload from the implementation
85
+ * annotated it `React.MouseEvent` — which a narrower declaration refuses
86
+ * contravariantly. `BaseSchema`'s own `onClick` / `onChange` / `onSubmit`
87
+ * already use this spelling for exactly this situation.
88
+ */
89
+ onRowClick?: (record: any, event?: any) => void;
41
90
  onDateClick?: (date: Date) => void;
91
+ /**
92
+ * The host's record form, opened on `record`. This component calls it for
93
+ * one gesture (objectui#12291): an empty-day click, or a range drag in the
94
+ * week / day grid, on an object with a required field quick-create cannot
95
+ * fill (`requiredFieldsQuickCreateCannotFill`). Quick-create could not
96
+ * succeed there, so the gesture hands the day to the host's full create
97
+ * form instead of offering the dialog: `record` is then a NEW record — it
98
+ * carries no `id` — whose keys are the date fields the click sets, written
99
+ * in their stored form, and the host pre-fills its create form with them.
100
+ * The console's handler already reads a record without an id as a new one.
101
+ * With no `onEdit`, that gesture offers nothing on such an object.
102
+ */
42
103
  onEdit?: (record: any) => void;
43
104
  onDelete?: (record: any) => void;
44
105
  onNavigate?: (date: Date) => void;
45
106
  onViewChange?: (view: 'month' | 'week' | 'day') => void;
107
+ /**
108
+ * The days the calendar draws, reported to a host that fetches its records
109
+ * for it (objectui#12081): on mount, and again whenever navigation or a view
110
+ * change moves them. `start` is local midnight of the first day on screen and
111
+ * `end` local midnight of the day after the last, so the range is half-open.
112
+ *
113
+ * This is the channel `ListView` windows its calendar fetch through: the
114
+ * calendar alone knows which days it draws (the month grid's leading and
115
+ * trailing days, the locale's first day of the week, the phone's day view),
116
+ * so the host is told rather than left to infer them from `onNavigate` and
117
+ * `onViewChange`, neither of which fires for the state the calendar opens
118
+ * on.
119
+ */
120
+ onVisibleRangeChange?: (range: {
121
+ start: Date;
122
+ end: Date;
123
+ }) => void;
46
124
  onEventDrop?: (record: any, newStart: Date, newEnd?: Date) => void;
47
125
  locale?: string;
48
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectCalendar.d.ts","sourceRoot":"","sources":["../src/ObjectCalendar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AA8B/F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6GAA6G;IAC7G,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;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AC;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IACxD;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA6RD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CA2vCjE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ObjectCalendar, ObjectCalendarComponentProps } from './ObjectCalendar';
2
+ import { ObjectCalendar, ObjectCalendarComponentProps } from './ObjectCalendar.js';
3
3
  export { ObjectCalendar };
4
4
  export type { ObjectCalendarComponentProps };
5
5
  /**
@@ -9,9 +9,9 @@ export type { ObjectCalendarComponentProps };
9
9
  * this component's props. The alias denotes the SAME type and is kept only so
10
10
  * existing importers keep compiling.
11
11
  */
12
- export type { ObjectCalendarComponentProps as ObjectCalendarProps } from './ObjectCalendar';
13
- export { CalendarView } from './CalendarView';
14
- export type { CalendarViewProps, CalendarViewEvent } from './CalendarView';
12
+ export type { ObjectCalendarComponentProps as ObjectCalendarProps } from './ObjectCalendar.js';
13
+ export { CalendarView } from './CalendarView.js';
14
+ export type { CalendarViewProps, CalendarViewEvent } from './CalendarView.js';
15
15
  /**
16
16
  * @deprecated Use `CalendarViewEvent`. Renamed in objectui#5044 because
17
17
  * `@object-ui/types` owns `CalendarEvent`, where it means the AUTHORING event
@@ -27,7 +27,7 @@ export type { CalendarViewProps, CalendarViewEvent } from './CalendarView';
27
27
  * module specifier is judged as its own declaration by
28
28
  * `scripts/check-spec-symbol-derivation.mjs`.
29
29
  */
30
- export type { CalendarViewEvent as CalendarEvent } from './CalendarView';
30
+ export type { CalendarViewEvent as CalendarEvent } from './CalendarView.js';
31
31
  export declare const ObjectCalendarRenderer: React.FC<{
32
32
  schema: any;
33
33
  [key: string]: any;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,4BAA4B,EAAE,CAAC;AAE7C;;;;;;GAMG;AACH,YAAY,EAAE,4BAA4B,IAAI,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,YAAY,EAAE,iBAAiB,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,0BAA0B,CAAC;AAyLlC,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,MAAM,EAAE,GAAG,CAAC;I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