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.
- package/README.md +10 -10
- package/dist/chunks/floating-B33g-M_1.js +63 -0
- package/dist/chunks/floating-B33g-M_1.js.map +1 -0
- package/dist/chunks/{index-STEEvEP7.js → index-TWJzttLX.js} +38 -15
- package/dist/chunks/index-TWJzttLX.js.map +1 -0
- package/dist/chunks/kt-calendar-CtwOby1R.js +780 -0
- package/dist/chunks/kt-calendar-CtwOby1R.js.map +1 -0
- package/dist/chunks/{kt-element-Djx2JcGl.js → kt-element-T0VbIBNp.js} +2 -2
- package/dist/chunks/{kt-element-Djx2JcGl.js.map → kt-element-T0VbIBNp.js.map} +1 -1
- package/dist/chunks/{listbox-llcUu_V-.js → listbox-LsUEyGhQ.js} +2 -2
- package/dist/chunks/{listbox-llcUu_V-.js.map → listbox-LsUEyGhQ.js.map} +1 -1
- package/dist/chunks/segmented-field-BBXR4XFL.js +384 -0
- package/dist/chunks/segmented-field-BBXR4XFL.js.map +1 -0
- package/dist/chunks/typed-date-CPAUNHzr.js +103 -0
- package/dist/chunks/typed-date-CPAUNHzr.js.map +1 -0
- package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
- package/dist/components/core/kt-badge/kt-badge.js +2 -2
- package/dist/components/core/kt-button/kt-button.js +1 -1
- package/dist/components/core/kt-card/kt-card.js +1 -1
- package/dist/components/core/kt-code/kt-code.js +13 -13
- package/dist/components/core/kt-code/kt-code.js.map +1 -1
- package/dist/components/core/kt-icon/kt-icon.js +1 -1
- package/dist/components/core/kt-kbd/kt-kbd.js +5 -5
- package/dist/components/core/kt-kbd/kt-kbd.js.map +1 -1
- package/dist/components/core/kt-split-button/kt-split-button.js +3 -3
- package/dist/components/data/kt-chart/kt-chart.js +3 -3
- package/dist/components/data/kt-chart/kt-chart.js.map +1 -1
- package/dist/components/data/kt-meter/kt-meter.js +1 -1
- package/dist/components/data/kt-pagination/kt-pagination.js +2 -2
- package/dist/components/data/kt-stat/kt-stat.js +1 -1
- package/dist/components/data/kt-table/kt-table.js +85 -85
- package/dist/components/data/kt-table/kt-table.js.map +1 -1
- package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
- package/dist/components/feedback/kt-alert/kt-alert.js +15 -15
- package/dist/components/feedback/kt-alert/kt-alert.js.map +1 -1
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +1 -1
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js +13 -13
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js.map +1 -1
- package/dist/components/feedback/kt-toast/kt-toast.js +3 -3
- package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js +1 -1
- package/dist/components/forms/kt-calendar/kt-calendar.d.ts +35 -9
- package/dist/components/forms/kt-calendar/kt-calendar.js +3 -3
- package/dist/components/forms/kt-checkbox/kt-checkbox.js +2 -2
- package/dist/components/forms/kt-date-input/kt-date-input.d.ts +65 -0
- package/dist/components/forms/kt-date-input/kt-date-input.js +241 -0
- package/dist/components/forms/kt-date-input/kt-date-input.js.map +1 -0
- package/dist/components/forms/kt-date-picker/kt-date-picker.d.ts +47 -3
- package/dist/components/forms/kt-date-picker/kt-date-picker.js +430 -199
- package/dist/components/forms/kt-date-picker/kt-date-picker.js.map +1 -1
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +3 -3
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
- package/dist/components/forms/kt-form/kt-form.js +2 -2
- package/dist/components/forms/kt-input/kt-input.js +10 -10
- package/dist/components/forms/kt-input/kt-input.js.map +1 -1
- package/dist/components/forms/kt-input-menu/kt-input-menu.js +4 -4
- package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
- package/dist/components/forms/kt-multi-select/kt-multi-select.d.ts +113 -0
- package/dist/components/forms/kt-multi-select/kt-multi-select.js +532 -0
- package/dist/components/forms/kt-multi-select/kt-multi-select.js.map +1 -0
- package/dist/components/forms/kt-radio-group/kt-radio-group.js +56 -51
- package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -1
- package/dist/components/forms/kt-select/kt-select.js +4 -4
- package/dist/components/forms/kt-textarea/kt-textarea.js +2 -2
- package/dist/components/forms/kt-time-input/kt-time-input.d.ts +48 -0
- package/dist/components/forms/kt-time-input/kt-time-input.js +114 -0
- package/dist/components/forms/kt-time-input/kt-time-input.js.map +1 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js +1 -1
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +6 -6
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js.map +1 -1
- package/dist/components/navigation/kt-header/kt-header.js +2 -2
- package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +2 -2
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +2 -2
- package/dist/components/navigation/kt-tabs/kt-tabs.js +2 -2
- package/dist/components/navigation/kt-tabs/kt-tabs.js.map +1 -1
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +1 -1
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +2 -2
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js +3 -3
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js.map +1 -1
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +2 -2
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js +24 -24
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
- package/dist/components/overlays/kt-modal/kt-modal.js +2 -2
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js +2 -2
- package/dist/custom-elements.json +2230 -842
- package/dist/index.d.ts +9 -1
- package/dist/index.js +316 -109
- package/dist/index.js.map +1 -1
- package/dist/internal/floating.d.ts +3 -0
- package/dist/internal/segmented-field.d.ts +114 -0
- package/dist/internal/segments.d.ts +30 -0
- package/dist/internal/strings.d.ts +30 -0
- package/dist/internal/typed-date.d.ts +33 -0
- package/dist/react/index.d.ts +23 -0
- package/dist/react/index.js +193 -169
- package/dist/react/index.js.map +1 -1
- package/dist/react/jsx.d.ts +20 -1
- package/dist/strings/index.js +1 -1
- package/dist/theme/accent.d.ts +51 -0
- package/dist/theme/appearance.d.ts +37 -0
- package/dist/tokens/README.md +100 -1
- package/dist/tokens/accents.css +80 -0
- package/dist/tokens/appearance.css +65 -0
- package/dist/tokens/base.css +3 -0
- package/dist/tokens/colors.css +78 -25
- package/dist/tokens/index.css +2 -0
- package/dist/tokens/responsive.css +160 -75
- package/dist/tokens/spacing.css +47 -28
- package/dist/tokens/theme-light.css +124 -38
- package/dist/tokens/typography.css +20 -13
- package/dist/vscode.css-custom-data.json +36 -1
- package/dist/vscode.html-custom-data.json +67 -2
- package/dist/vue/index.d.ts +6 -0
- package/dist/vue/index.js +11 -8
- package/dist/vue/index.js.map +1 -1
- package/dist/web-types.json +190 -3
- package/package.json +13 -1
- package/dist/chunks/floating-B7_Dahpn.js +0 -54
- package/dist/chunks/floating-B7_Dahpn.js.map +0 -1
- package/dist/chunks/index-STEEvEP7.js.map +0 -1
- package/dist/chunks/kt-calendar-B_hFdD9V.js +0 -640
- package/dist/chunks/kt-calendar-B_hFdD9V.js.map +0 -1
|
@@ -1,32 +1,52 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { query as
|
|
3
|
-
import { classMap as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { css as T, nothing as d, html as p } from "lit";
|
|
2
|
+
import { query as S, state as h, property as s } from "lit/decorators.js";
|
|
3
|
+
import { classMap as x } from "lit/directives/class-map.js";
|
|
4
|
+
import { live as O } from "lit/directives/live.js";
|
|
5
|
+
import { K as D, d as R } from "../../../chunks/kt-element-T0VbIBNp.js";
|
|
6
|
+
import { u as q, t as E, e as v } from "../../../chunks/events-r51msXNf.js";
|
|
7
|
+
import { a as B, s as F, b as L } from "../../../chunks/form-control-B74_EHtG.js";
|
|
8
|
+
import { F as z, f as K } from "../../../chunks/floating-B33g-M_1.js";
|
|
9
|
+
import { r as M, d as _ } from "../../../chunks/locale-C5xLkGx5.js";
|
|
10
|
+
import { s as f } from "../../../chunks/index-TWJzttLX.js";
|
|
11
|
+
import { a as P, p as u, c as g, b as w, t as m, e as k, f as C, g as V, h as I, d as W } from "../../../chunks/kt-calendar-CtwOby1R.js";
|
|
12
|
+
import { p as U, a as Y, e as j } from "../../../chunks/typed-date-CPAUNHzr.js";
|
|
11
13
|
import "../../core/kt-icon/kt-icon.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
import "../../feedback/kt-tooltip/kt-tooltip.js";
|
|
15
|
+
var G = Object.defineProperty, a = (l, t, e, o) => {
|
|
16
|
+
for (var r = void 0, n = l.length - 1, c; n >= 0; n--)
|
|
17
|
+
(c = l[n]) && (r = c(t, e, r) || r);
|
|
18
|
+
return r && G(t, e, r), r;
|
|
16
19
|
};
|
|
17
|
-
|
|
20
|
+
function H() {
|
|
21
|
+
const l = f(), t = m(), e = { ...t, day: 1 }, o = V(e, -1), r = (n, c) => k(n, c);
|
|
22
|
+
return [
|
|
23
|
+
{ label: l.presetToday, value: r(t, t) },
|
|
24
|
+
{ label: l.presetLast7Days, value: r(I(t, -6), t) },
|
|
25
|
+
{ label: l.presetLast30Days, value: r(I(t, -29), t) },
|
|
26
|
+
{ label: l.presetThisMonth, value: r(e, t) },
|
|
27
|
+
{
|
|
28
|
+
label: l.presetLastMonth,
|
|
29
|
+
value: r(o, {
|
|
30
|
+
...o,
|
|
31
|
+
day: W(o.year, o.month)
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
{ label: l.presetThisYear, value: r({ year: t.year, month: 1, day: 1 }, t) }
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
const i = class $ extends D {
|
|
18
38
|
constructor() {
|
|
19
|
-
super(...arguments), this.internals = null, this.defaultValue = null, this.panelId =
|
|
39
|
+
super(...arguments), this.internals = null, this.defaultValue = null, this.panelId = q("kt-date-picker-panel"), this.open = !1, this.text = "", this.editing = !1, this.typedError = "", this.focused = !1, this.compact = !1, this.placement = "bottom", this.floating = new z(this, {
|
|
20
40
|
panel: () => this.shadowRoot?.querySelector(".panel"),
|
|
21
|
-
anchor: () => this.shadowRoot?.querySelector(".
|
|
22
|
-
onPlace: (
|
|
23
|
-
this.placement =
|
|
24
|
-
}
|
|
25
|
-
}), this.value = null, this.range = !1, this.min = "", this.max = "", this.name = "", this.label = "", this.placeholder = void 0, this.locale = "", this.size = "medium", this.disabled = !1, this.formDisabled = !1, this.required = !1, this.clearable = !0, this.error = "", this.onDocumentPointerDown = (
|
|
26
|
-
this.open && !
|
|
27
|
-
}, this.onFocusOut = (
|
|
28
|
-
const
|
|
29
|
-
!this.open || !
|
|
41
|
+
anchor: () => this.shadowRoot?.querySelector(".field"),
|
|
42
|
+
onPlace: (t) => {
|
|
43
|
+
this.placement = t === "top" ? "top" : "bottom";
|
|
44
|
+
}
|
|
45
|
+
}), this.value = null, this.range = !1, this.min = "", this.max = "", this.name = "", this.label = "", this.placeholder = void 0, this.locale = "", this.size = "medium", this.disabled = !1, this.formDisabled = !1, this.required = !1, this.clearable = !0, this.presets = void 0, this.error = "", this.onDocumentPointerDown = (t) => {
|
|
46
|
+
this.open && !t.composedPath().includes(this) && this.close(!1);
|
|
47
|
+
}, this.onFocusOut = (t) => {
|
|
48
|
+
const e = t.relatedTarget;
|
|
49
|
+
!this.open || !e || this.contains(e) || this.shadowRoot?.contains(e) || t.composedPath().includes(e) || this.calendar?.shadowRoot?.contains(e) || this.close(!1);
|
|
30
50
|
};
|
|
31
51
|
}
|
|
32
52
|
static {
|
|
@@ -34,14 +54,13 @@ class r extends m {
|
|
|
34
54
|
}
|
|
35
55
|
static {
|
|
36
56
|
this.styles = [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
D.styles,
|
|
58
|
+
K,
|
|
59
|
+
T`
|
|
40
60
|
:host {
|
|
41
61
|
position: relative;
|
|
42
62
|
display: block;
|
|
43
63
|
--field-height: var(--button-height);
|
|
44
|
-
--day-size: 36px;
|
|
45
64
|
}
|
|
46
65
|
:host([size='small']) {
|
|
47
66
|
--field-height: var(--button-height-small);
|
|
@@ -50,95 +69,106 @@ class r extends m {
|
|
|
50
69
|
--field-height: var(--button-height-large);
|
|
51
70
|
}
|
|
52
71
|
|
|
72
|
+
/* The field, as kt-input draws one: a fill with a resting hairline, an
|
|
73
|
+
outline on hover and focus that never reflows it. */
|
|
53
74
|
.field {
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.trigger {
|
|
58
|
-
display: grid;
|
|
59
|
-
grid-template-columns: 1fr auto;
|
|
75
|
+
display: flex;
|
|
60
76
|
align-items: center;
|
|
61
|
-
gap:
|
|
62
|
-
width: 100%;
|
|
77
|
+
gap: 2px;
|
|
63
78
|
height: var(--field-height);
|
|
64
|
-
padding: 0
|
|
79
|
+
padding: 0 10px 0 4px;
|
|
65
80
|
color: var(--text-body);
|
|
66
|
-
font: var(--font-input);
|
|
67
|
-
text-align: left;
|
|
68
81
|
background-color: var(--color-dark-20);
|
|
69
82
|
border: var(--border-width) solid var(--border-field);
|
|
70
83
|
border-radius: var(--radius-input);
|
|
71
84
|
outline: var(--outline-width) solid transparent;
|
|
72
|
-
cursor: pointer;
|
|
73
85
|
transition:
|
|
74
86
|
background-color var(--duration-instant),
|
|
75
87
|
outline-color var(--duration-instant);
|
|
76
88
|
}
|
|
77
|
-
.
|
|
89
|
+
.field:hover {
|
|
78
90
|
outline: var(--outline-width) solid var(--color-text-700);
|
|
79
91
|
}
|
|
80
|
-
.
|
|
81
|
-
.open .
|
|
92
|
+
.field:focus-within,
|
|
93
|
+
.open .field {
|
|
82
94
|
background-color: var(--color-dark-12);
|
|
83
95
|
outline: var(--outline-width) solid var(--color-primary-base);
|
|
84
96
|
}
|
|
85
|
-
.error .
|
|
86
|
-
.error .
|
|
97
|
+
.error .field,
|
|
98
|
+
.error .field:hover,
|
|
99
|
+
.error .field:focus-within {
|
|
87
100
|
outline: var(--outline-width) solid var(--color-danger-base);
|
|
88
101
|
}
|
|
89
|
-
:host(:disabled) .
|
|
102
|
+
:host(:disabled) .field {
|
|
90
103
|
color: var(--text-disabled);
|
|
91
104
|
background-color: var(--color-dark-14);
|
|
92
|
-
cursor: not-allowed;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.value {
|
|
96
|
-
overflow: hidden;
|
|
97
|
-
white-space: nowrap;
|
|
98
|
-
text-overflow: ellipsis;
|
|
99
|
-
}
|
|
100
|
-
.placeholder {
|
|
101
|
-
color: var(--text-muted);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
align-items: center;
|
|
107
|
-
gap: var(--gap-element);
|
|
108
|
-
color: var(--text-muted);
|
|
109
|
-
}
|
|
110
|
-
/* Room for the clear button, which sits over the field, not inside the
|
|
111
|
-
trigger: a button inside a button is not a thing assistive
|
|
112
|
-
technology can operate. */
|
|
113
|
-
.clearable .icons {
|
|
114
|
-
padding-left: calc(18px + var(--gap-element));
|
|
115
|
-
}
|
|
107
|
+
/* The calendar button leads: it says what kind of field this is. */
|
|
108
|
+
.trigger,
|
|
116
109
|
.clear {
|
|
117
|
-
position: absolute;
|
|
118
|
-
top: 50%;
|
|
119
|
-
/* Just left of the calendar icon, in the room .icons keeps for it. */
|
|
120
|
-
right: calc(var(--button-padding-x) + 18px + var(--gap-element));
|
|
121
110
|
display: inline-flex;
|
|
111
|
+
flex: none;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
122
114
|
padding: 0;
|
|
123
115
|
color: var(--text-muted);
|
|
124
116
|
background: none;
|
|
125
117
|
border: none;
|
|
126
|
-
border-radius: var(--radius-
|
|
118
|
+
border-radius: calc(var(--radius-input) - 2px);
|
|
127
119
|
cursor: pointer;
|
|
128
|
-
|
|
120
|
+
transition:
|
|
121
|
+
background-color var(--duration-instant),
|
|
122
|
+
color var(--duration-instant);
|
|
123
|
+
}
|
|
124
|
+
.trigger {
|
|
125
|
+
width: calc(var(--field-height) - 10px);
|
|
126
|
+
height: calc(var(--field-height) - 10px);
|
|
127
|
+
}
|
|
128
|
+
.trigger:hover,
|
|
129
|
+
.open .trigger {
|
|
130
|
+
color: var(--text-body);
|
|
131
|
+
background: var(--color-dark-22);
|
|
129
132
|
}
|
|
130
133
|
.clear:hover {
|
|
131
134
|
color: var(--text-body);
|
|
132
135
|
}
|
|
136
|
+
.trigger:focus-visible,
|
|
133
137
|
.clear:focus-visible {
|
|
134
138
|
outline: var(--outline-width) solid var(--color-primary-base);
|
|
135
139
|
}
|
|
140
|
+
:host(:disabled) .trigger {
|
|
141
|
+
cursor: not-allowed;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
input {
|
|
145
|
+
flex: 1;
|
|
146
|
+
min-width: 0;
|
|
147
|
+
height: 100%;
|
|
148
|
+
padding: 0 4px;
|
|
149
|
+
color: inherit;
|
|
150
|
+
font: var(--font-input);
|
|
151
|
+
background: transparent;
|
|
152
|
+
border: none;
|
|
153
|
+
outline: none;
|
|
154
|
+
}
|
|
155
|
+
input::placeholder {
|
|
156
|
+
color: var(--text-muted);
|
|
157
|
+
}
|
|
158
|
+
.error input {
|
|
159
|
+
color: var(--color-danger-text);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.error-icon {
|
|
163
|
+
flex: none;
|
|
164
|
+
color: var(--color-danger-text);
|
|
165
|
+
}
|
|
136
166
|
|
|
137
167
|
/* Placed from the field by FloatingController. */
|
|
138
168
|
.panel {
|
|
139
169
|
box-sizing: border-box;
|
|
140
170
|
padding: var(--padding-expand);
|
|
141
|
-
background: var(--
|
|
171
|
+
background: var(--surface-popover);
|
|
142
172
|
border-radius: var(--radius-input);
|
|
143
173
|
|
|
144
174
|
visibility: hidden;
|
|
@@ -166,6 +196,78 @@ class r extends m {
|
|
|
166
196
|
.panel kt-calendar {
|
|
167
197
|
display: block;
|
|
168
198
|
}
|
|
199
|
+
|
|
200
|
+
.panel-body {
|
|
201
|
+
display: flex;
|
|
202
|
+
gap: 12px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Ready-made periods: the quickest way to a period, so they lead. */
|
|
206
|
+
.presets {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-direction: column;
|
|
209
|
+
gap: 2px;
|
|
210
|
+
min-width: 128px;
|
|
211
|
+
padding-right: 12px;
|
|
212
|
+
border-right: var(--border-width) solid var(--divider-popover);
|
|
213
|
+
}
|
|
214
|
+
.presets button,
|
|
215
|
+
.today {
|
|
216
|
+
height: 32px;
|
|
217
|
+
padding: 0 10px;
|
|
218
|
+
color: var(--text-body);
|
|
219
|
+
font: var(--font-normal-regular);
|
|
220
|
+
text-align: left;
|
|
221
|
+
white-space: nowrap;
|
|
222
|
+
background: none;
|
|
223
|
+
border: none;
|
|
224
|
+
border-radius: var(--radius-input);
|
|
225
|
+
cursor: pointer;
|
|
226
|
+
}
|
|
227
|
+
.presets button:hover:not(:disabled),
|
|
228
|
+
.today:hover:not(:disabled) {
|
|
229
|
+
background: var(--color-dark-22);
|
|
230
|
+
}
|
|
231
|
+
.presets button[aria-pressed='true'] {
|
|
232
|
+
color: var(--color-primary-text);
|
|
233
|
+
font-weight: 600;
|
|
234
|
+
background: var(--color-primary-soft);
|
|
235
|
+
}
|
|
236
|
+
.presets button:disabled,
|
|
237
|
+
.today:disabled {
|
|
238
|
+
color: var(--text-disabled);
|
|
239
|
+
cursor: not-allowed;
|
|
240
|
+
}
|
|
241
|
+
.presets button:focus-visible,
|
|
242
|
+
.today:focus-visible {
|
|
243
|
+
outline: var(--outline-width) solid var(--color-primary-base);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* On a narrow screen the periods wrap in a row above the one month. */
|
|
247
|
+
.panel-body.compact {
|
|
248
|
+
flex-direction: column;
|
|
249
|
+
}
|
|
250
|
+
.compact .presets {
|
|
251
|
+
flex-direction: row;
|
|
252
|
+
flex-wrap: wrap;
|
|
253
|
+
min-width: 0;
|
|
254
|
+
max-width: calc(var(--day-size, 32px) * 7);
|
|
255
|
+
padding: 0 0 8px;
|
|
256
|
+
border-right: none;
|
|
257
|
+
border-bottom: var(--border-width) solid var(--divider-popover);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.footer {
|
|
261
|
+
display: flex;
|
|
262
|
+
justify-content: flex-start;
|
|
263
|
+
margin-top: var(--gap-element);
|
|
264
|
+
padding-top: var(--gap-element);
|
|
265
|
+
border-top: var(--border-width) solid var(--divider-popover);
|
|
266
|
+
}
|
|
267
|
+
.today {
|
|
268
|
+
color: var(--color-primary-text);
|
|
269
|
+
font-weight: 600;
|
|
270
|
+
}
|
|
169
271
|
`
|
|
170
272
|
];
|
|
171
273
|
}
|
|
@@ -174,129 +276,223 @@ class r extends m {
|
|
|
174
276
|
return this.disabled || this.formDisabled;
|
|
175
277
|
}
|
|
176
278
|
connectedCallback() {
|
|
177
|
-
super.connectedCallback(), this.internals ??=
|
|
279
|
+
super.connectedCallback(), this.internals ??= B(this), this.defaultValue = this.value, E(this.open, document, "pointerdown", this.onDocumentPointerDown);
|
|
178
280
|
}
|
|
179
281
|
disconnectedCallback() {
|
|
180
282
|
super.disconnectedCallback(), document.removeEventListener("pointerdown", this.onDocumentPointerDown);
|
|
181
283
|
}
|
|
182
284
|
// Untyped: `open` is private, so not among the keys PropertyValues<this> knows.
|
|
183
|
-
updated(
|
|
184
|
-
|
|
285
|
+
updated(t) {
|
|
286
|
+
t.has("open") && E(this.open, document, "pointerdown", this.onDocumentPointerDown), this.floating.sync(this.open);
|
|
185
287
|
}
|
|
186
|
-
willUpdate(
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
288
|
+
willUpdate(t) {
|
|
289
|
+
if (t.has("value") || t.has("range") || t.has("required") || t.has("error") || t.has("typedError") || this.stringsChanged(t)) {
|
|
290
|
+
const e = this.isComplete();
|
|
291
|
+
F(this.internals, e ? this.value : null);
|
|
292
|
+
const o = this.required && !e;
|
|
293
|
+
L(
|
|
192
294
|
this.internals,
|
|
193
|
-
{
|
|
194
|
-
|
|
295
|
+
{
|
|
296
|
+
valueMissing: o,
|
|
297
|
+
badInput: !!this.typedError,
|
|
298
|
+
customError: !!this.error
|
|
299
|
+
},
|
|
300
|
+
this.error || this.typedError || (o ? f().dateRequired : "")
|
|
195
301
|
);
|
|
196
302
|
}
|
|
197
303
|
}
|
|
198
304
|
formResetCallback() {
|
|
199
|
-
this.value = this.defaultValue, this.close(!1);
|
|
305
|
+
this.value = this.defaultValue, this.editing = !1, this.typedError = "", this.close(!1);
|
|
200
306
|
}
|
|
201
307
|
/**
|
|
202
308
|
* Called by the platform when the control's disabled state changes — its
|
|
203
309
|
* own `disabled`, or an ancestor `<fieldset disabled>` it cannot see.
|
|
204
310
|
*/
|
|
205
|
-
formDisabledCallback(
|
|
206
|
-
this.formDisabled =
|
|
311
|
+
formDisabledCallback(t) {
|
|
312
|
+
this.formDisabled = t;
|
|
207
313
|
}
|
|
208
|
-
formStateRestoreCallback(
|
|
209
|
-
this.value =
|
|
314
|
+
formStateRestoreCallback(t) {
|
|
315
|
+
this.value = t;
|
|
210
316
|
}
|
|
211
|
-
focus(
|
|
212
|
-
this.
|
|
317
|
+
focus(t) {
|
|
318
|
+
this.input?.focus(t);
|
|
213
319
|
}
|
|
214
320
|
// --- Reading the value ---
|
|
215
321
|
get resolvedLocale() {
|
|
216
|
-
return
|
|
322
|
+
return M(this.locale);
|
|
217
323
|
}
|
|
218
324
|
get selection() {
|
|
219
|
-
return this.range ?
|
|
325
|
+
return this.range ? P(this.value) : { start: u(this.value), end: u(this.value) };
|
|
220
326
|
}
|
|
221
327
|
isComplete() {
|
|
222
|
-
const { start:
|
|
223
|
-
return
|
|
328
|
+
const { start: t, end: e } = this.selection;
|
|
329
|
+
return t !== null && e !== null && g(t, e) <= 0;
|
|
224
330
|
}
|
|
225
331
|
display() {
|
|
226
|
-
const { start:
|
|
227
|
-
if (!
|
|
228
|
-
const
|
|
229
|
-
return this.range ?
|
|
332
|
+
const { start: t, end: e } = this.selection;
|
|
333
|
+
if (!t || !e) return null;
|
|
334
|
+
const o = _(this.resolvedLocale, { dateStyle: "medium" });
|
|
335
|
+
return this.range ? o.formatRange(w(t), w(e)) : o.format(w(t));
|
|
336
|
+
}
|
|
337
|
+
static {
|
|
338
|
+
this.WIDE_ENOUGH = 720;
|
|
230
339
|
}
|
|
231
340
|
async show() {
|
|
232
|
-
this.inactive || this.open || (this.open = !0, await this.updateComplete, this.calendar?.focus());
|
|
341
|
+
this.inactive || this.open || (this.compact = window.innerWidth < $.WIDE_ENOUGH, this.open = !0, await this.updateComplete, this.calendar?.focus());
|
|
233
342
|
}
|
|
234
|
-
close(
|
|
235
|
-
this.open && (this.open = !1,
|
|
343
|
+
close(t) {
|
|
344
|
+
this.open && (this.open = !1, t && this.focus());
|
|
236
345
|
}
|
|
237
346
|
toggle() {
|
|
238
|
-
this.open ? this.close(!
|
|
347
|
+
this.open ? this.close(!0) : this.show();
|
|
348
|
+
}
|
|
349
|
+
/** A click in the text opens the calendar, leaving the focus to type. */
|
|
350
|
+
openForTyping() {
|
|
351
|
+
this.inactive || this.open || (this.compact = window.innerWidth < $.WIDE_ENOUGH, this.open = !0);
|
|
239
352
|
}
|
|
240
353
|
// --- Choosing ---
|
|
241
|
-
onCalendarChange(
|
|
242
|
-
|
|
354
|
+
onCalendarChange(t) {
|
|
355
|
+
t.stopPropagation(), this.editing = !1, this.typedError = "", this.value = t.detail.value, this.close(!0), v(this, "kt-change", { value: this.value });
|
|
356
|
+
}
|
|
357
|
+
/** A preset, or today: committed at once, the calendar closed. */
|
|
358
|
+
apply(t) {
|
|
359
|
+
this.editing = !1, this.typedError = "", this.close(!0), t !== this.value && (this.value = t, v(this, "kt-change", { value: t }));
|
|
360
|
+
}
|
|
361
|
+
/** Whether any of a period falls outside min and max. */
|
|
362
|
+
outOfBounds(t) {
|
|
363
|
+
const { start: e, end: o } = P(t), r = u(this.min), n = u(this.max);
|
|
364
|
+
return !e || !o ? !0 : r !== null && g(e, r) < 0 || n !== null && g(o, n) > 0;
|
|
365
|
+
}
|
|
366
|
+
renderPresets() {
|
|
367
|
+
const t = this.presets ?? H();
|
|
368
|
+
return !this.range || t.length === 0 ? d : p`<div
|
|
369
|
+
part="presets"
|
|
370
|
+
class="presets"
|
|
371
|
+
role="group"
|
|
372
|
+
aria-label=${f().selectPeriod}
|
|
373
|
+
>
|
|
374
|
+
${t.map(
|
|
375
|
+
(e) => p`<button
|
|
376
|
+
type="button"
|
|
377
|
+
aria-pressed=${e.value === this.value ? "true" : "false"}
|
|
378
|
+
?disabled=${this.outOfBounds(e.value)}
|
|
379
|
+
@click=${() => this.apply(e.value)}
|
|
380
|
+
>
|
|
381
|
+
${e.label}
|
|
382
|
+
</button>`
|
|
383
|
+
)}
|
|
384
|
+
</div>`;
|
|
243
385
|
}
|
|
244
386
|
clear() {
|
|
245
|
-
this.value = null,
|
|
387
|
+
this.editing = !1, this.typedError = "", this.value = null, v(this, "kt-change", { value: null }), this.focus();
|
|
388
|
+
}
|
|
389
|
+
// --- Typing ---
|
|
390
|
+
onInput(t) {
|
|
391
|
+
this.text = t.target.value, this.editing = !0;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Reads what was typed into the value. Text that is not a date, or is a date
|
|
395
|
+
* outside min and max, is flagged and the value kept; an empty field empties
|
|
396
|
+
* the value.
|
|
397
|
+
*/
|
|
398
|
+
commitTyped() {
|
|
399
|
+
if (!this.editing) return;
|
|
400
|
+
this.editing = !1;
|
|
401
|
+
const t = this.text.trim();
|
|
402
|
+
if (!t) {
|
|
403
|
+
this.typedError = "", this.value !== null && (this.value = null, v(this, "kt-change", { value: null }));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const e = this.resolvedLocale, o = m(), r = this.range ? U(t, e, o) : (() => {
|
|
407
|
+
const b = Y(t, e, o);
|
|
408
|
+
return b && { start: b, end: b };
|
|
409
|
+
})();
|
|
410
|
+
if (!r) {
|
|
411
|
+
this.text = t, this.editing = !0, this.typedError = f().dateInvalid(j(e, o));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const n = u(this.min), c = u(this.max);
|
|
415
|
+
if (n && g(r.start, n) < 0 || c && g(r.end, c) > 0) {
|
|
416
|
+
this.text = t, this.editing = !0, this.typedError = f().dateOutOfRange;
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
this.typedError = "";
|
|
420
|
+
const y = this.range ? k(r.start, r.end) : C(r.start);
|
|
421
|
+
y !== this.value && (this.value = y, v(this, "kt-change", { value: y }));
|
|
246
422
|
}
|
|
247
423
|
// --- Keyboard ---
|
|
248
|
-
|
|
249
|
-
(
|
|
424
|
+
onInputKeyDown(t) {
|
|
425
|
+
switch (t.key) {
|
|
426
|
+
case "Enter":
|
|
427
|
+
t.preventDefault(), this.commitTyped(), this.typedError || this.close(!1);
|
|
428
|
+
return;
|
|
429
|
+
case "Escape":
|
|
430
|
+
if (!this.editing && !this.open) return;
|
|
431
|
+
t.preventDefault(), t.stopPropagation(), this.editing = !1, this.typedError = "", this.close(!1);
|
|
432
|
+
return;
|
|
433
|
+
case "ArrowDown":
|
|
434
|
+
t.preventDefault(), this.show();
|
|
435
|
+
}
|
|
250
436
|
}
|
|
251
|
-
onPanelKeyDown(
|
|
252
|
-
|
|
437
|
+
onPanelKeyDown(t) {
|
|
438
|
+
t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), this.close(!0));
|
|
253
439
|
}
|
|
254
440
|
// --- Rendering ---
|
|
255
441
|
render() {
|
|
256
|
-
const e = this.display(),
|
|
257
|
-
return
|
|
442
|
+
const t = f(), e = this.display(), o = this.placeholder ?? (this.range ? t.selectPeriod : t.selectDate), r = this.error || this.typedError, n = this.clearable && this.value !== null && !this.inactive && !this.editing && !r;
|
|
443
|
+
return p`${r ? p`<span id="error-message" class="visually-hidden">${r}</span>` : d}
|
|
258
444
|
<div
|
|
259
|
-
class=${
|
|
260
|
-
field: !0,
|
|
261
|
-
open: this.open,
|
|
262
|
-
error: !!this.error,
|
|
263
|
-
clearable: i
|
|
264
|
-
})}
|
|
445
|
+
class=${x({ open: this.open, error: !!r })}
|
|
265
446
|
@focusout=${this.onFocusOut}
|
|
266
447
|
>
|
|
267
|
-
<
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
448
|
+
<div part="field" class="field">
|
|
449
|
+
<button
|
|
450
|
+
part="trigger"
|
|
451
|
+
type="button"
|
|
452
|
+
class="trigger"
|
|
453
|
+
tabindex="-1"
|
|
454
|
+
aria-label=${t.openCalendar}
|
|
455
|
+
aria-haspopup="dialog"
|
|
456
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
457
|
+
aria-controls=${this.panelId}
|
|
458
|
+
?disabled=${this.inactive}
|
|
459
|
+
@click=${this.toggle}
|
|
460
|
+
>
|
|
461
|
+
<kt-icon name="calendar" size="18"></kt-icon>
|
|
462
|
+
</button>
|
|
463
|
+
<input
|
|
464
|
+
part="input"
|
|
465
|
+
.value=${O(this.editing ? this.text : e ?? "")}
|
|
466
|
+
placeholder=${o}
|
|
467
|
+
autocomplete="off"
|
|
468
|
+
aria-label=${this.label || o}
|
|
469
|
+
aria-invalid=${r ? "true" : d}
|
|
470
|
+
aria-describedby=${r ? "error-message" : d}
|
|
471
|
+
?disabled=${this.inactive}
|
|
472
|
+
@input=${this.onInput}
|
|
473
|
+
@change=${this.commitTyped}
|
|
474
|
+
@keydown=${this.onInputKeyDown}
|
|
475
|
+
@click=${this.openForTyping}
|
|
476
|
+
@focus=${() => {
|
|
477
|
+
this.focused = !0;
|
|
478
|
+
}}
|
|
479
|
+
@blur=${() => {
|
|
480
|
+
this.focused = !1;
|
|
481
|
+
}}
|
|
482
|
+
/>
|
|
483
|
+
${r ? p`<kt-tooltip class="error-icon" text=${r} ?open=${this.focused}>
|
|
484
|
+
<kt-icon name="circle-alert" size="18"></kt-icon>
|
|
485
|
+
</kt-tooltip>` : d}
|
|
486
|
+
${n ? p`<button type="button" class="clear" aria-label=${t.clear} @click=${this.clear}>
|
|
487
|
+
<kt-icon name="x" size="18"></kt-icon>
|
|
488
|
+
</button>` : d}
|
|
489
|
+
</div>
|
|
294
490
|
|
|
295
491
|
<div
|
|
296
492
|
part="panel"
|
|
297
493
|
id=${this.panelId}
|
|
298
494
|
popover="manual"
|
|
299
|
-
class=${
|
|
495
|
+
class=${x({
|
|
300
496
|
panel: !0,
|
|
301
497
|
floating: !0,
|
|
302
498
|
open: this.open,
|
|
@@ -304,79 +500,114 @@ class r extends m {
|
|
|
304
500
|
})}
|
|
305
501
|
role="dialog"
|
|
306
502
|
aria-modal="false"
|
|
307
|
-
aria-label=${this.range ?
|
|
503
|
+
aria-label=${this.range ? t.selectPeriod : t.selectDate}
|
|
308
504
|
@keydown=${this.onPanelKeyDown}
|
|
309
505
|
>
|
|
310
|
-
${this.open ?
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
506
|
+
${this.open ? p`<div class=${x({ "panel-body": !0, compact: this.compact })}>
|
|
507
|
+
${this.renderPresets()}
|
|
508
|
+
<div>
|
|
509
|
+
<kt-calendar
|
|
510
|
+
part="calendar"
|
|
511
|
+
.value=${this.value}
|
|
512
|
+
?range=${this.range}
|
|
513
|
+
months=${this.range && !this.compact ? 2 : 1}
|
|
514
|
+
min=${this.min}
|
|
515
|
+
max=${this.max}
|
|
516
|
+
locale=${this.locale}
|
|
517
|
+
label=${this.label}
|
|
518
|
+
@kt-change=${this.onCalendarChange}
|
|
519
|
+
></kt-calendar>
|
|
520
|
+
${this.range ? d : p`<div class="footer">
|
|
521
|
+
<button
|
|
522
|
+
type="button"
|
|
523
|
+
class="today"
|
|
524
|
+
?disabled=${this.outOfBounds(k(m(), m()))}
|
|
525
|
+
@click=${() => this.apply(C(m()))}
|
|
526
|
+
>
|
|
527
|
+
${t.presetToday}
|
|
528
|
+
</button>
|
|
529
|
+
</div>`}
|
|
530
|
+
</div>
|
|
531
|
+
</div>` : d}
|
|
320
532
|
</div>
|
|
321
533
|
</div>`;
|
|
322
534
|
}
|
|
323
|
-
}
|
|
535
|
+
};
|
|
536
|
+
a([
|
|
537
|
+
S("input")
|
|
538
|
+
], i.prototype, "input");
|
|
539
|
+
a([
|
|
540
|
+
S("kt-calendar")
|
|
541
|
+
], i.prototype, "calendar");
|
|
542
|
+
a([
|
|
543
|
+
h()
|
|
544
|
+
], i.prototype, "open");
|
|
545
|
+
a([
|
|
546
|
+
h()
|
|
547
|
+
], i.prototype, "text");
|
|
548
|
+
a([
|
|
549
|
+
h()
|
|
550
|
+
], i.prototype, "editing");
|
|
551
|
+
a([
|
|
552
|
+
h()
|
|
553
|
+
], i.prototype, "typedError");
|
|
324
554
|
a([
|
|
325
|
-
|
|
326
|
-
],
|
|
555
|
+
h()
|
|
556
|
+
], i.prototype, "focused");
|
|
327
557
|
a([
|
|
328
|
-
|
|
329
|
-
],
|
|
558
|
+
h()
|
|
559
|
+
], i.prototype, "compact");
|
|
330
560
|
a([
|
|
331
|
-
|
|
332
|
-
],
|
|
561
|
+
h()
|
|
562
|
+
], i.prototype, "placement");
|
|
333
563
|
a([
|
|
334
|
-
|
|
335
|
-
],
|
|
564
|
+
s({ type: String, reflect: !0 })
|
|
565
|
+
], i.prototype, "value");
|
|
336
566
|
a([
|
|
337
|
-
|
|
338
|
-
],
|
|
567
|
+
s({ type: Boolean, reflect: !0 })
|
|
568
|
+
], i.prototype, "range");
|
|
339
569
|
a([
|
|
340
|
-
|
|
341
|
-
],
|
|
570
|
+
s({ type: String })
|
|
571
|
+
], i.prototype, "min");
|
|
342
572
|
a([
|
|
343
|
-
|
|
344
|
-
],
|
|
573
|
+
s({ type: String })
|
|
574
|
+
], i.prototype, "max");
|
|
345
575
|
a([
|
|
346
|
-
|
|
347
|
-
],
|
|
576
|
+
s({ type: String })
|
|
577
|
+
], i.prototype, "name");
|
|
348
578
|
a([
|
|
349
|
-
|
|
350
|
-
],
|
|
579
|
+
s({ type: String })
|
|
580
|
+
], i.prototype, "label");
|
|
351
581
|
a([
|
|
352
|
-
|
|
353
|
-
],
|
|
582
|
+
s({ type: String })
|
|
583
|
+
], i.prototype, "placeholder");
|
|
354
584
|
a([
|
|
355
|
-
|
|
356
|
-
],
|
|
585
|
+
s({ type: String })
|
|
586
|
+
], i.prototype, "locale");
|
|
357
587
|
a([
|
|
358
|
-
|
|
359
|
-
],
|
|
588
|
+
s({ type: String, reflect: !0 })
|
|
589
|
+
], i.prototype, "size");
|
|
360
590
|
a([
|
|
361
|
-
|
|
362
|
-
],
|
|
591
|
+
s({ type: Boolean, reflect: !0 })
|
|
592
|
+
], i.prototype, "disabled");
|
|
363
593
|
a([
|
|
364
|
-
|
|
365
|
-
],
|
|
594
|
+
h()
|
|
595
|
+
], i.prototype, "formDisabled");
|
|
366
596
|
a([
|
|
367
|
-
|
|
368
|
-
],
|
|
597
|
+
s({ type: Boolean, reflect: !0 })
|
|
598
|
+
], i.prototype, "required");
|
|
369
599
|
a([
|
|
370
|
-
|
|
371
|
-
],
|
|
600
|
+
s({ type: Boolean })
|
|
601
|
+
], i.prototype, "clearable");
|
|
372
602
|
a([
|
|
373
|
-
|
|
374
|
-
],
|
|
603
|
+
s({ attribute: !1 })
|
|
604
|
+
], i.prototype, "presets");
|
|
375
605
|
a([
|
|
376
|
-
|
|
377
|
-
],
|
|
378
|
-
|
|
606
|
+
s({ type: String, reflect: !0 })
|
|
607
|
+
], i.prototype, "error");
|
|
608
|
+
let N = i;
|
|
609
|
+
R("kt-date-picker", N);
|
|
379
610
|
export {
|
|
380
|
-
|
|
611
|
+
N as KtDatePicker
|
|
381
612
|
};
|
|
382
613
|
//# sourceMappingURL=kt-date-picker.js.map
|