@golemui/gui-lit 1.0.3 → 1.1.1-rc.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 +26 -0
- package/{button.element-3a7rRHbA.js → button.element-CJay43iR.js} +16 -13
- package/calendar-D31xNsxx.js +267 -0
- package/{range-calendar.element-_1bHW_c1.js → calendar.element-BhFrCsns.js} +16 -16
- package/{checkbox.element-CVskoXEc.js → checkbox.element-DAAVB651.js} +49 -49
- package/{currency.element-5GSakkxF.js → currency.element-D8A2ObpM.js} +15 -11
- package/{date-CDUlLuYy.js → date-DBuYpvcO.js} +88 -29
- package/date-input-DLiMreSS.js +204 -0
- package/date-picker.element-DeUQtbLg.js +357 -0
- package/date-time-calendar-DzU-FtVl.js +374 -0
- package/date-time-calendar.element-BLBcVsFu.js +95 -0
- package/date-time-input-DZaz2heD.js +246 -0
- package/date-time-picker.element-BUbLdV6i.js +440 -0
- package/date-time.element-B5onfSBG.js +93 -0
- package/{date.element-BZO0UQez.js → date.element-BsKhLrEc.js} +27 -19
- package/day-status-CsWStVQV.js +554 -0
- package/{dropdown.element-CyJbVAA5.js → dropdown.element-CXpMwJsU.js} +53 -37
- package/{errors-QjKhr6mA.js → errors-Byb2dIhK.js} +3 -2
- package/focus-leave.controller-2gV0pQd5.js +73 -0
- package/index.js +1635 -948
- package/index.umd.cjs +2046 -601
- 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-D730tmGN.js +297 -0
- package/{list.element-Co3V3Cn5.js → list.element-eo3DIOrp.js} +23 -23
- package/{markdown.element-p-kC47D7.js → markdown.element-FbtwdnAv.js} +310 -218
- package/{number.element-CBr47IiY.js → number.element-BEpOCzXy.js} +76 -61
- package/package.json +6 -6
- package/part-templates-VORbpgs2.js +691 -0
- package/{password.element-n-R9RbkB.js → password.element-CBaB8h5b.js} +19 -17
- package/pill-ranges-DpvWwP-3.js +48 -0
- package/{pills-B66qz_KX.js → pills-BDMO2NiR.js} +84 -59
- package/popup.controller-B33OvX_y.js +86 -0
- package/{radiogroup.element-CeQn623u.js → radiogroup.element-KWzBx8mx.js} +55 -51
- package/range-calendar-DO_woqcF.js +466 -0
- package/{calendar.element-DcnTyvfg.js → range-calendar.element-DHLZhpnj.js} +37 -29
- package/range-commit-8-MmYUyo.js +14 -0
- package/range-date-input-Br7XqQPK.js +311 -0
- package/{range-date-input.element-BqzAF0O3.js → range-date-input.element-BdD4SlB4.js} +12 -8
- package/range-date-picker.element-DWRHiAoC.js +434 -0
- package/range-date-time-calendar-B3EMgN1E.js +734 -0
- package/range-date-time-calendar.element-Coea6RF4.js +97 -0
- package/range-date-time-input-Cu-T_nuC.js +353 -0
- package/range-date-time-input.element-Cti44iuW.js +87 -0
- package/range-date-time-picker.element-CDN2RL1y.js +472 -0
- package/range-selection-CU3hxLJE.js +25 -0
- package/range-time-input-BP9ZL9O8.js +348 -0
- package/range-time-input.element-B7wtHJoQ.js +84 -0
- package/range-time-picker.element-CPIAiQPC.js +470 -0
- package/{repeater.element-CtNgB4F5.js → repeater.element-BM1Keckd.js} +1 -1
- package/{select.element-jcDF1h-g.js → select.element-eepcXTpL.js} +117 -107
- package/{tabs.element-BvAyI71N.js → tabs.element-CvcIA8P3.js} +1 -0
- package/{tags.element-CX3vQL8L.js → tags.element-CPHgotb0.js} +21 -14
- package/templates-Dmr34nwp.js +88 -0
- package/{textarea.element-HThYqdR_.js → textarea.element-CiNEy9uq.js} +8 -7
- package/{textinput.element-CkXNzMUg.js → textinput.element-AL2Nr768.js} +10 -9
- package/time-input-5dkSm8UW.js +201 -0
- package/time-list-DLcq8BAp.js +217 -0
- package/time-picker-g337F8d0.js +299 -0
- package/time-picker.element-DLihegjg.js +89 -0
- package/time.element-BneqgMlQ.js +85 -0
- package/{toggle.element-C1kCw5H8.js → toggle.element-Cz91CRdp.js} +44 -43
- package/abstract-calendar-D0-077XJ.js +0 -545
- package/calendar-BclCC9VJ.js +0 -96
- package/date-input-DCdGWRio.js +0 -268
- package/date-picker.element-k7AJFQ5W.js +0 -168
- package/list-D1oKnH89.js +0 -283
- package/range-calendar-CBINu84w.js +0 -255
- package/range-date-input-BYXzqnr1.js +0 -395
- package/range-date-picker.element-BCBefgvY.js +0 -182
- package/templates-Dk1jxLwS.js +0 -75
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { InputWidgetAdapter as d, formContext as m, inputContext as u } from "@golemui/lit";
|
|
2
|
+
import "./range-date-time-calendar-B3EMgN1E.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, a, s, r) => {
|
|
8
|
+
for (var t = r > 1 ? void 0 : r ? f(a, s) : a, n = e.length - 1, o; n >= 0; n--)
|
|
9
|
+
(o = e[n]) && (t = (r ? o(a, s, t) : o(t)) || t);
|
|
10
|
+
return r && t && v(a, s, t), t;
|
|
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 a = this.adapter.templateData.size;
|
|
22
|
+
a ? this.style.flex = String(a) : 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
|
+
.selectYearAriaLabel=${e.selectYearAriaLabel}
|
|
48
|
+
.yearGridAriaLabel=${e.yearGridAriaLabel}
|
|
49
|
+
.dayFormat=${e.dayFormat}
|
|
50
|
+
.weekdayFormat=${e.weekdayFormat}
|
|
51
|
+
.monthFormat=${e.monthFormat}
|
|
52
|
+
.numberOfMonths=${e.numberOfMonths}
|
|
53
|
+
.removePillAriaLabel=${e.removePillAriaLabel}
|
|
54
|
+
.localeId=${e.lang}
|
|
55
|
+
.hourFormat=${e.hourFormat}
|
|
56
|
+
.minuteStep=${e.minuteStep}
|
|
57
|
+
?allow-custom-time=${e.allowCustomTime}
|
|
58
|
+
.startTimeLabel=${e.startTimeLabel}
|
|
59
|
+
.endTimeLabel=${e.endTimeLabel}
|
|
60
|
+
.minDateTime=${e.minDateTime}
|
|
61
|
+
.maxDateTime=${e.maxDateTime}
|
|
62
|
+
.disabledRanges=${e.disabledRanges}
|
|
63
|
+
.minDateTimeMessage=${e.minDateTimeMessage}
|
|
64
|
+
.maxDateTimeMessage=${e.maxDateTimeMessage}
|
|
65
|
+
.disabledRangeMessage=${e.disabledRangeMessage}
|
|
66
|
+
.noAvailableTimesMessage=${e.noAvailableTimesMessage}
|
|
67
|
+
.dayCountAriaLabel=${e.dayCountAriaLabel}
|
|
68
|
+
.disabledDayCountAriaLabel=${e.disabledDayCountAriaLabel}
|
|
69
|
+
@change=${this.valueChanged}
|
|
70
|
+
@inputError=${this.onInputError}
|
|
71
|
+
@blur=${() => this.adapter.onBlur()}
|
|
72
|
+
></gui-range-date-time-calendar>
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
valueChanged(e) {
|
|
76
|
+
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
|
|
77
|
+
}
|
|
78
|
+
onInputError(e) {
|
|
79
|
+
this.adapter.injectValidationIssues([e.detail.message]), this.adapter.onBlur();
|
|
80
|
+
}
|
|
81
|
+
disconnectedCallback() {
|
|
82
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
l([
|
|
86
|
+
p({ context: m }),
|
|
87
|
+
$({ attribute: !1 })
|
|
88
|
+
], i.prototype, "formContext", 2);
|
|
89
|
+
l([
|
|
90
|
+
h({ context: u })
|
|
91
|
+
], i.prototype, "adapter", 2);
|
|
92
|
+
i = l([
|
|
93
|
+
g("gui-range-date-time-calendar-input")
|
|
94
|
+
], i);
|
|
95
|
+
export {
|
|
96
|
+
i as RangeDateTimeCalendarElement
|
|
97
|
+
};
|
|
@@ -0,0 +1,353 @@
|
|
|
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 y } from "lit/directives/class-map.js";
|
|
4
|
+
import { styleMap as v } from "lit-html/directives/style-map.js";
|
|
5
|
+
import { G as b, b as f, c as D } from "./templates-Dmr34nwp.js";
|
|
6
|
+
import { G as A, g as S, a as P, r as h, f as T, p as m, b as L, d as _, m as E, c as R, o as C, P as $ } from "./part-templates-VORbpgs2.js";
|
|
7
|
+
import { c as k } from "./range-commit-8-MmYUyo.js";
|
|
8
|
+
import { r as I, f as M, b as w, a as B, s as F } from "./pill-ranges-DpvWwP-3.js";
|
|
9
|
+
import "./pills-BDMO2NiR.js";
|
|
10
|
+
import { D as O } from "./date-DBuYpvcO.js";
|
|
11
|
+
var x = Object.defineProperty, G = Object.getOwnPropertyDescriptor, i = (e, r, l, s) => {
|
|
12
|
+
for (var o = s > 1 ? void 0 : s ? G(r, l) : r, n = e.length - 1, d; n >= 0; n--)
|
|
13
|
+
(d = e[n]) && (o = (s ? d(r, l, o) : d(o)) || o);
|
|
14
|
+
return s && o && x(r, l, o), o;
|
|
15
|
+
};
|
|
16
|
+
let t = 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.dayAriaLabel = void 0, this.monthAriaLabel = void 0, this.yearAriaLabel = void 0, this.hourAriaLabel = void 0, this.minuteAriaLabel = void 0, this.dayPeriodAriaLabel = 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 A(this, {
|
|
19
|
+
blockClass: this.inputBlockClass,
|
|
20
|
+
groups: this.groups,
|
|
21
|
+
getDescriptor: (e) => this.getPartDescriptor(e),
|
|
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: (e) => this.dispatchEvent(new CustomEvent("inputError", { detail: { message: e }, bubbles: !0 })),
|
|
35
|
+
onSurfacedErrorCleared: (e) => this.dispatchEvent(
|
|
36
|
+
new CustomEvent("change", { detail: { value: e }, 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
|
+
required: this.required
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}), this.onPillRemoveEvent = (e) => {
|
|
52
|
+
if (this.disabled || this.readOnly) return;
|
|
53
|
+
const r = I(this.value, e.detail.key);
|
|
54
|
+
r && (this.value = r.next, this.dispatchEvent(
|
|
55
|
+
new CustomEvent("change", { detail: { value: this.value }, bubbles: !0, composed: !0 })
|
|
56
|
+
), r.next.length === 0 && requestAnimationFrame(() => {
|
|
57
|
+
this.querySelector(".gui-range-date-time-input__field input")?.focus();
|
|
58
|
+
}));
|
|
59
|
+
}, this.onPillClickEvent = (e) => {
|
|
60
|
+
const r = M(this.getSortedPills(), e.detail.key);
|
|
61
|
+
r && this.onPillClick(r);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
createRenderRoot() {
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
69
|
+
}
|
|
70
|
+
get localeData() {
|
|
71
|
+
return S(this.localeId, this.hourFormat, this.minuteStep, !0);
|
|
72
|
+
}
|
|
73
|
+
getPartDescriptor(e) {
|
|
74
|
+
return this.localeData.descriptors[e];
|
|
75
|
+
}
|
|
76
|
+
willUpdate(e) {
|
|
77
|
+
(!this.hasUpdated || e.has("hourFormat") || e.has("localeId")) && this._parts.seedDayPeriods();
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
const e = {
|
|
81
|
+
uid: this.uid,
|
|
82
|
+
label: this.label,
|
|
83
|
+
errors: this.errors,
|
|
84
|
+
touched: this.touched,
|
|
85
|
+
required: this.required,
|
|
86
|
+
disabled: this.disabled,
|
|
87
|
+
readonly: this.readOnly,
|
|
88
|
+
value: this.value,
|
|
89
|
+
hint: this.hint
|
|
90
|
+
}, r = {
|
|
91
|
+
blockClass: this.inputBlockClass,
|
|
92
|
+
groups: this.groups,
|
|
93
|
+
formatParts: P(this.localeId, this.localeData.effectiveHourFormat),
|
|
94
|
+
getDescriptor: (o) => this.getPartDescriptor(o),
|
|
95
|
+
getDisplayValue: this._parts.getPartDisplay,
|
|
96
|
+
getPartAriaLabel: (o, n) => ({
|
|
97
|
+
day: this.dayAriaLabel,
|
|
98
|
+
month: this.monthAriaLabel,
|
|
99
|
+
year: this.yearAriaLabel,
|
|
100
|
+
hour: this.hourAriaLabel,
|
|
101
|
+
minute: this.minuteAriaLabel
|
|
102
|
+
})[n] ?? $[n],
|
|
103
|
+
dayPeriodAriaLabel: this.dayPeriodAriaLabel,
|
|
104
|
+
disabled: this.disabled,
|
|
105
|
+
partsReadonly: !!this.readOnly
|
|
106
|
+
}, l = w(
|
|
107
|
+
this.getSortedPills(),
|
|
108
|
+
(o) => B(o, (n) => this.formatDateTimeForDisplay(n))
|
|
109
|
+
), s = {
|
|
110
|
+
"gui-widget-icon": !0,
|
|
111
|
+
[this.icon]: !!this.icon
|
|
112
|
+
};
|
|
113
|
+
return u`
|
|
114
|
+
${this.label ? f(this.uid, e, !1, void 0, !1) : p}
|
|
115
|
+
|
|
116
|
+
<div class="gui-widget">
|
|
117
|
+
<div
|
|
118
|
+
class="gui-widget-input gui-parts-ring gui-range-date-time-input ${this.icon ? "gui-range-date-time-input--icon" : ""}"
|
|
119
|
+
role="group"
|
|
120
|
+
aria-label=${this.label ?? "Date-time range input"}
|
|
121
|
+
>
|
|
122
|
+
${this.icon ? u`<span
|
|
123
|
+
class=${y(s)}
|
|
124
|
+
data-icon=${this.icon}
|
|
125
|
+
aria-hidden="true"
|
|
126
|
+
></span>` : p}
|
|
127
|
+
|
|
128
|
+
<gui-pills
|
|
129
|
+
class="gui-range-date-time-input__pills"
|
|
130
|
+
style=${v(l.length ? {} : { "min-width": 0 })}
|
|
131
|
+
.uid=${this.uid}
|
|
132
|
+
.toolbarAriaLabel=${"Selected date-time ranges"}
|
|
133
|
+
.items=${l}
|
|
134
|
+
.removable=${!0}
|
|
135
|
+
.clickable=${!0}
|
|
136
|
+
.bubble=${!0}
|
|
137
|
+
?disabled=${this.disabled}
|
|
138
|
+
?readonly=${this.readOnly}
|
|
139
|
+
.removeAriaLabel=${this.removePillAriaLabel ?? "Remove date-time"}
|
|
140
|
+
.compactAriaLabel=${`${l.length} date-time ranges`}
|
|
141
|
+
@pillremove=${this.onPillRemoveEvent}
|
|
142
|
+
@pillclick=${this.onPillClickEvent}
|
|
143
|
+
></gui-pills>
|
|
144
|
+
|
|
145
|
+
<div class="gui-range-date-time-input__inputs">
|
|
146
|
+
<div
|
|
147
|
+
class="gui-parts gui-range-date-time-input__field"
|
|
148
|
+
role="group"
|
|
149
|
+
aria-label=${this.startDateTimeAriaLabel ?? "Start date-time"}
|
|
150
|
+
>
|
|
151
|
+
${h("start", r, this._parts)}
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<span class="gui-range-date-time-input__separator">${this.separator ?? "-"}</span>
|
|
155
|
+
|
|
156
|
+
<div
|
|
157
|
+
class="gui-parts gui-range-date-time-input__field"
|
|
158
|
+
role="group"
|
|
159
|
+
aria-label=${this.endDateTimeAriaLabel ?? "End date-time"}
|
|
160
|
+
>
|
|
161
|
+
${h("end", r, this._parts)}
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
${this.showErrors && this.errors?.length ? D(this.uid, e) : p}
|
|
167
|
+
</div>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
onPillClick(e) {
|
|
171
|
+
this.dispatchEvent(
|
|
172
|
+
new CustomEvent("pillClick", { detail: { range: e }, bubbles: !0, composed: !0 })
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
formatDateTimeForDisplay(e) {
|
|
176
|
+
return T(e, this.localeId, this.localeData.effectiveHourFormat);
|
|
177
|
+
}
|
|
178
|
+
getSortedPills() {
|
|
179
|
+
return F(
|
|
180
|
+
this.value,
|
|
181
|
+
(e, r) => m(e).getTime() - m(r).getTime()
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Parses a group into an ISO date-time via the shared clamp/bounds pipeline,
|
|
186
|
+
* distinguishing an incomplete group (nothing to report) from a
|
|
187
|
+
* complete-but-rejected one (an impossible date or an out-of-bounds
|
|
188
|
+
* date-time). It does not emit: the caller decides whether to surface or
|
|
189
|
+
* clear an error, so fixing one group clears its error even while the other
|
|
190
|
+
* is still empty.
|
|
191
|
+
*
|
|
192
|
+
* Each endpoint is an instant, so it is bounded by instants. A date-only
|
|
193
|
+
* bound could not express this: `maxDate: 2026-02-10` is ambiguous about
|
|
194
|
+
* whether the 10th is allowed until 00:00 or 23:59, and independent date/time
|
|
195
|
+
* axes would wrongly reject Feb 11 08:00 for a `minTime` of 09:00.
|
|
196
|
+
*/
|
|
197
|
+
validateDateTimeParts(e) {
|
|
198
|
+
const { effectiveHourFormat: r, descriptors: l } = this.localeData, { result: s, writeBacks: o } = L(this._parts.values[e] ?? {}, {
|
|
199
|
+
hourFormat: r,
|
|
200
|
+
descriptors: l,
|
|
201
|
+
invalidDateMessage: this.invalidDateMessage
|
|
202
|
+
});
|
|
203
|
+
if (this._parts.applyWriteBacks(e, o), s.kind === "incomplete") return { kind: "incomplete" };
|
|
204
|
+
if (s.kind === "invalid") return { kind: "invalid", message: s.message };
|
|
205
|
+
const n = _(s.iso, this.minDateTime, this.maxDateTime, {
|
|
206
|
+
minDateTimeMessage: this.minDateTimeMessage,
|
|
207
|
+
maxDateTimeMessage: this.maxDateTimeMessage
|
|
208
|
+
});
|
|
209
|
+
return n ? { kind: "invalid", message: n } : { kind: "valid", value: s.iso };
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Re-parses both endpoints so per-endpoint problems (impossible date-time,
|
|
213
|
+
* out of instant bounds) surface while the user types. Runs on every part
|
|
214
|
+
* change.
|
|
215
|
+
*/
|
|
216
|
+
syncParts() {
|
|
217
|
+
return {
|
|
218
|
+
start: this.validateDateTimeParts("start"),
|
|
219
|
+
end: this.validateDateTimeParts("end")
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Parses the range and updates the error state, without ever committing.
|
|
224
|
+
* Shared by the Enter commit and by {@link revalidate}.
|
|
225
|
+
*/
|
|
226
|
+
evaluateRange() {
|
|
227
|
+
const { start: e, end: r } = this.syncParts(), l = k(e, r, this.value, {
|
|
228
|
+
// Date-time ranges are two instants: a backward selection reorders (swap)
|
|
229
|
+
// rather than erroring — mirroring the range calendar's date swap.
|
|
230
|
+
order: (s, o) => {
|
|
231
|
+
const n = C(s, o);
|
|
232
|
+
return { start: n.start, end: n.end };
|
|
233
|
+
},
|
|
234
|
+
validate: (s) => R({ start: s.start, end: s.end }, this.disabledRanges) ? this.disabledRangeMessage ?? O : null,
|
|
235
|
+
toRange: (s) => ({ start: s.start, end: s.end }),
|
|
236
|
+
merge: E
|
|
237
|
+
});
|
|
238
|
+
return l.kind === "invalid" && this._parts.surfaceInputError(l.message), l.kind === "incomplete" && this._parts.clearSurfacedInputError(this.value ?? []), l;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Once the user has attempted a commit, every later edit re-runs validation
|
|
242
|
+
* so a corrected range clears its error immediately, otherwise the message
|
|
243
|
+
* would linger until the next Enter and the user could not tell the problem
|
|
244
|
+
* was solved.
|
|
245
|
+
*/
|
|
246
|
+
revalidate() {
|
|
247
|
+
this.evaluateRange().kind === "commit" && this._parts.clearSurfacedInputError(this.value ?? []);
|
|
248
|
+
}
|
|
249
|
+
tryCreatePill() {
|
|
250
|
+
this._validationTriggered = !0;
|
|
251
|
+
const e = this.evaluateRange();
|
|
252
|
+
e.kind === "commit" && (this.value = e.value, this._validationTriggered = !1, this._parts.clearGroup("start"), this._parts.clearGroup("end"), this._parts.seedDayPeriods(), this._parts.resetSurfacedInputError(), this.dispatchEvent(
|
|
253
|
+
new CustomEvent("change", { detail: { value: this.value }, bubbles: !0, composed: !0 })
|
|
254
|
+
), this._parts.focusFirst("start"), this.requestUpdate());
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
i([
|
|
258
|
+
a({ type: String })
|
|
259
|
+
], t.prototype, "uid", 2);
|
|
260
|
+
i([
|
|
261
|
+
a({ type: String })
|
|
262
|
+
], t.prototype, "label", 2);
|
|
263
|
+
i([
|
|
264
|
+
a({ type: String, attribute: "locale-id" })
|
|
265
|
+
], t.prototype, "localeId", 2);
|
|
266
|
+
i([
|
|
267
|
+
a({ type: Array })
|
|
268
|
+
], t.prototype, "errors", 2);
|
|
269
|
+
i([
|
|
270
|
+
a({ type: Boolean })
|
|
271
|
+
], t.prototype, "showErrors", 2);
|
|
272
|
+
i([
|
|
273
|
+
a({ type: Boolean })
|
|
274
|
+
], t.prototype, "touched", 2);
|
|
275
|
+
i([
|
|
276
|
+
a({ type: Boolean })
|
|
277
|
+
], t.prototype, "required", 2);
|
|
278
|
+
i([
|
|
279
|
+
a({ type: Boolean })
|
|
280
|
+
], t.prototype, "disabled", 2);
|
|
281
|
+
i([
|
|
282
|
+
a({ type: Boolean, attribute: "readonly" })
|
|
283
|
+
], t.prototype, "readOnly", 2);
|
|
284
|
+
i([
|
|
285
|
+
a({ type: String })
|
|
286
|
+
], t.prototype, "icon", 2);
|
|
287
|
+
i([
|
|
288
|
+
a({ type: String })
|
|
289
|
+
], t.prototype, "hint", 2);
|
|
290
|
+
i([
|
|
291
|
+
a({ type: String })
|
|
292
|
+
], t.prototype, "dayAriaLabel", 2);
|
|
293
|
+
i([
|
|
294
|
+
a({ type: String })
|
|
295
|
+
], t.prototype, "monthAriaLabel", 2);
|
|
296
|
+
i([
|
|
297
|
+
a({ type: String })
|
|
298
|
+
], t.prototype, "yearAriaLabel", 2);
|
|
299
|
+
i([
|
|
300
|
+
a({ type: String })
|
|
301
|
+
], t.prototype, "hourAriaLabel", 2);
|
|
302
|
+
i([
|
|
303
|
+
a({ type: String })
|
|
304
|
+
], t.prototype, "minuteAriaLabel", 2);
|
|
305
|
+
i([
|
|
306
|
+
a({ type: String })
|
|
307
|
+
], t.prototype, "dayPeriodAriaLabel", 2);
|
|
308
|
+
i([
|
|
309
|
+
a({ type: String, attribute: "hour-format" })
|
|
310
|
+
], t.prototype, "hourFormat", 2);
|
|
311
|
+
i([
|
|
312
|
+
a({ type: Number, attribute: "minute-step" })
|
|
313
|
+
], t.prototype, "minuteStep", 2);
|
|
314
|
+
i([
|
|
315
|
+
a({ type: String, attribute: "invalid-date-message" })
|
|
316
|
+
], t.prototype, "invalidDateMessage", 2);
|
|
317
|
+
i([
|
|
318
|
+
a({ type: Array })
|
|
319
|
+
], t.prototype, "value", 2);
|
|
320
|
+
i([
|
|
321
|
+
a({ type: String })
|
|
322
|
+
], t.prototype, "removePillAriaLabel", 2);
|
|
323
|
+
i([
|
|
324
|
+
a({ type: String })
|
|
325
|
+
], t.prototype, "startDateTimeAriaLabel", 2);
|
|
326
|
+
i([
|
|
327
|
+
a({ type: String })
|
|
328
|
+
], t.prototype, "endDateTimeAriaLabel", 2);
|
|
329
|
+
i([
|
|
330
|
+
a({ type: String })
|
|
331
|
+
], t.prototype, "separator", 2);
|
|
332
|
+
i([
|
|
333
|
+
a({ type: String, attribute: "min-date-time" })
|
|
334
|
+
], t.prototype, "minDateTime", 2);
|
|
335
|
+
i([
|
|
336
|
+
a({ type: String, attribute: "max-date-time" })
|
|
337
|
+
], t.prototype, "maxDateTime", 2);
|
|
338
|
+
i([
|
|
339
|
+
a({ type: String, attribute: "min-date-time-message" })
|
|
340
|
+
], t.prototype, "minDateTimeMessage", 2);
|
|
341
|
+
i([
|
|
342
|
+
a({ type: String, attribute: "max-date-time-message" })
|
|
343
|
+
], t.prototype, "maxDateTimeMessage", 2);
|
|
344
|
+
i([
|
|
345
|
+
a({ type: Array, attribute: "disabled-ranges" })
|
|
346
|
+
], t.prototype, "disabledRanges", 2);
|
|
347
|
+
i([
|
|
348
|
+
a({ type: String, attribute: "disabled-range-message" })
|
|
349
|
+
], t.prototype, "disabledRangeMessage", 2);
|
|
350
|
+
t = i([
|
|
351
|
+
c("gui-range-date-time")
|
|
352
|
+
], t);
|
|
353
|
+
typeof customElements < "u" && !customElements.get("gui-range-date-time") && customElements.define("gui-range-date-time", t);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { InputWidgetAdapter as m, formContext as n, inputContext as o } from "@golemui/lit";
|
|
2
|
+
import "./range-date-time-input-Cu-T_nuC.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 b, customElement as $ } from "lit/decorators.js";
|
|
6
|
+
import "rxjs";
|
|
7
|
+
var g = Object.defineProperty, L = Object.getOwnPropertyDescriptor, d = (e, t, s, r) => {
|
|
8
|
+
for (var a = r > 1 ? void 0 : r ? L(t, s) : t, p = e.length - 1, l; p >= 0; p--)
|
|
9
|
+
(l = e[p]) && (a = (r ? l(t, s, a) : l(a)) || a);
|
|
10
|
+
return r && a && g(t, s, a), a;
|
|
11
|
+
};
|
|
12
|
+
let i = class extends D {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.adapter = new m(), 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", "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
|
+
.dayAriaLabel=${this.adapter.templateData.dayAriaLabel}
|
|
44
|
+
.monthAriaLabel=${this.adapter.templateData.monthAriaLabel}
|
|
45
|
+
.yearAriaLabel=${this.adapter.templateData.yearAriaLabel}
|
|
46
|
+
.hourAriaLabel=${this.adapter.templateData.hourAriaLabel}
|
|
47
|
+
.minuteAriaLabel=${this.adapter.templateData.minuteAriaLabel}
|
|
48
|
+
.dayPeriodAriaLabel=${this.adapter.templateData.dayPeriodAriaLabel}
|
|
49
|
+
.separator=${this.adapter.templateData.separator}
|
|
50
|
+
.removePillAriaLabel=${this.adapter.templateData.removePillAriaLabel}
|
|
51
|
+
.startDateTimeAriaLabel=${this.adapter.templateData.startDateTimeAriaLabel}
|
|
52
|
+
.endDateTimeAriaLabel=${this.adapter.templateData.endDateTimeAriaLabel}
|
|
53
|
+
.hourFormat=${this.adapter.templateData.hourFormat}
|
|
54
|
+
.minuteStep=${this.adapter.templateData.minuteStep}
|
|
55
|
+
.minDateTime=${this.adapter.templateData.minDateTime}
|
|
56
|
+
.maxDateTime=${this.adapter.templateData.maxDateTime}
|
|
57
|
+
.invalidDateMessage=${this.adapter.templateData.invalidDateMessage}
|
|
58
|
+
.minDateTimeMessage=${this.adapter.templateData.minDateTimeMessage}
|
|
59
|
+
.maxDateTimeMessage=${this.adapter.templateData.maxDateTimeMessage}
|
|
60
|
+
@change=${this.valueChanged}
|
|
61
|
+
@inputError=${this.onInputError}
|
|
62
|
+
></gui-range-date-time>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
valueChanged(e) {
|
|
66
|
+
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
|
|
67
|
+
}
|
|
68
|
+
onInputError(e) {
|
|
69
|
+
this.adapter.injectValidationIssues([e.detail.message]);
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
d([
|
|
76
|
+
h({ context: n }),
|
|
77
|
+
b({ attribute: !1 })
|
|
78
|
+
], i.prototype, "formContext", 2);
|
|
79
|
+
d([
|
|
80
|
+
u({ context: o })
|
|
81
|
+
], i.prototype, "adapter", 2);
|
|
82
|
+
i = d([
|
|
83
|
+
$("gui-range-date-time-input")
|
|
84
|
+
], i);
|
|
85
|
+
export {
|
|
86
|
+
i as RangeDateTimeInputElement
|
|
87
|
+
};
|