/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.0.0-beta.97 */ import { h, Host, Build } from "@stencil/core"; import { getLocaleData, getValueAsDateRange } from "../date-picker/utils"; import { dateFromRange, inRange, dateFromISO, dateToISO, parseDateString, sameDate, setEndOfDay } from "../../utils/date"; import { TEXT } from "../date-picker/resources"; import { CSS } from "./resources"; import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label"; import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form"; import { FloatingCSS, connectFloatingUI, disconnectFloatingUI, defaultMenuPlacement, filterComputedPlacements, reposition, updateAfterClose } from "../../utils/floating-ui"; import { updateHostInteraction } from "../../utils/interactive"; import { toAriaBoolean } from "../../utils/dom"; import { connectOpenCloseComponent, disconnectOpenCloseComponent } from "../../utils/openCloseComponent"; import { connectLocalized, disconnectLocalized, numberStringFormatter } from "../../utils/locale"; import { numberKeys } from "../../utils/key"; export class InputDatePicker { constructor() { //-------------------------------------------------------------------------- // // Public Properties // //-------------------------------------------------------------------------- /** * When `true`, interaction is prevented and the component is displayed with lower opacity. */ this.disabled = false; /** * When `true`, the component's value can be read, but controls are not accessible and the value cannot be modified. * * @mdn [readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly) */ this.readOnly = false; /** * When `true`, the component is active. * * @deprecated use `open` instead. */ this.active = false; /** When `true`, displays the `calcite-date-picker` component. */ this.open = false; /** * Accessible name for the component's previous month button. * * @default "Previous month" */ this.intlPrevMonth = TEXT.prevMonth; /** * Accessible name for the component's next month button. * * @default "Next month" */ this.intlNextMonth = TEXT.nextMonth; /** * Accessible name for the component's year input. * * @default "Year" */ this.intlYear = TEXT.year; /** Specifies the size of the component. */ this.scale = "m"; /** * Specifies the placement of the `calcite-date-picker` relative to the component. * * @default "bottom-start" */ this.placement = defaultMenuPlacement; /** When `true`, activates a range for the component. */ this.range = false; /** * When `true`, the component must have a value in order for the form to submit. * * @internal */ this.required = false; /** * Determines the type of positioning to use for the overlaid content. * * Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout. * * `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`. * */ this.overlayPositioning = "absolute"; /** * When `true`, disables the default behavior on the third click of narrowing or extending the range. * Instead starts a new range. */ this.proximitySelectionDisabled = false; /** Defines the layout of the component. */ this.layout = "horizontal"; this.effectiveLocale = ""; this.focusedInput = "start"; this.globalAttributes = {}; this.openTransitionProp = "opacity"; //-------------------------------------------------------------------------- // // Private Methods // //-------------------------------------------------------------------------- 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.keyDownHandler = (event) => { const { defaultPrevented, key } = event; if (key === "Enter" && !defaultPrevented) { if (submitForm(this)) { event.preventDefault(); } } else if (key === "Escape" && !defaultPrevented) { this.active = false; this.open = false; event.preventDefault(); } }; this.inputBlur = (event) => { this.blur(event.currentTarget); }; this.startInputFocus = () => { if (!this.readOnly) { this.open = true; } this.focusedInput = "start"; }; this.endInputFocus = () => { if (!this.readOnly) { this.open = true; } this.focusedInput = "end"; }; this.startInputInput = () => { const parsedValue = this.parseNumerals(this.startInput.value); const formattedValue = this.formatNumerals(parsedValue); this.startInput.value = formattedValue; this.input(parsedValue); }; this.endInputInput = () => { const parsedValue = this.parseNumerals(this.endInput.value); const formattedValue = this.formatNumerals(parsedValue); this.endInput.value = formattedValue; this.input(parsedValue); }; this.setFloatingEl = (el) => { if (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(); }; /** * Event handler for when the selected date changes * * @param event */ this.handleDateChange = (event) => { if (this.range) { return; } this.value = dateToISO(event.detail); }; this.handleDateRangeChange = (event) => { var _a, _b; if (!this.range || !event.detail) { return; } const { startDate, endDate } = event.detail; this.start = dateToISO(startDate); this.end = dateToISO(endDate); this.value = [this.start, this.end]; if (this.shouldFocusRangeEnd()) { (_a = this.endInput) === null || _a === void 0 ? void 0 : _a.setFocus(); } else if (this.shouldFocusRangeStart()) { (_b = this.startInput) === null || _b === void 0 ? void 0 : _b.setFocus(); } }; this.commonDateSeparators = [".", "-", "/"]; this.formatNumerals = (value) => value ? value .split("") .map((char) => // convert common separators to the locale's 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("") : ""; } handleDisabledAndReadOnlyChange(value) { if (!value) { this.open = false; } } valueHandler(value) { if (Array.isArray(value)) { this.valueAsDate = getValueAsDateRange(value); this.start = value[0]; this.end = value[1]; } else if (value) { this.valueAsDate = dateFromISO(value); this.start = ""; this.end = ""; } else { this.valueAsDate = undefined; this.start = undefined; this.end = undefined; } } flipPlacementsHandler() { this.setFilteredPlacements(); this.reposition(true); } onMinChanged(min) { if (min) { this.minAsDate = dateFromISO(min); } } onMaxChanged(max) { if (max) { this.maxAsDate = dateFromISO(max); } } activeHandler(value) { this.open = value; } openHandler(value) { this.active = value; if (this.disabled || this.readOnly) { if (!value) { updateAfterClose(this.floatingEl); } this.open = false; return; } if (value) { this.reposition(true); } else { updateAfterClose(this.floatingEl); } } overlayPositioningHandler() { this.reposition(true); } //-------------------------------------------------------------------------- // // Event Listeners // //-------------------------------------------------------------------------- handleDateOrRangeChange() { this.calciteInputDatePickerChange.emit(); } calciteDaySelectHandler() { if (this.shouldFocusRangeStart() || this.shouldFocusRangeEnd()) { return; } this.open = false; } // -------------------------------------------------------------------------- // // Public Methods // // -------------------------------------------------------------------------- /** Sets focus on the component. */ async setFocus() { var _a; (_a = this.startInput) === null || _a === void 0 ? void 0 : _a.setFocus(); } /** * 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() { connectLocalized(this); const isOpen = this.active || this.open; isOpen && this.activeHandler(isOpen); isOpen && this.openHandler(isOpen); if (Array.isArray(this.value)) { this.valueAsDate = getValueAsDateRange(this.value); this.start = this.value[0]; this.end = this.value[1]; } else if (this.value) { this.valueAsDate = dateFromISO(this.value); this.start = ""; this.end = ""; } if (this.start) { this.startAsDate = dateFromISO(this.start); } if (this.end) { this.endAsDate = setEndOfDay(dateFromISO(this.end)); } if (this.min) { this.minAsDate = dateFromISO(this.min); } if (this.max) { this.maxAsDate = dateFromISO(this.max); } connectLabel(this); connectForm(this); connectOpenCloseComponent(this); this.setFilteredPlacements(); this.reposition(true); numberStringFormatter.numberFormatOptions = { numberingSystem: this.numberingSystem, locale: this.effectiveLocale, useGrouping: false }; } async componentWillLoad() { await this.loadLocaleData(); this.onMinChanged(this.min); this.onMaxChanged(this.max); } componentDidLoad() { this.reposition(true); } disconnectedCallback() { disconnectLabel(this); disconnectForm(this); disconnectFloatingUI(this, this.referenceEl, this.floatingEl); disconnectOpenCloseComponent(this); disconnectLocalized(this); } componentDidRender() { updateHostInteraction(this); } render() { var _a, _b; const { disabled, readOnly, numberingSystem, effectiveLocale } = this; numberStringFormatter.numberFormatOptions = { numberingSystem, locale: effectiveLocale, useGrouping: false }; const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate); const endDate = this.range ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate) : null; const formattedEndDate = endDate ? this.formatNumerals(endDate.toLocaleDateString(effectiveLocale)) : ""; const formattedDate = date ? this.formatNumerals(date.toLocaleDateString(effectiveLocale)) : ""; return (h(Host, { onBlur: this.deactivate, onKeyDown: this.keyDownHandler, role: "application" }, this.localeData && (h("div", { "aria-expanded": toAriaBoolean(this.open), class: "input-container", role: "application" }, h("div", { class: "input-wrapper", ref: this.setStartWrapper }, h("calcite-input", { class: `input ${this.layout === "vertical" && this.range ? `no-bottom-border` : ``}`, disabled: disabled, icon: "calendar", label: getLabelText(this), lang: effectiveLocale, "number-button-type": "none", numberingSystem: numberingSystem, onCalciteInputInput: this.startInputInput, onCalciteInternalInputBlur: this.inputBlur, onCalciteInternalInputFocus: this.startInputFocus, placeholder: (_a = this.localeData) === null || _a === void 0 ? void 0 : _a.placeholder, readOnly: readOnly, ref: this.setStartInput, scale: this.scale, type: "text", value: formattedDate })), h("div", { "aria-hidden": toAriaBoolean(!this.open), class: { [CSS.menu]: true, [CSS.menuActive]: this.open }, ref: this.setFloatingEl }, h("div", { class: { ["calendar-picker-wrapper"]: true, ["calendar-picker-wrapper--end"]: this.focusedInput === "end", [FloatingCSS.animation]: true, [FloatingCSS.animationActive]: this.open }, ref: this.setTransitionEl }, h("calcite-date-picker", { activeRange: this.focusedInput, endAsDate: this.endAsDate, headingLevel: this.headingLevel, intlNextMonth: this.intlNextMonth, intlPrevMonth: this.intlPrevMonth, intlYear: this.intlYear, lang: effectiveLocale, max: this.max, maxAsDate: this.maxAsDate, min: this.min, minAsDate: this.minAsDate, numberingSystem: numberingSystem, onCalciteDatePickerChange: this.handleDateChange, onCalciteDatePickerRangeChange: this.handleDateRangeChange, proximitySelectionDisabled: this.proximitySelectionDisabled, range: this.range, scale: this.scale, startAsDate: this.startAsDate, tabIndex: 0, valueAsDate: this.valueAsDate }))), this.range && this.layout === "horizontal" && (h("div", { class: "horizontal-arrow-container" }, h("calcite-icon", { flipRtl: true, icon: "arrow-right", scale: "s" }))), this.range && this.layout === "vertical" && this.scale !== "s" && (h("div", { class: "vertical-arrow-container" }, h("calcite-icon", { icon: "arrow-down", scale: "s" }))), this.range && (h("div", { class: "input-wrapper", ref: this.setEndWrapper }, h("calcite-input", { class: { input: true, "border-top-color-one": this.layout === "vertical" && this.range }, disabled: disabled, icon: "calendar", lang: effectiveLocale, "number-button-type": "none", numberingSystem: numberingSystem, onCalciteInputInput: this.endInputInput, onCalciteInternalInputBlur: this.inputBlur, onCalciteInternalInputFocus: this.endInputFocus, placeholder: (_b = this.localeData) === null || _b === void 0 ? void 0 : _b.placeholder, readOnly: readOnly, ref: this.setEndInput, scale: this.scale, type: "text", value: formattedEndDate }))))), h(HiddenFormInputSlot, { component: this }))); } setReferenceEl() { const { focusedInput, layout, endWrapper, startWrapper } = this; this.referenceEl = focusedInput === "end" || layout === "vertical" ? endWrapper || startWrapper : startWrapper || endWrapper; connectFloatingUI(this, this.referenceEl, this.floatingEl); } onLabelClick() { this.setFocus(); } onBeforeOpen() { this.calciteInputDatePickerBeforeOpen.emit(); } onOpen() { this.calciteInputDatePickerOpen.emit(); } onBeforeClose() { this.calciteInputDatePickerBeforeClose.emit(); } onClose() { this.calciteInputDatePickerClose.emit(); } startWatcher(start) { this.startAsDate = dateFromISO(start); } endWatcher(end) { this.endAsDate = end ? setEndOfDay(dateFromISO(end)) : dateFromISO(end); } async loadLocaleData() { if (!Build.isBrowser) { return; } this.localeData = await getLocaleData(this.effectiveLocale); } clearCurrentValue() { if (!this.range) { if (typeof this.value === "string" && this.value) { this.calciteDatePickerChange.emit(); } this.value = ""; return; } const { focusedInput } = this; if (focusedInput === "start") { if (this.start) { this.calciteDatePickerRangeChange.emit(); } this.value = Array.isArray(this.value) ? ["", this.value[1] || ""] : [""]; this.start = undefined; } else if (focusedInput === "end") { if (this.end) { this.calciteDatePickerRangeChange.emit(); } this.value = Array.isArray(this.value) ? [this.value[0] || "", ""] : ["", ""]; this.end = undefined; } } /** * If inputted string is a valid date, update value/active * * @param value */ input(value) { const date = this.getDateFromInput(value); if (!date) { this.clearCurrentValue(); return; } if (!this.range) { this.value = dateToISO(date); this.calciteDatePickerChange.emit(date); return; } const { focusedInput } = this; if (focusedInput === "start") { if (!this.startAsDate || !sameDate(date, this.startAsDate)) { const startDateISO = dateToISO(date); this.value = Array.isArray(this.value) ? [startDateISO, this.value[1] || ""] : [startDateISO]; this.start = startDateISO; this.calciteDatePickerRangeChange.emit({ startDate: date, endDate: this.endAsDate }); } } else if (focusedInput === "end") { if (!this.endAsDate || !sameDate(date, this.endAsDate)) { const endDateISO = dateToISO(date); this.value = Array.isArray(this.value) ? [this.value[0] || "", endDateISO] : ["", endDateISO]; this.end = endDateISO; this.calciteDatePickerRangeChange.emit({ startDate: this.startAsDate, endDate: setEndOfDay(date) }); } } } /** * Clean up invalid date from input on blur * * @param target */ blur(target) { const { focusedInput, endAsDate, range, startAsDate, valueAsDate } = this; const locale = this.effectiveLocale; const date = this.getDateFromInput(target.value); if (!date) { if (!range && valueAsDate) { target.value = this.formatNumerals(Array.isArray(valueAsDate) ? valueAsDate[focusedInput === "end" ? 1 : 0].toLocaleDateString(locale) : valueAsDate.toLocaleDateString(locale)); } else if (focusedInput === "start" && startAsDate) { target.value = this.formatNumerals(startAsDate.toLocaleDateString(locale)); } else if (focusedInput === "end" && endAsDate) { target.value = this.formatNumerals(endAsDate.toLocaleDateString(locale)); } } } shouldFocusRangeStart() { return !!(this.endAsDate && !this.startAsDate && this.focusedInput === "end" && this.startInput); } shouldFocusRangeEnd() { return !!(this.startAsDate && !this.endAsDate && this.focusedInput === "start" && this.endInput); } /** * Find a date from input string * return false if date is invalid, or out of range * * @param value */ getDateFromInput(value) { if (!this.localeData) { return false; } const { separator } = this.localeData; const { day, month, year } = parseDateString(value, this.localeData); const validDay = day > 0; const validMonth = month > -1; const date = new Date(year, month, day); date.setFullYear(year); const validDate = !isNaN(date.getTime()); const validLength = value.split(separator).filter((c) => c).length > 2; const validYear = year.toString().length > 0; if (validDay && validMonth && validDate && validLength && validYear && inRange(date, this.min, this.max)) { return date; } return false; } static get is() { return "calcite-input-date-picker"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["input-date-picker.scss"] }; } static get styleUrls() { return { "$": ["input-date-picker.css"] }; } 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" }, "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": "The component's value." }, "attribute": "value", "reflect": false }, "flipPlacements": { "type": "unknown", "mutable": false, "complexType": { "original": "EffectivePlacement[]", "resolved": "Placement[]", "references": { "EffectivePlacement": { "location": "import", "path": "../../utils/floating-ui" } } }, "required": false, "optional": true, "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": true, "docs": { "tags": [], "text": "The component's value as a full date object." } }, "startAsDate": { "type": "unknown", "mutable": true, "complexType": { "original": "Date", "resolved": "Date", "references": { "Date": { "location": "global" } } }, "required": false, "optional": true, "docs": { "tags": [{ "name": "deprecated", "text": "use `valueAsDate` instead." }], "text": "The component's start date as a full date object." } }, "endAsDate": { "type": "unknown", "mutable": true, "complexType": { "original": "Date", "resolved": "Date", "references": { "Date": { "location": "global" } } }, "required": false, "optional": true, "docs": { "tags": [{ "name": "deprecated", "text": "use `valueAsDate` instead." }], "text": "The component's end date as a full date object." } }, "minAsDate": { "type": "unknown", "mutable": true, "complexType": { "original": "Date", "resolved": "Date", "references": { "Date": { "location": "global" } } }, "required": false, "optional": true, "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": true, "docs": { "tags": [], "text": "Specifies the latest allowed date as a full date object." } }, "min": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Specifies the earliest allowed date (\"yyyy-mm-dd\")." }, "attribute": "min", "reflect": false }, "max": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Specifies the latest allowed date (\"yyyy-mm-dd\")." }, "attribute": "max", "reflect": false }, "active": { "type": "boolean", "mutable": true, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [{ "name": "deprecated", "text": "use `open` instead." }], "text": "When `true`, the component is active." }, "attribute": "active", "reflect": true, "defaultValue": "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 on form submission." }, "attribute": "name", "reflect": true }, "intlPrevMonth": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [{ "name": "default", "text": "\"Previous month\"" }], "text": "Accessible name for the component's previous month button." }, "attribute": "intl-prev-month", "reflect": false, "defaultValue": "TEXT.prevMonth" }, "intlNextMonth": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [{ "name": "default", "text": "\"Next month\"" }], "text": "Accessible name for the component's next month button." }, "attribute": "intl-next-month", "reflect": false, "defaultValue": "TEXT.nextMonth" }, "intlYear": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [{ "name": "default", "text": "\"Year\"" }], "text": "Accessible name for the component's year input." }, "attribute": "intl-year", "reflect": false, "defaultValue": "TEXT.year" }, "locale": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [{ "name": "deprecated", "text": "set the global `lang` attribute on the element instead." }, { "name": "mdn", "text": "[lang](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)" }], "text": "Specifies the BCP 47 language tag for the desired language and country format." }, "attribute": "locale", "reflect": false }, "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": true, "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-leading\" | \"bottom-start\" | \"bottom-trailing\" | \"top\" | \"top-end\" | \"top-leading\" | \"top-start\" | \"top-trailing\"", "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" }, "start": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [{ "name": "deprecated", "text": "use `value` instead." }], "text": "The component's start date." }, "attribute": "start", "reflect": true }, "end": { "type": "string", "mutable": true, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": true, "docs": { "tags": [{ "name": "deprecated", "text": "use `value` instead." }], "text": "The component's end date." }, "attribute": "end", "reflect": true }, "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 { "effectiveLocale": {}, "focusedInput": {}, "globalAttributes": {}, "localeData": {} }; } static get events() { return [{ "method": "calciteDatePickerChange", "name": "calciteDatePickerChange", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [{ "name": "deprecated", "text": "use `calciteInputDatePickerChange` instead." }], "text": "Fires when a user changes the date." }, "complexType": { "original": "Date", "resolved": "Date", "references": { "Date": { "location": "global" } } } }, { "method": "calciteDatePickerRangeChange", "name": "calciteDatePickerRangeChange", "bubbles": true, "cancelable": false, "composed": true, "docs": { "tags": [{ "name": "see", "text": "[DateRangeChange](https://github.com/Esri/calcite-components/blob/master/src/components/date-picker/interfaces.ts#L1)" }, { "name": "deprecated", "text": "use `calciteInputDatePickerChange` instead." }], "text": "Fires when a user changes the date range." }, "complexType": { "original": "DateRangeChange", "resolved": "DateRangeChange", "references": { "DateRangeChange": { "location": "import", "path": "../date-picker/interfaces" } } } }, { "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", "parameters": [], "references": { "Promise": { "location": "global" } }, "return": "Promise" }, "docs": { "text": "Sets focus on the component.", "tags": [] } }, "reposition": { "complexType": { "signature": "(delayed?: boolean) => Promise", "parameters": [{ "tags": [{ "name": "param", "text": "delayed" }], "text": "" }], "references": { "Promise": { "location": "global" } }, "return": "Promise" }, "docs": { "text": "Updates the position of the component.", "tags": [{ "name": "param", "text": "delayed" }] } } }; } static get elementRef() { return "el"; } static get watchers() { return [{ "propName": "disabled", "methodName": "handleDisabledAndReadOnlyChange" }, { "propName": "readOnly", "methodName": "handleDisabledAndReadOnlyChange" }, { "propName": "value", "methodName": "valueHandler" }, { "propName": "flipPlacements", "methodName": "flipPlacementsHandler" }, { "propName": "min", "methodName": "onMinChanged" }, { "propName": "max", "methodName": "onMaxChanged" }, { "propName": "active", "methodName": "activeHandler" }, { "propName": "open", "methodName": "openHandler" }, { "propName": "overlayPositioning", "methodName": "overlayPositioningHandler" }, { "propName": "layout", "methodName": "setReferenceEl" }, { "propName": "focusedInput", "methodName": "setReferenceEl" }, { "propName": "start", "methodName": "startWatcher" }, { "propName": "end", "methodName": "endWatcher" }, { "propName": "effectiveLocale", "methodName": "loadLocaleData" }]; } static get listeners() { return [{ "name": "calciteDatePickerChange", "method": "handleDateOrRangeChange", "target": undefined, "capture": false, "passive": false }, { "name": "calciteDatePickerRangeChange", "method": "handleDateOrRangeChange", "target": undefined, "capture": false, "passive": false }, { "name": "calciteDaySelect", "method": "calciteDaySelectHandler", "target": undefined, "capture": false, "passive": false }]; } }