@powerportalspro/react-calendar 0.0.0-stage → 12.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.
@@ -0,0 +1,368 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TableRecordReference, TableRecord, MultiTableViewDefinition, MultiTableSeries, MultiTableItem } from '@powerportalspro/core';
3
+ import { MultiTableForms, ViewSort } from '@powerportalspro/react-fluent';
4
+ import { ReactNode, CSSProperties, ReactElement } from 'react';
5
+ import { ToolbarButtonProps } from '@fluentui/react-components';
6
+
7
+ /**
8
+ * How the calendar lays out its appointments — by the hour over a day or a week, a month of days, or
9
+ * a list — named as the calendar's API names them on both stacks. A layout, not a view: a view is
10
+ * the saved query that decides which appointments are shown. FullCalendar calls these views.
11
+ */
12
+ type CalendarLayout = 'day' | 'workWeek' | 'week' | 'month' | 'agenda';
13
+ declare const calendarLayouts: readonly CalendarLayout[];
14
+
15
+ /**
16
+ * How an appointment shows the time it takes, as Outlook's "Show as" does: busy as appointments are
17
+ * drawn, free hollow, tentative striped, out of office in purple. The values are those of
18
+ * `AppointmentShowAs` in C#, which the Blazor Calendar sends, and of the one `@powerportalspro/core`
19
+ * exports, which React code passes: this folder can't import that package.
20
+ */
21
+ declare const AppointmentShowAs: {
22
+ readonly Busy: 0;
23
+ readonly Free: 1;
24
+ readonly Tentative: 2;
25
+ readonly OutOfOffice: 3;
26
+ };
27
+ type AppointmentShowAs = (typeof AppointmentShowAs)[keyof typeof AppointmentShowAs];
28
+ interface CalendarAppointment$1 {
29
+ id: string;
30
+ subject: string;
31
+ start: Date | string;
32
+ end: Date | string;
33
+ allDay?: boolean;
34
+ location?: string | null;
35
+ /** An occurrence of a recurring series. */
36
+ recurring?: boolean;
37
+ /** False when the user may not move or resize this appointment; null or absent follows the calendar. */
38
+ editable?: boolean | null;
39
+ /** False when it can be moved but not resized: its table keeps no end it may change. */
40
+ durationEditable?: boolean | null;
41
+ /** The table of the row behind it, for a calendar that shows several. Absent for an appointment of the host's. */
42
+ table?: string | null;
43
+ /** The CSS color it is drawn in, its table's. Absent for the calendar's own. */
44
+ color?: string | null;
45
+ /** How it shows the time it takes. Busy when absent. */
46
+ showAs?: AppointmentShowAs | null;
47
+ /** Whether it was canceled: its subject is struck through. */
48
+ canceled?: boolean | null;
49
+ /**
50
+ * The record behind it — for one the calendar loaded, every column of the view or query — for a
51
+ * tooltip that shows more. A `TableRecord` in React; this folder can't import its type.
52
+ */
53
+ record?: unknown;
54
+ }
55
+ /** A move or resize the user made, which the host saves or refuses. */
56
+ interface CalendarAppointmentChange {
57
+ id: string;
58
+ start: Date;
59
+ end: Date | null;
60
+ allDay: boolean;
61
+ /** The table of the row moved, when the calendar loaded it. */
62
+ table?: string | null;
63
+ }
64
+
65
+ /** A time to start a new appointment over: what selecting a range in the calendar gives. */
66
+ interface CalendarRange {
67
+ start: Date;
68
+ end: Date;
69
+ allDay: boolean;
70
+ }
71
+ /**
72
+ * A `<Calendar>` as a control in its toolbar sees it: the period it shows, the record it is about,
73
+ * and what it can be asked to do. Read it with {@link useCalendarContext}; a `<CalendarButton>`
74
+ * hands it to its click. The Blazor `CalendarContext` is its twin.
75
+ */
76
+ interface CalendarContextValue {
77
+ /** The layout shown. */
78
+ layout: CalendarLayout;
79
+ /** The first moment shown; undefined until the calendar has drawn. */
80
+ start: Date | undefined;
81
+ /** The moment after the last one shown; undefined until the calendar has drawn. */
82
+ end: Date | undefined;
83
+ /** The record the calendar is about: its `regarding`. */
84
+ regarding: TableRecordReference | undefined;
85
+ /**
86
+ * Whether {@link createAppointment} has something to start: an `editable` calendar whose host
87
+ * handles `onRangeSelect`, or that loads its own appointments for a user who may create them.
88
+ * False until that is known.
89
+ */
90
+ canCreateAppointments: boolean;
91
+ /**
92
+ * Starts a new appointment, as selecting a time does in an `editable` calendar: the host's to
93
+ * handle when it handles `onRangeSelect`; otherwise, in a calendar that loads its own
94
+ * appointments, a form to create one, when the user may. Without a range, the appointment starts
95
+ * at the next half hour when the period shown takes in today, and otherwise at 8:00 on its first
96
+ * day, and lasts half an hour. Does nothing unless the calendar is `editable`.
97
+ */
98
+ createAppointment: (range?: CalendarRange) => Promise<void>;
99
+ /** Reads the appointments of the range shown again. */
100
+ refresh: () => void;
101
+ }
102
+ /** The calendar a control in its toolbar sits in. Throws outside a `<Calendar>`'s toolbar. */
103
+ declare function useCalendarContext(): CalendarContextValue;
104
+
105
+ /**
106
+ * An appointment as the calendar draws it: what it shows, how it shows the time it takes, and — for
107
+ * one the calendar loaded — the record behind it, with every column of the view or query, for a
108
+ * tooltip that shows more. The Blazor `CalendarAppointment` is its twin.
109
+ */
110
+ interface CalendarAppointment extends Omit<CalendarAppointment$1, 'record' | 'showAs'> {
111
+ /** How it shows the time it takes. Busy when absent. */
112
+ showAs?: AppointmentShowAs | null;
113
+ /** The record behind it: every column of the view or query, for one the calendar loaded. */
114
+ record?: TableRecord | null;
115
+ }
116
+
117
+ /** Where a {@link Calendar} opens an appointment's details and another table's form. */
118
+ type CalendarFormLocation = 'center' | 'left' | 'right';
119
+ interface CalendarProps {
120
+ /**
121
+ * The appointments to show, when the host has them. Without it, the calendar loads the rows of
122
+ * each range it shows from Dataverse — appointments, tasks and the other tables the server
123
+ * registered — as the view picked, {@link regarding} and the user's access allow.
124
+ */
125
+ appointments?: readonly CalendarAppointment[];
126
+ /**
127
+ * Only the rows about this record, when the calendar loads its own: through each table's
128
+ * regarding column, and the activities it takes part in (see {@link matchParties}).
129
+ */
130
+ regarding?: TableRecordReference;
131
+ /**
132
+ * The tables the calendar may show, by logical name: of those the server registered
133
+ * (`AddMultiTableSource`, or notes and activities by default) and the user may read. Every one when
134
+ * omitted.
135
+ */
136
+ tables?: readonly string[];
137
+ /**
138
+ * The tables shown at first when the calendar shows every table — no view of its own: the others
139
+ * the user may read are offered in the table menu, switched off. Defaults to appointments and tasks.
140
+ * With none of them to show, every table is.
141
+ */
142
+ defaultTables?: readonly string[];
143
+ /**
144
+ * Dataverse views the user can pick from, by id: each shows its own table's rows that it picks.
145
+ * With more than one view on offer — these, {@link multiTableViewIds} and
146
+ * {@link customViewDefinitions} — the toolbar has a picker. With none, the calendar shows every
147
+ * table (see {@link defaultTables}).
148
+ */
149
+ viewIds?: readonly string[];
150
+ /**
151
+ * Views of several tables the user can pick from: ones the server registered (`AddMultiTableView`)
152
+ * or kept in Dataverse (`ppp_multitableview`), by id.
153
+ */
154
+ multiTableViewIds?: readonly string[];
155
+ /**
156
+ * The view the calendar opens on, one of those offered. Without it, the first of {@link viewIds},
157
+ * then of {@link multiTableViewIds}, then of {@link customViewDefinitions}.
158
+ */
159
+ defaultViewId?: string;
160
+ /**
161
+ * Views defined in code, of one table or several, offered beside {@link viewIds}: each table with
162
+ * which of its rows show.
163
+ */
164
+ customViewDefinitions?: readonly MultiTableViewDefinition[];
165
+ /**
166
+ * Whether activities the {@link regarding} record takes part in — as a sender, recipient or
167
+ * attendee — show beside those about it. Unset, each table's setting, else the server's.
168
+ */
169
+ matchParties?: boolean;
170
+ /** How recurring appointments show. Unset, each table's setting: each occurrence on its own. */
171
+ series?: MultiTableSeries;
172
+ /**
173
+ * Draws a table's rows the page's own way, by logical name: the row, with the whole record read in
174
+ * its `record`, in place of all the calendar draws of it — its time, subject, place and repeat icon.
175
+ * For the rows the calendar loads, not `appointments` the host gives it. A row is drawn as its range
176
+ * is read, so a change to what a template shows reaches it with the next range or refresh.
177
+ */
178
+ templates?: Readonly<Record<string, (item: MultiTableItem) => ReactNode>>;
179
+ /**
180
+ * The forms a row of another table than appointments opens in, by table, in place of the default
181
+ * one: `{ task: { edit: TaskForm } }`.
182
+ */
183
+ forms?: Readonly<Record<string, MultiTableForms>>;
184
+ /**
185
+ * Where an appointment's details and another table's form open: a dialog in the `center` (the
186
+ * default), or a side panel on the `left` or the `right`.
187
+ */
188
+ formLocation?: CalendarFormLocation;
189
+ /** The order of the views in the picker. Defaults to `ViewSort.NameAscending`. */
190
+ viewSort?: ViewSort;
191
+ /**
192
+ * When `true`, the toolbar has a Filter button, which opens the view's filters to change, as a
193
+ * grid's does — a tab for each table shown: conditions on its columns, nested in groups, and
194
+ * related tables to filter by — every filter FetchXML can express, over the columns and tables the
195
+ * user may read. The changes last while the calendar shows the view; another view starts from its
196
+ * own filters. Not offered for {@link appointments} the host gives the calendar, nor for a view of
197
+ * several tables kept in Dataverse. Defaults to `false`: the user can take away every filter the
198
+ * view has, which a view meant to narrow a page's rows may not want.
199
+ */
200
+ allowFiltering?: boolean;
201
+ /**
202
+ * Lets signed-in users save the calendar as they've arranged it — the view it shows with their
203
+ * filter, and its layout — as views of their own, offered in the view picker beside the page's,
204
+ * and choose their default view and hide the views they don't use. A view saved on a calendar or a
205
+ * grid of appointments with no {@link savedViewsKey} is offered on both, each keeping its own
206
+ * layout of it. Off by default. Needs the Power Portals Pro Core solution's saved-view tables; an
207
+ * internal user also needs the `Power Portals Pro Saved Views` security role.
208
+ */
209
+ allowSavedViews?: boolean;
210
+ /**
211
+ * Names this calendar among the controls of appointments, so the views saved on it and the user's
212
+ * default and hidden views are its own: it offers the views saved on it as well as the views saved on
213
+ * controls with no key, and its default and hidden views are set for it alone. Without one, the
214
+ * calendar shares its views with every grid and calendar of appointments that has none, and its
215
+ * default and hidden views with every calendar that has none. Letters, digits, `-`, `_` and `.`.
216
+ */
217
+ savedViewsKey?: string;
218
+ /**
219
+ * Where a user who isn't signed in is sent to sign in, from the saved views' menu, which asks them
220
+ * to first; they come back to this page (`ReturnUrl`). Defaults to `/Account/Login`.
221
+ */
222
+ signInUrl?: string;
223
+ /**
224
+ * Whether the toolbar has a search box, when the calendar loads its own appointments. A search
225
+ * finds each table's search columns as a grid's search does. Defaults to `true`.
226
+ */
227
+ allowSearch?: boolean;
228
+ /**
229
+ * Whether the search is kept in the URL with the rest of the calendar's state. Off by default:
230
+ * what users search for can be sensitive, and stays in the browser's history and in referrers.
231
+ * Has no effect without {@link persistedStateQueryParameter}.
232
+ */
233
+ includeSearchInPersistedState?: boolean;
234
+ /**
235
+ * The layout it opens in: the hours of a `day`, a `workWeek` or a `week`, a `month` of days, or an
236
+ * `agenda` list. Defaults to `week`; the first of {@link layouts} when that leaves it out.
237
+ */
238
+ defaultLayout?: CalendarLayout;
239
+ /**
240
+ * The layouts the user can switch between, in the order the picker lists them. With one, the
241
+ * picker is hidden and the calendar stays in it: a link naming another is ignored, and a day's
242
+ * number no longer opens that day unless `day` is offered. Every layout when omitted.
243
+ */
244
+ layouts?: readonly CalendarLayout[];
245
+ /**
246
+ * Whether appointments can be moved, resized and created by selecting a range. A loaded row can be
247
+ * moved when the user may change it and its start, and it isn't closed — completed, canceled or
248
+ * inactive; resized when they may change its end too. The calendar saves the move, unless
249
+ * {@link onAppointmentChange} does.
250
+ */
251
+ editable?: boolean;
252
+ /**
253
+ * The tables an appointment's Regarding can name a record of, in the order its form's table
254
+ * picker lists them. Tables Regarding can't point to are ignored. Every one it can when omitted;
255
+ * either way, only the tables whose records the user may read and point a lookup to are offered.
256
+ * The Blazor Calendar's
257
+ * `RegardingTables` is its twin.
258
+ */
259
+ regardingTables?: readonly string[];
260
+ /** Height of the whole calendar, toolbar included. Defaults to `600px`. */
261
+ height?: CSSProperties['height'];
262
+ /**
263
+ * An appointment was clicked or activated from the keyboard. Without it, an appointment the
264
+ * calendar loaded opens in a dialog of its details.
265
+ */
266
+ onAppointmentClick?: (id: string) => void;
267
+ /**
268
+ * The fields the details dialog shows, in place of the calendar's own: column edits and the like,
269
+ * read from the appointment's record as on a record page. The calendar's own show when it is,
270
+ * where, what it is regarding, its status and its description, read-only.
271
+ */
272
+ appointmentDetails?: ReactNode;
273
+ /**
274
+ * What an appointment's tooltip shows, in place of its subject, when, where and whether it
275
+ * repeats: given the appointment, whose `record` holds every column of the view for one the
276
+ * calendar loaded. A tooltip isn't interactive, so it shows what this draws, not controls to use.
277
+ */
278
+ appointmentTooltip?: (appointment: CalendarAppointment) => ReactNode;
279
+ /** A range was selected to create an appointment in, or a New button clicked. */
280
+ onRangeSelect?: (range: CalendarRange) => void;
281
+ /**
282
+ * An appointment was moved or resized. Resolve false to put it back, as when the save is
283
+ * refused.
284
+ */
285
+ onAppointmentChange?: (change: CalendarAppointmentChange) => boolean | Promise<boolean>;
286
+ /** The visible range changed, by navigation or a change of layout. */
287
+ onRangeChange?: (range: {
288
+ start: Date;
289
+ end: Date;
290
+ layout: CalendarLayout;
291
+ }) => void;
292
+ /**
293
+ * Controls for the toolbar: `<CalendarButton>`s, such as `<NewAppointmentCalendarButton>`, or any
294
+ * other element. They appear in the order given, ahead of the search box, as a grid's toolbar
295
+ * buttons do, and read the calendar through `useCalendarContext`. The Blazor Calendar's
296
+ * `ToolbarItems` is its twin.
297
+ */
298
+ children?: ReactNode;
299
+ /**
300
+ * The name of a URL query parameter to keep the calendar's state in — its layout, the period it
301
+ * shows, the appointment view picked and (with {@link includeSearchInPersistedState}) the search —
302
+ * so a reload or a link opens it where it was left. Each change replaces the browser's history
303
+ * entry rather than adding one. What the calendar would open on anyway is left out: the layout
304
+ * while it is the one it opens in, the appointment view while it is the default one, and the date while
305
+ * the period shown takes in today, so a link to the current week keeps following today. The URL is
306
+ * read once, when the calendar opens; a value it can't read is ignored.
307
+ *
308
+ * The Blazor Calendar keeps the same value, so a link made on one stack opens the same calendar
309
+ * on the other.
310
+ */
311
+ persistedStateQueryParameter?: string;
312
+ }
313
+ /**
314
+ * An Outlook-style calendar of appointments — and of tasks and any other table it is given — laid out
315
+ * by day, week or month, or as an agenda.
316
+ */
317
+ declare function Calendar({ appointments, regarding, tables, defaultTables, viewIds, multiTableViewIds, defaultViewId, customViewDefinitions, matchParties, series, templates, forms, formLocation, viewSort, allowFiltering, allowSavedViews, savedViewsKey, signInUrl, allowSearch, includeSearchInPersistedState, defaultLayout, layouts, editable, regardingTables, height, onAppointmentClick, appointmentDetails, appointmentTooltip, onRangeSelect, onAppointmentChange, onRangeChange, persistedStateQueryParameter, children, }: CalendarProps): react_jsx_runtime.JSX.Element;
318
+
319
+ interface CalendarButtonProps {
320
+ /** Called when the button is clicked, with the calendar as it is then. */
321
+ onClick?: (calendar: CalendarContextValue) => void | Promise<void>;
322
+ /** The text on the button. */
323
+ label?: string;
324
+ /** An icon shown before the text, such as `<ArrowDownloadRegular />`. */
325
+ icon?: ReactElement;
326
+ /** Shown when the pointer rests on the button; also its name for a screen reader when it has no label. */
327
+ tooltip?: string;
328
+ /** How the button is drawn. `subtle` by default, as the calendar's own toolbar buttons are. */
329
+ appearance?: ToolbarButtonProps['appearance'];
330
+ /** Whether the button can't be clicked. */
331
+ disabled?: boolean;
332
+ /** A class added to the button. */
333
+ className?: string;
334
+ }
335
+ /**
336
+ * A button for a `<Calendar>`'s toolbar: place it among the calendar's children, and a click hands
337
+ * it the calendar as it is then — the period shown, the record it is about, and what it can be
338
+ * asked to do. The grid's `<GridButton>` is its counterpart, and the Blazor `CalendarButton` its
339
+ * twin.
340
+ *
341
+ * ```tsx
342
+ * <Calendar regarding={account} editable>
343
+ * <NewAppointmentCalendarButton />
344
+ * <CalendarButton label="Export" icon={<ArrowDownloadRegular />} onClick={(calendar) => exportRange(calendar.start, calendar.end)} />
345
+ * </Calendar>
346
+ * ```
347
+ */
348
+ declare function CalendarButton({ onClick, label, icon, tooltip, appearance, disabled, className, }: CalendarButtonProps): react_jsx_runtime.JSX.Element;
349
+ interface NewAppointmentCalendarButtonProps {
350
+ /** The text on the button. "New" by default. */
351
+ label?: string;
352
+ /** The icon shown before the text. A plus by default. */
353
+ icon?: ReactElement;
354
+ /** Shown when the pointer rests on the button. */
355
+ tooltip?: string;
356
+ /** How the button is drawn. `subtle` by default. */
357
+ appearance?: ToolbarButtonProps['appearance'];
358
+ }
359
+ /**
360
+ * A New button for a `<Calendar>`'s toolbar: it starts a new appointment as selecting a time does —
361
+ * from the next half hour when the period shown takes in today, and otherwise from 8:00 on its
362
+ * first day. Shown only where that starts something: in an `editable` calendar whose host handles
363
+ * `onRangeSelect`, or that loads its own appointments for a user who may create them. The Blazor
364
+ * `NewAppointmentCalendarButton` is its twin.
365
+ */
366
+ declare function NewAppointmentCalendarButton({ label, icon, tooltip, appearance, }: NewAppointmentCalendarButtonProps): react_jsx_runtime.JSX.Element | null;
367
+
368
+ export { AppointmentShowAs, Calendar, type CalendarAppointment, type CalendarAppointmentChange, CalendarButton, type CalendarButtonProps, type CalendarContextValue, type CalendarFormLocation, type CalendarLayout, type CalendarProps, type CalendarRange, NewAppointmentCalendarButton, type NewAppointmentCalendarButtonProps, calendarLayouts, useCalendarContext };