@golemui/gui-lit 1.0.3 → 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 +11 -0
- package/calendar-BuJgwvZx.js +254 -0
- package/{calendar.element-DcnTyvfg.js → calendar.element-M5MPJmap.js} +1 -1
- package/{currency.element-5GSakkxF.js → currency.element-CfFrAtrr.js} +4 -1
- package/{date-CDUlLuYy.js → date-Bj9mI3GU.js} +80 -29
- 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-BZO0UQez.js → date.element-Consgsbb.js} +32 -27
- package/day-status-0-hJHrI7.js +530 -0
- package/{dropdown.element-CyJbVAA5.js → dropdown.element-WsD61Qel.js} +46 -36
- package/focus-leave.controller-2gV0pQd5.js +73 -0
- package/index.js +1199 -971
- package/index.umd.cjs +1582 -530
- 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/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-_1bHW_c1.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-BqzAF0O3.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-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/range-calendar-CBINu84w.js +0 -255
- package/range-date-input-BYXzqnr1.js +0 -395
- package/range-date-picker.element-BCBefgvY.js +0 -182
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { LitElement as v, nothing as p, html as u } from "lit";
|
|
2
|
+
import { property as s, customElement as m } from "lit/decorators.js";
|
|
3
|
+
import { classMap as y } from "lit/directives/class-map.js";
|
|
4
|
+
import { G as b, b as f, c as D } from "./templates-Dk1jxLwS.js";
|
|
5
|
+
import { n as _, G as P, r as h, q as E } from "./part-templates-Db871PS3.js";
|
|
6
|
+
import { g as S, p as c, m as C, t as g } from "./date-Bj9mI3GU.js";
|
|
7
|
+
import { r as $, f as k, b as I, a as R, c as w, s as A } from "./pill-ranges-DCqDmpkk.js";
|
|
8
|
+
import { c as O, o as L } from "./range-commit-8-MmYUyo.js";
|
|
9
|
+
import "./pills-Be1UrLgq.js";
|
|
10
|
+
import { styleMap as B } from "lit-html/directives/style-map.js";
|
|
11
|
+
var G = Object.defineProperty, q = Object.getOwnPropertyDescriptor, r = (t, e, a, n) => {
|
|
12
|
+
for (var l = n > 1 ? void 0 : n ? q(e, a) : e, o = t.length - 1, d; o >= 0; o--)
|
|
13
|
+
(d = t[o]) && (l = (n ? d(e, a, l) : d(l)) || l);
|
|
14
|
+
return n && l && G(e, a, l), l;
|
|
15
|
+
};
|
|
16
|
+
let i = class extends v {
|
|
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.value = [], this.invalidDateMessage = void 0, this.removePillAriaLabel = void 0, this.startDateAriaLabel = void 0, this.endDateAriaLabel = void 0, this.separator = void 0, this.inputBlockClass = "gui-range-date-input", this.groups = ["start", "end"], this.partDescriptors = _(), this._validationTriggered = !1, this._parts = new P(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
|
+
if (this.tryCreatePill(), this.value && this.value.length > 0) {
|
|
31
|
+
const t = this.value[this.value.length - 1];
|
|
32
|
+
this.onPillClick(t);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
onInputErrorSurfaced: (t) => this.dispatchEvent(new CustomEvent("inputError", { detail: { message: t }, bubbles: !0 })),
|
|
36
|
+
onSurfacedErrorCleared: (t) => this.dispatchEvent(
|
|
37
|
+
new CustomEvent("change", { detail: { value: t }, bubbles: !0, composed: !0 })
|
|
38
|
+
)
|
|
39
|
+
}), this.ariaController = new b(this, {
|
|
40
|
+
getTargets: () => this.querySelectorAll(`.${this.inputBlockClass}`),
|
|
41
|
+
getState: () => ({
|
|
42
|
+
uid: this.uid,
|
|
43
|
+
templateData: {
|
|
44
|
+
hint: this.hint,
|
|
45
|
+
errors: this.errors,
|
|
46
|
+
readonly: this.readOnly,
|
|
47
|
+
disabled: this.disabled,
|
|
48
|
+
touched: this.touched
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}), this.onPillRemoveEvent = (t) => {
|
|
52
|
+
if (this.disabled || this.readOnly) return;
|
|
53
|
+
const e = $(this.value, t.detail.key);
|
|
54
|
+
e && (this.value = e.next, this.dispatchEvent(
|
|
55
|
+
new CustomEvent("change", {
|
|
56
|
+
detail: { value: this.value },
|
|
57
|
+
bubbles: !0,
|
|
58
|
+
composed: !0
|
|
59
|
+
})
|
|
60
|
+
), e.next.length === 0 && requestAnimationFrame(() => {
|
|
61
|
+
this.querySelector(
|
|
62
|
+
".gui-range-date-input__field input"
|
|
63
|
+
)?.focus();
|
|
64
|
+
}));
|
|
65
|
+
}, this.onPillClickEvent = (t) => {
|
|
66
|
+
const e = k(this.getSortedPills(), t.detail.key);
|
|
67
|
+
e && this.onPillClick(e);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
createRenderRoot() {
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
connectedCallback() {
|
|
74
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
75
|
+
}
|
|
76
|
+
getPartDescriptor(t) {
|
|
77
|
+
return this.partDescriptors[t];
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
const t = {
|
|
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
|
+
}, e = {
|
|
91
|
+
blockClass: this.inputBlockClass,
|
|
92
|
+
groups: this.groups,
|
|
93
|
+
formatParts: S(this.localeId),
|
|
94
|
+
getDescriptor: (l) => this.getPartDescriptor(l),
|
|
95
|
+
getDisplayValue: this._parts.getPartDisplay,
|
|
96
|
+
required: this.required,
|
|
97
|
+
disabled: this.disabled,
|
|
98
|
+
partsReadonly: !!this.readOnly
|
|
99
|
+
}, a = I(
|
|
100
|
+
this.getSortedPills(),
|
|
101
|
+
(l) => R(l, (o) => w(o, this.localeId)),
|
|
102
|
+
this.removePillAriaLabel ?? "Remove date"
|
|
103
|
+
), n = {
|
|
104
|
+
"gui-widget-icon": !0,
|
|
105
|
+
[this.icon]: !!this.icon
|
|
106
|
+
};
|
|
107
|
+
return u`
|
|
108
|
+
${this.label ? f(this.uid, t, !1, void 0, !1) : p}
|
|
109
|
+
|
|
110
|
+
<div class="gui-widget">
|
|
111
|
+
<div
|
|
112
|
+
class="gui-widget-input gui-parts-ring gui-range-date-input ${this.icon ? "gui-range-date-input--icon" : ""}"
|
|
113
|
+
role="group"
|
|
114
|
+
aria-label=${this.label ?? "Date range input"}
|
|
115
|
+
>
|
|
116
|
+
${this.icon ? u`<span class=${y(n)} data-icon=${this.icon}></span>` : p}
|
|
117
|
+
|
|
118
|
+
<gui-pills
|
|
119
|
+
class="gui-range-date-input__pills"
|
|
120
|
+
style=${B(a.length ? {} : { "min-width": 0 })}
|
|
121
|
+
.items=${a}
|
|
122
|
+
.removable=${!0}
|
|
123
|
+
.clickable=${!0}
|
|
124
|
+
.bubble=${!0}
|
|
125
|
+
?disabled=${this.disabled}
|
|
126
|
+
?readonly=${this.readOnly}
|
|
127
|
+
.removeAriaLabel=${this.removePillAriaLabel ?? "Remove date"}
|
|
128
|
+
.compactAriaLabel=${`${a.length} date ranges`}
|
|
129
|
+
@pillremove=${this.onPillRemoveEvent}
|
|
130
|
+
@pillclick=${this.onPillClickEvent}
|
|
131
|
+
></gui-pills>
|
|
132
|
+
|
|
133
|
+
<div class="gui-range-date-input__inputs">
|
|
134
|
+
<div
|
|
135
|
+
class="gui-parts gui-range-date-input__field"
|
|
136
|
+
role="group"
|
|
137
|
+
aria-label=${this.startDateAriaLabel ?? "Start date"}
|
|
138
|
+
>
|
|
139
|
+
${h("start", e, this._parts)}
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<span class="gui-range-date-input__separator">${this.separator ?? "-"}</span>
|
|
143
|
+
|
|
144
|
+
<div
|
|
145
|
+
class="gui-parts gui-range-date-input__field"
|
|
146
|
+
role="group"
|
|
147
|
+
aria-label=${this.endDateAriaLabel ?? "End date"}
|
|
148
|
+
>
|
|
149
|
+
${h("end", e, this._parts)}
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
${this.showErrors && this.errors?.length ? D(this.uid, t) : p}
|
|
155
|
+
</div>
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
getSortedPills() {
|
|
159
|
+
return A(
|
|
160
|
+
this.value,
|
|
161
|
+
(t, e) => c(t).getTime() - c(e).getTime()
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
onPillClick(t) {
|
|
165
|
+
this.dispatchEvent(
|
|
166
|
+
new CustomEvent("pillClick", {
|
|
167
|
+
detail: { range: t },
|
|
168
|
+
bubbles: !0,
|
|
169
|
+
composed: !0
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
validateDateParts(t) {
|
|
174
|
+
const { result: e, writeBacks: a } = E(this._parts.values[t] ?? {}, {
|
|
175
|
+
descriptors: this.partDescriptors,
|
|
176
|
+
invalidDateMessage: this.invalidDateMessage
|
|
177
|
+
});
|
|
178
|
+
return this._parts.applyWriteBacks(t, a), e.kind === "invalid" ? { kind: "invalid", message: e.message } : e.kind === "valid" && e.instant ? { kind: "valid", value: e.instant } : { kind: "incomplete" };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Re-parses both endpoints so per-endpoint problems (impossible date, out of
|
|
182
|
+
* bounds) surface while the user types. Runs on every part change.
|
|
183
|
+
*/
|
|
184
|
+
syncParts() {
|
|
185
|
+
return {
|
|
186
|
+
start: this.validateDateParts("start"),
|
|
187
|
+
end: this.validateDateParts("end")
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Parses the range and updates the error state, without ever committing.
|
|
192
|
+
* Shared by the Enter commit and by {@link revalidate}.
|
|
193
|
+
*/
|
|
194
|
+
evaluateRange() {
|
|
195
|
+
const { start: t, end: e } = this.syncParts(), a = O(t, e, this.value, {
|
|
196
|
+
// Swap if end < start
|
|
197
|
+
order: (n, l) => L(n, l, (o, d) => o.getTime() - d.getTime()),
|
|
198
|
+
toRange: ({ start: n, end: l }) => {
|
|
199
|
+
const o = g(n), d = g(l);
|
|
200
|
+
return o === d ? { start: o } : { start: o, end: d };
|
|
201
|
+
},
|
|
202
|
+
merge: C
|
|
203
|
+
});
|
|
204
|
+
return a.kind === "invalid" && this._parts.surfaceInputError(a.message), a.kind === "incomplete" && this._parts.clearSurfacedInputError(this.value ?? []), a;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Once the user has attempted a commit, every later edit re-runs validation
|
|
208
|
+
* so a corrected range clears its error immediately, otherwise the message
|
|
209
|
+
* would linger until the next Enter and the user could not tell the problem
|
|
210
|
+
* was solved.
|
|
211
|
+
*/
|
|
212
|
+
revalidate() {
|
|
213
|
+
this.evaluateRange().kind === "commit" && this._parts.clearSurfacedInputError(this.value ?? []);
|
|
214
|
+
}
|
|
215
|
+
tryCreatePill() {
|
|
216
|
+
this._validationTriggered = !0;
|
|
217
|
+
const t = this.evaluateRange();
|
|
218
|
+
t.kind === "commit" && (this.value = t.value, this._validationTriggered = !1, this._parts.clearGroup("start"), this._parts.clearGroup("end"), this._parts.resetSurfacedInputError(), this.dispatchEvent(
|
|
219
|
+
new CustomEvent("change", {
|
|
220
|
+
detail: { value: this.value },
|
|
221
|
+
bubbles: !0,
|
|
222
|
+
composed: !0
|
|
223
|
+
})
|
|
224
|
+
), this._parts.focusFirst("start"), this.requestUpdate());
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Echo a range into the input parts without committing it (no pill, no change
|
|
228
|
+
* event). Used by the picker to show a range the calendar rejected.
|
|
229
|
+
*/
|
|
230
|
+
showRange(t, e) {
|
|
231
|
+
this._parts.setGroupFromISO("start", t, "date"), this._parts.setGroupFromISO("end", e, "date");
|
|
232
|
+
}
|
|
233
|
+
/** Clear both groups' parts (e.g. once a valid range is committed). */
|
|
234
|
+
clearRangeInputs() {
|
|
235
|
+
this._parts.clearGroup("start"), this._parts.clearGroup("end");
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
r([
|
|
239
|
+
s({ type: String })
|
|
240
|
+
], i.prototype, "uid", 2);
|
|
241
|
+
r([
|
|
242
|
+
s({ type: String })
|
|
243
|
+
], i.prototype, "label", 2);
|
|
244
|
+
r([
|
|
245
|
+
s({ type: String, attribute: "locale-id" })
|
|
246
|
+
], i.prototype, "localeId", 2);
|
|
247
|
+
r([
|
|
248
|
+
s({ type: Array })
|
|
249
|
+
], i.prototype, "errors", 2);
|
|
250
|
+
r([
|
|
251
|
+
s({ type: Boolean })
|
|
252
|
+
], i.prototype, "showErrors", 2);
|
|
253
|
+
r([
|
|
254
|
+
s({ type: Boolean })
|
|
255
|
+
], i.prototype, "touched", 2);
|
|
256
|
+
r([
|
|
257
|
+
s({ type: Boolean })
|
|
258
|
+
], i.prototype, "required", 2);
|
|
259
|
+
r([
|
|
260
|
+
s({ type: Boolean })
|
|
261
|
+
], i.prototype, "disabled", 2);
|
|
262
|
+
r([
|
|
263
|
+
s({ type: Boolean, attribute: "readonly" })
|
|
264
|
+
], i.prototype, "readOnly", 2);
|
|
265
|
+
r([
|
|
266
|
+
s({ type: String })
|
|
267
|
+
], i.prototype, "icon", 2);
|
|
268
|
+
r([
|
|
269
|
+
s({ type: String })
|
|
270
|
+
], i.prototype, "hint", 2);
|
|
271
|
+
r([
|
|
272
|
+
s({ type: Array })
|
|
273
|
+
], i.prototype, "value", 2);
|
|
274
|
+
r([
|
|
275
|
+
s({ type: String, attribute: "invalid-date-message" })
|
|
276
|
+
], i.prototype, "invalidDateMessage", 2);
|
|
277
|
+
r([
|
|
278
|
+
s({ type: String })
|
|
279
|
+
], i.prototype, "removePillAriaLabel", 2);
|
|
280
|
+
r([
|
|
281
|
+
s({ type: String })
|
|
282
|
+
], i.prototype, "startDateAriaLabel", 2);
|
|
283
|
+
r([
|
|
284
|
+
s({ type: String })
|
|
285
|
+
], i.prototype, "endDateAriaLabel", 2);
|
|
286
|
+
r([
|
|
287
|
+
s({ type: String })
|
|
288
|
+
], i.prototype, "separator", 2);
|
|
289
|
+
i = r([
|
|
290
|
+
m("gui-range-date")
|
|
291
|
+
], i);
|
|
292
|
+
typeof customElements < "u" && !customElements.get("gui-range-date") && customElements.define("gui-range-date", i);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { InputWidgetAdapter as n, formContext as o, inputContext as u } from "@golemui/lit";
|
|
2
|
-
import "./range-date-input-
|
|
2
|
+
import "./range-date-input-D--AqBMv.js";
|
|
3
3
|
import { consume as h, provide as m } 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 g } from "lit/decorators.js";
|
|
6
6
|
import "rxjs";
|
|
7
|
-
var
|
|
7
|
+
var v = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, d = (t, e, s, r) => {
|
|
8
8
|
for (var a = r > 1 ? void 0 : r ? $(e, s) : e, p = t.length - 1, l; p >= 0; p--)
|
|
9
9
|
(l = t[p]) && (a = (r ? l(e, s, a) : l(a)) || a);
|
|
10
|
-
return r && a &&
|
|
10
|
+
return r && a && v(e, s, a), a;
|
|
11
11
|
};
|
|
12
12
|
let i = class extends c {
|
|
13
13
|
constructor() {
|
|
@@ -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-date
|
|
32
32
|
.uid=${this.widget.uid}
|
|
33
33
|
.label=${this.adapter.templateData.label}
|
|
@@ -40,6 +40,7 @@ let i = class extends c {
|
|
|
40
40
|
?readonly=${this.adapter.templateData.readonly}
|
|
41
41
|
.value=${this.adapter.templateData.value}
|
|
42
42
|
.localeId=${this.adapter.templateData.lang}
|
|
43
|
+
.invalidDateMessage=${this.adapter.templateData.invalidDateMessage}
|
|
43
44
|
.separator=${this.adapter.templateData.separator}
|
|
44
45
|
.removePillAriaLabel=${this.adapter.templateData.removePillAriaLabel}
|
|
45
46
|
.startDateAriaLabel=${this.adapter.templateData.startDateAriaLabel}
|
|
@@ -61,7 +62,7 @@ let i = class extends c {
|
|
|
61
62
|
};
|
|
62
63
|
d([
|
|
63
64
|
h({ context: o }),
|
|
64
|
-
|
|
65
|
+
b({ attribute: !1 })
|
|
65
66
|
], i.prototype, "formContext", 2);
|
|
66
67
|
d([
|
|
67
68
|
m({ context: u })
|