@forcecalendar/interface 1.4.0 → 1.6.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/dist/force-calendar-interface.esm.js +219 -56
- package/dist/force-calendar-interface.esm.js.map +1 -1
- package/dist/force-calendar-interface.umd.js +17 -17
- package/dist/force-calendar-interface.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ForceCalendar.js +150 -9
- package/src/core/BaseComponent.js +4 -0
- package/src/core/StateManager.js +235 -0
- package/src/index.js +1 -0
- package/src/utils/StyleUtils.js +28 -0
- package/types/components/ForceCalendar.d.ts +56 -3
- package/types/core/StateManager.d.ts +164 -16
- package/types/index.d.ts +1 -0
- package/types/utils/DateUtils.d.ts +1 -1
- package/types/utils/StyleUtils.d.ts +26 -0
|
@@ -14,6 +14,10 @@ export declare class ForceCalendar extends BaseComponent {
|
|
|
14
14
|
currentView: any;
|
|
15
15
|
_hasRendered: boolean;
|
|
16
16
|
_busUnsubscribers: any[];
|
|
17
|
+
_pendingEvents: {
|
|
18
|
+
events: (object | import("@forcecalendar/core").Event)[];
|
|
19
|
+
options: import("../core/StateManager.js").EventsSetOptions;
|
|
20
|
+
} | null;
|
|
17
21
|
_stateUnsubscribe: (() => void) | null | undefined;
|
|
18
22
|
_currentViewInstance: any;
|
|
19
23
|
_viewUnsubscribe: any;
|
|
@@ -32,6 +36,13 @@ export declare class ForceCalendar extends BaseComponent {
|
|
|
32
36
|
*/
|
|
33
37
|
propChanged(name: any, oldValue: any, newValue: any): void;
|
|
34
38
|
initialize(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Re-apply a property that was set as an own data property before the
|
|
41
|
+
* custom element was upgraded, so the class accessor sees the value.
|
|
42
|
+
* @param {string} name
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
private _upgradeProperty;
|
|
35
46
|
setupEventListeners(): void;
|
|
36
47
|
handleStateChange(newState: any, oldState: any): void;
|
|
37
48
|
/**
|
|
@@ -59,15 +70,56 @@ export declare class ForceCalendar extends BaseComponent {
|
|
|
59
70
|
getStyles(): string;
|
|
60
71
|
template(): string;
|
|
61
72
|
renderView(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Apply a named theme preset (e.g. theme="slds") as host-level custom
|
|
75
|
+
* properties so it cascades into the shadow DOM and stays overridable
|
|
76
|
+
* by page-level --fc-* variables.
|
|
77
|
+
*/
|
|
78
|
+
_applyTheme(name: any): void;
|
|
62
79
|
afterRender(): void;
|
|
63
80
|
handleNavigation(event: any): void;
|
|
64
81
|
handleViewChange(event: any): void;
|
|
65
82
|
getTitle(date: any, view: any): string;
|
|
66
83
|
getIcon(name: any): any;
|
|
67
|
-
addEvent(event: any):
|
|
68
|
-
updateEvent(eventId: any, updates: any):
|
|
84
|
+
addEvent(event: any): import("@forcecalendar/core").Event | null;
|
|
85
|
+
updateEvent(eventId: any, updates: any): import("@forcecalendar/core").Event | null;
|
|
69
86
|
deleteEvent(eventId: any): boolean;
|
|
70
|
-
getEvents():
|
|
87
|
+
getEvents(): import("@forcecalendar/core").Event[];
|
|
88
|
+
/**
|
|
89
|
+
* Replace the calendar's events with a complete snapshot, applying only the
|
|
90
|
+
* differences: unchanged events keep their instance, changed ones are
|
|
91
|
+
* replaced, new ones are added and events missing from the snapshot are
|
|
92
|
+
* removed unless `removeMissing` is false. The view re-renders at most once
|
|
93
|
+
* and a single `calendar-events-set` event describes the change set; no
|
|
94
|
+
* per-event `calendar-event-add`/`-remove` events are dispatched.
|
|
95
|
+
*
|
|
96
|
+
* Before the element is connected the snapshot is stored and applied on
|
|
97
|
+
* initialisation, in which case `null` is returned.
|
|
98
|
+
*
|
|
99
|
+
* @param {Iterable<object|import('../core/StateManager.js').CalendarEvent>} events - Complete snapshot of events
|
|
100
|
+
* @param {import('../core/StateManager.js').EventsSetOptions} [options={}]
|
|
101
|
+
* @returns {import('../core/StateManager.js').EventsSetResult|null}
|
|
102
|
+
*/
|
|
103
|
+
setEvents(events: Iterable<object | import('../core/StateManager.js').CalendarEvent>, options?: import('../core/StateManager.js').EventsSetOptions): import('../core/StateManager.js').EventsSetResult | null;
|
|
104
|
+
/**
|
|
105
|
+
* Declarative form of {@link ForceCalendar#setEvents}: assign a complete
|
|
106
|
+
* snapshot and the calendar reconciles it with `removeMissing: true`.
|
|
107
|
+
* Reading it returns the events currently held by the calendar.
|
|
108
|
+
*
|
|
109
|
+
* @returns {import('../core/StateManager.js').CalendarEvent[]}
|
|
110
|
+
*/
|
|
111
|
+
get events(): import('../core/StateManager.js').CalendarEvent[];
|
|
112
|
+
/**
|
|
113
|
+
* @param {Iterable<object|import('../core/StateManager.js').CalendarEvent>|null} events - Complete snapshot of events
|
|
114
|
+
*/
|
|
115
|
+
set events(events: Iterable<object | import('../core/StateManager.js').CalendarEvent> | null);
|
|
116
|
+
/**
|
|
117
|
+
* Get the window of dates the current view covers (leading and trailing
|
|
118
|
+
* other-month days included). `end` is inclusive.
|
|
119
|
+
*
|
|
120
|
+
* @returns {import('../core/StateManager.js').VisibleRange|null} The range, or null before the element is initialised
|
|
121
|
+
*/
|
|
122
|
+
getVisibleRange(): import('../core/StateManager.js').VisibleRange | null;
|
|
71
123
|
setView(view: any): void;
|
|
72
124
|
setDate(date: any): void;
|
|
73
125
|
next(): void;
|
|
@@ -75,4 +127,5 @@ export declare class ForceCalendar extends BaseComponent {
|
|
|
75
127
|
today(): void;
|
|
76
128
|
unmount(): void;
|
|
77
129
|
destroy(): void;
|
|
130
|
+
_releaseBindings(): void;
|
|
78
131
|
}
|
|
@@ -4,13 +4,95 @@
|
|
|
4
4
|
* Wraps the @forcecalendar/core Calendar instance
|
|
5
5
|
* Provides reactive state updates and component synchronization
|
|
6
6
|
*/
|
|
7
|
+
import { Calendar } from '@forcecalendar/core';
|
|
7
8
|
import { EventBus } from './EventBus.js';
|
|
9
|
+
export type CalendarEvent = import('@forcecalendar/core').Event;
|
|
10
|
+
export type EventsSetOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* - Remove stored events that are absent from the snapshot
|
|
13
|
+
*/
|
|
14
|
+
removeMissing?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type EventsSetUpdate = {
|
|
17
|
+
/**
|
|
18
|
+
* - Event now held by the calendar
|
|
19
|
+
*/
|
|
20
|
+
event: CalendarEvent;
|
|
21
|
+
/**
|
|
22
|
+
* - Event instance it replaced
|
|
23
|
+
*/
|
|
24
|
+
oldEvent: CalendarEvent;
|
|
25
|
+
};
|
|
26
|
+
export type EventsSetResult = {
|
|
27
|
+
/**
|
|
28
|
+
* - All events after the snapshot was applied
|
|
29
|
+
*/
|
|
30
|
+
events: CalendarEvent[];
|
|
31
|
+
/**
|
|
32
|
+
* - Events that were not present before
|
|
33
|
+
*/
|
|
34
|
+
added: CalendarEvent[];
|
|
35
|
+
/**
|
|
36
|
+
* - Events whose data changed
|
|
37
|
+
*/
|
|
38
|
+
updated: EventsSetUpdate[];
|
|
39
|
+
/**
|
|
40
|
+
* - Events dropped because they were missing from the snapshot
|
|
41
|
+
*/
|
|
42
|
+
removed: CalendarEvent[];
|
|
43
|
+
/**
|
|
44
|
+
* - Events left untouched (same instances as before)
|
|
45
|
+
*/
|
|
46
|
+
unchanged: CalendarEvent[];
|
|
47
|
+
};
|
|
48
|
+
export type VisibleRange = {
|
|
49
|
+
/**
|
|
50
|
+
* - First instant shown by the current view
|
|
51
|
+
*/
|
|
52
|
+
start: Date;
|
|
53
|
+
/**
|
|
54
|
+
* - Last instant shown by the current view (inclusive)
|
|
55
|
+
*/
|
|
56
|
+
end: Date;
|
|
57
|
+
};
|
|
58
|
+
export type VisibleRangeChange = VisibleRange & {
|
|
59
|
+
view: string;
|
|
60
|
+
date: Date;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {import('@forcecalendar/core').Event} CalendarEvent
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {Object} EventsSetOptions
|
|
67
|
+
* @property {boolean} [removeMissing=true] - Remove stored events that are absent from the snapshot
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {Object} EventsSetUpdate
|
|
71
|
+
* @property {CalendarEvent} event - Event now held by the calendar
|
|
72
|
+
* @property {CalendarEvent} oldEvent - Event instance it replaced
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {Object} EventsSetResult
|
|
76
|
+
* @property {CalendarEvent[]} events - All events after the snapshot was applied
|
|
77
|
+
* @property {CalendarEvent[]} added - Events that were not present before
|
|
78
|
+
* @property {EventsSetUpdate[]} updated - Events whose data changed
|
|
79
|
+
* @property {CalendarEvent[]} removed - Events dropped because they were missing from the snapshot
|
|
80
|
+
* @property {CalendarEvent[]} unchanged - Events left untouched (same instances as before)
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* @typedef {Object} VisibleRange
|
|
84
|
+
* @property {Date} start - First instant shown by the current view
|
|
85
|
+
* @property {Date} end - Last instant shown by the current view (inclusive)
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {VisibleRange & { view: string, date: Date }} VisibleRangeChange
|
|
89
|
+
*/
|
|
8
90
|
declare class StateManager {
|
|
9
91
|
eventBus: EventBus;
|
|
10
|
-
calendar:
|
|
92
|
+
calendar: Calendar;
|
|
11
93
|
state: {
|
|
12
|
-
view:
|
|
13
|
-
currentDate:
|
|
94
|
+
view: import("@forcecalendar/core/types").ViewType;
|
|
95
|
+
currentDate: Date;
|
|
14
96
|
events: never[];
|
|
15
97
|
selectedEvent: null;
|
|
16
98
|
selectedDate: null;
|
|
@@ -19,6 +101,7 @@ declare class StateManager {
|
|
|
19
101
|
config: {};
|
|
20
102
|
};
|
|
21
103
|
subscribers: Set<any>;
|
|
104
|
+
_visibleRangeKey: string;
|
|
22
105
|
_subscriberIds: Map<any, any> | null | undefined;
|
|
23
106
|
constructor(config?: {});
|
|
24
107
|
/**
|
|
@@ -34,7 +117,7 @@ declare class StateManager {
|
|
|
34
117
|
_syncEventsFromCore(options?: {
|
|
35
118
|
silent: boolean;
|
|
36
119
|
force: boolean;
|
|
37
|
-
}):
|
|
120
|
+
}): import("@forcecalendar/core").Event[];
|
|
38
121
|
/**
|
|
39
122
|
* Check if two event arrays have the same events by id.
|
|
40
123
|
* Only used for add/delete guards — updateEvent must pass force:true
|
|
@@ -42,8 +125,8 @@ declare class StateManager {
|
|
|
42
125
|
*/
|
|
43
126
|
_eventsMatch(arr1: any, arr2: any): any;
|
|
44
127
|
getState(): {
|
|
45
|
-
view:
|
|
46
|
-
currentDate:
|
|
128
|
+
view: import("@forcecalendar/core/types").ViewType;
|
|
129
|
+
currentDate: Date;
|
|
47
130
|
selectedEvent: null;
|
|
48
131
|
selectedDate: null;
|
|
49
132
|
loading: boolean;
|
|
@@ -52,8 +135,8 @@ declare class StateManager {
|
|
|
52
135
|
events: never[];
|
|
53
136
|
};
|
|
54
137
|
setState(updates: any, options?: {}): {
|
|
55
|
-
view:
|
|
56
|
-
currentDate:
|
|
138
|
+
view: import("@forcecalendar/core/types").ViewType;
|
|
139
|
+
currentDate: Date;
|
|
57
140
|
events: never[];
|
|
58
141
|
selectedEvent: null;
|
|
59
142
|
selectedDate: null;
|
|
@@ -75,26 +158,91 @@ declare class StateManager {
|
|
|
75
158
|
notifySubscribers(oldState: any, newState: any): void;
|
|
76
159
|
emitStateChange(oldState: any, newState: any): void;
|
|
77
160
|
setView(view: any): void;
|
|
78
|
-
getView():
|
|
161
|
+
getView(): import("@forcecalendar/core/types").ViewType;
|
|
79
162
|
setDate(date: any): void;
|
|
80
|
-
getCurrentDate():
|
|
163
|
+
getCurrentDate(): Date;
|
|
81
164
|
next(): void;
|
|
82
165
|
previous(): void;
|
|
83
166
|
today(): void;
|
|
84
167
|
goToDate(date: any): void;
|
|
85
|
-
addEvent(event: any):
|
|
86
|
-
updateEvent(eventId: any, updates: any):
|
|
168
|
+
addEvent(event: any): import("@forcecalendar/core").Event | null;
|
|
169
|
+
updateEvent(eventId: any, updates: any): import("@forcecalendar/core").Event | null;
|
|
87
170
|
deleteEvent(eventId: any): boolean;
|
|
88
|
-
getEvents():
|
|
171
|
+
getEvents(): import("@forcecalendar/core").Event[];
|
|
172
|
+
/**
|
|
173
|
+
* Replace the calendar's events with a complete snapshot, applying only the
|
|
174
|
+
* differences.
|
|
175
|
+
*
|
|
176
|
+
* Unchanged events keep their existing instance, changed ones are replaced,
|
|
177
|
+
* new ones are added and events missing from the snapshot are removed
|
|
178
|
+
* (unless `removeMissing` is false). The state is updated at most once and a
|
|
179
|
+
* single `events:set` bus event carries the change set. The per-event
|
|
180
|
+
* `event:add`/`event:added`/`event:remove`/`event:deleted` events are NOT
|
|
181
|
+
* emitted, so listeners that persist user edits are not triggered by a
|
|
182
|
+
* snapshot load.
|
|
183
|
+
*
|
|
184
|
+
* Uses `Calendar#reconcileEvents` when the installed core provides it
|
|
185
|
+
* (2.4.0+) and falls back to an id-based diff on older cores.
|
|
186
|
+
*
|
|
187
|
+
* @param {Iterable<object|CalendarEvent>} events - Complete snapshot of events
|
|
188
|
+
* @param {EventsSetOptions} [options={}]
|
|
189
|
+
* @returns {EventsSetResult} The applied change set
|
|
190
|
+
* @throws {Error} If an entry fails validation or two entries share an id (an `event:error` bus event is emitted first)
|
|
191
|
+
*/
|
|
192
|
+
setEvents(events: Iterable<object | CalendarEvent>, options?: EventsSetOptions): EventsSetResult;
|
|
193
|
+
/**
|
|
194
|
+
* Id-based diff for cores that predate `Calendar#reconcileEvents`.
|
|
195
|
+
* Works on the core calendar directly so no per-event bus events fire.
|
|
196
|
+
* Equivalence is approximated by comparing the fields present in the
|
|
197
|
+
* snapshot entry, so an entry that only omits fields is treated as unchanged.
|
|
198
|
+
*
|
|
199
|
+
* @param {Array<object|CalendarEvent>} snapshot
|
|
200
|
+
* @param {boolean} removeMissing
|
|
201
|
+
* @returns {{ added: CalendarEvent[], updated: EventsSetUpdate[], removed: CalendarEvent[], unchanged: CalendarEvent[] }}
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
private _reconcileFallback;
|
|
205
|
+
/**
|
|
206
|
+
* Field-wise comparison of a stored event against snapshot data.
|
|
207
|
+
* @param {CalendarEvent} existing
|
|
208
|
+
* @param {object} data
|
|
209
|
+
* @returns {boolean}
|
|
210
|
+
* @private
|
|
211
|
+
*/
|
|
212
|
+
private _isEquivalentFallback;
|
|
89
213
|
/**
|
|
90
214
|
* Force sync state.events from Core calendar
|
|
91
215
|
* Use this if you've modified events directly on the Core calendar
|
|
92
216
|
*/
|
|
93
|
-
syncEvents():
|
|
94
|
-
getEventsForDate(date: any):
|
|
95
|
-
getEventsInRange(start: any, end: any):
|
|
217
|
+
syncEvents(): import("@forcecalendar/core").Event[];
|
|
218
|
+
getEventsForDate(date: any): import("@forcecalendar/core").Event[];
|
|
219
|
+
getEventsInRange(start: any, end: any): import("@forcecalendar/core").Event[];
|
|
96
220
|
getViewData(): any;
|
|
97
221
|
enrichViewData(viewData: any): any;
|
|
222
|
+
/**
|
|
223
|
+
* Get the window of dates the current view covers, including leading and
|
|
224
|
+
* trailing days from adjacent months in the month view.
|
|
225
|
+
*
|
|
226
|
+
* `end` is the last millisecond of the window (inclusive), so the pair can
|
|
227
|
+
* be passed straight to {@link StateManager#getEventsInRange}.
|
|
228
|
+
*
|
|
229
|
+
* @returns {VisibleRange}
|
|
230
|
+
*/
|
|
231
|
+
getVisibleRange(): VisibleRange;
|
|
232
|
+
/**
|
|
233
|
+
* @param {VisibleRange} range
|
|
234
|
+
* @returns {string}
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
private _rangeKey;
|
|
238
|
+
/**
|
|
239
|
+
* Single choke point for `range:changed`: recompute the visible window and
|
|
240
|
+
* emit only when it differs from the last one that was announced.
|
|
241
|
+
* Called after view, date and week-start changes, once their own bus events
|
|
242
|
+
* have been emitted, so listeners see navigation before the range update.
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
private _syncVisibleRange;
|
|
98
246
|
selectEvent(event: any): void;
|
|
99
247
|
selectEventById(eventId: any): void;
|
|
100
248
|
deselectEvent(): void;
|
package/types/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { MonthViewRenderer } from './renderers/MonthViewRenderer.js';
|
|
|
15
15
|
export { WeekViewRenderer } from './renderers/WeekViewRenderer.js';
|
|
16
16
|
export { DayViewRenderer } from './renderers/DayViewRenderer.js';
|
|
17
17
|
export { ForceCalendar } from './components/ForceCalendar.js';
|
|
18
|
+
export { EventForm } from './components/EventForm.js';
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* StyleUtils - Styling utilities and theme management
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Named theme presets applied via the <forcecal-main theme="..."> attribute.
|
|
6
|
+
* Each maps design tokens to a platform's visual language.
|
|
7
|
+
*/
|
|
8
|
+
export declare const THEME_PRESETS: {
|
|
9
|
+
slds: {
|
|
10
|
+
'--fc-primary-color': string;
|
|
11
|
+
'--fc-primary-hover': string;
|
|
12
|
+
'--fc-primary-light': string;
|
|
13
|
+
'--fc-accent-color': string;
|
|
14
|
+
'--fc-text-color': string;
|
|
15
|
+
'--fc-text-secondary': string;
|
|
16
|
+
'--fc-text-light': string;
|
|
17
|
+
'--fc-border-color': string;
|
|
18
|
+
'--fc-border-color-hover': string;
|
|
19
|
+
'--fc-background': string;
|
|
20
|
+
'--fc-background-alt': string;
|
|
21
|
+
'--fc-background-hover': string;
|
|
22
|
+
'--fc-background-active': string;
|
|
23
|
+
'--fc-danger-color': string;
|
|
24
|
+
'--fc-success-color': string;
|
|
25
|
+
'--fc-border-radius': string;
|
|
26
|
+
'--fc-border-radius-sm': string;
|
|
27
|
+
'--fc-font-family': string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
4
30
|
export declare class StyleUtils {
|
|
5
31
|
/**
|
|
6
32
|
* Default theme colors
|