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