UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1,286 lines (1,285 loc) • 42.3 kB
/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.5.0-next.4 */ import { Build, h, Host } from "@stencil/core"; import { dateFromISO, dateFromLocalizedString, dateFromRange, datePartsFromLocalizedString, dateToISO, inRange } from "../../utils/date"; import { toAriaBoolean } from "../../utils/dom"; import { connectFloatingUI, defaultMenuPlacement, disconnectFloatingUI, filterComputedPlacements, FloatingCSS, reposition } from "../../utils/floating-ui"; import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form"; import { connectInteractive, disconnectInteractive, updateHostInteraction } from "../../utils/interactive"; import { numberKeys } from "../../utils/key"; import { connectLabel, disconnectLabel } from "../../utils/label"; import { componentLoaded, setComponentLoaded, setUpLoadableComponent } from "../../utils/loadable"; import { connectLocalized, disconnectLocalized, numberStringFormatter } from "../../utils/locale"; import { connectOpenCloseComponent, disconnectOpenCloseComponent } from "../../utils/openCloseComponent"; import { getLocaleData, getValueAsDateRange } from "../date-picker/utils"; import { CSS } from "./resources"; import { connectMessages, disconnectMessages, setUpMessages } from "../../utils/t9n"; import { activateFocusTrap, connectFocusTrap, deactivateFocusTrap } from "../../utils/focusTrapComponent"; import { guid } from "../../utils/guid"; export class InputDatePicker { constructor() { this.calciteInternalInputInputHandler = (event) => { const target = event.target; const value = target.value; const parsedValue = this.parseNumerals(value); const formattedValue = this.formatNumerals(parsedValue); target.value = formattedValue; const { year } = datePartsFromLocalizedString(value, this.localeData); if (year && year.length < 4) { return; } const date = dateFromLocalizedString(value, this.localeData); if (inRange(date, this.min, this.max)) { this.datePickerActiveDate = date; } }; this.calciteInternalInputBlurHandler = () => { this.commitValue(); }; this.dialogId = `date-picker-dialog--${guid()}`; this.focusOnOpen = false; this.lastBlurredInput = "none"; this.userChangedValue = false; this.openTransitionProp = "opacity"; this.valueAsDateChangedExternally = false; //-------------------------------------------------------------------------- // // Private Methods // //-------------------------------------------------------------------------- this.onInputWrapperClick = () => { if (this.range && this.lastBlurredInput !== "none" && this.open) { // we keep the date-picker open when moving between inputs } else { this.open = !this.open; } this.lastBlurredInput = "none"; }; this.setFilteredPlacements = () => { const { el, flipPlacements } = this; this.filteredFlipPlacements = flipPlacements ? filterComputedPlacements(flipPlacements, el) : null; }; this.setTransitionEl = (el) => { this.transitionEl = el; connectOpenCloseComponent(this); }; this.setStartInput = (el) => { this.startInput = el; }; this.setEndInput = (el) => { this.endInput = el; }; this.deactivate = () => { this.open = false; this.lastBlurredInput = "none"; }; this.keyDownHandler = (event) => { const { defaultPrevented, key } = event; if (defaultPrevented) { return; } if (key === "Enter") { this.commitValue(); if (this.shouldFocusRangeEnd()) { this.endInput?.setFocus(); } else if (this.shouldFocusRangeStart()) { this.startInput?.setFocus(); } if (submitForm(this)) { event.preventDefault(); this.restoreInputFocus(); } } else if (key === "ArrowDown") { this.open = true; this.focusOnOpen = true; event.preventDefault(); } else if (key === "Escape") { this.open = false; event.preventDefault(); this.restoreInputFocus(); } }; this.startInputFocus = () => { this.focusedInput = "start"; }; this.startEndInputFocus = (event) => { const blurredEl = event.relatedTarget; this.lastBlurredInput = blurredEl === this.startInput ? "start" : blurredEl === this.endInput ? "end" : "none"; }; this.endInputFocus = () => { this.focusedInput = "end"; }; this.setFloatingEl = (el) => { this.floatingEl = el; connectFloatingUI(this, this.referenceEl, this.floatingEl); }; this.setStartWrapper = (el) => { this.startWrapper = el; this.setReferenceEl(); }; this.setEndWrapper = (el) => { this.endWrapper = el; this.setReferenceEl(); }; this.setDatePickerRef = (el) => { this.datePickerEl = el; connectFocusTrap(this, { focusTrapEl: el, focusTrapOptions: { initialFocus: false, setReturnFocus: false } }); }; /** * Event handler for when the selected date changes * * @param event CalciteDatePicker custom change event */ this.handleDateChange = (event) => { if (this.range) { return; } event.stopPropagation(); this.setValue(event.target.valueAsDate); this.localizeInputValues(); this.restoreInputFocus(); }; this.handleDateRangeChange = (event) => { if (!this.range) { return; } event.stopPropagation(); const value = event.target.valueAsDate; this.setRangeValue(value); this.localizeInputValues(); this.restoreInputFocus(); }; this.setInputValue = (newValue, input = "start") => { const inputEl = this[`${input}Input`]; if (!inputEl) { return; } inputEl.value = newValue; }; this.setRangeValue = (valueAsDate) => { if (!this.range) { return; } const { value: oldValue } = this; const oldValueIsArray = Array.isArray(oldValue); const valueIsArray = Array.isArray(valueAsDate); const newStartDate = valueIsArray ? valueAsDate[0] : null; const newStartDateISO = valueIsArray ? dateToISO(newStartDate) : ""; const newEndDate = valueIsArray ? valueAsDate[1] : null; const newEndDateISO = valueIsArray ? dateToISO(newEndDate) : ""; const newValue = newStartDateISO || newEndDateISO ? [newStartDateISO, newEndDateISO] : ""; if (newValue === oldValue) { return; } this.userChangedValue = true; this.value = newValue; this.valueAsDate = newValue ? getValueAsDateRange(newValue) : undefined; const changeEvent = this.calciteInputDatePickerChange.emit(); if (changeEvent && changeEvent.defaultPrevented) { this.value = oldValue; if (oldValueIsArray) { this.setInputValue(oldValue[0], "start"); this.setInputValue(oldValue[1], "end"); } else { this.value = oldValue; this.setInputValue(oldValue); } } }; this.setValue = (value) => { if (this.range) { return; } const oldValue = this.value; const newValue = dateToISO(value); if (newValue === oldValue) { return; } this.userChangedValue = true; this.valueAsDate = newValue ? dateFromISO(newValue) : undefined; this.value = newValue || ""; const changeEvent = this.calciteInputDatePickerChange.emit(); if (changeEvent.defaultPrevented) { this.value = oldValue; this.setInputValue(oldValue); } }; this.commonDateSeparators = [".", "-", "/"]; this.formatNumerals = (value) => value ? value .split("") .map((char) => this.commonDateSeparators?.includes(char) ? this.localeData?.separator : numberKeys?.includes(char) ? numberStringFormatter?.numberFormatter?.format(Number(char)) : char) .join("") : ""; this.parseNumerals = (value) => value ? value .split("") .map((char) => numberKeys.includes(char) ? numberStringFormatter.delocalize(char) : char) .join("") : ""; this.disabled = false; this.focusTrapDisabled = false; this.form = undefined; this.readOnly = false; this.value = ""; this.flipPlacements = undefined; this.headingLevel = undefined; this.valueAsDate = undefined; this.messageOverrides = undefined; this.messages = undefined; this.minAsDate = undefined; this.maxAsDate = undefined; this.min = undefined; this.max = undefined; this.open = false; this.name = undefined; this.numberingSystem = undefined; this.scale = "m"; this.placement = defaultMenuPlacement; this.range = false; this.required = false; this.overlayPositioning = "absolute"; this.proximitySelectionDisabled = false; this.layout = "horizontal"; this.datePickerActiveDate = undefined; this.defaultMessages = undefined; this.effectiveLocale = ""; this.focusedInput = "start"; this.localeData = undefined; } handleFocusTrapDisabled(focusTrapDisabled) { if (!this.open) { return; } focusTrapDisabled ? deactivateFocusTrap(this) : activateFocusTrap(this); } handleDisabledAndReadOnlyChange(value) { if (!value) { this.open = false; } } valueWatcher(newValue) { if (!this.userChangedValue) { let newValueAsDate; if (Array.isArray(newValue)) { newValueAsDate = getValueAsDateRange(newValue); } else if (newValue) { newValueAsDate = dateFromISO(newValue); } else { newValueAsDate = undefined; } if (!this.valueAsDateChangedExternally && newValueAsDate !== this.valueAsDate) { this.valueAsDate = newValueAsDate; } this.localizeInputValues(); } this.userChangedValue = false; } valueAsDateWatcher(valueAsDate) { this.datePickerActiveDate = valueAsDate; const newValue = this.range && Array.isArray(valueAsDate) ? [dateToISO(valueAsDate[0]), dateToISO(valueAsDate[1])] : dateToISO(valueAsDate); if (this.value !== newValue) { this.valueAsDateChangedExternally = true; this.value = newValue; this.valueAsDateChangedExternally = false; } } flipPlacementsHandler() { this.setFilteredPlacements(); this.reposition(true); } onMessagesChange() { /* wired up by t9n util */ } onMinChanged(min) { if (min) { this.minAsDate = dateFromISO(min); } } onMaxChanged(max) { if (max) { this.maxAsDate = dateFromISO(max); } } openHandler(value) { if (this.disabled || this.readOnly) { this.open = false; return; } if (value) { this.reposition(true); } } overlayPositioningHandler() { this.reposition(true); } //-------------------------------------------------------------------------- // // Event Listeners // //-------------------------------------------------------------------------- calciteDaySelectHandler() { if (this.shouldFocusRangeStart() || this.shouldFocusRangeEnd()) { return; } this.open = false; } // -------------------------------------------------------------------------- // // Public Methods // // -------------------------------------------------------------------------- /** Sets focus on the component. */ async setFocus() { await componentLoaded(this); this.el.focus(); } /** * Updates the position of the component. * * @param delayed */ async reposition(delayed = false) { const { floatingEl, referenceEl, placement, overlayPositioning, filteredFlipPlacements } = this; return reposition(this, { floatingEl, referenceEl, overlayPositioning, placement, flipPlacements: filteredFlipPlacements, type: "menu" }, delayed); } // -------------------------------------------------------------------------- // // Lifecycle // // -------------------------------------------------------------------------- connectedCallback() { connectInteractive(this); connectLocalized(this); const { open } = this; open && this.openHandler(open); if (Array.isArray(this.value)) { this.valueAsDate = getValueAsDateRange(this.value); } else if (this.value) { try { this.valueAsDate = dateFromISO(this.value); } catch (error) { this.warnAboutInvalidValue(this.value); this.value = ""; } } else if (this.range && this.valueAsDate) { this.setRangeValue(this.valueAsDate); } if (this.min) { this.minAsDate = dateFromISO(this.min); } if (this.max) { this.maxAsDate = dateFromISO(this.max); } connectLabel(this); connectForm(this); connectOpenCloseComponent(this); connectMessages(this); this.setFilteredPlacements(); this.reposition(true); numberStringFormatter.numberFormatOptions = { numberingSystem: this.numberingSystem, locale: this.effectiveLocale, useGrouping: false }; } async componentWillLoad() { setUpLoadableComponent(this); await Promise.all([this.loadLocaleData(), setUpMessages(this)]); this.onMinChanged(this.min); this.onMaxChanged(this.max); } componentDidLoad() { setComponentLoaded(this); this.localizeInputValues(); this.reposition(true); } disconnectedCallback() { deactivateFocusTrap(this); disconnectInteractive(this); disconnectLabel(this); disconnectForm(this); disconnectFloatingUI(this, this.referenceEl, this.floatingEl); disconnectOpenCloseComponent(this); disconnectLocalized(this); disconnectMessages(this); } componentDidRender() { updateHostInteraction(this); } render() { const { disabled, effectiveLocale, messages, numberingSystem, readOnly } = this; numberStringFormatter.numberFormatOptions = { numberingSystem, locale: effectiveLocale, useGrouping: false }; return (h(Host, { onBlur: this.deactivate, onKeyDown: this.keyDownHandler }, this.localeData && (h("div", { class: "input-container" }, h("div", { class: "input-wrapper", onClick: this.onInputWrapperClick, // eslint-disable-next-line react/jsx-sort-props ref: this.setStartWrapper }, h("calcite-input", { "aria-autocomplete": "none", "aria-controls": this.dialogId, "aria-expanded": toAriaBoolean(this.open), "aria-haspopup": "dialog", class: `input ${this.layout === "vertical" && this.range ? `no-bottom-border` : ``}`, disabled: disabled, icon: "calendar", "number-button-type": "none", numberingSystem: numberingSystem, onCalciteInputInput: this.calciteInternalInputInputHandler, onCalciteInternalInputBlur: this.calciteInternalInputBlurHandler, onCalciteInternalInputFocus: this.startInputFocus, onFocus: this.startEndInputFocus, placeholder: this.localeData?.placeholder, readOnly: readOnly, role: "combobox", scale: this.scale, type: "text", // eslint-disable-next-line react/jsx-sort-props ref: this.setStartInput }), this.renderToggleIcon(this.open && this.focusedInput === "start")), h("div", { "aria-hidden": toAriaBoolean(!this.open), "aria-label": messages.chooseDate, "aria-live": "polite", "aria-modal": "true", class: { [CSS.menu]: true, [CSS.menuActive]: this.open }, id: this.dialogId, role: "dialog", // eslint-disable-next-line react/jsx-sort-props ref: this.setFloatingEl }, h("div", { class: { ["calendar-picker-wrapper"]: true, ["calendar-picker-wrapper--end"]: this.focusedInput === "end", [FloatingCSS.animation]: true, [FloatingCSS.animationActive]: this.open }, // eslint-disable-next-line react/jsx-sort-props ref: this.setTransitionEl }, h("calcite-date-picker", { activeDate: this.datePickerActiveDate, activeRange: this.focusedInput, headingLevel: this.headingLevel, max: this.max, maxAsDate: this.maxAsDate, messageOverrides: this.messageOverrides, min: this.min, minAsDate: this.minAsDate, numberingSystem: numberingSystem, onCalciteDatePickerChange: this.handleDateChange, onCalciteDatePickerRangeChange: this.handleDateRangeChange, proximitySelectionDisabled: this.proximitySelectionDisabled, range: this.range, scale: this.scale, tabIndex: this.open ? undefined : -1, valueAsDate: this.valueAsDate, // eslint-disable-next-line react/jsx-sort-props ref: this.setDatePickerRef }))), this.range && this.layout === "horizontal" && (h("div", { class: "horizontal-arrow-container" }, h("calcite-icon", { flipRtl: true, icon: "arrow-right", scale: this.scale === "l" ? "m" : "s" }))), this.range && this.layout === "vertical" && this.scale !== "s" && (h("div", { class: "vertical-arrow-container" }, h("calcite-icon", { icon: "arrow-down", scale: this.scale === "l" ? "m" : "s" }))), this.range && (h("div", { class: "input-wrapper", onClick: this.onInputWrapperClick, // eslint-disable-next-line react/jsx-sort-props ref: this.setEndWrapper }, h("calcite-input", { "aria-autocomplete": "none", "aria-controls": this.dialogId, "aria-expanded": toAriaBoolean(this.open), "aria-haspopup": "dialog", class: { input: true, "border-top-color-one": this.layout === "vertical" && this.range }, disabled: disabled, icon: "calendar", "number-button-type": "none", numberingSystem: numberingSystem, onCalciteInputInput: this.calciteInternalInputInputHandler, onCalciteInternalInputBlur: this.calciteInternalInputBlurHandler, onCalciteInternalInputFocus: this.endInputFocus, onFocus: this.startEndInputFocus, placeholder: this.localeData?.placeholder, readOnly: readOnly, role: "combobox", scale: this.scale, type: "text", // eslint-disable-next-line react/jsx-sort-props ref: this.setEndInput }), this.renderToggleIcon(this.open && this.focusedInput === "end"))))), h(HiddenFormInputSlot, { component: this }))); } renderToggleIcon(open) { return (h("span", { class: CSS.toggleIcon }, h("calcite-icon", { icon: open ? "chevron-up" : "chevron-down", scale: "s" }))); } setReferenceEl() { const { focusedInput, layout, endWrapper, startWrapper } = this; this.referenceEl = focusedInput === "end" || layout === "vertical" ? endWrapper || startWrapper : startWrapper || endWrapper; requestAnimationFrame(() => connectFloatingUI(this, this.referenceEl, this.floatingEl)); } onLabelClick() { this.setFocus(); } onBeforeOpen() { this.calciteInputDatePickerBeforeOpen.emit(); } onOpen() { activateFocusTrap(this, { onActivate: () => { if (this.focusOnOpen) { this.datePickerEl.setFocus(); this.focusOnOpen = false; } } }); this.calciteInputDatePickerOpen.emit(); } onBeforeClose() { this.calciteInputDatePickerBeforeClose.emit(); } onClose() { this.calciteInputDatePickerClose.emit(); deactivateFocusTrap(this); this.restoreInputFocus(); this.focusOnOpen = false; } commitValue() { const { focusedInput, value } = this; const focusedInputName = `${focusedInput}Input`; const focusedInputValue = this[focusedInputName].value; const date = dateFromLocalizedString(focusedInputValue, this.localeData); const dateAsISO = dateToISO(date); const valueIsArray = Array.isArray(value); if (this.range) { const focusedInputValueIndex = focusedInput === "start" ? 0 : 1; if (valueIsArray) { if (dateAsISO === value[focusedInputValueIndex]) { return; } if (date) { this.setRangeValue([ focusedInput === "start" ? date : dateFromISO(value[0]), focusedInput === "end" ? date : dateFromISO(value[1]) ]); this.localizeInputValues(); } else { this.setRangeValue([ focusedInput === "end" && dateFromISO(value[0]), focusedInput === "start" && dateFromISO(value[1]) ]); } } else { if (date) { this.setRangeValue([ focusedInput === "start" ? date : dateFromISO(value[0]), focusedInput === "end" ? date : dateFromISO(value[1]) ]); this.localizeInputValues(); } } } else { if (dateAsISO === value) { return; } this.setValue(date); this.localizeInputValues(); } } async loadLocaleData() { if (!Build.isBrowser) { return; } numberStringFormatter.numberFormatOptions = { numberingSystem: this.numberingSystem, locale: this.effectiveLocale, useGrouping: false }; this.localeData = await getLocaleData(this.effectiveLocale); this.localizeInputValues(); } shouldFocusRangeStart() { const startValue = this.value[0]; const endValue = this.value[1]; return !!(endValue && !startValue && this.focusedInput === "end" && this.startInput); } shouldFocusRangeEnd() { const startValue = this.value[0]; const endValue = this.value[1]; return !!(startValue && !endValue && this.focusedInput === "start" && this.endInput); } restoreInputFocus() { if (!this.range) { this.startInput.setFocus(); return; } const focusedInput = this.focusedInput === "start" ? this.startInput : this.endInput; focusedInput.setFocus(); } localizeInputValues() { const date = dateFromRange((this.range ? (Array.isArray(this.valueAsDate) && this.valueAsDate[0]) || undefined : this.valueAsDate), this.minAsDate, this.maxAsDate); const endDate = this.range ? dateFromRange((Array.isArray(this.valueAsDate) && this.valueAsDate[1]) || undefined, this.minAsDate, this.maxAsDate) : null; const localizedDate = date && this.formatNumerals(date.toLocaleDateString(this.effectiveLocale)); const localizedEndDate = endDate && this.formatNumerals(endDate.toLocaleDateString(this.effectiveLocale)); this.setInputValue(localizedDate ?? "", "start"); this.setInputValue((this.range && localizedEndDate) ?? "", "end"); } warnAboutInvalidValue(value) { console.warn(`The specified value "${value}" does not conform to the required format, "YYYY-MM-DD".`); } static get is() { return "calcite-input-date-picker"; } static get encapsulation() { return "shadow"; } static get delegatesFocus() { return true; } static get originalStyleUrls() { return { "$": ["input-date-picker.scss"] }; } static get styleUrls() { return { "$": ["input-date-picker.css"] }; } static get assetsDirs() { return ["assets"]; } static get properties() { return { "disabled": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, interaction is prevented and the component is displayed with lower opacity." }, "attribute": "disabled", "reflect": true, "defaultValue": "false" }, "focusTrapDisabled": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, prevents focus trapping." }, "attribute": "focus-trap-disabled", "reflect": true, "defaultValue": "false" }, "form": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "The ID of the form that will be associated with the component.\n\nWhen not set, the component will be associated with its ancestor form element, if any." }, "attribute": "form", "reflect": true }, "readOnly": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "mdn", "text": "[readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)" }], "text": "When `true`, the component's value can be read, but controls are not accessible and the value cannot be modified." }, "attribute": "read-only", "reflect": true, "defaultValue": "false" }, "value": { "type": "string", "mutable": true, "complexType": { "original": "string | string[]", "resolved": "string | string[]", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Selected date as a string in ISO format (YYYY-MM-DD)" }, "attribute": "value", "reflect": false, "defaultValue": "\"\"" }, "flipPlacements": { "type": "unknown", "mutable": false, "complexType": { "original": "EffectivePlacement[]", "resolved": "Placement[]", "references": { "EffectivePlacement": { "location": "import", "path": "../../utils/floating-ui" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Defines the available placements that can be used when a flip occurs." } }, "headingLevel": { "type": "number", "mutable": false, "complexType": { "original": "HeadingLevel", "resolved": "1 | 2 | 3 | 4 | 5 | 6", "references": { "HeadingLevel": { "location": "import", "path": "../functional/Heading" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the number at which section headings should start." }, "attribute": "heading-level", "reflect": true }, "valueAsDate": { "type": "unknown", "mutable": true, "complexType": { "original": "Date | Date[]", "resolved": "Date | Date[]", "references": { "Date": { "location": "global" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "The component's value as a full date object." } }, "messageOverrides": { "type": "unknown", "mutable": true, "complexType": { "original": "Partial<InputDatePickerMessages & DatePickerMessages>", "resolved": "{ chooseDate?: string; nextMonth?: string; prevMonth?: string; year?: string; }", "references": { "Partial": { "location": "global" }, "InputDatePickerMessages": { "location": "import", "path": "./assets/input-date-picker/t9n" }, "DatePickerMessages": { "location": "import", "path": "../date-picker/assets/date-picker/t9n" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Use this property to override individual strings used by the component." } }, "messages": { "type": "unknown", "mutable": true, "complexType": { "original": "InputDatePickerMessages", "resolved": "{ chooseDate: string; }", "references": { "InputDatePickerMessages": { "location": "import", "path": "./assets/input-date-picker/t9n" } } }, "required": false, "optional": false, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "Made into a prop for testing purposes only" } }, "minAsDate": { "type": "unknown", "mutable": true, "complexType": { "original": "Date", "resolved": "Date", "references": { "Date": { "location": "global" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the earliest allowed date as a full date object." } }, "maxAsDate": { "type": "unknown", "mutable": true, "complexType": { "original": "Date", "resolved": "Date", "references": { "Date": { "location": "global" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the latest allowed date as a full date object." } }, "min": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the earliest allowed date (\"yyyy-mm-dd\")." }, "attribute": "min", "reflect": false }, "max": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the latest allowed date (\"yyyy-mm-dd\")." }, "attribute": "max", "reflect": false }, "open": { "type": "boolean", "mutable": true, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, displays the `calcite-date-picker` component." }, "attribute": "open", "reflect": true, "defaultValue": "false" }, "name": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the name of the component.\n\nRequired to pass the component's `value` on form submission." }, "attribute": "name", "reflect": true }, "numberingSystem": { "type": "string", "mutable": false, "complexType": { "original": "NumberingSystem", "resolved": "\"arab\" | \"arabext\" | \"bali\" | \"beng\" | \"deva\" | \"fullwide\" | \"gujr\" | \"guru\" | \"hanidec\" | \"khmr\" | \"knda\" | \"laoo\" | \"latn\" | \"limb\" | \"mlym\" | \"mong\" | \"mymr\" | \"orya\" | \"tamldec\" | \"telu\" | \"thai\" | \"tibt\"", "references": { "NumberingSystem": { "location": "import", "path": "../../utils/locale" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the Unicode numeral system used by the component for localization. This property cannot be dynamically changed." }, "attribute": "numbering-system", "reflect": true }, "scale": { "type": "string", "mutable": false, "complexType": { "original": "\"s\" | \"m\" | \"l\"", "resolved": "\"l\" | \"m\" | \"s\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Specifies the size of the component." }, "attribute": "scale", "reflect": true, "defaultValue": "\"m\"" }, "placement": { "type": "string", "mutable": false, "complexType": { "original": "MenuPlacement", "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"top\" | \"top-end\" | \"top-start\"", "references": { "MenuPlacement": { "location": "import", "path": "../../utils/floating-ui" } } }, "required": false, "optional": false, "docs": { "tags": [{ "name": "default", "text": "\"bottom-start\"" }], "text": "Specifies the placement of the `calcite-date-picker` relative to the component." }, "attribute": "placement", "reflect": true, "defaultValue": "defaultMenuPlacement" }, "range": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, activates a range for the component." }, "attribute": "range", "reflect": true, "defaultValue": "false" }, "required": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "internal", "text": undefined }], "text": "When `true`, the component must have a value in order for the form to submit." }, "attribute": "required", "reflect": true, "defaultValue": "false" }, "overlayPositioning": { "type": "string", "mutable": false, "complexType": { "original": "OverlayPositioning", "resolved": "\"absolute\" | \"fixed\"", "references": { "OverlayPositioning": { "location": "import", "path": "../../utils/floating-ui" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "Determines the type of positioning to use for the overlaid content.\n\nUsing `\"absolute\"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.\n\n`\"fixed\"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `\"fixed\"`." }, "attribute": "overlay-positioning", "reflect": true, "defaultValue": "\"absolute\"" }, "proximitySelectionDisabled": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "When `true`, disables the default behavior on the third click of narrowing or extending the range.\nInstead starts a new range." }, "attribute": "proximity-selection-disabled", "reflect": false, "defaultValue": "false" }, "layout": { "type": "string", "mutable": false, "complexType": { "original": "\"horizontal\" | \"vertical\"", "resolved": "\"horizontal\" | \"vertical\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Defines the layout of the component." }, "attribute": "layout", "reflect": true, "defaultValue": "\"horizontal\"" } }; } static get states() { return { "datePickerActiveDate": {}, "defaultMessages": {}, "effectiveLocale": {}, "focusedInput": {}, "localeData": {} }; } static get events() { return [{ "method": "calciteInputDatePickerChange", "name": "calciteInputDatePickerChange", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [], "text": "Fires when the component's value changes." }, "complexType": { "original": "void", "resolved": "void", "references": {} } }, { "method": "calciteInputDatePickerBeforeClose", "name": "calciteInputDatePickerBeforeClose", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [], "text": "Fires when the component is requested to be closed and before the closing transition begins." }, "complexType": { "original": "void", "resolved": "void", "references": {} } }, { "method": "calciteInputDatePickerClose", "name": "calciteInputDatePickerClose", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [], "text": "Fires when the component is closed and animation is complete." }, "complexType": { "original": "void", "resolved": "void", "references": {} } }, { "method": "calciteInputDatePickerBeforeOpen", "name": "calciteInputDatePickerBeforeOpen", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [], "text": "Fires when the component is added to the DOM but not rendered, and before the opening transition begins." }, "complexType": { "original": "void", "resolved": "void", "references": {} } }, { "method": "calciteInputDatePickerOpen", "name": "calciteInputDatePickerOpen", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [], "text": "Fires when the component is open and animation is complete." }, "complexType": { "original": "void", "resolved": "void", "references": {} } }]; } static get methods() { return { "setFocus": { "complexType": { "signature": "() => Promise<void>", "parameters": [], "references": { "Promise": { "location": "global" } }, "return": "Promise<void>" }, "docs": { "text": "Sets focus on the component.", "tags": [] } }, "reposition": { "complexType": { "signature": "(delayed?: boolean) => Promise<void>", "parameters": [{ "tags": [{ "name": "param", "text": "delayed" }], "text": "" }], "references": { "Promise": { "location": "global" } }, "return": "Promise<void>" }, "docs": { "text": "Updates the position of the component.", "tags": [{ "name": "param", "text": "delayed" }] } } }; } static get elementRef() { return "el"; } static get watchers() { return [{ "propName": "focusTrapDisabled", "methodName": "handleFocusTrapDisabled" }, { "propName": "disabled", "methodName": "handleDisabledAndReadOnlyChange" }, { "propName": "readOnly", "methodName": "handleDisabledAndReadOnlyChange" }, { "propName": "value", "methodName": "valueWatcher" }, { "propName": "valueAsDate", "methodName": "valueAsDateWatcher" }, { "propName": "flipPlacements", "methodName": "flipPlacementsHandler" }, { "propName": "messageOverrides", "methodName": "onMessagesChange" }, { "propName": "min", "methodName": "onMinChanged" }, { "propName": "max", "methodName": "onMaxChanged" }, { "propName": "open", "methodName": "openHandler" }, { "propName": "overlayPositioning", "methodName": "overlayPositioningHandler" }, { "propName": "layout", "methodName": "setReferenceEl" }, { "propName": "focusedInput", "methodName": "setReferenceEl" }, { "propName": "effectiveLocale", "methodName": "loadLocaleData" }]; } static get listeners() { return [{ "name": "calciteDaySelect", "method": "calciteDaySelectHandler", "target": undefined, "capture": false, "passive": false }]; } }