@golemui/gui-lit 0.0.2

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 +529 -0
  2. package/README.md +7 -0
  3. package/accordion.element-D1RfC2ew.js +92 -0
  4. package/alert.element-B4rpyqGV.js +55 -0
  5. package/button.element-BnUBVNSH.js +58 -0
  6. package/calendar.element-D7mAbpAa.js +70 -0
  7. package/checkbox.element--Kc7sWBx.js +65 -0
  8. package/currency.element-D9dyGRBH.js +71 -0
  9. package/date-picker.element-Dcs5OpxN.js +136 -0
  10. package/date.element-na_Uywms.js +74 -0
  11. package/default-list-item-renderer-DNVEjKSX.js +23 -0
  12. package/dropdown.element-Cfj40aJz.js +225 -0
  13. package/flex.element-BSMOum-h.js +65 -0
  14. package/index.d.ts +2 -0
  15. package/index.js +2254 -0
  16. package/index.umd.cjs +535 -0
  17. package/lib/components/accordion.element.d.ts +21 -0
  18. package/lib/components/alert.element.d.ts +16 -0
  19. package/lib/components/button.element.d.ts +15 -0
  20. package/lib/components/calendar.element.d.ts +16 -0
  21. package/lib/components/checkbox.element.d.ts +17 -0
  22. package/lib/components/currency.element.d.ts +17 -0
  23. package/lib/components/date-picker.element.d.ts +26 -0
  24. package/lib/components/date.element.d.ts +18 -0
  25. package/lib/components/default-list-item-renderer.d.ts +2 -0
  26. package/lib/components/dropdown.element.d.ts +38 -0
  27. package/lib/components/flex.element.d.ts +16 -0
  28. package/lib/components/form.element.d.ts +21 -0
  29. package/lib/components/list.element.d.ts +25 -0
  30. package/lib/components/number.element.d.ts +17 -0
  31. package/lib/components/password.element.d.ts +17 -0
  32. package/lib/components/radiogroup.element.d.ts +17 -0
  33. package/lib/components/range-calendar.element.d.ts +16 -0
  34. package/lib/components/renderer.element.d.ts +15 -0
  35. package/lib/components/repeater.element.d.ts +18 -0
  36. package/lib/components/select.element.d.ts +18 -0
  37. package/lib/components/tabs.element.d.ts +27 -0
  38. package/lib/components/textarea.element.d.ts +17 -0
  39. package/lib/components/textinput.element.d.ts +17 -0
  40. package/lib/components/toggle.element.d.ts +17 -0
  41. package/lib/widget.loaders.d.ts +4 -0
  42. package/list.element--aj6sNNU.js +138 -0
  43. package/number.element-Bl5YReaL.js +69 -0
  44. package/package.json +34 -0
  45. package/password.element-CKmcH8Gn.js +70 -0
  46. package/radiogroup.element-Cn1lyyVE.js +67 -0
  47. package/range-calendar.element-C2YUElqM.js +70 -0
  48. package/renderer.element-B7AjPqr2.js +43 -0
  49. package/repeater.element-BfwzCooC.js +83 -0
  50. package/select.element-LWiqYxzA.js +73 -0
  51. package/tabs.element-DYg1wAz9.js +158 -0
  52. package/textarea.element-BXc-rLZE.js +70 -0
  53. package/textinput.element-x9LYeW8B.js +66 -0
  54. package/toggle.element-BP4YKWyR.js +65 -0
@@ -0,0 +1,69 @@
1
+ import * as l from "@golemui/lit";
2
+ import { consume as u, provide as n } from "@lit/context";
3
+ import { LitElement as m, html as h } from "lit";
4
+ import { property as c, customElement as b } from "lit/decorators.js";
5
+ var f = Object.defineProperty, D = Object.getOwnPropertyDescriptor, o = (e, t, i, r) => {
6
+ for (var a = r > 1 ? void 0 : r ? D(t, i) : t, p = e.length - 1, d; p >= 0; p--)
7
+ (d = e[p]) && (a = (r ? d(t, i, a) : d(a)) || a);
8
+ return r && a && f(t, i, a), a;
9
+ };
10
+ let s = class extends m {
11
+ constructor() {
12
+ super(...arguments), this.adapter = new l.InputWidgetAdapter(), this.subscriptions = [];
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-number"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
19
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
20
+ );
21
+ }
22
+ updated(e) {
23
+ super.updated(e);
24
+ const t = this.adapter.templateData.size;
25
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
26
+ }
27
+ render() {
28
+ return super.render(), h`
29
+ <gui-number
30
+ .uid=${this.widget.uid}
31
+ .label=${this.adapter.templateData.label}
32
+ .hint=${this.adapter.templateData.hint}
33
+ .errors=${this.adapter.templateData.errors}
34
+ ?touched=${this.adapter.templateData.touched}
35
+ ?required=${this.adapter.templateData.validator?.required}
36
+ ?disabled=${this.adapter.templateData.disabled}
37
+ ?readonly=${this.adapter.templateData.readonly}
38
+ .value=${this.adapter.templateData.value}
39
+ .step=${this.adapter.templateData.step}
40
+ .minimum=${this.adapter.templateData.minimum}
41
+ .maximum=${this.adapter.templateData.maximum}
42
+ .autoGrow=${this.adapter.templateData.autoGrow}
43
+ .placeholder=${this.adapter.templateData.placeholder}
44
+ @input=${this.valueChanged}
45
+ @blur=${() => this.adapter.onBlur()}
46
+ ></gui-number>
47
+ `;
48
+ }
49
+ valueChanged(e) {
50
+ const t = e.detail.value;
51
+ this.adapter.valueChanged(t);
52
+ }
53
+ disconnectedCallback() {
54
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
55
+ }
56
+ };
57
+ o([
58
+ u({ context: l.formContext }),
59
+ c({ attribute: !1 })
60
+ ], s.prototype, "formContext", 2);
61
+ o([
62
+ n({ context: l.inputContext })
63
+ ], s.prototype, "adapter", 2);
64
+ s = o([
65
+ b("gui-number-input")
66
+ ], s);
67
+ export {
68
+ s as NumberElement
69
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@golemui/gui-lit",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "main": "./index.umd.cjs",
6
+ "module": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js",
12
+ "require": "./index.umd.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "lib",
17
+ "index.d.ts",
18
+ "index.js",
19
+ "index.umd.cjs",
20
+ "*.js",
21
+ "*.md"
22
+ ],
23
+ "peerDependencies": {
24
+ "@golemui/lit": "*",
25
+ "@golemui/core": "*",
26
+ "@golemui/gui-components": "*",
27
+ "@golemui/gui-shared": "*",
28
+ "@golemui/gui-validators": "*",
29
+ "@lit/context": "^1.1.6",
30
+ "lit-html": "^3.3.1",
31
+ "lit": "^3.3.1",
32
+ "rxjs": "^7.8.0"
33
+ }
34
+ }
@@ -0,0 +1,70 @@
1
+ import * as o from "@golemui/lit";
2
+ import { consume as n, provide as h } from "@lit/context";
3
+ import { LitElement as u, html as c } from "lit";
4
+ import { property as m, customElement as b } from "lit/decorators.js";
5
+ var w = Object.defineProperty, D = Object.getOwnPropertyDescriptor, l = (e, t, i, s) => {
6
+ for (var a = s > 1 ? void 0 : s ? D(t, i) : t, d = e.length - 1, p; d >= 0; d--)
7
+ (p = e[d]) && (a = (s ? p(t, i, a) : p(a)) || a);
8
+ return s && a && w(t, i, a), a;
9
+ };
10
+ let r = class extends u {
11
+ constructor() {
12
+ super(...arguments), this.adapter = new o.InputWidgetAdapter(), this.subscriptions = [];
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-password"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
19
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
20
+ );
21
+ }
22
+ updated(e) {
23
+ super.updated(e);
24
+ const t = this.adapter.templateData.size;
25
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
26
+ }
27
+ render() {
28
+ return super.render(), c`
29
+ <gui-password
30
+ .uid=${this.widget.uid}
31
+ .label=${this.adapter.templateData.label}
32
+ .hint=${this.adapter.templateData.hint}
33
+ .errors=${this.adapter.templateData.errors}
34
+ ?touched=${this.adapter.templateData.touched}
35
+ ?required=${this.adapter.templateData.validator?.required}
36
+ ?disabled=${this.adapter.templateData.disabled}
37
+ ?readonly=${this.adapter.templateData.readonly}
38
+ .value=${this.adapter.templateData.value}
39
+ .icon=${this.adapter.templateData.icon}
40
+ .placeholder=${this.adapter.templateData.placeholder}
41
+ .showPasswordIcon=${this.adapter.templateData.showPasswordIcon}
42
+ .hidePasswordIcon=${this.adapter.templateData.hidePasswordIcon}
43
+ .showPasswordLabel=${this.adapter.templateData.showPasswordLabel}
44
+ .hidePasswordLabel=${this.adapter.templateData.hidePasswordLabel}
45
+ @input=${this.valueChanged}
46
+ @blur=${() => this.adapter.onBlur()}
47
+ ></gui-password>
48
+ `;
49
+ }
50
+ valueChanged(e) {
51
+ const t = e.detail.value;
52
+ this.adapter.valueChanged(t);
53
+ }
54
+ disconnectedCallback() {
55
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
56
+ }
57
+ };
58
+ l([
59
+ n({ context: o.formContext }),
60
+ m({ attribute: !1 })
61
+ ], r.prototype, "formContext", 2);
62
+ l([
63
+ h({ context: o.inputContext })
64
+ ], r.prototype, "adapter", 2);
65
+ r = l([
66
+ b("gui-password-input")
67
+ ], r);
68
+ export {
69
+ r as PasswordElement
70
+ };
@@ -0,0 +1,67 @@
1
+ import * as o from "@golemui/lit";
2
+ import { consume as n, provide as u } from "@lit/context";
3
+ import { LitElement as h, html as c } from "lit";
4
+ import { property as m, customElement as b } from "lit/decorators.js";
5
+ var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, l = (e, t, s, r) => {
6
+ for (var a = r > 1 ? void 0 : r ? v(t, s) : t, p = e.length - 1, d; p >= 0; p--)
7
+ (d = e[p]) && (a = (r ? d(t, s, a) : d(a)) || a);
8
+ return r && a && g(t, s, a), a;
9
+ };
10
+ let i = class extends h {
11
+ constructor() {
12
+ super(...arguments), this.adapter = new o.InputWidgetAdapter(), this.subscriptions = [];
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-radiogroup"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
19
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
20
+ );
21
+ }
22
+ updated(e) {
23
+ super.updated(e);
24
+ const t = this.adapter.templateData.size;
25
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
26
+ }
27
+ render() {
28
+ return super.render(), c`
29
+ <gui-radiogroup
30
+ .uid=${this.widget.uid}
31
+ .label=${this.adapter.templateData.label}
32
+ .errors=${this.adapter.templateData.errors}
33
+ ?touched=${this.adapter.templateData.touched}
34
+ ?required=${this.adapter.templateData.validator?.required}
35
+ ?disabled=${this.adapter.templateData.disabled}
36
+ ?readonly=${this.adapter.templateData.readonly}
37
+ .value=${this.adapter.templateData.value}
38
+ .hint=${this.adapter.templateData.hint}
39
+ .options=${this.adapter.templateData.options}
40
+ .labelField=${this.adapter.templateData.labelField}
41
+ .valueField=${this.adapter.templateData.valueField}
42
+ @change=${this.valueChanged}
43
+ @blur=${() => this.adapter.onBlur()}
44
+ ></gui-radiogroup>
45
+ `;
46
+ }
47
+ valueChanged(e) {
48
+ const t = e.detail.value;
49
+ this.adapter.valueChanged(t);
50
+ }
51
+ disconnectedCallback() {
52
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
53
+ }
54
+ };
55
+ l([
56
+ n({ context: o.formContext }),
57
+ m({ attribute: !1 })
58
+ ], i.prototype, "formContext", 2);
59
+ l([
60
+ u({ context: o.inputContext })
61
+ ], i.prototype, "adapter", 2);
62
+ i = l([
63
+ b("gui-radiogroup-input")
64
+ ], i);
65
+ export {
66
+ i as RadiogroupElement
67
+ };
@@ -0,0 +1,70 @@
1
+ import * as d from "@golemui/lit";
2
+ import { consume as l, provide as h } from "@lit/context";
3
+ import { LitElement as m, html as c } from "lit";
4
+ import { property as u, customElement as D } from "lit/decorators.js";
5
+ var b = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, o = (a, e, n, r) => {
6
+ for (var t = r > 1 ? void 0 : r ? $(e, n) : e, i = a.length - 1, p; i >= 0; i--)
7
+ (p = a[i]) && (t = (r ? p(e, n, t) : p(t)) || t);
8
+ return r && t && b(e, n, t), t;
9
+ };
10
+ let s = class extends m {
11
+ constructor() {
12
+ super(...arguments), this.adapter = new d.InputWidgetAdapter(), this.subscriptions = [];
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-calendar"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
19
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
20
+ );
21
+ }
22
+ render() {
23
+ return super.render(), c`
24
+ <gui-range-calendar
25
+ .uid=${this.widget.uid}
26
+ .label=${this.adapter.templateData.label}
27
+ .hint=${this.adapter.templateData.hint}
28
+ .errors=${this.adapter.templateData.errors}
29
+ ?touched=${this.adapter.templateData.touched}
30
+ ?required=${this.adapter.templateData.validator?.required}
31
+ ?disabled=${this.adapter.templateData.disabled}
32
+ ?readonly=${this.adapter.templateData.readonly}
33
+ .value=${this.adapter.templateData.value}
34
+ .prevMonthIcon=${this.adapter.templateData.prevMonthIcon}
35
+ .nextMonthIcon=${this.adapter.templateData.nextMonthIcon}
36
+ .prevMonthAriaLabel=${this.adapter.templateData.prevMonthAriaLabel}
37
+ .nextMonthAriaLabel=${this.adapter.templateData.nextMonthAriaLabel}
38
+ .dayFormat=${this.adapter.templateData.dayFormat}
39
+ .weekdayFormat=${this.adapter.templateData.weekdayFormat}
40
+ .monthFormat=${this.adapter.templateData.monthFormat}
41
+ .minDate=${this.adapter.templateData.minDate}
42
+ .maxDate=${this.adapter.templateData.maxDate}
43
+ .disabledRanges=${this.adapter.templateData.disabledRanges}
44
+ .numberOfMonths=${this.adapter.templateData.numberOfMonths}
45
+ .localeId=${this.adapter.templateData.lang}
46
+ @change=${this.valueChanged}
47
+ ></gui-range-calendar>
48
+ `;
49
+ }
50
+ valueChanged(a) {
51
+ const e = a?.target;
52
+ this.adapter.valueChanged(e.value);
53
+ }
54
+ disconnectedCallback() {
55
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((a) => a.unsubscribe());
56
+ }
57
+ };
58
+ o([
59
+ l({ context: d.formContext }),
60
+ u({ attribute: !1 })
61
+ ], s.prototype, "formContext", 2);
62
+ o([
63
+ h({ context: d.inputContext })
64
+ ], s.prototype, "adapter", 2);
65
+ s = o([
66
+ D("gui-range-calendar-input")
67
+ ], s);
68
+ export {
69
+ s as RangeCalendarElement
70
+ };
@@ -0,0 +1,43 @@
1
+ import * as p from "@golemui/lit";
2
+ import { consume as c, provide as l } from "@lit/context";
3
+ import { LitElement as u, html as m } from "lit";
4
+ import { property as h, customElement as b } from "lit/decorators.js";
5
+ var f = Object.defineProperty, g = Object.getOwnPropertyDescriptor, d = (e, r, a, s) => {
6
+ for (var t = s > 1 ? void 0 : s ? g(r, a) : r, o = e.length - 1, n; o >= 0; o--)
7
+ (n = e[o]) && (t = (s ? n(r, a, t) : n(t)) || t);
8
+ return s && t && f(r, a, t), t;
9
+ };
10
+ let i = class extends u {
11
+ constructor() {
12
+ super(...arguments), this.adapter = new p.DisplayWidgetAdapter(), this.subscriptions = [];
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-renderer"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
19
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
20
+ );
21
+ }
22
+ render() {
23
+ return m`
24
+ <div class="gui-widget" id=${this.widget.uid}>${this.adapter.templateData.render}</div>
25
+ `;
26
+ }
27
+ disconnectedCallback() {
28
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
29
+ }
30
+ };
31
+ d([
32
+ c({ context: p.formContext }),
33
+ h({ attribute: !1 })
34
+ ], i.prototype, "formContext", 2);
35
+ d([
36
+ l({ context: p.displayWidgetContext })
37
+ ], i.prototype, "adapter", 2);
38
+ i = d([
39
+ b("gui-renderer-component")
40
+ ], i);
41
+ export {
42
+ i as RendererElement
43
+ };
@@ -0,0 +1,83 @@
1
+ import * as o from "@golemui/lit";
2
+ import { consume as u, provide as h } from "@lit/context";
3
+ import { LitElement as m, nothing as c, html as n } from "lit";
4
+ import { repeat as b } from "lit-html/directives/repeat.js";
5
+ import { property as v, customElement as g } from "lit/decorators.js";
6
+ var f = Object.defineProperty, D = Object.getOwnPropertyDescriptor, l = (e, t, s, r) => {
7
+ for (var a = r > 1 ? void 0 : r ? D(t, s) : t, p = e.length - 1, d; p >= 0; p--)
8
+ (d = e[p]) && (a = (r ? d(t, s, a) : d(a)) || a);
9
+ return r && a && f(t, s, a), a;
10
+ };
11
+ let i = class extends m {
12
+ constructor() {
13
+ super(...arguments), this.adapter = new o.InputWidgetAdapter(), this.subscriptions = [];
14
+ }
15
+ createRenderRoot() {
16
+ return this;
17
+ }
18
+ connectedCallback() {
19
+ super.connectedCallback(), this.classList.add("gui-repeater"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
20
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
21
+ );
22
+ }
23
+ updated(e) {
24
+ super.updated(e);
25
+ const t = this.adapter.templateData.size;
26
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
27
+ }
28
+ render() {
29
+ return super.render(), n`
30
+ <div id=${this.widget.uid}>
31
+ <h2>${this.adapter.templateData.label}</h2>
32
+
33
+ ${this.adapter.templateData.value ? b(
34
+ this.adapter.templateData.value,
35
+ (e) => e.uid,
36
+ (e, t) => n`
37
+ <div class="card">
38
+ <gui-repeater-widget
39
+ .repeaterIndex=${t}
40
+ .widget=${this.adapter.templateData.template}
41
+ ></gui-repeater-widget>
42
+ <button type="button" class="gui-button" @click=${() => this.removeItem(t)}>
43
+ ${this.adapter.templateData.removeLabel ?? "Remove"}
44
+ </button>
45
+ </div>
46
+ `
47
+ ) : c}
48
+
49
+ <button
50
+ type="button"
51
+ class="gui-button"
52
+ @click=${() => this.addItem()}
53
+ ?disabled=${!!(this.adapter.templateData.limit && this.adapter.templateData.limit === this.adapter.templateData.value?.length)}
54
+ >
55
+ ${this.adapter.templateData.addLabel ?? "Add"}
56
+ </button>
57
+ </div>
58
+ `;
59
+ }
60
+ disconnectedCallback() {
61
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
62
+ }
63
+ addItem() {
64
+ this.adapter.valueChanged([...this.adapter.templateData.value ?? [], {}]), this.requestUpdate();
65
+ }
66
+ removeItem(e) {
67
+ const t = [...this.adapter.templateData.value ?? []];
68
+ t.splice(e, 1), this.adapter.valueChanged(t), this.requestUpdate();
69
+ }
70
+ };
71
+ l([
72
+ u({ context: o.formContext }),
73
+ v({ attribute: !1 })
74
+ ], i.prototype, "formContext", 2);
75
+ l([
76
+ h({ context: o.inputContext })
77
+ ], i.prototype, "adapter", 2);
78
+ i = l([
79
+ g("gui-repeater-input")
80
+ ], i);
81
+ export {
82
+ i as RepeaterElement
83
+ };
@@ -0,0 +1,73 @@
1
+ import * as d from "@golemui/lit";
2
+ import { consume as n, provide as u } from "@lit/context";
3
+ import { LitElement as h, html as c } from "lit";
4
+ import { property as m, customElement as b } from "lit/decorators.js";
5
+ var v = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, o = (t, e, i, r) => {
6
+ for (var a = r > 1 ? void 0 : r ? $(e, i) : e, l = t.length - 1, p; l >= 0; l--)
7
+ (p = t[l]) && (a = (r ? p(e, i, a) : p(a)) || a);
8
+ return r && a && v(e, i, a), a;
9
+ };
10
+ let s = class extends h {
11
+ constructor() {
12
+ super(...arguments), this.adapter = new d.InputWidgetAdapter(), this.subscriptions = [];
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-select"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
19
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
20
+ );
21
+ }
22
+ updated(t) {
23
+ super.updated(t);
24
+ const e = this.adapter.templateData.size;
25
+ e ? this.style.flex = String(e) : this.style.removeProperty("flex");
26
+ }
27
+ render() {
28
+ return super.render(), c`
29
+ <gui-select
30
+ .uid=${this.widget.uid}
31
+ .label=${this.adapter.templateData.label}
32
+ .errors=${this.adapter.templateData.errors}
33
+ ?touched=${this.adapter.templateData.touched}
34
+ ?required=${this.adapter.templateData.validator?.required}
35
+ ?disabled=${this.adapter.templateData.disabled}
36
+ ?readonly=${this.adapter.templateData.readonly}
37
+ .value=${this.adapter.templateData.value}
38
+ .hint=${this.adapter.templateData.hint}
39
+ .icon=${this.adapter.templateData.icon}
40
+ .placeholder=${this.adapter.templateData.placeholder}
41
+ .options=${this.adapter.templateData.options}
42
+ .labelField=${this.adapter.templateData.labelField}
43
+ .valueField=${this.adapter.templateData.valueField}
44
+ @change=${this.valueChanged}
45
+ @inputError=${this.onInputError}
46
+ @blur=${() => this.adapter.onBlur()}
47
+ ></gui-select>
48
+ `;
49
+ }
50
+ valueChanged(t) {
51
+ const e = t.detail.value;
52
+ this.adapter.valueChanged(e);
53
+ }
54
+ onInputError(t) {
55
+ this.adapter.injectValidationIssues([t.detail.message]);
56
+ }
57
+ disconnectedCallback() {
58
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
59
+ }
60
+ };
61
+ o([
62
+ n({ context: d.formContext }),
63
+ m({ attribute: !1 })
64
+ ], s.prototype, "formContext", 2);
65
+ o([
66
+ u({ context: d.inputContext })
67
+ ], s.prototype, "adapter", 2);
68
+ s = o([
69
+ b("gui-select-input")
70
+ ], s);
71
+ export {
72
+ s as SelectElement
73
+ };
@@ -0,0 +1,158 @@
1
+ import * as c from "@golemui/lit";
2
+ import { createIntersectionObserver as p } from "@golemui/gui-components";
3
+ import { consume as m, provide as v } from "@lit/context";
4
+ import { LitElement as w, html as d, nothing as $ } from "lit";
5
+ import { repeat as u } from "lit-html/directives/repeat.js";
6
+ import { query as b, state as g, queryAll as y, property as f, customElement as T } from "lit/decorators.js";
7
+ import { classMap as h } from "lit/directives/class-map.js";
8
+ import { ifDefined as _ } from "lit-html/directives/if-defined.js";
9
+ var x = Object.defineProperty, C = Object.getOwnPropertyDescriptor, o = (s, i, e, t) => {
10
+ for (var r = t > 1 ? void 0 : t ? C(i, e) : i, a = s.length - 1, l; a >= 0; a--)
11
+ (l = s[a]) && (r = (t ? l(i, e, r) : l(r)) || r);
12
+ return t && r && x(i, e, r), r;
13
+ };
14
+ let n = class extends w {
15
+ constructor() {
16
+ super(...arguments), this.activeTab = "", this.adapter = new c.LayoutWidgetAdapter(), this.subscriptions = [];
17
+ }
18
+ createRenderRoot() {
19
+ return this;
20
+ }
21
+ connectedCallback() {
22
+ super.connectedCallback(), this.classList.add("gui-tabs");
23
+ const s = this.widget.props;
24
+ this.adapter.context = this.formContext, this.adapter.init(this.widget), this.activeTab = s.defaultOpen ?? s.tabs[0].uid, this.subscriptions.push(
25
+ this.adapter.templateDataChanged$.subscribe(() => {
26
+ this.requestUpdate();
27
+ })
28
+ );
29
+ }
30
+ updated(s) {
31
+ super.updated(s);
32
+ const i = this.adapter.templateData.size;
33
+ i ? this.style.flex = String(i) : this.style.removeProperty("flex");
34
+ }
35
+ firstUpdated(s) {
36
+ this.startObserver = p(
37
+ this.startSentinel,
38
+ (t) => this.isStartVisible = t
39
+ ), this.endObserver = p(
40
+ this.endSentinel,
41
+ (t) => this.isEndVisible = t
42
+ );
43
+ const e = this.widget.props.tabs.findIndex((t) => t.uid === this.activeTab);
44
+ this.tabButtons[e].scrollIntoView();
45
+ }
46
+ render() {
47
+ if (!this.adapter.templateData) return d``;
48
+ const s = this.widget.children.filter(
49
+ (e) => e.uid === this.activeTab || this.adapter.templateData.renderMode !== "activeOnly"
50
+ ), i = {
51
+ "gui-widget": !0,
52
+ "gui-widget--horizontal": !0,
53
+ "gui-tabs--start-shadow": !this.isStartVisible,
54
+ "gui-tabs--end-shadow": !this.isEndVisible
55
+ };
56
+ return d`<nav class=${h(i)} id=${this.widget.uid}>
57
+ <ul role="tablist">
58
+ <li role="presentation" id="start-sentinel" class="gui-sentinel"></li>
59
+ ${this.adapter.templateData.tabs ? u(
60
+ this.adapter.templateData.tabs,
61
+ (e, t) => d`
62
+ <li role="presentation">
63
+ <button
64
+ type="button"
65
+ role="tab"
66
+ tabindex=${_(e.uid === this.activeTab ? void 0 : -1)}
67
+ data-cy=${`tab_${this.widget.uid}_${t}`}
68
+ id=${`tab_${this.widget.uid}_${t}`}
69
+ aria-controls=${`tabpanel_${this.widget.uid}_${t}`}
70
+ aria-selected=${e.uid === this.activeTab ? "true" : "false"}
71
+ class=${h({ active: e.uid === this.activeTab })}
72
+ @click=${() => this.onClickTab(e.uid)}
73
+ @keydown=${this.onKeyDown}
74
+ @focus=${(r) => r.target.scrollIntoView()}
75
+ >
76
+ ${e.label}
77
+ </button>
78
+ </li>
79
+ `
80
+ ) : $}
81
+ <li role="presentation" id="end-sentinel" class="gui-sentinel"></li>
82
+ </ul>
83
+ </nav>
84
+ ${u(
85
+ s,
86
+ (e) => e?.uid,
87
+ (e, t) => d`<section
88
+ role="tabpanel"
89
+ data-cy=${`tabpanel_${this.widget.uid}_${t}`}
90
+ id=${`tabpanel_${this.widget.uid}_${t}`}
91
+ ?hidden=${e.uid !== this.activeTab && this.adapter.templateData.renderMode !== "activeOnly"}
92
+ aria-labelledby=${`tab_${this.widget.uid}_${t}`}
93
+ >
94
+ <gui-widget .widget=${e}></gui-widget>
95
+ </section>`
96
+ )}`;
97
+ }
98
+ disconnectedCallback() {
99
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((s) => s.unsubscribe()), this.startObserver?.disconnect(), this.endObserver?.disconnect();
100
+ }
101
+ onClickTab(s) {
102
+ this.activeTab = s, this.adapter.change(s), this.requestUpdate();
103
+ }
104
+ onKeyDown(s) {
105
+ const i = this.widget.props.tabs, e = i.findIndex((a) => a.uid === this.activeTab), t = Array.from(this.tabButtons), r = window.getComputedStyle(this).direction === "rtl";
106
+ switch (s.key) {
107
+ case "ArrowLeft": {
108
+ const a = e + (r ? 1 : -1);
109
+ a >= 0 && a < i.length && (this.activeTab = i[a].uid, t[a].focus());
110
+ break;
111
+ }
112
+ case "ArrowRight": {
113
+ const a = e + (r ? -1 : 1);
114
+ a >= 0 && a < i.length && (this.activeTab = i[a].uid, t[a].focus());
115
+ break;
116
+ }
117
+ case "Home":
118
+ this.activeTab = i[0].uid, t[0].focus();
119
+ break;
120
+ case "End":
121
+ this.activeTab = i[i.length - 1].uid, t[i.length - 1].focus();
122
+ break;
123
+ default:
124
+ return;
125
+ }
126
+ }
127
+ };
128
+ o([
129
+ b("#start-sentinel")
130
+ ], n.prototype, "startSentinel", 2);
131
+ o([
132
+ b("#end-sentinel")
133
+ ], n.prototype, "endSentinel", 2);
134
+ o([
135
+ g()
136
+ ], n.prototype, "isStartVisible", 2);
137
+ o([
138
+ g()
139
+ ], n.prototype, "isEndVisible", 2);
140
+ o([
141
+ y('button[role="tab"]')
142
+ ], n.prototype, "tabButtons", 2);
143
+ o([
144
+ f({ type: String })
145
+ ], n.prototype, "activeTab", 2);
146
+ o([
147
+ m({ context: c.formContext }),
148
+ f({ attribute: !1 })
149
+ ], n.prototype, "formContext", 2);
150
+ o([
151
+ v({ context: c.layoutContext })
152
+ ], n.prototype, "adapter", 2);
153
+ n = o([
154
+ T("gui-tabs-layout")
155
+ ], n);
156
+ export {
157
+ n as TabsElement
158
+ };