All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.MonthPicker.js.map Maven / Gradle / Ivy

The newest version!
{"version":3,"file":"MonthPicker.js","sourceRoot":"","sources":["../src/MonthPicker.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,KAAK,MAAM,kDAAkD,CAAC;AACrE,OAAO,2BAA2B,MAAM,qEAAqE,CAAC;AAC9G,OAAO,+BAA+B,MAAM,+EAA+E,CAAC;AAC5H,OAAO,4BAA4B,MAAM,4EAA4E,CAAC;AACtH,OAAO,YAAY,MAAM,4DAA4D,CAAC;AACtF,OAAO,YAAY,MAAM,oDAAoD,CAAC;AAC9E,OAAO,EACN,OAAO,EACP,OAAO,EACP,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,QAAQ,EACR,UAAU,GACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,SAAS,MAAM,kDAAkD,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAE3E,OAAO,EACN,wBAAwB,GACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAG7C,WAAW;AACX,OAAO,mBAAmB,MAAM,kDAAkD,CAAC;AAEnF,SAAS;AACT,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AAEtE,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,gCAAgC;AAyBtD;;;;;;;;GAQG;AAiBH,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,YAAY;IAAtC;;QACC;;;;;WAKG;QAEH,kBAAa,GAAkB,EAAE,CAAC;QAGlC,YAAO,GAAkB,EAAE,CAAC;QAG5B,YAAO,GAAG,KAAK,CAAC;IAsOjB,CAAC;IAlOA,MAAM,CAAC,KAAK,CAAC,QAAQ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,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEpC,OAAO,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG,QAAQ,CAAC,CAAC;IAC7H,CAAC;CACD,CAAA;AA5OA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDACQ;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CACE;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;4CAC/B;AAdX,WAAW;IAhBhB,aAAa,CAAC;QACd,GAAG,EAAE,iBAAiB;QACtB,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,iBAAiB;KACzB,CAAC;IACF;;;OAGG;;IACD,KAAK,CAAC,QAAQ,CAAC;IACjB;;;;OAIG;;IACF,KAAK,CAAC,UAAU,CAAC;GACZ,WAAW,CAoPhB;AAED,WAAW,CAAC,MAAM,EAAE,CAAC;AAErB,eAAe,WAAW,CAAC","sourcesContent":["import customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event.js\";\nimport getCachedLocaleDataInstance from \"@ui5/webcomponents-localization/dist/getCachedLocaleDataInstance.js\";\nimport convertMonthNumbersToMonthNames from \"@ui5/webcomponents-localization/dist/dates/convertMonthNumbersToMonthNames.js\";\nimport transformDateToSecondaryType from \"@ui5/webcomponents-localization/dist/dates/transformDateToSecondaryType.js\";\nimport CalendarDate from \"@ui5/webcomponents-localization/dist/dates/CalendarDate.js\";\nimport CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.js\";\nimport {\n\tisEnter,\n\tisSpace,\n\tisDown,\n\tisUp,\n\tisLeft,\n\tisRight,\n\tisHome,\n\tisEnd,\n\tisHomeCtrl,\n\tisEndCtrl,\n\tisPageUp,\n\tisPageDown,\n} from \"@ui5/webcomponents-base/dist/Keys.js\";\nimport getLocale from \"@ui5/webcomponents-base/dist/locale/getLocale.js\";\nimport { getI18nBundle } from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport type I18nBundle from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport {\n\tMONTH_PICKER_DESCRIPTION,\n} from \"./generated/i18n/i18n-defaults.js\";\nimport CalendarPart from \"./CalendarPart.js\";\nimport type { ICalendarPicker } from \"./Calendar.js\";\n\n// Template\nimport MonthPickerTemplate from \"./generated/templates/MonthPickerTemplate.lit.js\";\n\n// Styles\nimport monthPickerStyles from \"./generated/themes/MonthPicker.css.js\";\n\nconst PAGE_SIZE = 12; // total months on a single page\n\ntype Month = {\n\ttimestamp: string,\n\tfocusRef: boolean,\n\t_tabIndex: string,\n\tselected: boolean,\n\tariaSelected: string,\n\tname: string,\n\tnameInSecType: string,\n\tdisabled: boolean,\n\tclasses: string,\n\tparts: string,\n}\n\ntype MonthInterval = Array>;\n\ntype MonthPickerChangeEventDetail = {\n\ttimestamp: number,\n}\n\ntype MonthPickerNavigateEventDetail = {\n\ttimestamp: number,\n}\n\n/**\n * Month picker component.\n * @class\n *\n * Displays months which can be selected.\n * @constructor\n * @extends CalendarPart\n * @private\n */\n@customElement({\n\ttag: \"ui5-monthpicker\",\n\ttemplate: MonthPickerTemplate,\n\tstyles: monthPickerStyles,\n})\n/**\n * Fired when the user selects a month via \"Space\", \"Enter\" or click.\n * @public\n */\n @event(\"change\")\n/**\n * Fired when the timestamp changes - the user navigates with the keyboard or clicks with the mouse.\n * @since 1.0.0-rc.9\n * @public\n */\n@event(\"navigate\")\nclass MonthPicker extends CalendarPart implements ICalendarPicker {\n\t/**\n\t * An array of UTC timestamps representing the selected date\n\t * or dates depending on the capabilities of the picker component.\n\t * @public\n\t * @default []\n\t */\n\t@property({ type: Array })\n\tselectedDates: Array = [];\n\n\t@property({ type: Array })\n\t_months: MonthInterval = [];\n\n\t@property({ type: Boolean, noAttribute: true })\n\t_hidden = false;\n\n\tstatic i18nBundle: I18nBundle;\n\n\tstatic async onDefine() {\n\t\tMonthPicker.i18nBundle = await getI18nBundle(\"@ui5/webcomponents\");\n\t}\n\n\tget roleDescription() {\n\t\treturn MonthPicker.i18nBundle.getText(MONTH_PICKER_DESCRIPTION);\n\t}\n\n\tonBeforeRendering() {\n\t\tthis._buildMonths();\n\t}\n\n\tonAfterRendering() {\n\t\tif (!this._hidden) {\n\t\t\tthis.focus();\n\t\t}\n\t}\n\n\tget rowSize() {\n\t\treturn (this.secondaryCalendarType === CalendarType.Islamic && this.primaryCalendarType !== CalendarType.Islamic)\n\t\t\t|| (this.secondaryCalendarType === CalendarType.Persian && this.primaryCalendarType !== CalendarType.Persian) ? 2 : 3;\n\t}\n\n\t_buildMonths() {\n\t\tif (this._hidden) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst localeData = getCachedLocaleDataInstance(getLocale());\n\t\tconst monthsNames = localeData.getMonthsStandAlone(\"wide\", this._primaryCalendarType);\n\n\t\tconst months: MonthInterval = [];\n\t\tconst calendarDate = this._calendarDate; // store the value of the expensive getter\n\t\tconst minDate = this._minDate; // store the value of the expensive getter\n\t\tconst maxDate = this._maxDate; // store the value of the expensive getter\n\t\tconst tempDate = new CalendarDate(calendarDate, this._primaryCalendarType);\n\t\tlet timestamp;\n\n\t\t/* eslint-disable no-loop-func */\n\t\tfor (let i = 0; i < 12; i++) {\n\t\t\ttempDate.setMonth(i);\n\t\t\ttimestamp = tempDate.valueOf() / 1000;\n\n\t\t\tconst isSelected = this.selectedDates.some(itemTimestamp => {\n\t\t\t\tconst date = CalendarDate.fromTimestamp(itemTimestamp * 1000, this._primaryCalendarType);\n\t\t\t\treturn date.getYear() === tempDate.getYear() && date.getMonth() === tempDate.getMonth();\n\t\t\t});\n\t\t\tconst isFocused = tempDate.getMonth() === calendarDate.getMonth();\n\t\t\tconst isDisabled = this._isOutOfSelectableRange(tempDate, minDate, maxDate);\n\n\t\t\tconst month: Month = {\n\t\t\t\ttimestamp: timestamp.toString(),\n\t\t\t\tfocusRef: isFocused,\n\t\t\t\t_tabIndex: isFocused ? \"0\" : \"-1\",\n\t\t\t\tselected: isSelected,\n\t\t\t\tariaSelected: isSelected ? \"true\" : \"false\",\n\t\t\t\tname: monthsNames[i],\n\t\t\t\tnameInSecType: this.hasSecondaryCalendarType && this._getDisplayedSecondaryMonthText(timestamp).text,\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tclasses: \"ui5-mp-item\",\n\t\t\t\tparts: \"month-cell\",\n\t\t\t};\n\n\t\t\tif (isSelected) {\n\t\t\t\tmonth.classes += \" ui5-mp-item--selected\";\n\t\t\t\tmonth.parts += \" month-cell-selected\";\n\t\t\t}\n\n\t\t\tif (isDisabled) {\n\t\t\t\tmonth.classes += \" ui5-mp-item--disabled\";\n\t\t\t}\n\n\t\t\tconst quarterIndex = Math.floor(i / this.rowSize);\n\n\t\t\tif (months[quarterIndex]) {\n\t\t\t\tmonths[quarterIndex].push(month);\n\t\t\t} else {\n\t\t\t\tmonths[quarterIndex] = [month];\n\t\t\t}\n\t\t}\n\n\t\tthis._months = months;\n\t}\n\n\t_getDisplayedSecondaryMonthText(timestamp: number) {\n\t\tconst monthsName = transformDateToSecondaryType(this._primaryCalendarType, this.secondaryCalendarType, timestamp);\n\t\treturn convertMonthNumbersToMonthNames(monthsName.firstDate.getMonth(), monthsName.lastDate.getMonth(), this.secondaryCalendarType);\n\t}\n\n\t_onkeydown(e: KeyboardEvent) {\n\t\tlet preventDefault = true;\n\n\t\tif (isEnter(e)) {\n\t\t\tthis._selectMonth(e);\n\t\t} else if (isSpace(e)) {\n\t\t\te.preventDefault();\n\t\t} else if (isLeft(e)) {\n\t\t\tthis._modifyTimestampBy(-1);\n\t\t} else if (isRight(e)) {\n\t\t\tthis._modifyTimestampBy(1);\n\t\t} else if (isUp(e)) {\n\t\t\tthis._modifyTimestampBy(-this.rowSize);\n\t\t} else if (isDown(e)) {\n\t\t\tthis._modifyTimestampBy(this.rowSize);\n\t\t} else if (isPageUp(e)) {\n\t\t\tthis._modifyTimestampBy(-PAGE_SIZE);\n\t\t} else if (isPageDown(e)) {\n\t\t\tthis._modifyTimestampBy(PAGE_SIZE);\n\t\t} else if (isHome(e) || isEnd(e)) {\n\t\t\tthis._onHomeOrEnd(isHome(e));\n\t\t} else if (isHomeCtrl(e)) {\n\t\t\tthis._setTimestamp(parseInt(this._months[0][0].timestamp)); // first month of first row\n\t\t} else if (isEndCtrl(e)) {\n\t\t\tthis._setTimestamp(parseInt(this._months[PAGE_SIZE / this.rowSize - 1][this.rowSize - 1].timestamp)); // last month of last row\n\t\t} else {\n\t\t\tpreventDefault = false;\n\t\t}\n\n\t\tif (preventDefault) {\n\t\t\te.preventDefault();\n\t\t}\n\t}\n\n\t_onHomeOrEnd(homePressed: boolean) {\n\t\tthis._months.forEach(row => {\n\t\t\tconst indexInRow = row.findIndex(item => CalendarDate.fromTimestamp(parseInt(item.timestamp) * 1000).getMonth() === this._calendarDate.getMonth());\n\t\t\tif (indexInRow !== -1) { // The current month is on this row\n\t\t\t\tconst index = homePressed ? 0 : this.rowSize - 1; // select the first (if Home) or last (if End) month on the row\n\t\t\t\tthis._setTimestamp(parseInt(row[index].timestamp));\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Sets the timestamp to an absolute value.\n\t * @param value\n\t * @private\n\t */\n\t_setTimestamp(value: number) {\n\t\tthis._safelySetTimestamp(value);\n\t\tthis.fireEvent(\"navigate\", { timestamp: this.timestamp! });\n\t}\n\n\t/**\n\t * Modifies timestamp by a given amount of months and,\n\t * if necessary, loads the prev/next page.\n\t * @param amount\n\t * @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)\n\t * @private\n\t */\n\t_modifyTimestampBy(amount: number, preserveDate?: boolean) {\n\t\t// Modify the current timestamp\n\t\tthis._safelyModifyTimestampBy(amount, \"month\", preserveDate);\n\n\t\t// Notify the calendar to update its timestamp\n\t\tthis.fireEvent(\"navigate\", { timestamp: this.timestamp! });\n\t}\n\n\t_onkeyup(e: KeyboardEvent) {\n\t\tif (isSpace(e)) {\n\t\t\tthis._selectMonth(e);\n\t\t}\n\t}\n\n\t/**\n\t * Selects a month, when the user clicks or presses \"Enter\" or \"Space\".\n\t * @param e\n\t * @private\n\t */\n\t_selectMonth(e: Event) {\n\t\te.preventDefault();\n\n\t\tconst target = e.target as HTMLElement;\n\n\t\tif (target.className.indexOf(\"ui5-mp-item\") > -1) {\n\t\t\tconst timestamp = this._getTimestampFromDom(target);\n\t\t\tthis._safelySetTimestamp(timestamp);\n\t\t\tthis.fireEvent(\"change\", { timestamp: this.timestamp! });\n\t\t}\n\t}\n\n\t/**\n\t * Called by the Calendar component.\n\t * @protected\n\t */\n\t_hasPreviousPage(): boolean {\n\t\treturn this._calendarDate.getYear() !== this._minDate.getYear();\n\t}\n\n\t/**\n\t * Called by the Calendar component.\n\t * @protected\n\t */\n\t_hasNextPage(): boolean {\n\t\treturn this._calendarDate.getYear() !== this._maxDate.getYear();\n\t}\n\n\t/**\n\t * Called by Calendar.js.\n\t *\n\t * **Note:** when the user presses the \"<\" button in the calendar header (same as \"PageUp\")\n\t * @protected\n\t */\n\t_showPreviousPage() {\n\t\tthis._modifyTimestampBy(-PAGE_SIZE, true);\n\t}\n\n\t/**\n\t * Called by Calendar.js\n\t * **Note:** when the user presses the \">\" button in the calendar header (same as \"PageDown\")\n\t * @protected\n\t */\n\t_showNextPage() {\n\t\tthis._modifyTimestampBy(PAGE_SIZE, true);\n\t}\n\n\t_isOutOfSelectableRange(date: CalendarDate, minDate: CalendarDate, maxDate: CalendarDate): boolean {\n\t\tconst month = date.getMonth();\n\t\tconst year = date.getYear();\n\t\tconst minYear = minDate.getYear();\n\t\tconst minMonth = minDate.getMonth();\n\t\tconst maxYear = maxDate.getYear();\n\t\tconst maxMonth = maxDate.getMonth();\n\n\t\treturn year < minYear || (year === minYear && month < minMonth) || year > maxYear || (year === maxYear && month > maxMonth);\n\t}\n}\n\nMonthPicker.define();\n\nexport default MonthPicker;\nexport type {\n\tMonthPickerNavigateEventDetail,\n\tMonthPickerChangeEventDetail,\n};\n"]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy