@golemui/gui-lit 1.0.2 → 1.1.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/CHANGELOG.md +15 -0
- package/calendar-BuJgwvZx.js +254 -0
- package/{calendar.element-MubSE1bx.js → calendar.element-M5MPJmap.js} +1 -1
- package/{currency.element-BHXWcOEu.js → currency.element-CfFrAtrr.js} +20 -14
- package/{date-DTYg8sog.js → date-Bj9mI3GU.js} +106 -50
- package/date-input-cJDkNnVw.js +184 -0
- package/date-picker.element-va_-LGZD.js +312 -0
- package/date-time-calendar-BzRfkLKU.js +361 -0
- package/date-time-calendar.element-DC4NK0y1.js +93 -0
- package/date-time-input-BXxsfuyZ.js +214 -0
- package/date-time-picker.element-Dy-8cb-_.js +380 -0
- package/date-time.element-Bv4XdzMi.js +87 -0
- package/{date.element-BtVJSIRk.js → date.element-Consgsbb.js} +32 -27
- package/day-status-0-hJHrI7.js +530 -0
- package/{dropdown.element-DqzC6aXR.js → dropdown.element-WsD61Qel.js} +57 -48
- package/focus-leave.controller-2gV0pQd5.js +73 -0
- package/index.js +1209 -981
- package/index.umd.cjs +1574 -519
- package/lib/components/date-picker.element.d.ts +0 -11
- package/lib/components/date-time-calendar.element.d.ts +18 -0
- package/lib/components/date-time-picker.element.d.ts +18 -0
- package/lib/components/date-time.element.d.ts +18 -0
- package/lib/components/dropdown.element.d.ts +2 -0
- package/lib/components/range-calendar.element.d.ts +2 -1
- package/lib/components/range-date-picker.element.d.ts +0 -15
- package/lib/components/range-date-time-calendar.element.d.ts +18 -0
- package/lib/components/range-date-time-input.element.d.ts +18 -0
- package/lib/components/range-date-time-picker.element.d.ts +18 -0
- package/lib/components/range-time-input.element.d.ts +18 -0
- package/lib/components/range-time-picker.element.d.ts +18 -0
- package/lib/components/time-picker.element.d.ts +18 -0
- package/lib/components/time.element.d.ts +18 -0
- package/{list-D1oKnH89.js → list-CrLIL4by.js} +76 -61
- package/{list.element-Co3V3Cn5.js → list.element-DV82YxnJ.js} +22 -22
- package/{number.element-BhEyoOtc.js → number.element-CBr47IiY.js} +18 -16
- package/numeric-jmOOKz30.js +12 -0
- package/package.json +6 -6
- package/part-templates-Db871PS3.js +677 -0
- package/pill-ranges-DCqDmpkk.js +48 -0
- package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
- package/popup.controller-eUDxE6jD.js +71 -0
- package/range-calendar-CKPYeSGt.js +452 -0
- package/{range-calendar.element-QTE6vGNP.js → range-calendar.element-D6KYq18B.js} +24 -20
- package/range-commit-8-MmYUyo.js +14 -0
- package/range-date-input-D--AqBMv.js +292 -0
- package/{range-date-input.element-Dj29D_OQ.js → range-date-input.element-D4nIXJbw.js} +8 -7
- package/range-date-picker.element-dhxPAAE6.js +386 -0
- package/range-date-time-calendar-yksWrR7b.js +720 -0
- package/range-date-time-calendar.element-C00aDefZ.js +95 -0
- package/range-date-time-input-B37TUoM3.js +322 -0
- package/range-date-time-input.element-DUnbv4ed.js +81 -0
- package/range-date-time-picker.element-Cbps6s_G.js +412 -0
- package/range-selection-CU3hxLJE.js +25 -0
- package/range-time-input-3lhqR1Ku.js +329 -0
- package/range-time-input.element-dU2iBdmJ.js +81 -0
- package/range-time-picker.element-v6nQsIPw.js +429 -0
- package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
- package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
- package/time-input-BOhlBGJZ.js +181 -0
- package/time-list-Czo48bZm.js +217 -0
- package/time-picker-bFJ63ky8.js +261 -0
- package/time-picker.element-CYZVXgRS.js +85 -0
- package/time.element-fK3oLi49.js +82 -0
- package/abstract-calendar-BoqKPRmS.js +0 -545
- package/calendar-DTYKVYc3.js +0 -96
- package/date-input-BeQvyfln.js +0 -268
- package/date-picker.element-DabW_-0-.js +0 -166
- package/range-calendar-9skwbwlB.js +0 -255
- package/range-date-input-Uy8134vi.js +0 -395
- package/range-date-picker.element-CuKIBkIO.js +0 -182
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { InputWidgetAdapter as d, formContext as m, inputContext as u } from "@golemui/lit";
|
|
2
|
+
import "./range-date-time-calendar-yksWrR7b.js";
|
|
3
|
+
import { consume as p, provide as h } from "@lit/context";
|
|
4
|
+
import { LitElement as c, html as b } from "lit";
|
|
5
|
+
import { property as $, customElement as g } from "lit/decorators.js";
|
|
6
|
+
import "rxjs";
|
|
7
|
+
var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, l = (e, t, s, r) => {
|
|
8
|
+
for (var a = r > 1 ? void 0 : r ? f(t, s) : t, n = e.length - 1, o; n >= 0; n--)
|
|
9
|
+
(o = e[n]) && (a = (r ? o(t, s, a) : o(a)) || a);
|
|
10
|
+
return r && a && v(t, s, a), a;
|
|
11
|
+
};
|
|
12
|
+
let i = class extends c {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.adapter = new d(), this.subscriptions = [];
|
|
15
|
+
}
|
|
16
|
+
createRenderRoot() {
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
updated(e) {
|
|
20
|
+
super.updated(e);
|
|
21
|
+
const t = this.adapter.templateData.size;
|
|
22
|
+
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback(), this.classList.add("gui-range-date-time-calendar", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
26
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
super.render();
|
|
31
|
+
const e = this.adapter.templateData;
|
|
32
|
+
return b`
|
|
33
|
+
<gui-range-date-time-calendar
|
|
34
|
+
.uid=${this.widget.uid}
|
|
35
|
+
.label=${e.label}
|
|
36
|
+
.hint=${e.hint}
|
|
37
|
+
.errors=${e.errors}
|
|
38
|
+
?touched=${e.touched}
|
|
39
|
+
?required=${e.validator?.required}
|
|
40
|
+
?disabled=${e.disabled}
|
|
41
|
+
?readonly=${e.readonly}
|
|
42
|
+
.value=${e.value}
|
|
43
|
+
.prevMonthIcon=${e.prevMonthIcon}
|
|
44
|
+
.nextMonthIcon=${e.nextMonthIcon}
|
|
45
|
+
.prevMonthAriaLabel=${e.prevMonthAriaLabel}
|
|
46
|
+
.nextMonthAriaLabel=${e.nextMonthAriaLabel}
|
|
47
|
+
.dayFormat=${e.dayFormat}
|
|
48
|
+
.weekdayFormat=${e.weekdayFormat}
|
|
49
|
+
.monthFormat=${e.monthFormat}
|
|
50
|
+
.numberOfMonths=${e.numberOfMonths}
|
|
51
|
+
.removePillAriaLabel=${e.removePillAriaLabel}
|
|
52
|
+
.localeId=${e.lang}
|
|
53
|
+
.hourFormat=${e.hourFormat}
|
|
54
|
+
.minuteStep=${e.minuteStep}
|
|
55
|
+
?allow-custom-time=${e.allowCustomTime}
|
|
56
|
+
.startTimeLabel=${e.startTimeLabel}
|
|
57
|
+
.endTimeLabel=${e.endTimeLabel}
|
|
58
|
+
.minDateTime=${e.minDateTime}
|
|
59
|
+
.maxDateTime=${e.maxDateTime}
|
|
60
|
+
.disabledRanges=${e.disabledRanges}
|
|
61
|
+
.minDateTimeMessage=${e.minDateTimeMessage}
|
|
62
|
+
.maxDateTimeMessage=${e.maxDateTimeMessage}
|
|
63
|
+
.disabledRangeMessage=${e.disabledRangeMessage}
|
|
64
|
+
.noAvailableTimesMessage=${e.noAvailableTimesMessage}
|
|
65
|
+
.dayCountAriaLabel=${e.dayCountAriaLabel}
|
|
66
|
+
.disabledDayCountAriaLabel=${e.disabledDayCountAriaLabel}
|
|
67
|
+
@change=${this.valueChanged}
|
|
68
|
+
@inputError=${this.onInputError}
|
|
69
|
+
@blur=${() => this.adapter.onBlur()}
|
|
70
|
+
></gui-range-date-time-calendar>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
valueChanged(e) {
|
|
74
|
+
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
|
|
75
|
+
}
|
|
76
|
+
onInputError(e) {
|
|
77
|
+
this.adapter.injectValidationIssues([e.detail.message]), this.adapter.onBlur();
|
|
78
|
+
}
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
l([
|
|
84
|
+
p({ context: m }),
|
|
85
|
+
$({ attribute: !1 })
|
|
86
|
+
], i.prototype, "formContext", 2);
|
|
87
|
+
l([
|
|
88
|
+
h({ context: u })
|
|
89
|
+
], i.prototype, "adapter", 2);
|
|
90
|
+
i = l([
|
|
91
|
+
g("gui-range-date-time-calendar-input")
|
|
92
|
+
], i);
|
|
93
|
+
export {
|
|
94
|
+
i as RangeDateTimeCalendarElement
|
|
95
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { LitElement as g, nothing as p, html as u } from "lit";
|
|
2
|
+
import { property as a, customElement as c } from "lit/decorators.js";
|
|
3
|
+
import { classMap as v } from "lit/directives/class-map.js";
|
|
4
|
+
import { styleMap as y } from "lit-html/directives/style-map.js";
|
|
5
|
+
import { G as b, b as f, c as D } from "./templates-Dk1jxLwS.js";
|
|
6
|
+
import { G as T, g as E, a as _, r as h, f as P, p as m, b as S, d as R, m as C, c as k, o as $ } from "./part-templates-Db871PS3.js";
|
|
7
|
+
import { c as A } from "./range-commit-8-MmYUyo.js";
|
|
8
|
+
import { r as L, f as I, b as M, a as w, s as B } from "./pill-ranges-DCqDmpkk.js";
|
|
9
|
+
import "./pills-Be1UrLgq.js";
|
|
10
|
+
import { D as F } from "./date-Bj9mI3GU.js";
|
|
11
|
+
var O = Object.defineProperty, x = Object.getOwnPropertyDescriptor, i = (t, s, l, r) => {
|
|
12
|
+
for (var o = r > 1 ? void 0 : r ? x(s, l) : s, n = t.length - 1, d; n >= 0; n--)
|
|
13
|
+
(d = t[n]) && (o = (r ? d(s, l, o) : d(o)) || o);
|
|
14
|
+
return r && o && O(s, l, o), o;
|
|
15
|
+
};
|
|
16
|
+
let e = class extends g {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = void 0, this.errors = [], this.showErrors = !0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.icon = "", this.hint = void 0, this.hourFormat = void 0, this.minuteStep = 1, this.invalidDateMessage = void 0, this.value = [], this.removePillAriaLabel = void 0, this.startDateTimeAriaLabel = void 0, this.endDateTimeAriaLabel = void 0, this.separator = void 0, this.minDateTime = void 0, this.maxDateTime = void 0, this.minDateTimeMessage = void 0, this.maxDateTimeMessage = void 0, this.disabledRanges = void 0, this.disabledRangeMessage = void 0, this.inputBlockClass = "gui-range-date-time-input", this.groups = ["start", "end"], this._validationTriggered = !1, this._parts = new T(this, {
|
|
19
|
+
blockClass: this.inputBlockClass,
|
|
20
|
+
groups: this.groups,
|
|
21
|
+
getDescriptor: (t) => this.getPartDescriptor(t),
|
|
22
|
+
commitGroup: () => {
|
|
23
|
+
this._validationTriggered ? this.revalidate() : this.syncParts();
|
|
24
|
+
},
|
|
25
|
+
isReadonly: () => !!this.readOnly,
|
|
26
|
+
isDisabled: () => !!this.disabled,
|
|
27
|
+
onEmptyPartBlur: () => {
|
|
28
|
+
},
|
|
29
|
+
onEnter: () => {
|
|
30
|
+
this.tryCreatePill(), this.value && this.value.length > 0 && this.onPillClick(this.value[this.value.length - 1]);
|
|
31
|
+
},
|
|
32
|
+
getHourFormat: () => this.localeData.effectiveHourFormat,
|
|
33
|
+
getDayPeriodLabels: () => this.localeData.dayPeriodLabels,
|
|
34
|
+
onInputErrorSurfaced: (t) => this.dispatchEvent(new CustomEvent("inputError", { detail: { message: t }, bubbles: !0 })),
|
|
35
|
+
onSurfacedErrorCleared: (t) => this.dispatchEvent(
|
|
36
|
+
new CustomEvent("change", { detail: { value: t }, bubbles: !0, composed: !0 })
|
|
37
|
+
)
|
|
38
|
+
}), this.ariaController = new b(this, {
|
|
39
|
+
getTargets: () => this.querySelectorAll(`.${this.inputBlockClass}`),
|
|
40
|
+
getState: () => ({
|
|
41
|
+
uid: this.uid,
|
|
42
|
+
templateData: {
|
|
43
|
+
hint: this.hint,
|
|
44
|
+
errors: this.errors,
|
|
45
|
+
readonly: this.readOnly,
|
|
46
|
+
disabled: this.disabled,
|
|
47
|
+
touched: this.touched
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}), this.onPillRemoveEvent = (t) => {
|
|
51
|
+
if (this.disabled || this.readOnly) return;
|
|
52
|
+
const s = L(this.value, t.detail.key);
|
|
53
|
+
s && (this.value = s.next, this.dispatchEvent(
|
|
54
|
+
new CustomEvent("change", { detail: { value: this.value }, bubbles: !0, composed: !0 })
|
|
55
|
+
), s.next.length === 0 && requestAnimationFrame(() => {
|
|
56
|
+
this.querySelector(".gui-range-date-time-input__field input")?.focus();
|
|
57
|
+
}));
|
|
58
|
+
}, this.onPillClickEvent = (t) => {
|
|
59
|
+
const s = I(this.getSortedPills(), t.detail.key);
|
|
60
|
+
s && this.onPillClick(s);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
createRenderRoot() {
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
68
|
+
}
|
|
69
|
+
get localeData() {
|
|
70
|
+
return E(this.localeId, this.hourFormat, this.minuteStep, !0);
|
|
71
|
+
}
|
|
72
|
+
getPartDescriptor(t) {
|
|
73
|
+
return this.localeData.descriptors[t];
|
|
74
|
+
}
|
|
75
|
+
willUpdate(t) {
|
|
76
|
+
(!this.hasUpdated || t.has("hourFormat") || t.has("localeId")) && this._parts.seedDayPeriods();
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
const t = {
|
|
80
|
+
uid: this.uid,
|
|
81
|
+
label: this.label,
|
|
82
|
+
errors: this.errors,
|
|
83
|
+
touched: this.touched,
|
|
84
|
+
required: this.required,
|
|
85
|
+
disabled: this.disabled,
|
|
86
|
+
readonly: this.readOnly,
|
|
87
|
+
value: this.value,
|
|
88
|
+
hint: this.hint
|
|
89
|
+
}, s = {
|
|
90
|
+
blockClass: this.inputBlockClass,
|
|
91
|
+
groups: this.groups,
|
|
92
|
+
formatParts: _(this.localeId, this.localeData.effectiveHourFormat),
|
|
93
|
+
getDescriptor: (o) => this.getPartDescriptor(o),
|
|
94
|
+
getDisplayValue: this._parts.getPartDisplay,
|
|
95
|
+
required: this.required,
|
|
96
|
+
disabled: this.disabled,
|
|
97
|
+
partsReadonly: !!this.readOnly
|
|
98
|
+
}, l = M(
|
|
99
|
+
this.getSortedPills(),
|
|
100
|
+
(o) => w(o, (n) => this.formatDateTimeForDisplay(n)),
|
|
101
|
+
this.removePillAriaLabel ?? "Remove date-time"
|
|
102
|
+
), r = {
|
|
103
|
+
"gui-widget-icon": !0,
|
|
104
|
+
[this.icon]: !!this.icon
|
|
105
|
+
};
|
|
106
|
+
return u`
|
|
107
|
+
${this.label ? f(this.uid, t, !1, void 0, !1) : p}
|
|
108
|
+
|
|
109
|
+
<div class="gui-widget">
|
|
110
|
+
<div
|
|
111
|
+
class="gui-widget-input gui-parts-ring gui-range-date-time-input ${this.icon ? "gui-range-date-time-input--icon" : ""}"
|
|
112
|
+
role="group"
|
|
113
|
+
aria-label=${this.label ?? "Date-time range input"}
|
|
114
|
+
>
|
|
115
|
+
${this.icon ? u`<span class=${v(r)} data-icon=${this.icon}></span>` : p}
|
|
116
|
+
|
|
117
|
+
<gui-pills
|
|
118
|
+
class="gui-range-date-time-input__pills"
|
|
119
|
+
style=${y(l.length ? {} : { "min-width": 0 })}
|
|
120
|
+
.items=${l}
|
|
121
|
+
.removable=${!0}
|
|
122
|
+
.clickable=${!0}
|
|
123
|
+
.bubble=${!0}
|
|
124
|
+
?disabled=${this.disabled}
|
|
125
|
+
?readonly=${this.readOnly}
|
|
126
|
+
.removeAriaLabel=${this.removePillAriaLabel ?? "Remove date-time"}
|
|
127
|
+
.compactAriaLabel=${`${l.length} date-time ranges`}
|
|
128
|
+
@pillremove=${this.onPillRemoveEvent}
|
|
129
|
+
@pillclick=${this.onPillClickEvent}
|
|
130
|
+
></gui-pills>
|
|
131
|
+
|
|
132
|
+
<div class="gui-range-date-time-input__inputs">
|
|
133
|
+
<div
|
|
134
|
+
class="gui-parts gui-range-date-time-input__field"
|
|
135
|
+
role="group"
|
|
136
|
+
aria-label=${this.startDateTimeAriaLabel ?? "Start date-time"}
|
|
137
|
+
>
|
|
138
|
+
${h("start", s, this._parts)}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<span class="gui-range-date-time-input__separator">${this.separator ?? "-"}</span>
|
|
142
|
+
|
|
143
|
+
<div
|
|
144
|
+
class="gui-parts gui-range-date-time-input__field"
|
|
145
|
+
role="group"
|
|
146
|
+
aria-label=${this.endDateTimeAriaLabel ?? "End date-time"}
|
|
147
|
+
>
|
|
148
|
+
${h("end", s, this._parts)}
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
${this.showErrors && this.errors?.length ? D(this.uid, t) : p}
|
|
154
|
+
</div>
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
onPillClick(t) {
|
|
158
|
+
this.dispatchEvent(
|
|
159
|
+
new CustomEvent("pillClick", { detail: { range: t }, bubbles: !0, composed: !0 })
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
formatDateTimeForDisplay(t) {
|
|
163
|
+
return P(t, this.localeId, this.localeData.effectiveHourFormat);
|
|
164
|
+
}
|
|
165
|
+
getSortedPills() {
|
|
166
|
+
return B(
|
|
167
|
+
this.value,
|
|
168
|
+
(t, s) => m(t).getTime() - m(s).getTime()
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Parses a group into an ISO date-time via the shared clamp/bounds pipeline,
|
|
173
|
+
* distinguishing an incomplete group (nothing to report) from a
|
|
174
|
+
* complete-but-rejected one (an impossible date or an out-of-bounds
|
|
175
|
+
* date-time). It does not emit: the caller decides whether to surface or
|
|
176
|
+
* clear an error, so fixing one group clears its error even while the other
|
|
177
|
+
* is still empty.
|
|
178
|
+
*
|
|
179
|
+
* Each endpoint is an instant, so it is bounded by instants. A date-only
|
|
180
|
+
* bound could not express this: `maxDate: 2026-02-10` is ambiguous about
|
|
181
|
+
* whether the 10th is allowed until 00:00 or 23:59, and independent date/time
|
|
182
|
+
* axes would wrongly reject Feb 11 08:00 for a `minTime` of 09:00.
|
|
183
|
+
*/
|
|
184
|
+
validateDateTimeParts(t) {
|
|
185
|
+
const { effectiveHourFormat: s, descriptors: l } = this.localeData, { result: r, writeBacks: o } = S(this._parts.values[t] ?? {}, {
|
|
186
|
+
hourFormat: s,
|
|
187
|
+
descriptors: l,
|
|
188
|
+
invalidDateMessage: this.invalidDateMessage
|
|
189
|
+
});
|
|
190
|
+
if (this._parts.applyWriteBacks(t, o), r.kind === "incomplete") return { kind: "incomplete" };
|
|
191
|
+
if (r.kind === "invalid") return { kind: "invalid", message: r.message };
|
|
192
|
+
const n = R(r.iso, this.minDateTime, this.maxDateTime, {
|
|
193
|
+
minDateTimeMessage: this.minDateTimeMessage,
|
|
194
|
+
maxDateTimeMessage: this.maxDateTimeMessage
|
|
195
|
+
});
|
|
196
|
+
return n ? { kind: "invalid", message: n } : { kind: "valid", value: r.iso };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Re-parses both endpoints so per-endpoint problems (impossible date-time,
|
|
200
|
+
* out of instant bounds) surface while the user types. Runs on every part
|
|
201
|
+
* change.
|
|
202
|
+
*/
|
|
203
|
+
syncParts() {
|
|
204
|
+
return {
|
|
205
|
+
start: this.validateDateTimeParts("start"),
|
|
206
|
+
end: this.validateDateTimeParts("end")
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Parses the range and updates the error state, without ever committing.
|
|
211
|
+
* Shared by the Enter commit and by {@link revalidate}.
|
|
212
|
+
*/
|
|
213
|
+
evaluateRange() {
|
|
214
|
+
const { start: t, end: s } = this.syncParts(), l = A(t, s, this.value, {
|
|
215
|
+
// Date-time ranges are two instants: a backward selection reorders (swap)
|
|
216
|
+
// rather than erroring — mirroring the range calendar's date swap.
|
|
217
|
+
order: (r, o) => {
|
|
218
|
+
const n = $(r, o);
|
|
219
|
+
return { start: n.start, end: n.end };
|
|
220
|
+
},
|
|
221
|
+
validate: (r) => k({ start: r.start, end: r.end }, this.disabledRanges) ? this.disabledRangeMessage ?? F : null,
|
|
222
|
+
toRange: (r) => ({ start: r.start, end: r.end }),
|
|
223
|
+
merge: C
|
|
224
|
+
});
|
|
225
|
+
return l.kind === "invalid" && this._parts.surfaceInputError(l.message), l.kind === "incomplete" && this._parts.clearSurfacedInputError(this.value ?? []), l;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Once the user has attempted a commit, every later edit re-runs validation
|
|
229
|
+
* so a corrected range clears its error immediately, otherwise the message
|
|
230
|
+
* would linger until the next Enter and the user could not tell the problem
|
|
231
|
+
* was solved.
|
|
232
|
+
*/
|
|
233
|
+
revalidate() {
|
|
234
|
+
this.evaluateRange().kind === "commit" && this._parts.clearSurfacedInputError(this.value ?? []);
|
|
235
|
+
}
|
|
236
|
+
tryCreatePill() {
|
|
237
|
+
this._validationTriggered = !0;
|
|
238
|
+
const t = this.evaluateRange();
|
|
239
|
+
t.kind === "commit" && (this.value = t.value, this._validationTriggered = !1, this._parts.clearGroup("start"), this._parts.clearGroup("end"), this._parts.seedDayPeriods(), this._parts.resetSurfacedInputError(), this.dispatchEvent(
|
|
240
|
+
new CustomEvent("change", { detail: { value: this.value }, bubbles: !0, composed: !0 })
|
|
241
|
+
), this._parts.focusFirst("start"), this.requestUpdate());
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
i([
|
|
245
|
+
a({ type: String })
|
|
246
|
+
], e.prototype, "uid", 2);
|
|
247
|
+
i([
|
|
248
|
+
a({ type: String })
|
|
249
|
+
], e.prototype, "label", 2);
|
|
250
|
+
i([
|
|
251
|
+
a({ type: String, attribute: "locale-id" })
|
|
252
|
+
], e.prototype, "localeId", 2);
|
|
253
|
+
i([
|
|
254
|
+
a({ type: Array })
|
|
255
|
+
], e.prototype, "errors", 2);
|
|
256
|
+
i([
|
|
257
|
+
a({ type: Boolean })
|
|
258
|
+
], e.prototype, "showErrors", 2);
|
|
259
|
+
i([
|
|
260
|
+
a({ type: Boolean })
|
|
261
|
+
], e.prototype, "touched", 2);
|
|
262
|
+
i([
|
|
263
|
+
a({ type: Boolean })
|
|
264
|
+
], e.prototype, "required", 2);
|
|
265
|
+
i([
|
|
266
|
+
a({ type: Boolean })
|
|
267
|
+
], e.prototype, "disabled", 2);
|
|
268
|
+
i([
|
|
269
|
+
a({ type: Boolean, attribute: "readonly" })
|
|
270
|
+
], e.prototype, "readOnly", 2);
|
|
271
|
+
i([
|
|
272
|
+
a({ type: String })
|
|
273
|
+
], e.prototype, "icon", 2);
|
|
274
|
+
i([
|
|
275
|
+
a({ type: String })
|
|
276
|
+
], e.prototype, "hint", 2);
|
|
277
|
+
i([
|
|
278
|
+
a({ type: String, attribute: "hour-format" })
|
|
279
|
+
], e.prototype, "hourFormat", 2);
|
|
280
|
+
i([
|
|
281
|
+
a({ type: Number, attribute: "minute-step" })
|
|
282
|
+
], e.prototype, "minuteStep", 2);
|
|
283
|
+
i([
|
|
284
|
+
a({ type: String, attribute: "invalid-date-message" })
|
|
285
|
+
], e.prototype, "invalidDateMessage", 2);
|
|
286
|
+
i([
|
|
287
|
+
a({ type: Array })
|
|
288
|
+
], e.prototype, "value", 2);
|
|
289
|
+
i([
|
|
290
|
+
a({ type: String })
|
|
291
|
+
], e.prototype, "removePillAriaLabel", 2);
|
|
292
|
+
i([
|
|
293
|
+
a({ type: String })
|
|
294
|
+
], e.prototype, "startDateTimeAriaLabel", 2);
|
|
295
|
+
i([
|
|
296
|
+
a({ type: String })
|
|
297
|
+
], e.prototype, "endDateTimeAriaLabel", 2);
|
|
298
|
+
i([
|
|
299
|
+
a({ type: String })
|
|
300
|
+
], e.prototype, "separator", 2);
|
|
301
|
+
i([
|
|
302
|
+
a({ type: String, attribute: "min-date-time" })
|
|
303
|
+
], e.prototype, "minDateTime", 2);
|
|
304
|
+
i([
|
|
305
|
+
a({ type: String, attribute: "max-date-time" })
|
|
306
|
+
], e.prototype, "maxDateTime", 2);
|
|
307
|
+
i([
|
|
308
|
+
a({ type: String, attribute: "min-date-time-message" })
|
|
309
|
+
], e.prototype, "minDateTimeMessage", 2);
|
|
310
|
+
i([
|
|
311
|
+
a({ type: String, attribute: "max-date-time-message" })
|
|
312
|
+
], e.prototype, "maxDateTimeMessage", 2);
|
|
313
|
+
i([
|
|
314
|
+
a({ type: Array, attribute: "disabled-ranges" })
|
|
315
|
+
], e.prototype, "disabledRanges", 2);
|
|
316
|
+
i([
|
|
317
|
+
a({ type: String, attribute: "disabled-range-message" })
|
|
318
|
+
], e.prototype, "disabledRangeMessage", 2);
|
|
319
|
+
e = i([
|
|
320
|
+
c("gui-range-date-time")
|
|
321
|
+
], e);
|
|
322
|
+
typeof customElements < "u" && !customElements.get("gui-range-date-time") && customElements.define("gui-range-date-time", e);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { InputWidgetAdapter as n, formContext as m, inputContext as o } from "@golemui/lit";
|
|
2
|
+
import "./range-date-time-input-B37TUoM3.js";
|
|
3
|
+
import { consume as h, provide as u } from "@lit/context";
|
|
4
|
+
import { LitElement as D, html as c } from "lit";
|
|
5
|
+
import { property as g, customElement as $ } from "lit/decorators.js";
|
|
6
|
+
import "rxjs";
|
|
7
|
+
var b = Object.defineProperty, v = Object.getOwnPropertyDescriptor, d = (t, e, s, i) => {
|
|
8
|
+
for (var a = i > 1 ? void 0 : i ? v(e, s) : e, p = t.length - 1, l; p >= 0; p--)
|
|
9
|
+
(l = t[p]) && (a = (i ? l(e, s, a) : l(a)) || a);
|
|
10
|
+
return i && a && b(e, s, a), a;
|
|
11
|
+
};
|
|
12
|
+
let r = class extends D {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.adapter = new n(), this.subscriptions = [];
|
|
15
|
+
}
|
|
16
|
+
createRenderRoot() {
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
updated(t) {
|
|
20
|
+
super.updated(t);
|
|
21
|
+
const e = this.adapter.templateData.size;
|
|
22
|
+
e ? this.style.flex = String(e) : this.style.removeProperty("flex");
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback(), this.classList.add("gui-range-date-time", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
26
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return super.render(), c`
|
|
31
|
+
<gui-range-date-time
|
|
32
|
+
.uid=${this.widget.uid}
|
|
33
|
+
.label=${this.adapter.templateData.label}
|
|
34
|
+
.hint=${this.adapter.templateData.hint}
|
|
35
|
+
.icon=${this.adapter.templateData.icon}
|
|
36
|
+
.errors=${this.adapter.templateData.errors}
|
|
37
|
+
?touched=${this.adapter.templateData.touched}
|
|
38
|
+
?required=${this.adapter.templateData.validator?.required}
|
|
39
|
+
?disabled=${this.adapter.templateData.disabled}
|
|
40
|
+
?readonly=${this.adapter.templateData.readonly}
|
|
41
|
+
.value=${this.adapter.templateData.value}
|
|
42
|
+
.localeId=${this.adapter.templateData.lang}
|
|
43
|
+
.separator=${this.adapter.templateData.separator}
|
|
44
|
+
.removePillAriaLabel=${this.adapter.templateData.removePillAriaLabel}
|
|
45
|
+
.startDateTimeAriaLabel=${this.adapter.templateData.startDateTimeAriaLabel}
|
|
46
|
+
.endDateTimeAriaLabel=${this.adapter.templateData.endDateTimeAriaLabel}
|
|
47
|
+
.hourFormat=${this.adapter.templateData.hourFormat}
|
|
48
|
+
.minuteStep=${this.adapter.templateData.minuteStep}
|
|
49
|
+
.minDateTime=${this.adapter.templateData.minDateTime}
|
|
50
|
+
.maxDateTime=${this.adapter.templateData.maxDateTime}
|
|
51
|
+
.invalidDateMessage=${this.adapter.templateData.invalidDateMessage}
|
|
52
|
+
.minDateTimeMessage=${this.adapter.templateData.minDateTimeMessage}
|
|
53
|
+
.maxDateTimeMessage=${this.adapter.templateData.maxDateTimeMessage}
|
|
54
|
+
@change=${this.valueChanged}
|
|
55
|
+
@inputError=${this.onInputError}
|
|
56
|
+
></gui-range-date-time>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
valueChanged(t) {
|
|
60
|
+
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(t.detail.value);
|
|
61
|
+
}
|
|
62
|
+
onInputError(t) {
|
|
63
|
+
this.adapter.injectValidationIssues([t.detail.message]);
|
|
64
|
+
}
|
|
65
|
+
disconnectedCallback() {
|
|
66
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
d([
|
|
70
|
+
h({ context: m }),
|
|
71
|
+
g({ attribute: !1 })
|
|
72
|
+
], r.prototype, "formContext", 2);
|
|
73
|
+
d([
|
|
74
|
+
u({ context: o })
|
|
75
|
+
], r.prototype, "adapter", 2);
|
|
76
|
+
r = d([
|
|
77
|
+
$("gui-range-date-time-input")
|
|
78
|
+
], r);
|
|
79
|
+
export {
|
|
80
|
+
r as RangeDateTimeInputElement
|
|
81
|
+
};
|