@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,48 @@
|
|
|
1
|
+
import { p as o } from "./date-Bj9mI3GU.js";
|
|
2
|
+
function i(t) {
|
|
3
|
+
return `${t.start}-${t.end ?? t.start}`;
|
|
4
|
+
}
|
|
5
|
+
function f(t, n) {
|
|
6
|
+
return !t || !Array.isArray(t) ? [] : [...t].sort((r, e) => n(r.start, e.start));
|
|
7
|
+
}
|
|
8
|
+
function u(t, n) {
|
|
9
|
+
return t.find((r) => i(r) === n);
|
|
10
|
+
}
|
|
11
|
+
function c(t, n) {
|
|
12
|
+
const r = t ?? [], e = u(r, n);
|
|
13
|
+
if (!e) return null;
|
|
14
|
+
const a = r.filter(
|
|
15
|
+
(s) => !(s.start === e.start && (s.end ?? null) === (e.end ?? null))
|
|
16
|
+
);
|
|
17
|
+
return { removed: e, next: a };
|
|
18
|
+
}
|
|
19
|
+
function d(t, n) {
|
|
20
|
+
const r = o(t);
|
|
21
|
+
return isNaN(r.getTime()) ? t : new Intl.DateTimeFormat(n ?? "en", {
|
|
22
|
+
year: "numeric",
|
|
23
|
+
month: "2-digit",
|
|
24
|
+
day: "2-digit"
|
|
25
|
+
}).format(r);
|
|
26
|
+
}
|
|
27
|
+
function m(t, n) {
|
|
28
|
+
const r = n(t.start), e = t.end ? n(t.end) : r;
|
|
29
|
+
return `${r} - ${e}`;
|
|
30
|
+
}
|
|
31
|
+
function y(t, n, r) {
|
|
32
|
+
return t.map((e) => {
|
|
33
|
+
const a = n(e);
|
|
34
|
+
return {
|
|
35
|
+
key: i(e),
|
|
36
|
+
label: a,
|
|
37
|
+
ariaLabel: `${r} ${a}`
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
m as a,
|
|
43
|
+
y as b,
|
|
44
|
+
d as c,
|
|
45
|
+
u as f,
|
|
46
|
+
c as r,
|
|
47
|
+
f as s
|
|
48
|
+
};
|
|
@@ -130,6 +130,9 @@ let r = class extends m {
|
|
|
130
130
|
tabindex="-1"
|
|
131
131
|
aria-hidden="true"
|
|
132
132
|
?disabled=${this.disabled || this.readOnly}
|
|
133
|
+
@mousedown=${(t) => {
|
|
134
|
+
t.stopPropagation(), t.preventDefault();
|
|
135
|
+
}}
|
|
133
136
|
@click=${(t) => {
|
|
134
137
|
t.stopPropagation(), this.emitRemove(e.key, this.items.indexOf(e));
|
|
135
138
|
}}
|
|
@@ -198,7 +201,7 @@ let r = class extends m {
|
|
|
198
201
|
return;
|
|
199
202
|
}
|
|
200
203
|
if (e.key === "Escape" && s) {
|
|
201
|
-
e.preventDefault(), this.closeDropdown();
|
|
204
|
+
e.preventDefault(), e.stopPropagation(), this.closeDropdown();
|
|
202
205
|
return;
|
|
203
206
|
}
|
|
204
207
|
this.emitKeydown(t.key, e);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "lit";
|
|
2
|
+
import { G as r } from "./focus-leave.controller-2gV0pQd5.js";
|
|
3
|
+
class p {
|
|
4
|
+
constructor(s, n) {
|
|
5
|
+
this._open = !1, this._restoringFocus = !1, this._suppressNextFocusOut = !1, this.show = () => {
|
|
6
|
+
this.options.isDisabled() || this._restoringFocus || (this.options.beforeOpen?.(this), this.setOpen(!0));
|
|
7
|
+
}, this.close = () => {
|
|
8
|
+
this.setOpen(!1);
|
|
9
|
+
}, this.toggle = () => {
|
|
10
|
+
this.options.isDisabled() || (this.options.keyToggleMode === "toggle" ? this.setOpen(!this._open) : this._open ? this.close() : this.show());
|
|
11
|
+
}, this.onAnchorClick = (t) => {
|
|
12
|
+
if (this.options.isDisabled()) return;
|
|
13
|
+
const e = t.target, o = this.options.clickIntent(e);
|
|
14
|
+
if (o !== "ignore") {
|
|
15
|
+
if (o === "open") {
|
|
16
|
+
this.show();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.toggle();
|
|
20
|
+
}
|
|
21
|
+
}, this.onAnchorKeyUp = (t) => {
|
|
22
|
+
this.options.isDisabled() || t.target === t.currentTarget && (t.key === "Enter" || t.key === " ") && this.toggle();
|
|
23
|
+
}, this.onAnchorKeyDown = (t) => this.options.isDisabled() ? !1 : t.key === "Escape" && this._open ? (t.preventDefault(), t.stopPropagation(), this.restoreFocusToInput(), this.close(), !0) : !1, this.onDocumentClick = (t) => {
|
|
24
|
+
if (!this._open) return;
|
|
25
|
+
const e = t.composedPath();
|
|
26
|
+
this.options.getInteriorElements().some((i) => !!i && e.includes(i)) || this.close();
|
|
27
|
+
}, this.onHostFocusOut = (t) => {
|
|
28
|
+
if (this._suppressNextFocusOut) {
|
|
29
|
+
this._suppressNextFocusOut = !1;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this._open && this.focusLeave.handleFocusOut(t);
|
|
33
|
+
}, this.host = s, this.options = n, this.focusLeave = new r(s, {
|
|
34
|
+
onLeave: () => this.close()
|
|
35
|
+
}), s.addController(this);
|
|
36
|
+
}
|
|
37
|
+
get open() {
|
|
38
|
+
return this._open;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Swallows exactly the next focusout pass — even one that arrives while
|
|
42
|
+
* the popup is closed — then re-arms normal behavior. Used around
|
|
43
|
+
* operations that transiently move focus (pills dropdown coordination).
|
|
44
|
+
*/
|
|
45
|
+
suppressNextFocusOut() {
|
|
46
|
+
this._suppressNextFocusOut = !0;
|
|
47
|
+
}
|
|
48
|
+
setOpen(s) {
|
|
49
|
+
this._open !== s && (this._open = s, this.host.requestUpdate(), this.options.onOpenChanged?.(s));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Focuses the `focusRestoreSelector` element, arming the restoring-focus
|
|
53
|
+
* flag (reset via setTimeout(0)) so the resulting focus event does not
|
|
54
|
+
* re-open the popup through show().
|
|
55
|
+
*/
|
|
56
|
+
restoreFocusToInput() {
|
|
57
|
+
const s = this.host.querySelector(this.options.focusRestoreSelector);
|
|
58
|
+
s && (this._restoringFocus = !0, s.focus(), setTimeout(() => {
|
|
59
|
+
this._restoringFocus = !1;
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
hostConnected() {
|
|
63
|
+
document.addEventListener("click", this.onDocumentClick), this.host.addEventListener("focusout", this.onHostFocusOut);
|
|
64
|
+
}
|
|
65
|
+
hostDisconnected() {
|
|
66
|
+
document.removeEventListener("click", this.onDocumentClick), this.host.removeEventListener("focusout", this.onHostFocusOut);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
p as G
|
|
71
|
+
};
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { LitElement as y, html as c, nothing as p } from "lit";
|
|
2
|
+
import { property as s, state as v, customElement as b } from "lit/decorators.js";
|
|
3
|
+
import { classMap as m } from "lit/directives/class-map.js";
|
|
4
|
+
import { G as D } from "./templates-Dk1jxLwS.js";
|
|
5
|
+
import { G as f, a as _, r as R, b as S, c as M, d as I, e as C } from "./day-status-0-hJHrI7.js";
|
|
6
|
+
import { G as O } from "./focus-leave.controller-2gV0pQd5.js";
|
|
7
|
+
import { p as h, t as l, r as E, D as A, m as P, c as L } from "./date-Bj9mI3GU.js";
|
|
8
|
+
import { r as x, f as k, a as w, b as G, s as N, c as T } from "./pill-ranges-DCqDmpkk.js";
|
|
9
|
+
import { i as $, s as F, r as g } from "./range-selection-CU3hxLJE.js";
|
|
10
|
+
import "./pills-Be1UrLgq.js";
|
|
11
|
+
var Y = Object.defineProperty, B = Object.getOwnPropertyDescriptor, n = (e, t, o, a) => {
|
|
12
|
+
for (var r = a > 1 ? void 0 : a ? B(t, o) : t, d = e.length - 1, u; d >= 0; d--)
|
|
13
|
+
(u = e[d]) && (r = (a ? u(t, o, r) : u(r)) || r);
|
|
14
|
+
return a && r && Y(t, o, r), r;
|
|
15
|
+
};
|
|
16
|
+
let i = class extends y {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.localeId = void 0, this.errors = [], this.touched = void 0, this.required = !1, this.disabled = !1, this.readOnly = !1, this.prevMonthIcon = "", this.nextMonthIcon = "", this.prevMonthAriaLabel = "", this.nextMonthAriaLabel = "", this.dayFormat = "numeric", this.weekdayFormat = "narrow", this.monthFormat = "long", this.minDate = void 0, this.maxDate = void 0, this.disabledRanges = void 0, this.numberOfMonths = 1, this.value = [], this.focusDate = void 0, this.hidePills = !1, this.removePillAriaLabel = void 0, this.disabledDateRangeMessage = void 0, this.invalidRange = null, this._selection = $(), this._invalidRange = null, this._skipValueNavigation = !1, this._nav = new f(this, {
|
|
19
|
+
getMinDate: () => this.minDate,
|
|
20
|
+
getMaxDate: () => this.maxDate,
|
|
21
|
+
getNumberOfMonths: () => this.numberOfMonths,
|
|
22
|
+
getDisabledRanges: () => this.disabledRanges,
|
|
23
|
+
onYearSelectorToggled: () => this._keyboard.onYearGridToggled()
|
|
24
|
+
}), this.ariaController = new D(this, {
|
|
25
|
+
getTargets: () => this.querySelectorAll(".gui-calendar-input"),
|
|
26
|
+
getState: () => ({
|
|
27
|
+
uid: this.uid,
|
|
28
|
+
templateData: {
|
|
29
|
+
hint: this.hint,
|
|
30
|
+
errors: this.errors,
|
|
31
|
+
readonly: this.readOnly,
|
|
32
|
+
disabled: this.disabled,
|
|
33
|
+
touched: this.touched
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}), this._keyboard = new _(this, {
|
|
37
|
+
canGoPrev: () => this._nav.canGoPrev(),
|
|
38
|
+
canGoNext: () => this._nav.canGoNext(),
|
|
39
|
+
goPrev: () => this._nav.prevMonth(),
|
|
40
|
+
goNext: () => this._nav.nextMonth(),
|
|
41
|
+
onActivateDay: (e, t) => this.selectDate(this.activationDay(e), t),
|
|
42
|
+
onSelectYear: (e) => this._nav.selectYear(e),
|
|
43
|
+
onCloseYearGrid: () => this._nav.closeYearSelector(),
|
|
44
|
+
isYearGridOpen: () => this._nav.yearSelectorOpen
|
|
45
|
+
}), this._focusLeave = new O(this, {
|
|
46
|
+
onLeave: () => this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 }))
|
|
47
|
+
}), this.onPillRemoveEvent = (e) => {
|
|
48
|
+
if (this.disabled || this.readOnly) return;
|
|
49
|
+
const t = x(this.value, e.detail.key);
|
|
50
|
+
t && (this.value = t.next, this.dispatchEvent(
|
|
51
|
+
new CustomEvent("change", {
|
|
52
|
+
detail: { value: this.value },
|
|
53
|
+
bubbles: !0,
|
|
54
|
+
composed: !0
|
|
55
|
+
})
|
|
56
|
+
));
|
|
57
|
+
}, this.onPillClickEvent = (e) => {
|
|
58
|
+
const t = k(this.getSortedPills(), e.detail.key);
|
|
59
|
+
t && this.navigateToDate(t.start);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** The nav controller's month cursor, kept under its historical name. */
|
|
63
|
+
get _currentDate() {
|
|
64
|
+
return this._nav.currentDate;
|
|
65
|
+
}
|
|
66
|
+
set _currentDate(e) {
|
|
67
|
+
this._nav.currentDate = e;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Full instant of an endpoint, used to order the pills. Date-only here; a
|
|
71
|
+
* subclass whose endpoints carry a time overrides it so two ranges on the
|
|
72
|
+
* same day still sort by time.
|
|
73
|
+
*/
|
|
74
|
+
parseEndpoint(e) {
|
|
75
|
+
return h(e);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Midnight-truncated calendar day of an endpoint, used to highlight the day
|
|
79
|
+
* grid.
|
|
80
|
+
*/
|
|
81
|
+
endpointDay(e) {
|
|
82
|
+
return h(e);
|
|
83
|
+
}
|
|
84
|
+
/** Pill text for one committed range. */
|
|
85
|
+
formatPillLabel(e) {
|
|
86
|
+
return w(e, (t) => T(t, this.localeId));
|
|
87
|
+
}
|
|
88
|
+
/** Day-button inner content. */
|
|
89
|
+
renderDayContent(e) {
|
|
90
|
+
return c`${e.dayLabel}`;
|
|
91
|
+
}
|
|
92
|
+
createRenderRoot() {
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
connectedCallback() {
|
|
96
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
97
|
+
}
|
|
98
|
+
willUpdate(e) {
|
|
99
|
+
if (e.has("invalidRange"))
|
|
100
|
+
if (this.invalidRange) {
|
|
101
|
+
const t = this.endpointDay(this.invalidRange.start), o = this.endpointDay(this.invalidRange.end);
|
|
102
|
+
this._invalidRange = isNaN(t.getTime()) || isNaN(o.getTime()) ? null : { start: t, end: o };
|
|
103
|
+
} else
|
|
104
|
+
this._invalidRange = null;
|
|
105
|
+
if (e.has("value") && !e.has("focusDate")) {
|
|
106
|
+
if (this._skipValueNavigation)
|
|
107
|
+
this._skipValueNavigation = !1;
|
|
108
|
+
else if (this.value) {
|
|
109
|
+
const t = Array.isArray(this.value) ? this.value : [{ start: this.value }];
|
|
110
|
+
t.length > 0 && t[0].start && this._nav.navigateToDate(this.endpointDay(t[0].start));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (e.has("focusDate") && this.focusDate) {
|
|
114
|
+
const t = h(this.focusDate);
|
|
115
|
+
isNaN(t.getTime()) || (this._nav.navigateToDate(t), this.focusDate = void 0);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
return R({
|
|
120
|
+
uid: this.uid,
|
|
121
|
+
label: this.label,
|
|
122
|
+
hint: this.hint,
|
|
123
|
+
errors: this.errors,
|
|
124
|
+
touched: this.touched,
|
|
125
|
+
required: this.required,
|
|
126
|
+
disabled: this.disabled,
|
|
127
|
+
numberOfMonths: this.numberOfMonths,
|
|
128
|
+
prevMonthIcon: this.prevMonthIcon,
|
|
129
|
+
nextMonthIcon: this.nextMonthIcon,
|
|
130
|
+
prevMonthAriaLabel: this.prevMonthAriaLabel,
|
|
131
|
+
nextMonthAriaLabel: this.nextMonthAriaLabel,
|
|
132
|
+
canGoPrev: this._nav.canGoPrev(),
|
|
133
|
+
canGoNext: this._nav.canGoNext(),
|
|
134
|
+
onPrevMonthClick: this._keyboard.onPrevMonthClick,
|
|
135
|
+
onNextMonthClick: this._keyboard.onNextMonthClick,
|
|
136
|
+
onFocusOut: this._focusLeave.onFocusOut,
|
|
137
|
+
renderAboveCalendar: () => this.renderAboveCalendar(),
|
|
138
|
+
renderMonthPanel: (e) => S({
|
|
139
|
+
currentDate: this._nav.currentDate,
|
|
140
|
+
offset: e,
|
|
141
|
+
localeId: this.localeId,
|
|
142
|
+
monthFormat: this.monthFormat,
|
|
143
|
+
yearSelectorOpen: this._nav.yearSelectorOpen,
|
|
144
|
+
onToggleYearSelector: () => this.toggleYearSelector(),
|
|
145
|
+
renderBelowHeader: (t) => this.renderBelowHeader(t),
|
|
146
|
+
renderPanelBody: (t) => this.renderPanelBody(t)
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/** Hook rendered between the header and the panel body. Default: nothing. */
|
|
151
|
+
renderBelowHeader(e) {
|
|
152
|
+
return p;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The panel content below the header: the year grid replaces the days grid
|
|
156
|
+
* of the first panel while the year selector is open. Subclasses can swap
|
|
157
|
+
* in other bodies (e.g. the date-time calendar's time grid).
|
|
158
|
+
*/
|
|
159
|
+
renderPanelBody(e) {
|
|
160
|
+
return M({
|
|
161
|
+
offset: e,
|
|
162
|
+
yearSelectorOpen: this._nav.yearSelectorOpen,
|
|
163
|
+
years: this._nav.yearList,
|
|
164
|
+
currentYear: this._nav.currentDate.getFullYear(),
|
|
165
|
+
onSelectYear: (t) => this._keyboard.selectYear(t),
|
|
166
|
+
onYearKeydown: this._keyboard.handleYearKeydown,
|
|
167
|
+
localeId: this.localeId,
|
|
168
|
+
getDays: (t) => this.getDaysInMonth(t),
|
|
169
|
+
renderDay: (t) => this.renderDay(t)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Kept as a thin override point — the range date-time subclass closes its
|
|
174
|
+
* time pickers before delegating to the nav controller.
|
|
175
|
+
*/
|
|
176
|
+
toggleYearSelector() {
|
|
177
|
+
this._nav.toggleYearSelector();
|
|
178
|
+
}
|
|
179
|
+
isDisabled(e) {
|
|
180
|
+
return this._nav.isDisabled(e);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Rebuilds the day context for an Enter/Space activation from the button's
|
|
184
|
+
* `data-date`. Legitimate because a day button can only be focused when it
|
|
185
|
+
* is enabled and in-month; the `disabled`/`readOnly` guards stay in
|
|
186
|
+
* `selectDate`.
|
|
187
|
+
*/
|
|
188
|
+
activationDay(e) {
|
|
189
|
+
return {
|
|
190
|
+
date: h(e),
|
|
191
|
+
isCurrentMonth: !0,
|
|
192
|
+
isDisabled: !1,
|
|
193
|
+
isFocusable: !0,
|
|
194
|
+
dayLabel: "",
|
|
195
|
+
isToday: !1,
|
|
196
|
+
isRangeStart: !1,
|
|
197
|
+
isRangeEnd: !1,
|
|
198
|
+
isInRange: !1,
|
|
199
|
+
isOneDayRange: !1,
|
|
200
|
+
isAnchor: !1,
|
|
201
|
+
isSelecting: !1,
|
|
202
|
+
isInvalidStart: !1,
|
|
203
|
+
isInvalidEnd: !1,
|
|
204
|
+
isInvalidInRange: !1
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
renderDay(e) {
|
|
208
|
+
const t = e.isInvalidStart && e.isInvalidEnd, o = {
|
|
209
|
+
"gui-calendar__day-button": !0,
|
|
210
|
+
today: e.isToday,
|
|
211
|
+
"other-month": !e.isCurrentMonth,
|
|
212
|
+
"range-start": e.isRangeStart && !e.isOneDayRange,
|
|
213
|
+
"range-end": e.isRangeEnd && !e.isOneDayRange,
|
|
214
|
+
selected: e.isOneDayRange,
|
|
215
|
+
"in-range": e.isInRange,
|
|
216
|
+
"invalid-range-start": e.isInvalidStart && !t,
|
|
217
|
+
"invalid-range-end": e.isInvalidEnd && !t,
|
|
218
|
+
"invalid-range-single": t,
|
|
219
|
+
"invalid-in-range": e.isInvalidInRange,
|
|
220
|
+
"is-anchor": e.isAnchor,
|
|
221
|
+
"is-selecting": e.isSelecting,
|
|
222
|
+
disabled: e.isDisabled
|
|
223
|
+
};
|
|
224
|
+
return c`
|
|
225
|
+
<button
|
|
226
|
+
type="button"
|
|
227
|
+
role="gridcell"
|
|
228
|
+
class=${m(o)}
|
|
229
|
+
tabindex=${e.isFocusable ? 0 : -1}
|
|
230
|
+
?disabled=${!e.isCurrentMonth || e.isDisabled}
|
|
231
|
+
data-date=${l(e.date)}
|
|
232
|
+
@click=${(a) => this.selectDate(e, a)}
|
|
233
|
+
@mouseover=${() => this.onMouseOver(e)}
|
|
234
|
+
@focus=${() => this.onMouseOver(e)}
|
|
235
|
+
@keydown=${(a) => this._keyboard.handleDayKeydown(a)}
|
|
236
|
+
aria-selected=${e.isRangeStart || e.isRangeEnd || e.isInRange ? "true" : "false"}
|
|
237
|
+
>
|
|
238
|
+
${this.renderDayContent(e)}
|
|
239
|
+
</button>
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
getDaysInMonth(e) {
|
|
243
|
+
const t = (this.value ?? []).map((a) => ({
|
|
244
|
+
start: this.endpointDay(a.start),
|
|
245
|
+
end: a.end ? this.endpointDay(a.end) : void 0
|
|
246
|
+
})), o = F(this._selection);
|
|
247
|
+
return I({
|
|
248
|
+
currentDate: this._currentDate,
|
|
249
|
+
offset: e,
|
|
250
|
+
localeId: this.localeId,
|
|
251
|
+
numberOfMonths: this.numberOfMonths ?? 1,
|
|
252
|
+
isDisabled: (a) => this.isDisabled(a),
|
|
253
|
+
toDay: (a) => {
|
|
254
|
+
const r = C(a.date, {
|
|
255
|
+
ranges: t,
|
|
256
|
+
anchor: this._selection.anchor,
|
|
257
|
+
selectingSpan: o,
|
|
258
|
+
invalidRange: this._invalidRange
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
date: a.date,
|
|
262
|
+
dayLabel: a.dayLabel,
|
|
263
|
+
isCurrentMonth: a.isCurrentMonth,
|
|
264
|
+
isToday: a.isToday,
|
|
265
|
+
isRangeStart: r.isRangeStart,
|
|
266
|
+
isRangeEnd: r.isRangeEnd,
|
|
267
|
+
isInRange: r.isInRange,
|
|
268
|
+
isInvalidStart: r.isInvalidStart && a.isCurrentMonth,
|
|
269
|
+
isInvalidEnd: r.isInvalidEnd && a.isCurrentMonth,
|
|
270
|
+
isInvalidInRange: r.isInvalidInRange && a.isCurrentMonth,
|
|
271
|
+
isDisabled: a.isDisabled,
|
|
272
|
+
isOneDayRange: r.isOneDayRange,
|
|
273
|
+
isAnchor: r.isAnchor,
|
|
274
|
+
isFocusable: a.isToday || r.isRangeStart,
|
|
275
|
+
isSelecting: r.isSelecting && a.isCurrentMonth
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
focusFallbackDates: [
|
|
279
|
+
/* @__PURE__ */ new Date(),
|
|
280
|
+
...(this.value ?? []).map((a) => this.endpointDay(a.start))
|
|
281
|
+
]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
selectDate(e, t = null) {
|
|
285
|
+
if (!e.isCurrentMonth || this.disabled || this.readOnly) return;
|
|
286
|
+
const { state: o, commit: a } = g(this._selection, {
|
|
287
|
+
type: "pick",
|
|
288
|
+
date: e.date
|
|
289
|
+
});
|
|
290
|
+
if (this._selection = o, !a) {
|
|
291
|
+
this._invalidRange = null;
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (E(
|
|
295
|
+
l(a.start),
|
|
296
|
+
l(a.end),
|
|
297
|
+
this.disabledRanges,
|
|
298
|
+
this.minDate,
|
|
299
|
+
this.maxDate
|
|
300
|
+
)) {
|
|
301
|
+
this._invalidRange = { start: a.start, end: a.end }, this.dispatchEvent(
|
|
302
|
+
new CustomEvent("inputError", {
|
|
303
|
+
detail: {
|
|
304
|
+
message: this.disabledDateRangeMessage ?? A,
|
|
305
|
+
range: { start: l(a.start), end: l(a.end) }
|
|
306
|
+
},
|
|
307
|
+
bubbles: !0,
|
|
308
|
+
composed: !0
|
|
309
|
+
})
|
|
310
|
+
), this.requestUpdate();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
this._invalidRange = null, this._skipValueNavigation = !0, this.value = P([
|
|
314
|
+
...this.value || [],
|
|
315
|
+
L(a.start, a.end)
|
|
316
|
+
]), this.dispatchEvent(
|
|
317
|
+
new CustomEvent("change", {
|
|
318
|
+
detail: { value: this.value },
|
|
319
|
+
bubbles: !0,
|
|
320
|
+
composed: !0
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
onMouseOver(e) {
|
|
325
|
+
this._selection = g(this._selection, {
|
|
326
|
+
type: "hover",
|
|
327
|
+
date: e.date
|
|
328
|
+
}).state;
|
|
329
|
+
}
|
|
330
|
+
// --- Pills ---
|
|
331
|
+
renderAboveCalendar() {
|
|
332
|
+
if (this.hidePills) return p;
|
|
333
|
+
const e = this.getSortedPills();
|
|
334
|
+
if (e.length === 0) return p;
|
|
335
|
+
const t = G(
|
|
336
|
+
e,
|
|
337
|
+
(o) => this.formatPillLabel(o),
|
|
338
|
+
this.removePillAriaLabel ?? "Remove date"
|
|
339
|
+
);
|
|
340
|
+
return c`
|
|
341
|
+
<gui-pills
|
|
342
|
+
class="gui-range-calendar__pills"
|
|
343
|
+
.items=${t}
|
|
344
|
+
.removable=${!0}
|
|
345
|
+
.clickable=${!0}
|
|
346
|
+
.bubble=${!1}
|
|
347
|
+
?disabled=${this.disabled}
|
|
348
|
+
?readonly=${this.readOnly}
|
|
349
|
+
.removeAriaLabel=${this.removePillAriaLabel ?? "Remove date"}
|
|
350
|
+
@pillremove=${this.onPillRemoveEvent}
|
|
351
|
+
@pillclick=${this.onPillClickEvent}
|
|
352
|
+
></gui-pills>
|
|
353
|
+
`;
|
|
354
|
+
}
|
|
355
|
+
getSortedPills() {
|
|
356
|
+
return N(
|
|
357
|
+
this.value,
|
|
358
|
+
(e, t) => this.parseEndpoint(e).getTime() - this.parseEndpoint(t).getTime()
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
navigateToDate(e) {
|
|
362
|
+
this._nav.navigateToDate(this.endpointDay(e));
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
n([
|
|
366
|
+
s({ type: String })
|
|
367
|
+
], i.prototype, "uid", 2);
|
|
368
|
+
n([
|
|
369
|
+
s({ type: String })
|
|
370
|
+
], i.prototype, "label", 2);
|
|
371
|
+
n([
|
|
372
|
+
s({ type: String })
|
|
373
|
+
], i.prototype, "hint", 2);
|
|
374
|
+
n([
|
|
375
|
+
s({ type: String, attribute: "locale-id" })
|
|
376
|
+
], i.prototype, "localeId", 2);
|
|
377
|
+
n([
|
|
378
|
+
s({ type: Array })
|
|
379
|
+
], i.prototype, "errors", 2);
|
|
380
|
+
n([
|
|
381
|
+
s({ type: Boolean })
|
|
382
|
+
], i.prototype, "touched", 2);
|
|
383
|
+
n([
|
|
384
|
+
s({ type: Boolean })
|
|
385
|
+
], i.prototype, "required", 2);
|
|
386
|
+
n([
|
|
387
|
+
s({ type: Boolean })
|
|
388
|
+
], i.prototype, "disabled", 2);
|
|
389
|
+
n([
|
|
390
|
+
s({ type: Boolean, attribute: "readonly" })
|
|
391
|
+
], i.prototype, "readOnly", 2);
|
|
392
|
+
n([
|
|
393
|
+
s({ type: String, attribute: "prev-month-icon" })
|
|
394
|
+
], i.prototype, "prevMonthIcon", 2);
|
|
395
|
+
n([
|
|
396
|
+
s({ type: String, attribute: "next-month-icon" })
|
|
397
|
+
], i.prototype, "nextMonthIcon", 2);
|
|
398
|
+
n([
|
|
399
|
+
s({ type: String, attribute: "prev-month-aria-label" })
|
|
400
|
+
], i.prototype, "prevMonthAriaLabel", 2);
|
|
401
|
+
n([
|
|
402
|
+
s({ type: String, attribute: "next-month-aria-label" })
|
|
403
|
+
], i.prototype, "nextMonthAriaLabel", 2);
|
|
404
|
+
n([
|
|
405
|
+
s({ type: String })
|
|
406
|
+
], i.prototype, "dayFormat", 2);
|
|
407
|
+
n([
|
|
408
|
+
s({ type: String })
|
|
409
|
+
], i.prototype, "weekdayFormat", 2);
|
|
410
|
+
n([
|
|
411
|
+
s({ type: String })
|
|
412
|
+
], i.prototype, "monthFormat", 2);
|
|
413
|
+
n([
|
|
414
|
+
s({ type: String })
|
|
415
|
+
], i.prototype, "minDate", 2);
|
|
416
|
+
n([
|
|
417
|
+
s({ type: String })
|
|
418
|
+
], i.prototype, "maxDate", 2);
|
|
419
|
+
n([
|
|
420
|
+
s({ type: Array })
|
|
421
|
+
], i.prototype, "disabledRanges", 2);
|
|
422
|
+
n([
|
|
423
|
+
s({ type: Number })
|
|
424
|
+
], i.prototype, "numberOfMonths", 2);
|
|
425
|
+
n([
|
|
426
|
+
s({ type: Array })
|
|
427
|
+
], i.prototype, "value", 2);
|
|
428
|
+
n([
|
|
429
|
+
s({ type: String })
|
|
430
|
+
], i.prototype, "focusDate", 2);
|
|
431
|
+
n([
|
|
432
|
+
s({ type: Boolean })
|
|
433
|
+
], i.prototype, "hidePills", 2);
|
|
434
|
+
n([
|
|
435
|
+
s({ type: String })
|
|
436
|
+
], i.prototype, "removePillAriaLabel", 2);
|
|
437
|
+
n([
|
|
438
|
+
s({ type: String, attribute: "disabled-date-range-message" })
|
|
439
|
+
], i.prototype, "disabledDateRangeMessage", 2);
|
|
440
|
+
n([
|
|
441
|
+
s({ attribute: !1 })
|
|
442
|
+
], i.prototype, "invalidRange", 2);
|
|
443
|
+
n([
|
|
444
|
+
v()
|
|
445
|
+
], i.prototype, "_selection", 2);
|
|
446
|
+
n([
|
|
447
|
+
v()
|
|
448
|
+
], i.prototype, "_invalidRange", 2);
|
|
449
|
+
i = n([
|
|
450
|
+
b("gui-range-calendar")
|
|
451
|
+
], i);
|
|
452
|
+
typeof customElements < "u" && !customElements.get("gui-range-calendar") && customElements.define("gui-range-calendar", i);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { InputWidgetAdapter as d, formContext as o, inputContext as h } from "@golemui/lit";
|
|
2
|
-
import "./range-calendar-
|
|
2
|
+
import "./range-calendar-CKPYeSGt.js";
|
|
3
3
|
import { consume as m, provide as u } from "@lit/context";
|
|
4
|
-
import { LitElement as c, html as
|
|
5
|
-
import { property as
|
|
4
|
+
import { LitElement as c, html as D } from "lit";
|
|
5
|
+
import { property as b, customElement as $ } from "lit/decorators.js";
|
|
6
6
|
import "rxjs";
|
|
7
|
-
var g = Object.defineProperty, f = Object.getOwnPropertyDescriptor,
|
|
8
|
-
for (var a = r > 1 ? void 0 : r ? f(
|
|
9
|
-
(
|
|
10
|
-
return r && a && g(
|
|
7
|
+
var g = Object.defineProperty, f = Object.getOwnPropertyDescriptor, l = (t, e, s, r) => {
|
|
8
|
+
for (var a = r > 1 ? void 0 : r ? f(e, s) : e, p = t.length - 1, n; p >= 0; p--)
|
|
9
|
+
(n = t[p]) && (a = (r ? n(e, s, a) : n(a)) || a);
|
|
10
|
+
return r && a && g(e, s, a), a;
|
|
11
11
|
};
|
|
12
12
|
let i = class extends c {
|
|
13
13
|
constructor() {
|
|
@@ -16,10 +16,10 @@ let i = class extends c {
|
|
|
16
16
|
createRenderRoot() {
|
|
17
17
|
return this;
|
|
18
18
|
}
|
|
19
|
-
updated(
|
|
20
|
-
super.updated(
|
|
21
|
-
const
|
|
22
|
-
|
|
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
23
|
}
|
|
24
24
|
connectedCallback() {
|
|
25
25
|
super.connectedCallback(), this.classList.add("gui-calendar", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
@@ -27,7 +27,7 @@ let i = class extends c {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
render() {
|
|
30
|
-
return super.render(),
|
|
30
|
+
return super.render(), D`
|
|
31
31
|
<gui-range-calendar
|
|
32
32
|
.uid=${this.widget.uid}
|
|
33
33
|
.label=${this.adapter.templateData.label}
|
|
@@ -48,31 +48,35 @@ let i = class extends c {
|
|
|
48
48
|
.minDate=${this.adapter.templateData.minDate}
|
|
49
49
|
.maxDate=${this.adapter.templateData.maxDate}
|
|
50
50
|
.disabledRanges=${this.adapter.templateData.disabledRanges}
|
|
51
|
+
.disabledDateRangeMessage=${this.adapter.templateData.disabledDateRangeMessage}
|
|
51
52
|
.numberOfMonths=${this.adapter.templateData.numberOfMonths}
|
|
52
53
|
.hidePills=${!1}
|
|
53
54
|
.removePillAriaLabel=${this.adapter.templateData.removePillAriaLabel}
|
|
54
55
|
.localeId=${this.adapter.templateData.lang}
|
|
55
56
|
@change=${this.valueChanged}
|
|
57
|
+
@inputError=${this.onInputError}
|
|
56
58
|
@blur=${() => this.adapter.onBlur()}
|
|
57
59
|
></gui-range-calendar>
|
|
58
60
|
`;
|
|
59
61
|
}
|
|
60
|
-
valueChanged(
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
valueChanged(t) {
|
|
63
|
+
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(t.detail.value);
|
|
64
|
+
}
|
|
65
|
+
onInputError(t) {
|
|
66
|
+
this.adapter.injectValidationIssues([t.detail.message]), this.adapter.onBlur();
|
|
63
67
|
}
|
|
64
68
|
disconnectedCallback() {
|
|
65
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((
|
|
69
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
66
70
|
}
|
|
67
71
|
};
|
|
68
|
-
|
|
72
|
+
l([
|
|
69
73
|
m({ context: o }),
|
|
70
|
-
|
|
74
|
+
b({ attribute: !1 })
|
|
71
75
|
], i.prototype, "formContext", 2);
|
|
72
|
-
|
|
76
|
+
l([
|
|
73
77
|
u({ context: h })
|
|
74
78
|
], i.prototype, "adapter", 2);
|
|
75
|
-
i =
|
|
79
|
+
i = l([
|
|
76
80
|
$("gui-range-calendar-input")
|
|
77
81
|
], i);
|
|
78
82
|
export {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function u(e, i, r) {
|
|
2
|
+
return r(i, e) < 0 ? { start: i, end: e } : { start: e, end: i };
|
|
3
|
+
}
|
|
4
|
+
function v(e, i, r, n) {
|
|
5
|
+
if (e.kind === "invalid") return { kind: "invalid", message: e.message };
|
|
6
|
+
if (i.kind === "invalid") return { kind: "invalid", message: i.message };
|
|
7
|
+
if (e.kind !== "valid" || i.kind !== "valid") return { kind: "incomplete" };
|
|
8
|
+
const d = n.order ? n.order(e.value, i.value) : { start: e.value, end: i.value }, a = n.validate?.(d) ?? null;
|
|
9
|
+
return a !== null ? { kind: "invalid", message: a } : { kind: "commit", value: n.merge([...r ?? [], n.toRange(d)]) };
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
v as c,
|
|
13
|
+
u as o
|
|
14
|
+
};
|