@skf-design-system/ui-components 1.0.1-beta.0 → 1.0.1-beta.1
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/components/accordion/accordion.component.js +3 -3
- package/dist/components/alert/alert.component.js +8 -8
- package/dist/components/button/button.component.d.ts +3 -3
- package/dist/components/button/button.component.js +59 -55
- package/dist/components/card/card.component.js +4 -4
- package/dist/components/checkbox/checkbox.component.d.ts +3 -1
- package/dist/components/checkbox/checkbox.component.js +69 -56
- package/dist/components/date-picker/datepicker.calendar.component.d.ts +72 -0
- package/dist/components/date-picker/datepicker.calendar.component.js +382 -0
- package/dist/components/date-picker/datepicker.calendar.styles.d.ts +1 -0
- package/dist/components/date-picker/datepicker.calendar.styles.js +192 -0
- package/dist/components/date-picker/datepicker.component.d.ts +74 -0
- package/dist/components/date-picker/datepicker.component.js +241 -0
- package/dist/components/date-picker/datepicker.d.ts +10 -0
- package/dist/components/date-picker/datepicker.helpers.d.ts +40 -0
- package/dist/components/date-picker/datepicker.helpers.js +69 -0
- package/dist/components/date-picker/datepicker.js +8 -0
- package/dist/components/date-picker/datepicker.styles.d.ts +1 -0
- package/dist/components/date-picker/datepicker.styles.js +99 -0
- package/dist/components/date-picker-input/datepicker-input.component.d.ts +107 -0
- package/dist/components/date-picker-input/datepicker-input.component.js +397 -0
- package/dist/components/date-picker-input/datepicker-input.d.ts +8 -0
- package/dist/components/date-picker-input/datepicker-input.helpers.d.ts +4 -0
- package/dist/components/date-picker-input/datepicker-input.helpers.js +29 -0
- package/dist/components/date-picker-input/datepicker-input.js +6 -0
- package/dist/components/date-picker-input/datepicker-input.styles.d.ts +1 -0
- package/dist/components/date-picker-input/datepicker-input.styles.js +22 -0
- package/dist/components/dialog/dialog.component.js +19 -19
- package/dist/components/divider/divider.component.js +12 -12
- package/dist/components/heading/heading.component.js +13 -13
- package/dist/components/icon/icon.component.js +19 -19
- package/dist/components/input/input.component.d.ts +1 -0
- package/dist/components/input/input.component.js +87 -80
- package/dist/components/link/link.component.js +28 -28
- package/dist/components/loader/loader.component.js +19 -19
- package/dist/components/logo/logo.component.js +6 -6
- package/dist/components/popover/popover.component.js +12 -12
- package/dist/components/progress/progress.component.js +7 -7
- package/dist/components/radio/radio.component.js +4 -4
- package/dist/components/select-option-group/select-option-group.component.js +9 -9
- package/dist/components/stepper/stepper.component.js +9 -9
- package/dist/components/stepper/stepper.helpers.js +5 -5
- package/dist/components/stepper-item/stepper-item.component.js +23 -23
- package/dist/components/tab/tab.component.js +4 -4
- package/dist/components/tab-panel/tab-panel.component.js +12 -12
- package/dist/components/tag/tag.component.js +9 -9
- package/dist/components/textarea/textarea.component.js +3 -3
- package/dist/components/toast/toast.component.js +13 -13
- package/dist/components/toast-wrapper/toast-wrapper.component.js +10 -10
- package/dist/components/tooltip/tooltip.component.js +2 -2
- package/dist/custom-elements.json +941 -161
- package/dist/index.d.ts +2 -0
- package/dist/index.js +72 -66
- package/dist/internal/components/hint/hint.component.js +13 -13
- package/dist/internal/controllers/popover.controller.d.ts +2 -1
- package/dist/internal/controllers/popover.controller.js +2 -2
- package/dist/internal/helpers/dateFormatter.d.ts +2 -0
- package/dist/internal/helpers/utilityTypes.d.ts +22 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/skf-datepicker/index.d.ts +12 -0
- package/dist/react/skf-datepicker/index.js +18 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +45 -3
- package/dist/types/vue/index.d.ts +44 -1
- package/dist/vscode.html-custom-data.json +39 -1
- package/dist/web-types.json +107 -10
- package/package.json +3 -2
@@ -0,0 +1,382 @@
|
|
1
|
+
import { dateFormatter as c } from "../date-picker-input/datepicker-input.helpers.js";
|
2
|
+
import { compareDates as y } from "./datepicker.helpers.js";
|
3
|
+
import { SkfElement as _ } from "../../internal/components/skf-element.js";
|
4
|
+
import { watch as S } from "../../internal/helpers/watch.js";
|
5
|
+
import { Temporal as l } from "@js-temporal/polyfill";
|
6
|
+
import $ from "../../styles/component.styles.js";
|
7
|
+
import { html as u } from "lit";
|
8
|
+
import { property as o, state as b } from "lit/decorators.js";
|
9
|
+
import { repeat as D } from "lit/directives/repeat.js";
|
10
|
+
import { styles as M } from "./datepicker.calendar.styles.js";
|
11
|
+
var O = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (h, t, e, a) => {
|
12
|
+
for (var s = a > 1 ? void 0 : a ? w(t, e) : t, i = h.length - 1, d; i >= 0; i--)
|
13
|
+
(d = h[i]) && (s = (a ? d(t, e, s) : d(s)) || s);
|
14
|
+
return a && s && O(t, e, s), s;
|
15
|
+
};
|
16
|
+
const g = class g extends _ {
|
17
|
+
constructor() {
|
18
|
+
super(...arguments), this._secondCalendarOffset = 0, this.date = /* @__PURE__ */ new Date(), this.firstDayOfWeek = 0, this.locale = "en-CA", this.range = !1, this.selectedDate = void 0, this.selectedDateRange = {
|
19
|
+
start: null,
|
20
|
+
end: null
|
21
|
+
}, this._numberOfDays = 0, this._numberOfDaysLastMonth = 0, this.dateSelectable = (t) => {
|
22
|
+
var d;
|
23
|
+
const e = (d = this.invalidDates) == null ? void 0 : d.split(",").includes(t), a = !this.selectableTo || y(t, this.selectableTo) < 0, s = !this.selectableFrom || y(t, this.selectableFrom) > 0;
|
24
|
+
return { matchesInvalidDates: e, dateWithinRange: !(a && s) };
|
25
|
+
};
|
26
|
+
}
|
27
|
+
firstUpdated() {
|
28
|
+
this._secondCalendarOffset = this.id.endsWith("-range-end") ? -1 : 0;
|
29
|
+
}
|
30
|
+
/** For single select, the selected date */
|
31
|
+
attributeChangedCallback(t, e, a) {
|
32
|
+
t === "selected-date" && e !== a && (this.selectedDate = new Date(a));
|
33
|
+
}
|
34
|
+
handleDateChange() {
|
35
|
+
var t, e;
|
36
|
+
this._numberOfDays = ((t = this._plainDate(this.date)) == null ? void 0 : t.daysInMonth) ?? 0, this._numberOfDaysLastMonth = ((e = this._plainDate(this.date)) == null ? void 0 : e.subtract({
|
37
|
+
months: 1
|
38
|
+
}).daysInMonth) ?? 0;
|
39
|
+
}
|
40
|
+
_createDate({ year: t, month: e, day: a = 1 }, s) {
|
41
|
+
switch (e ?? (e = this.date.getMonth()), t ?? (t = this.date.getFullYear()), !0) {
|
42
|
+
case e < 0:
|
43
|
+
e = 11, t--;
|
44
|
+
break;
|
45
|
+
case e > 11:
|
46
|
+
e = 0, t++;
|
47
|
+
break;
|
48
|
+
}
|
49
|
+
if (s)
|
50
|
+
try {
|
51
|
+
return l.PlainDate.from({
|
52
|
+
year: t,
|
53
|
+
month: e + 1,
|
54
|
+
day: a
|
55
|
+
});
|
56
|
+
} catch (i) {
|
57
|
+
console.error("error", i);
|
58
|
+
}
|
59
|
+
return new Date(t, e, a);
|
60
|
+
}
|
61
|
+
/** @internal Converts a new Date object to PlainDate type. If no argument sent, uses 'this.date' */
|
62
|
+
_plainDate(t) {
|
63
|
+
if (!t) return null;
|
64
|
+
const e = {
|
65
|
+
year: t.getFullYear(),
|
66
|
+
month: t.getMonth() + 1,
|
67
|
+
// Months are 0-based in Date, but 1-based in Temporal
|
68
|
+
day: t.getDate()
|
69
|
+
};
|
70
|
+
try {
|
71
|
+
return l.PlainDate.from(e);
|
72
|
+
} catch (a) {
|
73
|
+
return console.log(e), console.error("error", a), null;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
/** @internal Check if a day is between two dates */
|
77
|
+
_isDateBetween(t, e, a) {
|
78
|
+
if (!e || !a) return !1;
|
79
|
+
const s = l.PlainDate.compare(t, e) > 0, i = l.PlainDate.compare(t, a) < 0;
|
80
|
+
return s && i;
|
81
|
+
}
|
82
|
+
render() {
|
83
|
+
return u`
|
84
|
+
${this.getCalendarHead()}
|
85
|
+
|
86
|
+
<!-- weekdays -->
|
87
|
+
<ul class="weekdays grid">
|
88
|
+
${D(
|
89
|
+
Array.from({ length: 7 }, (t, e) => e),
|
90
|
+
(t) => t,
|
91
|
+
(t) => u`<li>
|
92
|
+
${new Intl.DateTimeFormat(this.locale, {
|
93
|
+
weekday: "short"
|
94
|
+
}).format(new Date(2018, 0, t)).slice(0, 2)}
|
95
|
+
</li>`
|
96
|
+
)}
|
97
|
+
</ul>
|
98
|
+
|
99
|
+
<!-- start of calendar -->
|
100
|
+
<ol class="calendar grid">
|
101
|
+
<!-- previous month -->
|
102
|
+
${this.getCalendarPreMonthDays()}
|
103
|
+
<!-- current days -->
|
104
|
+
${D(
|
105
|
+
Array.from({ length: this._numberOfDays }, (t, e) => e + 1),
|
106
|
+
(t) => t,
|
107
|
+
(t) => {
|
108
|
+
const e = this._createDate({ day: t }, !0).toString(), a = this.returnDayClasses(t);
|
109
|
+
return u`<li>
|
110
|
+
<button
|
111
|
+
class="day ${a}"
|
112
|
+
data-date=${e}
|
113
|
+
aria-label="Choose ${this._createDate({
|
114
|
+
day: t
|
115
|
+
}).toLocaleDateString(this.locale, {
|
116
|
+
weekday: "long",
|
117
|
+
year: "numeric",
|
118
|
+
month: "short",
|
119
|
+
day: "numeric"
|
120
|
+
})}"
|
121
|
+
@click="${() => {
|
122
|
+
this.handleSelectDay({ day: t });
|
123
|
+
}}"
|
124
|
+
?disabled="${a.includes("invalid")}"
|
125
|
+
>
|
126
|
+
${t}
|
127
|
+
</button>
|
128
|
+
</li>`;
|
129
|
+
}
|
130
|
+
)}
|
131
|
+
<!-- next month -->
|
132
|
+
${this.getCalendarRemaningDays()}
|
133
|
+
</ol>
|
134
|
+
<slot></slot>
|
135
|
+
<div class="triangle"></div>
|
136
|
+
`;
|
137
|
+
}
|
138
|
+
/** @internal */
|
139
|
+
returnDayClasses(t) {
|
140
|
+
var m, p, f;
|
141
|
+
const e = [], a = this._createDate({ day: t }).getDate(), s = ((m = this.selectedDate) == null ? void 0 : m.getMonth()) === this.date.getMonth();
|
142
|
+
this.range && this._isDateBetween(
|
143
|
+
this._createDate({ day: t }, !0),
|
144
|
+
this._plainDate(this.selectedDateRange.start) ?? void 0,
|
145
|
+
this._plainDate(this.selectedDateRange.end) ?? void 0
|
146
|
+
) && e.push("in-range"), this.range && this.selectedDateRange.start && (this.selectedDateRange.start.getMonth() === this.date.getMonth() && this.selectedDateRange.start.getDate() === a && e.push("selected selected-start"), ((p = this.selectedDateRange.end) == null ? void 0 : p.getMonth()) === this.date.getMonth() && this.selectedDateRange.end.getDate() === a && e.push("selected selected-end"));
|
147
|
+
const { matchesInvalidDates: i, dateWithinRange: d } = this.dateSelectable(
|
148
|
+
this._createDate({ day: t }, !0).toString()
|
149
|
+
);
|
150
|
+
(i || d) && e.push("invalid");
|
151
|
+
const v = ((f = this.selectedDate) == null ? void 0 : f.getDate()) === a;
|
152
|
+
return !this.range && v && s && (console.log("is single date selected", this.selectedDate), e.push("selected")), this._createDate({ day: t }, !0).equals(String(this._plainDate(/* @__PURE__ */ new Date()))) && e.push("today"), e.join(" ");
|
153
|
+
}
|
154
|
+
/** @internal */
|
155
|
+
handleSelectDay({
|
156
|
+
year: t = this.date.getFullYear(),
|
157
|
+
month: e = this.date.getMonth(),
|
158
|
+
day: a
|
159
|
+
}) {
|
160
|
+
this.emit("selected-date-changed", {
|
161
|
+
detail: {
|
162
|
+
date: new Date(t, e, a),
|
163
|
+
id: this.eventid
|
164
|
+
}
|
165
|
+
});
|
166
|
+
}
|
167
|
+
/** @internal */
|
168
|
+
getCalendarPreMonthDays() {
|
169
|
+
return D(
|
170
|
+
Array.from(
|
171
|
+
{
|
172
|
+
length: this.getCalendarStartDay().getDay()
|
173
|
+
},
|
174
|
+
(t, e) => this._numberOfDaysLastMonth - this.getCalendarStartDay().getDay() + 1 + e
|
175
|
+
),
|
176
|
+
(t) => t,
|
177
|
+
(t) => {
|
178
|
+
const e = ["prevmonth"], a = this._createDate(
|
179
|
+
{
|
180
|
+
year: this.date.getFullYear(),
|
181
|
+
month: this.date.getMonth() - 1,
|
182
|
+
day: t + 1
|
183
|
+
},
|
184
|
+
!0
|
185
|
+
).toString(), { matchesInvalidDates: s, dateWithinRange: i } = this.dateSelectable(a);
|
186
|
+
return (s || i) && e.push("invalid"), u`<li class="day ">
|
187
|
+
<button
|
188
|
+
class=${e.join(" ")}
|
189
|
+
data-date=${a}
|
190
|
+
@click="${() => {
|
191
|
+
this.handleSelectDay({
|
192
|
+
month: this.date.getMonth() - 1,
|
193
|
+
day: t
|
194
|
+
}), this.emit("update-calendar-view", {
|
195
|
+
detail: l.PlainDate.from(c(this.date)).subtract({ months: 1 }).toString()
|
196
|
+
});
|
197
|
+
}}"
|
198
|
+
?disabled=${e.includes("invalid")}
|
199
|
+
>
|
200
|
+
${t}
|
201
|
+
</button>
|
202
|
+
</li>`;
|
203
|
+
}
|
204
|
+
);
|
205
|
+
}
|
206
|
+
/** @internal */
|
207
|
+
getCalendarRemaningDays() {
|
208
|
+
return (this._numberOfDays + this.calendarMonthStartsOn()) % 7 === 0 ? "" : D(
|
209
|
+
Array.from(
|
210
|
+
{
|
211
|
+
length: 7 - this._createDate({
|
212
|
+
year: this.date.getFullYear(),
|
213
|
+
month: this.date.getMonth(),
|
214
|
+
day: this._numberOfDays + 1
|
215
|
+
}).getDay()
|
216
|
+
},
|
217
|
+
(t, e) => e
|
218
|
+
),
|
219
|
+
(t) => t,
|
220
|
+
(t) => {
|
221
|
+
const e = ["nextmonth"], a = this._createDate(
|
222
|
+
{
|
223
|
+
year: this.date.getFullYear(),
|
224
|
+
month: this.date.getMonth() + 1,
|
225
|
+
day: t + 1
|
226
|
+
},
|
227
|
+
!0
|
228
|
+
).toString(), { matchesInvalidDates: s, dateWithinRange: i } = this.dateSelectable(a);
|
229
|
+
return (s || i) && e.push("invalid"), u`<li class="day">
|
230
|
+
<button
|
231
|
+
data-date=${a}
|
232
|
+
class=${e.join(" ")}
|
233
|
+
@click="${() => {
|
234
|
+
this.handleSelectDay({
|
235
|
+
month: this.date.getMonth() + 1,
|
236
|
+
day: t + 1
|
237
|
+
}), this.emit("update-calendar-view", {
|
238
|
+
detail: l.PlainDate.from(c(this.date)).add({ months: 1 }).toString()
|
239
|
+
});
|
240
|
+
}}"
|
241
|
+
?disabled=${e.includes("invalid")}
|
242
|
+
>
|
243
|
+
${t + 1}
|
244
|
+
</button>
|
245
|
+
</li>`;
|
246
|
+
}
|
247
|
+
);
|
248
|
+
}
|
249
|
+
/** @internal */
|
250
|
+
calendarMonthStartsOn({
|
251
|
+
year: t = this.date.getFullYear(),
|
252
|
+
month: e = this.date.getMonth()
|
253
|
+
} = {}) {
|
254
|
+
return this._createDate({ year: t, month: e, day: 1 }).getDay();
|
255
|
+
}
|
256
|
+
/** @internal */
|
257
|
+
getCalendarStartDay(t) {
|
258
|
+
const e = t ?? this.date;
|
259
|
+
return this._createDate({
|
260
|
+
year: e.getFullYear(),
|
261
|
+
month: e.getMonth(),
|
262
|
+
day: 1
|
263
|
+
});
|
264
|
+
}
|
265
|
+
/** @internal */
|
266
|
+
getCalendarHead() {
|
267
|
+
return u` <div class="calendar-head">
|
268
|
+
<div
|
269
|
+
class="calendar-head__controls${this.range && this.classList.contains("end") ? " hide" : ""}"
|
270
|
+
>
|
271
|
+
<button
|
272
|
+
aria-label="Previous year"
|
273
|
+
title="Previous year"
|
274
|
+
@click="${() => {
|
275
|
+
this.emit("update-calendar-view", {
|
276
|
+
detail: l.PlainDate.from(c(this.date)).subtract({ years: 1 }).toString()
|
277
|
+
});
|
278
|
+
}}"
|
279
|
+
>
|
280
|
+
<div style="letter-spacing: -0.2em" aria-hidden="true" data-comp="icon">❮❮</div>
|
281
|
+
</button>
|
282
|
+
<button
|
283
|
+
aria-label="Previous month"
|
284
|
+
title="Previous month"
|
285
|
+
@click="${() => {
|
286
|
+
this.emit("update-calendar-view", {
|
287
|
+
detail: l.PlainDate.from(c(this.date)).subtract({ months: 1 }).toString()
|
288
|
+
});
|
289
|
+
}}"
|
290
|
+
>
|
291
|
+
❮
|
292
|
+
</button>
|
293
|
+
</div>
|
294
|
+
<h4>
|
295
|
+
${this.date.toLocaleString(this.locale, { month: "short" })} ${this.date.getFullYear()}
|
296
|
+
</h4>
|
297
|
+
<div
|
298
|
+
class="calendar-head__controls${this.range && this.classList.contains("start") ? " hide" : ""}"
|
299
|
+
>
|
300
|
+
<button
|
301
|
+
aria-label="Next month"
|
302
|
+
title="Next month"
|
303
|
+
@click="${() => {
|
304
|
+
this.emit("update-calendar-view", {
|
305
|
+
detail: l.PlainDate.from(c(this.date)).add({ months: 1 + this._secondCalendarOffset }).toString()
|
306
|
+
});
|
307
|
+
}}"
|
308
|
+
>
|
309
|
+
❯
|
310
|
+
</button>
|
311
|
+
<button
|
312
|
+
aria-label="Next year"
|
313
|
+
title="Next year"
|
314
|
+
@click="${() => {
|
315
|
+
this.emit("update-calendar-view", {
|
316
|
+
detail: l.PlainDate.from(c(this.date)).add({ months: 12 + this._secondCalendarOffset }).toString()
|
317
|
+
});
|
318
|
+
}}"
|
319
|
+
>
|
320
|
+
<div style="letter-spacing: -0.2em" aria-hidden="true" data-comp="icon">❯❯</div>
|
321
|
+
</button>
|
322
|
+
</div>
|
323
|
+
</div>`;
|
324
|
+
}
|
325
|
+
};
|
326
|
+
g.styles = [$, M];
|
327
|
+
let r = g;
|
328
|
+
n([
|
329
|
+
o({
|
330
|
+
converter: {
|
331
|
+
fromAttribute(h) {
|
332
|
+
return console.log("value", typeof h), new Date(h);
|
333
|
+
},
|
334
|
+
toAttribute(h) {
|
335
|
+
return h.toISOString();
|
336
|
+
}
|
337
|
+
}
|
338
|
+
})
|
339
|
+
], r.prototype, "date", 2);
|
340
|
+
n([
|
341
|
+
o()
|
342
|
+
], r.prototype, "eventid", 2);
|
343
|
+
n([
|
344
|
+
o({ type: Number })
|
345
|
+
], r.prototype, "firstDayOfWeek", 2);
|
346
|
+
n([
|
347
|
+
o({ reflect: !0, attribute: "invalid-dates" })
|
348
|
+
], r.prototype, "invalidDates", 2);
|
349
|
+
n([
|
350
|
+
o({ reflect: !0 })
|
351
|
+
], r.prototype, "locale", 2);
|
352
|
+
n([
|
353
|
+
o({ type: Boolean })
|
354
|
+
], r.prototype, "range", 2);
|
355
|
+
n([
|
356
|
+
o({ attribute: "selectable-from" })
|
357
|
+
], r.prototype, "selectableFrom", 2);
|
358
|
+
n([
|
359
|
+
o({ attribute: "selectable-to" })
|
360
|
+
], r.prototype, "selectableTo", 2);
|
361
|
+
n([
|
362
|
+
o({
|
363
|
+
attribute: "selected-date",
|
364
|
+
converter: { fromAttribute: (h) => new Date(h) },
|
365
|
+
reflect: !0
|
366
|
+
})
|
367
|
+
], r.prototype, "selectedDate", 2);
|
368
|
+
n([
|
369
|
+
o({ type: Object })
|
370
|
+
], r.prototype, "selectedDateRange", 2);
|
371
|
+
n([
|
372
|
+
b()
|
373
|
+
], r.prototype, "_numberOfDays", 2);
|
374
|
+
n([
|
375
|
+
b()
|
376
|
+
], r.prototype, "_numberOfDaysLastMonth", 2);
|
377
|
+
n([
|
378
|
+
S("date")
|
379
|
+
], r.prototype, "handleDateChange", 1);
|
380
|
+
export {
|
381
|
+
r as SkfDatePickerCalendar
|
382
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
@@ -0,0 +1,192 @@
|
|
1
|
+
import { css as e } from "lit";
|
2
|
+
const r = e`
|
3
|
+
@layer components {
|
4
|
+
:host {
|
5
|
+
box-sizing: inherit;
|
6
|
+
contain: layout;
|
7
|
+
display: block;
|
8
|
+
width: 100%;
|
9
|
+
}
|
10
|
+
|
11
|
+
:host([hidden]) {
|
12
|
+
display: none !important;
|
13
|
+
}
|
14
|
+
|
15
|
+
.grid {
|
16
|
+
display: grid;
|
17
|
+
grid-template-columns: repeat(7, 1fr);
|
18
|
+
list-style: none;
|
19
|
+
margin: 0;
|
20
|
+
padding: 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
h4 {
|
24
|
+
color: var(--title-fg);
|
25
|
+
font-size: 1.2em;
|
26
|
+
margin: 0;
|
27
|
+
padding: 0;
|
28
|
+
white-space: nowrap;
|
29
|
+
}
|
30
|
+
|
31
|
+
.weekdays > li {
|
32
|
+
color: var(--weekday-fg);
|
33
|
+
display: grid;
|
34
|
+
font-size: 1.2em;
|
35
|
+
margin-block: 1em 0.5em;
|
36
|
+
place-items: center;
|
37
|
+
user-select: none;
|
38
|
+
}
|
39
|
+
|
40
|
+
.calendar > li {
|
41
|
+
background-color: transparent;
|
42
|
+
border-radius: 0.2em;
|
43
|
+
display: grid;
|
44
|
+
min-width: 2.5em;
|
45
|
+
outline: 1px solid var(--day-outline);
|
46
|
+
place-items: center;
|
47
|
+
|
48
|
+
& button {
|
49
|
+
aspect-ratio: 1.2 / 1;
|
50
|
+
background-color: transparent;
|
51
|
+
border: 0;
|
52
|
+
border-radius: 0;
|
53
|
+
cursor: pointer;
|
54
|
+
display: grid;
|
55
|
+
font-size: 1.2em;
|
56
|
+
margin-block: 0.4em;
|
57
|
+
place-items: center;
|
58
|
+
transition: background-color 0.3s;
|
59
|
+
width: 100%;
|
60
|
+
|
61
|
+
&:focus-visible {
|
62
|
+
border-radius: 0.2em;
|
63
|
+
outline: 2px solid #469;
|
64
|
+
outline-offset: 2px;
|
65
|
+
}
|
66
|
+
|
67
|
+
&.today {
|
68
|
+
background-color: var(--today);
|
69
|
+
color: var(--today-fg);
|
70
|
+
}
|
71
|
+
|
72
|
+
&.in-range {
|
73
|
+
background-color: var(--in-range-bg);
|
74
|
+
}
|
75
|
+
|
76
|
+
&.selected {
|
77
|
+
background-color: var(--selected-bg);
|
78
|
+
color: var(--selected-fg);
|
79
|
+
}
|
80
|
+
|
81
|
+
&.selected-start {
|
82
|
+
border-radius: 5px 0 0 5px;
|
83
|
+
}
|
84
|
+
|
85
|
+
&.selected-end {
|
86
|
+
border-radius: 0 5px 5px 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
&.selected-start.selected-end {
|
90
|
+
border-radius: 5px;
|
91
|
+
}
|
92
|
+
|
93
|
+
&.prevmonth,
|
94
|
+
&.nextmonth {
|
95
|
+
color: var(--other-month-fg);
|
96
|
+
}
|
97
|
+
|
98
|
+
&:not(.selected):hover {
|
99
|
+
background-color: var(--hover-bg);
|
100
|
+
transition-duration: 0s;
|
101
|
+
}
|
102
|
+
|
103
|
+
&[disabled] {
|
104
|
+
cursor: not-allowed;
|
105
|
+
opacity: 0.5;
|
106
|
+
position: relative;
|
107
|
+
|
108
|
+
&::after {
|
109
|
+
background: linear-gradient(-45deg, transparent 45%, black 50%, transparent 50%);
|
110
|
+
content: '';
|
111
|
+
inset: 0;
|
112
|
+
position: absolute;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
.calendar-head {
|
119
|
+
align-items: baseline;
|
120
|
+
display: flex;
|
121
|
+
font-size: 1.2em;
|
122
|
+
gap: 0;
|
123
|
+
grid-template-columns: min-content auto min-content;
|
124
|
+
justify-content: space-between;
|
125
|
+
margin: 0 0 1em;
|
126
|
+
padding: 0;
|
127
|
+
position: relative;
|
128
|
+
|
129
|
+
&::after {
|
130
|
+
background-color: var(--border-color);
|
131
|
+
bottom: -0.8em;
|
132
|
+
content: '';
|
133
|
+
display: block;
|
134
|
+
grid-column: 1 / -1;
|
135
|
+
height: 1px;
|
136
|
+
left: 0;
|
137
|
+
margin-inline: calc(var(--calendar-padding) * -1);
|
138
|
+
position: absolute;
|
139
|
+
right: 0;
|
140
|
+
}
|
141
|
+
|
142
|
+
& .calendar-head__controls {
|
143
|
+
display: contents;
|
144
|
+
|
145
|
+
&.hide {
|
146
|
+
display: none;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
& h4 {
|
151
|
+
color: var(--title-fg);
|
152
|
+
font-size: 1.2em;
|
153
|
+
margin: 0;
|
154
|
+
padding: 0;
|
155
|
+
text-align: center;
|
156
|
+
white-space: nowrap;
|
157
|
+
}
|
158
|
+
|
159
|
+
& button {
|
160
|
+
background-color: transparent;
|
161
|
+
border: none;
|
162
|
+
color: var(--button-control-fg);
|
163
|
+
cursor: pointer;
|
164
|
+
min-width: 1.5em;
|
165
|
+
padding: 0.2em;
|
166
|
+
text-align: center;
|
167
|
+
|
168
|
+
&:focus-visible {
|
169
|
+
border-radius: 0.2em;
|
170
|
+
outline: 2px solid #469;
|
171
|
+
outline-offset: 2px;
|
172
|
+
}
|
173
|
+
|
174
|
+
& > div {
|
175
|
+
width: 1em;
|
176
|
+
}
|
177
|
+
|
178
|
+
&:hover {
|
179
|
+
color: var(--button-control-fg-hover);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
.hide {
|
185
|
+
pointer-events: none;
|
186
|
+
visibility: hidden;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
`;
|
190
|
+
export {
|
191
|
+
r as styles
|
192
|
+
};
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import '../button/button';
|
2
|
+
import { SkfElement } from '../../internal/components/skf-element.js';
|
3
|
+
import { type CSSResultGroup } from 'lit';
|
4
|
+
import './datepicker';
|
5
|
+
export interface SkfDatePickerDateRange {
|
6
|
+
start: Date | null;
|
7
|
+
end: Date | null;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* A date picker component that allows users to select a date or a range of dates.
|
11
|
+
*
|
12
|
+
* @element skf-datepicker
|
13
|
+
* @fires selected-date-changed - When a date is selected
|
14
|
+
* @fires selected-date-range-changed - When a range of dates is selected
|
15
|
+
*
|
16
|
+
* @prop {string} date - The date to display in the date picker
|
17
|
+
* @prop {boolean} range - If true, the date picker will allow the selection of a range of dates
|
18
|
+
* @prop {string} locale - The locale to use for formatting the date
|
19
|
+
*
|
20
|
+
* @slot - Default hint content placed inside the date picker
|
21
|
+
*
|
22
|
+
* @cssprop --max-width - The maximum width of the date picker
|
23
|
+
*/
|
24
|
+
export declare class SkfDatePicker extends SkfElement {
|
25
|
+
static styles: CSSResultGroup;
|
26
|
+
locale: string;
|
27
|
+
date: string;
|
28
|
+
id: string;
|
29
|
+
/**
|
30
|
+
* A comma-separated list of dates (yyyy-mm-dd format) that are not selectable.
|
31
|
+
*/
|
32
|
+
invalidDates?: string;
|
33
|
+
range: boolean;
|
34
|
+
selectedDate: Date | undefined;
|
35
|
+
/**
|
36
|
+
* Earliest selectable date. (yyyy-mm-dd format)
|
37
|
+
*/
|
38
|
+
selectableFrom?: string;
|
39
|
+
/**
|
40
|
+
* Latest selectable date. (yyyy-mm-dd format)
|
41
|
+
*/
|
42
|
+
selectableTo?: string;
|
43
|
+
selectedDateRange: SkfDatePickerDateRange;
|
44
|
+
/** @internal */
|
45
|
+
private _date?;
|
46
|
+
/** @internal */
|
47
|
+
_datePlusOneMonth: Date;
|
48
|
+
connectedCallback(): void;
|
49
|
+
protected firstUpdated(): void;
|
50
|
+
clearSelection(): void;
|
51
|
+
/** @internal */
|
52
|
+
private _handleCalendarView;
|
53
|
+
/** @internal */
|
54
|
+
private _handleSelectedDate;
|
55
|
+
/** @internal */
|
56
|
+
_onRangeCompleteEmitEvent(): void;
|
57
|
+
/** @internal */
|
58
|
+
_handleRangeChange(): void;
|
59
|
+
/** @internal */
|
60
|
+
_handleDateChange(): void;
|
61
|
+
/** @internal */
|
62
|
+
_handleSelectedDateRangeChange(): void;
|
63
|
+
/** @internal */
|
64
|
+
_handleSelectedDateChange(): void;
|
65
|
+
/** @internal */
|
66
|
+
_handleTodayClick: () => void;
|
67
|
+
render(): import("lit").TemplateResult<1>;
|
68
|
+
/** @internal */
|
69
|
+
private _renderTodayBtn;
|
70
|
+
/** @internal */
|
71
|
+
private _handleChangeCalendarView;
|
72
|
+
/** @internal */
|
73
|
+
private _animateView;
|
74
|
+
}
|