@bimetal/calendar-headless 0.29.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.
Files changed (59) hide show
  1. package/README.md +53 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/click-intent.d.ts +39 -0
  4. package/dist/click-intent.d.ts.map +1 -0
  5. package/dist/click-intent.js +29 -0
  6. package/dist/click-intent.js.map +1 -0
  7. package/dist/controller/config.d.ts +12 -0
  8. package/dist/controller/config.d.ts.map +1 -0
  9. package/dist/controller/config.js +103 -0
  10. package/dist/controller/config.js.map +1 -0
  11. package/dist/controller/create-controller.d.ts +20 -0
  12. package/dist/controller/create-controller.d.ts.map +1 -0
  13. package/dist/controller/create-controller.js +634 -0
  14. package/dist/controller/create-controller.js.map +1 -0
  15. package/dist/controller/types.d.ts +302 -0
  16. package/dist/controller/types.d.ts.map +1 -0
  17. package/dist/controller/types.js +10 -0
  18. package/dist/controller/types.js.map +1 -0
  19. package/dist/controller/view-configs.d.ts +11 -0
  20. package/dist/controller/view-configs.d.ts.map +1 -0
  21. package/dist/controller/view-configs.js +74 -0
  22. package/dist/controller/view-configs.js.map +1 -0
  23. package/dist/date-strings.d.ts +16 -0
  24. package/dist/date-strings.d.ts.map +1 -0
  25. package/dist/date-strings.js +14 -0
  26. package/dist/date-strings.js.map +1 -0
  27. package/dist/defaults.d.ts +22 -0
  28. package/dist/defaults.d.ts.map +1 -0
  29. package/dist/defaults.js +24 -0
  30. package/dist/defaults.js.map +1 -0
  31. package/dist/drag-helpers.d.ts +56 -0
  32. package/dist/drag-helpers.d.ts.map +1 -0
  33. package/dist/drag-helpers.js +69 -0
  34. package/dist/drag-helpers.js.map +1 -0
  35. package/dist/drag-preview.d.ts +102 -0
  36. package/dist/drag-preview.d.ts.map +1 -0
  37. package/dist/drag-preview.js +181 -0
  38. package/dist/drag-preview.js.map +1 -0
  39. package/dist/event-actions.d.ts +64 -0
  40. package/dist/event-actions.d.ts.map +1 -0
  41. package/dist/event-actions.js +135 -0
  42. package/dist/event-actions.js.map +1 -0
  43. package/dist/event-text.d.ts +21 -0
  44. package/dist/event-text.d.ts.map +1 -0
  45. package/dist/event-text.js +37 -0
  46. package/dist/event-text.js.map +1 -0
  47. package/dist/grid-geometry.d.ts +52 -0
  48. package/dist/grid-geometry.d.ts.map +1 -0
  49. package/dist/grid-geometry.js +50 -0
  50. package/dist/grid-geometry.js.map +1 -0
  51. package/dist/index.d.ts +31 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +25 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/validate-save.d.ts +18 -0
  56. package/dist/validate-save.d.ts.map +1 -0
  57. package/dist/validate-save.js +56 -0
  58. package/dist/validate-save.js.map +1 -0
  59. package/package.json +50 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-text.js","sourceRoot":"","sources":["../src/event-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;0EAC0E;AAC1E,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAClE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/D,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;kFAGkF;AAClF,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,MAAM,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,aAAa,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACxC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACxC,OAAO,aAAa,IAAI,aAAa,CAAC;AACxC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Month-grid pixel geometry shared by all framework bindings. Pure math over a
3
+ * plain rect (no DOM types), so it lives once in headless; the binding does the
4
+ * DOM read (`element.getBoundingClientRect()`) and passes the rect in.
5
+ */
6
+ /** Minimal rect shape — structurally satisfied by a DOMRect. */
7
+ export interface GridRowRect {
8
+ readonly left: number;
9
+ readonly width: number;
10
+ }
11
+ /** Width (px) of the leading week-number column in the month grid. */
12
+ export declare const WEEK_NUM_COL_WIDTH = 36;
13
+ /**
14
+ * Which day column (0..colCount-1) the cursor is over, from the mouse X relative
15
+ * to a week-row's bounding rect (accounting for the leading week-number column).
16
+ */
17
+ export declare function getColFromX(clientX: number, rowRect: GridRowRect, colCount?: number): number;
18
+ /**
19
+ * Which day column for a TIME grid — the week/day/all-day rows whose leading
20
+ * gutter is a time-LABEL column (`labelWidth` px), NOT the week-number column.
21
+ * Same math as `getColFromX` with a configurable gutter. (B-CAL-3.)
22
+ */
23
+ export declare function colFromTimeGridX(clientX: number, rowRect: GridRowRect, labelWidth: number, colCount?: number): number;
24
+ /**
25
+ * THE week time-grid hit-test: day column + snapped `HH:MM`, composed from the
26
+ * shared `colFromTimeGridX` + `snapTimeFromMouseY`. Replaces the per-view
27
+ * hand-rolled `getColAndTimeFromMouse` (was duplicated ×4 stacks). The binding
28
+ * measures the inner grid rect and forwards it; all the math lives here.
29
+ */
30
+ export declare function timeGridHit(point: {
31
+ x: number;
32
+ y: number;
33
+ }, rect: {
34
+ left: number;
35
+ top: number;
36
+ width: number;
37
+ }, opts: {
38
+ labelWidth: number;
39
+ hourHeight: number;
40
+ snapMinutes: number;
41
+ colCount?: number;
42
+ }): {
43
+ col: number;
44
+ time: string;
45
+ };
46
+ /**
47
+ * Max timed events a month-grid day cell shows before collapsing to "+N more".
48
+ * UX heuristic: fewer slots when all-day lanes already eat into the cell
49
+ * (`Math.max(1, 3 - cellLanes)`). Was re-derived ×4 in the bindings. (B-CAL-3.)
50
+ */
51
+ export declare function maxVisibleTimedInMonth(cellLanes: number): number;
52
+ //# sourceMappingURL=grid-geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-geometry.d.ts","sourceRoot":"","sources":["../src/grid-geometry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,SAAI,GAAG,MAAM,CAKvF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAKhH;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/B,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAClD,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACvF;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAK/B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Month-grid pixel geometry shared by all framework bindings. Pure math over a
3
+ * plain rect (no DOM types), so it lives once in headless; the binding does the
4
+ * DOM read (`element.getBoundingClientRect()`) and passes the rect in.
5
+ */
6
+ import { snapTimeFromMouseY } from './drag-helpers.js';
7
+ /** Width (px) of the leading week-number column in the month grid. */
8
+ export const WEEK_NUM_COL_WIDTH = 36;
9
+ /**
10
+ * Which day column (0..colCount-1) the cursor is over, from the mouse X relative
11
+ * to a week-row's bounding rect (accounting for the leading week-number column).
12
+ */
13
+ export function getColFromX(clientX, rowRect, colCount = 7) {
14
+ const x = clientX - rowRect.left - WEEK_NUM_COL_WIDTH;
15
+ const dayAreaWidth = rowRect.width - WEEK_NUM_COL_WIDTH;
16
+ const col = Math.floor((x / dayAreaWidth) * colCount);
17
+ return Math.max(0, Math.min(colCount - 1, col));
18
+ }
19
+ /**
20
+ * Which day column for a TIME grid — the week/day/all-day rows whose leading
21
+ * gutter is a time-LABEL column (`labelWidth` px), NOT the week-number column.
22
+ * Same math as `getColFromX` with a configurable gutter. (B-CAL-3.)
23
+ */
24
+ export function colFromTimeGridX(clientX, rowRect, labelWidth, colCount = 7) {
25
+ const x = clientX - rowRect.left - labelWidth;
26
+ const dayAreaWidth = rowRect.width - labelWidth;
27
+ const col = Math.floor((x / dayAreaWidth) * colCount);
28
+ return Math.max(0, Math.min(colCount - 1, col));
29
+ }
30
+ /**
31
+ * THE week time-grid hit-test: day column + snapped `HH:MM`, composed from the
32
+ * shared `colFromTimeGridX` + `snapTimeFromMouseY`. Replaces the per-view
33
+ * hand-rolled `getColAndTimeFromMouse` (was duplicated ×4 stacks). The binding
34
+ * measures the inner grid rect and forwards it; all the math lives here.
35
+ */
36
+ export function timeGridHit(point, rect, opts) {
37
+ return {
38
+ col: colFromTimeGridX(point.x, rect, opts.labelWidth, opts.colCount),
39
+ time: snapTimeFromMouseY(point.y, rect, opts.hourHeight, opts.snapMinutes),
40
+ };
41
+ }
42
+ /**
43
+ * Max timed events a month-grid day cell shows before collapsing to "+N more".
44
+ * UX heuristic: fewer slots when all-day lanes already eat into the cell
45
+ * (`Math.max(1, 3 - cellLanes)`). Was re-derived ×4 in the bindings. (B-CAL-3.)
46
+ */
47
+ export function maxVisibleTimedInMonth(cellLanes) {
48
+ return Math.max(1, 3 - cellLanes);
49
+ }
50
+ //# sourceMappingURL=grid-geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-geometry.js","sourceRoot":"","sources":["../src/grid-geometry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQvD,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,OAAoB,EAAE,QAAQ,GAAG,CAAC;IAC7E,MA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AC,SAAiB;IACtD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @module @bimetal/calendar-headless
3
+ *
4
+ * Framework-agnostic headless calendar adapter layer.
5
+ * Sits between Core/Data and framework-specific packages.
6
+ *
7
+ * React, Vue, Angular, and Svelte packages wrap these adapters
8
+ * with their reactive primitives — they add no business logic.
9
+ */
10
+ export { createEventActions } from './event-actions.js';
11
+ export type { EventActions } from './event-actions.js';
12
+ export { validateSavePreview } from './validate-save.js';
13
+ export { computeDragPreview, computeTimedDragPreview, findExpandedEvent, buildDragInfo, computePreviewEvent } from './drag-preview.js';
14
+ export type { DragPreview, DragInfo } from './drag-preview.js';
15
+ export { snapTimeFromMouseY, parseDragInfo, DRAG_MIME, writeCalendarDragData, installTransparentDragImage } from './drag-helpers.js';
16
+ export type { DragDataReader, DragDataWriter } from './drag-helpers.js';
17
+ export { createClickIntent } from './click-intent.js';
18
+ export type { ClickIntent, ClickIntentState } from './click-intent.js';
19
+ export { relativeLuminance, eventBarWantsDarkText } from './event-text.js';
20
+ export { createCalendarController } from './controller/create-controller.js';
21
+ export type { CalendarController, CalendarControllerOptions, CalendarControllerSnapshot, CalendarConfig, CalendarConfigInput, CalendarLocale, Category, ViewConfig, CustomViewSpec, EventDialogKind, AnchorRect, DialogState, EventDraft, SelectionState, LastAction, NormalizedKeyEvent, } from './controller/types.js';
22
+ export { mergeCalendarConfig, defaultCalendarConfig, defaultLocale } from './controller/config.js';
23
+ export { createViewConfigs } from './controller/view-configs.js';
24
+ export { toDateStr, toTimeStr, parseDateStr, parseDateTimeStr } from './date-strings.js';
25
+ export { WEEK_NUM_COL_WIDTH, getColFromX, colFromTimeGridX, timeGridHit, maxVisibleTimedInMonth } from './grid-geometry.js';
26
+ export { ZERO_RECT } from '@bimetal/headless-core';
27
+ export { DEFAULT_UNDO_DISMISS_MS, DEFAULT_AGENDA_RANGE_DAYS, DEFAULT_SCROLL_HOUR, DEFAULT_HOUR_HEIGHT, DEFAULT_TIME_LABEL_WIDTH_DAY, DEFAULT_TIME_LABEL_WIDTH_WEEK, DEFAULT_RESOURCE_LABEL_WIDTH, } from './defaults.js';
28
+ export type { CalendarEvent, CalendarDateTime, TimeRange, CoreConfig, RecurrenceInstanceMetadata, } from '@bimetal/calendar-core';
29
+ export { RECURRENCE_MASTER_ID_KEY, RECURRENCE_INSTANCE_DATE_KEY, isExpandedRecurrenceInstance, getRecurrenceInstanceMetadata, stripRecurrenceInstanceMetadata, } from '@bimetal/calendar-core';
30
+ export type { CalendarStore, CalendarReadModel, Unsubscribe, } from '@bimetal/calendar-data';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvI,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrI,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5H,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @module @bimetal/calendar-headless
3
+ *
4
+ * Framework-agnostic headless calendar adapter layer.
5
+ * Sits between Core/Data and framework-specific packages.
6
+ *
7
+ * React, Vue, Angular, and Svelte packages wrap these adapters
8
+ * with their reactive primitives — they add no business logic.
9
+ */
10
+ export { createEventActions } from './event-actions.js';
11
+ export { validateSavePreview } from './validate-save.js';
12
+ export { computeDragPreview, computeTimedDragPreview, findExpandedEvent, buildDragInfo, computePreviewEvent } from './drag-preview.js';
13
+ export { snapTimeFromMouseY, parseDragInfo, DRAG_MIME, writeCalendarDragData, installTransparentDragImage } from './drag-helpers.js';
14
+ export { createClickIntent } from './click-intent.js';
15
+ export { relativeLuminance, eventBarWantsDarkText } from './event-text.js';
16
+ // ── Canonical Calendar Controller (the single source of interaction semantics) ──
17
+ export { createCalendarController } from './controller/create-controller.js';
18
+ export { mergeCalendarConfig, defaultCalendarConfig, defaultLocale } from './controller/config.js';
19
+ export { createViewConfigs } from './controller/view-configs.js';
20
+ export { toDateStr, toTimeStr, parseDateStr, parseDateTimeStr } from './date-strings.js';
21
+ export { WEEK_NUM_COL_WIDTH, getColFromX, colFromTimeGridX, timeGridHit, maxVisibleTimedInMonth } from './grid-geometry.js';
22
+ export { ZERO_RECT } from '@bimetal/headless-core';
23
+ export { DEFAULT_UNDO_DISMISS_MS, DEFAULT_AGENDA_RANGE_DAYS, DEFAULT_SCROLL_HOUR, DEFAULT_HOUR_HEIGHT, DEFAULT_TIME_LABEL_WIDTH_DAY, DEFAULT_TIME_LABEL_WIDTH_WEEK, DEFAULT_RESOURCE_LABEL_WIDTH, } from './defaults.js';
24
+ export { RECURRENCE_MASTER_ID_KEY, RECURRENCE_INSTANCE_DATE_KEY, isExpandedRecurrenceInstance, getRecurrenceInstanceMetadata, stripRecurrenceInstanceMetadata, } from '@bimetal/calendar-core';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEvI,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAErI,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,mFAAmF;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAmB7E,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5H,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AAUvB,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Preview validation for save operations.
3
+ *
4
+ * Evaluates rules against the event that would be saved,
5
+ * without actually dispatching. Used by UI dialogs to show
6
+ * validation errors before the user commits.
7
+ */
8
+ import type { CalendarEvent, CoreConfig } from '@bimetal/calendar-core';
9
+ import type { CalendarRule } from '@bimetal/calendar-rules';
10
+ /**
11
+ * Validate an event against rules before saving.
12
+ * Returns an array of error/warning messages (empty = valid).
13
+ *
14
+ * This is the single implementation — all framework components delegate here
15
+ * instead of duplicating the rule evaluation logic.
16
+ */
17
+ export declare function validateSavePreview(event: CalendarEvent, currentEvents: readonly CalendarEvent[], config: CoreConfig, rules: readonly CalendarRule[]): string[];
18
+ //# sourceMappingURL=validate-save.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-save.d.ts","sourceRoot":"","sources":["../src/validate-save.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAoB,MAAM,wBAAwB,CAAC;AAO1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,SAAS,aAAa,EAAE,EACvC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,YAAY,EAAE,GAC7B,MAAM,EAAE,CAyCV"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Preview validation for save operations.
3
+ *
4
+ * Evaluates rules against the event that would be saved,
5
+ * without actually dispatching. Used by UI dialogs to show
6
+ * validation errors before the user commits.
7
+ */
8
+ import { now as coreNow, buildSaveChanges, getRecurrenceInstanceMetadata, stripRecurrenceInstanceMetadata, } from '@bimetal/calendar-core';
9
+ import { createEvent, updateEvent, modifyInstance } from '@bimetal/calendar-data';
10
+ import { createRuleEngine } from '@bimetal/calendar-rules';
11
+ /**
12
+ * Validate an event against rules before saving.
13
+ * Returns an array of error/warning messages (empty = valid).
14
+ *
15
+ * This is the single implementation — all framework components delegate here
16
+ * instead of duplicating the rule evaluation logic.
17
+ */
18
+ export function validateSavePreview(event, currentEvents, config, rules) {
19
+ if (rules.length === 0)
20
+ return [];
21
+ const engine = createRuleEngine(rules);
22
+ // Detect expanded recurring instance — the dialog passes the instance, but
23
+ // the real save dispatches ModifyInstance. Mirror that here so noOverlap
24
+ // and friends see the same command shape and exclude the master correctly.
25
+ const instanceMarkers = getRecurrenceInstanceMetadata(event);
26
+ let command;
27
+ if (instanceMarkers) {
28
+ const instanceDate = { epochMs: instanceMarkers.instanceDate, timezone: config.timezone };
29
+ command = modifyInstance(instanceMarkers.masterEventId, instanceDate, {
30
+ title: event.title,
31
+ timeRange: event.timeRange,
32
+ allDay: event.allDay,
33
+ metadata: stripRecurrenceInstanceMetadata(event.metadata),
34
+ domains: event.domains,
35
+ });
36
+ }
37
+ else {
38
+ const isExisting = currentEvents.some(e => e.id === event.id);
39
+ command = isExisting
40
+ ? updateEvent(event.id, buildSaveChanges(event))
41
+ : createEvent(event);
42
+ }
43
+ // JSON-clone strips reactive framework proxies (Svelte 5 $state, Vue ref/reactive)
44
+ // that structuredClone refuses. CalendarEvent is plain JSON-serializable data.
45
+ const context = {
46
+ readModel: { events: JSON.parse(JSON.stringify([...currentEvents])), version: 0 },
47
+ config,
48
+ now: coreNow(config.timezone, config.clock),
49
+ };
50
+ const result = engine.evaluate(command, context);
51
+ return [
52
+ ...result.errors.filter(r => !r.passed).map(r => !r.passed ? r.message : ''),
53
+ ...result.warnings.filter(r => !r.passed).map(r => !r.passed ? r.message : ''),
54
+ ].filter(Boolean);
55
+ }
56
+ //# sourceMappingURL=validate-save.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-save.js","sourceRoot":"","sources":["../src/validate-save.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,GAAG,IAAI,OAAO,EAAE,gBAAgB,EAChC,6BAA6B,EAAE,+BAA+B,GAC/D,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAA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AI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;QACjF,MAAM;QACN,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC;KAC5C,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEjD,OAAO;QACL,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/E,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@bimetal/calendar-headless",
3
+ "version": "0.29.0",
4
+ "description": "Framework-agnostic headless calendar adapter: event actions, drag preview logic",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -b",
21
+ "dev": "tsc -b --watch",
22
+ "typecheck": "tsc --noEmit",
23
+ "test": "vitest run",
24
+ "prepublishOnly": "npm run build"
25
+ },
26
+ "dependencies": {
27
+ "@bimetal/core": "^0.29.0",
28
+ "@bimetal/calendar-core": "^0.29.0",
29
+ "@bimetal/calendar-data": "^0.29.0",
30
+ "@bimetal/calendar-rules": "^0.29.0",
31
+ "@bimetal/headless-core": "^0.29.0"
32
+ },
33
+ "devDependencies": {
34
+ "vitest": "^3.2.4"
35
+ },
36
+ "sideEffects": false,
37
+ "license": "PolyForm-Noncommercial-1.0.0",
38
+ "author": "Andreas Biederbeck",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/bimetal/bimetal.git",
42
+ "directory": "packages/calendar/calendar-headless"
43
+ },
44
+ "keywords": [
45
+ "calendar",
46
+ "headless",
47
+ "adapter",
48
+ "framework-agnostic"
49
+ ]
50
+ }