@besaitech/ng-design-system 0.0.77 → 0.0.78

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,207 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { SdsSegmentedOption } from '@besaitech/ng-design-system';
3
+
4
+ /** Which span of time the calendar is showing. */
5
+ type SdsEventCalendarView = 'month' | 'week' | '3day' | 'day';
6
+ /**
7
+ * How an event is tinted. These map onto the library's existing accent roles, so an event picks a
8
+ * meaning-free hue — it is NOT a severity and NOT a status. Anything clinical that needs to say
9
+ * "how bad" belongs in `sds-severity`, which has its own measured ramp.
10
+ */
11
+ type SdsEventColor = 'brand' | 'blue' | 'green' | 'amber' | 'red' | 'indigo' | 'neutral';
12
+ /**
13
+ * One thing on the calendar.
14
+ *
15
+ * <p>`start`/`end` are Dates or anything `new Date(...)` parses. Everything is computed in the
16
+ * BROWSER's timezone: a calendar shows a person their own day, and converting on the way in is the
17
+ * caller's job if their data says otherwise.
18
+ */
19
+ interface SdsCalendarEvent<T = unknown> {
20
+ id: string;
21
+ title: string;
22
+ start: Date | string | number;
23
+ /** Defaults to `start` + `defaultMinutes` when absent — a zero-length block is unclickable. */
24
+ end?: Date | string | number;
25
+ /** Second line, shown where there is room: a room, a reason, a phone number. */
26
+ subtitle?: string;
27
+ allDay?: boolean;
28
+ color?: SdsEventColor;
29
+ /** Struck through and faded — a cancelled appointment is still part of the day's record. */
30
+ cancelled?: boolean;
31
+ /** Whatever the caller wants back on click. The component never reads it. */
32
+ meta?: T;
33
+ }
34
+ /** An event resolved to real Dates, with its place in the grid worked out. */
35
+ interface PlacedEvent<T = unknown> {
36
+ event: SdsCalendarEvent<T>;
37
+ start: Date;
38
+ end: Date;
39
+ /** 0..1 of the visible day height. */
40
+ top: number;
41
+ height: number;
42
+ /** 0..1 across the column: side-by-side layout for events sharing a time. */
43
+ left: number;
44
+ width: number;
45
+ }
46
+ declare function toDate(value: Date | string | number): Date;
47
+ /** Minutes since local midnight. Read off the clock, never from an epoch difference — see below. */
48
+ declare function minutesOfDay(d: Date): number;
49
+ declare function startOfWeek(d: Date, firstDayOfWeek: number): Date;
50
+ /**
51
+ * The days a view shows.
52
+ *
53
+ * <p>`month` is always a 6×7 block, never 4–6 ragged rows: a grid that changes height as you page
54
+ * through the year makes everything below it jump.
55
+ */
56
+ declare function visibleDays(view: SdsEventCalendarView, date: Date, firstDayOfWeek: number): Date[];
57
+ /** The half-open range a view covers — what a host should fetch for. */
58
+ declare function visibleRange(view: SdsEventCalendarView, date: Date, firstDayOfWeek: number): {
59
+ start: Date;
60
+ end: Date;
61
+ };
62
+ /** Paging: one month, one week, three days or one day at a time, in the view's own unit. */
63
+ declare function step(view: SdsEventCalendarView, date: Date, direction: 1 | -1): Date;
64
+ /** Whether an event touches a given day at all. Half-open: an event ending at 00:00 is not there. */
65
+ declare function occursOn(start: Date, end: Date, day: Date): boolean;
66
+ /**
67
+ * Place one day's timed events in the grid, side by side where they overlap.
68
+ *
69
+ * <p>The classic column packing: events are clustered into runs that transitively overlap, each
70
+ * takes the leftmost column that is free at its time, and the whole cluster is then divided by the
71
+ * widest point. So two appointments at 09:00 each take half the width and a third takes a third —
72
+ * and a 14:00 appointment with nothing beside it is full width, because it is in its own cluster.
73
+ *
74
+ * <p><b>Vertical position is read off the clock, not from an epoch difference.</b> On the two days a
75
+ * year when the clocks move, a 09:00–10:00 appointment is still drawn at 09:00 and one hour tall;
76
+ * computing it from elapsed milliseconds would slide every event after the change by an hour.
77
+ *
78
+ * <p>Events are clipped to the visible window rather than dropped: a night shift starting at 06:00
79
+ * on a grid that opens at 08:00 should still show, flush to the top, not vanish.
80
+ */
81
+ declare function placeDay<T>(events: readonly SdsCalendarEvent<T>[], day: Date, startHour: number, endHour: number, defaultMinutes: number): PlacedEvent<T>[];
82
+ /** The all-day (and multi-day) events touching a given day, in a stable order. */
83
+ declare function allDayOn<T>(events: readonly SdsCalendarEvent<T>[], day: Date, defaultMinutes: number): SdsCalendarEvent<T>[];
84
+ /** Every event touching a day, all-day first then by start — what a month cell lists. */
85
+ declare function eventsOn<T>(events: readonly SdsCalendarEvent<T>[], day: Date, defaultMinutes: number): SdsCalendarEvent<T>[];
86
+
87
+ /** A click on empty time: what a host turns into "new appointment". */
88
+ interface SdsCalendarSlot {
89
+ start: Date;
90
+ end: Date;
91
+ }
92
+ interface SdsCalendarRange {
93
+ start: Date;
94
+ end: Date;
95
+ view: SdsEventCalendarView;
96
+ }
97
+ /**
98
+ * A calendar of events — month, week, three days or one day.
99
+ *
100
+ * <p><b>Not {@link SdsCalendar}</b>, which is the month grid inside the date picker and exists to
101
+ * pick a date. This one shows what is ON the days, and it owns no data: the host passes `events`
102
+ * and listens to `rangeChange` to fetch the next lot.
103
+ *
104
+ * <p><b>It stores nothing and decides nothing.</b> `view` and `date` are two-way models, so the
105
+ * host can deep-link a view or restore one; every interaction is an output. That is what lets the
106
+ * same component serve a doctor's diary, a room's bookings or a delivery schedule without knowing
107
+ * what any of them are.
108
+ *
109
+ * <p><b>Dates come from `Intl`, control words come from you.</b> Day and month names follow
110
+ * `[locale]` automatically, so the part that is genuinely per-language needs no wiring — but
111
+ * "Today", "All day" and "+2 more" are inputs with English defaults, and a non-English app MUST
112
+ * pass them. An icon-only control's accessible name is the only name it has.
113
+ *
114
+ * <p><b>Mobile.</b> The week view keeps a readable minimum column width and scrolls sideways under
115
+ * its own header rather than squeezing seven columns onto a phone; the month view drops from chips
116
+ * to dots below `sm`. Both are CSS, so there is no resize listener to get wrong and no layout that
117
+ * depends on JavaScript having run.
118
+ *
119
+ * @example
120
+ * <sds-event-calendar
121
+ * [events]="appointments()"
122
+ * [(view)]="view"
123
+ * [(date)]="focused"
124
+ * [todayLabel]="'calendar.today' | translate"
125
+ * (eventClick)="open($event)"
126
+ * (rangeChange)="load($event)" />
127
+ */
128
+ declare class SdsEventCalendar<T = unknown> {
129
+ private readonly destroyRef;
130
+ readonly events: _angular_core.InputSignal<readonly SdsCalendarEvent<T>[]>;
131
+ /** Two-way: the host can deep-link or restore a view. */
132
+ readonly view: _angular_core.ModelSignal<SdsEventCalendarView>;
133
+ /** Two-way: any day inside the span being shown. */
134
+ readonly date: _angular_core.ModelSignal<Date>;
135
+ /** 1 = Monday (the European week), 0 = Sunday. */
136
+ readonly firstDayOfWeek: _angular_core.InputSignalWithTransform<number, unknown>;
137
+ /** The hours the time grid shows. Events outside are clipped to the edge, never dropped. */
138
+ readonly startHour: _angular_core.InputSignalWithTransform<number, unknown>;
139
+ readonly endHour: _angular_core.InputSignalWithTransform<number, unknown>;
140
+ readonly hourHeight: _angular_core.InputSignalWithTransform<number, unknown>;
141
+ /** How long an event with no `end` is assumed to last. */
142
+ readonly defaultMinutes: _angular_core.InputSignalWithTransform<number, unknown>;
143
+ /** CSS height of the scrolling body (month: of the whole grid). */
144
+ readonly height: _angular_core.InputSignal<string>;
145
+ /** BCP-47 tag for day and month names. Empty follows the browser. */
146
+ readonly locale: _angular_core.InputSignal<string>;
147
+ readonly nowIndicator: _angular_core.InputSignalWithTransform<boolean, unknown>;
148
+ readonly showToolbar: _angular_core.InputSignalWithTransform<boolean, unknown>;
149
+ readonly showViewSwitcher: _angular_core.InputSignalWithTransform<boolean, unknown>;
150
+ /** Chips per month cell before it collapses to "+N". */
151
+ readonly maxPerCell: _angular_core.InputSignalWithTransform<number, unknown>;
152
+ /** Control words. English defaults — a non-English app must pass every one of these. */
153
+ readonly todayLabel: _angular_core.InputSignal<string>;
154
+ readonly previousLabel: _angular_core.InputSignal<string>;
155
+ readonly nextLabel: _angular_core.InputSignal<string>;
156
+ readonly allDayLabel: _angular_core.InputSignal<string>;
157
+ /** `{count}` is substituted. */
158
+ readonly moreLabel: _angular_core.InputSignal<string>;
159
+ readonly viewSwitcherLabel: _angular_core.InputSignal<string>;
160
+ readonly monthLabel: _angular_core.InputSignal<string>;
161
+ readonly weekLabel: _angular_core.InputSignal<string>;
162
+ readonly threeDayLabel: _angular_core.InputSignal<string>;
163
+ readonly dayLabel: _angular_core.InputSignal<string>;
164
+ readonly eventClick: _angular_core.OutputEmitterRef<SdsCalendarEvent<T>>;
165
+ /** A click on empty time, snapped to the hour that was clicked. */
166
+ readonly slotClick: _angular_core.OutputEmitterRef<SdsCalendarSlot>;
167
+ readonly dayClick: _angular_core.OutputEmitterRef<Date>;
168
+ /** The span now on screen — fetch for this. Fires whenever the view or the date moves. */
169
+ readonly rangeChange: _angular_core.OutputEmitterRef<SdsCalendarRange>;
170
+ /** Ticks the now-indicator. One timer, cleared with the component. */
171
+ private readonly now;
172
+ constructor();
173
+ protected readonly days: _angular_core.Signal<Date[]>;
174
+ protected readonly hours: _angular_core.Signal<number[]>;
175
+ protected readonly bodyHeight: _angular_core.Signal<number>;
176
+ protected readonly columns: _angular_core.Signal<string>;
177
+ /** Keeps a day column readable on a phone; the grid scrolls sideways instead of squeezing. */
178
+ protected readonly minWidth: _angular_core.Signal<number>;
179
+ private readonly intl;
180
+ protected readonly weekdayNames: _angular_core.Signal<string[]>;
181
+ protected readonly title: _angular_core.Signal<string>;
182
+ protected readonly viewOptions: _angular_core.Signal<SdsSegmentedOption<unknown>[]>;
183
+ protected readonly hasAllDay: _angular_core.Signal<boolean>;
184
+ protected readonly nowTop: _angular_core.Signal<number | null>;
185
+ protected placed(day: Date): PlacedEvent<T>[];
186
+ protected allDayEvents(day: Date): SdsCalendarEvent<T>[];
187
+ protected cellEvents(day: Date): SdsCalendarEvent<T>[];
188
+ protected isToday(day: Date): boolean;
189
+ protected inFocusedMonth(day: Date): boolean;
190
+ protected shortWeekday(day: Date): string;
191
+ protected hourLabel(hour: number): string;
192
+ protected clock(value: Date | string | number): string;
193
+ protected hourTop(hour: number): number;
194
+ protected chipClass(e: SdsCalendarEvent<T>): string;
195
+ protected dotClass(e: SdsCalendarEvent<T>): string;
196
+ protected setView(next: unknown): void;
197
+ protected move(direction: 1 | -1): void;
198
+ protected goToday(): void;
199
+ /** A click on empty grid becomes a slot of `defaultMinutes`, snapped to the hour clicked. */
200
+ protected onGridClick(event: MouseEvent, day: Date): void;
201
+ protected onEventClick(event: MouseEvent, placed: PlacedEvent<T>): void;
202
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdsEventCalendar<any>, never>;
203
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdsEventCalendar<any>, "sds-event-calendar", never, { "events": { "alias": "events"; "required": false; "isSignal": true; }; "view": { "alias": "view"; "required": false; "isSignal": true; }; "date": { "alias": "date"; "required": false; "isSignal": true; }; "firstDayOfWeek": { "alias": "firstDayOfWeek"; "required": false; "isSignal": true; }; "startHour": { "alias": "startHour"; "required": false; "isSignal": true; }; "endHour": { "alias": "endHour"; "required": false; "isSignal": true; }; "hourHeight": { "alias": "hourHeight"; "required": false; "isSignal": true; }; "defaultMinutes": { "alias": "defaultMinutes"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; "nowIndicator": { "alias": "nowIndicator"; "required": false; "isSignal": true; }; "showToolbar": { "alias": "showToolbar"; "required": false; "isSignal": true; }; "showViewSwitcher": { "alias": "showViewSwitcher"; "required": false; "isSignal": true; }; "maxPerCell": { "alias": "maxPerCell"; "required": false; "isSignal": true; }; "todayLabel": { "alias": "todayLabel"; "required": false; "isSignal": true; }; "previousLabel": { "alias": "previousLabel"; "required": false; "isSignal": true; }; "nextLabel": { "alias": "nextLabel"; "required": false; "isSignal": true; }; "allDayLabel": { "alias": "allDayLabel"; "required": false; "isSignal": true; }; "moreLabel": { "alias": "moreLabel"; "required": false; "isSignal": true; }; "viewSwitcherLabel": { "alias": "viewSwitcherLabel"; "required": false; "isSignal": true; }; "monthLabel": { "alias": "monthLabel"; "required": false; "isSignal": true; }; "weekLabel": { "alias": "weekLabel"; "required": false; "isSignal": true; }; "threeDayLabel": { "alias": "threeDayLabel"; "required": false; "isSignal": true; }; "dayLabel": { "alias": "dayLabel"; "required": false; "isSignal": true; }; }, { "view": "viewChange"; "date": "dateChange"; "eventClick": "eventClick"; "slotClick": "slotClick"; "dayClick": "dayClick"; "rangeChange": "rangeChange"; }, never, never, true, never>;
204
+ }
205
+
206
+ export { SdsEventCalendar, allDayOn, eventsOn, minutesOfDay, occursOn, placeDay, startOfWeek, step, toDate, visibleDays, visibleRange };
207
+ export type { PlacedEvent, SdsCalendarEvent, SdsCalendarRange, SdsCalendarSlot, SdsEventCalendarView, SdsEventColor };