@sbb-esta/lyne-elements 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendar/calendar.component.d.ts +54 -8
- package/calendar/calendar.component.d.ts.map +1 -1
- package/calendar/calendar.component.js +543 -256
- package/core/i18n/i18n.d.ts +1 -0
- package/core/i18n/i18n.d.ts.map +1 -1
- package/core/i18n/i18n.js +22 -16
- package/core/i18n.js +79 -78
- package/custom-elements.json +226 -21
- package/development/calendar/calendar.component.d.ts +54 -8
- package/development/calendar/calendar.component.d.ts.map +1 -1
- package/development/calendar/calendar.component.js +496 -81
- package/development/core/i18n/i18n.d.ts +1 -0
- package/development/core/i18n/i18n.d.ts.map +1 -1
- package/development/core/i18n/i18n.js +8 -1
- package/development/core/i18n.js +2 -1
- package/development/icon/icon-request.js +2 -2
- package/icon/icon-request.js +3 -3
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { CSSResultGroup, LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
export interface Day<T = Date> {
|
|
3
|
+
/** Date as ISO string. */
|
|
3
4
|
value: string;
|
|
4
5
|
dayValue: string;
|
|
5
6
|
monthValue: string;
|
|
6
7
|
yearValue: string;
|
|
7
8
|
dateValue?: T;
|
|
9
|
+
weekValue?: number;
|
|
10
|
+
weekDayValue?: number;
|
|
8
11
|
}
|
|
9
12
|
export interface Month {
|
|
10
13
|
value: string;
|
|
@@ -18,7 +21,7 @@ export interface Weekday {
|
|
|
18
21
|
export type CalendarView = 'day' | 'month' | 'year';
|
|
19
22
|
declare const SbbCalendarElement_base: import('../core/mixins.js').AbstractConstructor<import('../core/mixins.js').SbbHydrationMixinType> & typeof LitElement;
|
|
20
23
|
/**
|
|
21
|
-
* It displays a calendar which allows
|
|
24
|
+
* It displays a calendar which allows choosing a date.
|
|
22
25
|
*/
|
|
23
26
|
export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_base {
|
|
24
27
|
static styles: CSSResultGroup;
|
|
@@ -39,19 +42,23 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
39
42
|
* Accepts an ISO8601 formatted string (e.g. 2024-12-24) as attribute.
|
|
40
43
|
*/
|
|
41
44
|
accessor max: T | null;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
/** Whether the calendar allows for multiple date selection. */
|
|
46
|
+
accessor multiple: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The selected date: accepts a date object, or, if `multiple`, an array of dates.
|
|
49
|
+
*/
|
|
50
|
+
set selected(value: T | T[] | null);
|
|
51
|
+
get selected(): T | T[] | null;
|
|
52
|
+
private accessor _selected;
|
|
46
53
|
/** A function used to filter out dates. */
|
|
47
54
|
accessor dateFilter: ((date: T | null) => boolean) | null;
|
|
48
55
|
/** The orientation of days in the calendar. */
|
|
49
56
|
accessor orientation: 'horizontal' | 'vertical';
|
|
57
|
+
/** Whether it has to display the week numbers in addition to week days. */
|
|
58
|
+
accessor weekNumbers: boolean;
|
|
50
59
|
private _dateAdapter;
|
|
51
60
|
/** The currently active date. */
|
|
52
61
|
private accessor _activeDate;
|
|
53
|
-
/** The selected date as ISOString. */
|
|
54
|
-
private accessor _selected;
|
|
55
62
|
/** The current wide property considering property value and breakpoints. From zero to small `wide` has always to be false. */
|
|
56
63
|
private set _wide(value);
|
|
57
64
|
private get _wide();
|
|
@@ -73,6 +80,10 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
73
80
|
private _nextMonthWeeks;
|
|
74
81
|
/** An array containing all the month names in the current language. */
|
|
75
82
|
private _monthNames;
|
|
83
|
+
/** An array containing the weeks' numbers for the current month. */
|
|
84
|
+
private _weekNumbers;
|
|
85
|
+
/** An array containing the weeks' numbers for the next month in wide mode. */
|
|
86
|
+
private _nextMonthWeekNumbers;
|
|
76
87
|
/** A list of buttons corresponding to days, months or years depending on the view. */
|
|
77
88
|
private get _cells();
|
|
78
89
|
/** The chosen year in the year selection view. */
|
|
@@ -93,13 +104,31 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
93
104
|
focus(): void;
|
|
94
105
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
95
106
|
protected updated(changedProperties: PropertyValues<this>): void;
|
|
107
|
+
/**
|
|
108
|
+
* The `_selected` state should be adapted when the `multiple` property changes:
|
|
109
|
+
* - if it changes to true, the '_selected' is set to an array;
|
|
110
|
+
* - if it changes to false, the first available option is set as 'value' otherwise it's set to null.
|
|
111
|
+
*/
|
|
112
|
+
private _onMultipleChanged;
|
|
96
113
|
/** Initializes the component. */
|
|
97
114
|
private _init;
|
|
98
115
|
/** Focuses on a day cell prioritizing the selected day, the current day, and lastly, the first selectable day. */
|
|
99
116
|
private _focusCell;
|
|
100
117
|
/** Creates the array of weekdays. */
|
|
101
118
|
private _setWeekdays;
|
|
102
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Given a date, it returns the week numbers for the month the date belongs to.
|
|
121
|
+
* TODO: check if date-fns can be replaced with custom logic.
|
|
122
|
+
*
|
|
123
|
+
* Since the calculation is not simple (see https://en.wikipedia.org/wiki/Week#Numbering),
|
|
124
|
+
* the date-fns library has been used this way:
|
|
125
|
+
* the first and the last day of the month are calculated and then passed to the `eachWeekOfInterval` function,
|
|
126
|
+
* which returns an array containing the starting day of every ISO week of the month,
|
|
127
|
+
* considering Monday as the first day.
|
|
128
|
+
* Then, this array is mapped via the `getWeek` function, which returns the ISO week number for that date.
|
|
129
|
+
*/
|
|
130
|
+
private _createWeekNumbers;
|
|
131
|
+
/** Creates the rows along the horizontal direction and sets the parameters used in keyboard navigation. */
|
|
103
132
|
private _createWeekRows;
|
|
104
133
|
/**
|
|
105
134
|
* Creates the rows for each week in orientation='horizontal'.
|
|
@@ -150,6 +179,23 @@ export declare class SbbCalendarElement<T = Date> extends SbbCalendarElement_bas
|
|
|
150
179
|
private _isYearFilteredOut;
|
|
151
180
|
/** Emits the selected date and sets it internally. */
|
|
152
181
|
private _selectDate;
|
|
182
|
+
/**
|
|
183
|
+
* Handle multiple dates selection via weekNumber / weekDay buttons:
|
|
184
|
+
* - if Cmd or Ctrl are pressed, add the new date to the current ones;
|
|
185
|
+
* - if not,
|
|
186
|
+
* - if the new dates are the same of the current ones, it means that the same button has been clicked twice, so do nothing;
|
|
187
|
+
* - if not, the selected dates are the new ones.
|
|
188
|
+
*/
|
|
189
|
+
private _selectMultipleDates;
|
|
190
|
+
/**
|
|
191
|
+
* Emits the dateselected event given the detail (as T or T[] based on the value of the multiple flag).
|
|
192
|
+
*/
|
|
193
|
+
private _emitDateSelectedEvent;
|
|
194
|
+
/**
|
|
195
|
+
* In case of multiple selection, newly added days must be added to the existing ones, without duplication.
|
|
196
|
+
* If the days to add are exactly the same as the selected ones, the set must be emptied.
|
|
197
|
+
*/
|
|
198
|
+
private _updateSelectedWithMultipleDates;
|
|
153
199
|
private _setChosenYear;
|
|
154
200
|
private _assignActiveDate;
|
|
155
201
|
/** Goes to the month identified by the shift. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.component.d.ts","sourceRoot":"","sources":["../../../src/elements/calendar/calendar.component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calendar.component.d.ts","sourceRoot":"","sources":["../../../src/elements/calendar/calendar.component.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EAGnB,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAoCb,OAAO,+BAA+B,CAAC;AACvC,OAAO,YAAY,CAAC;AACpB,OAAO,0BAA0B,CAAC;AAyClC,MAAM,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI;IAC3B,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACn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