@mintplayer/web-components 2.5.0 → 2.7.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/a11y/index.mjs +9 -8
- package/checkbox/index.mjs +1 -1
- package/chunks/error-text-B45eDAt1.mjs +17 -0
- package/chunks/{form-associated-axmc5sY0.mjs → form-associated-BR-fUvZ1.mjs} +11 -26
- package/chunks/{id-D5QCG603.mjs → id-BstjfRrz.mjs} +97 -72
- package/chunks/{mp-checkbox-Ph2mMRGz.mjs → mp-checkbox-6EJwdUIn.mjs} +6 -5
- package/chunks/{mp-datatable-BwTlh9A_.mjs → mp-datatable-25O1GtvU.mjs} +1 -1
- package/chunks/mp-datetime-picker.element-MPTRHwyc.mjs +530 -0
- package/chunks/{mp-radio-BjW1HNSc.mjs → mp-radio-DvKgrTFL.mjs} +2 -2
- package/chunks/{mp-select-Ctu-v1-p.mjs → mp-select-CKX0eM5C.mjs} +5 -4
- package/chunks/{mp-timepicker.element-Bz393NDQ.mjs → mp-timepicker.element-COZEUIoE.mjs} +56 -52
- package/chunks/{mp-toggle-button-Kz6sIgBJ.mjs → mp-toggle-button-C4Loq_p4.mjs} +5 -4
- package/chunks/{overlay-controller-DPt13i8p.mjs → overlay-controller-D6agzzOI.mjs} +19 -4
- package/datatable/index.mjs +1 -1
- package/datepicker/index.mjs +1 -1
- package/datetime-picker/index.mjs +2 -431
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +66 -0
- package/file-manager/index.mjs +1 -1
- package/navbar/index.mjs +1 -1
- package/otp-input/index.mjs +4 -3
- package/overlay/index.mjs +1 -1
- package/overlay/src/overlay-controller.d.ts +13 -0
- package/package.json +1 -1
- package/query-builder/index.mjs +2 -2
- package/radio/index.mjs +1 -1
- package/radio-group/index.mjs +2 -2
- package/ribbon/index.mjs +1 -1
- package/scheduler/index.mjs +1996 -813
- package/scheduler/src/components/mp-scheduler.d.ts +269 -11
- package/scheduler/src/state/scheduler-state.d.ts +10 -0
- package/scheduler/src/views/timeline-view.d.ts +51 -3
- package/scheduler/src/views/year-view.d.ts +4 -2
- package/scheduler-core/index.mjs +9 -8
- package/scheduler-core/src/models/event.d.ts +6 -2
- package/scheduler-core/src/models/messages.d.ts +60 -0
- package/scheduler-core/src/models/options.d.ts +22 -6
- package/scheduler-core/src/models/permissions.d.ts +35 -4
- package/scheduler-core/src/models/time-slot.d.ts +11 -6
- package/select/index.mjs +1 -1
- package/timepicker/index.mjs +4 -3
- package/timepicker/src/mp-time-list.element.d.ts +44 -7
- package/timepicker/src/mp-timepicker.element.d.ts +5 -0
- package/toggle-button/index.mjs +1 -1
- package/tree-select/index.mjs +1 -1
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { html as c, unsafeCSS as v, LitElement as y, nothing as b } from "lit";
|
|
2
|
+
import { query as n } from "lit/decorators.js";
|
|
3
|
+
import { L as w } from "./live-announcer-Bi0orG4n.mjs";
|
|
4
|
+
import { e as D } from "./error-text-B45eDAt1.mjs";
|
|
5
|
+
import { O as g } from "./overlay-controller-D6agzzOI.mjs";
|
|
6
|
+
import "./mp-calendar.element-u6uS31_j.mjs";
|
|
7
|
+
import { m as p } from "./mp-timepicker.element-COZEUIoE.mjs";
|
|
8
|
+
import { i as $ } from "./invalid-feedback.styles-he0JYrJm.mjs";
|
|
9
|
+
c`<!-- Rendered dynamically by render(). Codegen-wc emits styles from the
|
|
10
|
+
sibling .scss; the template export is intentionally unused. -->`;
|
|
11
|
+
const C = v(`:host {
|
|
12
|
+
display: inline-block;
|
|
13
|
+
position: relative;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
font-family: inherit;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.input-group {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
position: relative;
|
|
21
|
+
width: 100%;
|
|
22
|
+
align-items: stretch;
|
|
23
|
+
border-radius: var(--bs-border-radius, 0.375rem);
|
|
24
|
+
}
|
|
25
|
+
.input-group:focus-within {
|
|
26
|
+
box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
|
|
27
|
+
}
|
|
28
|
+
.input-group:focus-within input.form-control,
|
|
29
|
+
.input-group:focus-within button.trigger {
|
|
30
|
+
border-color: var(--bs-primary);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
input.form-control {
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
padding: 0.375rem 0.75rem;
|
|
37
|
+
font-size: 1rem;
|
|
38
|
+
line-height: 1.5;
|
|
39
|
+
color: var(--bs-body-color);
|
|
40
|
+
background-color: var(--bs-body-bg);
|
|
41
|
+
border: 1px solid var(--bs-border-color);
|
|
42
|
+
border-inline-end-width: 0;
|
|
43
|
+
border-start-start-radius: var(--bs-border-radius, 0.375rem);
|
|
44
|
+
border-end-start-radius: var(--bs-border-radius, 0.375rem);
|
|
45
|
+
border-start-end-radius: 0;
|
|
46
|
+
border-end-end-radius: 0;
|
|
47
|
+
outline: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.input-group:has(input.form-control.is-invalid) input.form-control,
|
|
51
|
+
.input-group:has(input.form-control.is-invalid) button.trigger {
|
|
52
|
+
border-color: var(--bs-form-invalid-border-color, var(--bs-danger));
|
|
53
|
+
}
|
|
54
|
+
.input-group:has(input.form-control.is-invalid):focus-within {
|
|
55
|
+
box-shadow: 0 0 0 0.2rem rgba(var(--bs-danger-rgb), 0.25);
|
|
56
|
+
}
|
|
57
|
+
.input-group:has(input.form-control.is-invalid):focus-within input.form-control,
|
|
58
|
+
.input-group:has(input.form-control.is-invalid):focus-within button.trigger {
|
|
59
|
+
border-color: var(--bs-form-invalid-border-color, var(--bs-danger));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
input.form-control:disabled {
|
|
63
|
+
background-color: var(--bs-secondary-bg);
|
|
64
|
+
opacity: 1;
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
button.trigger {
|
|
69
|
+
flex: 0 0 auto;
|
|
70
|
+
padding: 0.375rem 0.75rem;
|
|
71
|
+
font-size: 1rem;
|
|
72
|
+
line-height: 1.5;
|
|
73
|
+
color: var(--bs-body-color);
|
|
74
|
+
background-color: var(--bs-body-bg);
|
|
75
|
+
border: 1px solid var(--bs-border-color);
|
|
76
|
+
border-inline-start: 0;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
}
|
|
79
|
+
button.trigger.clear {
|
|
80
|
+
border-inline-start: 0;
|
|
81
|
+
border-inline-end: 0;
|
|
82
|
+
}
|
|
83
|
+
button.trigger.time {
|
|
84
|
+
border-start-end-radius: var(--bs-border-radius, 0.375rem);
|
|
85
|
+
border-end-end-radius: var(--bs-border-radius, 0.375rem);
|
|
86
|
+
}
|
|
87
|
+
button.trigger:hover:not(:disabled) {
|
|
88
|
+
background-color: var(--bs-secondary-bg);
|
|
89
|
+
}
|
|
90
|
+
button.trigger:focus-visible {
|
|
91
|
+
outline: 2px solid var(--bs-primary);
|
|
92
|
+
outline-offset: -2px;
|
|
93
|
+
}
|
|
94
|
+
button.trigger:disabled {
|
|
95
|
+
opacity: 0.65;
|
|
96
|
+
cursor: not-allowed;
|
|
97
|
+
}
|
|
98
|
+
button.trigger svg {
|
|
99
|
+
width: 1em;
|
|
100
|
+
height: 1em;
|
|
101
|
+
vertical-align: -0.125em;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.popup {
|
|
105
|
+
position: fixed;
|
|
106
|
+
z-index: 1050;
|
|
107
|
+
display: none;
|
|
108
|
+
padding: 0.5rem;
|
|
109
|
+
background-color: var(--bs-body-bg);
|
|
110
|
+
border: 1px solid var(--bs-border-color);
|
|
111
|
+
border-radius: var(--bs-border-radius, 0.375rem);
|
|
112
|
+
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
|
|
113
|
+
max-width: min(360px, 100vw - 16px);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([data-open=date]) .popup-date,
|
|
117
|
+
:host([data-open=time]) .popup-time {
|
|
118
|
+
display: block;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.popup-footer {
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: flex-end;
|
|
124
|
+
padding-top: 0.5rem;
|
|
125
|
+
}
|
|
126
|
+
.popup-footer button {
|
|
127
|
+
padding: 0.25rem 0.75rem;
|
|
128
|
+
font-size: 0.875rem;
|
|
129
|
+
color: #fff;
|
|
130
|
+
background-color: var(--bs-primary);
|
|
131
|
+
border: 1px solid var(--bs-primary);
|
|
132
|
+
border-radius: var(--bs-border-radius, 0.375rem);
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
}
|
|
135
|
+
.popup-footer button:hover {
|
|
136
|
+
filter: brightness(0.95);
|
|
137
|
+
}
|
|
138
|
+
.popup-footer button:focus-visible {
|
|
139
|
+
outline: 2px solid var(--bs-primary);
|
|
140
|
+
outline-offset: 2px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@media (pointer: coarse) {
|
|
144
|
+
button.trigger,
|
|
145
|
+
.popup-footer button {
|
|
146
|
+
min-height: 40px;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
@media (prefers-reduced-motion: reduce) {
|
|
150
|
+
.popup {
|
|
151
|
+
transition: none !important;
|
|
152
|
+
}
|
|
153
|
+
}`);
|
|
154
|
+
var O = Object.defineProperty, l = (a, e, t, i) => {
|
|
155
|
+
for (var r = void 0, u = a.length - 1, d; u >= 0; u--)
|
|
156
|
+
(d = a[u]) && (r = d(e, t, r) || r);
|
|
157
|
+
return r && O(e, t, r), r;
|
|
158
|
+
};
|
|
159
|
+
const T = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM2 2a1 1 0 0 0-1 1v1h14V3a1 1 0 0 0-1-1H2zm13 3H1v9a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V5z"/></svg>', x = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z"/><path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z"/></svg>', M = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/></svg>';
|
|
160
|
+
let P = 0;
|
|
161
|
+
function s(a) {
|
|
162
|
+
return new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime();
|
|
163
|
+
}
|
|
164
|
+
function f(a, e) {
|
|
165
|
+
return s(a) === s(e);
|
|
166
|
+
}
|
|
167
|
+
class o extends y {
|
|
168
|
+
constructor() {
|
|
169
|
+
super(...arguments), this.value = null, this.min = null, this.max = null, this.disableDateFn = null, this.firstDayOfWeek = 1, this.locale = void 0, this.hour12 = "auto", this.step = 15, this.defaultTime = { hour: 0, minute: 0 }, this.placeholder = "", this.showClear = !1, this.disabled = !1, this.invalid = !1, this.errorText = null, this.inputLabel = "Selected date and time", this.dateButtonLabel = "Choose date", this.timeButtonLabel = "Choose time", this.clearLabel = "Clear", this.todayLabel = "Today", this.nowLabel = "Now", this._openPopup = null, this._calendarMonth = null, this.instanceId = `mp-dtp-${++P}`, this.datePopupId = `${this.instanceId}-popup-date`, this.timePopupId = `${this.instanceId}-popup-time`, this.errorId = `${this.instanceId}-error`, this.dateOverlay = new g(this, {
|
|
170
|
+
anchor: () => this.inputGroupEl ?? this.dateTriggerEl ?? null,
|
|
171
|
+
trigger: () => this.dateTriggerEl ?? null,
|
|
172
|
+
panel: () => this.datePopupEl ?? null,
|
|
173
|
+
panelWidth: "anchor-min",
|
|
174
|
+
// APG Date Picker Dialog: opening moves focus onto the calendar grid's
|
|
175
|
+
// roving cell. A slotted consumer calendar wins over the shadow default.
|
|
176
|
+
initialFocus: () => this.datePopupEl?.querySelector('slot[name="calendar"]')?.assignedElements()[0] ?? this.datePopupEl?.querySelector("mp-calendar") ?? null,
|
|
177
|
+
onOpen: () => {
|
|
178
|
+
this.dispatchEvent(
|
|
179
|
+
new CustomEvent("opened", { detail: "date", bubbles: !0, composed: !0 })
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
onClose: () => {
|
|
183
|
+
this._openPopup === "date" && (this._openPopup = null), this.dispatchEvent(
|
|
184
|
+
new CustomEvent("closed", { detail: "date", bubbles: !0, composed: !0 })
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}), this.timeOverlay = new g(this, {
|
|
188
|
+
anchor: () => this.inputGroupEl ?? this.timeTriggerEl ?? null,
|
|
189
|
+
trigger: () => this.timeTriggerEl ?? null,
|
|
190
|
+
panel: () => this.timePopupEl ?? null,
|
|
191
|
+
panelWidth: "anchor-min",
|
|
192
|
+
// Opening moves focus onto the time list's active option (its focus()
|
|
193
|
+
// override lands there). A slotted consumer list wins over the default.
|
|
194
|
+
initialFocus: () => this.timePopupEl?.querySelector('slot[name="time-list"]')?.assignedElements()[0] ?? this.timePopupEl?.querySelector("mp-time-list") ?? null,
|
|
195
|
+
onOpen: () => {
|
|
196
|
+
this.dispatchEvent(
|
|
197
|
+
new CustomEvent("opened", { detail: "time", bubbles: !0, composed: !0 })
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
onClose: () => {
|
|
201
|
+
this._openPopup === "time" && (this._openPopup = null), this.dispatchEvent(
|
|
202
|
+
new CustomEvent("closed", { detail: "time", bubbles: !0, composed: !0 })
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}), this.liveAnnouncer = new w(this), this.lastAnnouncedValue = null, this.onDateTriggerClick = async (e) => {
|
|
206
|
+
this.disabled || (e.stopPropagation(), this.dateOverlay.isOpen ? this.dateOverlay.close() : await this.openDate());
|
|
207
|
+
}, this.onTimeTriggerClick = async (e) => {
|
|
208
|
+
this.disabled || (e.stopPropagation(), this.timeOverlay.isOpen ? this.timeOverlay.close() : await this.openTime());
|
|
209
|
+
}, this.onDateTriggerKeyDown = async (e) => {
|
|
210
|
+
this.disabled || (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.dateOverlay.isOpen || await this.openDate());
|
|
211
|
+
}, this.onTimeTriggerKeyDown = async (e) => {
|
|
212
|
+
this.disabled || (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.timeOverlay.isOpen || await this.openTime());
|
|
213
|
+
}, this.onClearClick = (e) => {
|
|
214
|
+
this.disabled || (e.stopPropagation(), this.clear());
|
|
215
|
+
}, this.onCalendarSelectedDateChange = (e) => {
|
|
216
|
+
const t = e.detail;
|
|
217
|
+
if (!(t instanceof Date)) return;
|
|
218
|
+
const i = this.value !== null && this.value.getFullYear() === t.getFullYear() && this.value.getMonth() === t.getMonth() && this.value.getDate() === t.getDate();
|
|
219
|
+
this.updateDatePart(t), i && this.dateOverlay.close();
|
|
220
|
+
}, this.onCalendarCurrentMonthChange = (e) => {
|
|
221
|
+
const t = e.detail;
|
|
222
|
+
t instanceof Date && (this._calendarMonth = t);
|
|
223
|
+
}, this.onTimeListSelectedTimeChange = (e) => {
|
|
224
|
+
const t = e.detail;
|
|
225
|
+
t instanceof Date && (this.updateTimePart(t), this.timeOverlay.close());
|
|
226
|
+
}, this.onTodayClick = () => {
|
|
227
|
+
this.todayOutOfRange() || this.updateDatePart(/* @__PURE__ */ new Date());
|
|
228
|
+
}, this.onNowClick = () => {
|
|
229
|
+
const e = this.roundedNow();
|
|
230
|
+
this.nowOutOfRange() || this.updateTimePart(e);
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
static {
|
|
234
|
+
this.styles = [C, $];
|
|
235
|
+
}
|
|
236
|
+
static {
|
|
237
|
+
this.properties = {
|
|
238
|
+
value: { attribute: !1 },
|
|
239
|
+
min: { attribute: !1 },
|
|
240
|
+
max: { attribute: !1 },
|
|
241
|
+
disableDateFn: { attribute: !1 },
|
|
242
|
+
firstDayOfWeek: { attribute: "first-day-of-week", type: Number, reflect: !0 },
|
|
243
|
+
locale: { attribute: "locale", type: String, reflect: !0 },
|
|
244
|
+
hour12: { attribute: "hour12" },
|
|
245
|
+
step: { attribute: "step", type: Number, reflect: !0 },
|
|
246
|
+
defaultTime: { attribute: !1 },
|
|
247
|
+
placeholder: { attribute: "placeholder", type: String, reflect: !0 },
|
|
248
|
+
showClear: { attribute: "show-clear", type: Boolean, reflect: !0 },
|
|
249
|
+
disabled: { attribute: "disabled", type: Boolean, reflect: !0 },
|
|
250
|
+
invalid: { attribute: "invalid", type: Boolean, reflect: !0 },
|
|
251
|
+
errorText: { attribute: "error-text", type: String, reflect: !1 },
|
|
252
|
+
inputLabel: { attribute: "input-label", type: String, reflect: !0 },
|
|
253
|
+
dateButtonLabel: { attribute: "date-button-label", type: String, reflect: !0 },
|
|
254
|
+
timeButtonLabel: { attribute: "time-button-label", type: String, reflect: !0 },
|
|
255
|
+
clearLabel: { attribute: "clear-label", type: String, reflect: !0 },
|
|
256
|
+
todayLabel: { attribute: "today-label", type: String, reflect: !0 },
|
|
257
|
+
nowLabel: { attribute: "now-label", type: String, reflect: !0 },
|
|
258
|
+
_openPopup: { state: !0 },
|
|
259
|
+
_calendarMonth: { state: !0 }
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Focusing the picker means focusing its display input — the node that
|
|
264
|
+
* carries the accessible name, the invalid state and the error message's
|
|
265
|
+
* description, so it is also the node that must receive focus for a
|
|
266
|
+
* validation message to be spoken.
|
|
267
|
+
*
|
|
268
|
+
* An override rather than `delegatesFocus: true`, which would change what a
|
|
269
|
+
* click anywhere in the input-group focuses for every consumer.
|
|
270
|
+
*/
|
|
271
|
+
focus(e) {
|
|
272
|
+
const t = this.displayInputEl;
|
|
273
|
+
t ? t.focus(e) : super.focus(e);
|
|
274
|
+
}
|
|
275
|
+
willUpdate(e) {
|
|
276
|
+
e.has("value") && this.value && !this._calendarMonth && (this._calendarMonth = new Date(this.value.getFullYear(), this.value.getMonth(), 1));
|
|
277
|
+
}
|
|
278
|
+
updated(e) {
|
|
279
|
+
super.updated?.(e), e.has("_openPopup") && (this._openPopup === null ? this.removeAttribute("data-open") : this.setAttribute("data-open", this._openPopup));
|
|
280
|
+
}
|
|
281
|
+
/* ---- Public API ---- */
|
|
282
|
+
setValue(e, t = !0) {
|
|
283
|
+
const i = e === null && this.value === null || e instanceof Date && this.value instanceof Date && e.getTime() === this.value.getTime();
|
|
284
|
+
this.value = e ? new Date(e.getTime()) : null, e && (this._calendarMonth = new Date(e.getFullYear(), e.getMonth(), 1)), this.requestUpdate(), t && !i && (this.dispatchEvent(
|
|
285
|
+
new CustomEvent("value-change", {
|
|
286
|
+
detail: this.value ? new Date(this.value.getTime()) : null,
|
|
287
|
+
bubbles: !0,
|
|
288
|
+
composed: !0
|
|
289
|
+
})
|
|
290
|
+
), this.announceValue());
|
|
291
|
+
}
|
|
292
|
+
/** Polite live-region announce on value change. Skipped on first render. */
|
|
293
|
+
announceValue() {
|
|
294
|
+
const e = this.value ? this.value.getTime() : null;
|
|
295
|
+
if (this.lastAnnouncedValue, e === this.lastAnnouncedValue) return;
|
|
296
|
+
if (this.lastAnnouncedValue = e, this.value === null) {
|
|
297
|
+
this.liveAnnouncer.announce(`${this.clearLabel}`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const t = this.value.toLocaleString(this.locale ?? void 0, {
|
|
301
|
+
dateStyle: "long",
|
|
302
|
+
timeStyle: "short",
|
|
303
|
+
hour12: this.resolvedHour12()
|
|
304
|
+
});
|
|
305
|
+
this.liveAnnouncer.announce(`${t} selected`);
|
|
306
|
+
}
|
|
307
|
+
clear() {
|
|
308
|
+
this.disabled || this.setValue(null);
|
|
309
|
+
}
|
|
310
|
+
get openPopup() {
|
|
311
|
+
return this._openPopup;
|
|
312
|
+
}
|
|
313
|
+
async openDate() {
|
|
314
|
+
this.disabled || (this.timeOverlay.isOpen && this.timeOverlay.close(!1), this._openPopup = "date", await this.dateOverlay.open());
|
|
315
|
+
}
|
|
316
|
+
async openTime() {
|
|
317
|
+
this.disabled || (this.dateOverlay.isOpen && this.dateOverlay.close(!1), this._openPopup = "time", await this.timeOverlay.open());
|
|
318
|
+
}
|
|
319
|
+
closePopups() {
|
|
320
|
+
this.dateOverlay.isOpen && this.dateOverlay.close(), this.timeOverlay.isOpen && this.timeOverlay.close();
|
|
321
|
+
}
|
|
322
|
+
/* ---- Display ---- */
|
|
323
|
+
formatDisplay() {
|
|
324
|
+
return this.value ? this.value.toLocaleString(this.locale ?? void 0, {
|
|
325
|
+
dateStyle: "short",
|
|
326
|
+
timeStyle: "short",
|
|
327
|
+
hour12: this.resolvedHour12()
|
|
328
|
+
}) : "";
|
|
329
|
+
}
|
|
330
|
+
resolvedHour12() {
|
|
331
|
+
if (this.hour12 === !0) return !0;
|
|
332
|
+
if (this.hour12 === !1) return !1;
|
|
333
|
+
}
|
|
334
|
+
/* ---- Value composition ---- */
|
|
335
|
+
updateDatePart(e) {
|
|
336
|
+
const t = this.value ? { hour: this.value.getHours(), minute: this.value.getMinutes() } : { hour: this.defaultTime.hour, minute: this.defaultTime.minute }, i = new Date(
|
|
337
|
+
e.getFullYear(),
|
|
338
|
+
e.getMonth(),
|
|
339
|
+
e.getDate(),
|
|
340
|
+
t.hour,
|
|
341
|
+
t.minute,
|
|
342
|
+
0,
|
|
343
|
+
0
|
|
344
|
+
);
|
|
345
|
+
this.setValue(i);
|
|
346
|
+
}
|
|
347
|
+
updateTimePart(e) {
|
|
348
|
+
const t = /* @__PURE__ */ new Date(), i = this.value ?? t, r = new Date(
|
|
349
|
+
i.getFullYear(),
|
|
350
|
+
i.getMonth(),
|
|
351
|
+
i.getDate(),
|
|
352
|
+
e.getHours(),
|
|
353
|
+
e.getMinutes(),
|
|
354
|
+
0,
|
|
355
|
+
0
|
|
356
|
+
);
|
|
357
|
+
this.setValue(r);
|
|
358
|
+
}
|
|
359
|
+
/** `Now`, snapped down to the nearest step — the value that button writes. */
|
|
360
|
+
roundedNow() {
|
|
361
|
+
const e = /* @__PURE__ */ new Date(), t = Math.floor(e.getMinutes() / this.step) * this.step;
|
|
362
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), t, 0, 0);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* `Today` and `Now` used to write their value with no bound check at all, so
|
|
366
|
+
* a footer button escaped a constraint the grid one layer below enforced.
|
|
367
|
+
* They are DISABLED rather than silently ignored — a control that does
|
|
368
|
+
* nothing when pressed is the worse of the two failures.
|
|
369
|
+
*/
|
|
370
|
+
todayOutOfRange() {
|
|
371
|
+
const e = /* @__PURE__ */ new Date();
|
|
372
|
+
return this.min && s(e) < s(this.min) || this.max && s(e) > s(this.max) ? !0 : !!this.disableDateFn?.(e);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* `Now` writes only the TIME half, onto whichever day is currently selected,
|
|
376
|
+
* so it is bounded by that day's derived range — not by "is now within
|
|
377
|
+
* min..max", which would be a different question entirely.
|
|
378
|
+
*/
|
|
379
|
+
nowOutOfRange() {
|
|
380
|
+
const e = p(this.roundedNow()), { minMinutes: t, maxMinutes: i } = this.timeBounds();
|
|
381
|
+
return t !== null && e < t || i !== null && e > i;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The time list's bounds for the day being edited (D12.15 #1/#2).
|
|
385
|
+
*
|
|
386
|
+
* A bound only constrains the CLOCK on its own day: an end on a later day
|
|
387
|
+
* gets the full 24 hours, which is what Google Calendar and Outlook both do.
|
|
388
|
+
* Forwarding `min`/`max` verbatim — as this element failed to do at all,
|
|
389
|
+
* while both its siblings did — would instead grey out the same clock range
|
|
390
|
+
* on every day.
|
|
391
|
+
*
|
|
392
|
+
* The day in question is `value ?? today` — not a guess, but exactly what
|
|
393
|
+
* `updateTimePart` will compose the picked time with when no date has been
|
|
394
|
+
* chosen yet. Deriving it from anything else would bound a day the pick is
|
|
395
|
+
* not going to land on.
|
|
396
|
+
*/
|
|
397
|
+
timeBounds() {
|
|
398
|
+
const e = this.value ?? /* @__PURE__ */ new Date();
|
|
399
|
+
return {
|
|
400
|
+
minMinutes: this.min && f(e, this.min) ? p(this.min) : null,
|
|
401
|
+
maxMinutes: this.max && f(e, this.max) ? p(this.max) : null
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
/* ---- Render ---- */
|
|
405
|
+
render() {
|
|
406
|
+
const e = this.formatDisplay(), t = this.value !== null, i = this.showClear && t && !this.disabled, r = this._calendarMonth ?? (this.value ? new Date(this.value.getFullYear(), this.value.getMonth(), 1) : /* @__PURE__ */ new Date()), u = this.value ?? null, d = this.value ?? null, h = D(this.errorId, this.errorText, this.invalid), m = this.timeBounds();
|
|
407
|
+
return c`
|
|
408
|
+
<div class="input-group">
|
|
409
|
+
<input
|
|
410
|
+
class="form-control ${this.invalid ? "is-invalid" : ""}"
|
|
411
|
+
type="text"
|
|
412
|
+
readonly
|
|
413
|
+
aria-readonly="true"
|
|
414
|
+
aria-label="${this.inputLabel}"
|
|
415
|
+
aria-invalid="${this.invalid ? "true" : "false"}"
|
|
416
|
+
aria-errormessage="${h.id}"
|
|
417
|
+
aria-describedby="${h.id}"
|
|
418
|
+
.value="${e}"
|
|
419
|
+
placeholder="${this.placeholder || b}"
|
|
420
|
+
?disabled="${this.disabled}"
|
|
421
|
+
/>
|
|
422
|
+
${i ? c`<button
|
|
423
|
+
class="trigger clear"
|
|
424
|
+
type="button"
|
|
425
|
+
aria-label="${this.clearLabel}"
|
|
426
|
+
?disabled="${this.disabled}"
|
|
427
|
+
@click="${this.onClearClick}"
|
|
428
|
+
.innerHTML="${M}"
|
|
429
|
+
></button>` : b}
|
|
430
|
+
<button
|
|
431
|
+
class="trigger date"
|
|
432
|
+
type="button"
|
|
433
|
+
aria-haspopup="dialog"
|
|
434
|
+
aria-expanded="${this._openPopup === "date" ? "true" : "false"}"
|
|
435
|
+
aria-controls="${this.datePopupId}"
|
|
436
|
+
aria-label="${this.dateButtonLabel}"
|
|
437
|
+
?disabled="${this.disabled}"
|
|
438
|
+
@click="${this.onDateTriggerClick}"
|
|
439
|
+
@keydown="${this.onDateTriggerKeyDown}"
|
|
440
|
+
.innerHTML="${T}"
|
|
441
|
+
></button>
|
|
442
|
+
<button
|
|
443
|
+
class="trigger time"
|
|
444
|
+
type="button"
|
|
445
|
+
aria-haspopup="dialog"
|
|
446
|
+
aria-expanded="${this._openPopup === "time" ? "true" : "false"}"
|
|
447
|
+
aria-controls="${this.timePopupId}"
|
|
448
|
+
aria-label="${this.timeButtonLabel}"
|
|
449
|
+
?disabled="${this.disabled}"
|
|
450
|
+
@click="${this.onTimeTriggerClick}"
|
|
451
|
+
@keydown="${this.onTimeTriggerKeyDown}"
|
|
452
|
+
.innerHTML="${x}"
|
|
453
|
+
></button>
|
|
454
|
+
</div>
|
|
455
|
+
${h.node}
|
|
456
|
+
${this.liveAnnouncer.template()}
|
|
457
|
+
|
|
458
|
+
<div class="popup popup-date" id="${this.datePopupId}" role="dialog" aria-label="${this.dateButtonLabel}">
|
|
459
|
+
<slot name="calendar"
|
|
460
|
+
@selected-date-change="${this.onCalendarSelectedDateChange}"
|
|
461
|
+
@current-month-change="${this.onCalendarCurrentMonthChange}"
|
|
462
|
+
>
|
|
463
|
+
<mp-calendar
|
|
464
|
+
.selectedDate="${u}"
|
|
465
|
+
.currentMonth="${r}"
|
|
466
|
+
.disableDateFn="${this.disableDateFn}"
|
|
467
|
+
.min="${this.min}"
|
|
468
|
+
.max="${this.max}"
|
|
469
|
+
.firstDayOfWeek="${this.firstDayOfWeek}"
|
|
470
|
+
.locale="${this.locale}"
|
|
471
|
+
@selected-date-change="${this.onCalendarSelectedDateChange}"
|
|
472
|
+
@current-month-change="${this.onCalendarCurrentMonthChange}"
|
|
473
|
+
></mp-calendar>
|
|
474
|
+
</slot>
|
|
475
|
+
<div class="popup-footer">
|
|
476
|
+
<button
|
|
477
|
+
type="button"
|
|
478
|
+
?disabled="${this.todayOutOfRange()}"
|
|
479
|
+
@click="${this.onTodayClick}"
|
|
480
|
+
>${this.todayLabel}</button>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
|
|
484
|
+
<div class="popup popup-time" id="${this.timePopupId}" role="dialog" aria-label="${this.timeButtonLabel}">
|
|
485
|
+
<slot name="time-list"
|
|
486
|
+
@selected-time-change="${this.onTimeListSelectedTimeChange}"
|
|
487
|
+
>
|
|
488
|
+
<mp-time-list
|
|
489
|
+
.selectedTime="${d}"
|
|
490
|
+
.step="${this.step}"
|
|
491
|
+
.minMinutes="${m.minMinutes}"
|
|
492
|
+
.maxMinutes="${m.maxMinutes}"
|
|
493
|
+
.hour12="${this.hour12}"
|
|
494
|
+
.locale="${this.locale}"
|
|
495
|
+
@selected-time-change="${this.onTimeListSelectedTimeChange}"
|
|
496
|
+
></mp-time-list>
|
|
497
|
+
</slot>
|
|
498
|
+
<div class="popup-footer">
|
|
499
|
+
<button
|
|
500
|
+
type="button"
|
|
501
|
+
?disabled="${this.nowOutOfRange()}"
|
|
502
|
+
@click="${this.onNowClick}"
|
|
503
|
+
>${this.nowLabel}</button>
|
|
504
|
+
</div>
|
|
505
|
+
</div>
|
|
506
|
+
`;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
l([
|
|
510
|
+
n("input.form-control")
|
|
511
|
+
], o.prototype, "displayInputEl");
|
|
512
|
+
l([
|
|
513
|
+
n("button.date")
|
|
514
|
+
], o.prototype, "dateTriggerEl");
|
|
515
|
+
l([
|
|
516
|
+
n("button.time")
|
|
517
|
+
], o.prototype, "timeTriggerEl");
|
|
518
|
+
l([
|
|
519
|
+
n(".input-group")
|
|
520
|
+
], o.prototype, "inputGroupEl");
|
|
521
|
+
l([
|
|
522
|
+
n(".popup-date")
|
|
523
|
+
], o.prototype, "datePopupEl");
|
|
524
|
+
l([
|
|
525
|
+
n(".popup-time")
|
|
526
|
+
], o.prototype, "timePopupEl");
|
|
527
|
+
typeof customElements < "u" && !customElements.get("mp-datetime-picker") && customElements.define("mp-datetime-picker", o);
|
|
528
|
+
export {
|
|
529
|
+
o as M
|
|
530
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement as i, nothing as r, html as a } from "lit";
|
|
2
2
|
import { createRef as d, ref as n } from "lit/directives/ref.js";
|
|
3
|
-
import { t as l } from "./mp-toggle-button-
|
|
3
|
+
import { t as l } from "./mp-toggle-button-C4Loq_p4.mjs";
|
|
4
4
|
import { f as c } from "./form-check.styles-jBlHetYX.mjs";
|
|
5
5
|
import { i as p } from "./invalid-feedback.styles-he0JYrJm.mjs";
|
|
6
6
|
import { H as b } from "./host-aria-WSGs7SPQ.mjs";
|
|
7
|
-
import { a as _, e as g } from "./
|
|
7
|
+
import { a as _, e as g } from "./error-text-B45eDAt1.mjs";
|
|
8
8
|
const o = /* @__PURE__ */ new Set(["radio", "toggle_button"]), h = /* @__PURE__ */ new Set([
|
|
9
9
|
"primary",
|
|
10
10
|
"secondary",
|
|
@@ -3,7 +3,8 @@ import { ifDefined as c } from "lit/directives/if-defined.js";
|
|
|
3
3
|
import { createRef as b, ref as m } from "lit/directives/ref.js";
|
|
4
4
|
import { i as p } from "./invalid-feedback.styles-he0JYrJm.mjs";
|
|
5
5
|
import { H as v } from "./host-aria-WSGs7SPQ.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { a as f, e as _ } from "./error-text-B45eDAt1.mjs";
|
|
7
|
+
import { F as g } from "./form-associated-BR-fUvZ1.mjs";
|
|
7
8
|
const k = h(`.form-select {
|
|
8
9
|
--bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
|
|
9
10
|
display: block;
|
|
@@ -73,11 +74,11 @@ function x(o) {
|
|
|
73
74
|
}
|
|
74
75
|
const u = /* @__PURE__ */ new Set(["sm", "md", "lg"]);
|
|
75
76
|
let y = 0;
|
|
76
|
-
class q extends
|
|
77
|
+
class q extends g(n) {
|
|
77
78
|
constructor() {
|
|
78
79
|
super(...arguments), this._size = "md", this._multiple = !1, this._numberVisible = null, this._disabled = !1, this._value = null, this._inputLabel = null, this._errorText = null, this._errorId = `mp-select-${++y}-error`, this._values = [], this._options = null, this._slotOptions = [], this._selectRef = b(), this._slotObserver = null, this.hostAria = new v(this, {
|
|
79
80
|
referenceTarget: () => this._selectRef.value ?? null,
|
|
80
|
-
describedByExtras: () =>
|
|
81
|
+
describedByExtras: () => f(this.renderRoot)
|
|
81
82
|
}), this.onSlotChange = (e) => {
|
|
82
83
|
const s = e.target.assignedElements({ flatten: !0 });
|
|
83
84
|
this._slotOptions = this.collectSlotItems(s), this.observeSlottedMutations(s), this.requestUpdate();
|
|
@@ -250,7 +251,7 @@ class q extends f(n) {
|
|
|
250
251
|
super.disconnectedCallback(), this._slotObserver?.disconnect(), this._slotObserver = null;
|
|
251
252
|
}
|
|
252
253
|
render() {
|
|
253
|
-
const e = this._options ?? this._slotOptions, t = this._size === "sm" || this._size === "lg" ? `form-select form-select-${this._size}` : "form-select", s = this.getAttribute("aria-label") ?? this._inputLabel, r =
|
|
254
|
+
const e = this._options ?? this._slotOptions, t = this._size === "sm" || this._size === "lg" ? `form-select form-select-${this._size}` : "form-select", s = this.getAttribute("aria-label") ?? this._inputLabel, r = _(this._errorId, this._errorText, this.hasAttribute("invalid"));
|
|
254
255
|
return a`
|
|
255
256
|
<select
|
|
256
257
|
${m(this._selectRef)}
|