@forcecalendar/interface 1.1.0 → 1.3.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,151 @@
1
+ /**
2
+ * BaseViewRenderer - Foundation for all view renderers
3
+ *
4
+ * Pure JavaScript class (no Web Components) for Salesforce Locker Service compatibility.
5
+ * Provides common functionality for rendering calendar views.
6
+ */
7
+ export declare class BaseViewRenderer {
8
+ container: HTMLElement;
9
+ stateManager: StateManager;
10
+ _listeners: any[];
11
+ _scrolled: boolean;
12
+ _nowIndicatorTimer: number | null;
13
+ _pendingSlotFocus: {
14
+ colIndex: number;
15
+ hour: number;
16
+ } | {
17
+ colIndex: number;
18
+ hour: number;
19
+ } | null | undefined;
20
+ /**
21
+ * @param {HTMLElement} container - The DOM element to render into
22
+ * @param {StateManager} stateManager - The state manager instance
23
+ */
24
+ constructor(container: HTMLElement, stateManager: StateManager);
25
+ /**
26
+ * Render the view into the container
27
+ * Must be implemented by subclasses
28
+ */
29
+ render(): void;
30
+ /**
31
+ * Clean up event listeners
32
+ */
33
+ cleanup(): void;
34
+ /**
35
+ * Add an event listener with automatic cleanup tracking
36
+ * @param {HTMLElement} element
37
+ * @param {string} event
38
+ * @param {Function} handler
39
+ */
40
+ addListener(element: HTMLElement, event: string, handler: Function): void;
41
+ /**
42
+ * Escape HTML to prevent XSS
43
+ * @param {string} str
44
+ * @returns {string}
45
+ */
46
+ escapeHTML(str: string): string;
47
+ /**
48
+ * Check if a date is today
49
+ * @param {Date} date
50
+ * @returns {boolean}
51
+ */
52
+ isToday(date: Date): boolean;
53
+ /**
54
+ * Check if two dates are the same day
55
+ * @param {Date} date1
56
+ * @param {Date} date2
57
+ * @returns {boolean}
58
+ */
59
+ isSameDay(date1: Date, date2: Date): boolean;
60
+ /**
61
+ * Format hour for display (e.g., "9 AM", "2 PM")
62
+ * @param {number} hour - Hour in 24-hour format (0-23)
63
+ * @returns {string}
64
+ */
65
+ formatHour(hour: number): string;
66
+ /**
67
+ * Format time for display (e.g., "9 AM", "2:30 PM")
68
+ * @param {Date} date
69
+ * @returns {string}
70
+ */
71
+ formatTime(date: Date): string;
72
+ /**
73
+ * Get contrasting text color for a background color.
74
+ * Delegates to StyleUtils.getContrastColor() as the single implementation.
75
+ * @param {string} bgColor - Hex color string
76
+ * @returns {string} '#000000' or '#FFFFFF'
77
+ */
78
+ getContrastingTextColor(bgColor: string): string;
79
+ /**
80
+ * Render the "now" indicator line for time-based views
81
+ * @returns {string} HTML string
82
+ */
83
+ renderNowIndicator(): string;
84
+ /**
85
+ * Start a timer that updates the now indicator position every 60 seconds.
86
+ * Call this after render() in day/week views that show a now indicator.
87
+ */
88
+ startNowIndicatorTimer(): void;
89
+ /**
90
+ * Compute overlap layout columns for a list of timed events.
91
+ * Returns a Map of event.id -> { column, totalColumns }.
92
+ * Uses a greedy left-to-right column packing algorithm.
93
+ * @param {Array} events - Array of event objects with start/end dates
94
+ * @returns {Map<string, {column: number, totalColumns: number}>}
95
+ */
96
+ computeOverlapLayout(events: any[]): Map<string, {
97
+ column: number;
98
+ totalColumns: number;
99
+ }>;
100
+ /**
101
+ * Render a timed event block
102
+ * @param {Object} event - Event object
103
+ * @param {Object} options - Rendering options
104
+ * @param {Object} options.compact - Use compact layout
105
+ * @param {Object} options.overlapLayout - Map from computeOverlapLayout()
106
+ * @returns {string} HTML string
107
+ */
108
+ renderTimedEvent(event: Object, options?: {
109
+ compact: Object;
110
+ overlapLayout: Object;
111
+ }): string;
112
+ /**
113
+ * Get a safe, sanitized event color value.
114
+ * @param {Object} event
115
+ * @returns {string}
116
+ */
117
+ getEventColor(event: Object): string;
118
+ /**
119
+ * Attach common event handlers for day/event clicks
120
+ */
121
+ attachCommonEventHandlers(): void;
122
+ _selectEventFromElement(eventEl: any): void;
123
+ /**
124
+ * WAI-ARIA semantics and keyboard navigation for time grids (week/day
125
+ * views). The DOM is column-major (a column per day, an hour line per
126
+ * slot), so each day column is exposed as a row of 24 hour gridcells.
127
+ * Arrow keys navigate visually: Up/Down moves hours, Left/Right moves
128
+ * days, Home/End jumps to the day's bounds, PageUp/PageDown navigates
129
+ * periods, Enter/Space selects the slot's date and time.
130
+ * @param {string} columnSelector - Selector for the day columns
131
+ * @param {string} gridLabel - Accessible label for the grid
132
+ */
133
+ _enhanceTimeGridAccessibility(columnSelector: string, gridLabel: string): void;
134
+ /**
135
+ * Get the hour slot at a column/hour position
136
+ * @private
137
+ */
138
+ private _slotAt;
139
+ /**
140
+ * Keep exactly one hour slot tabbable. Defaults to 9:00 AM in the
141
+ * first column (today's column when present).
142
+ * @private
143
+ */
144
+ private _applySlotRovingTabindex;
145
+ /**
146
+ * Make rendered events keyboard-reachable and screen-reader labeled.
147
+ * Runs after every render, across all views.
148
+ */
149
+ _enhanceEventAccessibility(): void;
150
+ }
151
+ export default BaseViewRenderer;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * DayViewRenderer - Renders single day calendar view
3
+ *
4
+ * Pure JavaScript renderer for day view, compatible with Salesforce Locker Service.
5
+ */
6
+ import { BaseViewRenderer } from './BaseViewRenderer.js';
7
+ export declare class DayViewRenderer extends BaseViewRenderer {
8
+ hourHeight: number;
9
+ totalHeight: number;
10
+ constructor(container: any, stateManager: any);
11
+ render(): void;
12
+ _renderDayView(viewData: any, _config: any): string;
13
+ _extractDayData(viewData: any, currentDate: any): {
14
+ dayDate: Date;
15
+ dayName: any;
16
+ isToday: any;
17
+ allDayEvents: any;
18
+ timedEvents: any;
19
+ } | null;
20
+ _renderHeader(dayDate: any, dayName: any, isToday: any): string;
21
+ _renderAllDayRow(allDayEvents: any, dayDate: any): string;
22
+ _renderTimeGrid(timedEvents: any, isToday: any, dayDate: any, hours: any): string;
23
+ _renderTimeGutter(hours: any): string;
24
+ _renderDayColumn(timedEvents: any, isToday: any, dayDate: any, hours: any): string;
25
+ _attachEventHandlers(): void;
26
+ _scrollToCurrentTime(): void;
27
+ }
28
+ export default DayViewRenderer;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * MonthViewRenderer - Renders month calendar grid
3
+ *
4
+ * Pure JavaScript renderer for month view, compatible with Salesforce Locker Service.
5
+ */
6
+ import { BaseViewRenderer } from './BaseViewRenderer.js';
7
+ export declare class MonthViewRenderer extends BaseViewRenderer {
8
+ maxEventsToShow: number;
9
+ _pendingFocusMs: number | null | undefined;
10
+ _dayLabelFormatter: Intl.DateTimeFormat | undefined;
11
+ constructor(container: any, stateManager: any);
12
+ render(): void;
13
+ _renderMonthView(viewData: any, config: any): string;
14
+ _getDayNames(weekStartsOn: any): string[];
15
+ _renderWeek(week: any): string;
16
+ _renderDay(day: any): string;
17
+ _renderEvent(event: any): string;
18
+ _attachEventHandlers(): void;
19
+ /**
20
+ * Ensure exactly one grid cell participates in the tab order.
21
+ * Priority: requested focus date, selected date, today, first day of
22
+ * the current month.
23
+ * @param {number|null} focusMs - Preferred focus date as a timestamp
24
+ * @returns {HTMLElement|null} The tabbable cell
25
+ */
26
+ _applyRovingTabindex(focusMs?: number | null): HTMLElement | null;
27
+ }
28
+ export default MonthViewRenderer;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * WeekViewRenderer - Renders week calendar view
3
+ *
4
+ * Pure JavaScript renderer for week view, compatible with Salesforce Locker Service.
5
+ */
6
+ import { BaseViewRenderer } from './BaseViewRenderer.js';
7
+ export declare class WeekViewRenderer extends BaseViewRenderer {
8
+ hourHeight: number;
9
+ totalHeight: number;
10
+ constructor(container: any, stateManager: any);
11
+ render(): void;
12
+ _renderWeekView(viewData: any, _config: any): string;
13
+ _renderHeader(days: any): string;
14
+ _renderAllDayRow(days: any): string;
15
+ _renderTimeGrid(days: any, hours: any): string;
16
+ _renderTimeGutter(hours: any): string;
17
+ _renderDayColumn(day: any, hours: any): string;
18
+ _attachEventHandlers(): void;
19
+ _scrollToCurrentTime(): void;
20
+ }
21
+ export default WeekViewRenderer;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * View Renderers
3
+ *
4
+ * Pure JavaScript renderers for calendar views.
5
+ * Compatible with Salesforce Locker Service (no custom elements).
6
+ */
7
+ export { BaseViewRenderer } from './BaseViewRenderer.js';
8
+ export { MonthViewRenderer } from './MonthViewRenderer.js';
9
+ export { WeekViewRenderer } from './WeekViewRenderer.js';
10
+ export { DayViewRenderer } from './DayViewRenderer.js';
@@ -0,0 +1,121 @@
1
+ /**
2
+ * DOMUtils - DOM manipulation and event utilities
3
+ */
4
+ export declare class DOMUtils {
5
+ /**
6
+ * Create element with attributes and children
7
+ */
8
+ static createElement(tag: any, attributes?: {}, children?: any[]): any;
9
+ /**
10
+ * Add multiple event listeners
11
+ */
12
+ static addEventListeners(element: any, events: any): () => void;
13
+ /**
14
+ * Delegate event handling
15
+ */
16
+ static delegate(element: any, selector: any, event: any, handler: any): () => any;
17
+ /**
18
+ * Get element position relative to viewport
19
+ */
20
+ static getPosition(element: any): {
21
+ top: any;
22
+ left: any;
23
+ bottom: any;
24
+ right: any;
25
+ width: any;
26
+ height: any;
27
+ };
28
+ /**
29
+ * Check if element is in viewport
30
+ */
31
+ static isInViewport(element: any, threshold?: number): boolean;
32
+ /**
33
+ * Smooth scroll to element
34
+ */
35
+ static scrollToElement(element: any, options?: {}): void;
36
+ /**
37
+ * Get computed style value
38
+ */
39
+ static getStyle(element: any, property: any): string;
40
+ /**
41
+ * Set multiple styles
42
+ */
43
+ static setStyles(element: any, styles: any): void;
44
+ /**
45
+ * Add/remove classes with animation support
46
+ */
47
+ static animateClass(element: any, className: any, duration?: number): Promise<void>;
48
+ /**
49
+ * Wait for animation/transition to complete
50
+ * Resolves after `timeout` ms even if the event never fires (animation
51
+ * cancelled, element removed from DOM, etc.) so awaiting callers can't hang.
52
+ * @param {Element} element - Element to listen on
53
+ * @param {string} [eventType='animationend'] - Event to wait for
54
+ * @param {number} [timeout=3000] - Max wait in ms; 0 disables the timeout
55
+ */
56
+ static waitForAnimation(element: Element, eventType?: string, timeout?: number): Promise<any>;
57
+ /**
58
+ * Utility wait function
59
+ */
60
+ static wait(ms: any): Promise<any>;
61
+ /**
62
+ * Parse HTML string safely
63
+ * Sanitizes by default: strips script-capable elements, inline event
64
+ * handlers and javascript: URLs so the returned node is inert even if the
65
+ * input contains an XSS payload. Pass { sanitize: false } only for trusted,
66
+ * non-user-controlled markup.
67
+ */
68
+ static parseHTML(htmlString: any, { sanitize }?: {
69
+ sanitize?: boolean | undefined;
70
+ }): ChildNode | null;
71
+ /**
72
+ * Remove script-capable elements, on* handlers and javascript: URLs
73
+ * from a parsed DOM fragment (in place)
74
+ */
75
+ static _sanitizeNode(root: any): void;
76
+ /**
77
+ * Escape HTML to prevent XSS
78
+ */
79
+ static escapeHTML(str: any): string;
80
+ /**
81
+ * Debounce function calls
82
+ */
83
+ static debounce(func: any, wait?: number): (...args: any[]) => void;
84
+ /**
85
+ * Throttle function calls
86
+ */
87
+ static throttle(func: any, limit?: number): (...args: any[]) => void;
88
+ /**
89
+ * Get closest parent matching selector
90
+ */
91
+ static closest(element: any, selector: any): any;
92
+ /**
93
+ * Get all parents matching selector
94
+ */
95
+ static parents(element: any, selector: any): any[];
96
+ /**
97
+ * Measure element dimensions including margins
98
+ */
99
+ static getOuterDimensions(element: any): {
100
+ width: any;
101
+ height: any;
102
+ margin: {
103
+ top: number;
104
+ right: number;
105
+ bottom: number;
106
+ left: number;
107
+ };
108
+ };
109
+ /**
110
+ * Clone an element. Event listeners are NOT copied — the Web Platform
111
+ * provides no way to enumerate listeners, so callers must re-attach their
112
+ * own handlers to the clone.
113
+ * @deprecated Use element.cloneNode(deep) directly and re-bind listeners.
114
+ */
115
+ static cloneWithEvents(element: any, deep?: boolean): any;
116
+ /**
117
+ * Focus trap for modals/dialogs
118
+ */
119
+ static trapFocus(container: any): () => any;
120
+ }
121
+ export default DOMUtils;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * DateUtils - Date formatting and manipulation utilities
3
+ *
4
+ * Extends Core DateUtils with UI-specific formatting
5
+ */
6
+ import { DateUtils as CoreDateUtils } from '@forcecalendar/core';
7
+ export declare class DateUtils extends CoreDateUtils {
8
+ /**
9
+ * Format date for display
10
+ */
11
+ static formatDate(date: any, format?: string, locale?: string): string;
12
+ /**
13
+ * Format time for display
14
+ */
15
+ static formatTime(date: any, showMinutes?: boolean, use24Hour?: boolean, locale?: string): string;
16
+ /**
17
+ * Format date range for display
18
+ */
19
+ static formatDateRange(start: any, end: any, locale?: string): string;
20
+ /**
21
+ * Format time range for display
22
+ */
23
+ static formatTimeRange(start: any, end: any, locale?: string): string;
24
+ /**
25
+ * Get relative time string (e.g., "2 hours ago", "in 3 days")
26
+ */
27
+ static getRelativeTime(date: any, baseDate?: Date, locale?: string): string;
28
+ /**
29
+ * Check if date is today
30
+ */
31
+ static isToday(date: any): any;
32
+ /**
33
+ * Check if date is in the past
34
+ */
35
+ static isPast(date: any): boolean;
36
+ /**
37
+ * Check if date is in the future
38
+ */
39
+ static isFuture(date: any): boolean;
40
+ /**
41
+ * Get calendar week number
42
+ */
43
+ static getWeekNumber(date: any): number;
44
+ /**
45
+ * Get day abbreviation
46
+ */
47
+ static getDayAbbreviation(dayIndex: any, locale?: string): string;
48
+ /**
49
+ * Get full day name
50
+ */
51
+ static getDayName(dayIndex: any, locale?: string): string;
52
+ /**
53
+ * Get month name
54
+ */
55
+ static getMonthName(monthIndex: any, format?: string, locale?: string): string;
56
+ /**
57
+ * Parse time string (e.g., "14:30" or "2:30 PM")
58
+ */
59
+ static parseTimeString(timeStr: any, baseDate?: Date): Date;
60
+ }
61
+ export default DateUtils;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * StyleUtils - Styling utilities and theme management
3
+ */
4
+ export declare class StyleUtils {
5
+ /**
6
+ * Default theme colors
7
+ */
8
+ static colors: {
9
+ primary: string;
10
+ secondary: string;
11
+ accent: string;
12
+ danger: string;
13
+ warning: string;
14
+ info: string;
15
+ success: string;
16
+ light: string;
17
+ dark: string;
18
+ white: string;
19
+ gray: {
20
+ 50: string;
21
+ 100: string;
22
+ 200: string;
23
+ 300: string;
24
+ 400: string;
25
+ 500: string;
26
+ 600: string;
27
+ 700: string;
28
+ 800: string;
29
+ 900: string;
30
+ };
31
+ };
32
+ /**
33
+ * Common CSS variables
34
+ */
35
+ static cssVariables: {
36
+ '--fc-primary-color': string;
37
+ '--fc-primary-hover': string;
38
+ '--fc-primary-light': string;
39
+ '--fc-text-color': string;
40
+ '--fc-text-secondary': string;
41
+ '--fc-text-light': string;
42
+ '--fc-border-color': string;
43
+ '--fc-border-color-hover': string;
44
+ '--fc-background': string;
45
+ '--fc-background-alt': string;
46
+ '--fc-background-hover': string;
47
+ '--fc-background-active': string;
48
+ '--fc-accent-color': string;
49
+ '--fc-danger-color': string;
50
+ '--fc-success-color': string;
51
+ '--fc-font-family': string;
52
+ '--fc-font-size-xs': string;
53
+ '--fc-font-size-sm': string;
54
+ '--fc-font-size-base': string;
55
+ '--fc-font-size-lg': string;
56
+ '--fc-font-size-xl': string;
57
+ '--fc-font-size-2xl': string;
58
+ '--fc-line-height': string;
59
+ '--fc-font-weight-normal': string;
60
+ '--fc-font-weight-medium': string;
61
+ '--fc-font-weight-semibold': string;
62
+ '--fc-font-weight-bold': string;
63
+ '--fc-spacing-xs': string;
64
+ '--fc-spacing-sm': string;
65
+ '--fc-spacing-md': string;
66
+ '--fc-spacing-lg': string;
67
+ '--fc-spacing-xl': string;
68
+ '--fc-spacing-2xl': string;
69
+ '--fc-border-width': string;
70
+ '--fc-border-radius-sm': string;
71
+ '--fc-border-radius': string;
72
+ '--fc-border-radius-lg': string;
73
+ '--fc-border-radius-full': string;
74
+ '--fc-shadow-sm': string;
75
+ '--fc-shadow': string;
76
+ '--fc-shadow-md': string;
77
+ '--fc-shadow-lg': string;
78
+ '--fc-transition-fast': string;
79
+ '--fc-transition': string;
80
+ '--fc-transition-slow': string;
81
+ '--fc-z-dropdown': string;
82
+ '--fc-z-modal': string;
83
+ '--fc-z-tooltip': string;
84
+ };
85
+ /**
86
+ * Get CSS variable value
87
+ */
88
+ static getCSSVariable(name: any, element?: HTMLElement): string;
89
+ /**
90
+ * Set CSS variables
91
+ */
92
+ static setCSSVariables(variables: any, element?: HTMLElement): void;
93
+ /**
94
+ * Generate base styles
95
+ */
96
+ static getBaseStyles(): string;
97
+ /**
98
+ * Generate button styles
99
+ */
100
+ static getButtonStyles(): string;
101
+ /**
102
+ * Darken color by percentage
103
+ */
104
+ static darken(color: any, percent: any): string;
105
+ /**
106
+ * Lighten color by percentage
107
+ */
108
+ static lighten(color: any, percent: any): string;
109
+ /**
110
+ * Get contrast color (black or white) for background
111
+ */
112
+ static getContrastColor(bgColor: any): "#000000" | "#FFFFFF";
113
+ /**
114
+ * Sanitize color value to prevent CSS injection
115
+ * Returns the color if valid, or a fallback color if invalid
116
+ */
117
+ static sanitizeColor(color: any, fallback?: string): string;
118
+ /**
119
+ * Convert hex to rgba
120
+ */
121
+ static hexToRgba(hex: any, alpha?: number): string;
122
+ /**
123
+ * Generate grid styles
124
+ */
125
+ static getGridStyles(): string;
126
+ /**
127
+ * Get responsive breakpoints
128
+ */
129
+ static breakpoints: {
130
+ xs: string;
131
+ sm: string;
132
+ md: string;
133
+ lg: string;
134
+ xl: string;
135
+ '2xl': string;
136
+ };
137
+ /**
138
+ * Generate media query
139
+ */
140
+ static mediaQuery(breakpoint: any, styles: any): string;
141
+ /**
142
+ * Animation keyframes
143
+ */
144
+ static getAnimations(): string;
145
+ }
146
+ export default StyleUtils;