@lavalogic/scoria 0.40.21 → 0.40.24

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.
@@ -0,0 +1,25 @@
1
+ import type { CalendarEvent, ResourceCalendarProps } from './ResourceCalendarProps.js';
2
+ declare function $$render<E extends CalendarEvent>(): {
3
+ props: ResourceCalendarProps<E>;
4
+ exports: {};
5
+ bindings: "";
6
+ slots: {};
7
+ events: {};
8
+ };
9
+ declare class __sveltets_Render<E extends CalendarEvent> {
10
+ props(): ReturnType<typeof $$render<E>>['props'];
11
+ events(): ReturnType<typeof $$render<E>>['events'];
12
+ slots(): ReturnType<typeof $$render<E>>['slots'];
13
+ bindings(): "";
14
+ exports(): {};
15
+ }
16
+ interface $$IsomorphicComponent {
17
+ new <E extends CalendarEvent>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<E>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<E>['props']>, ReturnType<__sveltets_Render<E>['events']>, ReturnType<__sveltets_Render<E>['slots']>> & {
18
+ $$bindings?: ReturnType<__sveltets_Render<E>['bindings']>;
19
+ } & ReturnType<__sveltets_Render<E>['exports']>;
20
+ <E extends CalendarEvent>(internal: unknown, props: ReturnType<__sveltets_Render<E>['props']> & {}): ReturnType<__sveltets_Render<E>['exports']>;
21
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
22
+ }
23
+ declare const ResourceCalendar: $$IsomorphicComponent;
24
+ type ResourceCalendar<E extends CalendarEvent> = InstanceType<typeof ResourceCalendar<E>>;
25
+ export default ResourceCalendar;
@@ -0,0 +1,116 @@
1
+ import type { InputDateWithTime } from '../../Types/Internal/Misc.js';
2
+ import type { SvelteDate } from 'svelte/reactivity';
3
+ import type { Snippet } from 'svelte';
4
+ /**
5
+ * Available calendar view modes.
6
+ *
7
+ * Frozen const + derived type, following the scoria enum-as-const convention.
8
+ */
9
+ export declare const CalendarViewMode: {
10
+ readonly Day: "day";
11
+ readonly Week: "week";
12
+ readonly Month: "month";
13
+ };
14
+ export type CalendarViewMode = (typeof CalendarViewMode)[keyof typeof CalendarViewMode];
15
+ /**
16
+ * A column the calendar lays events out under — a generic "lane" such as a
17
+ * room, a machine, a person, or (in the appointments app) a door.
18
+ */
19
+ export interface CalendarResource {
20
+ readonly id: number;
21
+ readonly label: string;
22
+ }
23
+ /**
24
+ * The minimum data a calendar event must supply: an id, the resource (column)
25
+ * it belongs to, and its start/end. Consumers extend this interface with their
26
+ * own domain fields and render the card body + colours via the `event` snippet
27
+ * — the component itself is domain-agnostic.
28
+ *
29
+ * `start` and `end` are branded with {@link InputDateWithTime} so callers
30
+ * cannot pass a raw `string` that does not parse as an ISO date-time. The
31
+ * branded values remain plain strings at runtime; the component parses them
32
+ * into `Date` internally.
33
+ */
34
+ export interface CalendarEvent {
35
+ readonly id: number;
36
+ readonly resourceId: number;
37
+ readonly start: InputDateWithTime;
38
+ readonly end: InputDateWithTime;
39
+ }
40
+ /**
41
+ * A span of available time on the currently displayed day, expressed in minutes
42
+ * from midnight (`startMinutes` inclusive, `endMinutes` exclusive). Consumed by
43
+ * {@link ResourceCalendarProps.availability} to shade out times a resource is
44
+ * not bookable.
45
+ */
46
+ export interface CalendarAvailabilityWindow {
47
+ readonly startMinutes: number;
48
+ readonly endMinutes: number;
49
+ }
50
+ /** Emitted when the user click-drags a new time range within a resource column. */
51
+ export interface CalendarRangeSelection {
52
+ readonly resourceId: number;
53
+ readonly start: Date;
54
+ readonly end: Date;
55
+ }
56
+ /** Emitted when the user drags an existing event to a new resource and/or time. */
57
+ export interface CalendarEventMoveArgs<E extends CalendarEvent> {
58
+ readonly event: E;
59
+ readonly newResourceId: number;
60
+ readonly newStart: Date;
61
+ readonly newEnd: Date;
62
+ }
63
+ export interface ResourceCalendarProps<E extends CalendarEvent> {
64
+ /** The columns to display (e.g. doors, rooms, machines). */
65
+ resources: ReadonlyArray<CalendarResource>;
66
+ /** The events to render. */
67
+ events: ReadonlyArray<E>;
68
+ /**
69
+ * Renders one event's card body and colours. The component only provides
70
+ * the positioned, interactive wrapper (drag/click) around it, so the
71
+ * consumer owns all domain-specific appearance. The snippet should render a
72
+ * full-size card (e.g. `height: 100%`).
73
+ */
74
+ event: Snippet<[E]>;
75
+ /**
76
+ * The currently selected date. Accepts a `Date` or a `SvelteDate`; the
77
+ * component never writes to it — use `ondatechange`.
78
+ */
79
+ selectedDate: Date | SvelteDate;
80
+ /** The current view mode. */
81
+ viewMode: CalendarViewMode;
82
+ /** Called when the user changes the selected date. */
83
+ ondatechange: (date: Date) => void;
84
+ /** Called when the user changes the view mode. */
85
+ onviewmodechange: (mode: CalendarViewMode) => void;
86
+ /** Called when the user click-drags to select a new time range in a column. */
87
+ onrangeselect?: (selection: CalendarRangeSelection) => void;
88
+ /** Called when the user clicks an event. */
89
+ oneventclick?: (event: E) => void;
90
+ /** Called when the user drags an event to a new resource and/or time slot. */
91
+ oneventmove?: (args: CalendarEventMoveArgs<E>) => void;
92
+ /** The start hour for the day/week grid (default: 0). */
93
+ startHour?: number;
94
+ /** The end hour for the day/week grid (default: 24). */
95
+ endHour?: number;
96
+ /** The slot interval in minutes (default: 15). */
97
+ slotIntervalMinutes?: number;
98
+ /**
99
+ * Per-resource availability for the displayed day, keyed by resource id.
100
+ *
101
+ * Any slot whose start falls outside all of a resource's windows is shaded
102
+ * unavailable and cannot seed/receive an event. A resource absent from the
103
+ * map is fully available (no shading); map an id to an empty array to mark
104
+ * it wholly unavailable. Omit the prop to disable shading.
105
+ */
106
+ availability?: ReadonlyMap<number, ReadonlyArray<CalendarAvailabilityWindow>>;
107
+ /**
108
+ * Hour of the day (0–23) to vertically centre when the day/week grid first
109
+ * appears (default: 12). Set to `null` to keep the grid scrolled to the top.
110
+ */
111
+ centreHour?: number | null;
112
+ /** Whether the calendar is loading data. */
113
+ isLoading?: boolean;
114
+ /** Optional snippet for extra header content (e.g. buttons). */
115
+ headerExtra?: Snippet;
116
+ }
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Available calendar view modes.
3
3
  *
4
- * Frozen const + derived type, following the scoria
5
- * enum-as-const convention.
4
+ * Frozen const + derived type, following the scoria enum-as-const convention.
6
5
  */
7
6
  export const CalendarViewMode = {
8
7
  Day: 'day',
@@ -2,7 +2,7 @@
2
2
  * Global fallback configuration for all loaders.
3
3
  *
4
4
  * Loaders rendered *internally* by components like {@link Table},
5
- * {@link DesktopModal} and {@link AppointmentCalendar} can't be handed a `name`
5
+ * {@link DesktopModal} and {@link ResourceCalendar} can't be handed a `name`
6
6
  * prop at the call site. So the host app sets {@link loaderDefaults.name} once —
7
7
  * typically in its root layout inside a browser `$effect` — and every loader
8
8
  * (including those internal ones) spells that name. An explicit `name` prop on a
@@ -2,7 +2,7 @@
2
2
  * Global fallback configuration for all loaders.
3
3
  *
4
4
  * Loaders rendered *internally* by components like {@link Table},
5
- * {@link DesktopModal} and {@link AppointmentCalendar} can't be handed a `name`
5
+ * {@link DesktopModal} and {@link ResourceCalendar} can't be handed a `name`
6
6
  * prop at the call site. So the host app sets {@link loaderDefaults.name} once —
7
7
  * typically in its root layout inside a browser `$effect` — and every loader
8
8
  * (including those internal ones) spells that name. An explicit `name` prop on a
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as AccordionGroup } from './Components/AccordionGroup.svelte';
2
- export { default as AppointmentCalendar } from './Components/AppointmentCalendar/AppointmentCalendar.svelte';
3
- export type { AppointmentCalendarProps, AppointmentMoveArgs, CalendarAppointment, CalendarDoor, CalendarViewMode, DoorAvailabilityWindow, DragSelection, } from './Components/AppointmentCalendar/AppointmentCalendarProps.js';
2
+ export { default as ResourceCalendar } from './Components/ResourceCalendar/ResourceCalendar.svelte';
3
+ export type { CalendarAvailabilityWindow, CalendarEvent, CalendarEventMoveArgs, CalendarRangeSelection, CalendarResource, CalendarViewMode, ResourceCalendarProps, } from './Components/ResourceCalendar/ResourceCalendarProps.js';
4
4
  export type { AccordionGroupButtonProps, AccordionGroupOption, } from './Components/AccordionGroupButtonProps.js';
5
5
  export type { AccordionGroupProps } from './Components/AccordionGroupProps.js';
6
6
  export { default as Action } from './Components/Action.svelte';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as AccordionGroup } from './Components/AccordionGroup.svelte';
2
- export { default as AppointmentCalendar } from './Components/AppointmentCalendar/AppointmentCalendar.svelte';
2
+ export { default as ResourceCalendar } from './Components/ResourceCalendar/ResourceCalendar.svelte';
3
3
  export { default as Action } from './Components/Action.svelte';
4
4
  export { default as AlertModal } from './Components/AlertModal.svelte';
5
5
  export { default as ContextWrapper } from './Components/Base/ContextWrapper.svelte';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.40.21",
4
+ "version": "0.40.24",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },
@@ -1,4 +0,0 @@
1
- import type { AppointmentCalendarProps } from './AppointmentCalendarProps.js';
2
- declare const AppointmentCalendar: import("svelte").Component<AppointmentCalendarProps, {}, "">;
3
- type AppointmentCalendar = ReturnType<typeof AppointmentCalendar>;
4
- export default AppointmentCalendar;
@@ -1,123 +0,0 @@
1
- import type { InputDateWithTime } from '../../Types/Internal/Misc.js';
2
- import type { SvelteDate } from 'svelte/reactivity';
3
- import type { Snippet } from 'svelte';
4
- /**
5
- * Available calendar view modes.
6
- *
7
- * Frozen const + derived type, following the scoria
8
- * enum-as-const convention.
9
- */
10
- export declare const CalendarViewMode: {
11
- readonly Day: "day";
12
- readonly Week: "week";
13
- readonly Month: "month";
14
- };
15
- export type CalendarViewMode = (typeof CalendarViewMode)[keyof typeof CalendarViewMode];
16
- /**
17
- * A single appointment on the calendar.
18
- *
19
- * `dateFrom` and `dateTo` are branded with {@link InputDateWithTime} so
20
- * callers cannot accidentally pass a raw `string` that does not parse
21
- * as an ISO date-time. The branded values remain plain strings at
22
- * runtime; the component parses them into `Date` internally.
23
- */
24
- export interface CalendarAppointment {
25
- readonly id: number;
26
- readonly segmentId: number;
27
- readonly dateFrom: InputDateWithTime;
28
- readonly dateTo: InputDateWithTime;
29
- readonly typeCode: string;
30
- readonly label: string;
31
- readonly sublabel?: string;
32
- /** Optional booking reference shown on the appointment card. */
33
- readonly reference?: string;
34
- }
35
- export interface CalendarDoor {
36
- readonly id: number;
37
- readonly name: string;
38
- }
39
- export interface DragSelection {
40
- readonly doorId: number;
41
- readonly doorName: string;
42
- readonly dateFrom: Date;
43
- readonly dateTo: Date;
44
- }
45
- /**
46
- * A span of available time on the currently displayed day, expressed in
47
- * minutes from midnight (`startMinutes` inclusive, `endMinutes`
48
- * exclusive). Consumed by {@link AppointmentCalendarProps.availability}
49
- * to shade out the times a door is not bookable.
50
- */
51
- export interface DoorAvailabilityWindow {
52
- readonly startMinutes: number;
53
- readonly endMinutes: number;
54
- }
55
- /**
56
- * Arguments passed to {@link AppointmentCalendarProps.onappointmentmove}.
57
- *
58
- * The previous five-positional-argument signature was easy to mix up
59
- * at the call site; this object form makes each field self-describing.
60
- */
61
- export interface AppointmentMoveArgs {
62
- readonly appointment: CalendarAppointment;
63
- readonly newDoorId: number;
64
- readonly newDoorName: string;
65
- readonly newDateFrom: Date;
66
- readonly newDateTo: Date;
67
- }
68
- export interface AppointmentCalendarProps {
69
- /** The doors (segments) to display as columns. */
70
- doors: ReadonlyArray<CalendarDoor>;
71
- /** The appointments to render on the calendar. */
72
- appointments: ReadonlyArray<CalendarAppointment>;
73
- /**
74
- * The currently selected date.
75
- *
76
- * Accepts either a `Date` (which the component reads but does not
77
- * mutate) or a `SvelteDate` for callers that want reactive
78
- * day-rollover semantics. The component never writes to the value;
79
- * use `ondatechange` to update it.
80
- */
81
- selectedDate: Date | SvelteDate;
82
- /** The current view mode. */
83
- viewMode: CalendarViewMode;
84
- /** Called when the user changes the selected date. */
85
- ondatechange: (date: Date) => void;
86
- /** Called when the user changes the view mode. */
87
- onviewmodechange: (mode: CalendarViewMode) => void;
88
- /** Called when the user clicks and drags to create a new appointment. */
89
- ondragcreate?: (selection: DragSelection) => void;
90
- /** Called when the user clicks on an existing appointment. */
91
- onappointmentclick?: (appointment: CalendarAppointment) => void;
92
- /** Called when the user drags an existing appointment to a new door or time slot. */
93
- onappointmentmove?: (args: AppointmentMoveArgs) => void;
94
- /** The start hour for the day view grid (default: 0). */
95
- startHour?: number;
96
- /** The end hour for the day view grid (default: 24). */
97
- endHour?: number;
98
- /** The slot interval in minutes (default: 15). */
99
- slotIntervalMinutes?: number;
100
- /**
101
- * Per-door availability for the currently displayed day, keyed by
102
- * door (segment) id.
103
- *
104
- * When a door id is present, any slot whose start falls outside all
105
- * of its {@link DoorAvailabilityWindow}s is shaded as unavailable and
106
- * cannot be used to create or receive an appointment. A door absent
107
- * from the map is treated as fully available (no shading); map an id
108
- * to an empty array to mark a door wholly unavailable for the day.
109
- *
110
- * Omit the prop entirely to disable availability shading.
111
- */
112
- availability?: ReadonlyMap<number, ReadonlyArray<DoorAvailabilityWindow>>;
113
- /**
114
- * Hour of the day (0–23) to vertically centre when the day/week grid
115
- * first appears (default: 12, i.e. midday). Set to `null` to keep the
116
- * grid scrolled to the top.
117
- */
118
- centreHour?: number | null;
119
- /** Whether the calendar is loading data. */
120
- isLoading?: boolean;
121
- /** Optional snippet for extra header content (e.g. buttons). */
122
- headerExtra?: Snippet;
123
- }