@liturgical-calendar/components-js
Version:
Liturgical calendar components for javascript: an html select populated with liturgical calendars supported by the Liturgical Calendar API; form controls for parameters that are supported by the Liturgical Calendar API; a webcalendar; and liturgy of the d
210 lines • 9.72 kB
TypeScript
export default class LiturgyOfTheDay {
/**
* @type {RegExp[]}
* @static
* @private
* @readonly
*/
private static readonly "__#16@#filterTagsDisplayGrade";
/**
* @type {['geeen', 'red', 'purple']}
* @static
* @private
* @readonly
*/
private static readonly "__#16@#highContrast";
/**
* Validates the given class name to ensure it is a valid CSS class name.
*
* A valid CSS class name is a string that starts with a letter, underscore or dash,
* followed by any number of alphanumeric characters, dashes or underscores.
*
* @param {string} className - The class name to validate.
* @returns {boolean} True if the class name is valid, false otherwise.
* @static
* @private
*/
private static "__#16@#isValidClassName";
/**
* Validates the given ID to ensure it is a valid HTML ID.
*
* A valid HTML ID is a string that starts with a letter, underscore or dash,
* followed by any number of alphanumeric characters, dashes or underscores.
*
* @param {string} id - The ID to validate.
* @returns {boolean} True if the ID is valid, false otherwise.
* @static
* @private
*/
private static "__#16@#isValidId";
/**
* Validates the given element selector to ensure it is a valid HTML element selector.
*
* @param {string} element - The element selector to validate.
* @returns {Element} The DOM element that the selector matches.
* @throws {Error} If the element selector is invalid or does not match any elements.
* @static
* @private
*/
private static "__#16@#validateElementSelector";
/**
* Constructs a LiturgyOfTheDay object.
*
* @param {string|Object|null} [options=null] - The locale to use for formatting the date and the titles.
* The locale should be a valid string that can be parsed by the Intl.getCanonicalLocales function.
* If the locale string contains an underscore, the underscore will be replaced with a hyphen.
* The default is 'en' (English). Locales with region extensions are also supported, such as 'en-US', 'en-GB', 'en-CA', etc.
*
* @throws {Error} If the locale is invalid.
*/
constructor(options?: string | Object | null);
/**
* Sets the id of the element.
*
* @param {string} id The id of the element
* @throws {Error} if id is not a string
* @throws {Error} if id is not a valid CSS selector
* @returns {LiturgyOfTheDay} The current instance of LiturgyOfTheDay, allowing method chaining
*/
id(id: string): LiturgyOfTheDay;
/**
* Sets the class attribute for the LiturgyOfTheDay instance's DOM element.
*
* Validates the input class name(s) to ensure they are strings and conform to
* CSS class naming conventions. If the class name is valid, it is sanitized
* and assigned to the element.
*
* @param {string} className - A space-separated string of class names to be
* assigned to the DOM element.
* @throws {Error} If the className is not a string, or if any class name is
* invalid.
* @returns {LiturgyOfTheDay} The current LiturgyOfTheDay instance for chaining.
*/
class(className: string): LiturgyOfTheDay;
/**
* Sets the class attribute for the title element of the LiturgyOfTheDay instance.
*
* Validates the input class name(s) to ensure they are strings and conform to
* CSS class naming conventions. If the class name is valid, it is sanitized
* and added to the title element.
*
* @param {string} className - A space-separated string of class names to be
* assigned to the title element.
* @throws {Error} If the className is not a string, or if any class name is
* invalid.
* @returns {LiturgyOfTheDay} The current LiturgyOfTheDay instance for chaining.
*/
titleClass(className: string): LiturgyOfTheDay;
/**
* Sets the class attribute for the date element of the LiturgyOfTheDay instance.
*
* Validates the input class name(s) to ensure they are strings and conform to
* CSS class naming conventions. If the class name is valid, it is sanitized
* and added to the date element.
*
* @param {string} className - A space-separated string of class names to be
* assigned to the date element.
* @throws {Error} If the className is not a string, or if any class name is
* invalid.
* @returns {LiturgyOfTheDay} The current LiturgyOfTheDay instance for chaining.
*/
dateClass(className: string): LiturgyOfTheDay;
/**
* Sets the class attribute for the wrapper element of the LiturgyOfTheDay instance's events.
*
* Validates the input class name(s) to ensure they are strings and conform to
* CSS class naming conventions. If the class name is valid, it is sanitized
* and assigned to the element.
*
* @param {string} className - A space-separated string of class names to be
* assigned to the events wrapper element.
* @throws {Error} If the className is not a string, or if any class name is
* invalid.
* @returns {LiturgyOfTheDay} The current LiturgyOfTheDay instance for chaining.
*/
eventsWrapperClass(className: string): LiturgyOfTheDay;
/**
* Sets the class attribute for the event elements of the LiturgyOfTheDay instance.
*
* Validates the input class name(s) to ensure they are strings and conform to
* CSS class naming conventions. If the class name is valid, it is sanitized
* and assigned to the event elements wrapper.
*
* @param {string} className - A space-separated string of class names to be
* assigned to the event elements.
* @throws {Error} If the className is not a string, or if any class name is
* invalid.
* @returns {LiturgyOfTheDay} The current LiturgyOfTheDay instance for chaining.
*/
eventClass(className: string): LiturgyOfTheDay;
eventGradeClass(className: any): this;
eventCommonClass(className: any): this;
eventYearCycleClass(className: any): this;
/**
* Sets the LiturgyOfTheDay instance to listen to the `calendarFetched` event emitted by the ApiClient.
*
* Upon receiving the event, it processes the liturgical calendar data and updates the liturgical events
* section of the component. The method will validate that the `apiClient` is an instance of ApiClient and
* listen to the `calendarFetched` event on the client's event bus. When the event is triggered, it checks
* the integrity of the received data, ensuring it contains the necessary properties and is of the correct type.
* It then filters the liturgical calendar data to only include events that match the current date and updates
* the internal state of the component.
*
* @param {ApiClient} apiClient - The API client to listen to for calendar data events.
* @throws {Error} If the provided `apiClient` is not an instance of ApiClient or if the received
* data is invalid or malformed.
* @return {LiturgyOfTheDay} - Returns the instance of LiturgyOfTheDay for method chaining.
*/
listenTo(apiClient: ApiClient): LiturgyOfTheDay;
/**
* Appends the LiturgyOfTheDay instance to the element matched by the provided element selector.
*
* @param {string|HTMLElement} elementSelector - The CSS selector for the element to which the LiturgyOfTheDay instance will be appended.
* @throws {Error} If the type of elementSelector is not a string.
* @throws {Error} If the element selector is invalid.
* @throws {Error} If the element selector does not match any element.
* @return {LiturgyOfTheDay} - The same instance of LiturgyOfTheDay, allowing method chaining
*/
appendTo(elementSelector: string | HTMLElement): LiturgyOfTheDay;
/**
* Replaces the element matched by the provided element selector with the LiturgyOfTheDay instance.
*
* @param {string|HTMLElement} elementSelector - The CSS selector for the element to be replaced.
* @throws {Error} If the type of elementSelector is not a string.
* @throws {Error} If the element selector is invalid.
* @throws {Error} If the element selector does not match any element.
* @return {LiturgyOfTheDay} - The same instance of LiturgyOfTheDay, allowing method chaining
*/
replace(elementSelector: string | HTMLElement): LiturgyOfTheDay;
/**
* Retrieves the underlying DOM element of the LiturgyOfTheDay instance.
*
* @returns {HTMLElement} The DOM element associated with the LiturgyOfTheDay instance.
* @readonly
*/
readonly get _domElement(): HTMLElement;
/**
* Retrieves the underlying title element associated with the LiturgyOfTheDay instance.
*
* @returns {HTMLElement} The title element.
* @readonly
*/
readonly get _titleElement(): HTMLElement;
/**
* Retrieves the underlying date element associated with the LiturgyOfTheDay instance.
*
* @returns {HTMLElement} The date element.
* @readonly
*/
readonly get _dateElement(): HTMLElement;
/**
* Retrieves the underlying wrapper element for the liturgical events list.
*
* @returns {HTMLElement} The wrapper element for the liturgical events list.
* @readonly
*/
readonly get _eventsElementsWrapper(): HTMLElement;
#private;
}
import ApiClient from '../ApiClient/ApiClient.js';
//# sourceMappingURL=LiturgyOfTheDay.d.ts.map