@golemui/lit 0.13.1 → 0.13.3
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 +8 -0
- package/index.d.ts +12 -12
- package/index.js +116 -116
- package/index.umd.cjs +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.13.2 (2026-05-19)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.13.1 (2026-05-18)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 0.13.0 (2026-05-18)
|
|
2
10
|
|
|
3
11
|
### 🚀 Features
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
1
|
+
export { actionContext, ActionWidgetAdapter } from './lib/adapters/action-widget.adapter';
|
|
2
|
+
export { BaseWidgetAdapter } from './lib/adapters/base-widget.adapter';
|
|
3
|
+
export { DisplayWidgetAdapter, displayWidgetContext } from './lib/adapters/display.widget-adapter';
|
|
4
|
+
export { inputContext, InputWidgetAdapter } from './lib/adapters/input-widget.adapter';
|
|
5
|
+
export { layoutContext, LayoutWidgetAdapter } from './lib/adapters/layout-widget.adapter';
|
|
6
|
+
export { FormElement } from './lib/components/form/form.element';
|
|
7
|
+
export type { LitItemRenderer } from './lib/components/item-renderers/item-renderer';
|
|
8
|
+
export { RepeaterWidgetElement } from './lib/components/widget/repeater-widget.element';
|
|
9
|
+
export { WidgetElement } from './lib/components/widget/widget-element';
|
|
10
|
+
export { formContext, LitFormContext } from './lib/context/form.context';
|
|
11
|
+
export { repeaterIndexesContext } from './lib/context/repeater-index-token.context';
|
|
12
|
+
export type { Type } from './lib/utils/type';
|
package/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createContext as h, consume as m, provide as I, ContextProvider as W } from "@lit/context";
|
|
2
|
+
import { FormContext as A, calculatedWidgetsByUid$ as S, assertNoPropCollisions as O, dataByPath$ as N, validationByPath$ as R, injectedValidationByPath$ as P, touchedControlsByPath$ as L, calculatedLayoutChildrenByUid$ as j, makeRepeaterItemConfig as T, cloneObject as _, errorCodes as $, shortUUID as F, getDirectionFromLanguage as v, formHealth as U } from "@golemui/core";
|
|
3
|
+
import { Subject as E, takeUntil as p, combineLatest as M } from "rxjs";
|
|
4
4
|
import { LitElement as y, nothing as V, html as b } from "lit";
|
|
5
5
|
import { property as n, customElement as f, state as B } from "lit/decorators.js";
|
|
6
6
|
import { when as H } from "lit/directives/when.js";
|
|
7
7
|
const w = h("guiFormContext");
|
|
8
|
-
class z extends
|
|
8
|
+
class z extends A {
|
|
9
9
|
// Just a subclass to make Core.FormContext Injectable
|
|
10
10
|
}
|
|
11
11
|
class g {
|
|
@@ -23,13 +23,13 @@ class g {
|
|
|
23
23
|
}
|
|
24
24
|
// Listen to the calculated props stream and keep all widget props merged in a flattened object
|
|
25
25
|
templateDataUpdater() {
|
|
26
|
-
this.context.store.state$.pipe(p(this.destroy$),
|
|
26
|
+
this.context.store.state$.pipe(p(this.destroy$), S(this.widget.uid)).subscribe((t) => {
|
|
27
27
|
const o = {
|
|
28
28
|
...t,
|
|
29
29
|
lang: this.context.store.getState().lang,
|
|
30
30
|
deps: this.context.dependencies
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
O(t.uid, t.props, o), this.setTemplateData({
|
|
33
33
|
...o,
|
|
34
34
|
...t.props
|
|
35
35
|
});
|
|
@@ -42,8 +42,35 @@ class g {
|
|
|
42
42
|
}), this.destroy$.next();
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const nt = h("
|
|
45
|
+
const nt = h("guiActionWidgetAdapter");
|
|
46
46
|
class dt extends g {
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments), this.templateData = {};
|
|
49
|
+
}
|
|
50
|
+
init(t) {
|
|
51
|
+
this.widget = t, this.setTemplateData({
|
|
52
|
+
label: this.widget.label,
|
|
53
|
+
icon: this.widget.props?.icon,
|
|
54
|
+
iconPosition: this.widget.props?.iconPosition
|
|
55
|
+
}), this.addWidgetToTheStore(t), this.templateDataUpdater(), this.context.emitEvent("load", this.widget);
|
|
56
|
+
}
|
|
57
|
+
click() {
|
|
58
|
+
this.context.emitEvent("click", this.widget);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const pt = h("guiDisplayWidgetAdapter");
|
|
62
|
+
class ht extends g {
|
|
63
|
+
constructor() {
|
|
64
|
+
super(...arguments), this.templateData = {};
|
|
65
|
+
}
|
|
66
|
+
init(t) {
|
|
67
|
+
this.widget = t, this.setTemplateData({
|
|
68
|
+
...this.widget.props
|
|
69
|
+
}), this.addWidgetToTheStore(t), this.templateDataUpdater();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const ct = h("guiInputWidgetAdapter");
|
|
73
|
+
class lt extends g {
|
|
47
74
|
constructor() {
|
|
48
75
|
super(...arguments), this.templateData = {};
|
|
49
76
|
}
|
|
@@ -51,21 +78,21 @@ class dt extends g {
|
|
|
51
78
|
this.widget = t, this.addWidgetToTheStore(t), this.templateDataUpdater(), this.context.store.dispatch({
|
|
52
79
|
type: "SET_WIDGET_INITIAL_DATA",
|
|
53
80
|
payload: { data: t.defaultValue, path: t.path }
|
|
54
|
-
}), this.context.store.state$.pipe(p(this.destroy$),
|
|
81
|
+
}), this.context.store.state$.pipe(p(this.destroy$), N(t.path)).subscribe((e) => this.setTemplateData({ value: e }));
|
|
55
82
|
const o = this.context.store.state$.pipe(
|
|
56
83
|
p(this.destroy$),
|
|
57
|
-
|
|
84
|
+
R(t.path)
|
|
58
85
|
), r = this.context.store.state$.pipe(
|
|
59
86
|
p(this.destroy$),
|
|
60
|
-
|
|
87
|
+
P(t.path)
|
|
61
88
|
);
|
|
62
|
-
|
|
89
|
+
M([o, r]).subscribe(
|
|
63
90
|
([e, i]) => {
|
|
64
91
|
this.setTemplateData({
|
|
65
92
|
errors: [...e ?? [], ...i ?? []]
|
|
66
93
|
});
|
|
67
94
|
}
|
|
68
|
-
), this.context.store.state$.pipe(p(this.destroy$),
|
|
95
|
+
), this.context.store.state$.pipe(p(this.destroy$), L(t.path)).subscribe((e) => this.setTemplateData({ touched: e })), this.context.emitEvent("load", this.widget);
|
|
69
96
|
}
|
|
70
97
|
valueChanged(t) {
|
|
71
98
|
this.context.store.dispatch({
|
|
@@ -95,33 +122,6 @@ class dt extends g {
|
|
|
95
122
|
}), this.context.emitEvent("blur", this.widget);
|
|
96
123
|
}
|
|
97
124
|
}
|
|
98
|
-
const pt = h("guiDisplayWidgetAdapter");
|
|
99
|
-
class ht extends g {
|
|
100
|
-
constructor() {
|
|
101
|
-
super(...arguments), this.templateData = {};
|
|
102
|
-
}
|
|
103
|
-
init(t) {
|
|
104
|
-
this.widget = t, this.setTemplateData({
|
|
105
|
-
...this.widget.props
|
|
106
|
-
}), this.addWidgetToTheStore(t), this.templateDataUpdater();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const ct = h("guiActionWidgetAdapter");
|
|
110
|
-
class lt extends g {
|
|
111
|
-
constructor() {
|
|
112
|
-
super(...arguments), this.templateData = {};
|
|
113
|
-
}
|
|
114
|
-
init(t) {
|
|
115
|
-
this.widget = t, this.setTemplateData({
|
|
116
|
-
label: this.widget.label,
|
|
117
|
-
icon: this.widget.props?.icon,
|
|
118
|
-
iconPosition: this.widget.props?.iconPosition
|
|
119
|
-
}), this.addWidgetToTheStore(t), this.templateDataUpdater(), this.context.emitEvent("load", this.widget);
|
|
120
|
-
}
|
|
121
|
-
click() {
|
|
122
|
-
this.context.emitEvent("click", this.widget);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
125
|
const ut = h("guiLayoutWidgetAdapter");
|
|
126
126
|
class mt extends g {
|
|
127
127
|
constructor() {
|
|
@@ -130,7 +130,7 @@ class mt extends g {
|
|
|
130
130
|
init(t) {
|
|
131
131
|
this.widget = t, this.setTemplateData({
|
|
132
132
|
...this.widget.props
|
|
133
|
-
}), this.context.store.state$.pipe(
|
|
133
|
+
}), this.context.store.state$.pipe(j(this.widget.uid)).pipe(p(this.destroy$)).subscribe((o) => {
|
|
134
134
|
this.setTemplateData({
|
|
135
135
|
children: o
|
|
136
136
|
});
|
|
@@ -202,81 +202,15 @@ let C = class extends k(y) {
|
|
|
202
202
|
C = J([
|
|
203
203
|
f("gui-widget")
|
|
204
204
|
], C);
|
|
205
|
-
var Z = Object.defineProperty,
|
|
206
|
-
for (var e = void 0, i = s.length - 1, a; i >= 0; i--)
|
|
207
|
-
(a = s[i]) && (e = a(t, o, e) || e);
|
|
208
|
-
return e && Z(t, o, e), e;
|
|
209
|
-
};
|
|
210
|
-
const Q = (s) => {
|
|
211
|
-
class t extends s {
|
|
212
|
-
constructor() {
|
|
213
|
-
super(...arguments), this.repeaterIndex = -1, this.parentRepeaterIndexes = [];
|
|
214
|
-
}
|
|
215
|
-
connectedCallback() {
|
|
216
|
-
super.connectedCallback(), this.loadWidgetComponent(this.repeaterIndex);
|
|
217
|
-
}
|
|
218
|
-
async loadWidgetComponent(r) {
|
|
219
|
-
if (this.widget)
|
|
220
|
-
try {
|
|
221
|
-
const e = await this.formContext.widgetRegistry.loadWidget(this.widget.type), i = new e(), a = [...this.parentRepeaterIndexes ?? [], r];
|
|
222
|
-
new U(i, {
|
|
223
|
-
context: x,
|
|
224
|
-
initialValue: a
|
|
225
|
-
}), i.widget = T(
|
|
226
|
-
_(this.widget),
|
|
227
|
-
a
|
|
228
|
-
), i.id = `host-${this.widget.uid}`, this.replaceWith(i);
|
|
229
|
-
} catch (e) {
|
|
230
|
-
console.error(`Widget "${this.widget.type}" could not be loaded`, e);
|
|
231
|
-
const i = $.widgetCouldNotBeLoaded;
|
|
232
|
-
this.dispatchEvent(
|
|
233
|
-
new CustomEvent("formHealth", {
|
|
234
|
-
detail: {
|
|
235
|
-
status: "errored",
|
|
236
|
-
message: `[${i}] Widget "${this.widget.type}" could not be loaded`,
|
|
237
|
-
code: i
|
|
238
|
-
},
|
|
239
|
-
bubbles: !0,
|
|
240
|
-
composed: !0
|
|
241
|
-
})
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
render() {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return u([
|
|
250
|
-
m({ context: w }),
|
|
251
|
-
n({ attribute: !1 })
|
|
252
|
-
], t.prototype, "formContext"), u([
|
|
253
|
-
n({ type: Object })
|
|
254
|
-
], t.prototype, "widget"), u([
|
|
255
|
-
n({ type: Number })
|
|
256
|
-
], t.prototype, "repeaterIndex"), u([
|
|
257
|
-
m({ context: x, subscribe: !0 }),
|
|
258
|
-
n({ attribute: !1 })
|
|
259
|
-
], t.prototype, "parentRepeaterIndexes"), t;
|
|
260
|
-
};
|
|
261
|
-
var X = Object.getOwnPropertyDescriptor, Y = (s, t, o, r) => {
|
|
262
|
-
for (var e = r > 1 ? void 0 : r ? X(t, o) : t, i = s.length - 1, a; i >= 0; i--)
|
|
263
|
-
(a = s[i]) && (e = a(e) || e);
|
|
264
|
-
return e;
|
|
265
|
-
};
|
|
266
|
-
let D = class extends Q(y) {
|
|
267
|
-
};
|
|
268
|
-
D = Y([
|
|
269
|
-
f("gui-repeater-widget")
|
|
270
|
-
], D);
|
|
271
|
-
var K = Object.defineProperty, tt = Object.getOwnPropertyDescriptor, c = (s, t, o, r) => {
|
|
272
|
-
for (var e = r > 1 ? void 0 : r ? tt(t, o) : t, i = s.length - 1, a; i >= 0; i--)
|
|
205
|
+
var Z = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, c = (s, t, o, r) => {
|
|
206
|
+
for (var e = r > 1 ? void 0 : r ? Q(t, o) : t, i = s.length - 1, a; i >= 0; i--)
|
|
273
207
|
(a = s[i]) && (e = (r ? a(t, o, e) : a(e)) || e);
|
|
274
|
-
return r && e &&
|
|
208
|
+
return r && e && Z(t, o, e), e;
|
|
275
209
|
};
|
|
276
210
|
let d = class extends y {
|
|
277
211
|
constructor() {
|
|
278
212
|
super(...arguments), this.context = new z(), this.autocomplete = void 0, this.direction = "ltr", this.unsubscribeI18n = () => {
|
|
279
|
-
}, this._defaultFormName =
|
|
213
|
+
}, this._defaultFormName = F();
|
|
280
214
|
}
|
|
281
215
|
connectedCallback() {
|
|
282
216
|
super.connectedCallback(), this.classList.add("gui-form"), this.eventSub = this.context.events$.subscribe(
|
|
@@ -299,7 +233,7 @@ let d = class extends y {
|
|
|
299
233
|
s.dependencies ?? {}
|
|
300
234
|
), this.direction = v(this.context.localization.lang), this.stateSub = this.context.store.state$.subscribe((t) => {
|
|
301
235
|
this.formState = t, this.requestUpdate();
|
|
302
|
-
}), this.healthSub =
|
|
236
|
+
}), this.healthSub = U(this.context.store.state$).subscribe((t) => {
|
|
303
237
|
this.dispatchEvent(
|
|
304
238
|
new CustomEvent(d.FORM_HEALTH_EVENT, {
|
|
305
239
|
detail: t,
|
|
@@ -346,7 +280,7 @@ let d = class extends y {
|
|
|
346
280
|
d.FORM_HEALTH_EVENT = "formHealth";
|
|
347
281
|
d.FORM_EVENT = "formEvent";
|
|
348
282
|
c([
|
|
349
|
-
|
|
283
|
+
I({ context: w })
|
|
350
284
|
], d.prototype, "context", 2);
|
|
351
285
|
c([
|
|
352
286
|
n({ attribute: !1 })
|
|
@@ -363,20 +297,86 @@ c([
|
|
|
363
297
|
d = c([
|
|
364
298
|
f("gui-core-form")
|
|
365
299
|
], d);
|
|
300
|
+
var X = Object.defineProperty, u = (s, t, o, r) => {
|
|
301
|
+
for (var e = void 0, i = s.length - 1, a; i >= 0; i--)
|
|
302
|
+
(a = s[i]) && (e = a(t, o, e) || e);
|
|
303
|
+
return e && X(t, o, e), e;
|
|
304
|
+
};
|
|
305
|
+
const Y = (s) => {
|
|
306
|
+
class t extends s {
|
|
307
|
+
constructor() {
|
|
308
|
+
super(...arguments), this.repeaterIndex = -1, this.parentRepeaterIndexes = [];
|
|
309
|
+
}
|
|
310
|
+
connectedCallback() {
|
|
311
|
+
super.connectedCallback(), this.loadWidgetComponent(this.repeaterIndex);
|
|
312
|
+
}
|
|
313
|
+
async loadWidgetComponent(r) {
|
|
314
|
+
if (this.widget)
|
|
315
|
+
try {
|
|
316
|
+
const e = await this.formContext.widgetRegistry.loadWidget(this.widget.type), i = new e(), a = [...this.parentRepeaterIndexes ?? [], r];
|
|
317
|
+
new W(i, {
|
|
318
|
+
context: x,
|
|
319
|
+
initialValue: a
|
|
320
|
+
}), i.widget = T(
|
|
321
|
+
_(this.widget),
|
|
322
|
+
a
|
|
323
|
+
), i.id = `host-${this.widget.uid}`, this.replaceWith(i);
|
|
324
|
+
} catch (e) {
|
|
325
|
+
console.error(`Widget "${this.widget.type}" could not be loaded`, e);
|
|
326
|
+
const i = $.widgetCouldNotBeLoaded;
|
|
327
|
+
this.dispatchEvent(
|
|
328
|
+
new CustomEvent("formHealth", {
|
|
329
|
+
detail: {
|
|
330
|
+
status: "errored",
|
|
331
|
+
message: `[${i}] Widget "${this.widget.type}" could not be loaded`,
|
|
332
|
+
code: i
|
|
333
|
+
},
|
|
334
|
+
bubbles: !0,
|
|
335
|
+
composed: !0
|
|
336
|
+
})
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
render() {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return u([
|
|
345
|
+
m({ context: w }),
|
|
346
|
+
n({ attribute: !1 })
|
|
347
|
+
], t.prototype, "formContext"), u([
|
|
348
|
+
n({ type: Object })
|
|
349
|
+
], t.prototype, "widget"), u([
|
|
350
|
+
n({ type: Number })
|
|
351
|
+
], t.prototype, "repeaterIndex"), u([
|
|
352
|
+
m({ context: x, subscribe: !0 }),
|
|
353
|
+
n({ attribute: !1 })
|
|
354
|
+
], t.prototype, "parentRepeaterIndexes"), t;
|
|
355
|
+
};
|
|
356
|
+
var K = Object.getOwnPropertyDescriptor, tt = (s, t, o, r) => {
|
|
357
|
+
for (var e = r > 1 ? void 0 : r ? K(t, o) : t, i = s.length - 1, a; i >= 0; i--)
|
|
358
|
+
(a = s[i]) && (e = a(e) || e);
|
|
359
|
+
return e;
|
|
360
|
+
};
|
|
361
|
+
let D = class extends Y(y) {
|
|
362
|
+
};
|
|
363
|
+
D = tt([
|
|
364
|
+
f("gui-repeater-widget")
|
|
365
|
+
], D);
|
|
366
366
|
export {
|
|
367
|
-
|
|
367
|
+
dt as ActionWidgetAdapter,
|
|
368
368
|
g as BaseWidgetAdapter,
|
|
369
369
|
ht as DisplayWidgetAdapter,
|
|
370
370
|
d as FormElement,
|
|
371
|
-
|
|
371
|
+
lt as InputWidgetAdapter,
|
|
372
372
|
mt as LayoutWidgetAdapter,
|
|
373
373
|
z as LitFormContext,
|
|
374
374
|
D as RepeaterWidgetElement,
|
|
375
375
|
C as WidgetElement,
|
|
376
|
-
|
|
376
|
+
nt as actionContext,
|
|
377
377
|
pt as displayWidgetContext,
|
|
378
378
|
w as formContext,
|
|
379
|
-
|
|
379
|
+
ct as inputContext,
|
|
380
380
|
ut as layoutContext,
|
|
381
381
|
x as repeaterIndexesContext
|
|
382
382
|
};
|
package/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@lit/context"),require("@golemui/core"),require("rxjs"),require("lit"),require("lit/decorators.js"),require("lit/directives/when.js")):typeof define=="function"&&define.amd?define(["exports","@lit/context","@golemui/core","rxjs","lit","lit/decorators.js","lit/directives/when.js"],p):(i=typeof globalThis<"u"?globalThis:i||self,p(i.lit={},i.context,i.core,i.rxjs,i.lit,i.decorators_js,i.when_js))})(this,(function(i,p,d,l,c,h,x){"use strict";const g=p.createContext("guiFormContext");class E extends d.FormContext{}class m{constructor(){this.templateData={},this.destroy$=new l.Subject,this.templateDataChanged$=new l.Subject}setTemplateData(t){this.templateData={...this.templateData,...t},this.templateDataChanged$.next()}addWidgetToTheStore(t){this.context.store.dispatch({type:"ADD_WIDGET",payload:{widget:t}})}templateDataUpdater(){this.context.store.state$.pipe(l.takeUntil(this.destroy$),d.calculatedWidgetsByUid$(this.widget.uid)).subscribe(t=>{const s={...t,lang:this.context.store.getState().lang,deps:this.context.dependencies};d.assertNoPropCollisions(t.uid,t.props,s),this.setTemplateData({...s,...t.props})})}destroy(){this.context.store.dispatch({type:"REMOVE_WIDGET",payload:{uid:this.widget.uid}}),this.destroy$.next()}}const w=p.createContext("guiActionWidgetAdapter");class C extends m{constructor(){super(...arguments),this.templateData={}}init(t){this.widget=t,this.setTemplateData({label:this.widget.label,icon:this.widget.props?.icon,iconPosition:this.widget.props?.iconPosition}),this.addWidgetToTheStore(t),this.templateDataUpdater(),this.context.emitEvent("load",this.widget)}click(){this.context.emitEvent("click",this.widget)}}const v=p.createContext("guiDisplayWidgetAdapter");class T extends m{constructor(){super(...arguments),this.templateData={}}init(t){this.widget=t,this.setTemplateData({...this.widget.props}),this.addWidgetToTheStore(t),this.templateDataUpdater()}}const D=p.createContext("guiInputWidgetAdapter");class $ extends m{constructor(){super(...arguments),this.templateData={}}init(t){this.widget=t,this.addWidgetToTheStore(t),this.templateDataUpdater(),this.context.store.dispatch({type:"SET_WIDGET_INITIAL_DATA",payload:{data:t.defaultValue,path:t.path}}),this.context.store.state$.pipe(l.takeUntil(this.destroy$),d.dataByPath$(t.path)).subscribe(e=>this.setTemplateData({value:e}));const s=this.context.store.state$.pipe(l.takeUntil(this.destroy$),d.validationByPath$(t.path)),r=this.context.store.state$.pipe(l.takeUntil(this.destroy$),d.injectedValidationByPath$(t.path));l.combineLatest([s,r]).subscribe(([e,a])=>{this.setTemplateData({errors:[...e??[],...a??[]]})}),this.context.store.state$.pipe(l.takeUntil(this.destroy$),d.touchedControlsByPath$(t.path)).subscribe(e=>this.setTemplateData({touched:e})),this.context.emitEvent("load",this.widget)}valueChanged(t){this.context.store.dispatch({type:"SET_WIDGET_DATA",payload:{path:this.widget.path,data:t}}),this.context.emitEvent("change",this.widget)}filterChanged(t){this.context.emitEvent("filter",this.widget,t)}injectValidationIssues(t){this.context.store.dispatch({type:"INJECT_VALIDATION_ISSUES",payload:{path:this.widget.path,issues:t}})}getItemRenderer(t,s){return t?this.context.itemRenderers[t]:s}onBlur(){this.context.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"blur",path:this.widget.path,uid:this.widget.uid}}),this.context.emitEvent("blur",this.widget)}}const W=p.createContext("guiLayoutWidgetAdapter");class I extends m{constructor(){super(...arguments),this.templateData={}}init(t){this.widget=t,this.setTemplateData({...this.widget.props}),this.context.store.state$.pipe(d.calculatedLayoutChildrenByUid$(this.widget.uid)).pipe(l.takeUntil(this.destroy$)).subscribe(s=>{this.setTemplateData({children:s})}),this.addWidgetToTheStore(t),this.templateDataUpdater()}change(t){this.context.emitEvent("change",this.widget,t)}}const y=p.createContext("guiRepeaterIndexesContext");var A=Object.defineProperty,b=(n,t,s,r)=>{for(var e=void 0,a=n.length-1,o;a>=0;a--)(o=n[a])&&(e=o(t,s,e)||e);return e&&A(t,s,e),e};const _=n=>{class t extends n{constructor(){super(...arguments),this.repeaterIndexes=[]}connectedCallback(){super.connectedCallback?.(),this.loadWidgetComponent()}async loadWidgetComponent(){if(this.widget)try{const r=await this.formContext.widgetRegistry.loadWidget(this.widget.type),e=new r,a=this.repeaterIndexes??[];let o;this.repeaterIndex!==void 0?o=[...a,this.repeaterIndex]:o=a,e.widget=o.length>0?d.makeRepeaterItemConfig(d.cloneObject(this.widget),o):this.widget,e.id=`host-${this.widget.uid}`,this.replaceWith(e)}catch(r){console.error(`Widget "${this.widget.type}" could not be loaded`,r);const e=d.errorCodes.widgetCouldNotBeLoaded;this.dispatchEvent(new CustomEvent("formHealth",{detail:{status:"errored",message:`[${e}] Widget "${this.widget.type}" could not be loaded`,code:e},bubbles:!0,composed:!0}))}}render(){return null}}return b([p.consume({context:g}),h.property({attribute:!1})],t.prototype,"formContext"),b([h.property({type:Object})],t.prototype,"widget"),b([h.property({type:Number})],t.prototype,"repeaterIndex"),b([p.consume({context:y,subscribe:!0}),h.property({attribute:!1})],t.prototype,"repeaterIndexes"),t};var S=Object.getOwnPropertyDescriptor,F=(n,t,s,r)=>{for(var e=r>1?void 0:r?S(t,s):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(e=o(e)||e);return e};i.WidgetElement=class extends _(c.LitElement){},i.WidgetElement=F([h.customElement("gui-widget")],i.WidgetElement);var R=Object.defineProperty,O=Object.getOwnPropertyDescriptor,u=(n,t,s,r)=>{for(var e=r>1?void 0:r?O(t,s):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(e=(r?o(t,s,e):o(e))||e);return r&&e&&R(t,s,e),e};i.FormElement=class extends c.LitElement{constructor(){super(...arguments),this.context=new E,this.autocomplete=void 0,this.direction="ltr",this.unsubscribeI18n=()=>{},this._defaultFormName=d.shortUUID()}connectedCallback(){super.connectedCallback(),this.classList.add("gui-form"),this.eventSub=this.context.events$.subscribe(t=>this.dispatchEvent(new CustomEvent(i.FormElement.FORM_EVENT,{detail:t,bubbles:!0})))}updated(t){super.updated(t),t.has("config")&&this.config&&this._reinitialize(this.config)}_reinitialize(t){this.unsubscribeI18n(),this.stateSub?.unsubscribe(),this.healthSub?.unsubscribe(),this.context.initialize(t.widgetLoaders,t.middlewares??[],this.validators,t.validateOn??"eager",t.itemRenderers??{},t.localization,t.dependencies??{}),this.direction=d.getDirectionFromLanguage(this.context.localization.lang),this.stateSub=this.context.store.state$.subscribe(s=>{this.formState=s,this.requestUpdate()}),this.healthSub=d.formHealth(this.context.store.state$).subscribe(s=>{this.dispatchEvent(new CustomEvent(i.FormElement.FORM_HEALTH_EVENT,{detail:s,bubbles:!0}))}),this.context.store.dispatch({type:"INITIALIZE",payload:{formName:t.formName??this._defaultFormName,formDef:t.formDef}}),this.context.store.dispatch({type:"SET_DATA",payload:{data:t.data??{}}}),this.context.store.dispatch({type:"SET_META",payload:{meta:t.meta??{}}}),this.unsubscribeI18n=this.context.localization.subscribe(s=>{this.direction=d.getDirectionFromLanguage(s),this.context.store.dispatch({type:"SET_LANGUAGE",payload:{lang:s}})})}createRenderRoot(){return this}render(){const t=this.formState?.formDef&&this.context.widgetRegistry.ready,s=this.config?.formName??this._defaultFormName;return c.html`
|
|
2
2
|
<form
|
|
3
3
|
id=${s}
|
|
4
4
|
novalidate
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
>
|
|
8
8
|
${x.when(t,()=>c.html` <gui-widget .widget=${this.formState?.formDef.form}></gui-widget>`,()=>c.html` <div>Loading form...</div>`)}
|
|
9
9
|
</form>
|
|
10
|
-
`}setData(t){this.context.store.dispatch({type:"SET_DATA",payload:{data:t}})}setMeta(t){this.context.store.dispatch({type:"SET_META",payload:{meta:t}})}disconnectedCallback(){super.disconnectedCallback(),this.stateSub?.unsubscribe(),this.healthSub?.unsubscribe(),this.eventSub?.unsubscribe(),this.unsubscribeI18n()}},i.FormElement.FORM_HEALTH_EVENT="formHealth",i.FormElement.FORM_EVENT="formEvent",u([
|
|
10
|
+
`}setData(t){this.context.store.dispatch({type:"SET_DATA",payload:{data:t}})}setMeta(t){this.context.store.dispatch({type:"SET_META",payload:{meta:t}})}disconnectedCallback(){super.disconnectedCallback(),this.stateSub?.unsubscribe(),this.healthSub?.unsubscribe(),this.eventSub?.unsubscribe(),this.unsubscribeI18n()}},i.FormElement.FORM_HEALTH_EVENT="formHealth",i.FormElement.FORM_EVENT="formEvent",u([p.provide({context:g})],i.FormElement.prototype,"context",2),u([h.property({attribute:!1})],i.FormElement.prototype,"config",2),u([h.property({attribute:!1})],i.FormElement.prototype,"validators",2),u([h.property({type:String})],i.FormElement.prototype,"autocomplete",2),u([h.state()],i.FormElement.prototype,"direction",2),i.FormElement=u([h.customElement("gui-core-form")],i.FormElement);var L=Object.defineProperty,f=(n,t,s,r)=>{for(var e=void 0,a=n.length-1,o;a>=0;a--)(o=n[a])&&(e=o(t,s,e)||e);return e&&L(t,s,e),e};const N=n=>{class t extends n{constructor(){super(...arguments),this.repeaterIndex=-1,this.parentRepeaterIndexes=[]}connectedCallback(){super.connectedCallback(),this.loadWidgetComponent(this.repeaterIndex)}async loadWidgetComponent(r){if(this.widget)try{const e=await this.formContext.widgetRegistry.loadWidget(this.widget.type),a=new e,o=[...this.parentRepeaterIndexes??[],r];new p.ContextProvider(a,{context:y,initialValue:o}),a.widget=d.makeRepeaterItemConfig(d.cloneObject(this.widget),o),a.id=`host-${this.widget.uid}`,this.replaceWith(a)}catch(e){console.error(`Widget "${this.widget.type}" could not be loaded`,e);const a=d.errorCodes.widgetCouldNotBeLoaded;this.dispatchEvent(new CustomEvent("formHealth",{detail:{status:"errored",message:`[${a}] Widget "${this.widget.type}" could not be loaded`,code:a},bubbles:!0,composed:!0}))}}render(){return null}}return f([p.consume({context:g}),h.property({attribute:!1})],t.prototype,"formContext"),f([h.property({type:Object})],t.prototype,"widget"),f([h.property({type:Number})],t.prototype,"repeaterIndex"),f([p.consume({context:y,subscribe:!0}),h.property({attribute:!1})],t.prototype,"parentRepeaterIndexes"),t};var P=Object.getOwnPropertyDescriptor,U=(n,t,s,r)=>{for(var e=r>1?void 0:r?P(t,s):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(e=o(e)||e);return e};i.RepeaterWidgetElement=class extends N(c.LitElement){},i.RepeaterWidgetElement=U([h.customElement("gui-repeater-widget")],i.RepeaterWidgetElement),i.ActionWidgetAdapter=C,i.BaseWidgetAdapter=m,i.DisplayWidgetAdapter=T,i.InputWidgetAdapter=$,i.LayoutWidgetAdapter=I,i.LitFormContext=E,i.actionContext=w,i.displayWidgetContext=v,i.formContext=g,i.inputContext=D,i.layoutContext=W,i.repeaterIndexesContext=y,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golemui/lit",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.umd.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"*.md"
|
|
21
21
|
],
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@golemui/core": "0.13.
|
|
23
|
+
"@golemui/core": "0.13.3",
|
|
24
24
|
"@lit/context": "^1.1.6",
|
|
25
25
|
"lit": "^3.3.1",
|
|
26
26
|
"rxjs": "^7.8.0"
|