123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- /*!
- * 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.82
- */
- import { Component, Element, Prop, Host, Event, Listen, h } from "@stencil/core";
- import { getElementDir } from "../../utils/dom";
- import { CSS_UTILITY } from "../../utils/resources";
- import { updateHostInteraction } from "../../utils/interactive";
- export class DatePickerDay {
- constructor() {
- /** Date is outside of range and can't be selected */
- this.disabled = false;
- /** Date is in the current month. */
- this.currentMonth = false;
- /** Date is the current selected date of the picker */
- this.selected = false;
- /** Date is currently highlighted as part of the range */
- this.highlighted = false;
- /** Showing date range */
- this.range = false;
- /** Date is the start of date range */
- this.startOfRange = false;
- /** Date is the end of date range */
- this.endOfRange = false;
- /** Date is being hovered and within the set range */
- this.rangeHover = false;
- /** Date is actively in focus for keyboard navigation */
- this.active = false;
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.onClick = () => {
- !this.disabled && this.calciteDaySelect.emit();
- };
- this.keyDownHandler = (e) => {
- const key = e.key;
- if (key === " " || key === "Enter") {
- !this.disabled && this.calciteDaySelect.emit();
- }
- };
- }
- mouseoverHandler() {
- this.calciteDayHover.emit({
- disabled: this.disabled
- });
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- render() {
- const formattedDay = String(this.day)
- .split("")
- .map((i) => this.localeData.numerals[i])
- .join("");
- const dir = getElementDir(this.el);
- return (h(Host, { onClick: this.onClick, onKeyDown: this.keyDownHandler, role: "gridcell" },
- h("div", { class: { "day-v-wrapper": true, [CSS_UTILITY.rtl]: dir === "rtl" } },
- h("div", { class: "day-wrapper" },
- h("span", { class: "day" },
- h("span", { class: "text" }, formattedDay))))));
- }
- componentDidRender() {
- updateHostInteraction(this, this.isTabbable);
- }
- isTabbable() {
- return this.active;
- }
- static get is() { return "calcite-date-picker-day"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() { return {
- "$": ["date-picker-day.scss"]
- }; }
- static get styleUrls() { return {
- "$": ["date-picker-day.css"]
- }; }
- static get properties() { return {
- "day": {
- "type": "number",
- "mutable": false,
- "complexType": {
- "original": "number",
- "resolved": "number",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Day of the month to be shown."
- },
- "attribute": "day",
- "reflect": false
- },
- "disabled": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is outside of range and can't be selected"
- },
- "attribute": "disabled",
- "reflect": true,
- "defaultValue": "false"
- },
- "currentMonth": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is in the current month."
- },
- "attribute": "current-month",
- "reflect": true,
- "defaultValue": "false"
- },
- "selected": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is the current selected date of the picker"
- },
- "attribute": "selected",
- "reflect": true,
- "defaultValue": "false"
- },
- "highlighted": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is currently highlighted as part of the range"
- },
- "attribute": "highlighted",
- "reflect": true,
- "defaultValue": "false"
- },
- "range": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Showing date range"
- },
- "attribute": "range",
- "reflect": true,
- "defaultValue": "false"
- },
- "startOfRange": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is the start of date range"
- },
- "attribute": "start-of-range",
- "reflect": true,
- "defaultValue": "false"
- },
- "endOfRange": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is the end of date range"
- },
- "attribute": "end-of-range",
- "reflect": true,
- "defaultValue": "false"
- },
- "rangeHover": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is being hovered and within the set range"
- },
- "attribute": "range-hover",
- "reflect": true,
- "defaultValue": "false"
- },
- "active": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date is actively in focus for keyboard navigation"
- },
- "attribute": "active",
- "reflect": true,
- "defaultValue": "false"
- },
- "localeData": {
- "type": "unknown",
- "mutable": false,
- "complexType": {
- "original": "DateLocaleData",
- "resolved": "DateLocaleData",
- "references": {
- "DateLocaleData": {
- "location": "import",
- "path": "../date-picker/utils"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "CLDR data for current locale"
- }
- },
- "scale": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Scale",
- "resolved": "\"l\" | \"m\" | \"s\"",
- "references": {
- "Scale": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "specify the scale of the date picker"
- },
- "attribute": "scale",
- "reflect": true
- },
- "value": {
- "type": "unknown",
- "mutable": false,
- "complexType": {
- "original": "Date",
- "resolved": "Date",
- "references": {
- "Date": {
- "location": "global"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Date value for the day."
- }
- }
- }; }
- static get events() { return [{
- "method": "calciteDaySelect",
- "name": "calciteDaySelect",
- "bubbles": true,
- "cancelable": true,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Emitted when user selects day"
- },
- "complexType": {
- "original": "any",
- "resolved": "any",
- "references": {}
- }
- }, {
- "method": "calciteDayHover",
- "name": "calciteDayHover",
- "bubbles": true,
- "cancelable": true,
- "composed": true,
- "docs": {
- "tags": [{
- "name": "internal",
- "text": undefined
- }],
- "text": "Emitted when user hovers over a day"
- },
- "complexType": {
- "original": "any",
- "resolved": "any",
- "references": {}
- }
- }]; }
- static get elementRef() { return "el"; }
- static get listeners() { return [{
- "name": "mouseover",
- "method": "mouseoverHandler",
- "target": undefined,
- "capture": false,
- "passive": true
- }]; }
- }
|