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