@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.
Files changed (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/calendar-BuJgwvZx.js +254 -0
  3. package/{calendar.element-MubSE1bx.js → calendar.element-M5MPJmap.js} +1 -1
  4. package/{currency.element-BHXWcOEu.js → currency.element-CfFrAtrr.js} +20 -14
  5. package/{date-DTYg8sog.js → date-Bj9mI3GU.js} +106 -50
  6. package/date-input-cJDkNnVw.js +184 -0
  7. package/date-picker.element-va_-LGZD.js +312 -0
  8. package/date-time-calendar-BzRfkLKU.js +361 -0
  9. package/date-time-calendar.element-DC4NK0y1.js +93 -0
  10. package/date-time-input-BXxsfuyZ.js +214 -0
  11. package/date-time-picker.element-Dy-8cb-_.js +380 -0
  12. package/date-time.element-Bv4XdzMi.js +87 -0
  13. package/{date.element-BtVJSIRk.js → date.element-Consgsbb.js} +32 -27
  14. package/day-status-0-hJHrI7.js +530 -0
  15. package/{dropdown.element-DqzC6aXR.js → dropdown.element-WsD61Qel.js} +57 -48
  16. package/focus-leave.controller-2gV0pQd5.js +73 -0
  17. package/index.js +1209 -981
  18. package/index.umd.cjs +1574 -519
  19. package/lib/components/date-picker.element.d.ts +0 -11
  20. package/lib/components/date-time-calendar.element.d.ts +18 -0
  21. package/lib/components/date-time-picker.element.d.ts +18 -0
  22. package/lib/components/date-time.element.d.ts +18 -0
  23. package/lib/components/dropdown.element.d.ts +2 -0
  24. package/lib/components/range-calendar.element.d.ts +2 -1
  25. package/lib/components/range-date-picker.element.d.ts +0 -15
  26. package/lib/components/range-date-time-calendar.element.d.ts +18 -0
  27. package/lib/components/range-date-time-input.element.d.ts +18 -0
  28. package/lib/components/range-date-time-picker.element.d.ts +18 -0
  29. package/lib/components/range-time-input.element.d.ts +18 -0
  30. package/lib/components/range-time-picker.element.d.ts +18 -0
  31. package/lib/components/time-picker.element.d.ts +18 -0
  32. package/lib/components/time.element.d.ts +18 -0
  33. package/{list-D1oKnH89.js → list-CrLIL4by.js} +76 -61
  34. package/{list.element-Co3V3Cn5.js → list.element-DV82YxnJ.js} +22 -22
  35. package/{number.element-BhEyoOtc.js → number.element-CBr47IiY.js} +18 -16
  36. package/numeric-jmOOKz30.js +12 -0
  37. package/package.json +6 -6
  38. package/part-templates-Db871PS3.js +677 -0
  39. package/pill-ranges-DCqDmpkk.js +48 -0
  40. package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
  41. package/popup.controller-eUDxE6jD.js +71 -0
  42. package/range-calendar-CKPYeSGt.js +452 -0
  43. package/{range-calendar.element-QTE6vGNP.js → range-calendar.element-D6KYq18B.js} +24 -20
  44. package/range-commit-8-MmYUyo.js +14 -0
  45. package/range-date-input-D--AqBMv.js +292 -0
  46. package/{range-date-input.element-Dj29D_OQ.js → range-date-input.element-D4nIXJbw.js} +8 -7
  47. package/range-date-picker.element-dhxPAAE6.js +386 -0
  48. package/range-date-time-calendar-yksWrR7b.js +720 -0
  49. package/range-date-time-calendar.element-C00aDefZ.js +95 -0
  50. package/range-date-time-input-B37TUoM3.js +322 -0
  51. package/range-date-time-input.element-DUnbv4ed.js +81 -0
  52. package/range-date-time-picker.element-Cbps6s_G.js +412 -0
  53. package/range-selection-CU3hxLJE.js +25 -0
  54. package/range-time-input-3lhqR1Ku.js +329 -0
  55. package/range-time-input.element-dU2iBdmJ.js +81 -0
  56. package/range-time-picker.element-v6nQsIPw.js +429 -0
  57. package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
  58. package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
  59. package/time-input-BOhlBGJZ.js +181 -0
  60. package/time-list-Czo48bZm.js +217 -0
  61. package/time-picker-bFJ63ky8.js +261 -0
  62. package/time-picker.element-CYZVXgRS.js +85 -0
  63. package/time.element-fK3oLi49.js +82 -0
  64. package/abstract-calendar-BoqKPRmS.js +0 -545
  65. package/calendar-DTYKVYc3.js +0 -96
  66. package/date-input-BeQvyfln.js +0 -268
  67. package/date-picker.element-DabW_-0-.js +0 -166
  68. package/range-calendar-9skwbwlB.js +0 -255
  69. package/range-date-input-Uy8134vi.js +0 -395
  70. package/range-date-picker.element-CuKIBkIO.js +0 -182
@@ -0,0 +1,386 @@
1
+ import { InputWidgetAdapter as y, formContext as v, inputContext as $ } from "@golemui/lit";
2
+ import { LitElement as c, html as h, nothing as D } from "lit";
3
+ import { property as i, query as g, state as m, customElement as b } from "lit/decorators.js";
4
+ import { classMap as f } from "lit/directives/class-map.js";
5
+ import "./range-date-input-D--AqBMv.js";
6
+ import "./range-calendar-CKPYeSGt.js";
7
+ import { G as M } from "./popup.controller-eUDxE6jD.js";
8
+ import { r as _, D as w, d as x } from "./date-Bj9mI3GU.js";
9
+ import { a as A, b as R, c as C } from "./templates-Dk1jxLwS.js";
10
+ import { consume as L, provide as E } from "@lit/context";
11
+ import "rxjs";
12
+ var I = Object.defineProperty, S = Object.getOwnPropertyDescriptor, a = (e, r, n, s) => {
13
+ for (var o = s > 1 ? void 0 : s ? S(r, n) : r, d = e.length - 1, l; d >= 0; d--)
14
+ (l = e[d]) && (o = (s ? l(r, n, o) : l(o)) || o);
15
+ return s && o && I(r, n, o), o;
16
+ };
17
+ let t = class extends c {
18
+ constructor() {
19
+ super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.icon = "", this.errors = [], this.showErrors = !0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.localeId = void 0, this.value = [], this.separator = void 0, this.removePillAriaLabel = void 0, this.startDateAriaLabel = void 0, this.endDateAriaLabel = void 0, this.prevMonthIcon = "", this.nextMonthIcon = "", this.prevMonthAriaLabel = void 0, this.nextMonthAriaLabel = void 0, this.dayFormat = void 0, this.weekdayFormat = void 0, this.monthFormat = void 0, this.minDate = void 0, this.maxDate = void 0, this.disabledRanges = void 0, this.numberOfMonths = void 0, this.invalidDateMessage = void 0, this.minDateMessage = void 0, this.maxDateMessage = void 0, this.disabledDateRangeMessage = void 0, this._focusDate = void 0, this._invalidRange = null, this._popup = new M(this, {
20
+ getInteriorElements: () => [this._dateRef, this._calendarRef],
21
+ focusRestoreSelector: "gui-range-date input",
22
+ isDisabled: () => !!this.disabled,
23
+ clickIntent: (e) => e.closest(".gui-range-date-input__part") || e.closest("gui-range-calendar") ? "open" : "toggle",
24
+ keyToggleMode: "openClose",
25
+ beforeOpen: (e) => {
26
+ this.querySelector(".gui-pills__dropdown") && e.suppressNextFocusOut(), this.closePillsDropdown();
27
+ }
28
+ }), this.onDropdownToggle = (e) => {
29
+ e.detail?.open && this._popup.open && this._popup.close();
30
+ };
31
+ }
32
+ createRenderRoot() {
33
+ return this;
34
+ }
35
+ connectedCallback() {
36
+ super.connectedCallback(), this.addEventListener("dropdowntoggle", this.onDropdownToggle);
37
+ }
38
+ disconnectedCallback() {
39
+ super.disconnectedCallback(), this.removeEventListener("dropdowntoggle", this.onDropdownToggle);
40
+ }
41
+ render() {
42
+ const e = A("datePicker", { icon: this.icon }), r = this._popup.open ? h`<gui-range-calendar
43
+ id="calendar-input"
44
+ .uid=${this.uid}
45
+ .hint=${this.hint}
46
+ ?touched=${this.touched}
47
+ ?required=${this.required}
48
+ ?disabled=${this.disabled}
49
+ ?readonly=${this.readOnly}
50
+ .value=${this.value}
51
+ .focusDate=${this._focusDate}
52
+ .prevMonthIcon=${this.prevMonthIcon}
53
+ .nextMonthIcon=${this.nextMonthIcon}
54
+ .prevMonthAriaLabel=${this.prevMonthAriaLabel}
55
+ .nextMonthAriaLabel=${this.nextMonthAriaLabel}
56
+ .dayFormat=${this.dayFormat}
57
+ .weekdayFormat=${this.weekdayFormat}
58
+ .monthFormat=${this.monthFormat}
59
+ .minDate=${this.minDate}
60
+ .maxDate=${this.maxDate}
61
+ .disabledRanges=${this.disabledRanges}
62
+ .disabledDateRangeMessage=${this.disabledDateRangeMessage}
63
+ .numberOfMonths=${this.numberOfMonths}
64
+ .localeId=${this.localeId}
65
+ .hidePills=${!0}
66
+ .invalidRange=${this._invalidRange}
67
+ @blur=${this.onCalendarBlur}
68
+ @change=${this.onCalendarChange}
69
+ @inputError=${this.onCalendarInputError}
70
+ ></gui-range-calendar>` : D;
71
+ return h`
72
+ ${R(this.uid ?? "", {
73
+ label: this.label,
74
+ hint: this.hint,
75
+ required: this.required
76
+ })}
77
+
78
+ <div
79
+ role="button"
80
+ tabindex="-1"
81
+ class="gui-widget"
82
+ aria-expanded=${this._popup.open}
83
+ @keyup=${this._popup.onAnchorKeyUp}
84
+ @keydown=${this._popup.onAnchorKeyDown}
85
+ @click=${this._popup.onAnchorClick}
86
+ >
87
+ <gui-range-date
88
+ id="date-input"
89
+ class=${f(e.widgetClasses)}
90
+ .uid=${this.uid}
91
+ .hint=${this.hint}
92
+ .showErrors=${!1}
93
+ .errors=${this.errors}
94
+ ?touched=${this.touched}
95
+ ?required=${this.required}
96
+ ?disabled=${this.disabled}
97
+ ?readonly=${this.readOnly}
98
+ .value=${this.value}
99
+ .icon=${this.icon}
100
+ .localeId=${this.localeId}
101
+ .separator=${this.separator}
102
+ .removePillAriaLabel=${this.removePillAriaLabel}
103
+ .startDateAriaLabel=${this.startDateAriaLabel}
104
+ .endDateAriaLabel=${this.endDateAriaLabel}
105
+ .invalidDateMessage=${this.invalidDateMessage}
106
+ @blur=${this.onDateBlur}
107
+ @focus=${this._popup.show}
108
+ @change=${this.onDateChange}
109
+ @pillClick=${this.onPillClick}
110
+ ></gui-range-date>
111
+ <span class="gui-range-date-picker__arrow"
112
+ ><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
113
+ <path
114
+ d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"
115
+ ></path></svg
116
+ ></span>
117
+
118
+ ${r}
119
+ </div>
120
+
121
+ ${this.showErrors ? C(this.uid ?? "", { errors: this.errors, touched: this.touched }) : ""}
122
+ `;
123
+ }
124
+ onDateChange(e) {
125
+ e.stopPropagation();
126
+ const r = e.detail.value;
127
+ for (const n of r ?? []) {
128
+ const s = this.rangeError(n);
129
+ if (s) {
130
+ this.rejectTypedRange(n, s);
131
+ return;
132
+ }
133
+ }
134
+ this.commitValue(r);
135
+ }
136
+ /** The message for the first constraint a range violates, or null when valid. */
137
+ rangeError(e) {
138
+ const r = e.start, n = e.end ?? e.start;
139
+ if (_(r, n, this.disabledRanges))
140
+ return this.disabledDateRangeMessage ?? w;
141
+ const s = {
142
+ minDateMessage: this.minDateMessage,
143
+ maxDateMessage: this.maxDateMessage
144
+ };
145
+ for (const o of [r, n]) {
146
+ const d = x(o, this.minDate, this.maxDate, void 0, s);
147
+ if (d) return d;
148
+ }
149
+ return null;
150
+ }
151
+ rejectTypedRange(e, r) {
152
+ const n = e.start, s = e.end ?? e.start;
153
+ this._invalidRange = { start: n, end: s };
154
+ const o = this._dateRef;
155
+ o && (o.value = this.value ?? [], o.showRange(n, s)), this.dispatchEvent(
156
+ new CustomEvent("inputError", {
157
+ detail: { message: r },
158
+ bubbles: !0,
159
+ composed: !0
160
+ })
161
+ );
162
+ }
163
+ onDateBlur() {
164
+ this.dispatchEvent(new CustomEvent("blur"));
165
+ }
166
+ onCalendarChange(e) {
167
+ e.stopPropagation(), this._dateRef?.clearRangeInputs(), this.commitValue(e.detail.value);
168
+ }
169
+ onCalendarInputError(e) {
170
+ const r = e.detail?.range;
171
+ r && (this._invalidRange = r, this._dateRef?.showRange(r.start, r.end));
172
+ }
173
+ commitValue(e) {
174
+ this.value = e ?? void 0, this._invalidRange = null, this.dispatchEvent(
175
+ new CustomEvent("change", {
176
+ detail: { value: e ?? null },
177
+ bubbles: !0,
178
+ composed: !0
179
+ })
180
+ );
181
+ }
182
+ onCalendarBlur() {
183
+ this._popup.close();
184
+ }
185
+ onPillClick(e) {
186
+ this._focusDate = e.detail.range.start, this._popup.show();
187
+ }
188
+ closePillsDropdown() {
189
+ this.querySelector("gui-pills")?.closeDropdown?.();
190
+ }
191
+ };
192
+ a([
193
+ i({ type: String })
194
+ ], t.prototype, "uid", 2);
195
+ a([
196
+ i({ type: String })
197
+ ], t.prototype, "label", 2);
198
+ a([
199
+ i({ type: String })
200
+ ], t.prototype, "hint", 2);
201
+ a([
202
+ i({ type: String })
203
+ ], t.prototype, "icon", 2);
204
+ a([
205
+ i({ type: Array })
206
+ ], t.prototype, "errors", 2);
207
+ a([
208
+ i({ type: Boolean })
209
+ ], t.prototype, "showErrors", 2);
210
+ a([
211
+ i({ type: Boolean })
212
+ ], t.prototype, "touched", 2);
213
+ a([
214
+ i({ type: Boolean })
215
+ ], t.prototype, "required", 2);
216
+ a([
217
+ i({ type: Boolean })
218
+ ], t.prototype, "disabled", 2);
219
+ a([
220
+ i({ type: Boolean, attribute: "readonly" })
221
+ ], t.prototype, "readOnly", 2);
222
+ a([
223
+ i({ type: String, attribute: "locale-id" })
224
+ ], t.prototype, "localeId", 2);
225
+ a([
226
+ i({ type: Array })
227
+ ], t.prototype, "value", 2);
228
+ a([
229
+ i({ type: String })
230
+ ], t.prototype, "separator", 2);
231
+ a([
232
+ i({ type: String, attribute: "remove-pill-aria-label" })
233
+ ], t.prototype, "removePillAriaLabel", 2);
234
+ a([
235
+ i({ type: String, attribute: "start-date-aria-label" })
236
+ ], t.prototype, "startDateAriaLabel", 2);
237
+ a([
238
+ i({ type: String, attribute: "end-date-aria-label" })
239
+ ], t.prototype, "endDateAriaLabel", 2);
240
+ a([
241
+ i({ type: String, attribute: "prev-month-icon" })
242
+ ], t.prototype, "prevMonthIcon", 2);
243
+ a([
244
+ i({ type: String, attribute: "next-month-icon" })
245
+ ], t.prototype, "nextMonthIcon", 2);
246
+ a([
247
+ i({ type: String, attribute: "prev-month-aria-label" })
248
+ ], t.prototype, "prevMonthAriaLabel", 2);
249
+ a([
250
+ i({ type: String, attribute: "next-month-aria-label" })
251
+ ], t.prototype, "nextMonthAriaLabel", 2);
252
+ a([
253
+ i({ type: String, attribute: "day-format" })
254
+ ], t.prototype, "dayFormat", 2);
255
+ a([
256
+ i({ type: String, attribute: "weekday-format" })
257
+ ], t.prototype, "weekdayFormat", 2);
258
+ a([
259
+ i({ type: String, attribute: "month-format" })
260
+ ], t.prototype, "monthFormat", 2);
261
+ a([
262
+ i({ type: String, attribute: "min-date" })
263
+ ], t.prototype, "minDate", 2);
264
+ a([
265
+ i({ type: String, attribute: "max-date" })
266
+ ], t.prototype, "maxDate", 2);
267
+ a([
268
+ i({ type: Array, attribute: "disabled-ranges" })
269
+ ], t.prototype, "disabledRanges", 2);
270
+ a([
271
+ i({ type: Number, attribute: "number-of-months" })
272
+ ], t.prototype, "numberOfMonths", 2);
273
+ a([
274
+ i({ type: String, attribute: "invalid-date-message" })
275
+ ], t.prototype, "invalidDateMessage", 2);
276
+ a([
277
+ i({ type: String, attribute: "min-date-message" })
278
+ ], t.prototype, "minDateMessage", 2);
279
+ a([
280
+ i({ type: String, attribute: "max-date-message" })
281
+ ], t.prototype, "maxDateMessage", 2);
282
+ a([
283
+ i({ type: String, attribute: "disabled-date-range-message" })
284
+ ], t.prototype, "disabledDateRangeMessage", 2);
285
+ a([
286
+ g("#date-input")
287
+ ], t.prototype, "_dateRef", 2);
288
+ a([
289
+ g("#calendar-input")
290
+ ], t.prototype, "_calendarRef", 2);
291
+ a([
292
+ m()
293
+ ], t.prototype, "_focusDate", 2);
294
+ a([
295
+ m()
296
+ ], t.prototype, "_invalidRange", 2);
297
+ t = a([
298
+ b("gui-range-date-picker")
299
+ ], t);
300
+ typeof customElements < "u" && !customElements.get("gui-range-date-picker") && customElements.define("gui-range-date-picker", t);
301
+ var P = Object.defineProperty, k = Object.getOwnPropertyDescriptor, u = (e, r, n, s) => {
302
+ for (var o = s > 1 ? void 0 : s ? k(r, n) : r, d = e.length - 1, l; d >= 0; d--)
303
+ (l = e[d]) && (o = (s ? l(r, n, o) : l(o)) || o);
304
+ return s && o && P(r, n, o), o;
305
+ };
306
+ let p = class extends c {
307
+ constructor() {
308
+ super(...arguments), this.adapter = new y(), this.subscriptions = [];
309
+ }
310
+ createRenderRoot() {
311
+ return this;
312
+ }
313
+ updated(e) {
314
+ super.updated(e);
315
+ const r = this.adapter.templateData.size;
316
+ r ? this.style.flex = String(r) : this.style.removeProperty("flex");
317
+ }
318
+ connectedCallback() {
319
+ super.connectedCallback(), this.classList.add("gui-range-date-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
320
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
321
+ );
322
+ }
323
+ render() {
324
+ super.render();
325
+ const e = this.adapter.templateData;
326
+ return h`
327
+ <gui-range-date-picker
328
+ .uid=${this.widget.uid}
329
+ .label=${e.label}
330
+ .hint=${e.hint}
331
+ .errors=${e.errors}
332
+ ?touched=${e.touched}
333
+ ?required=${e.validator?.required}
334
+ ?disabled=${e.disabled}
335
+ ?readonly=${e.readonly}
336
+ .value=${e.value}
337
+ .icon=${e.icon}
338
+ .localeId=${e.lang}
339
+ .separator=${e.separator}
340
+ .removePillAriaLabel=${e.removePillAriaLabel}
341
+ .startDateAriaLabel=${e.startDateAriaLabel}
342
+ .endDateAriaLabel=${e.endDateAriaLabel}
343
+ .prevMonthIcon=${e.prevMonthIcon}
344
+ .nextMonthIcon=${e.nextMonthIcon}
345
+ .prevMonthAriaLabel=${e.prevMonthAriaLabel}
346
+ .nextMonthAriaLabel=${e.nextMonthAriaLabel}
347
+ .dayFormat=${e.dayFormat}
348
+ .weekdayFormat=${e.weekdayFormat}
349
+ .monthFormat=${e.monthFormat}
350
+ .minDate=${e.minDate}
351
+ .maxDate=${e.maxDate}
352
+ .disabledRanges=${e.disabledRanges}
353
+ .numberOfMonths=${e.numberOfMonths}
354
+ .invalidDateMessage=${e.invalidDateMessage}
355
+ .minDateMessage=${e.minDateMessage}
356
+ .maxDateMessage=${e.maxDateMessage}
357
+ .disabledDateRangeMessage=${e.disabledDateRangeMessage}
358
+ @inputError=${this.onInputError}
359
+ @blur=${() => this.adapter.onBlur()}
360
+ @change=${this.valueChanged}
361
+ ></gui-range-date-picker>
362
+ `;
363
+ }
364
+ valueChanged(e) {
365
+ this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
366
+ }
367
+ onInputError(e) {
368
+ this.adapter.injectValidationIssues([e.detail.message]), this.adapter.onBlur();
369
+ }
370
+ disconnectedCallback() {
371
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
372
+ }
373
+ };
374
+ u([
375
+ L({ context: v }),
376
+ i({ attribute: !1 })
377
+ ], p.prototype, "formContext", 2);
378
+ u([
379
+ E({ context: $ })
380
+ ], p.prototype, "adapter", 2);
381
+ p = u([
382
+ b("gui-range-date-picker-input")
383
+ ], p);
384
+ export {
385
+ p as RangeDatePickerElement
386
+ };