kanto-ds 1.5.2 → 1.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.
Files changed (125) hide show
  1. package/README.md +10 -10
  2. package/dist/chunks/floating-B33g-M_1.js +63 -0
  3. package/dist/chunks/floating-B33g-M_1.js.map +1 -0
  4. package/dist/chunks/{index-STEEvEP7.js → index-TWJzttLX.js} +38 -15
  5. package/dist/chunks/index-TWJzttLX.js.map +1 -0
  6. package/dist/chunks/kt-calendar-CtwOby1R.js +780 -0
  7. package/dist/chunks/kt-calendar-CtwOby1R.js.map +1 -0
  8. package/dist/chunks/{kt-element-Djx2JcGl.js → kt-element-T0VbIBNp.js} +2 -2
  9. package/dist/chunks/{kt-element-Djx2JcGl.js.map → kt-element-T0VbIBNp.js.map} +1 -1
  10. package/dist/chunks/{listbox-llcUu_V-.js → listbox-LsUEyGhQ.js} +2 -2
  11. package/dist/chunks/{listbox-llcUu_V-.js.map → listbox-LsUEyGhQ.js.map} +1 -1
  12. package/dist/chunks/segmented-field-BBXR4XFL.js +384 -0
  13. package/dist/chunks/segmented-field-BBXR4XFL.js.map +1 -0
  14. package/dist/chunks/typed-date-CPAUNHzr.js +103 -0
  15. package/dist/chunks/typed-date-CPAUNHzr.js.map +1 -0
  16. package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
  17. package/dist/components/core/kt-badge/kt-badge.js +2 -2
  18. package/dist/components/core/kt-button/kt-button.js +1 -1
  19. package/dist/components/core/kt-card/kt-card.js +1 -1
  20. package/dist/components/core/kt-code/kt-code.js +13 -13
  21. package/dist/components/core/kt-code/kt-code.js.map +1 -1
  22. package/dist/components/core/kt-icon/kt-icon.js +1 -1
  23. package/dist/components/core/kt-kbd/kt-kbd.js +5 -5
  24. package/dist/components/core/kt-kbd/kt-kbd.js.map +1 -1
  25. package/dist/components/core/kt-split-button/kt-split-button.js +3 -3
  26. package/dist/components/data/kt-chart/kt-chart.js +3 -3
  27. package/dist/components/data/kt-chart/kt-chart.js.map +1 -1
  28. package/dist/components/data/kt-meter/kt-meter.js +1 -1
  29. package/dist/components/data/kt-pagination/kt-pagination.js +2 -2
  30. package/dist/components/data/kt-stat/kt-stat.js +1 -1
  31. package/dist/components/data/kt-table/kt-table.js +85 -85
  32. package/dist/components/data/kt-table/kt-table.js.map +1 -1
  33. package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
  34. package/dist/components/feedback/kt-alert/kt-alert.js +15 -15
  35. package/dist/components/feedback/kt-alert/kt-alert.js.map +1 -1
  36. package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
  37. package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +1 -1
  38. package/dist/components/feedback/kt-skeleton/kt-skeleton.js +13 -13
  39. package/dist/components/feedback/kt-skeleton/kt-skeleton.js.map +1 -1
  40. package/dist/components/feedback/kt-toast/kt-toast.js +3 -3
  41. package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
  42. package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
  43. package/dist/components/feedback/kt-tooltip/kt-tooltip.js +1 -1
  44. package/dist/components/forms/kt-calendar/kt-calendar.d.ts +35 -9
  45. package/dist/components/forms/kt-calendar/kt-calendar.js +3 -3
  46. package/dist/components/forms/kt-checkbox/kt-checkbox.js +2 -2
  47. package/dist/components/forms/kt-date-input/kt-date-input.d.ts +65 -0
  48. package/dist/components/forms/kt-date-input/kt-date-input.js +241 -0
  49. package/dist/components/forms/kt-date-input/kt-date-input.js.map +1 -0
  50. package/dist/components/forms/kt-date-picker/kt-date-picker.d.ts +47 -3
  51. package/dist/components/forms/kt-date-picker/kt-date-picker.js +430 -199
  52. package/dist/components/forms/kt-date-picker/kt-date-picker.js.map +1 -1
  53. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +3 -3
  54. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
  55. package/dist/components/forms/kt-form/kt-form.js +2 -2
  56. package/dist/components/forms/kt-input/kt-input.js +10 -10
  57. package/dist/components/forms/kt-input/kt-input.js.map +1 -1
  58. package/dist/components/forms/kt-input-menu/kt-input-menu.js +4 -4
  59. package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
  60. package/dist/components/forms/kt-multi-select/kt-multi-select.d.ts +113 -0
  61. package/dist/components/forms/kt-multi-select/kt-multi-select.js +532 -0
  62. package/dist/components/forms/kt-multi-select/kt-multi-select.js.map +1 -0
  63. package/dist/components/forms/kt-radio-group/kt-radio-group.js +56 -51
  64. package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -1
  65. package/dist/components/forms/kt-select/kt-select.js +4 -4
  66. package/dist/components/forms/kt-textarea/kt-textarea.js +2 -2
  67. package/dist/components/forms/kt-time-input/kt-time-input.d.ts +48 -0
  68. package/dist/components/forms/kt-time-input/kt-time-input.js +114 -0
  69. package/dist/components/forms/kt-time-input/kt-time-input.js.map +1 -0
  70. package/dist/components/forms/kt-toggle/kt-toggle.js +1 -1
  71. package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +6 -6
  72. package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js.map +1 -1
  73. package/dist/components/navigation/kt-header/kt-header.js +2 -2
  74. package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
  75. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +2 -2
  76. package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +2 -2
  77. package/dist/components/navigation/kt-tabs/kt-tabs.js +2 -2
  78. package/dist/components/navigation/kt-tabs/kt-tabs.js.map +1 -1
  79. package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +1 -1
  80. package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +2 -2
  81. package/dist/components/overlays/kt-collapsible/kt-collapsible.js +3 -3
  82. package/dist/components/overlays/kt-collapsible/kt-collapsible.js.map +1 -1
  83. package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +2 -2
  84. package/dist/components/overlays/kt-dropdown/kt-dropdown.js +24 -24
  85. package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
  86. package/dist/components/overlays/kt-modal/kt-modal.js +2 -2
  87. package/dist/components/overlays/kt-side-panel/kt-side-panel.js +2 -2
  88. package/dist/custom-elements.json +2230 -842
  89. package/dist/index.d.ts +9 -1
  90. package/dist/index.js +316 -109
  91. package/dist/index.js.map +1 -1
  92. package/dist/internal/floating.d.ts +3 -0
  93. package/dist/internal/segmented-field.d.ts +114 -0
  94. package/dist/internal/segments.d.ts +30 -0
  95. package/dist/internal/strings.d.ts +30 -0
  96. package/dist/internal/typed-date.d.ts +33 -0
  97. package/dist/react/index.d.ts +23 -0
  98. package/dist/react/index.js +193 -169
  99. package/dist/react/index.js.map +1 -1
  100. package/dist/react/jsx.d.ts +20 -1
  101. package/dist/strings/index.js +1 -1
  102. package/dist/theme/accent.d.ts +51 -0
  103. package/dist/theme/appearance.d.ts +37 -0
  104. package/dist/tokens/README.md +100 -1
  105. package/dist/tokens/accents.css +80 -0
  106. package/dist/tokens/appearance.css +65 -0
  107. package/dist/tokens/base.css +3 -0
  108. package/dist/tokens/colors.css +78 -25
  109. package/dist/tokens/index.css +2 -0
  110. package/dist/tokens/responsive.css +160 -75
  111. package/dist/tokens/spacing.css +47 -28
  112. package/dist/tokens/theme-light.css +124 -38
  113. package/dist/tokens/typography.css +20 -13
  114. package/dist/vscode.css-custom-data.json +36 -1
  115. package/dist/vscode.html-custom-data.json +67 -2
  116. package/dist/vue/index.d.ts +6 -0
  117. package/dist/vue/index.js +11 -8
  118. package/dist/vue/index.js.map +1 -1
  119. package/dist/web-types.json +190 -3
  120. package/package.json +13 -1
  121. package/dist/chunks/floating-B7_Dahpn.js +0 -54
  122. package/dist/chunks/floating-B7_Dahpn.js.map +0 -1
  123. package/dist/chunks/index-STEEvEP7.js.map +0 -1
  124. package/dist/chunks/kt-calendar-B_hFdD9V.js +0 -640
  125. package/dist/chunks/kt-calendar-B_hFdD9V.js.map +0 -1
@@ -1,640 +0,0 @@
1
- import { css as z, html as l, nothing as C } from "lit";
2
- import { state as D, property as w } from "lit/decorators.js";
3
- import { classMap as O } from "lit/directives/class-map.js";
4
- import { K as T, d as Y } from "./kt-element-Djx2JcGl.js";
5
- import { u as A, e as L } from "./events-r51msXNf.js";
6
- import { r as j, d as E } from "./locale-C5xLkGx5.js";
7
- import { s as U } from "./index-STEEvEP7.js";
8
- import "../components/core/kt-icon/kt-icon.js";
9
- const I = /^(\d{4})-(\d{2})-(\d{2})$/;
10
- function $(o, t) {
11
- return new Date(Date.UTC(o, t, 0)).getUTCDate();
12
- }
13
- function v(o) {
14
- const t = I.exec(o?.trim() ?? "");
15
- if (!t) return null;
16
- const [e, r, a] = [Number(t[1]), Number(t[2]), Number(t[3])];
17
- return r < 1 || r > 12 || a < 1 || a > $(e, r) ? null : { year: e, month: r, day: a };
18
- }
19
- function x(o) {
20
- const t = (e, r = 2) => String(e).padStart(r, "0");
21
- return `${t(o.year, 4)}-${t(o.month)}-${t(o.day)}`;
22
- }
23
- function K(o) {
24
- const [t, e] = (o ?? "").split("/");
25
- return { start: v(t), end: v(e) };
26
- }
27
- function B(o, t) {
28
- return `${x(o)}/${x(t)}`;
29
- }
30
- function u(o, t) {
31
- return o.year - t.year || o.month - t.month || o.day - t.day;
32
- }
33
- function b(o, t) {
34
- return o !== null && t !== null && u(o, t) === 0;
35
- }
36
- function R(o, t, e) {
37
- const [r, a] = u(t, e) <= 0 ? [t, e] : [e, t];
38
- return u(o, r) >= 0 && u(o, a) <= 0;
39
- }
40
- function V(o) {
41
- const t = new Date(o);
42
- return { year: t.getUTCFullYear(), month: t.getUTCMonth() + 1, day: t.getUTCDate() };
43
- }
44
- function g(o, t) {
45
- return V(Date.UTC(o.year, o.month - 1, o.day + t));
46
- }
47
- function p(o, t) {
48
- const e = o.year * 12 + (o.month - 1) + t, r = Math.floor(e / 12), a = e % 12 + 1;
49
- return { year: r, month: a, day: Math.min(o.day, $(r, a)) };
50
- }
51
- function _(o) {
52
- const t = new Date(Date.UTC(o.year, o.month - 1, o.day)).getUTCDay();
53
- return t === 0 ? 7 : t;
54
- }
55
- function M(o, t) {
56
- return g(o, -((_(o) - t + 7) % 7));
57
- }
58
- function q(o, t, e) {
59
- let r = M({ year: o, month: t, day: 1 }, e);
60
- const a = [];
61
- for (let s = 0; s < 6; s += 1) {
62
- const h = [];
63
- for (let i = 0; i < 7; i += 1)
64
- h.push(r), r = g(r, 1);
65
- a.push(h);
66
- }
67
- return a;
68
- }
69
- function k() {
70
- const o = /* @__PURE__ */ new Date();
71
- return { year: o.getFullYear(), month: o.getMonth() + 1, day: o.getDate() };
72
- }
73
- function W(o) {
74
- return new Date(o.year, o.month - 1, o.day, 12);
75
- }
76
- function P(o) {
77
- try {
78
- const t = new Intl.Locale(o), e = t.getWeekInfo?.().firstDay ?? t.weekInfo?.firstDay;
79
- return e && e >= 1 && e <= 7 ? e : 1;
80
- } catch {
81
- return 1;
82
- }
83
- }
84
- var F = Object.defineProperty, y = (o, t, e, r) => {
85
- for (var a = void 0, s = o.length - 1, h; s >= 0; s--)
86
- (h = o[s]) && (a = h(t, e, a) || a);
87
- return a && F(t, e, a), a;
88
- };
89
- const m = 12;
90
- class f extends T {
91
- constructor() {
92
- super(...arguments), this.liveId = A("kt-calendar-live"), this.focusCell = !1, this.committing = !1, this.view = "day", this.month = { ...k(), day: 1 }, this.focused = k(), this.anchor = null, this.value = null, this.range = !1, this.min = "", this.max = "", this.locale = "", this.label = "";
93
- }
94
- static {
95
- this.styles = [
96
- T.styles,
97
- z`
98
- :host {
99
- display: inline-block;
100
- --day-size: 36px;
101
- }
102
-
103
- .calendar {
104
- display: flex;
105
- flex-direction: column;
106
- gap: var(--gap-element);
107
- width: calc(var(--day-size) * 7);
108
- }
109
-
110
- .header {
111
- display: grid;
112
- grid-template-columns: auto 1fr auto;
113
- align-items: center;
114
- }
115
- .title {
116
- display: flex;
117
- justify-content: center;
118
- gap: 2px;
119
- }
120
-
121
- .nav,
122
- .heading {
123
- display: inline-flex;
124
- align-items: center;
125
- justify-content: center;
126
- height: var(--day-size);
127
- padding: 0;
128
- color: var(--text-muted);
129
- font: var(--font-normal-medium);
130
- background: none;
131
- border: none;
132
- border-radius: var(--radius-input);
133
- cursor: pointer;
134
- }
135
- .nav {
136
- width: var(--day-size);
137
- }
138
- .heading {
139
- padding: 0 8px;
140
- color: var(--text-body);
141
- text-transform: capitalize;
142
- }
143
- .heading kt-icon {
144
- margin-left: 2px;
145
- color: var(--text-muted);
146
- }
147
- .heading.static {
148
- cursor: default;
149
- }
150
- .nav:hover,
151
- .heading:not(.static):hover {
152
- color: var(--text-body);
153
- background: var(--color-dark-22);
154
- }
155
- .nav:focus-visible,
156
- .heading:focus-visible {
157
- outline: var(--outline-width) solid var(--color-primary-base);
158
- }
159
-
160
- /* One height for every view, so the calendar does not shrink under the
161
- pointer when it switches from days to months or years. */
162
- .body {
163
- height: calc(var(--day-size) * 7 + 16px);
164
- }
165
- table {
166
- width: 100%;
167
- table-layout: fixed;
168
- border-collapse: separate;
169
- border-spacing: 0 2px;
170
- }
171
- table.wide {
172
- height: 100%;
173
- }
174
- th {
175
- padding-bottom: 4px;
176
- color: var(--text-muted);
177
- font: var(--font-normal-small);
178
- font-weight: 600;
179
- }
180
- th abbr {
181
- text-decoration: none;
182
- }
183
-
184
- .cell {
185
- height: var(--day-size);
186
- padding: 0;
187
- color: var(--text-body);
188
- font: var(--font-normal-regular);
189
- font-variant-numeric: tabular-nums;
190
- text-align: center;
191
- border-radius: var(--radius-input);
192
- outline: none;
193
- cursor: pointer;
194
- }
195
- .cell:hover {
196
- background: var(--color-dark-22);
197
- }
198
- .cell:focus-visible {
199
- box-shadow: inset 0 0 0 var(--outline-width) var(--color-primary-base);
200
- }
201
- /* Months and years sit three to a row, sharing the height the days use. */
202
- .wide .cell {
203
- height: auto;
204
- text-transform: capitalize;
205
- }
206
- .cell.outside {
207
- color: var(--text-muted);
208
- }
209
- .cell.current {
210
- font-weight: 700;
211
- text-decoration: underline;
212
- text-decoration-thickness: 2px;
213
- text-underline-offset: 4px;
214
- }
215
-
216
- /* A period reads as one band: the days between are tinted and squared
217
- off, and only its two ends are rounded. */
218
- .cell.in-range {
219
- background: var(--color-primary-soft);
220
- border-radius: 0;
221
- }
222
- .cell.range-start {
223
- border-radius: var(--radius-input) 0 0 var(--radius-input);
224
- }
225
- .cell.range-end {
226
- border-radius: 0 var(--radius-input) var(--radius-input) 0;
227
- }
228
- .cell.range-start.range-end {
229
- border-radius: var(--radius-input);
230
- }
231
- .cell.selected {
232
- color: var(--color-white);
233
- background: var(--color-primary-base);
234
- }
235
-
236
- .cell[aria-disabled='true'] {
237
- color: var(--text-disabled);
238
- background: none;
239
- text-decoration: line-through;
240
- cursor: not-allowed;
241
- }
242
- `
243
- ];
244
- }
245
- connectedCallback() {
246
- super.connectedCallback(), this.jumpTo(this.clamp(this.selection.start ?? k()), !1);
247
- }
248
- willUpdate(t) {
249
- if (t.has("value") && !this.committing && this.hasUpdated) {
250
- this.anchor = null;
251
- const e = this.selection.start;
252
- e && this.jumpTo(this.clamp(e), !1);
253
- }
254
- this.committing = !1;
255
- }
256
- updated() {
257
- this.focusCell && (this.focusCell = !1, this.shadowRoot?.querySelector('.cell[tabindex="0"]')?.focus());
258
- }
259
- /** Focuses the grid's current cell — the chosen day, or today. */
260
- focus() {
261
- this.focusCell = !0, this.requestUpdate();
262
- }
263
- // --- Reading the value ---
264
- get resolvedLocale() {
265
- return j(this.locale);
266
- }
267
- get selection() {
268
- return this.range ? K(this.value) : { start: v(this.value), end: v(this.value) };
269
- }
270
- get bounds() {
271
- return { min: v(this.min), max: v(this.max) };
272
- }
273
- clamp(t) {
274
- const { min: e, max: r } = this.bounds;
275
- return e && u(t, e) < 0 ? e : r && u(t, r) > 0 ? r : t;
276
- }
277
- isOutOfBounds(t) {
278
- const { min: e, max: r } = this.bounds;
279
- return e !== null && u(t, e) < 0 || r !== null && u(t, r) > 0;
280
- }
281
- /** A month or a year is unavailable only when every day of it is. */
282
- isSpanOutOfBounds(t, e) {
283
- const { min: r, max: a } = this.bounds;
284
- return a !== null && u(t, a) > 0 || r !== null && u(e, r) < 0;
285
- }
286
- format(t, e) {
287
- return E(this.resolvedLocale, t).format(W(e));
288
- }
289
- // --- Moving ---
290
- /** Moves the tab stop, and the day view with it when it leaves the month. */
291
- jumpTo(t, e = !0) {
292
- this.focused = t, (t.year !== this.month.year || t.month !== this.month.month) && (this.month = { year: t.year, month: t.month, day: 1 }), this.focusCell = e;
293
- }
294
- setView(t) {
295
- this.view = t, this.focusCell = !0;
296
- }
297
- // --- Choosing ---
298
- chooseDay(t) {
299
- if (this.isOutOfBounds(t)) return;
300
- if (this.focused = t, !this.range) {
301
- this.commit(x(t));
302
- return;
303
- }
304
- if (!this.anchor) {
305
- this.anchor = t;
306
- return;
307
- }
308
- const [e, r] = u(this.anchor, t) <= 0 ? [this.anchor, t] : [t, this.anchor];
309
- this.anchor = null, this.commit(B(e, r));
310
- }
311
- commit(t) {
312
- this.committing = !0, this.value = t, L(this, "kt-change", { value: t });
313
- }
314
- chooseMonth(t) {
315
- const e = Math.min(this.focused.day, $(this.focused.year, t));
316
- this.jumpTo(this.clamp({ year: this.focused.year, month: t, day: e })), this.setView("day");
317
- }
318
- chooseYear(t) {
319
- const e = Math.min(this.focused.day, $(t, this.focused.month));
320
- this.focused = { year: t, month: this.focused.month, day: e }, this.setView("month");
321
- }
322
- // --- Keyboard ---
323
- onDayKeyDown(t) {
324
- const e = P(this.resolvedLocale), r = this.focused;
325
- let a;
326
- switch (t.key) {
327
- case "ArrowLeft":
328
- a = g(r, -1);
329
- break;
330
- case "ArrowRight":
331
- a = g(r, 1);
332
- break;
333
- case "ArrowUp":
334
- a = g(r, -7);
335
- break;
336
- case "ArrowDown":
337
- a = g(r, 7);
338
- break;
339
- case "Home":
340
- a = M(r, e);
341
- break;
342
- case "End":
343
- a = g(M(r, e), 6);
344
- break;
345
- case "PageUp":
346
- a = p(r, t.shiftKey ? -12 : -1);
347
- break;
348
- case "PageDown":
349
- a = p(r, t.shiftKey ? 12 : 1);
350
- break;
351
- case "Enter":
352
- case " ":
353
- t.preventDefault(), this.chooseDay(r);
354
- return;
355
- default:
356
- return;
357
- }
358
- t.preventDefault(), this.jumpTo(a);
359
- }
360
- /** Months and years share one model: a list of cells, three to a row. */
361
- onPickerKeyDown(t) {
362
- const e = this.view === "month", r = (s) => e ? p(this.focused, s) : p(this.focused, s * 12);
363
- let a;
364
- switch (t.key) {
365
- case "ArrowLeft":
366
- a = r(-1);
367
- break;
368
- case "ArrowRight":
369
- a = r(1);
370
- break;
371
- case "ArrowUp":
372
- a = r(-3);
373
- break;
374
- case "ArrowDown":
375
- a = r(3);
376
- break;
377
- case "PageUp":
378
- a = r(e ? -12 : -m);
379
- break;
380
- case "PageDown":
381
- a = r(e ? 12 : m);
382
- break;
383
- case "Enter":
384
- case " ":
385
- t.preventDefault(), e ? this.chooseMonth(this.focused.month) : this.chooseYear(this.focused.year);
386
- return;
387
- case "Escape":
388
- t.preventDefault(), t.stopPropagation(), this.setView("day");
389
- return;
390
- default:
391
- return;
392
- }
393
- t.preventDefault(), this.focused = a, this.focusCell = !0;
394
- }
395
- // --- Rendering ---
396
- renderHeader() {
397
- const { year: t } = this.focused, e = U();
398
- if (this.view === "day")
399
- return l`<div class="header">
400
- <button
401
- type="button"
402
- class="nav"
403
- aria-label=${e.previousMonth}
404
- @click=${() => this.jumpTo(p(this.focused, -1), !1)}
405
- >
406
- <kt-icon name="chevron-left" size="18"></kt-icon>
407
- </button>
408
- <div class="title">
409
- <button
410
- type="button"
411
- class="heading"
412
- aria-label=${`${e.chooseMonth}, ${this.format({ month: "long" }, this.month)}`}
413
- @click=${() => this.setView("month")}
414
- >
415
- ${this.format({ month: "long" }, this.month)}
416
- </button>
417
- <button
418
- type="button"
419
- class="heading"
420
- aria-label=${`${e.chooseYear}, ${this.month.year}`}
421
- @click=${() => this.setView("year")}
422
- >
423
- ${this.format({ year: "numeric" }, this.month)}
424
- <kt-icon name="chevron-down" size="14"></kt-icon>
425
- </button>
426
- </div>
427
- <button
428
- type="button"
429
- class="nav"
430
- aria-label=${e.nextMonth}
431
- @click=${() => this.jumpTo(p(this.focused, 1), !1)}
432
- >
433
- <kt-icon name="chevron-right" size="18"></kt-icon>
434
- </button>
435
- </div>`;
436
- const r = this.view === "month", a = t - (t % m + m) % m, s = r ? 12 : m * 12;
437
- return l`<div class="header">
438
- <button
439
- type="button"
440
- class="nav"
441
- aria-label=${r ? e.previousYear : e.previousYears}
442
- @click=${() => {
443
- this.focused = p(this.focused, -s);
444
- }}
445
- >
446
- <kt-icon name="chevron-left" size="18"></kt-icon>
447
- </button>
448
- <div class="title">
449
- ${r ? l`<button
450
- type="button"
451
- class="heading"
452
- aria-label=${`${e.chooseYear}, ${t}`}
453
- @click=${() => this.setView("year")}
454
- >
455
- ${t}
456
- </button>` : l`<span class="heading static"
457
- >${a} – ${a + m - 1}</span
458
- >`}
459
- </div>
460
- <button
461
- type="button"
462
- class="nav"
463
- aria-label=${r ? e.nextYear : e.nextYears}
464
- @click=${() => {
465
- this.focused = p(this.focused, s);
466
- }}
467
- >
468
- <kt-icon name="chevron-right" size="18"></kt-icon>
469
- </button>
470
- </div>`;
471
- }
472
- renderDay(t) {
473
- const { start: e, end: r } = this.selection, a = this.anchor ?? e, s = this.anchor ? this.focused : r, [h, i] = a && s && u(a, s) > 0 ? [s, a] : [a, s], n = this.range ? b(t, h) || b(t, i) : b(t, e), c = this.range && h !== null && i !== null && R(t, h, i), d = b(t, k());
474
- return l`<td
475
- part="day"
476
- role="gridcell"
477
- class=${O({
478
- cell: !0,
479
- outside: t.month !== this.month.month,
480
- current: d,
481
- selected: n,
482
- "in-range": c,
483
- "range-start": c && b(t, h),
484
- "range-end": c && b(t, i)
485
- })}
486
- data-date=${x(t)}
487
- tabindex=${b(t, this.focused) ? 0 : -1}
488
- aria-selected=${n ? "true" : "false"}
489
- aria-disabled=${this.isOutOfBounds(t) ? "true" : C}
490
- aria-current=${d ? "date" : C}
491
- aria-label=${this.format({ dateStyle: "full" }, t)}
492
- @click=${() => this.chooseDay(t)}
493
- @pointerenter=${() => {
494
- this.anchor && (this.focused = t);
495
- }}
496
- >
497
- ${t.day}
498
- </td>`;
499
- }
500
- renderDays() {
501
- const t = q(this.month.year, this.month.month, P(this.resolvedLocale));
502
- return l`<table role="grid" aria-labelledby=${this.liveId} @keydown=${this.onDayKeyDown}>
503
- <thead>
504
- <tr>
505
- ${t[0].map(
506
- (e) => l`<th scope="col">
507
- <abbr title=${this.format({ weekday: "long" }, e)}
508
- >${this.format({ weekday: "short" }, e)}</abbr
509
- >
510
- </th>`
511
- )}
512
- </tr>
513
- </thead>
514
- <tbody>
515
- ${t.map(
516
- (e) => l`<tr>
517
- ${e.map((r) => this.renderDay(r))}
518
- </tr>`
519
- )}
520
- </tbody>
521
- </table>`;
522
- }
523
- /** The month or year grid: twelve cells, three to a row. */
524
- renderPicker() {
525
- const t = this.view === "month", { year: e } = this.focused, r = k(), a = e - (e % m + m) % m, s = Array.from({ length: 12 }, (i, n) => {
526
- if (t) {
527
- const d = n + 1, S = { year: e, month: d, day: 1 };
528
- return {
529
- key: `${e}-${d}`,
530
- label: this.format({ month: "short" }, S),
531
- fullLabel: this.format({ month: "long", year: "numeric" }, S),
532
- focused: d === this.focused.month,
533
- selected: d === this.month.month && e === this.month.year,
534
- current: d === r.month && e === r.year,
535
- disabled: this.isSpanOutOfBounds(S, { year: e, month: d, day: $(e, d) }),
536
- choose: () => this.chooseMonth(d)
537
- };
538
- }
539
- const c = a + n;
540
- return {
541
- key: String(c),
542
- label: String(c),
543
- fullLabel: String(c),
544
- focused: c === e,
545
- selected: c === this.month.year,
546
- current: c === r.year,
547
- disabled: this.isSpanOutOfBounds(
548
- { year: c, month: 1, day: 1 },
549
- { year: c, month: 12, day: 31 }
550
- ),
551
- choose: () => this.chooseYear(c)
552
- };
553
- }), h = [0, 3, 6, 9].map((i) => s.slice(i, i + 3));
554
- return l`<table
555
- role="grid"
556
- class="wide"
557
- aria-labelledby=${this.liveId}
558
- @keydown=${this.onPickerKeyDown}
559
- >
560
- <tbody>
561
- ${h.map(
562
- (i) => l`<tr>
563
- ${i.map(
564
- (n) => l`<td
565
- role="gridcell"
566
- class=${O({
567
- cell: !0,
568
- selected: n.selected,
569
- current: n.current
570
- })}
571
- data-key=${n.key}
572
- tabindex=${n.focused ? 0 : -1}
573
- aria-selected=${n.selected ? "true" : "false"}
574
- aria-disabled=${n.disabled ? "true" : C}
575
- aria-label=${n.fullLabel}
576
- @click=${() => {
577
- n.disabled || n.choose();
578
- }}
579
- >
580
- ${n.label}
581
- </td>`
582
- )}
583
- </tr>`
584
- )}
585
- </tbody>
586
- </table>`;
587
- }
588
- render() {
589
- const t = U(), e = this.view === "day" ? this.format({ month: "long", year: "numeric" }, this.month) : this.view === "month" ? String(this.focused.year) : t.chooseYear;
590
- return l`<div
591
- part="base"
592
- class="calendar"
593
- role="group"
594
- aria-label=${this.label || (this.range ? t.selectPeriod : t.selectDate)}
595
- >
596
- <span id=${this.liveId} class="visually-hidden" aria-live="polite">${e}</span>
597
- ${this.renderHeader()}
598
- <div class="body">${this.view === "day" ? this.renderDays() : this.renderPicker()}</div>
599
- </div>`;
600
- }
601
- }
602
- y([
603
- D()
604
- ], f.prototype, "view");
605
- y([
606
- D()
607
- ], f.prototype, "month");
608
- y([
609
- D()
610
- ], f.prototype, "focused");
611
- y([
612
- D()
613
- ], f.prototype, "anchor");
614
- y([
615
- w({ type: String, reflect: !0 })
616
- ], f.prototype, "value");
617
- y([
618
- w({ type: Boolean, reflect: !0 })
619
- ], f.prototype, "range");
620
- y([
621
- w({ type: String })
622
- ], f.prototype, "min");
623
- y([
624
- w({ type: String })
625
- ], f.prototype, "max");
626
- y([
627
- w({ type: String })
628
- ], f.prototype, "locale");
629
- y([
630
- w({ type: String })
631
- ], f.prototype, "label");
632
- Y("kt-calendar", f);
633
- export {
634
- f as K,
635
- v as a,
636
- u as c,
637
- K as p,
638
- W as t
639
- };
640
- //# sourceMappingURL=kt-calendar-B_hFdD9V.js.map