@golemui/gui-lit 2.0.0-rc.0 → 2.0.0-rc.1

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.
@@ -0,0 +1,139 @@
1
+ import { InputWidgetAdapter as h, formContext as c, inputContext as m } from "@golemui/lit";
2
+ import { consume as g, provide as b } from "@lit/context";
3
+ import { LitElement as $, nothing as u, html as n } from "lit";
4
+ import { property as f, state as v, query as _ } from "lit/decorators.js";
5
+ import { unsubscribeAll as y, cspStyleMap as C, safeDefine as x } from "@golemui/lit/internals";
6
+ import "rxjs";
7
+ import { d as w } from "./default-multi-list-item-renderer-CG3Fuye0.js";
8
+ import "@golemui/gui-components/label";
9
+ import "@golemui/gui-components/multi-list";
10
+ import "@golemui/gui-components/errors";
11
+ import { live as I } from "lit/directives/live.js";
12
+ var R = Object.defineProperty, d = (o, e, r, a) => {
13
+ for (var i = void 0, t = o.length - 1, s; t >= 0; t--)
14
+ (s = o[t]) && (i = s(e, r, i) || i);
15
+ return i && R(e, r, i), i;
16
+ };
17
+ class l extends $ {
18
+ constructor() {
19
+ super(...arguments), this.adapter = new h(), this.subscriptions = [], this._visibleItems = [];
20
+ }
21
+ createRenderRoot() {
22
+ return this;
23
+ }
24
+ connectedCallback() {
25
+ super.connectedCallback(), this.classList.add("gui-multi-list-widget", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
26
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
27
+ );
28
+ }
29
+ disconnectedCallback() {
30
+ super.disconnectedCallback(), this.adapter.destroy(), y(this.subscriptions);
31
+ }
32
+ render() {
33
+ const e = this.adapter.templateData, r = e.touched && e.errors && e.errors.length > 0, a = this._currentValues(), i = this.adapter.getItemRenderer(
34
+ e.itemRenderer,
35
+ w
36
+ );
37
+ return n`
38
+ <gui-label
39
+ .targetElement=${this._guiListRef}
40
+ .uid=${this.widget.uid}
41
+ .label=${e.label}
42
+ .hint=${e.hint}
43
+ .errors=${e.errors}
44
+ .touched=${e.touched}
45
+ .required=${e.validator?.required}
46
+ .disabled=${e.disabled}
47
+ .readOnly=${e.readonly}
48
+ .native=${!1}
49
+ ></gui-label>
50
+
51
+ <div class="gui-widget">
52
+ <gui-multi-list
53
+ .uid=${this.widget.uid}
54
+ .values=${I(a)}
55
+ .valueField=${e.valueField}
56
+ .items=${e.items}
57
+ .itemHeight=${e.itemHeight}
58
+ .height=${e.height}
59
+ ?required=${e.validator?.required}
60
+ .touched=${e.touched}
61
+ ?disabled=${e.disabled}
62
+ ?readonly=${e.readonly}
63
+ aria-labelledby=${e.label ? `${this.widget.uid}_label` : u}
64
+ aria-describedby=${e.hint ? `${this.widget.uid}_hint` : u}
65
+ @gui-visible-items-change=${this._onVisibleItemsChange}
66
+ @gui-blur=${() => this.adapter.onBlur()}
67
+ @gui-item-toggle=${this._valueChanged}
68
+ >
69
+ ${this._visibleItems.map((t) => {
70
+ const s = e.labelField ?? "label", p = t.template !== null && typeof t.template == "object" && s && !e.itemRenderer ? t.template[s] : t.template;
71
+ return n`
72
+ <div
73
+ role="option"
74
+ tabindex="-1"
75
+ class="gui-list__item-wrapper"
76
+ id=${t.id}
77
+ style=${C({ height: `${e.itemHeight || 40}px` })}
78
+ aria-selected=${t.selected ? "true" : "false"}
79
+ aria-disabled=${t.disabled ? "true" : "false"}
80
+ >
81
+ ${i({
82
+ template: p,
83
+ value: t.value,
84
+ index: t.index,
85
+ selected: t.selected,
86
+ disabled: t.disabled,
87
+ focused: t.focused
88
+ })}
89
+ </div>
90
+ `;
91
+ })}
92
+ </gui-multi-list>
93
+ </div>
94
+
95
+ ${r ? n`<gui-errors
96
+ .uid=${this.widget.uid}
97
+ .errors=${e.errors}
98
+ .touched=${e.touched}
99
+ ></gui-errors>` : u}
100
+ `;
101
+ }
102
+ _currentValues() {
103
+ const e = this.adapter.templateData.value;
104
+ return Array.isArray(e) ? e : [];
105
+ }
106
+ _toggleValue(e) {
107
+ const r = this.adapter.templateData;
108
+ if (r.disabled || r.readonly) return;
109
+ const a = this._currentValues();
110
+ if (a.includes(e)) {
111
+ this.adapter.valueChanged(a.filter((i) => i !== e));
112
+ return;
113
+ }
114
+ this.adapter.valueChanged([...a, e]);
115
+ }
116
+ _onVisibleItemsChange(e) {
117
+ this._visibleItems = e.detail;
118
+ }
119
+ _valueChanged(e) {
120
+ this.adapter.templateData.readonly || this._toggleValue(e.detail.value);
121
+ }
122
+ }
123
+ d([
124
+ g({ context: c }),
125
+ f({ attribute: !1 })
126
+ ], l.prototype, "formContext");
127
+ d([
128
+ b({ context: m })
129
+ ], l.prototype, "adapter");
130
+ d([
131
+ v()
132
+ ], l.prototype, "_visibleItems");
133
+ d([
134
+ _("gui-multi-list")
135
+ ], l.prototype, "_guiListRef");
136
+ x("gui-multi-list-input", l);
137
+ export {
138
+ l as MultiListElement
139
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemui/gui-lit",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,11 +25,11 @@
25
25
  "*.md"
26
26
  ],
27
27
  "peerDependencies": {
28
- "@golemui/lit": "2.0.0-rc.0",
29
- "@golemui/core": "2.0.0-rc.0",
30
- "@golemui/gui-components": "2.0.0-rc.0",
31
- "@golemui/gui-shared": "2.0.0-rc.0",
32
- "@golemui/gui-validators": "2.0.0-rc.0",
28
+ "@golemui/lit": "2.0.0-rc.1",
29
+ "@golemui/core": "2.0.0-rc.1",
30
+ "@golemui/gui-components": "2.0.0-rc.1",
31
+ "@golemui/gui-shared": "2.0.0-rc.1",
32
+ "@golemui/gui-validators": "2.0.0-rc.1",
33
33
  "@lit/context": "^1.1.6",
34
34
  "lit-html": "^3.3.1",
35
35
  "lit": "^3.3.1",
@@ -1,24 +0,0 @@
1
- import { html as i } from "lit";
2
- import { classMap as t } from "lit/directives/class-map.js";
3
- import "@golemui/core";
4
- const r = (e) => {
5
- const s = {
6
- "gui-list__item": !0,
7
- "gui-list__item-selected": !!e.selected,
8
- "gui-list__item-focused": !!e.focused,
9
- "gui-list__item-disabled": !!e.disabled
10
- };
11
- return i`
12
- <div
13
- role="option"
14
- class=${t(s)}
15
- aria-selected=${e.selected ? "true" : "false"}
16
- aria-disabled=${e.disabled ? "true" : "false"}
17
- >
18
- ${e.template}
19
- </div>
20
- `;
21
- };
22
- export {
23
- r as d
24
- };
@@ -1,147 +0,0 @@
1
- import { InputWidgetAdapter as $, formContext as _, inputContext as v } from "@golemui/lit";
2
- import { consume as I, provide as x } from "@lit/context";
3
- import { LitElement as y, nothing as u, html as h } from "lit";
4
- import { property as C, state as p, query as R } from "lit/decorators.js";
5
- import { unsubscribeAll as w, cspStyleMap as L, safeDefine as D } from "@golemui/lit/internals";
6
- import "rxjs";
7
- import { d as k } from "./default-list-item-renderer-CuPJ9jUD.js";
8
- import "@golemui/gui-components/label";
9
- import "@golemui/gui-components/list";
10
- import "@golemui/gui-components/errors";
11
- import { live as F } from "lit/directives/live.js";
12
- var q = Object.defineProperty, r = (o, e, s, d) => {
13
- for (var i = void 0, t = o.length - 1, l; t >= 0; t--)
14
- (l = o[t]) && (i = l(e, s, i) || i);
15
- return i && q(e, s, i), i;
16
- };
17
- class a extends y {
18
- constructor() {
19
- super(...arguments), this.adapter = new $(), this.subscriptions = [], this._range = { start: 0, end: 10 }, this._listItems = [], this._focusedIndex = -1;
20
- }
21
- createRenderRoot() {
22
- return this;
23
- }
24
- connectedCallback() {
25
- super.connectedCallback(), this.classList.add("gui-list", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
26
- this.adapter.templateDataChanged$.subscribe(() => {
27
- const e = this.adapter.templateData;
28
- e.items && this._listItems.length === 0 && (this._listItems = e.items), this.requestUpdate();
29
- })
30
- );
31
- }
32
- disconnectedCallback() {
33
- super.disconnectedCallback(), this.adapter.destroy(), w(this.subscriptions);
34
- }
35
- render() {
36
- const e = this.adapter.templateData, s = e.touched && e.errors && e.errors.length > 0, d = this._listItems.slice(this._range.start, this._range.end), i = this.adapter.getItemRenderer(
37
- e.itemRenderer,
38
- k
39
- );
40
- return h`
41
- <gui-label
42
- .targetElement=${this._guiListRef}
43
- .uid=${this.widget.uid}
44
- .label=${e.label}
45
- .hint=${e.hint}
46
- .errors=${e.errors}
47
- .touched=${e.touched}
48
- .required=${e.validator?.required}
49
- .disabled=${e.disabled}
50
- .readOnly=${e.readonly}
51
- .native=${!1}
52
- ></gui-label>
53
-
54
- <div class="gui-widget">
55
- <gui-list
56
- .uid=${this.widget.uid}
57
- .value=${F(e.value ?? "")}
58
- .valueField=${e.valueField}
59
- .items=${e.items}
60
- .itemHeight=${e.itemHeight}
61
- .height=${e.height}
62
- ?required=${e.validator?.required}
63
- .touched=${e.touched}
64
- ?disabled=${e.disabled}
65
- ?readonly=${e.readonly}
66
- aria-labelledby=${e.label ? `${this.widget.uid}_label` : u}
67
- aria-describedby=${e.hint ? `${this.widget.uid}_hint` : u}
68
- @gui-range-change=${this._onRangeChange}
69
- @gui-update-items=${this._onUpdateItems}
70
- @gui-focus-change=${this._onFocusChange}
71
- @gui-blur=${() => this.adapter.onBlur()}
72
- @gui-input=${this._valueChanged}
73
- >
74
- ${d.map((t, l) => {
75
- const n = this._range.start + l, c = e.value === t.value, b = this._focusedIndex === n, g = !!e.disabled || !!t.disabled, m = e.labelField ?? "label", f = t.template !== null && typeof t.template == "object" && m && !e.itemRenderer ? t.template[m] : t.template;
76
- return h`
77
- <div
78
- role="option"
79
- tabindex="-1"
80
- class="gui-list__item-wrapper"
81
- id="${this.widget.uid}-item-${n}"
82
- style=${L({ height: `${e.itemHeight || 40}px` })}
83
- aria-selected=${c ? "true" : "false"}
84
- aria-disabled=${g ? "true" : "false"}
85
- @click=${() => this._onClickItem(t, n)}
86
- >
87
- ${i({
88
- template: f,
89
- value: t.value,
90
- index: n,
91
- selected: c,
92
- disabled: g,
93
- focused: b
94
- })}
95
- </div>
96
- `;
97
- })}
98
- </gui-list>
99
- </div>
100
-
101
- ${s ? h`<gui-errors
102
- .uid=${this.widget.uid}
103
- .errors=${e.errors}
104
- .touched=${e.touched}
105
- ></gui-errors>` : u}
106
- `;
107
- }
108
- _onRangeChange(e) {
109
- this._range = { start: e.detail.startIndex, end: e.detail.endIndex };
110
- }
111
- _onUpdateItems(e) {
112
- this._listItems = e.detail || [];
113
- }
114
- _onFocusChange(e) {
115
- this._focusedIndex = e.detail.index;
116
- }
117
- _onClickItem(e, s) {
118
- const { disabled: d, readonly: i } = this.adapter.templateData;
119
- d || i || e.disabled || (this.adapter.valueChanged(e.value), this._focusedIndex = s, this._guiListRef && typeof this._guiListRef.focusItemAtIndex == "function" && this._guiListRef.focusItemAtIndex(s));
120
- }
121
- _valueChanged(e) {
122
- this.adapter.templateData.readonly || this.adapter.valueChanged(e.detail.value);
123
- }
124
- }
125
- r([
126
- I({ context: _ }),
127
- C({ attribute: !1 })
128
- ], a.prototype, "formContext");
129
- r([
130
- x({ context: v })
131
- ], a.prototype, "adapter");
132
- r([
133
- p()
134
- ], a.prototype, "_range");
135
- r([
136
- p()
137
- ], a.prototype, "_listItems");
138
- r([
139
- p()
140
- ], a.prototype, "_focusedIndex");
141
- r([
142
- R("gui-list")
143
- ], a.prototype, "_guiListRef");
144
- D("gui-list-input", a);
145
- export {
146
- a as ListElement
147
- };
@@ -1,161 +0,0 @@
1
- import { InputWidgetAdapter as $, formContext as v, inputContext as I } from "@golemui/lit";
2
- import { consume as y, provide as x } from "@lit/context";
3
- import { LitElement as C, nothing as u, html as h } from "lit";
4
- import { property as R, state as c, query as w } from "lit/decorators.js";
5
- import { unsubscribeAll as D, cspStyleMap as L, safeDefine as k } from "@golemui/lit/internals";
6
- import "rxjs";
7
- import { d as F } from "./default-multi-list-item-renderer-Cv-guvEX.js";
8
- import "@golemui/gui-components/label";
9
- import "@golemui/gui-components/multi-list";
10
- import "@golemui/gui-components/errors";
11
- import { live as q } from "lit/directives/live.js";
12
- var A = Object.defineProperty, d = (o, e, s, a) => {
13
- for (var t = void 0, l = o.length - 1, i; l >= 0; l--)
14
- (i = o[l]) && (t = i(e, s, t) || t);
15
- return t && A(e, s, t), t;
16
- };
17
- class r extends C {
18
- constructor() {
19
- super(...arguments), this.adapter = new $(), this.subscriptions = [], this._range = { start: 0, end: 10 }, this._listItems = [], this._focusedIndex = -1;
20
- }
21
- createRenderRoot() {
22
- return this;
23
- }
24
- connectedCallback() {
25
- super.connectedCallback(), this.classList.add("gui-multi-list-widget", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
26
- this.adapter.templateDataChanged$.subscribe(() => {
27
- const e = this.adapter.templateData;
28
- e.items && this._listItems.length === 0 && (this._listItems = e.items), this.requestUpdate();
29
- })
30
- );
31
- }
32
- disconnectedCallback() {
33
- super.disconnectedCallback(), this.adapter.destroy(), D(this.subscriptions);
34
- }
35
- render() {
36
- const e = this.adapter.templateData, s = e.touched && e.errors && e.errors.length > 0, a = this._listItems.slice(this._range.start, this._range.end), t = this._currentValues(), l = this.adapter.getItemRenderer(
37
- e.itemRenderer,
38
- F
39
- );
40
- return h`
41
- <gui-label
42
- .targetElement=${this._guiListRef}
43
- .uid=${this.widget.uid}
44
- .label=${e.label}
45
- .hint=${e.hint}
46
- .errors=${e.errors}
47
- .touched=${e.touched}
48
- .required=${e.validator?.required}
49
- .disabled=${e.disabled}
50
- .readOnly=${e.readonly}
51
- .native=${!1}
52
- ></gui-label>
53
-
54
- <div class="gui-widget">
55
- <gui-multi-list
56
- .uid=${this.widget.uid}
57
- .values=${q(t)}
58
- .valueField=${e.valueField}
59
- .items=${e.items}
60
- .itemHeight=${e.itemHeight}
61
- .height=${e.height}
62
- ?required=${e.validator?.required}
63
- .touched=${e.touched}
64
- ?disabled=${e.disabled}
65
- ?readonly=${e.readonly}
66
- aria-labelledby=${e.label ? `${this.widget.uid}_label` : u}
67
- aria-describedby=${e.hint ? `${this.widget.uid}_hint` : u}
68
- @gui-range-change=${this._onRangeChange}
69
- @gui-update-items=${this._onUpdateItems}
70
- @gui-focus-change=${this._onFocusChange}
71
- @gui-blur=${() => this.adapter.onBlur()}
72
- @gui-item-toggle=${this._valueChanged}
73
- >
74
- ${a.map((i, f) => {
75
- const n = this._range.start + f, p = t.includes(i.value), _ = this._focusedIndex === n, g = !!e.disabled || !!i.disabled, m = e.labelField ?? "label", b = i.template !== null && typeof i.template == "object" && m && !e.itemRenderer ? i.template[m] : i.template;
76
- return h`
77
- <div
78
- role="option"
79
- tabindex="-1"
80
- class="gui-list__item-wrapper"
81
- id="${this.widget.uid}-item-${n}"
82
- style=${L({ height: `${e.itemHeight || 40}px` })}
83
- aria-selected=${p ? "true" : "false"}
84
- aria-disabled=${g ? "true" : "false"}
85
- @click=${() => this._onClickItem(i, n)}
86
- >
87
- ${l({
88
- template: b,
89
- value: i.value,
90
- index: n,
91
- selected: p,
92
- disabled: g,
93
- focused: _
94
- })}
95
- </div>
96
- `;
97
- })}
98
- </gui-multi-list>
99
- </div>
100
-
101
- ${s ? h`<gui-errors
102
- .uid=${this.widget.uid}
103
- .errors=${e.errors}
104
- .touched=${e.touched}
105
- ></gui-errors>` : u}
106
- `;
107
- }
108
- _currentValues() {
109
- const e = this.adapter.templateData.value;
110
- return Array.isArray(e) ? e : [];
111
- }
112
- _toggleValue(e) {
113
- const s = this.adapter.templateData;
114
- if (s.disabled || s.readonly) return;
115
- const a = this._currentValues();
116
- if (a.includes(e)) {
117
- this.adapter.valueChanged(a.filter((t) => t !== e));
118
- return;
119
- }
120
- this.adapter.valueChanged([...a, e]);
121
- }
122
- _onRangeChange(e) {
123
- this._range = { start: e.detail.startIndex, end: e.detail.endIndex };
124
- }
125
- _onUpdateItems(e) {
126
- this._listItems = e.detail || [];
127
- }
128
- _onFocusChange(e) {
129
- this._focusedIndex = e.detail.index;
130
- }
131
- _onClickItem(e, s) {
132
- const { disabled: a, readonly: t } = this.adapter.templateData;
133
- a || t || e.disabled || (this._toggleValue(e.value), this._focusedIndex = s, this._guiListRef && typeof this._guiListRef.focusItemAtIndex == "function" && this._guiListRef.focusItemAtIndex(s));
134
- }
135
- _valueChanged(e) {
136
- this.adapter.templateData.readonly || this._toggleValue(e.detail.value);
137
- }
138
- }
139
- d([
140
- y({ context: v }),
141
- R({ attribute: !1 })
142
- ], r.prototype, "formContext");
143
- d([
144
- x({ context: I })
145
- ], r.prototype, "adapter");
146
- d([
147
- c()
148
- ], r.prototype, "_range");
149
- d([
150
- c()
151
- ], r.prototype, "_listItems");
152
- d([
153
- c()
154
- ], r.prototype, "_focusedIndex");
155
- d([
156
- w("gui-multi-list")
157
- ], r.prototype, "_guiListRef");
158
- k("gui-multi-list-input", r);
159
- export {
160
- r as MultiListElement
161
- };