/** * 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 select 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. * - ___holydaysOfObligationInput__: The select input with options for which holy days of obligation are observed. * - ___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 { /** @type {string[]} */ static "__#13@#expectedSettingsKeys": string[]; /** * Basic heuristic to make Holy Days of Obligation select options labels human-friendly * * TODO: It would be even better to retrieve the actual "name" of the corresponding liturgical events from the current calendar, * but this would require fetching the calendar data first, which is not ideal. * So for now, this private method just applies some basic transformations to make the keys more readable. * We don't have access to any calendar data in ApiClient._calendarData, because it is not a static property, it is an instance property. * Had we access to that instance property, and calendar data had been fetched, * we could filter the calendar data to find the corresponding localized event names. * * @param {string} key * @returns {string} */ static "__#13@#prettifyLabel"(key: string): string; /** * 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`, `ApiOptionsFilter.LOCALE_ONLY`, `ApiOptionsFilter.YEAR_ONLY`, 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.LOCALE_ONLY` will show only the locale input, useful when you only need language selection. * - `ApiOptionsFilter.YEAR_ONLY` will show only the year input, useful when used with LiturgyOfAnyDay component. * - `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 (one for nations and one for dioceses) 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 Holydays of Obligation input element. * * @returns {HolydaysOfObligationInput} The Holydays of Obligation input element. * @readonly */ readonly get _holydaysOfObligationInput(): HolydaysOfObligationInput; /** * 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`, `ApiOptionsFilter.LOCALE_ONLY`, `ApiOptionsFilter.YEAR_ONLY`, 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.LOCALE_ONLY` will show only the locale input, useful when you only need language selection. * - `ApiOptionsFilter.YEAR_ONLY` will show only the year input, useful when used with LiturgyOfAnyDay component. * - `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} An array of filter values applied to the ApiOptions instance. * @readonly */ readonly get _filtersSet(): Array; #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 { HolydaysOfObligationInput } 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