@progressive-development/pd-calendar 0.5.3 → 0.6.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/dist/generated/locale-codes.d.ts +14 -0
- package/dist/generated/locale-codes.d.ts.map +1 -0
- package/dist/generated/locales/be.d.ts +22 -0
- package/dist/generated/locales/be.d.ts.map +1 -0
- package/dist/generated/locales/de.d.ts +22 -0
- package/dist/generated/locales/de.d.ts.map +1 -0
- package/dist/generated/locales/en.d.ts +22 -0
- package/dist/generated/locales/en.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/locales/be.d.ts +2 -0
- package/dist/locales/be.js +0 -7
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/de.js +0 -7
- package/dist/locales/en.d.ts +2 -0
- package/dist/locales/en.js +0 -7
- package/dist/pd-calendar-cell.d.ts +47 -0
- package/dist/pd-calendar-cell.d.ts.map +1 -0
- package/dist/pd-calendar-cell.js +282 -0
- package/dist/pd-calendar.d.ts +51 -0
- package/dist/pd-calendar.d.ts.map +1 -0
- package/dist/pd-calendar.js +452 -3
- package/dist/pd-year-popup.d.ts +25 -0
- package/dist/pd-year-popup.d.ts.map +1 -0
- package/dist/pd-year-popup.js +136 -0
- package/dist/stories/cell.stories.d.ts +15 -0
- package/dist/stories/cell.stories.d.ts.map +1 -0
- package/dist/stories/index.stories.d.ts +23 -0
- package/dist/stories/index.stories.d.ts.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +29 -45
- package/dist/src/PdCalendar.js +0 -513
- package/dist/src/PdCalendarCell.js +0 -246
- package/dist/src/PdYearPopup.js +0 -87
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { LitElement, css, html } from "lit";
|
|
2
|
-
import { parse } from "fecha";
|
|
3
|
-
import { PDColorStyles, PDFontStyles } from "@progressive-development/pd-shared-styles";
|
|
4
|
-
class PdCalendarCell extends LitElement {
|
|
5
|
-
/**
|
|
6
|
-
* @event select-date - fires when user clicks on a selectable cell.
|
|
7
|
-
*/
|
|
8
|
-
static get properties() {
|
|
9
|
-
return {
|
|
10
|
-
/**
|
|
11
|
-
* If enabled, cell could be selected (with visible hover element and pointer)
|
|
12
|
-
* vy the user => results in fire cell-selected.
|
|
13
|
-
*/
|
|
14
|
-
selectEnabled: { type: Boolean },
|
|
15
|
-
/**
|
|
16
|
-
* If enabled, highlight the current day
|
|
17
|
-
*/
|
|
18
|
-
today: { type: Boolean },
|
|
19
|
-
/**
|
|
20
|
-
* If enabled, highlight the selected day
|
|
21
|
-
*/
|
|
22
|
-
selected: { type: Boolean },
|
|
23
|
-
/**
|
|
24
|
-
* If enabled the cell gets an special class (e.g. green day).
|
|
25
|
-
*/
|
|
26
|
-
special: { type: Boolean },
|
|
27
|
-
/**
|
|
28
|
-
* If set shows info text in the middle (hack) of the cell (e.g. price info).
|
|
29
|
-
*/
|
|
30
|
-
infoTxt: { type: String },
|
|
31
|
-
/**
|
|
32
|
-
* CSS class for day number inside the cell, top-left and center available
|
|
33
|
-
*/
|
|
34
|
-
numberClass: { type: String },
|
|
35
|
-
/* key, weekDayNumber, dayNumber could merged to date
|
|
36
|
-
on the other hand then there is the need to calculate them for each cell... */
|
|
37
|
-
key: { type: String },
|
|
38
|
-
weekDayNumber: { type: Number },
|
|
39
|
-
dayNumber: { type: Number }
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
static get styles() {
|
|
43
|
-
return [
|
|
44
|
-
PDColorStyles,
|
|
45
|
-
PDFontStyles,
|
|
46
|
-
css`
|
|
47
|
-
:host {
|
|
48
|
-
display: block;
|
|
49
|
-
|
|
50
|
-
/* Defined by PdCalendar and also setted here
|
|
51
|
-
--my-primary-font: var(--squi-primary-font, Oswald);*/
|
|
52
|
-
|
|
53
|
-
/* not used in the moment, was created for gradient cells
|
|
54
|
-
--my-info-cell-bg2-color: var(--squi-title-color, #084c61);
|
|
55
|
-
--my-info-cell-bg1-hover: var(--squi-highlight-color, #ffc857);
|
|
56
|
-
--my-info-cell-bg2-hover: var(--squi-highlight-color, #177e89);
|
|
57
|
-
*/
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.cell {
|
|
61
|
-
width: 100%;
|
|
62
|
-
height: 100%;
|
|
63
|
-
min-height: 30px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.cell-empty {
|
|
67
|
-
background-color: var(--pd-calendar-cell-empty-bg-col, var(--pd-default-bg));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.cell-day {
|
|
71
|
-
position: relative;
|
|
72
|
-
/*background-image: linear-gradient(to right, rgb(51, 101, 138) , rgb(38, 76, 104)); */
|
|
73
|
-
/*box-shadow: 2px 2px 3px;*/
|
|
74
|
-
background-color: var(--pd-calendar-cell-day-bg-col, var(--pd-default-light-col));
|
|
75
|
-
/*border-radius: 2px 2px 2px 2px;*/
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.cell-day.we {
|
|
79
|
-
background-color: var(--pd-calendar-cell-day-we-bg-col, var(--pd-default-disabled-light-col));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.free {
|
|
83
|
-
/*background-image: linear-gradient(to right, green, darkgreen);
|
|
84
|
-
background-color: var(--my-info-cell-bg1-color);*/
|
|
85
|
-
background-color: var(--pd-calendar-cell-day-free-bg-col, var(--pd-default-col));
|
|
86
|
-
/*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
|
|
87
|
-
box-shadow: var(--pd-calendar-cell-selectable-shadow, 1px 2px 2px);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.special {
|
|
91
|
-
/*background-image: linear-gradient(to right, green, darkgreen);
|
|
92
|
-
background-color: var(--my-info-cell-bg1-color);*/
|
|
93
|
-
background-color: var(--pd-calendar-cell-day-special-bg-col, var(--pd-default-success-col));
|
|
94
|
-
/*background-image: linear-gradient(to right, var(--my-info-cell-bg1-color), var(--my-info-cell-bg2-color));*/
|
|
95
|
-
box-shadow: var(--pd-calendar-cell-selectable-shadow, 1px 2px 2px);;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.special:hover,
|
|
99
|
-
.free:hover {
|
|
100
|
-
background-color: var(--pd-calendar-cell-day-bg-col-hover, var(--pd-default-hover-col));
|
|
101
|
-
/*background-image: linear-gradient(to right, var(--my-info-cell-bg1-hover), var(--my-info-cell-bg2-hover));*/
|
|
102
|
-
cursor: pointer;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.cell-info {
|
|
107
|
-
display: flex;
|
|
108
|
-
align-items: center;
|
|
109
|
-
justify-content: center;
|
|
110
|
-
height: 100%;
|
|
111
|
-
color: var(--pd-calendar-cell-day-info-col, var(--pd-default-bg-col));
|
|
112
|
-
font-family: var(--pd-default-font-title-family);
|
|
113
|
-
font-weight: bold;
|
|
114
|
-
font-size: var(--pd-calendar-info-font-size, 1.5em);
|
|
115
|
-
text-shadow: 1px 1px var(--pd-default-dark-col);
|
|
116
|
-
pointer-events: none;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.cell-number {
|
|
120
|
-
pointer-events: none;
|
|
121
|
-
font-size: var(--pd-calendar-number-font-size, 1em);
|
|
122
|
-
font-weight: bold;
|
|
123
|
-
color: var(--pd-calendar-cell-day-info-col, var(--pd-default-bg-col));
|
|
124
|
-
font-family: var(--pd-default-font-content-family);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.cell-number.top-left {
|
|
128
|
-
position: absolute;
|
|
129
|
-
left: 3px;
|
|
130
|
-
top: 2px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/* Noch umstellen, passt nicht für alle größen (die anderen auf flex/center umgestellt) */
|
|
134
|
-
.center {
|
|
135
|
-
display: flex;
|
|
136
|
-
align-items: center;
|
|
137
|
-
justify-content: center;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.free .cell-number, .special .cell-number {
|
|
141
|
-
color: var(--pd-calendar-cell-day-info-free-col, var(--pd-default-bg-col));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.number-ring {
|
|
145
|
-
position: absolute;
|
|
146
|
-
height: 28px;
|
|
147
|
-
width: 28px;
|
|
148
|
-
border-radius: 50%;
|
|
149
|
-
display: inline-block;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.today {
|
|
153
|
-
border: 2px solid blue;
|
|
154
|
-
pointer-events: none;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.selected {
|
|
158
|
-
border: 2px solid red;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/* ToDo: Dont work for calendars sized by custom properties. Needed to calculate from calendar size
|
|
162
|
-
not from window size, this is a topic for container queries, which are not available right now... */
|
|
163
|
-
@media (max-width: 800px) {
|
|
164
|
-
.cell-info {
|
|
165
|
-
font-size: 1.3em;
|
|
166
|
-
}
|
|
167
|
-
.cell-number {
|
|
168
|
-
font-size: 0.8em;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
@media (max-width: 500px) {
|
|
172
|
-
.cell-info {
|
|
173
|
-
font-weight: normal;
|
|
174
|
-
font-size: 1em;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
`
|
|
178
|
-
];
|
|
179
|
-
}
|
|
180
|
-
constructor() {
|
|
181
|
-
super();
|
|
182
|
-
this.numberClass = "top-left";
|
|
183
|
-
}
|
|
184
|
-
_renderSelectableCell() {
|
|
185
|
-
return html` <div
|
|
186
|
-
@keypress="${this._selectableCellClicked}"
|
|
187
|
-
@click="${this._selectableCellClicked}"
|
|
188
|
-
@mouseenter="${this._mouseEnter}"
|
|
189
|
-
@mouseleave="${this._mouseLeave}"
|
|
190
|
-
data-date="${this.key}"
|
|
191
|
-
class="cell cell-day ${this.numberClass} ${this.special ? "special" : "free"}
|
|
192
|
-
${(this.weekDayNumber === 6 || this.weekDayNumber === 0) && !this.special ? "we" : ""}"
|
|
193
|
-
>
|
|
194
|
-
${this.infoTxt ? html` <div class="cell-info">${this.infoTxt}</div>` : ""}
|
|
195
|
-
|
|
196
|
-
${this.today ? html`<div class="number-ring today"></div>` : ""}
|
|
197
|
-
|
|
198
|
-
${this.selected ? html`<div class="number-ring selected"></div>` : ""}
|
|
199
|
-
|
|
200
|
-
<div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
|
|
201
|
-
</div>`;
|
|
202
|
-
}
|
|
203
|
-
_renderEmptyCell() {
|
|
204
|
-
return html`<div
|
|
205
|
-
class="cell cell-day ${this.numberClass} ${(this.weekDayNumber === 6 || this.weekDayNumber === 0) && !this.special ? "we" : ""}"
|
|
206
|
-
>
|
|
207
|
-
${this.infoTxt ? html`<div class="cell-info">${this.infoTxt}</div>` : ""}
|
|
208
|
-
|
|
209
|
-
<div class="cell-number ${this.numberClass}">${this.dayNumber}</div>
|
|
210
|
-
</div>`;
|
|
211
|
-
}
|
|
212
|
-
render() {
|
|
213
|
-
return this.selectEnabled ? this._renderSelectableCell() : this._renderEmptyCell();
|
|
214
|
-
}
|
|
215
|
-
_selectableCellClicked(e) {
|
|
216
|
-
const dateKey = e.target.dataset.date;
|
|
217
|
-
if (dateKey) {
|
|
218
|
-
const userSelectedDate = parse(dateKey, "YYYY-MM-DD");
|
|
219
|
-
this.dispatchEvent(
|
|
220
|
-
new CustomEvent("select-date", {
|
|
221
|
-
detail: {
|
|
222
|
-
dateKey,
|
|
223
|
-
date: userSelectedDate
|
|
224
|
-
}
|
|
225
|
-
})
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
_mouseEnter() {
|
|
230
|
-
const userSelectedDate = parse(this.key, "YYYY-MM-DD");
|
|
231
|
-
this.dispatchEvent(
|
|
232
|
-
new CustomEvent("mouse-enter-date", {
|
|
233
|
-
detail: {
|
|
234
|
-
dateKey: this.key,
|
|
235
|
-
date: userSelectedDate
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
_mouseLeave() {
|
|
241
|
-
this.dispatchEvent(
|
|
242
|
-
new CustomEvent("mouse-leave-date")
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
window.customElements.define("pd-calendar-cell", PdCalendarCell);
|
package/dist/src/PdYearPopup.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { LitElement, css, html } from "lit";
|
|
2
|
-
class PdYearPopup extends LitElement {
|
|
3
|
-
/**
|
|
4
|
-
* @event select-date - fires when user clicks on a selectable cell.
|
|
5
|
-
*/
|
|
6
|
-
static get properties() {
|
|
7
|
-
return {
|
|
8
|
-
yearSelection: { type: Array },
|
|
9
|
-
currentYear: { type: String }
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
static get styles() {
|
|
13
|
-
return [
|
|
14
|
-
css`
|
|
15
|
-
:host {
|
|
16
|
-
position: absolute;
|
|
17
|
-
z-index: 1;
|
|
18
|
-
top: 25px;
|
|
19
|
-
right: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
ul {
|
|
23
|
-
list-style: none;
|
|
24
|
-
max-width: 200px;
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: 0;
|
|
27
|
-
background: var(--pd-default-light-col, #cdeaf844);
|
|
28
|
-
box-shadow: 3px 3px 5px 0 #ccc;
|
|
29
|
-
border: 1px solid var(--pd-default-col);
|
|
30
|
-
|
|
31
|
-
display: flex;
|
|
32
|
-
flex-direction: column;
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
li {
|
|
37
|
-
text-align: center;
|
|
38
|
-
padding: 10px;
|
|
39
|
-
color: var(--pd-default-dark-col);
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.current {
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.selectable:hover {
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
`
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
constructor() {
|
|
54
|
-
super();
|
|
55
|
-
this.yearSelection = [];
|
|
56
|
-
}
|
|
57
|
-
render() {
|
|
58
|
-
return html`
|
|
59
|
-
<ul>
|
|
60
|
-
${this.yearSelection.map((year) => html`
|
|
61
|
-
<li class="${this.currentYear === year ? "current" : ""}" data-year="${year}" @click="${this._yearSelection}">${year}</li>
|
|
62
|
-
`)}
|
|
63
|
-
</ul>
|
|
64
|
-
`;
|
|
65
|
-
}
|
|
66
|
-
_yearSelection(event) {
|
|
67
|
-
if (event.target.dataset.year) {
|
|
68
|
-
this.dispatchEvent(new CustomEvent(
|
|
69
|
-
"change-year-selection",
|
|
70
|
-
{
|
|
71
|
-
detail: {
|
|
72
|
-
year: event.target.dataset.year
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
));
|
|
76
|
-
} else {
|
|
77
|
-
this._closeSelection();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
_closeSelection() {
|
|
81
|
-
this.dispatchEvent(new CustomEvent("abort-year-selection"));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
window.customElements.define("pd-year-popup", PdYearPopup);
|
|
85
|
-
export {
|
|
86
|
-
PdYearPopup
|
|
87
|
-
};
|