@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
183 lines • 9.05 kB
TypeScript
/**
* Class to generate form controls for request options to the Liturgical Calendar API.
*
* The form controls can be fully customized using the methods provided by the class.
*
* __ constructor()__ Initializes the ApiOptions object with default or provided settings:
* - __locale__: The locale to use for the API options form.
*
* The following properties are initialized on the object instance:
* - ___epiphanyInput__: The seslect input with options for when the Epiphany is celebrated.
* - ___ascensionInput__: The select input with options for when the Ascension is celebrated.
* - ___corpusChristiInput__: The select input with options for when Corpus Christi is celebrated.
* - ___eternalHighPriestInput__: The select input with options for whether the Eternal High Priest is celebrated.
* - ___yearTypeInput__: The select input with options for the type of year to produce, whether liturgical or civil.
* - ___localeInput__: The select input with options for the locale to use for the calendar response from the API.
* - ___acceptHeaderInput__: The select input with options for the Accept header to use for the calendar response from the API.
*
* @example
* const apiOptions = new ApiOptions();
* apiOptions.localeInput.defaultValue( 'en' );
* apiOptions.acceptHeaderInput.hide();
*
* @example
* const apiOptions = new ApiOptions('it-IT');
* apiOptions.localeInput.defaultValue( 'it' );
*
* @author [John Romano D'Orazio](https://github.com/JohnRDOrazio)
* @license Apache-2.0
* @see https://github.com/Liturgical-Calendar/liturgy-components-js
*/
export default class ApiOptions {
/**
* Constructs an instance of the ApiOptions class, initializing various input components
* with the given locale. Throws an error if the locale is invalid.
*
* @param {string} locale - The locale to use for initialization, defaults to 'en'.
* Underscores in the locale string are replaced with hyphens.
*
* @throws {Error} If the locale is invalid or not recognized.
*/
constructor(locale?: string);
/**
* Sets the filter for the ApiOptions instance.
*
* The filter can be either `ApiOptionsFilter.ALL_CALENDARS`, `ApiOptionsFilter.GENERAL_ROMAN`, `ApiOptionsFilter.PATH_BUILDER`, or `ApiOptionsFilter.NONE`.
* - `ApiOptionsFilter.ALL_CALENDARS` will show only the form controls that are useful for all calendars: locale, yearType, year, and conditionally acceptHeader inputs.
* - `ApiOptionsFilter.GENERAL_ROMAN` will show only the form controls that are useful for the General Roman Calendar: epiphany, ascension, corpusChristi, and eternalHighPriest inputs.
* - `ApiOptionsFilter.PATH_BUILDER` will show only the form controls that are useful for the Path Builder: calendarPath and year inputs.
* - `ApiOptionsFilter.NONE` will show all possible form controls.
*
* If the filter is set to a value that is not a valid value for the `ApiOptionsFilter` enum,
* an error will be thrown.
*
* If the filter has been previously set to a value that is not ApiOptionsFilter.NONE,
* the select elements will be filtered accordingly, but a value of ApiOptionsFilter.NONE cannot be set.
*
* If the filter has been previously set to ApiOptionsFilter.NONE,
* the select elements will be filtered accordingly, but a value other than ApiOptionsFilter.NONE cannot be set.
*
* @param {string} [filter=ApiOptionsFilter.NONE] The filter to set.
* @throws {Error} If the filter is set to a value that is not a valid value for the `ApiOptionsFilter` enum.
* @throws {Error} If the filter is set to a value that is different from the current filter.
* @returns {ApiOptions} The ApiOptions instance.
*/
filter(filter?: string): ApiOptions;
/**
* Link the ApiOptions instance to a CalendarSelect instance or an array of two CalendarSelect instances.
* When a CalendarSelect instance is linked, the selected calendar's settings will be used to populate the
* API options. When the selected calendar is changed, the API options will be updated accordingly.
* If two CalendarSelect instances are linked, one must be a `nations` filtered CalendarSelect and the other a
* `dioceses` filtered CalendarSelect. When the selected calendar is changed in either of the two CalendarSelect
* instances, the API options will be updated accordingly.
* @param {CalendarSelect | [CalendarSelect, CalendarSelect]} calendarSelect - The CalendarSelect instance or
* an array of two CalendarSelect instances to link to the ApiOptions instance.
* @returns {ApiOptions} - The ApiOptions instance.
*/
linkToCalendarSelect(calendarSelect: CalendarSelect | [CalendarSelect, CalendarSelect]): ApiOptions;
/**
* Appends input elements to the specified DOM element, optionally filtered based on the ApiOptionsFilter.
*
* @param {string|HTMLElement} elementSelector - The CSS selector for the DOM element to which the input elements will be appended.
*/
appendTo(elementSelector: string | HTMLElement): void;
/**
* Gets the Epiphany input element.
*
* @returns {EpiphanyInput} The Epiphany input element.
* @readonly
*/
readonly get _epiphanyInput(): EpiphanyInput;
/**
* Gets the Ascension input element.
*
* @returns {AscensionInput} The Ascension input element.
* @readonly
*/
readonly get _ascensionInput(): AscensionInput;
/**
* Gets the Corpus Christi input element.
*
* @returns {CorpusChristiInput} The Corpus Christi input element.
* @readonly
*/
readonly get _corpusChristiInput(): CorpusChristiInput;
/**
* Gets the Eternal High Priest input element.
*
* @returns {EternalHighPriestInput} The Eternal High Priest input element.
* @readonly
*/
readonly get _eternalHighPriestInput(): EternalHighPriestInput;
/**
* Gets the locale input element.
*
* @returns {LocaleInput} The locale input element.
* @readonly
*/
readonly get _localeInput(): LocaleInput;
/**
* Gets the year type input element.
*
* @returns {YearTypeInput} The year type input element.
* @readonly
*/
readonly get _yearTypeInput(): YearTypeInput;
/**
* Gets the year input element.
*
* @returns {YearInput} The year input element.
* @readonly
*/
readonly get _yearInput(): YearInput;
/**
* Gets the Accept header input element.
*
* @returns {AcceptHeaderInput} The Accept header input element.
* @readonly
*/
readonly get _acceptHeaderInput(): AcceptHeaderInput;
/**
* Gets the calendar path input element.
*
* @returns {CalendarPathInput} The calendar path input element.
* @readonly
*/
readonly get _calendarPathInput(): CalendarPathInput;
/**
* Gets the CURRENT filter of the ApiOptions instance.
* The filter can be set explicitly multiple times, and the last set filter will be returned.
*
* The filter can be either `ApiOptionsFilter.GENERAL_ROMAN`, `ApiOptionsFilter.ALL_CALENDARS`, `ApiOptionsFilter.PATH_BUILDER`, or `ApiOptionsFilter.NONE`.
* - `ApiOptionsFilter.ALL_CALENDARS` will show only the form controls that are useful for all calendars: locale, yearType, year, and conditionally acceptHeader inputs.
* - `ApiOptionsFilter.GENERAL_ROMAN` will show only the form controls that are useful for the General Roman Calendar: epiphany, ascension, corpusChristi, and eternalHighPriest inputs.
* - `ApiOptionsFilter.PATH_BUILDER` will show only the form controls that are useful for the Path Builder: calendarPath and year inputs.
* - `ApiOptionsFilter.NONE` will show all possible form controls.
*
* @returns {string} The current filter of the ApiOptions instance.
* @readonly
*/
readonly get _filter(): string;
/**
* Gets the set of filters that have been applied to the ApiOptions instance.
*
* This is a list of filter values that have been set, and may contain multiple
* entries if filters have been set in succession.
*
* @returns {Array<string>} An array of filter values applied to the ApiOptions instance.
* @readonly
*/
readonly get _filtersSet(): Array<string>;
#private;
}
import CalendarSelect from '../CalendarSelect/CalendarSelect.js';
import { EpiphanyInput } from './Input/index.js';
import { AscensionInput } from './Input/index.js';
import { CorpusChristiInput } from './Input/index.js';
import { EternalHighPriestInput } from './Input/index.js';
import { LocaleInput } from './Input/index.js';
import { YearTypeInput } from './Input/index.js';
import { YearInput } from './Input/index.js';
import { AcceptHeaderInput } from './Input/index.js';
import { CalendarPathInput } from './Input/index.js';
//# sourceMappingURL=ApiOptions.d.ts.map