diff --git a/packages/base/src/types/CalendarSelection.js b/packages/base/src/types/CalendarSelection.js new file mode 100644 index 000000000000..3850573e37b9 --- /dev/null +++ b/packages/base/src/types/CalendarSelection.js @@ -0,0 +1,17 @@ +import DataType from "./DataType.js"; + +const CalendarSelections = { + Single: "Single", + Multiple: "Multiple", + Range: "Range", +}; + +class CalendarSelection extends DataType { + static isValid(value) { + return !!CalendarSelections[value]; + } +} + +CalendarSelection.generateTypeAcessors(CalendarSelections); + +export default CalendarSelection; diff --git a/packages/main/src/Calendar.hbs b/packages/main/src/Calendar.hbs index f1d364cec13c..50ed216837a2 100644 --- a/packages/main/src/Calendar.hbs +++ b/packages/main/src/Calendar.hbs @@ -1,7 +1,8 @@
@@ -26,6 +28,7 @@ .selectedDates="{{_oMonth.selectedDates}}" ._hidden="{{_oMonth._hidden}}" .primaryCalendarType="{{_oMonth.primaryCalendarType}}" + .selection="{{_oMonth.selection}}" .minDate="{{_oMonth.minDate}}" .maxDate="{{_oMonth.maxDate}}" timestamp="{{_oMonth.timestamp}}" diff --git a/packages/main/src/Calendar.js b/packages/main/src/Calendar.js index 5d96be05d445..4e94d6ecf3be 100644 --- a/packages/main/src/Calendar.js +++ b/packages/main/src/Calendar.js @@ -7,8 +7,15 @@ import DateFormat from "@ui5/webcomponents-localization/dist/DateFormat.js"; import getCachedLocaleDataInstance from "@ui5/webcomponents-localization/dist/getCachedLocaleDataInstance.js"; import CalendarDate from "@ui5/webcomponents-localization/dist/dates/CalendarDate.js"; import CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js"; +import CalendarSelection from "@ui5/webcomponents-base/dist/types/CalendarSelection.js"; import Integer from "@ui5/webcomponents-base/dist/types/Integer.js"; -import { isF4, isF4Shift } from "@ui5/webcomponents-base/dist/Keys.js"; +import { + isF4, + isF4Shift, + isTabNext, + isTabPrevious, +} from "@ui5/webcomponents-base/dist/Keys.js"; +import RenderScheduler from "@ui5/webcomponents-base/dist/RenderScheduler.js"; import CalendarHeader from "./CalendarHeader.js"; import DayPicker from "./DayPicker.js"; import MonthPicker from "./MonthPicker.js"; @@ -29,15 +36,6 @@ import calendarCSS from "./generated/themes/Calendar.css.js"; const metadata = { tag: "ui5-calendar", properties: /** @lends sap.ui.webcomponents.main.Calendar.prototype */ { - /** - * Defines the UNIX timestamp - seconds since 00:00:00 UTC on Jan 1, 1970. - * @type {Integer} - * @public - */ - timestamp: { - type: Integer, - }, - /** * Defines the calendar type used for display. * If not defined, the calendar type of the global configuration is used. @@ -49,6 +47,24 @@ const metadata = { type: CalendarType, }, + /** + * Defines the type of selection used in the calendar component. + * The property takes as value an object of type CalendarSelection. + * Accepted property values are:
+ * + * @type {CalendarSelection} + * @defaultvalue "Single" + * @public + */ + selection: { + type: CalendarSelection, + defaultValue: CalendarSelection.Single, + }, + /** * Defines the selected dates as UTC timestamps. * @type {Array} @@ -64,7 +80,6 @@ const metadata = { * * @type {string} * @defaultvalue "" - * @since 1.0.0-rc.6 * @public */ minDate: { @@ -76,7 +91,6 @@ const metadata = { * * @type {string} * @defaultvalue "" - * @since 1.0.0-rc.6 * @public */ maxDate: { @@ -93,12 +107,20 @@ const metadata = { * @type {boolean} * @defaultvalue false * @public - * @since 1.0.0-rc.8 */ hideWeekNumbers: { type: Boolean, }, + /** + * Defines the UNIX timestamp - seconds since 00:00:00 UTC on Jan 1, 1970. + * @type {Integer} + * @private + */ + timestamp: { + type: Integer, + }, + _header: { type: Object, }, @@ -133,55 +155,74 @@ const metadata = { /** * Fired when the selected dates changed. * @event sap.ui.webcomponents.main.Calendar#selected-dates-change - * @param {Array} dates The selected dates' timestamps + * @param {Array} dates The selected dates timestamps * @public */ - "selected-dates-change": { type: Array }, + "selected-dates-change": { + detail: { + dates: { type: Array }, + }, + }, }, }; /** * @class * + *

Overview

+ * + * The ui5-calendar can be used stand alone to display the years, months, weeks and days + *

+ * + *

Usage

+ * + * The user can navigate to a particular date by: + *
+ * + *
+ * The user can comfirm a date selection by pressing over a date inside the days view. + *

+ * *

Keyboard Handling

-* The ui5-calendar provides advanced keyboard handling. -* If the ui5-calendar is focused the user can -* choose a picker by using the following shortcuts:
-*