@cupra/ui-kit 2.0.0-canary.78 → 2.0.0-canary.80
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/cjs/components/ds-calendar/ds-calendar.cjs +26 -0
- package/dist/cjs/components/ds-calendar/styles/common.styles.cjs +38 -0
- package/dist/cjs/components/ds-calendar-day/ds-calendar-day.cjs +14 -0
- package/dist/cjs/components/ds-calendar-day/styles/common.styles.cjs +23 -0
- package/dist/cjs/components/ds-theme-provider/ds-theme-provider.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/IconsManager.cjs +1 -1
- package/dist/cjs/utils/PubSub.cjs +1 -1
- package/dist/cjs/utils/StylesRegistry/StylesRegistry.cjs +1 -1
- package/dist/cjs/utils/cssWithTokens.cjs +1 -1
- package/dist/cjs/utils/htmlWithTokens.cjs +1 -1
- package/dist/esm/components/ds-calendar/ds-calendar.js +276 -0
- package/dist/esm/components/ds-calendar/styles/common.styles.js +45 -0
- package/dist/esm/components/ds-calendar-day/ds-calendar-day.js +84 -0
- package/dist/esm/components/ds-calendar-day/styles/common.styles.js +30 -0
- package/dist/esm/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/utils/IconsManager.js +1 -1
- package/dist/esm/utils/PubSub.js +1 -1
- package/dist/esm/utils/StylesRegistry/StylesRegistry.js +1 -1
- package/dist/esm/utils/cssWithTokens.js +1 -1
- package/dist/esm/utils/htmlWithTokens.js +1 -1
- package/dist/types/components/ds-calendar/ds-calendar.d.ts +42 -0
- package/dist/types/components/ds-calendar/ds-calendar.test.d.ts +8 -0
- package/dist/types/components/ds-calendar/ds-calendar.types.d.ts +35 -0
- package/dist/types/components/ds-calendar/styles/common.styles.d.ts +1 -0
- package/dist/types/components/ds-calendar-day/ds-calendar-day.d.ts +20 -0
- package/dist/types/components/ds-calendar-day/ds-calendar-day.test.d.ts +8 -0
- package/dist/types/components/ds-calendar-day/ds-calendar-day.types.d.ts +10 -0
- package/dist/types/components/ds-calendar-day/styles/common.styles.d.ts +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist-react/cjs/components/ds-calendar/ds-calendar.cjs +26 -0
- package/dist-react/cjs/components/ds-calendar/styles/common.styles.cjs +38 -0
- package/dist-react/cjs/components/ds-calendar-day/ds-calendar-day.cjs +14 -0
- package/dist-react/cjs/components/ds-calendar-day/styles/common.styles.cjs +23 -0
- package/dist-react/cjs/components/ds-theme-provider/ds-theme-provider.cjs +1 -1
- package/dist-react/cjs/index.cjs +1 -1
- package/dist-react/cjs/utils/IconsManager.cjs +1 -1
- package/dist-react/cjs/utils/PubSub.cjs +1 -1
- package/dist-react/cjs/utils/StylesRegistry/StylesRegistry.cjs +1 -1
- package/dist-react/cjs/utils/cssWithTokens.cjs +1 -1
- package/dist-react/cjs/utils/htmlWithTokens.cjs +1 -1
- package/dist-react/esm/components/ds-calendar/ds-calendar.js +276 -0
- package/dist-react/esm/components/ds-calendar/styles/common.styles.js +45 -0
- package/dist-react/esm/components/ds-calendar-day/ds-calendar-day.js +84 -0
- package/dist-react/esm/components/ds-calendar-day/styles/common.styles.js +30 -0
- package/dist-react/esm/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist-react/esm/index.js +4 -2
- package/dist-react/esm/utils/IconsManager.js +1 -1
- package/dist-react/esm/utils/PubSub.js +1 -1
- package/dist-react/esm/utils/StylesRegistry/StylesRegistry.js +1 -1
- package/dist-react/esm/utils/cssWithTokens.js +1 -1
- package/dist-react/esm/utils/htmlWithTokens.js +1 -1
- package/dist-react/types/components/ds-calendar/ds-calendar.d.ts +42 -0
- package/dist-react/types/components/ds-calendar/ds-calendar.test.d.ts +8 -0
- package/dist-react/types/components/ds-calendar/ds-calendar.types.d.ts +35 -0
- package/dist-react/types/components/ds-calendar/styles/common.styles.d.ts +1 -0
- package/dist-react/types/components/ds-calendar-day/ds-calendar-day.d.ts +20 -0
- package/dist-react/types/components/ds-calendar-day/ds-calendar-day.test.d.ts +8 -0
- package/dist-react/types/components/ds-calendar-day/ds-calendar-day.types.d.ts +10 -0
- package/dist-react/types/components/ds-calendar-day/styles/common.styles.d.ts +1 -0
- package/dist-react/types/components/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { UiKitElement as b } from "../base/UiKitElement.js";
|
|
2
|
+
import "../ds-calendar-day/ds-calendar-day.js";
|
|
3
|
+
import { customUiKitElement as _ } from "../../decorators/customUiKitElement.js";
|
|
4
|
+
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
5
|
+
import { html as y } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
6
|
+
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
7
|
+
import { property as h } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
8
|
+
import { state as m } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
9
|
+
import { classMap as M } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
10
|
+
import { commonStyles as k } from "./styles/common.styles.js";
|
|
11
|
+
var S = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, l = (t, e, s, i) => {
|
|
12
|
+
for (var r = i > 1 ? void 0 : i ? $(e, s) : e, a = t.length - 1, o; a >= 0; a--)
|
|
13
|
+
(o = t[a]) && (r = (i ? o(e, s, r) : o(r)) || r);
|
|
14
|
+
return i && r && S(e, s, r), r;
|
|
15
|
+
};
|
|
16
|
+
let n = class extends b {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.variant = "plane", this.locale = "en-US", this.firstDayOfWeek = 1, this.disabledDates = [], this.disabledWeekdays = [], this._viewDate = /* @__PURE__ */ new Date(), this._value = null, this._initialValueApplied = !1;
|
|
19
|
+
}
|
|
20
|
+
get selectedDate() {
|
|
21
|
+
if (this.value) {
|
|
22
|
+
const t = this.parseDate(this.value);
|
|
23
|
+
if (t) return t;
|
|
24
|
+
}
|
|
25
|
+
return this._value;
|
|
26
|
+
}
|
|
27
|
+
get viewDate() {
|
|
28
|
+
return this._viewDate;
|
|
29
|
+
}
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
super.connectedCallback(), this.applyInitialValue(), this.initializeViewDate();
|
|
32
|
+
}
|
|
33
|
+
updated(t) {
|
|
34
|
+
super.updated(t), (t.has("value") || t.has("viewDateAttr")) && this.initializeViewDate();
|
|
35
|
+
}
|
|
36
|
+
applyInitialValue() {
|
|
37
|
+
if (!this._initialValueApplied && (this._initialValueApplied = !0, this.initialValue)) {
|
|
38
|
+
const t = this.parseDate(this.initialValue);
|
|
39
|
+
t && (this._value = t);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
initializeViewDate() {
|
|
43
|
+
if (this.viewDateAttr) {
|
|
44
|
+
const t = this.parseDate(this.viewDateAttr);
|
|
45
|
+
t && (this._viewDate = t);
|
|
46
|
+
} else if (this.value) {
|
|
47
|
+
const t = this.parseDate(this.value);
|
|
48
|
+
t && (this._viewDate = new Date(t));
|
|
49
|
+
} else this._value ? this._viewDate = new Date(this._value) : this._viewDate = /* @__PURE__ */ new Date();
|
|
50
|
+
}
|
|
51
|
+
parseDate(t) {
|
|
52
|
+
const e = t.split("-");
|
|
53
|
+
if (e.length >= 2) {
|
|
54
|
+
const s = Number.parseInt(e[0], 10), i = Number.parseInt(e[1], 10) - 1, r = e.length >= 3 ? Number.parseInt(e[2], 10) : 1, a = new Date(s, i, r);
|
|
55
|
+
if (!Number.isNaN(a.getTime()))
|
|
56
|
+
return a;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
get calendarClasses() {
|
|
61
|
+
return {
|
|
62
|
+
calendar: !0,
|
|
63
|
+
[this.variant]: !0
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
get weekdayNames() {
|
|
67
|
+
const t = new Intl.DateTimeFormat(this.locale, { weekday: "short" }), e = [], s = new Date(2024, 0, 1);
|
|
68
|
+
for (; s.getDay() !== this.firstDayOfWeek; )
|
|
69
|
+
s.setDate(s.getDate() + 1);
|
|
70
|
+
for (let i = 0; i < 7; i++) {
|
|
71
|
+
const r = new Date(s);
|
|
72
|
+
r.setDate(s.getDate() + i);
|
|
73
|
+
const a = t.format(r);
|
|
74
|
+
e.push(a.slice(0, 2));
|
|
75
|
+
}
|
|
76
|
+
return e;
|
|
77
|
+
}
|
|
78
|
+
get monthYearLabel() {
|
|
79
|
+
return new Intl.DateTimeFormat(this.locale, {
|
|
80
|
+
month: "long",
|
|
81
|
+
year: "numeric"
|
|
82
|
+
}).format(this._viewDate);
|
|
83
|
+
}
|
|
84
|
+
getDaysInMonth(t, e) {
|
|
85
|
+
return new Date(t, e + 1, 0).getDate();
|
|
86
|
+
}
|
|
87
|
+
getFirstDayOfMonth(t, e) {
|
|
88
|
+
return new Date(t, e, 1).getDay();
|
|
89
|
+
}
|
|
90
|
+
get calendarDays() {
|
|
91
|
+
const t = this._viewDate.getFullYear(), e = this._viewDate.getMonth(), s = /* @__PURE__ */ new Date();
|
|
92
|
+
s.setHours(0, 0, 0, 0);
|
|
93
|
+
const i = this.getDaysInMonth(t, e);
|
|
94
|
+
let a = this.getFirstDayOfMonth(t, e) - this.firstDayOfWeek;
|
|
95
|
+
a < 0 && (a += 7);
|
|
96
|
+
const o = [], c = e === 0 ? 11 : e - 1, u = e === 0 ? t - 1 : t, p = this.getDaysInMonth(u, c);
|
|
97
|
+
for (let d = a - 1; d >= 0; d--) {
|
|
98
|
+
const D = p - d, w = new Date(u, c, D);
|
|
99
|
+
o.push(this.createCalendarDay(w, !1, s));
|
|
100
|
+
}
|
|
101
|
+
for (let d = 1; d <= i; d++) {
|
|
102
|
+
const D = new Date(t, e, d);
|
|
103
|
+
o.push(this.createCalendarDay(D, !0, s));
|
|
104
|
+
}
|
|
105
|
+
const f = 42 - o.length, v = e === 11 ? 0 : e + 1, g = e === 11 ? t + 1 : t;
|
|
106
|
+
for (let d = 1; d <= f; d++) {
|
|
107
|
+
const D = new Date(g, v, d);
|
|
108
|
+
o.push(this.createCalendarDay(D, !1, s));
|
|
109
|
+
}
|
|
110
|
+
return o;
|
|
111
|
+
}
|
|
112
|
+
createCalendarDay(t, e, s) {
|
|
113
|
+
t.setHours(0, 0, 0, 0);
|
|
114
|
+
const i = t.getDate(), r = t.getMonth(), a = t.getFullYear(), o = i === s.getDate() && r === s.getMonth() && a === s.getFullYear(), c = this.selectedDate, u = c ? i === c.getDate() && r === c.getMonth() && a === c.getFullYear() : !1, p = !e || this.isDateDisabled(t);
|
|
115
|
+
return {
|
|
116
|
+
day: i,
|
|
117
|
+
month: r,
|
|
118
|
+
year: a,
|
|
119
|
+
date: t,
|
|
120
|
+
isCurrentMonth: e,
|
|
121
|
+
isToday: o,
|
|
122
|
+
isSelected: u,
|
|
123
|
+
isDisabled: p
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
isDateDisabled(t) {
|
|
127
|
+
if (this.minDate) {
|
|
128
|
+
const e = new Date(this.minDate);
|
|
129
|
+
if (e.setHours(0, 0, 0, 0), t < e) return !0;
|
|
130
|
+
}
|
|
131
|
+
if (this.maxDate) {
|
|
132
|
+
const e = new Date(this.maxDate);
|
|
133
|
+
if (e.setHours(0, 0, 0, 0), t > e) return !0;
|
|
134
|
+
}
|
|
135
|
+
if (this.disabledWeekdays && this.disabledWeekdays.length > 0) {
|
|
136
|
+
const e = t.getDay();
|
|
137
|
+
if (this.disabledWeekdays.includes(e)) return !0;
|
|
138
|
+
}
|
|
139
|
+
if (this.disabledDates && this.disabledDates.length > 0) {
|
|
140
|
+
const e = t.toISOString().split("T")[0];
|
|
141
|
+
if (this.disabledDates.includes(e)) return !0;
|
|
142
|
+
}
|
|
143
|
+
return !1;
|
|
144
|
+
}
|
|
145
|
+
handlePrevMonth() {
|
|
146
|
+
const t = new Date(this._viewDate);
|
|
147
|
+
t.setMonth(t.getMonth() - 1), this._viewDate = t;
|
|
148
|
+
}
|
|
149
|
+
handleNextMonth() {
|
|
150
|
+
const t = new Date(this._viewDate);
|
|
151
|
+
t.setMonth(t.getMonth() + 1), this._viewDate = t;
|
|
152
|
+
}
|
|
153
|
+
handleDayChange(t) {
|
|
154
|
+
var f;
|
|
155
|
+
t.stopPropagation();
|
|
156
|
+
const e = t.target;
|
|
157
|
+
if (!e || !e.tagName.toLowerCase().startsWith("ds-calendar-day")) return;
|
|
158
|
+
const i = Array.from(((f = this.shadowRoot) == null ? void 0 : f.querySelectorAll("ds-calendar-day")) || []).indexOf(e);
|
|
159
|
+
if (i === -1) return;
|
|
160
|
+
const a = this.calendarDays[i];
|
|
161
|
+
if (!a || a.isDisabled) return;
|
|
162
|
+
this._value = a.date, this._viewDate = new Date(a.date);
|
|
163
|
+
const o = a.date.getFullYear(), c = String(a.date.getMonth() + 1).padStart(2, "0"), u = String(a.date.getDate()).padStart(2, "0"), p = `${o}-${c}-${u}`;
|
|
164
|
+
this.dispatchEvent(
|
|
165
|
+
new CustomEvent("ds-calendar-change", {
|
|
166
|
+
bubbles: !0,
|
|
167
|
+
composed: !0,
|
|
168
|
+
detail: {
|
|
169
|
+
value: p,
|
|
170
|
+
date: a.date
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
get prevButtonTemplate() {
|
|
176
|
+
return this.componentFactory.createIconButton({
|
|
177
|
+
class: "nav-button",
|
|
178
|
+
"icon-name": "arrow-left",
|
|
179
|
+
"data-aria-label": "Previous month",
|
|
180
|
+
"@click": this.handlePrevMonth,
|
|
181
|
+
variant: "naked",
|
|
182
|
+
size: "medium",
|
|
183
|
+
color: "var(--ds-icon-button-icon-color-standard-default, #fafafa)"
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
get nextButtonTemplate() {
|
|
187
|
+
return this.componentFactory.createIconButton({
|
|
188
|
+
class: "nav-button",
|
|
189
|
+
"icon-name": "arrow-right",
|
|
190
|
+
"data-aria-label": "Next month",
|
|
191
|
+
"@click": this.handleNextMonth,
|
|
192
|
+
variant: "naked",
|
|
193
|
+
size: "medium",
|
|
194
|
+
color: "var(--ds-icon-button-icon-color-standard-default, #fafafa)"
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
get weekdaysTemplate() {
|
|
198
|
+
return y`
|
|
199
|
+
<div class="weekdays">
|
|
200
|
+
${this.weekdayNames.map((t) => y`<div class="weekday">${t}</div>`)}
|
|
201
|
+
</div>
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
get daysTemplate() {
|
|
205
|
+
return y`
|
|
206
|
+
<div class="days-grid" @ds-calendar-day-change=${this.handleDayChange}>
|
|
207
|
+
${this.calendarDays.map(
|
|
208
|
+
(t) => y`
|
|
209
|
+
<ds-calendar-day
|
|
210
|
+
day=${t.day}
|
|
211
|
+
?disabled=${t.isDisabled}
|
|
212
|
+
?selected=${t.isSelected}
|
|
213
|
+
?today=${t.isToday}
|
|
214
|
+
?outside-month=${!t.isCurrentMonth}
|
|
215
|
+
></ds-calendar-day>
|
|
216
|
+
`
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
`;
|
|
220
|
+
}
|
|
221
|
+
render() {
|
|
222
|
+
return y`
|
|
223
|
+
<div class=${M(this.calendarClasses)} role="application" aria-label="Calendar">
|
|
224
|
+
<div class="header">
|
|
225
|
+
${this.prevButtonTemplate}
|
|
226
|
+
<div class="month-year" aria-live="polite">${this.monthYearLabel}</div>
|
|
227
|
+
${this.nextButtonTemplate}
|
|
228
|
+
</div>
|
|
229
|
+
${this.weekdaysTemplate} ${this.daysTemplate}
|
|
230
|
+
</div>
|
|
231
|
+
`;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
n.styles = [k];
|
|
235
|
+
l([
|
|
236
|
+
h({ type: String, reflect: !0 })
|
|
237
|
+
], n.prototype, "value", 2);
|
|
238
|
+
l([
|
|
239
|
+
h({ type: String, reflect: !0 })
|
|
240
|
+
], n.prototype, "variant", 2);
|
|
241
|
+
l([
|
|
242
|
+
h({ type: String, reflect: !0 })
|
|
243
|
+
], n.prototype, "locale", 2);
|
|
244
|
+
l([
|
|
245
|
+
h({ type: Number, reflect: !0, attribute: "first-day-of-week" })
|
|
246
|
+
], n.prototype, "firstDayOfWeek", 2);
|
|
247
|
+
l([
|
|
248
|
+
h({ type: String, reflect: !0, attribute: "min-date" })
|
|
249
|
+
], n.prototype, "minDate", 2);
|
|
250
|
+
l([
|
|
251
|
+
h({ type: String, reflect: !0, attribute: "max-date" })
|
|
252
|
+
], n.prototype, "maxDate", 2);
|
|
253
|
+
l([
|
|
254
|
+
h({ type: Array, attribute: "disabled-dates" })
|
|
255
|
+
], n.prototype, "disabledDates", 2);
|
|
256
|
+
l([
|
|
257
|
+
h({ type: Array, attribute: "disabled-weekdays" })
|
|
258
|
+
], n.prototype, "disabledWeekdays", 2);
|
|
259
|
+
l([
|
|
260
|
+
h({ type: String, reflect: !0, attribute: "view-date" })
|
|
261
|
+
], n.prototype, "viewDateAttr", 2);
|
|
262
|
+
l([
|
|
263
|
+
h({ type: String, attribute: "initial-value" })
|
|
264
|
+
], n.prototype, "initialValue", 2);
|
|
265
|
+
l([
|
|
266
|
+
m()
|
|
267
|
+
], n.prototype, "_viewDate", 2);
|
|
268
|
+
l([
|
|
269
|
+
m()
|
|
270
|
+
], n.prototype, "_value", 2);
|
|
271
|
+
n = l([
|
|
272
|
+
_("ds-calendar")
|
|
273
|
+
], n);
|
|
274
|
+
export {
|
|
275
|
+
n as DsCalendar
|
|
276
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
2
|
+
import "../../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
3
|
+
import "../../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
|
+
import { css as e } from "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
5
|
+
const n = e`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.calendar {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.month-year {
|
|
23
|
+
flex: 1;
|
|
24
|
+
text-align: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.weekdays {
|
|
28
|
+
display: grid;
|
|
29
|
+
grid-template-columns: repeat(7, 1fr);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.weekday {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.days-grid {
|
|
39
|
+
display: grid;
|
|
40
|
+
grid-template-columns: repeat(7, 1fr);
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
export {
|
|
44
|
+
n as commonStyles
|
|
45
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { UiKitElement as c } from "../base/UiKitElement.js";
|
|
2
|
+
import { customUiKitElement as h } from "../../decorators/customUiKitElement.js";
|
|
3
|
+
import { booleanConverter as l } from "../../utils/booleanConverter.js";
|
|
4
|
+
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
5
|
+
import { html as y } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
6
|
+
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
7
|
+
import { property as o } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
8
|
+
import { classMap as u } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
9
|
+
import { commonStyles as m } from "./styles/common.styles.js";
|
|
10
|
+
var f = Object.defineProperty, b = Object.getOwnPropertyDescriptor, s = (e, a, d, i) => {
|
|
11
|
+
for (var r = i > 1 ? void 0 : i ? b(a, d) : a, n = e.length - 1, p; n >= 0; n--)
|
|
12
|
+
(p = e[n]) && (r = (i ? p(a, d, r) : p(r)) || r);
|
|
13
|
+
return i && r && f(a, d, r), r;
|
|
14
|
+
};
|
|
15
|
+
let t = class extends c {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments), this.disabled = !1, this.selected = !1, this.today = !1, this.outsideMonth = !1;
|
|
18
|
+
}
|
|
19
|
+
get classes() {
|
|
20
|
+
return {
|
|
21
|
+
day: !0,
|
|
22
|
+
disabled: this.disabled,
|
|
23
|
+
selected: this.selected,
|
|
24
|
+
today: this.today,
|
|
25
|
+
"outside-month": this.outsideMonth
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
handleClick(e) {
|
|
29
|
+
if (this.disabled) {
|
|
30
|
+
e.preventDefault(), e.stopPropagation();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.dispatchEvent(
|
|
34
|
+
new CustomEvent("ds-calendar-day-change", {
|
|
35
|
+
bubbles: !0,
|
|
36
|
+
composed: !0,
|
|
37
|
+
detail: {
|
|
38
|
+
day: this.day
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
handleKeyDown(e) {
|
|
44
|
+
this.disabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.handleClick(e));
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
return y`
|
|
48
|
+
<button
|
|
49
|
+
class=${u(this.classes)}
|
|
50
|
+
?disabled=${this.disabled}
|
|
51
|
+
aria-label=${this.day ? `Day ${this.day}` : ""}
|
|
52
|
+
aria-selected=${this.selected}
|
|
53
|
+
aria-current=${this.today ? "date" : "false"}
|
|
54
|
+
tabindex=${this.disabled ? -1 : 0}
|
|
55
|
+
@click=${this.handleClick}
|
|
56
|
+
@keydown=${this.handleKeyDown}
|
|
57
|
+
>
|
|
58
|
+
${this.day}
|
|
59
|
+
</button>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
t.styles = [m];
|
|
64
|
+
s([
|
|
65
|
+
o({ type: Number, reflect: !0 })
|
|
66
|
+
], t.prototype, "day", 2);
|
|
67
|
+
s([
|
|
68
|
+
o({ type: Boolean, converter: l, reflect: !0 })
|
|
69
|
+
], t.prototype, "disabled", 2);
|
|
70
|
+
s([
|
|
71
|
+
o({ type: Boolean, converter: l, reflect: !0 })
|
|
72
|
+
], t.prototype, "selected", 2);
|
|
73
|
+
s([
|
|
74
|
+
o({ type: Boolean, converter: l, reflect: !0 })
|
|
75
|
+
], t.prototype, "today", 2);
|
|
76
|
+
s([
|
|
77
|
+
o({ type: Boolean, converter: l, reflect: !0, attribute: "outside-month" })
|
|
78
|
+
], t.prototype, "outsideMonth", 2);
|
|
79
|
+
t = s([
|
|
80
|
+
h("ds-calendar-day")
|
|
81
|
+
], t);
|
|
82
|
+
export {
|
|
83
|
+
t as DsCalendarDay
|
|
84
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
2
|
+
import "../../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
3
|
+
import "../../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
|
+
import { css as e } from "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
5
|
+
const t = e`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.day {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
user-select: none;
|
|
17
|
+
border: none;
|
|
18
|
+
background: none;
|
|
19
|
+
padding: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.day.disabled {
|
|
24
|
+
cursor: default;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
export {
|
|
29
|
+
t as commonStyles
|
|
30
|
+
};
|
|
@@ -54,7 +54,7 @@ let m = class extends v {
|
|
|
54
54
|
}
|
|
55
55
|
loadThemeStyles() {
|
|
56
56
|
return this.loadStyles ? new Promise((t, o) => {
|
|
57
|
-
const s = "/2.0.0-canary.
|
|
57
|
+
const s = "/2.0.0-canary.80", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
|
|
58
58
|
if (document.head.querySelector(`link[href="${r}"]`)) t();
|
|
59
59
|
else {
|
|
60
60
|
const e = `ui-kit-theme-${s}`, a = document.getElementById(e), n = document.createElement("link");
|
package/dist-react/esm/index.js
CHANGED
|
@@ -9,6 +9,8 @@ import "./components/ds-breadcrumbs/ds-breadcrumbs.js";
|
|
|
9
9
|
import "./components/ds-breadcrumbs-item/ds-breadcrumbs-item.js";
|
|
10
10
|
import "./components/ds-bullets/ds-bullets.js";
|
|
11
11
|
import "./components/ds-button/ds-button.js";
|
|
12
|
+
import "./components/ds-calendar/ds-calendar.js";
|
|
13
|
+
import "./components/ds-calendar-day/ds-calendar-day.js";
|
|
12
14
|
import "./components/ds-carousel-indicator/ds-carousel-indicator.js";
|
|
13
15
|
import "./components/ds-checkbox/ds-checkbox.js";
|
|
14
16
|
import "./components/ds-checkbox-group/ds-checkbox-group.js";
|
|
@@ -77,7 +79,7 @@ import "./components/ds-navigation-controls/ds-navigation-controls.js";
|
|
|
77
79
|
import "./components/ds-table/ds-table.js";
|
|
78
80
|
import "./components/ds-table-row/ds-table-row.js";
|
|
79
81
|
import "./components/ds-table-cell/ds-table-cell.js";
|
|
80
|
-
import { iconNames as
|
|
82
|
+
import { iconNames as Do } from "./components/ds-icon/iconNames.js";
|
|
81
83
|
export {
|
|
82
|
-
|
|
84
|
+
Do as iconNames
|
|
83
85
|
};
|
|
@@ -25,7 +25,7 @@ class l {
|
|
|
25
25
|
}), f.subscribe("theme", this.handleChangeTheme);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const c = Symbol.for("@cupra/ui-kit/icons-manager/2.0.0-canary.
|
|
28
|
+
const c = Symbol.for("@cupra/ui-kit/icons-manager/2.0.0-canary.80"), h = globalThis;
|
|
29
29
|
let i = h[c];
|
|
30
30
|
i || (i = new l(), Object.defineProperty(h, c, {
|
|
31
31
|
value: i,
|
|
@@ -18,7 +18,7 @@ class e {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
const u = Symbol.for("@cupra/ui-kit/pubsub/2.0.0-canary.
|
|
21
|
+
const u = Symbol.for("@cupra/ui-kit/pubsub/2.0.0-canary.80"), t = globalThis;
|
|
22
22
|
let b = t[u];
|
|
23
23
|
b || (b = new e(), Object.defineProperty(t, u, {
|
|
24
24
|
value: b,
|
|
@@ -7,7 +7,7 @@ class s {
|
|
|
7
7
|
theme: t
|
|
8
8
|
}) => {
|
|
9
9
|
if (!t || !e) return;
|
|
10
|
-
const c = `https://ds-assets.cupra.com/2.0.0-canary.
|
|
10
|
+
const c = `https://ds-assets.cupra.com/2.0.0-canary.80/styles/${t}/components/${e}.css`, r = this.getCachedStyleSheetPromise({ url: c });
|
|
11
11
|
if (r) return r;
|
|
12
12
|
const i = h(() => this.fetchStyle({ url: c })).then((n) => (n || this.stylePromises.delete(c), n));
|
|
13
13
|
return this.stylePromises.set(c, i), this.stylePromises.get(c);
|
|
@@ -3,7 +3,7 @@ import "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
|
3
3
|
import "../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
4
|
import { unsafeCSS as n, css as o } from "../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
|
|
5
5
|
function x(t, ...r) {
|
|
6
|
-
const e = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-
|
|
6
|
+
const e = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-80"), i = n(e);
|
|
7
7
|
return o`${i}`;
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
@@ -3,7 +3,7 @@ import { html as n } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit
|
|
|
3
3
|
import "../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
4
4
|
import { unsafeHTML as i } from "../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/unsafe-html.js";
|
|
5
5
|
function x(t, ...r) {
|
|
6
|
-
const o = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-
|
|
6
|
+
const o = String.raw({ raw: t }, ...r).replace(/(--private-[\w-]+)(?=\s*[):,])/g, "$1-v2-0-0-canary-80"), e = i(o);
|
|
7
7
|
return n`${e}`;
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UiKitElement } from '../base/UiKitElement.ts';
|
|
2
|
+
import '../ds-calendar-day/ds-calendar-day.ts';
|
|
3
|
+
import type { DsCalendarAttrs, DsCalendarVariant, WeekDay } from './ds-calendar.types';
|
|
4
|
+
export declare class DsCalendar extends UiKitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
value: DsCalendarAttrs['value'];
|
|
7
|
+
variant: DsCalendarVariant;
|
|
8
|
+
locale: DsCalendarAttrs['locale'];
|
|
9
|
+
firstDayOfWeek: WeekDay;
|
|
10
|
+
minDate: DsCalendarAttrs['min-date'];
|
|
11
|
+
maxDate: DsCalendarAttrs['max-date'];
|
|
12
|
+
disabledDates: DsCalendarAttrs['disabled-dates'];
|
|
13
|
+
disabledWeekdays: DsCalendarAttrs['disabled-weekdays'];
|
|
14
|
+
viewDateAttr: DsCalendarAttrs['view-date'];
|
|
15
|
+
initialValue: DsCalendarAttrs['initial-value'];
|
|
16
|
+
private _viewDate;
|
|
17
|
+
private _value;
|
|
18
|
+
private _initialValueApplied;
|
|
19
|
+
private get selectedDate();
|
|
20
|
+
get viewDate(): Date;
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
updated(changedProperties: Map<string, unknown>): void;
|
|
23
|
+
private applyInitialValue;
|
|
24
|
+
private initializeViewDate;
|
|
25
|
+
private parseDate;
|
|
26
|
+
private get calendarClasses();
|
|
27
|
+
private get weekdayNames();
|
|
28
|
+
private get monthYearLabel();
|
|
29
|
+
private getDaysInMonth;
|
|
30
|
+
private getFirstDayOfMonth;
|
|
31
|
+
private get calendarDays();
|
|
32
|
+
private createCalendarDay;
|
|
33
|
+
private isDateDisabled;
|
|
34
|
+
private handlePrevMonth;
|
|
35
|
+
private handleNextMonth;
|
|
36
|
+
private handleDayChange;
|
|
37
|
+
private get prevButtonTemplate();
|
|
38
|
+
private get nextButtonTemplate();
|
|
39
|
+
private get weekdaysTemplate();
|
|
40
|
+
private get daysTemplate();
|
|
41
|
+
render(): import("lit").TemplateResult<1>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CommonAttrs } from '../../types/types';
|
|
2
|
+
export type DsCalendarVariant = 'plane' | 'elevated';
|
|
3
|
+
export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
export interface DsCalendarAttrs extends CommonAttrs {
|
|
5
|
+
/** Selected date in ISO format (YYYY-MM-DD) */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Visual style variant */
|
|
8
|
+
variant?: DsCalendarVariant;
|
|
9
|
+
/** BCP 47 locale for formatting (e.g., 'es-ES', 'en-US') */
|
|
10
|
+
locale?: string;
|
|
11
|
+
/** First day of week (0=Sunday, 1=Monday, etc.) */
|
|
12
|
+
'first-day-of-week'?: WeekDay;
|
|
13
|
+
/** Minimum selectable date (YYYY-MM-DD) */
|
|
14
|
+
'min-date'?: string;
|
|
15
|
+
/** Maximum selectable date (YYYY-MM-DD) */
|
|
16
|
+
'max-date'?: string;
|
|
17
|
+
/** Array of specific dates to disable (YYYY-MM-DD) */
|
|
18
|
+
'disabled-dates'?: string[];
|
|
19
|
+
/** Array of weekdays to disable (0=Sunday, 6=Saturday) */
|
|
20
|
+
'disabled-weekdays'?: WeekDay[];
|
|
21
|
+
/** Month/year to display (YYYY-MM or YYYY-MM-DD). Overrides value for view. */
|
|
22
|
+
'view-date'?: string;
|
|
23
|
+
/** Initial value for uncontrolled mode (YYYY-MM-DD). Applied once on mount. */
|
|
24
|
+
'initial-value'?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CalendarDay {
|
|
27
|
+
day: number;
|
|
28
|
+
month: number;
|
|
29
|
+
year: number;
|
|
30
|
+
date: Date;
|
|
31
|
+
isCurrentMonth: boolean;
|
|
32
|
+
isToday: boolean;
|
|
33
|
+
isSelected: boolean;
|
|
34
|
+
isDisabled: boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const commonStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UiKitElement } from '../base/UiKitElement.ts';
|
|
2
|
+
import type { DsCalendarDayAttrs } from './ds-calendar-day.types';
|
|
3
|
+
export declare class DsCalendarDay extends UiKitElement {
|
|
4
|
+
static styles: import("lit").CSSResult[];
|
|
5
|
+
day: DsCalendarDayAttrs['day'];
|
|
6
|
+
disabled: DsCalendarDayAttrs['disabled'];
|
|
7
|
+
selected: DsCalendarDayAttrs['selected'];
|
|
8
|
+
today: DsCalendarDayAttrs['today'];
|
|
9
|
+
outsideMonth: DsCalendarDayAttrs['outside-month'];
|
|
10
|
+
protected get classes(): {
|
|
11
|
+
day: boolean;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
selected: boolean;
|
|
14
|
+
today: boolean;
|
|
15
|
+
'outside-month': boolean;
|
|
16
|
+
};
|
|
17
|
+
private handleClick;
|
|
18
|
+
private handleKeyDown;
|
|
19
|
+
render(): import("lit").TemplateResult<1>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommonAttrs } from '../../types/types';
|
|
2
|
+
export type DsCalendarDayState = 'default' | 'hover' | 'pressed' | 'disabled' | 'selected' | 'today';
|
|
3
|
+
export interface DsCalendarDayAttrs extends CommonAttrs {
|
|
4
|
+
day?: number;
|
|
5
|
+
state?: DsCalendarDayState;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
today?: boolean;
|
|
9
|
+
'outside-month'?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const commonStyles: import("lit").CSSResult;
|
|
@@ -9,6 +9,8 @@ import './ds-breadcrumbs/ds-breadcrumbs.ts';
|
|
|
9
9
|
import './ds-breadcrumbs-item/ds-breadcrumbs-item.ts';
|
|
10
10
|
import './ds-bullets/ds-bullets.ts';
|
|
11
11
|
import './ds-button/ds-button.ts';
|
|
12
|
+
import './ds-calendar/ds-calendar.ts';
|
|
13
|
+
import './ds-calendar-day/ds-calendar-day.ts';
|
|
12
14
|
import './ds-carousel-indicator/ds-carousel-indicator.ts';
|
|
13
15
|
import './ds-checkbox/ds-checkbox.ts';
|
|
14
16
|
import './ds-checkbox-group/ds-checkbox-group.ts';
|