@golemui/gui-lit 0.14.0 → 0.15.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 (27) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/{button.element-ATNRRDN3.js → button.element-DxwYDdu6.js} +49 -45
  3. package/{currency.element-C7SZkoPP.js → currency.element-ybKzwXEh.js} +11 -10
  4. package/{date-input-e0k3oBof.js → date-input-D_Swskk4.js} +5 -5
  5. package/{date-picker.element-D6v6aHR5.js → date-picker.element-CP2_u_ZE.js} +1 -1
  6. package/{date.element-COU_mEUt.js → date.element-p6aB6OGd.js} +1 -1
  7. package/{dropdown.element-DCUI5Y7I.js → dropdown.element-8OaBgk7F.js} +1 -0
  8. package/index.js +271 -279
  9. package/index.umd.cjs +268 -195
  10. package/lib/components/range-date-picker.element.d.ts +3 -0
  11. package/lib/components/tags.element.d.ts +17 -0
  12. package/{markdown.element-CT1JOOM3.js → markdown.element-1IF3G5KX.js} +1 -0
  13. package/{number.element-HaXEg_7U.js → number.element-zgd4L5hn.js} +7 -6
  14. package/package.json +6 -6
  15. package/{password.element-B4-0SCe4.js → password.element-BT65mDsp.js} +1 -0
  16. package/pills-D0yyi-op.js +323 -0
  17. package/range-calendar-CZGBBOzO.js +258 -0
  18. package/{range-calendar.element-C-4qqRGK.js → range-calendar.element-DQZXvd-L.js} +1 -1
  19. package/range-date-input-CcPYH7P3.js +398 -0
  20. package/{range-date-input.element-D3xRMAaY.js → range-date-input.element-v71P-oUp.js} +1 -1
  21. package/{range-date-picker.element-Vgj3tFlQ.js → range-date-picker.element-CA-KcQhA.js} +60 -51
  22. package/{select.element-DuGZjlZY.js → select.element-CjWqp9dd.js} +1 -1
  23. package/tags.element-ed1_51GA.js +365 -0
  24. package/{textarea.element-C8yx2u0o.js → textarea.element-BTJLqnnI.js} +6 -5
  25. package/{textinput.element-DKuplF1A.js → textinput.element-zI0iG-Cq.js} +4 -3
  26. package/range-calendar-qpakwAba.js +0 -326
  27. package/range-date-input-DFnvo-KK.js +0 -507
@@ -12,8 +12,10 @@ export declare class RangeDatePickerElement extends LitElement implements WithWi
12
12
  isCalendarOpen: boolean;
13
13
  focusDate: string | undefined;
14
14
  subscriptions: Subscription[];
15
+ private _ignoreNextFocusOut;
15
16
  onFocusOut: (event: FocusEvent) => void;
16
17
  onDocumentClick: (event: MouseEvent) => void;
18
+ onDropdownToggle: (event: Event) => void;
17
19
  createRenderRoot(): this;
18
20
  updated(changedProperties: any): void;
19
21
  connectedCallback(): void;
@@ -26,5 +28,6 @@ export declare class RangeDatePickerElement extends LitElement implements WithWi
26
28
  toggleCalendar(event: Event): void;
27
29
  openCalendar(): void;
28
30
  closeCalendar(): void;
31
+ private closePillsDropdown;
29
32
  disconnectedCallback(): void;
30
33
  }
@@ -0,0 +1,17 @@
1
+ import { InputWidget, WithWidget } from '@golemui/core';
2
+ import { InputWidgetAdapter, LitFormContext } from '@golemui/lit';
3
+ import { TagsProps } from '@golemui/gui-shared';
4
+ import { LitElement } from 'lit';
5
+ import { Subscription } from 'rxjs';
6
+ export declare class TagsElement extends LitElement implements WithWidget {
7
+ widget: InputWidget<string[]>;
8
+ formContext: LitFormContext<any>;
9
+ adapter: InputWidgetAdapter<string[], TagsProps>;
10
+ subscriptions: Subscription[];
11
+ createRenderRoot(): this;
12
+ updated(changedProperties: any): void;
13
+ connectedCallback(): void;
14
+ render(): import('lit-html').TemplateResult<1>;
15
+ valueChanged(event: CustomEvent): void;
16
+ disconnectedCallback(): void;
17
+ }
@@ -62,6 +62,7 @@ let n = class extends H {
62
62
  maxLength: this.maxLength,
63
63
  dependencies: this.dependencies
64
64
  }, e = {
65
+ "gui-widget-input": !0,
65
66
  "gui-markdown--icon": !1
66
67
  };
67
68
  let i = u``;
@@ -2,8 +2,8 @@ import { InputWidgetAdapter as y, formContext as v, inputContext as $ } from "@g
2
2
  import "@golemui/gui-shared";
3
3
  import { LitElement as m, nothing as n, html as c } from "lit";
4
4
  import { property as s, customElement as b } from "lit/decorators.js";
5
- import { G as f, b as g, c as x } from "./templates-Dk1jxLwS.js";
6
- import { styleMap as w } from "lit-html/directives/style-map.js";
5
+ import { G as g, b as f, c as w } from "./templates-Dk1jxLwS.js";
6
+ import { styleMap as x } from "lit-html/directives/style-map.js";
7
7
  import { consume as D, provide as C } from "@lit/context";
8
8
  import "rxjs";
9
9
  var N = Object.defineProperty, E = Object.getOwnPropertyDescriptor, r = (t, i, e, o) => {
@@ -13,7 +13,7 @@ var N = Object.defineProperty, E = Object.getOwnPropertyDescriptor, r = (t, i, e
13
13
  };
14
14
  let a = class extends m {
15
15
  constructor() {
16
- super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.step = void 0, this.placeholder = void 0, this.autocomplete = void 0, this.minimum = void 0, this.maximum = void 0, this.autoGrow = !1, this.ariaController = new f(this, {
16
+ super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.step = void 0, this.placeholder = void 0, this.autocomplete = void 0, this.minimum = void 0, this.maximum = void 0, this.autoGrow = !1, this.ariaController = new g(this, {
17
17
  getTargets: () => this.querySelectorAll(`input[id="${this.uid}"]`),
18
18
  getState: () => ({
19
19
  uid: this.uid,
@@ -60,7 +60,7 @@ let a = class extends m {
60
60
  autocomplete: this.autocomplete
61
61
  };
62
62
  return c`
63
- ${g(this.uid, e)}
63
+ ${f(this.uid, e)}
64
64
 
65
65
  <div class="gui-widget">
66
66
  <button
@@ -78,7 +78,8 @@ let a = class extends m {
78
78
  inputmode="decimal"
79
79
  id=${this.uid}
80
80
  data-cy=${`${this.uid}_number`}
81
- style=${w(i)}
81
+ class="gui-widget-input"
82
+ style=${x(i)}
82
83
  value=${this.value}
83
84
  ?required=${this.required}
84
85
  ?disabled=${this.disabled}
@@ -102,7 +103,7 @@ let a = class extends m {
102
103
  </button>
103
104
  </div>
104
105
 
105
- ${x(this.uid, e)}
106
+ ${w(this.uid, e)}
106
107
  `;
107
108
  }
108
109
  keyDown(t) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemui/gui-lit",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "main": "./index.umd.cjs",
6
6
  "module": "./index.js",
@@ -21,11 +21,11 @@
21
21
  "*.md"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@golemui/lit": "0.14.0",
25
- "@golemui/core": "0.14.0",
26
- "@golemui/gui-components": "0.14.0",
27
- "@golemui/gui-shared": "0.14.0",
28
- "@golemui/gui-validators": "0.14.0",
24
+ "@golemui/lit": "0.15.0",
25
+ "@golemui/core": "0.15.0",
26
+ "@golemui/gui-components": "0.15.0",
27
+ "@golemui/gui-shared": "0.15.0",
28
+ "@golemui/gui-validators": "0.15.0",
29
29
  "@lit/context": "^1.1.6",
30
30
  "lit-html": "^3.3.1",
31
31
  "lit": "^3.3.1",
@@ -53,6 +53,7 @@ let e = class extends w {
53
53
  showPasswordLabel: this.showPasswordLabel,
54
54
  hidePasswordLabel: this.hidePasswordLabel
55
55
  }, a = f("password", t), i = {
56
+ "gui-widget-input": !0,
56
57
  "gui-password--icon": !!this.icon
57
58
  };
58
59
  return u`
@@ -0,0 +1,323 @@
1
+ import { LitElement as m, nothing as p, html as d } from "lit";
2
+ import { property as l, state as u, customElement as w } from "lit/decorators.js";
3
+ import { classMap as c } from "lit/directives/class-map.js";
4
+ import { repeat as b } from "lit/directives/repeat.js";
5
+ import { c as v } from "./tabs-DzSCq_98.js";
6
+ var y = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, o = (e, t, i, s) => {
7
+ for (var n = s > 1 ? void 0 : s ? _(t, i) : t, a = e.length - 1, h; a >= 0; a--)
8
+ (h = e[a]) && (n = (s ? h(t, i, n) : h(n)) || n);
9
+ return s && n && y(t, i, n), n;
10
+ };
11
+ let r = class extends m {
12
+ constructor() {
13
+ super(...arguments), this.items = [], this.clickable = !1, this.removable = !0, this.bubble = !0, this.tabbable = !0, this.disabled = !1, this.readOnly = !1, this.removeAriaLabel = "Remove", this._isStartVisible = !0, this._isEndVisible = !0, this._showDropdown = !1, this._pendingFocusIndex = null, this.handlePillFocus = (e) => {
14
+ e.target.scrollIntoView({
15
+ behavior: "smooth",
16
+ block: "nearest",
17
+ inline: "nearest"
18
+ });
19
+ }, this.toggleDropdown = () => {
20
+ this._showDropdown ? this.closeDropdown() : this.openDropdown();
21
+ }, this.handleOutsideInteraction = (e) => {
22
+ const t = this.querySelector(".gui-pills__compact"), i = this.querySelector(".gui-pills__dropdown"), s = e.composedPath()[0];
23
+ !t?.contains(s) && !i?.contains(s) && this.closeDropdown();
24
+ };
25
+ }
26
+ createRenderRoot() {
27
+ return this;
28
+ }
29
+ updated(e) {
30
+ if (super.updated(e), this.setupObservers(), this._pendingFocusIndex !== null && e.has("items")) {
31
+ const t = this._pendingFocusIndex;
32
+ this._pendingFocusIndex = null;
33
+ const i = this.items.length;
34
+ if (i === 0) {
35
+ this._showDropdown && this.closeDropdown();
36
+ return;
37
+ }
38
+ const s = Math.max(0, Math.min(t, i - 1));
39
+ this.focusPillAt(s);
40
+ }
41
+ }
42
+ disconnectedCallback() {
43
+ super.disconnectedCallback(), this.disconnectObservers(), this.removeOutsideListeners();
44
+ }
45
+ render() {
46
+ const e = this.items.length;
47
+ return e === 0 ? p : d`
48
+ ${this.renderStrip()}
49
+ ${this.bubble ? this.renderCompact(e) : p}
50
+ ${this.bubble && this._showDropdown ? this.renderDropdown() : p}
51
+ `;
52
+ }
53
+ renderStrip() {
54
+ return d`
55
+ <div
56
+ class=${c({
57
+ "gui-pills__strip-wrapper": !0,
58
+ "gui-pills--start-shadow": !this._isStartVisible,
59
+ "gui-pills--end-shadow": !this._isEndVisible
60
+ })}
61
+ >
62
+ <div class="gui-pills__strip" role="list" tabindex="-1">
63
+ <span class="gui-sentinel gui-sentinel__start"></span>
64
+ ${b(
65
+ this.items,
66
+ (e) => e.key,
67
+ (e, t) => this.renderPill(e, t, !1)
68
+ )}
69
+ <span class="gui-sentinel gui-sentinel__end"></span>
70
+ </div>
71
+ </div>
72
+ `;
73
+ }
74
+ renderCompact(e) {
75
+ return d`
76
+ <div class="gui-pills__compact">
77
+ <button
78
+ type="button"
79
+ class="gui-pills__count"
80
+ aria-label=${this.compactAriaLabel ?? `${e} items`}
81
+ aria-expanded=${this._showDropdown}
82
+ ?disabled=${this.disabled || this.readOnly}
83
+ @click=${(t) => {
84
+ t.stopPropagation(), this.toggleDropdown();
85
+ }}
86
+ >
87
+ ${e}
88
+ </button>
89
+ </div>
90
+ `;
91
+ }
92
+ renderDropdown() {
93
+ return d`
94
+ <div class="gui-pills__dropdown" role="list">
95
+ ${b(
96
+ this.items,
97
+ (e) => `dd-${e.key}`,
98
+ (e, t) => this.renderPill(e, t, !0)
99
+ )}
100
+ </div>
101
+ `;
102
+ }
103
+ renderPill(e, t, i) {
104
+ const s = e.ariaLabel ?? `${this.removeAriaLabel}: ${e.label}`, n = this.clickable && !this.disabled && !this.readOnly;
105
+ return d`
106
+ <div
107
+ class=${c({
108
+ "gui-pills__pill": !0,
109
+ "gui-pills__pill--clickable": n
110
+ })}
111
+ role="listitem"
112
+ data-key=${e.key}
113
+ data-index=${t}
114
+ data-in-dropdown=${i}
115
+ tabindex=${this.tabbable && !this.disabled && !this.readOnly ? 0 : -1}
116
+ aria-label=${s}
117
+ @click=${(a) => this.onPillClick(a, e)}
118
+ @focus=${this.handlePillFocus}
119
+ @keydown=${(a) => this.onPillKeydown(a, e, t)}
120
+ >
121
+ <span class="gui-pills__pill-text">${e.label}</span>
122
+ ${this.removable ? this.renderRemoveButton(e) : p}
123
+ </div>
124
+ `;
125
+ }
126
+ renderRemoveButton(e) {
127
+ return d`
128
+ <button
129
+ type="button"
130
+ class="gui-pills__pill-remove"
131
+ tabindex="-1"
132
+ aria-hidden="true"
133
+ ?disabled=${this.disabled || this.readOnly}
134
+ @click=${(t) => {
135
+ t.stopPropagation(), this.emitRemove(e.key, this.items.indexOf(e));
136
+ }}
137
+ >
138
+ ${this.removeIcon ? d`<span class=${`gui-widget-icon ${this.removeIcon}`} data-icon=${this.removeIcon}></span>` : d`<svg
139
+ xmlns="http://www.w3.org/2000/svg"
140
+ width="16"
141
+ height="16"
142
+ viewBox="0 0 256 256"
143
+ fill="currentColor"
144
+ aria-hidden="true"
145
+ >
146
+ <path
147
+ d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"
148
+ ></path>
149
+ </svg>`}
150
+ </button>
151
+ `;
152
+ }
153
+ onPillClick(e, t) {
154
+ !this.clickable || this.disabled || this.readOnly || (e.stopPropagation(), this.dispatchEvent(
155
+ new CustomEvent("pillclick", {
156
+ detail: { key: t.key },
157
+ bubbles: !0,
158
+ composed: !0
159
+ })
160
+ ));
161
+ }
162
+ onPillKeydown(e, t, i) {
163
+ if (this.disabled || this.readOnly) {
164
+ this.emitKeydown(t.key, e);
165
+ return;
166
+ }
167
+ if (this.removable && (e.key === "Delete" || e.key === "Backspace")) {
168
+ e.preventDefault(), e.stopPropagation(), this.emitRemove(t.key, i);
169
+ return;
170
+ }
171
+ if ((e.key === "Enter" || e.key === " ") && this.clickable) {
172
+ e.preventDefault(), this.dispatchEvent(
173
+ new CustomEvent("pillclick", {
174
+ detail: { key: t.key },
175
+ bubbles: !0,
176
+ composed: !0
177
+ })
178
+ );
179
+ return;
180
+ }
181
+ const s = this._showDropdown, n = s ? "ArrowUp" : "ArrowLeft", a = s ? "ArrowDown" : "ArrowRight";
182
+ if (e.key === n) {
183
+ i > 0 ? (e.preventDefault(), this.focusPillAt(i - 1)) : this.emitKeydown(t.key, e);
184
+ return;
185
+ }
186
+ if (e.key === a) {
187
+ i < this.items.length - 1 ? (e.preventDefault(), this.focusPillAt(i + 1)) : this.emitKeydown(t.key, e);
188
+ return;
189
+ }
190
+ if (e.key === "Home") {
191
+ e.preventDefault(), this.focusPillAt(0);
192
+ return;
193
+ }
194
+ if (e.key === "End") {
195
+ e.preventDefault(), this.focusPillAt(this.items.length - 1);
196
+ return;
197
+ }
198
+ if (e.key === "Escape" && s) {
199
+ e.preventDefault(), this.closeDropdown();
200
+ return;
201
+ }
202
+ this.emitKeydown(t.key, e);
203
+ }
204
+ emitRemove(e, t) {
205
+ this._pendingFocusIndex = t, this.dispatchEvent(
206
+ new CustomEvent("pillremove", {
207
+ detail: { key: e },
208
+ bubbles: !0,
209
+ composed: !0
210
+ })
211
+ );
212
+ }
213
+ emitKeydown(e, t) {
214
+ this.dispatchEvent(
215
+ new CustomEvent("pillkeydown", {
216
+ detail: { key: e, event: t },
217
+ bubbles: !0,
218
+ composed: !0
219
+ })
220
+ );
221
+ }
222
+ // ─── Focus ───────────────────────────────────────────────────────────────
223
+ /**
224
+ * Programmatically focus the pill at the given index. In dropdown mode,
225
+ * focuses the corresponding pill in the dropdown overlay; otherwise in the
226
+ * strip. Useful for hosts that want to "enter" the pill list from outside
227
+ * (e.g. tags' ArrowLeft from the input).
228
+ */
229
+ focusPillAt(e) {
230
+ requestAnimationFrame(() => {
231
+ const t = this._showDropdown ? ".gui-pills__dropdown .gui-pills__pill" : ".gui-pills__strip .gui-pills__pill", i = this.querySelectorAll(t);
232
+ if (i.length === 0) return;
233
+ const s = Math.max(0, Math.min(e, i.length - 1));
234
+ i[s].focus();
235
+ });
236
+ }
237
+ /** Open the dropdown and focus its first pill. No-op if `bubble` is false. */
238
+ openDropdown() {
239
+ !this.bubble || this.disabled || this.readOnly || this._showDropdown || (this._showDropdown = !0, this.dispatchEvent(
240
+ new CustomEvent("dropdowntoggle", {
241
+ detail: { open: !0 },
242
+ bubbles: !0,
243
+ composed: !0
244
+ })
245
+ ), requestAnimationFrame(() => {
246
+ this.addOutsideListeners(), this.querySelector(
247
+ ".gui-pills__dropdown .gui-pills__pill"
248
+ )?.focus();
249
+ }));
250
+ }
251
+ closeDropdown() {
252
+ this._showDropdown && (this._showDropdown = !1, this.removeOutsideListeners(), this.dispatchEvent(
253
+ new CustomEvent("dropdowntoggle", {
254
+ detail: { open: !1 },
255
+ bubbles: !0,
256
+ composed: !0
257
+ })
258
+ ));
259
+ }
260
+ addOutsideListeners() {
261
+ document.addEventListener("pointerdown", this.handleOutsideInteraction), document.addEventListener("focusin", this.handleOutsideInteraction);
262
+ }
263
+ removeOutsideListeners() {
264
+ document.removeEventListener("pointerdown", this.handleOutsideInteraction), document.removeEventListener("focusin", this.handleOutsideInteraction);
265
+ }
266
+ // ─── Observers ───────────────────────────────────────────────────────────
267
+ setupObservers() {
268
+ const e = this.querySelector(".gui-sentinel__start"), t = this.querySelector(".gui-sentinel__end");
269
+ e && !this.startObserver && (this.startObserver = v(
270
+ e,
271
+ (i) => this._isStartVisible = i
272
+ )), t && !this.endObserver && (this.endObserver = v(
273
+ t,
274
+ (i) => this._isEndVisible = i
275
+ )), !e && this.startObserver && (this.startObserver.disconnect(), this.startObserver = void 0, this._isStartVisible = !0), !t && this.endObserver && (this.endObserver.disconnect(), this.endObserver = void 0, this._isEndVisible = !0);
276
+ }
277
+ disconnectObservers() {
278
+ this.startObserver?.disconnect(), this.endObserver?.disconnect(), this.startObserver = void 0, this.endObserver = void 0;
279
+ }
280
+ };
281
+ o([
282
+ l({ type: Array })
283
+ ], r.prototype, "items", 2);
284
+ o([
285
+ l({ type: Boolean })
286
+ ], r.prototype, "clickable", 2);
287
+ o([
288
+ l({ type: Boolean })
289
+ ], r.prototype, "removable", 2);
290
+ o([
291
+ l({ type: Boolean })
292
+ ], r.prototype, "bubble", 2);
293
+ o([
294
+ l({ type: Boolean })
295
+ ], r.prototype, "tabbable", 2);
296
+ o([
297
+ l({ type: Boolean })
298
+ ], r.prototype, "disabled", 2);
299
+ o([
300
+ l({ type: Boolean, attribute: "readonly" })
301
+ ], r.prototype, "readOnly", 2);
302
+ o([
303
+ l({ type: String, attribute: "remove-aria-label" })
304
+ ], r.prototype, "removeAriaLabel", 2);
305
+ o([
306
+ l({ type: String, attribute: "remove-icon" })
307
+ ], r.prototype, "removeIcon", 2);
308
+ o([
309
+ l({ type: String, attribute: "compact-aria-label" })
310
+ ], r.prototype, "compactAriaLabel", 2);
311
+ o([
312
+ u()
313
+ ], r.prototype, "_isStartVisible", 2);
314
+ o([
315
+ u()
316
+ ], r.prototype, "_isEndVisible", 2);
317
+ o([
318
+ u()
319
+ ], r.prototype, "_showDropdown", 2);
320
+ r = o([
321
+ w("gui-pills")
322
+ ], r);
323
+ typeof customElements < "u" && !customElements.get("gui-pills") && customElements.define("gui-pills", r);