@golemui/gui-lit 1.3.0 → 1.4.0-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.
Files changed (54) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/accordion.element-BEenQrCh.js +102 -0
  3. package/{alert.element-CHn49Yaf.js → alert.element-Dzv49O-1.js} +19 -19
  4. package/{button.element-C9fHivSw.js → button.element-CKYv0Glr.js} +14 -14
  5. package/{calendar.element-XkojKTJk.js → calendar.element-DkHZFBNr.js} +16 -16
  6. package/{checkbox.element-DU_tVMXu.js → checkbox.element-MukoziRw.js} +16 -16
  7. package/{currency.element-BmAH5KS_.js → currency.element-DNumeSKA.js} +13 -13
  8. package/{date-picker.element-Bg3rF95F.js → date-picker.element-DpQmremq.js} +5 -5
  9. package/{date-time-calendar.element-sywQCeQQ.js → date-time-calendar.element-GAr8VMGa.js} +5 -5
  10. package/{date-time-picker.element-HHpwjWTQ.js → date-time-picker.element-Bt0GYSpS.js} +5 -5
  11. package/{date-time.element-ucETvSTC.js → date-time.element-WfLnY_Cb.js} +14 -14
  12. package/{date.element-BEHGxRFF.js → date.element-ChpTi2AQ.js} +15 -15
  13. package/default-multi-list-item-renderer-Cv-guvEX.js +31 -0
  14. package/{dropdown.element-Dg80G2PL.js → dropdown.element-D9wMyqWQ.js} +76 -55
  15. package/{flex.element-pwba7621.js → flex.element-DiZWJBwt.js} +14 -14
  16. package/{grid.element-C8K7_Qi3.js → grid.element-DJ9ACsqZ.js} +22 -22
  17. package/index.js +79 -77
  18. package/index.umd.cjs +374 -117
  19. package/lib/components/accordion.element.d.ts +3 -2
  20. package/lib/components/default-multi-list-item-renderer.d.ts +2 -0
  21. package/lib/components/dropdown.element.d.ts +3 -2
  22. package/lib/components/multi-dropdown.element.d.ts +48 -0
  23. package/lib/components/multi-list.element.d.ts +27 -0
  24. package/lib/components/tabs.element.d.ts +3 -0
  25. package/{list.element-ZtEMKE2x.js → list.element-DD5IL4QB.js} +7 -7
  26. package/{markdown-text.element-DDm36qD0.js → markdown-text.element-DflCQwAo.js} +16 -16
  27. package/{markdown.element-DWz3U9rG.js → markdown.element-DUHHoi2Y.js} +13 -13
  28. package/multi-dropdown.element-iEOlPvux.js +312 -0
  29. package/multi-list.element-CCX3i3k6.js +162 -0
  30. package/{number.element-VkG5wScD.js → number.element-mQSFQsYC.js} +16 -16
  31. package/package.json +6 -6
  32. package/{password.element-C5vQHq5P.js → password.element-xw5gugEg.js} +13 -13
  33. package/{radiogroup.element-CKdO9HwO.js → radiogroup.element-TqfrxVyI.js} +15 -15
  34. package/{range-calendar.element-BznGrej5.js → range-calendar.element-BJr97SVA.js} +13 -5
  35. package/{range-date-input.element-BloTHRDl.js → range-date-input.element-DDRYvP9h.js} +23 -15
  36. package/{range-date-picker.element-DKhwFasW.js → range-date-picker.element-rdEr0_wu.js} +25 -17
  37. package/{range-date-time-calendar.element-CZCET-sb.js → range-date-time-calendar.element-UlL1BBRJ.js} +25 -17
  38. package/{range-date-time-input.element-Dr2VrYhG.js → range-date-time-input.element-Cq4IdW7N.js} +17 -9
  39. package/{range-date-time-picker.element-CYeIMWLp.js → range-date-time-picker.element-CnJcIN9C.js} +27 -19
  40. package/{range-time-input.element-7OZhPQqx.js → range-time-input.element-Cq0TrGe9.js} +17 -9
  41. package/{range-time-picker.element-D0mRFZkK.js → range-time-picker.element-BzlIuZ6m.js} +24 -16
  42. package/{renderer.element-DbsFoBba.js → renderer.element-BVwerbtL.js} +15 -15
  43. package/repeater.element-DQNI4b7I.js +133 -0
  44. package/{select.element-Bb_9jAVB.js → select.element-RBtbAvLx.js} +12 -11
  45. package/tabs.element-BiVaQlvt.js +171 -0
  46. package/{tags.element-BSN3i9Gx.js → tags.element-CGvxhMmX.js} +18 -19
  47. package/{textarea.element-Dl1ZEOqO.js → textarea.element-E2ntRBtE.js} +13 -13
  48. package/{textinput.element-C5Vbbkxq.js → textinput.element-0q5F5ol3.js} +16 -16
  49. package/{time-picker.element-Crmj9YDy.js → time-picker.element-BiLaLr_c.js} +5 -5
  50. package/{time.element-DfSeAZp4.js → time.element-92goKRwJ.js} +15 -15
  51. package/{toggle.element-ORsprZ2M.js → toggle.element-zDUc9Vja.js} +16 -16
  52. package/accordion.element-C9GzfKrY.js +0 -103
  53. package/repeater.element-DGEbwvhY.js +0 -138
  54. package/tabs.element-BYDNF_pm.js +0 -161
@@ -1,4 +1,4 @@
1
- import { FormWidget, LayoutWidget, WithWidget } from '@golemui/core';
1
+ import { LayoutWidget, WithWidget } from '@golemui/core';
2
2
  import { LayoutWidgetAdapter, LitFormContext } from '@golemui/lit';
3
3
  import { AccordionProps } from '@golemui/gui-shared/internals';
4
4
  import { LitElement } from 'lit';
@@ -11,11 +11,12 @@ export declare class AccordionElement extends LitElement implements WithWidget {
11
11
  formContext: LitFormContext<any>;
12
12
  adapter: LayoutWidgetAdapter<AccordionProps>;
13
13
  subscriptions: Subscription[];
14
+ private rowIndexSuffix;
14
15
  createRenderRoot(): this;
15
16
  updated(changedProperties: any): void;
16
17
  connectedCallback(): void;
17
18
  onClickButton(uid: string): void;
18
- getChild(uid: string): FormWidget<string>;
19
+ getChild(uid: string): import('@golemui/core').NonFunctionWidget<string> | undefined;
19
20
  render(): import('lit-html').TemplateResult<1>;
20
21
  disconnectedCallback(): void;
21
22
  }
@@ -0,0 +1,2 @@
1
+ import { ItemRenderContext } from '@golemui/core';
2
+ export declare const defaultMultiListItemRenderer: (ctx: ItemRenderContext<any>) => import('lit-html').TemplateResult<1>;
@@ -35,8 +35,9 @@ export declare class DropdownElement extends LitElement implements WithWidget {
35
35
  private _filterItems;
36
36
  private _onWidgetKeyDown;
37
37
  private _onFocus;
38
+ private _onToggleMouseDown;
39
+ private _onToggleClick;
38
40
  private _onPanelMouseDown;
39
- private _onFocusOutInput;
40
- private _onBlur;
41
+ private _onFocusOut;
41
42
  render(): import('lit-html').TemplateResult<1>;
42
43
  }
@@ -0,0 +1,48 @@
1
+ import { InputWidget, WithWidget } from '@golemui/core';
2
+ import { InputWidgetAdapter, LitFormContext } from '@golemui/lit';
3
+ import { MultiDropdownProps, OptionValue } from '@golemui/gui-shared/internals';
4
+ import { LitElement } from 'lit';
5
+ import { Subject, Subscription } from 'rxjs';
6
+ export declare class MultiDropdownElement extends LitElement implements WithWidget {
7
+ widget: InputWidget<OptionValue[]>;
8
+ formContext: LitFormContext<any>;
9
+ adapter: InputWidgetAdapter<OptionValue[], MultiDropdownProps<any>>;
10
+ debouncer: Subject<string>;
11
+ subscriptions: Subscription[];
12
+ private _range;
13
+ private _filteredItems;
14
+ private _listItems;
15
+ private _focusedIndex;
16
+ private _isFiltering;
17
+ private _isListVisible;
18
+ private _triggerRef;
19
+ private _listRef;
20
+ private _panelRef;
21
+ private _ignoreNextFocus;
22
+ onDocumentClick: (event: MouseEvent) => void;
23
+ createRenderRoot(): this;
24
+ updated(changedProperties: any): void;
25
+ connectedCallback(): void;
26
+ disconnectedCallback(): void;
27
+ private _currentValues;
28
+ private _pillItems;
29
+ private _toggleValue;
30
+ private _openPanel;
31
+ private _onRangeChange;
32
+ private _onUpdateItems;
33
+ private _onFocusChange;
34
+ private _onClickItem;
35
+ private _onValueChange;
36
+ private _onPillRemove;
37
+ private _onPillsDropdownToggle;
38
+ private _onKeyDown;
39
+ private _onInput;
40
+ private _filterItems;
41
+ private _onWidgetKeyDown;
42
+ private _onFocusIn;
43
+ private _onToggleMouseDown;
44
+ private _onToggleClick;
45
+ private _onPanelMouseDown;
46
+ private _onFocusOut;
47
+ render(): import('lit-html').TemplateResult<1>;
48
+ }
@@ -0,0 +1,27 @@
1
+ import { InputWidget, WithWidget } from '@golemui/core';
2
+ import { InputWidgetAdapter, LitFormContext } from '@golemui/lit';
3
+ import { MultiListProps, OptionValue } from '@golemui/gui-shared/internals';
4
+ import { LitElement } from 'lit';
5
+ import { Subscription } from 'rxjs';
6
+ export declare class MultiListElement extends LitElement implements WithWidget {
7
+ widget: InputWidget<OptionValue[]>;
8
+ formContext: LitFormContext<any>;
9
+ adapter: InputWidgetAdapter<OptionValue[], MultiListProps<any>>;
10
+ subscriptions: Subscription[];
11
+ private _range;
12
+ private _listItems;
13
+ private _focusedIndex;
14
+ private _guiListRef;
15
+ createRenderRoot(): this;
16
+ updated(changedProperties: any): void;
17
+ connectedCallback(): void;
18
+ disconnectedCallback(): void;
19
+ render(): import('lit-html').TemplateResult<1>;
20
+ private _currentValues;
21
+ private _toggleValue;
22
+ private _onRangeChange;
23
+ private _onUpdateItems;
24
+ private _onFocusChange;
25
+ private _onClickItem;
26
+ private _valueChanged;
27
+ }
@@ -14,8 +14,11 @@ export declare class TabsElement extends LitElement implements WithWidget {
14
14
  formContext: LitFormContext<any>;
15
15
  adapter: LayoutWidgetAdapter<TabsProps>;
16
16
  subscriptions: Subscription[];
17
+ private rowIndexSuffix;
17
18
  private startObserver?;
18
19
  private endObserver?;
20
+ private get activeChildUid();
21
+ private childUid;
19
22
  createRenderRoot(): this;
20
23
  updated(changedProperties: any): void;
21
24
  connectedCallback(): void;
@@ -2,16 +2,16 @@ import { InputWidgetAdapter as _, formContext as $, inputContext as v } from "@g
2
2
  import { consume as I, provide as x } from "@lit/context";
3
3
  import { LitElement as y, nothing as o, html as u } from "lit";
4
4
  import { property as C, state as h, query as R } from "lit/decorators.js";
5
- import { safeDefine as w } from "@golemui/lit/internals";
5
+ import { unsubscribeAll as w, safeDefine as D } from "@golemui/lit/internals";
6
6
  import "rxjs";
7
- import { d as D } from "./default-list-item-renderer-CuPJ9jUD.js";
7
+ import { d as L } from "./default-list-item-renderer-CuPJ9jUD.js";
8
8
  import "@golemui/gui-components/label";
9
9
  import "@golemui/gui-components/list";
10
10
  import "@golemui/gui-components/errors";
11
- var L = Object.defineProperty, r = (n, e, i, p) => {
11
+ var k = Object.defineProperty, r = (n, e, i, p) => {
12
12
  for (var s = void 0, t = n.length - 1, d; t >= 0; t--)
13
13
  (d = n[t]) && (s = d(e, i, s) || s);
14
- return s && L(e, i, s), s;
14
+ return s && k(e, i, s), s;
15
15
  };
16
16
  class a extends y {
17
17
  constructor() {
@@ -34,12 +34,12 @@ class a extends y {
34
34
  );
35
35
  }
36
36
  disconnectedCallback() {
37
- super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
37
+ super.disconnectedCallback(), this.adapter.destroy(), w(this.subscriptions);
38
38
  }
39
39
  render() {
40
40
  const e = this.adapter.templateData, i = e.touched && e.errors && e.errors.length > 0, p = this._listItems.slice(this._range.start, this._range.end), s = this.adapter.getItemRenderer(
41
41
  e.itemRenderer,
42
- D
42
+ L
43
43
  );
44
44
  return u`
45
45
  <gui-label
@@ -142,7 +142,7 @@ r([
142
142
  r([
143
143
  R("gui-list")
144
144
  ], a.prototype, "_guiListRef");
145
- w("gui-list-input", a);
145
+ D("gui-list-input", a);
146
146
  export {
147
147
  a as ListElement
148
148
  };
@@ -1,26 +1,26 @@
1
1
  import { LitElement as p, html as n } from "lit";
2
2
  import { property as l } from "lit/decorators.js";
3
- import { safeDefine as m } from "@golemui/lit/internals";
4
- import { consume as c, provide as u } from "@lit/context";
5
- import { DisplayWidgetAdapter as h, formContext as f, displayWidgetContext as x } from "@golemui/lit";
3
+ import { unsubscribeAll as m, safeDefine as c } from "@golemui/lit/internals";
4
+ import { consume as u, provide as h } from "@lit/context";
5
+ import { DisplayWidgetAdapter as f, formContext as x, displayWidgetContext as g } from "@golemui/lit";
6
6
  import "@golemui/gui-components/markdown-text";
7
7
  import "rxjs";
8
- var g = Object.defineProperty, o = (i, t, r, b) => {
9
- for (var e = void 0, s = i.length - 1, d; s >= 0; s--)
10
- (d = i[s]) && (e = d(t, r, e) || e);
11
- return e && g(t, r, e), e;
8
+ var b = Object.defineProperty, o = (r, i, e, y) => {
9
+ for (var t = void 0, s = r.length - 1, d; s >= 0; s--)
10
+ (d = r[s]) && (t = d(i, e, t) || t);
11
+ return t && b(i, e, t), t;
12
12
  };
13
13
  class a extends p {
14
14
  constructor() {
15
- super(...arguments), this.adapter = new h(), this.subscriptions = [];
15
+ super(...arguments), this.adapter = new f(), this.subscriptions = [];
16
16
  }
17
17
  createRenderRoot() {
18
18
  return this;
19
19
  }
20
- updated(t) {
21
- super.updated(t);
22
- const r = this.adapter.templateData.size;
23
- r ? this.style.flex = String(r) : this.style.removeProperty("flex");
20
+ updated(i) {
21
+ super.updated(i);
22
+ const e = this.adapter.templateData.size;
23
+ e ? this.style.flex = String(e) : this.style.removeProperty("flex");
24
24
  }
25
25
  connectedCallback() {
26
26
  super.connectedCallback(), this.classList.add("gui-markdown-text", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
@@ -38,17 +38,17 @@ class a extends p {
38
38
  `;
39
39
  }
40
40
  disconnectedCallback() {
41
- super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
41
+ super.disconnectedCallback(), this.adapter.destroy(), m(this.subscriptions);
42
42
  }
43
43
  }
44
44
  o([
45
- c({ context: f }),
45
+ u({ context: x }),
46
46
  l({ attribute: !1 })
47
47
  ], a.prototype, "formContext");
48
48
  o([
49
- u({ context: x })
49
+ h({ context: g })
50
50
  ], a.prototype, "adapter");
51
- m("gui-markdown-text-display", a);
51
+ c("gui-markdown-text-display", a);
52
52
  export {
53
53
  a as MarkdownTextElement
54
54
  };
@@ -3,12 +3,12 @@ import "@golemui/gui-components/markdown";
3
3
  import { consume as h, provide as m } from "@lit/context";
4
4
  import { LitElement as u, html as c } from "lit";
5
5
  import { property as $ } from "lit/decorators.js";
6
- import { safeDefine as D } from "@golemui/lit/internals";
6
+ import { unsubscribeAll as D, safeDefine as b } from "@golemui/lit/internals";
7
7
  import "rxjs";
8
- var b = Object.defineProperty, d = (i, t, e, f) => {
8
+ var f = Object.defineProperty, d = (i, e, t, g) => {
9
9
  for (var a = void 0, r = i.length - 1, p; r >= 0; r--)
10
- (p = i[r]) && (a = p(t, e, a) || a);
11
- return a && b(t, e, a), a;
10
+ (p = i[r]) && (a = p(e, t, a) || a);
11
+ return a && f(e, t, a), a;
12
12
  };
13
13
  class l extends u {
14
14
  constructor() {
@@ -17,10 +17,10 @@ class l extends u {
17
17
  createRenderRoot() {
18
18
  return this;
19
19
  }
20
- updated(t) {
21
- super.updated(t);
22
- const e = this.adapter.templateData.size;
23
- e ? this.style.flex = String(e) : this.style.removeProperty("flex");
20
+ updated(e) {
21
+ super.updated(e);
22
+ const t = this.adapter.templateData.size;
23
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
24
24
  }
25
25
  connectedCallback() {
26
26
  super.connectedCallback(), this.classList.add("gui-markdown", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
@@ -63,12 +63,12 @@ class l extends u {
63
63
  ></gui-markdown>
64
64
  `;
65
65
  }
66
- valueChanged(t) {
67
- const e = t.detail.value;
68
- this.adapter.valueChanged(e);
66
+ valueChanged(e) {
67
+ const t = e.detail.value;
68
+ this.adapter.valueChanged(t);
69
69
  }
70
70
  disconnectedCallback() {
71
- super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
71
+ super.disconnectedCallback(), this.adapter.destroy(), D(this.subscriptions);
72
72
  }
73
73
  }
74
74
  d([
@@ -78,7 +78,7 @@ d([
78
78
  d([
79
79
  m({ context: n })
80
80
  ], l.prototype, "adapter");
81
- D("gui-markdown-input", l);
81
+ b("gui-markdown-input", l);
82
82
  export {
83
83
  l as MarkdownElement
84
84
  };
@@ -0,0 +1,312 @@
1
+ import { InputWidgetAdapter as y, formContext as v, inputContext as D } from "@golemui/lit";
2
+ import { updateListItems as F } from "@golemui/gui-components/internals";
3
+ import { consume as x, provide as L } from "@lit/context";
4
+ import { LitElement as R, nothing as w, html as m } from "lit";
5
+ import { property as C, state as h, query as b } from "lit/decorators.js";
6
+ import { unsubscribeAll as k, safeDefine as V } from "@golemui/lit/internals";
7
+ import { Subject as P, debounceTime as T } from "rxjs";
8
+ import { d as S } from "./default-multi-list-item-renderer-Cv-guvEX.js";
9
+ import "@golemui/gui-components/label";
10
+ import "@golemui/gui-components/multi-list";
11
+ import "@golemui/gui-components/multi-select-trigger";
12
+ import "@golemui/gui-components/errors";
13
+ var A = Object.defineProperty, n = (f, e, t, r) => {
14
+ for (var i = void 0, l = f.length - 1, a; l >= 0; l--)
15
+ (a = f[l]) && (i = a(e, t, i) || i);
16
+ return i && A(e, t, i), i;
17
+ };
18
+ class o extends R {
19
+ constructor() {
20
+ super(...arguments), this.adapter = new y(), this.debouncer = new P(), this.subscriptions = [], this._range = { start: 0, end: 10 }, this._filteredItems = [], this._listItems = [], this._focusedIndex = -1, this._isFiltering = !1, this._isListVisible = !1, this._ignoreNextFocus = !1, this.onDocumentClick = (e) => {
21
+ if (!this._isListVisible) return;
22
+ const t = e.composedPath(), r = this._triggerRef && t.includes(this._triggerRef), i = this._panelRef && t.includes(this._panelRef);
23
+ !r && !i && (this._isListVisible = !1);
24
+ }, this._onToggleMouseDown = (e) => {
25
+ e.preventDefault();
26
+ }, this._onToggleClick = async (e) => {
27
+ e.stopPropagation(), this._isListVisible ? (this._isListVisible = !1, this._isFiltering = !1, this._ignoreNextFocus = !0, this._triggerRef?.focusInput(), setTimeout(() => {
28
+ this._ignoreNextFocus = !1;
29
+ })) : (this._triggerRef?.focusInput(), await this._openPanel());
30
+ };
31
+ }
32
+ createRenderRoot() {
33
+ return this;
34
+ }
35
+ updated(e) {
36
+ super.updated(e);
37
+ const t = this.adapter.templateData.size;
38
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
39
+ }
40
+ connectedCallback() {
41
+ super.connectedCallback(), document.addEventListener("click", this.onDocumentClick), this.classList.add("gui-multi-dropdown", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this._filteredItems = this.adapter.templateData.items, this.subscriptions.push(
42
+ this.adapter.templateDataChanged$.subscribe(() => {
43
+ const e = this.adapter.templateData;
44
+ e.items && this._listItems?.length === 0 && this._filteredItems?.length === 0 && (this._filteredItems = e.items, this._listItems = e.items), this.requestUpdate();
45
+ }),
46
+ this.debouncer.pipe(T(this.adapter.templateData.inputDebounce ?? 500)).subscribe((e) => {
47
+ this._filterItems(e);
48
+ })
49
+ );
50
+ }
51
+ disconnectedCallback() {
52
+ super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.adapter.destroy(), k(this.subscriptions);
53
+ }
54
+ _currentValues() {
55
+ const e = this.adapter.templateData.value;
56
+ return Array.isArray(e) ? e : [];
57
+ }
58
+ _pillItems(e) {
59
+ const t = this.adapter.templateData, r = t.labelField ?? "label", i = F(
60
+ t.items ?? [],
61
+ t
62
+ );
63
+ return e.map((l) => {
64
+ const a = i.find((u) => u.value === l) ?? this._listItems.find((u) => u.value === l), c = a != null && a.template !== null && typeof a.template == "object", s = a == null ? String(l) : String(c ? a.template[r] : a.template);
65
+ return { key: String(l), label: s };
66
+ });
67
+ }
68
+ _toggleValue(e) {
69
+ const t = this.adapter.templateData;
70
+ if (t.disabled || t.readonly) return;
71
+ const r = this._currentValues();
72
+ if (r.includes(e)) {
73
+ this.adapter.valueChanged(r.filter((i) => i !== e));
74
+ return;
75
+ }
76
+ this.adapter.valueChanged([...r, e]);
77
+ }
78
+ async _openPanel() {
79
+ this._triggerRef?.closePillsDropdown(), this._isListVisible = !0, await this.updateComplete, this._listRef?.scrollToSelectedIndex();
80
+ }
81
+ _onRangeChange(e) {
82
+ this._range = { start: e.detail.startIndex, end: e.detail.endIndex };
83
+ }
84
+ _onUpdateItems(e) {
85
+ this._listItems = e.detail || [];
86
+ }
87
+ _onFocusChange(e) {
88
+ this._focusedIndex = e.detail.index;
89
+ }
90
+ _onClickItem(e, t) {
91
+ this.adapter.templateData.readonly || e.disabled || (this._toggleValue(e.value), this._focusedIndex = t, this._listRef && this._listRef.focusItemAtIndex(t));
92
+ }
93
+ _onValueChange(e) {
94
+ this.adapter.templateData.readonly || this._toggleValue(e.detail.value);
95
+ }
96
+ _onPillRemove(e) {
97
+ const t = this._currentValues().find((r) => String(r) === e.detail.key);
98
+ t !== void 0 && this._toggleValue(t);
99
+ }
100
+ _onPillsDropdownToggle(e) {
101
+ e.detail?.open && this._isListVisible && (this._isListVisible = !1);
102
+ }
103
+ async _onKeyDown(e) {
104
+ e.key === "ArrowDown" && (e.preventDefault(), await this._openPanel(), this._listRef?.focus());
105
+ }
106
+ _onInput(e) {
107
+ const t = e.target.value;
108
+ this.debouncer.next(t);
109
+ }
110
+ _filterItems(e) {
111
+ const t = this.adapter.templateData, r = !!this.widget.on?.filter;
112
+ if (this.adapter.filterChanged(e), e && !r) {
113
+ this._isFiltering = !0, this._isListVisible = !0;
114
+ const i = t.searchFields ?? [t.labelField, t.valueField].filter(
115
+ (s) => !!s
116
+ ), l = i.length > 0, c = (t.items || []).filter((s) => {
117
+ if (s === null || typeof s != "object")
118
+ return s != null && s.toString().toLowerCase().includes(e.toLowerCase());
119
+ const d = Object.keys(s), p = (g, _) => g || s[_].toString().toLowerCase().includes(e.toLowerCase());
120
+ return l ? d.filter((g) => i.includes(g)).reduce(p, !1) : d.reduce(p, !1);
121
+ });
122
+ this._filteredItems = [...c];
123
+ } else
124
+ this._isFiltering = !1, this._filteredItems = [...t.items];
125
+ }
126
+ _onWidgetKeyDown(e) {
127
+ e.key !== "Escape" || !this._isListVisible || (e.preventDefault(), e.stopPropagation(), this._isListVisible = !1, this._isFiltering = !1, this._ignoreNextFocus = !0, this._triggerRef?.focusInput(), setTimeout(() => {
128
+ this._ignoreNextFocus = !1;
129
+ }));
130
+ }
131
+ async _onFocusIn(e) {
132
+ if (this._ignoreNextFocus) return;
133
+ const t = this._triggerRef?.input, r = this._listRef && e.target === this._listRef;
134
+ e.target !== t && !r || await this._openPanel();
135
+ }
136
+ _onPanelMouseDown(e) {
137
+ const t = e.target;
138
+ this._listRef && this._listRef.contains(t) || e.preventDefault();
139
+ }
140
+ _onFocusOut(e) {
141
+ const t = e.relatedTarget;
142
+ t && this.contains(t) || (this.adapter.onBlur(), this._isListVisible = !1, this._isFiltering = !1);
143
+ }
144
+ render() {
145
+ const e = this.adapter.templateData, t = e.touched && e.errors && e.errors.length > 0, r = this._listItems.slice(this._range.start, this._range.end), i = this._currentValues(), l = this._pillItems(i), a = this.adapter.getItemRenderer(
146
+ e.itemRenderer,
147
+ S
148
+ ), c = !!this.widget.on?.filter;
149
+ return m`
150
+ <gui-label
151
+ .targetElement=${[this._listRef, this._triggerRef?.input]}
152
+ .uid=${this.widget.uid}
153
+ .label=${e.label}
154
+ .hint=${e.hint}
155
+ .errors=${e.errors}
156
+ .touched=${e.touched}
157
+ .required=${e.validator?.required}
158
+ .native=${!1}
159
+ ></gui-label>
160
+
161
+ <div class="gui-widget" @keydown=${this._onWidgetKeyDown} @focusout=${this._onFocusOut}>
162
+ <gui-multi-select-trigger
163
+ .uid=${this.widget.uid}
164
+ .pills=${l}
165
+ .errors=${e.errors}
166
+ .touched=${!!e.touched}
167
+ ?required=${e.validator?.required}
168
+ ?disabled=${e.disabled}
169
+ ?readonly=${e.readonly}
170
+ .placeholder=${e.placeholder ?? ""}
171
+ .icon=${e.icon}
172
+ .autocomplete=${e.autocomplete}
173
+ .hasLabel=${!!e.label}
174
+ .hasHint=${!!e.hint}
175
+ .panelOpen=${this._isListVisible}
176
+ .panelId=${`${this.widget.uid}-list`}
177
+ .removeAriaLabel=${e.removeAriaLabel}
178
+ .removeIcon=${e.removeIcon}
179
+ .compactAriaLabel=${`${l.length} selected`}
180
+ @keydown=${this._onKeyDown}
181
+ @input=${this._onInput}
182
+ @focusin=${this._onFocusIn}
183
+ @pillremove=${this._onPillRemove}
184
+ @dropdowntoggle=${this._onPillsDropdownToggle}
185
+ ></gui-multi-select-trigger>
186
+ <button
187
+ type="button"
188
+ class="gui-dropdown__arrow"
189
+ aria-label=${e.toggleAriaLabel ?? "Show options"}
190
+ aria-haspopup="listbox"
191
+ aria-expanded=${this._isListVisible ? "true" : "false"}
192
+ aria-controls=${`${this.widget.uid}-list`}
193
+ ?disabled=${e.disabled}
194
+ @mousedown=${this._onToggleMouseDown}
195
+ @click=${this._onToggleClick}
196
+ >
197
+ <svg
198
+ xmlns="http://www.w3.org/2000/svg"
199
+ width="16"
200
+ height="16"
201
+ viewBox="0 0 256 256"
202
+ aria-hidden="true"
203
+ >
204
+ <path
205
+ 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"
206
+ ></path>
207
+ </svg>
208
+ </button>
209
+
210
+ <div
211
+ class="gui-picker__panel"
212
+ ?hidden=${!this._isListVisible}
213
+ @mousedown=${this._onPanelMouseDown}
214
+ >
215
+ <gui-multi-list
216
+ id=${`${this.widget.uid}-list`}
217
+ .uid=${this.widget.uid}
218
+ .values=${i}
219
+ .valueField=${e.valueField}
220
+ .items=${this._isFiltering && !c ? this._filteredItems : e.items}
221
+ .itemHeight=${e.itemHeight}
222
+ .height=${e.height}
223
+ ?required=${e.validator?.required}
224
+ ?touched=${e.touched}
225
+ ?disabled=${e.disabled}
226
+ ?readonly=${e.readonly}
227
+ ?hidden=${!this._isListVisible}
228
+ @gui-range-change=${this._onRangeChange}
229
+ @gui-update-items=${this._onUpdateItems}
230
+ @gui-focus-change=${this._onFocusChange}
231
+ @change=${this._onValueChange}
232
+ >
233
+ ${r.map((s, u) => {
234
+ const d = this._range.start + u, p = i.includes(s.value), g = this._focusedIndex === d, _ = !!e.disabled || !!s.disabled, $ = e.labelField ?? "label", I = s.template !== null && typeof s.template == "object" && $ && !e.itemRenderer ? s.template[$] : s.template;
235
+ return m`
236
+ <div
237
+ role="option"
238
+ tabindex="-1"
239
+ class="gui-list__item-wrapper"
240
+ id="${this.widget.uid}-item-${d}"
241
+ style="height: ${e.itemHeight || 40}px"
242
+ aria-selected=${p ? "true" : "false"}
243
+ aria-disabled=${_ ? "true" : "false"}
244
+ @click=${() => this._onClickItem(s, d)}
245
+ >
246
+ ${a({
247
+ template: I,
248
+ value: s.value,
249
+ index: d,
250
+ selected: p,
251
+ disabled: _,
252
+ focused: g
253
+ })}
254
+ </div>
255
+ `;
256
+ })}
257
+ </gui-multi-list>
258
+ ${t ? m`<gui-errors
259
+ panel
260
+ .uid=${this.widget.uid}
261
+ .errors=${e.errors}
262
+ .touched=${e.touched}
263
+ ></gui-errors>` : w}
264
+ </div>
265
+ </div>
266
+
267
+ ${t ? m`<gui-errors
268
+ .uid=${this.widget.uid}
269
+ .errors=${e.errors}
270
+ .touched=${e.touched}
271
+ ></gui-errors>` : w}
272
+ `;
273
+ }
274
+ }
275
+ n([
276
+ x({ context: v }),
277
+ C({ attribute: !1 })
278
+ ], o.prototype, "formContext");
279
+ n([
280
+ L({ context: D })
281
+ ], o.prototype, "adapter");
282
+ n([
283
+ h()
284
+ ], o.prototype, "_range");
285
+ n([
286
+ h()
287
+ ], o.prototype, "_filteredItems");
288
+ n([
289
+ h()
290
+ ], o.prototype, "_listItems");
291
+ n([
292
+ h()
293
+ ], o.prototype, "_focusedIndex");
294
+ n([
295
+ h()
296
+ ], o.prototype, "_isFiltering");
297
+ n([
298
+ h()
299
+ ], o.prototype, "_isListVisible");
300
+ n([
301
+ b("gui-multi-select-trigger")
302
+ ], o.prototype, "_triggerRef");
303
+ n([
304
+ b("gui-multi-list")
305
+ ], o.prototype, "_listRef");
306
+ n([
307
+ b(".gui-picker__panel")
308
+ ], o.prototype, "_panelRef");
309
+ V("gui-multi-dropdown-input", o);
310
+ export {
311
+ o as MultiDropdownElement
312
+ };