@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.
- package/CHANGELOG.md +529 -0
- package/README.md +7 -0
- package/accordion.element-D1RfC2ew.js +92 -0
- package/alert.element-B4rpyqGV.js +55 -0
- package/button.element-BnUBVNSH.js +58 -0
- package/calendar.element-D7mAbpAa.js +70 -0
- package/checkbox.element--Kc7sWBx.js +65 -0
- package/currency.element-D9dyGRBH.js +71 -0
- package/date-picker.element-Dcs5OpxN.js +136 -0
- package/date.element-na_Uywms.js +74 -0
- package/default-list-item-renderer-DNVEjKSX.js +23 -0
- package/dropdown.element-Cfj40aJz.js +225 -0
- package/flex.element-BSMOum-h.js +65 -0
- package/index.d.ts +2 -0
- package/index.js +2254 -0
- package/index.umd.cjs +535 -0
- package/lib/components/accordion.element.d.ts +21 -0
- package/lib/components/alert.element.d.ts +16 -0
- package/lib/components/button.element.d.ts +15 -0
- package/lib/components/calendar.element.d.ts +16 -0
- package/lib/components/checkbox.element.d.ts +17 -0
- package/lib/components/currency.element.d.ts +17 -0
- package/lib/components/date-picker.element.d.ts +26 -0
- package/lib/components/date.element.d.ts +18 -0
- package/lib/components/default-list-item-renderer.d.ts +2 -0
- package/lib/components/dropdown.element.d.ts +38 -0
- package/lib/components/flex.element.d.ts +16 -0
- package/lib/components/form.element.d.ts +21 -0
- package/lib/components/list.element.d.ts +25 -0
- package/lib/components/number.element.d.ts +17 -0
- package/lib/components/password.element.d.ts +17 -0
- package/lib/components/radiogroup.element.d.ts +17 -0
- package/lib/components/range-calendar.element.d.ts +16 -0
- package/lib/components/renderer.element.d.ts +15 -0
- package/lib/components/repeater.element.d.ts +18 -0
- package/lib/components/select.element.d.ts +18 -0
- package/lib/components/tabs.element.d.ts +27 -0
- package/lib/components/textarea.element.d.ts +17 -0
- package/lib/components/textinput.element.d.ts +17 -0
- package/lib/components/toggle.element.d.ts +17 -0
- package/lib/widget.loaders.d.ts +4 -0
- package/list.element--aj6sNNU.js +138 -0
- package/number.element-Bl5YReaL.js +69 -0
- package/package.json +34 -0
- package/password.element-CKmcH8Gn.js +70 -0
- package/radiogroup.element-Cn1lyyVE.js +67 -0
- package/range-calendar.element-C2YUElqM.js +70 -0
- package/renderer.element-B7AjPqr2.js +43 -0
- package/repeater.element-BfwzCooC.js +83 -0
- package/select.element-LWiqYxzA.js +73 -0
- package/tabs.element-DYg1wAz9.js +158 -0
- package/textarea.element-BXc-rLZE.js +70 -0
- package/textinput.element-x9LYeW8B.js +66 -0
- package/toggle.element-BP4YKWyR.js +65 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import * as m from "@golemui/lit";
|
|
2
|
+
import { consume as $, provide as v } from "@lit/context";
|
|
3
|
+
import { LitElement as y, nothing as f, html as g } from "lit";
|
|
4
|
+
import { property as F, state as h, query as b, customElement as w } from "lit/decorators.js";
|
|
5
|
+
import { Subject as C, debounceTime as x } from "rxjs";
|
|
6
|
+
import { d as L } from "./default-list-item-renderer-DNVEjKSX.js";
|
|
7
|
+
var R = Object.defineProperty, D = Object.getOwnPropertyDescriptor, l = (e, t, i, a) => {
|
|
8
|
+
for (var r = a > 1 ? void 0 : a ? D(t, i) : t, u = e.length - 1, n; u >= 0; u--)
|
|
9
|
+
(n = e[u]) && (r = (a ? n(t, i, r) : n(r)) || r);
|
|
10
|
+
return a && r && R(t, i, r), r;
|
|
11
|
+
};
|
|
12
|
+
let s = class extends y {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.adapter = new m.InputWidgetAdapter(), this.debouncer = new C(), this.subscriptions = [], this._range = { start: 0, end: 10 }, this._filteredItems = [], this._listItems = [], this._focusedIndex = -1, this._isFiltering = !1, this._isListVisible = !1, this._selectedItem = void 0, this.onDocumentClick = (e) => {
|
|
15
|
+
if (!this._isListVisible) return;
|
|
16
|
+
const t = e.composedPath(), i = this._inputRef && t.includes(this._inputRef), a = this._listRef && t.includes(this._listRef);
|
|
17
|
+
!i && !a && (this._isListVisible = !1);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
createRenderRoot() {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback(), document.addEventListener("click", this.onDocumentClick), this.classList.add("gui-dropdown"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this._filteredItems = this.adapter.templateData.items, this.subscriptions.push(
|
|
25
|
+
this.adapter.templateDataChanged$.subscribe(() => {
|
|
26
|
+
const e = this.adapter.templateData;
|
|
27
|
+
e.items && this._listItems.length === 0 && this._filteredItems.length === 0 && (this._filteredItems = e.items, this._listItems = e.items), this.requestUpdate();
|
|
28
|
+
}),
|
|
29
|
+
this.debouncer.pipe(x(this.adapter.templateData.inputDebounce ?? 500)).subscribe((e) => {
|
|
30
|
+
this._filterItems(e);
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
updated(e) {
|
|
35
|
+
super.updated(e);
|
|
36
|
+
const t = this.adapter.templateData.size;
|
|
37
|
+
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
38
|
+
}
|
|
39
|
+
disconnectedCallback() {
|
|
40
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
41
|
+
}
|
|
42
|
+
_onRangeChange(e) {
|
|
43
|
+
this._range = { start: e.detail.startIndex, end: e.detail.endIndex };
|
|
44
|
+
}
|
|
45
|
+
_onUpdateItems(e) {
|
|
46
|
+
this._listItems = e.detail || [];
|
|
47
|
+
}
|
|
48
|
+
_onFocusChange(e) {
|
|
49
|
+
this._focusedIndex = e.detail.index;
|
|
50
|
+
}
|
|
51
|
+
_onClickItem(e, t) {
|
|
52
|
+
if (this.adapter.templateData.readonly) return;
|
|
53
|
+
const i = this.adapter.templateData;
|
|
54
|
+
this.adapter.valueChanged(e.value), this.adapter.filterChanged(""), this._focusedIndex = t, this._selectedItem = e, this._isFiltering = !1, this._isListVisible = !1, this._listRef && (this._listRef.focusItemAtIndex(t), this._inputRef.value = i.valueField ? e.template[i.valueField] : e.template);
|
|
55
|
+
}
|
|
56
|
+
_onValueChange(e) {
|
|
57
|
+
const t = e.detail.value;
|
|
58
|
+
this.adapter.valueChanged(t), this.adapter.filterChanged(""), this._selectedItem = this._listItems.find((i) => i.value === t), this._isFiltering = !1, this._isListVisible = !1;
|
|
59
|
+
}
|
|
60
|
+
async _onKeyDown(e) {
|
|
61
|
+
switch (e.key) {
|
|
62
|
+
case "ArrowDown":
|
|
63
|
+
e.preventDefault(), this._isListVisible = !0, await this.updateComplete, this._listRef.focus(), this._listRef.scrollToSelectedIndex();
|
|
64
|
+
break;
|
|
65
|
+
case "Enter":
|
|
66
|
+
this._inputRef.value || (this.adapter.valueChanged(null), this._isListVisible = !1, this._isFiltering = !1);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
_onInput(e) {
|
|
71
|
+
const t = e.target.value;
|
|
72
|
+
this.debouncer.next(t);
|
|
73
|
+
}
|
|
74
|
+
_filterItems(e) {
|
|
75
|
+
const t = this.adapter.templateData, i = !!this.widget.on?.filter;
|
|
76
|
+
if (this.adapter.filterChanged(e), e && !i) {
|
|
77
|
+
this._isFiltering = !0, this._isListVisible = !0;
|
|
78
|
+
const a = t.searchFields ?? [t.labelField, t.valueField].filter(
|
|
79
|
+
(o) => !!o
|
|
80
|
+
), r = a.length > 0, n = (t.items || []).filter((o) => {
|
|
81
|
+
const d = Object.keys(o);
|
|
82
|
+
if (!d.length)
|
|
83
|
+
return o.toString().toLowerCase().includes(e.toLowerCase());
|
|
84
|
+
const c = (_, I) => _ || o[I].toString().toLowerCase().includes(e.toLowerCase());
|
|
85
|
+
return r ? d.filter((_) => a.includes(_)).reduce(c, !1) : d.reduce(c, !1);
|
|
86
|
+
});
|
|
87
|
+
this._filteredItems = [...n];
|
|
88
|
+
} else
|
|
89
|
+
this._isFiltering = !1, this._filteredItems = [...t.items];
|
|
90
|
+
}
|
|
91
|
+
async _onFocus() {
|
|
92
|
+
this._isListVisible = !0, await this.updateComplete, this._listRef.scrollToSelectedIndex();
|
|
93
|
+
}
|
|
94
|
+
_onFocusOutInput(e) {
|
|
95
|
+
const t = e.relatedTarget;
|
|
96
|
+
t && this.contains(t) || (this.adapter.onBlur(), this._isListVisible = !1, this._isFiltering = !1);
|
|
97
|
+
}
|
|
98
|
+
_onBlur() {
|
|
99
|
+
this.adapter.onBlur(), this._isListVisible = !1, this._isFiltering = !1;
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
const e = this.adapter.templateData, t = this._listItems.slice(this._range.start, this._range.end), i = this.adapter.getItemRenderer(
|
|
103
|
+
e.itemRenderer,
|
|
104
|
+
L
|
|
105
|
+
), a = e.labelField ?? e.valueField, r = a ? this._selectedItem?.template[a] : this._selectedItem?.template, u = !!this.widget.on?.filter;
|
|
106
|
+
return g`
|
|
107
|
+
<gui-label
|
|
108
|
+
.targetElement=${[this._listRef, this._inputRef]}
|
|
109
|
+
.uid=${this.widget.uid}
|
|
110
|
+
.label=${e.label}
|
|
111
|
+
.hint=${e.hint}
|
|
112
|
+
.errors=${e.errors}
|
|
113
|
+
.touched=${e.touched}
|
|
114
|
+
.required=${e.validator?.required}
|
|
115
|
+
.native=${!1}
|
|
116
|
+
></gui-label>
|
|
117
|
+
|
|
118
|
+
<div class="gui-widget">
|
|
119
|
+
<input
|
|
120
|
+
type="text"
|
|
121
|
+
id=${this.widget.uid}
|
|
122
|
+
data-cy=${`${this.widget.uid}_textinput`}
|
|
123
|
+
.value=${r ?? ""}
|
|
124
|
+
?required=${e.validator?.required}
|
|
125
|
+
?disabled=${e.disabled}
|
|
126
|
+
?readonly=${e.readonly}
|
|
127
|
+
placeholder=${e.placeholder ?? ""}
|
|
128
|
+
@keydown=${this._onKeyDown}
|
|
129
|
+
@input=${this._onInput}
|
|
130
|
+
@focusout=${this._onFocusOutInput}
|
|
131
|
+
@focus=${this._onFocus}
|
|
132
|
+
aria-labelledby=${e.label ? `${this.widget.uid}_label` : f}
|
|
133
|
+
aria-describedby=${e.hint ? `${this.widget.uid}_hint` : f}
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
<gui-list
|
|
137
|
+
id=${this.widget.uid}
|
|
138
|
+
.uid=${this.widget.uid}
|
|
139
|
+
.value=${e.value ?? ""}
|
|
140
|
+
.valueField=${e.valueField}
|
|
141
|
+
.items=${this._isFiltering && !u ? this._filteredItems : e.items}
|
|
142
|
+
.itemHeight=${e.itemHeight}
|
|
143
|
+
.height=${e.height}
|
|
144
|
+
?required=${e.validator?.required}
|
|
145
|
+
?touched=${e.touched}
|
|
146
|
+
?disabled=${e.disabled}
|
|
147
|
+
?readonly=${e.readonly}
|
|
148
|
+
?hidden=${!this._isListVisible}
|
|
149
|
+
@gui-range-change=${this._onRangeChange}
|
|
150
|
+
@gui-update-items=${this._onUpdateItems}
|
|
151
|
+
@gui-focus-change=${this._onFocusChange}
|
|
152
|
+
@focus=${this._onFocus}
|
|
153
|
+
@blur=${this._onBlur}
|
|
154
|
+
@change=${this._onValueChange}
|
|
155
|
+
>
|
|
156
|
+
${t.map((n, o) => {
|
|
157
|
+
const d = this._range.start + o, p = e.value === n.value, c = this._focusedIndex === d;
|
|
158
|
+
return g`
|
|
159
|
+
<div
|
|
160
|
+
role="option"
|
|
161
|
+
tabindex="-1"
|
|
162
|
+
class="gui-list__item-wrapper"
|
|
163
|
+
id="${this.widget.uid}-item-${d}"
|
|
164
|
+
style="height: ${e.itemHeight || 40}px"
|
|
165
|
+
aria-selected=${p ? "true" : "false"}
|
|
166
|
+
@click=${() => this._onClickItem(n, d)}
|
|
167
|
+
>
|
|
168
|
+
${i({
|
|
169
|
+
template: n.template,
|
|
170
|
+
value: n.value,
|
|
171
|
+
index: d,
|
|
172
|
+
selected: p,
|
|
173
|
+
disabled: !!e.disabled,
|
|
174
|
+
focused: c
|
|
175
|
+
})}
|
|
176
|
+
</div>
|
|
177
|
+
`;
|
|
178
|
+
})}
|
|
179
|
+
</gui-list>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<gui-errors .errors=${e.errors} .touched=${e.touched}></gui-errors>
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
l([
|
|
187
|
+
$({ context: m.formContext }),
|
|
188
|
+
F({ attribute: !1 })
|
|
189
|
+
], s.prototype, "formContext", 2);
|
|
190
|
+
l([
|
|
191
|
+
v({ context: m.inputContext })
|
|
192
|
+
], s.prototype, "adapter", 2);
|
|
193
|
+
l([
|
|
194
|
+
h()
|
|
195
|
+
], s.prototype, "_range", 2);
|
|
196
|
+
l([
|
|
197
|
+
h()
|
|
198
|
+
], s.prototype, "_filteredItems", 2);
|
|
199
|
+
l([
|
|
200
|
+
h()
|
|
201
|
+
], s.prototype, "_listItems", 2);
|
|
202
|
+
l([
|
|
203
|
+
h()
|
|
204
|
+
], s.prototype, "_focusedIndex", 2);
|
|
205
|
+
l([
|
|
206
|
+
h()
|
|
207
|
+
], s.prototype, "_isFiltering", 2);
|
|
208
|
+
l([
|
|
209
|
+
h()
|
|
210
|
+
], s.prototype, "_isListVisible", 2);
|
|
211
|
+
l([
|
|
212
|
+
h()
|
|
213
|
+
], s.prototype, "_selectedItem", 2);
|
|
214
|
+
l([
|
|
215
|
+
b("input")
|
|
216
|
+
], s.prototype, "_inputRef", 2);
|
|
217
|
+
l([
|
|
218
|
+
b("gui-list")
|
|
219
|
+
], s.prototype, "_listRef", 2);
|
|
220
|
+
s = l([
|
|
221
|
+
w("gui-dropdown-input")
|
|
222
|
+
], s);
|
|
223
|
+
export {
|
|
224
|
+
s as DropdownElement
|
|
225
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as n from "@golemui/lit";
|
|
2
|
+
import { consume as c, provide as u } from "@lit/context";
|
|
3
|
+
import { LitElement as g, html as d } from "lit";
|
|
4
|
+
import { property as h, customElement as m } from "lit/decorators.js";
|
|
5
|
+
import { repeat as f } from "lit-html/directives/repeat.js";
|
|
6
|
+
import { classMap as x } from "lit/directives/class-map.js";
|
|
7
|
+
var _ = Object.defineProperty, w = Object.getOwnPropertyDescriptor, o = (e, t, s, i) => {
|
|
8
|
+
for (var a = i > 1 ? void 0 : i ? w(t, s) : t, l = e.length - 1, p; l >= 0; l--)
|
|
9
|
+
(p = e[l]) && (a = (i ? p(t, s, a) : p(a)) || a);
|
|
10
|
+
return i && a && _(t, s, a), a;
|
|
11
|
+
};
|
|
12
|
+
let r = class extends g {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.adapter = new n.LayoutWidgetAdapter(), this.subscriptions = [];
|
|
15
|
+
}
|
|
16
|
+
createRenderRoot() {
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
super.connectedCallback(), this.classList.add("gui-flex"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
21
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
updated(e) {
|
|
25
|
+
super.updated(e);
|
|
26
|
+
const t = this.adapter.templateData.size;
|
|
27
|
+
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
const e = {
|
|
31
|
+
"gui-flex__widget": !0,
|
|
32
|
+
"gui-flex__widget--horizontal": this.adapter.templateData.direction === "horizontal",
|
|
33
|
+
"gui-flex__widget--align-start": this.adapter.templateData.align === "start",
|
|
34
|
+
"gui-flex__widget--align-end": this.adapter.templateData.align === "end",
|
|
35
|
+
"gui-flex__widget--align-center": this.adapter.templateData.align === "center",
|
|
36
|
+
"gui-flex__widget--align-space-between": this.adapter.templateData.align === "space-between",
|
|
37
|
+
"gui-flex__widget--align-space-around": this.adapter.templateData.align === "space-around"
|
|
38
|
+
};
|
|
39
|
+
return d`
|
|
40
|
+
<div class=${x(e)} id=${this.widget?.uid}>
|
|
41
|
+
${f(
|
|
42
|
+
this.adapter.templateData.children || [],
|
|
43
|
+
(t) => t?.uid,
|
|
44
|
+
(t) => d`<gui-widget .widget=${t}></gui-widget>`
|
|
45
|
+
)}
|
|
46
|
+
</div>
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
o([
|
|
54
|
+
c({ context: n.formContext }),
|
|
55
|
+
h({ attribute: !1 })
|
|
56
|
+
], r.prototype, "formContext", 2);
|
|
57
|
+
o([
|
|
58
|
+
u({ context: n.layoutContext })
|
|
59
|
+
], r.prototype, "adapter", 2);
|
|
60
|
+
r = o([
|
|
61
|
+
m("gui-flex-layout")
|
|
62
|
+
], r);
|
|
63
|
+
export {
|
|
64
|
+
r as FlexElement
|
|
65
|
+
};
|
package/index.d.ts
ADDED