@golemui/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 +448 -0
- package/README.md +7 -0
- package/index.d.ts +12 -0
- package/index.js +388 -0
- package/index.umd.cjs +5 -0
- package/lib/adapters/action-widget.adapter.d.ts +10 -0
- package/lib/adapters/base-widget.adapter.d.ts +15 -0
- package/lib/adapters/display.widget-adapter.d.ts +9 -0
- package/lib/adapters/input-widget.adapter.d.ts +18 -0
- package/lib/adapters/layout-widget.adapter.d.ts +10 -0
- package/lib/components/form/form.element.d.ts +27 -0
- package/lib/components/form/property.converters.d.ts +3 -0
- package/lib/components/item-renderers/item-renderer.d.ts +7 -0
- package/lib/components/widget/repeater-widget.element.d.ts +5 -0
- package/lib/components/widget/widget-element.d.ts +5 -0
- package/lib/context/form.context.d.ts +6 -0
- package/lib/context/repeater-index-token.context.d.ts +6 -0
- package/lib/mixins/repeater-widget.mixin.d.ts +2 -0
- package/lib/mixins/widget-mixin.d.ts +2 -0
- package/lib/utils/type.d.ts +3 -0
- package/package.json +28 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
## 0.19.0 (2026-03-02)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- add the novalidate attr to forms ([60189661](https://github.com/golemui/formforge/commit/60189661))
|
|
6
|
+
- **lit:** integrate i18n.lang on the calendar component ([86cba865](https://github.com/golemui/formforge/commit/86cba865))
|
|
7
|
+
- **lit:** i18n integration ([0744c6db](https://github.com/golemui/formforge/commit/0744c6db))
|
|
8
|
+
- **lit:** add list component to lit-vanilla ([a00ba79e](https://github.com/golemui/formforge/commit/a00ba79e))
|
|
9
|
+
|
|
10
|
+
### 🩹 Fixes
|
|
11
|
+
|
|
12
|
+
- **core:** update kind taxonomy ([17d0aba1](https://github.com/golemui/formforge/commit/17d0aba1))
|
|
13
|
+
|
|
14
|
+
### ❤️ Thank You
|
|
15
|
+
|
|
16
|
+
- Joan Llenas
|
|
17
|
+
- Raul Jimenez @Elecash
|
|
18
|
+
|
|
19
|
+
## 0.18.0 (2026-01-13)
|
|
20
|
+
|
|
21
|
+
### 🩹 Fixes
|
|
22
|
+
|
|
23
|
+
- **lit:** lit uid fixes ([5973338](https://github.com/golemui/formforge/commit/5973338))
|
|
24
|
+
|
|
25
|
+
### ❤️ Thank You
|
|
26
|
+
|
|
27
|
+
- Joan Llenas
|
|
28
|
+
|
|
29
|
+
## 0.17.0 (2026-01-11)
|
|
30
|
+
|
|
31
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
32
|
+
|
|
33
|
+
## 0.16.0 (2026-01-05)
|
|
34
|
+
|
|
35
|
+
### 🚀 Features
|
|
36
|
+
|
|
37
|
+
- Add support for injectedIssues to the current validation pipeline ([d7de030](https://github.com/golemui/formforge/commit/d7de030))
|
|
38
|
+
|
|
39
|
+
### 🩹 Fixes
|
|
40
|
+
|
|
41
|
+
- **lit:** update validator handling ([4302b8f](https://github.com/golemui/formforge/commit/4302b8f))
|
|
42
|
+
|
|
43
|
+
### ❤️ Thank You
|
|
44
|
+
|
|
45
|
+
- Joan Llenas
|
|
46
|
+
|
|
47
|
+
## 0.15.2 (2026-01-03)
|
|
48
|
+
|
|
49
|
+
### 🩹 Fixes
|
|
50
|
+
|
|
51
|
+
- **lit:** rename formError to formHealth ([f57b6ec](https://github.com/golemui/formforge/commit/f57b6ec))
|
|
52
|
+
|
|
53
|
+
### ❤️ Thank You
|
|
54
|
+
|
|
55
|
+
- Joan Llenas
|
|
56
|
+
|
|
57
|
+
## 0.15.1 (2025-12-27)
|
|
58
|
+
|
|
59
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
60
|
+
|
|
61
|
+
## 0.15.0 (2025-12-27)
|
|
62
|
+
|
|
63
|
+
### 🩹 Fixes
|
|
64
|
+
|
|
65
|
+
- remove unnecessary field flags ([da74dc3](https://github.com/golemui/formforge/commit/da74dc3))
|
|
66
|
+
- **lit:** update adapters to use the new reactivity ([7e2dd8c](https://github.com/golemui/formforge/commit/7e2dd8c))
|
|
67
|
+
|
|
68
|
+
### ❤️ Thank You
|
|
69
|
+
|
|
70
|
+
- Joan Llenas
|
|
71
|
+
|
|
72
|
+
## 0.14.11 (2025-12-21)
|
|
73
|
+
|
|
74
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
75
|
+
|
|
76
|
+
## 0.14.10 (2025-12-20)
|
|
77
|
+
|
|
78
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
79
|
+
|
|
80
|
+
## 0.14.9 (2025-12-20)
|
|
81
|
+
|
|
82
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
83
|
+
|
|
84
|
+
## 0.14.8 (2025-12-20)
|
|
85
|
+
|
|
86
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
87
|
+
|
|
88
|
+
## 0.14.7 (2025-12-18)
|
|
89
|
+
|
|
90
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
91
|
+
|
|
92
|
+
## 0.14.6 (2025-12-18)
|
|
93
|
+
|
|
94
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
95
|
+
|
|
96
|
+
## 0.14.5 (2025-12-17)
|
|
97
|
+
|
|
98
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
99
|
+
|
|
100
|
+
## 0.14.4 (2025-12-17)
|
|
101
|
+
|
|
102
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
103
|
+
|
|
104
|
+
## 0.14.3 (2025-12-16)
|
|
105
|
+
|
|
106
|
+
### 🩹 Fixes
|
|
107
|
+
|
|
108
|
+
- **lit:** fix lit change detection ([124b9fe](https://github.com/golemui/formforge/commit/124b9fe))
|
|
109
|
+
|
|
110
|
+
### ❤️ Thank You
|
|
111
|
+
|
|
112
|
+
- Raul Jimenez @Elecash
|
|
113
|
+
|
|
114
|
+
## 0.14.2 (2025-12-16)
|
|
115
|
+
|
|
116
|
+
### 🩹 Fixes
|
|
117
|
+
|
|
118
|
+
- minor refactors and fixes ([b413896](https://github.com/golemui/formforge/commit/b413896))
|
|
119
|
+
|
|
120
|
+
### ❤️ Thank You
|
|
121
|
+
|
|
122
|
+
- Joan Llenas
|
|
123
|
+
|
|
124
|
+
## 0.14.1 (2025-12-15)
|
|
125
|
+
|
|
126
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
127
|
+
|
|
128
|
+
## 0.14.0 (2025-12-14)
|
|
129
|
+
|
|
130
|
+
### 🚀 Features
|
|
131
|
+
|
|
132
|
+
- **lit:** add form vanilla component ([3f4fde2](https://github.com/golemui/formforge/commit/3f4fde2))
|
|
133
|
+
|
|
134
|
+
### 🩹 Fixes
|
|
135
|
+
|
|
136
|
+
- unify vanilla apis ([efd0a00](https://github.com/golemui/formforge/commit/efd0a00))
|
|
137
|
+
|
|
138
|
+
### ❤️ Thank You
|
|
139
|
+
|
|
140
|
+
- Raul Jimenez @Elecash
|
|
141
|
+
|
|
142
|
+
## 0.13.0 (2025-12-11)
|
|
143
|
+
|
|
144
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
145
|
+
|
|
146
|
+
## 0.12.0 (2025-12-11)
|
|
147
|
+
|
|
148
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
149
|
+
|
|
150
|
+
## 0.11.0 (2025-12-08)
|
|
151
|
+
|
|
152
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
153
|
+
|
|
154
|
+
## 0.10.0 (2025-12-08)
|
|
155
|
+
|
|
156
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
157
|
+
|
|
158
|
+
## 0.9.0 (2025-12-08)
|
|
159
|
+
|
|
160
|
+
### 🚀 Features
|
|
161
|
+
|
|
162
|
+
- **core:** introduce SET_FIELD_INITIAL_DATA action and update related logic ([f6c2e89](https://github.com/golemui/formforge/commit/f6c2e89))
|
|
163
|
+
|
|
164
|
+
### ❤️ Thank You
|
|
165
|
+
|
|
166
|
+
- Joan Llenas
|
|
167
|
+
|
|
168
|
+
## 0.8.0 (2025-12-07)
|
|
169
|
+
|
|
170
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
171
|
+
|
|
172
|
+
## 0.7.1 (2025-12-07)
|
|
173
|
+
|
|
174
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
175
|
+
|
|
176
|
+
## 0.7.0 (2025-12-04)
|
|
177
|
+
|
|
178
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
179
|
+
|
|
180
|
+
## 0.6.0 (2025-12-03)
|
|
181
|
+
|
|
182
|
+
### 🚀 Features
|
|
183
|
+
|
|
184
|
+
- **lit:** Add select component ([b81344e](https://github.com/golemui/formforge/commit/b81344e))
|
|
185
|
+
|
|
186
|
+
### ❤️ Thank You
|
|
187
|
+
|
|
188
|
+
- Raul Jimenez @Elecash
|
|
189
|
+
|
|
190
|
+
## 0.5.0 (2025-11-30)
|
|
191
|
+
|
|
192
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
193
|
+
|
|
194
|
+
## 0.4.0 (2025-11-30)
|
|
195
|
+
|
|
196
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
197
|
+
|
|
198
|
+
## 0.3.26 (2025-11-29)
|
|
199
|
+
|
|
200
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
201
|
+
|
|
202
|
+
## 0.3.25 (2025-11-27)
|
|
203
|
+
|
|
204
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
205
|
+
|
|
206
|
+
## 0.3.24 (2025-11-27)
|
|
207
|
+
|
|
208
|
+
### 🩹 Fixes
|
|
209
|
+
|
|
210
|
+
- **lit:** remove all lit external dependencies from builds ([1ad4504](https://github.com/golemui/formforge/commit/1ad4504))
|
|
211
|
+
|
|
212
|
+
### ❤️ Thank You
|
|
213
|
+
|
|
214
|
+
- Raul Jimenez @Elecash
|
|
215
|
+
|
|
216
|
+
## 0.3.23 (2025-11-27)
|
|
217
|
+
|
|
218
|
+
### 🩹 Fixes
|
|
219
|
+
|
|
220
|
+
- **lit:** Use experimental decorators ([77856c0](https://github.com/golemui/formforge/commit/77856c0))
|
|
221
|
+
|
|
222
|
+
### ❤️ Thank You
|
|
223
|
+
|
|
224
|
+
- Raul Jimenez @Elecash
|
|
225
|
+
|
|
226
|
+
## 0.3.22 (2025-11-27)
|
|
227
|
+
|
|
228
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
229
|
+
|
|
230
|
+
## 0.3.21 (2025-11-27)
|
|
231
|
+
|
|
232
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
233
|
+
|
|
234
|
+
## 0.3.20 (2025-11-26)
|
|
235
|
+
|
|
236
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
237
|
+
|
|
238
|
+
## 0.3.19 (2025-11-26)
|
|
239
|
+
|
|
240
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
241
|
+
|
|
242
|
+
## 0.3.18 (2025-11-26)
|
|
243
|
+
|
|
244
|
+
### 🩹 Fixes
|
|
245
|
+
|
|
246
|
+
- build all libraries with vite ([2880d7f](https://github.com/golemui/formforge/commit/2880d7f))
|
|
247
|
+
|
|
248
|
+
### ❤️ Thank You
|
|
249
|
+
|
|
250
|
+
- Raul Jimenez @Elecash
|
|
251
|
+
|
|
252
|
+
## 0.3.17 (2025-11-25)
|
|
253
|
+
|
|
254
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
255
|
+
|
|
256
|
+
## 0.3.16 (2025-11-25)
|
|
257
|
+
|
|
258
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
259
|
+
|
|
260
|
+
## 0.3.15 (2025-11-25)
|
|
261
|
+
|
|
262
|
+
### 🩹 Fixes
|
|
263
|
+
|
|
264
|
+
- build with nx ([3f423b4](https://github.com/golemui/formforge/commit/3f423b4))
|
|
265
|
+
|
|
266
|
+
### ❤️ Thank You
|
|
267
|
+
|
|
268
|
+
- Raul Jimenez @Elecash
|
|
269
|
+
|
|
270
|
+
## 0.3.14 (2025-11-24)
|
|
271
|
+
|
|
272
|
+
### 🩹 Fixes
|
|
273
|
+
|
|
274
|
+
- package.json paths in core, lit and lit-vanilla ([677e530](https://github.com/golemui/formforge/commit/677e530))
|
|
275
|
+
|
|
276
|
+
### ❤️ Thank You
|
|
277
|
+
|
|
278
|
+
- Raul Jimenez @Elecash
|
|
279
|
+
|
|
280
|
+
## 0.3.13 (2025-11-24)
|
|
281
|
+
|
|
282
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
283
|
+
|
|
284
|
+
## 0.3.12 (2025-11-24)
|
|
285
|
+
|
|
286
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
287
|
+
|
|
288
|
+
## 0.3.11 (2025-11-24)
|
|
289
|
+
|
|
290
|
+
### 🩹 Fixes
|
|
291
|
+
|
|
292
|
+
- build files to output cjs and js ([20d24ec](https://github.com/golemui/formforge/commit/20d24ec))
|
|
293
|
+
|
|
294
|
+
### ❤️ Thank You
|
|
295
|
+
|
|
296
|
+
- Raul Jimenez @Elecash
|
|
297
|
+
|
|
298
|
+
## 0.3.10 (2025-11-24)
|
|
299
|
+
|
|
300
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
301
|
+
|
|
302
|
+
## 0.3.9 (2025-11-24)
|
|
303
|
+
|
|
304
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
305
|
+
|
|
306
|
+
## 0.3.8 (2025-11-24)
|
|
307
|
+
|
|
308
|
+
### 🩹 Fixes
|
|
309
|
+
|
|
310
|
+
- build libs for es2022 and commonjs ([7a7c037](https://github.com/golemui/formforge/commit/7a7c037))
|
|
311
|
+
|
|
312
|
+
### ❤️ Thank You
|
|
313
|
+
|
|
314
|
+
- Raul Jimenez @Elecash
|
|
315
|
+
|
|
316
|
+
## 0.3.7 (2025-11-23)
|
|
317
|
+
|
|
318
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
319
|
+
|
|
320
|
+
## 0.3.6 (2025-11-23)
|
|
321
|
+
|
|
322
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
323
|
+
|
|
324
|
+
## 0.3.5 (2025-11-23)
|
|
325
|
+
|
|
326
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
327
|
+
|
|
328
|
+
## 0.3.4 (2025-11-23)
|
|
329
|
+
|
|
330
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
331
|
+
|
|
332
|
+
## 0.3.3 (2025-11-23)
|
|
333
|
+
|
|
334
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
335
|
+
|
|
336
|
+
## 0.3.2 (2025-11-23)
|
|
337
|
+
|
|
338
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
339
|
+
|
|
340
|
+
## 0.3.1 (2025-11-23)
|
|
341
|
+
|
|
342
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
343
|
+
|
|
344
|
+
## 0.3.0 (2025-11-23)
|
|
345
|
+
|
|
346
|
+
### 🚀 Features
|
|
347
|
+
|
|
348
|
+
- **validators:** Make validators pluggable ([397e67c](https://github.com/golemui/formforge/commit/397e67c))
|
|
349
|
+
|
|
350
|
+
### ❤️ Thank You
|
|
351
|
+
|
|
352
|
+
- Joan Llenas
|
|
353
|
+
|
|
354
|
+
## 0.2.4 (2025-11-22)
|
|
355
|
+
|
|
356
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
357
|
+
|
|
358
|
+
## 0.2.3 (2025-11-22)
|
|
359
|
+
|
|
360
|
+
### 🩹 Fixes
|
|
361
|
+
|
|
362
|
+
- **react:** fix react package jsons build ([b98d9e2](https://github.com/golemui/formforge/commit/b98d9e2))
|
|
363
|
+
|
|
364
|
+
### ❤️ Thank You
|
|
365
|
+
|
|
366
|
+
- Raul Jimenez @Elecash
|
|
367
|
+
|
|
368
|
+
## 0.2.2 (2025-11-22)
|
|
369
|
+
|
|
370
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
371
|
+
|
|
372
|
+
## 0.2.1 (2025-11-16)
|
|
373
|
+
|
|
374
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
375
|
+
|
|
376
|
+
## 0.2.0 (2025-11-16)
|
|
377
|
+
|
|
378
|
+
### 🚀 Features
|
|
379
|
+
|
|
380
|
+
- **lit:** integrate touched flag ([8f9d918](https://github.com/golemui/formforge/commit/8f9d918))
|
|
381
|
+
- **lit:** Integrate the validateOn flag ([747e477](https://github.com/golemui/formforge/commit/747e477))
|
|
382
|
+
|
|
383
|
+
### 🩹 Fixes
|
|
384
|
+
|
|
385
|
+
- **lit:** Add types to ValidateOnConverter ([473b98c](https://github.com/golemui/formforge/commit/473b98c))
|
|
386
|
+
- **lit:** Integrate validateOn ([08927b1](https://github.com/golemui/formforge/commit/08927b1))
|
|
387
|
+
|
|
388
|
+
### ❤️ Thank You
|
|
389
|
+
|
|
390
|
+
- Joan Llenas
|
|
391
|
+
|
|
392
|
+
## 0.1.5 (2025-11-16)
|
|
393
|
+
|
|
394
|
+
### 🩹 Fixes
|
|
395
|
+
|
|
396
|
+
- lint errors and peer dependencies ([d0f139d](https://github.com/golemui/formforge/commit/d0f139d))
|
|
397
|
+
- set build paths for release artifacts ([9760118](https://github.com/golemui/formforge/commit/9760118))
|
|
398
|
+
|
|
399
|
+
### ❤️ Thank You
|
|
400
|
+
|
|
401
|
+
- Raul Jimenez @Elecash
|
|
402
|
+
|
|
403
|
+
## 0.1.4 (2025-11-16)
|
|
404
|
+
|
|
405
|
+
### 🩹 Fixes
|
|
406
|
+
|
|
407
|
+
- set correct paths for release artifacts ([8941d2f](https://github.com/golemui/formforge/commit/8941d2f))
|
|
408
|
+
- create release tool ([7cd7845](https://github.com/golemui/formforge/commit/7cd7845))
|
|
409
|
+
|
|
410
|
+
### ❤️ Thank You
|
|
411
|
+
|
|
412
|
+
- Raul Jimenez @Elecash
|
|
413
|
+
|
|
414
|
+
## 0.1.3 (2025-11-15)
|
|
415
|
+
|
|
416
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
417
|
+
|
|
418
|
+
## 0.1.2 (2025-11-15)
|
|
419
|
+
|
|
420
|
+
This was a version bump only for lit to align it with other projects, there were no code changes.
|
|
421
|
+
|
|
422
|
+
## 0.1.1 (2025-11-15)
|
|
423
|
+
|
|
424
|
+
### 🩹 Fixes
|
|
425
|
+
|
|
426
|
+
- update dependencies on libraries ([374b3c9](https://github.com/golemui/formforge/commit/374b3c9))
|
|
427
|
+
|
|
428
|
+
### ❤️ Thank You
|
|
429
|
+
|
|
430
|
+
- Raul Jimenez @Elecash
|
|
431
|
+
|
|
432
|
+
## 0.1.0 (2025-11-15)
|
|
433
|
+
|
|
434
|
+
### 🚀 Features
|
|
435
|
+
|
|
436
|
+
- **lit:** Add lit vanilla components, create shared lib for playgrounds ([3e34ad1](https://github.com/golemui/formforge/commit/3e34ad1))
|
|
437
|
+
- **lit:** Add lit element support ([a122d2d](https://github.com/golemui/formforge/commit/a122d2d))
|
|
438
|
+
|
|
439
|
+
### 🩹 Fixes
|
|
440
|
+
|
|
441
|
+
- Integrate custom validators on lit and react projects ([b109a1b](https://github.com/golemui/formforge/commit/b109a1b))
|
|
442
|
+
- **lit:** Fix lit form element event dispatching ([5669e26](https://github.com/golemui/formforge/commit/5669e26))
|
|
443
|
+
- **core:** Rename Button to Interactive ([25fcea3](https://github.com/golemui/formforge/commit/25fcea3))
|
|
444
|
+
|
|
445
|
+
### ❤️ Thank You
|
|
446
|
+
|
|
447
|
+
- Joan Llenas
|
|
448
|
+
- Raul Jimenez @Elecash
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './lib/adapters/base-widget.adapter';
|
|
2
|
+
export * from './lib/adapters/input-widget.adapter';
|
|
3
|
+
export * from './lib/adapters/display.widget-adapter';
|
|
4
|
+
export * from './lib/adapters/action-widget.adapter';
|
|
5
|
+
export * from './lib/adapters/layout-widget.adapter';
|
|
6
|
+
export * from './lib/components/widget/widget-element';
|
|
7
|
+
export * from './lib/components/widget/repeater-widget.element';
|
|
8
|
+
export * from './lib/components/form/form.element';
|
|
9
|
+
export * from './lib/components/item-renderers/item-renderer';
|
|
10
|
+
export * from './lib/context/form.context';
|
|
11
|
+
export * from './lib/context/repeater-index-token.context';
|
|
12
|
+
export * from './lib/utils/type';
|
package/index.js
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import * as p from "@golemui/core";
|
|
2
|
+
import { Subject as T, takeUntil as h, combineLatest as $ } from "rxjs";
|
|
3
|
+
import { createContext as l, consume as x, provide as E, ContextProvider as I } from "@lit/context";
|
|
4
|
+
import { LitElement as f, html as y } from "lit";
|
|
5
|
+
import { property as n, customElement as w, state as _ } from "lit/decorators.js";
|
|
6
|
+
import { when as W } from "lit/directives/when.js";
|
|
7
|
+
class g {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.templateData = {}, this.destroy$ = new T(), this.templateDataChanged$ = new T();
|
|
10
|
+
}
|
|
11
|
+
setTemplateData(t) {
|
|
12
|
+
this.templateData = { ...this.templateData, ...t }, this.templateDataChanged$.next();
|
|
13
|
+
}
|
|
14
|
+
addWidgetToTheStore(t) {
|
|
15
|
+
this.context.store.dispatch({
|
|
16
|
+
type: "ADD_WIDGET",
|
|
17
|
+
payload: { widget: t }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
// Listen to the calculated props stream and keep all widget props merged in a flattened object
|
|
21
|
+
templateDataUpdater() {
|
|
22
|
+
this.context.store.state$.pipe(h(this.destroy$), p.calculatedWidgetsByUid$(this.widget.uid)).subscribe((t) => {
|
|
23
|
+
this.setTemplateData({
|
|
24
|
+
...t,
|
|
25
|
+
...t.props,
|
|
26
|
+
lang: this.context.store.getState().lang
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
destroy() {
|
|
31
|
+
this.context.store.dispatch({
|
|
32
|
+
type: "REMOVE_WIDGET",
|
|
33
|
+
payload: { uid: this.widget.uid }
|
|
34
|
+
}), this.destroy$.next();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const Z = l("guiInputWidgetAdapter");
|
|
38
|
+
class q extends g {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments), this.templateData = {};
|
|
41
|
+
}
|
|
42
|
+
init(t) {
|
|
43
|
+
this.widget = t, this.addWidgetToTheStore(t), this.templateDataUpdater(), this.context.store.dispatch({
|
|
44
|
+
type: "SET_WIDGET_INITIAL_DATA",
|
|
45
|
+
payload: { data: t.defaultValue, path: t.path }
|
|
46
|
+
}), this.context.store.state$.pipe(h(this.destroy$), p.dataByPath$(t.path)).subscribe((e) => this.setTemplateData({ value: e }));
|
|
47
|
+
const a = this.context.store.state$.pipe(
|
|
48
|
+
h(this.destroy$),
|
|
49
|
+
p.validationByPath$(t.path)
|
|
50
|
+
), r = this.context.store.state$.pipe(
|
|
51
|
+
h(this.destroy$),
|
|
52
|
+
p.injectedValidationByPath$(t.path)
|
|
53
|
+
);
|
|
54
|
+
$([a, r]).subscribe(
|
|
55
|
+
([e, s]) => {
|
|
56
|
+
this.setTemplateData({
|
|
57
|
+
errors: [...e ?? [], ...s ?? []]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
), this.context.store.state$.pipe(h(this.destroy$), p.touchedControlsByPath$(t.path)).subscribe((e) => this.setTemplateData({ touched: e })), this.context.emitEvent("load", this.widget);
|
|
61
|
+
}
|
|
62
|
+
valueChanged(t) {
|
|
63
|
+
this.context.store.dispatch({
|
|
64
|
+
type: "SET_WIDGET_DATA",
|
|
65
|
+
payload: { path: this.widget.path, data: t }
|
|
66
|
+
}), this.context.emitEvent("change", this.widget);
|
|
67
|
+
}
|
|
68
|
+
filterChanged(t) {
|
|
69
|
+
this.context.emitEvent("filter", this.widget, t);
|
|
70
|
+
}
|
|
71
|
+
injectValidationIssues(t) {
|
|
72
|
+
this.context.store.dispatch({
|
|
73
|
+
type: "INJECT_VALIDATION_ISSUES",
|
|
74
|
+
payload: { path: this.widget.path, issues: t }
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* This is a helper to get the item renderer from the context
|
|
79
|
+
*/
|
|
80
|
+
getItemRenderer(t, a) {
|
|
81
|
+
return t ? this.context.itemRenderers[t] : a;
|
|
82
|
+
}
|
|
83
|
+
onBlur() {
|
|
84
|
+
this.context.store.dispatch({
|
|
85
|
+
type: "ATTEMPT_VALIDATION",
|
|
86
|
+
payload: { reason: "blur", path: this.widget.path, uid: this.widget.uid }
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const Q = l("guiDisplayWidgetAdapter");
|
|
91
|
+
class X extends g {
|
|
92
|
+
constructor() {
|
|
93
|
+
super(...arguments), this.templateData = {};
|
|
94
|
+
}
|
|
95
|
+
init(t) {
|
|
96
|
+
this.widget = t, this.setTemplateData({
|
|
97
|
+
...this.widget.props
|
|
98
|
+
}), this.addWidgetToTheStore(t), this.templateDataUpdater();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const Y = l("guiActionWidgetAdapter");
|
|
102
|
+
class K extends g {
|
|
103
|
+
constructor() {
|
|
104
|
+
super(...arguments), this.templateData = {};
|
|
105
|
+
}
|
|
106
|
+
init(t) {
|
|
107
|
+
this.widget = t, this.setTemplateData({
|
|
108
|
+
label: this.widget.label
|
|
109
|
+
}), this.addWidgetToTheStore(t), this.templateDataUpdater(), this.context.emitEvent("load", this.widget);
|
|
110
|
+
}
|
|
111
|
+
click() {
|
|
112
|
+
this.context.emitEvent("click", this.widget);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const tt = l("guiLayoutWidgetAdapter");
|
|
116
|
+
class et extends g {
|
|
117
|
+
constructor() {
|
|
118
|
+
super(...arguments), this.templateData = {};
|
|
119
|
+
}
|
|
120
|
+
init(t) {
|
|
121
|
+
this.widget = t, this.setTemplateData({
|
|
122
|
+
...this.widget.props
|
|
123
|
+
}), this.context.store.state$.pipe(p.calculatedLayoutChildrenByUid$(this.widget.uid)).pipe(h(this.destroy$)).subscribe((a) => {
|
|
124
|
+
this.setTemplateData({
|
|
125
|
+
children: a
|
|
126
|
+
});
|
|
127
|
+
}), this.addWidgetToTheStore(t), this.templateDataUpdater();
|
|
128
|
+
}
|
|
129
|
+
change(t) {
|
|
130
|
+
this.context.emitEvent("change", this.widget, t);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const v = l("guiFormContext");
|
|
134
|
+
class A extends p.FormContext {
|
|
135
|
+
// Just a subclass to make Core.FormContext Injectable
|
|
136
|
+
}
|
|
137
|
+
const b = l("guiRepeaterIndexContext");
|
|
138
|
+
class O {
|
|
139
|
+
constructor() {
|
|
140
|
+
this.index = -1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
var R = Object.defineProperty, u = (i, t, a, r) => {
|
|
144
|
+
for (var e = void 0, s = i.length - 1, d; s >= 0; s--)
|
|
145
|
+
(d = i[s]) && (e = d(t, a, e) || e);
|
|
146
|
+
return e && R(t, a, e), e;
|
|
147
|
+
};
|
|
148
|
+
const N = (i) => {
|
|
149
|
+
class t extends i {
|
|
150
|
+
connectedCallback() {
|
|
151
|
+
super.connectedCallback?.(), this.loadWidgetComponent();
|
|
152
|
+
}
|
|
153
|
+
async loadWidgetComponent() {
|
|
154
|
+
if (this.widget)
|
|
155
|
+
try {
|
|
156
|
+
const r = await this.formContext.widgetRegistry.loadWidget(this.widget.type), e = new r(), s = this.repeaterIndex ?? this.repeaterIndexToken?.index;
|
|
157
|
+
e.widget = typeof s == "number" && !Number.isNaN(s) && s > -1 ? p.makeRepeaterItemConfig(p.cloneObject(this.widget), s) : this.widget, e.id = `host-${this.widget.uid}`, this.replaceWith(e);
|
|
158
|
+
} catch (r) {
|
|
159
|
+
console.error(`Widget "${this.widget.type}" could not be loaded`, r), this.dispatchEvent(
|
|
160
|
+
new CustomEvent("formHealth", {
|
|
161
|
+
detail: {
|
|
162
|
+
status: "errored",
|
|
163
|
+
message: `Widget "${this.widget.type}" could not be loaded`
|
|
164
|
+
},
|
|
165
|
+
bubbles: !0,
|
|
166
|
+
composed: !0
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
render() {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return u([
|
|
176
|
+
x({ context: v }),
|
|
177
|
+
n({ attribute: !1 })
|
|
178
|
+
], t.prototype, "formContext"), u([
|
|
179
|
+
n({ type: Object })
|
|
180
|
+
], t.prototype, "widget"), u([
|
|
181
|
+
n({ type: Number })
|
|
182
|
+
], t.prototype, "repeaterIndex"), u([
|
|
183
|
+
x({ context: b, subscribe: !0 }),
|
|
184
|
+
n({ attribute: !1 })
|
|
185
|
+
], t.prototype, "repeaterIndexToken"), t;
|
|
186
|
+
};
|
|
187
|
+
var j = Object.getOwnPropertyDescriptor, L = (i, t, a, r) => {
|
|
188
|
+
for (var e = r > 1 ? void 0 : r ? j(t, a) : t, s = i.length - 1, d; s >= 0; s--)
|
|
189
|
+
(d = i[s]) && (e = d(e) || e);
|
|
190
|
+
return e;
|
|
191
|
+
};
|
|
192
|
+
let D = class extends N(f) {
|
|
193
|
+
};
|
|
194
|
+
D = L([
|
|
195
|
+
w("gui-widget")
|
|
196
|
+
], D);
|
|
197
|
+
var P = Object.defineProperty, m = (i, t, a, r) => {
|
|
198
|
+
for (var e = void 0, s = i.length - 1, d; s >= 0; s--)
|
|
199
|
+
(d = i[s]) && (e = d(t, a, e) || e);
|
|
200
|
+
return e && P(t, a, e), e;
|
|
201
|
+
};
|
|
202
|
+
const S = (i) => {
|
|
203
|
+
class t extends i {
|
|
204
|
+
constructor() {
|
|
205
|
+
super(...arguments), this.repeaterIndex = -1, this.repeaterIndexToken = new O();
|
|
206
|
+
}
|
|
207
|
+
connectedCallback() {
|
|
208
|
+
super.connectedCallback(), this.loadWidgetComponent(this.repeaterIndex);
|
|
209
|
+
}
|
|
210
|
+
async loadWidgetComponent(r) {
|
|
211
|
+
if (this.widget)
|
|
212
|
+
try {
|
|
213
|
+
const e = await this.formContext.widgetRegistry.loadWidget(this.widget.type), s = new e();
|
|
214
|
+
this.repeaterIndexToken.index = r, new I(s, b, this.repeaterIndexToken), s.widget = p.makeRepeaterItemConfig(p.cloneObject(this.widget), r), s.id = `host-${this.widget.uid}`, this.replaceWith(s);
|
|
215
|
+
} catch (e) {
|
|
216
|
+
console.error(`Widget "${this.widget.type}" could not be loaded`, e), this.dispatchEvent(
|
|
217
|
+
new CustomEvent("formHealth", {
|
|
218
|
+
detail: {
|
|
219
|
+
status: "errored",
|
|
220
|
+
message: `Widget "${this.widget.type}" could not be loaded`
|
|
221
|
+
},
|
|
222
|
+
bubbles: !0,
|
|
223
|
+
composed: !0
|
|
224
|
+
})
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
render() {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return m([
|
|
233
|
+
x({ context: v }),
|
|
234
|
+
n({ attribute: !1 })
|
|
235
|
+
], t.prototype, "formContext"), m([
|
|
236
|
+
n({ type: Object })
|
|
237
|
+
], t.prototype, "widget"), m([
|
|
238
|
+
n({ type: Number })
|
|
239
|
+
], t.prototype, "repeaterIndex"), m([
|
|
240
|
+
E({ context: b })
|
|
241
|
+
], t.prototype, "repeaterIndexToken"), t;
|
|
242
|
+
};
|
|
243
|
+
var k = Object.getOwnPropertyDescriptor, U = (i, t, a, r) => {
|
|
244
|
+
for (var e = r > 1 ? void 0 : r ? k(t, a) : t, s = i.length - 1, d; s >= 0; s--)
|
|
245
|
+
(d = i[s]) && (e = d(e) || e);
|
|
246
|
+
return e;
|
|
247
|
+
};
|
|
248
|
+
let C = class extends S(f) {
|
|
249
|
+
};
|
|
250
|
+
C = U([
|
|
251
|
+
w("gui-repeater-widget")
|
|
252
|
+
], C);
|
|
253
|
+
const V = {
|
|
254
|
+
fromAttribute(i) {
|
|
255
|
+
if (i !== null) {
|
|
256
|
+
try {
|
|
257
|
+
const t = JSON.parse(i);
|
|
258
|
+
if (Array.isArray(t))
|
|
259
|
+
return t;
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
return i;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
var F = Object.defineProperty, M = Object.getOwnPropertyDescriptor, c = (i, t, a, r) => {
|
|
267
|
+
for (var e = r > 1 ? void 0 : r ? M(t, a) : t, s = i.length - 1, d; s >= 0; s--)
|
|
268
|
+
(d = i[s]) && (e = (r ? d(t, a, e) : d(e)) || e);
|
|
269
|
+
return r && e && F(t, a, e), e;
|
|
270
|
+
};
|
|
271
|
+
let o = class extends f {
|
|
272
|
+
constructor() {
|
|
273
|
+
super(...arguments), this.context = new A(), this.formDef = {}, this.middlewares = [], this.data = {}, this.formName = p.shortUUID(), this.validateOn = "eager", this.itemRenderers = {}, this.direction = "ltr", this.subscriptions = [], this.unsubscribeI18n = () => {
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
connectedCallback() {
|
|
277
|
+
super.connectedCallback(), this.classList.add("gui-form"), this.context.initialize(
|
|
278
|
+
this.widgetLoaders,
|
|
279
|
+
this.middlewares,
|
|
280
|
+
this.validators,
|
|
281
|
+
this.validateOn,
|
|
282
|
+
this.itemRenderers,
|
|
283
|
+
this.localization
|
|
284
|
+
), this.direction = p.getDirectionFromLanguage(this.context.localization.lang), this.subscriptions.push(
|
|
285
|
+
this.context.store.state$.subscribe((i) => this.state = i),
|
|
286
|
+
p.formHealth(this.context.store.state$).subscribe((i) => {
|
|
287
|
+
this.dispatchEvent(
|
|
288
|
+
new CustomEvent(o.FORM_HEALTH_EVENT, {
|
|
289
|
+
detail: i,
|
|
290
|
+
bubbles: !0
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
}),
|
|
294
|
+
this.context.events$.subscribe(
|
|
295
|
+
(i) => this.dispatchEvent(
|
|
296
|
+
new CustomEvent(o.FORM_EVENT, { detail: i, bubbles: !0 })
|
|
297
|
+
)
|
|
298
|
+
)
|
|
299
|
+
), this.context.store.dispatch({
|
|
300
|
+
type: "INITIALIZE",
|
|
301
|
+
payload: { formName: this.formName, formDef: this.formDef }
|
|
302
|
+
}), this.context.store.dispatch({
|
|
303
|
+
type: "SET_DATA",
|
|
304
|
+
payload: { data: this.data }
|
|
305
|
+
}), this.unsubscribeI18n = this.context.localization.subscribe((i) => {
|
|
306
|
+
this.direction = p.getDirectionFromLanguage(i), this.context.store.dispatch({
|
|
307
|
+
type: "SET_LANGUAGE",
|
|
308
|
+
payload: {
|
|
309
|
+
lang: i
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
createRenderRoot() {
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
317
|
+
render() {
|
|
318
|
+
const i = this.state?.formDef && this.context.widgetRegistry.ready;
|
|
319
|
+
return y`
|
|
320
|
+
<form id=${this.formName} novalidate dir=${this.direction}>
|
|
321
|
+
${W(
|
|
322
|
+
i,
|
|
323
|
+
() => y` <gui-widget .widget=${this.state?.formDef.form}></gui-widget>`,
|
|
324
|
+
() => y` <div>Loading form...</div>`
|
|
325
|
+
)}
|
|
326
|
+
</form>
|
|
327
|
+
`;
|
|
328
|
+
}
|
|
329
|
+
disconnectedCallback() {
|
|
330
|
+
super.disconnectedCallback(), this.subscriptions.forEach((i) => i.unsubscribe()), this.unsubscribeI18n();
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
o.FORM_HEALTH_EVENT = "formHealth";
|
|
334
|
+
o.FORM_EVENT = "formEvent";
|
|
335
|
+
c([
|
|
336
|
+
E({ context: v })
|
|
337
|
+
], o.prototype, "context", 2);
|
|
338
|
+
c([
|
|
339
|
+
n({ type: Object })
|
|
340
|
+
], o.prototype, "formDef", 2);
|
|
341
|
+
c([
|
|
342
|
+
n({ type: Object })
|
|
343
|
+
], o.prototype, "widgetLoaders", 2);
|
|
344
|
+
c([
|
|
345
|
+
n({ attribute: !1 })
|
|
346
|
+
], o.prototype, "validators", 2);
|
|
347
|
+
c([
|
|
348
|
+
n({ type: Array })
|
|
349
|
+
], o.prototype, "middlewares", 2);
|
|
350
|
+
c([
|
|
351
|
+
n({ type: Object })
|
|
352
|
+
], o.prototype, "data", 2);
|
|
353
|
+
c([
|
|
354
|
+
n({ type: String })
|
|
355
|
+
], o.prototype, "formName", 2);
|
|
356
|
+
c([
|
|
357
|
+
n({ converter: V })
|
|
358
|
+
], o.prototype, "validateOn", 2);
|
|
359
|
+
c([
|
|
360
|
+
n({ type: Object })
|
|
361
|
+
], o.prototype, "itemRenderers", 2);
|
|
362
|
+
c([
|
|
363
|
+
n({ type: Object })
|
|
364
|
+
], o.prototype, "localization", 2);
|
|
365
|
+
c([
|
|
366
|
+
_()
|
|
367
|
+
], o.prototype, "direction", 2);
|
|
368
|
+
o = c([
|
|
369
|
+
w("gui-core-form")
|
|
370
|
+
], o);
|
|
371
|
+
export {
|
|
372
|
+
K as ActionWidgetAdapter,
|
|
373
|
+
g as BaseWidgetAdapter,
|
|
374
|
+
X as DisplayWidgetAdapter,
|
|
375
|
+
o as FormElement,
|
|
376
|
+
q as InputWidgetAdapter,
|
|
377
|
+
et as LayoutWidgetAdapter,
|
|
378
|
+
A as LitFormContext,
|
|
379
|
+
O as RepeaterIndexTokenContext,
|
|
380
|
+
C as RepeaterWidgetElement,
|
|
381
|
+
D as WidgetElement,
|
|
382
|
+
Y as actionContext,
|
|
383
|
+
Q as displayWidgetContext,
|
|
384
|
+
v as formContext,
|
|
385
|
+
Z as inputContext,
|
|
386
|
+
tt as layoutContext,
|
|
387
|
+
b as repeaterIndexTokenContext
|
|
388
|
+
};
|
package/index.umd.cjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(function(e,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@golemui/core"),require("rxjs"),require("@lit/context"),require("lit"),require("lit/decorators.js"),require("lit/directives/when.js")):typeof define=="function"&&define.amd?define(["exports","@golemui/core","rxjs","@lit/context","lit","lit/decorators.js","lit/directives/when.js"],u):(e=typeof globalThis<"u"?globalThis:e||self,u(e.lit={},e.Core,e.rxjs,e.context,e.lit,e.decorators_js,e.when_js))})(this,(function(e,u,h,l,m,o,C){"use strict";function T(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:()=>n[a]})}}return t.default=n,Object.freeze(t)}const d=T(u);class g{constructor(){this.templateData={},this.destroy$=new h.Subject,this.templateDataChanged$=new h.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(h.takeUntil(this.destroy$),d.calculatedWidgetsByUid$(this.widget.uid)).subscribe(t=>{this.setTemplateData({...t,...t.props,lang:this.context.store.getState().lang})})}destroy(){this.context.store.dispatch({type:"REMOVE_WIDGET",payload:{uid:this.widget.uid}}),this.destroy$.next()}}const x=l.createContext("guiInputWidgetAdapter");class D extends g{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(h.takeUntil(this.destroy$),d.dataByPath$(t.path)).subscribe(i=>this.setTemplateData({value:i}));const a=this.context.store.state$.pipe(h.takeUntil(this.destroy$),d.validationByPath$(t.path)),s=this.context.store.state$.pipe(h.takeUntil(this.destroy$),d.injectedValidationByPath$(t.path));h.combineLatest([a,s]).subscribe(([i,r])=>{this.setTemplateData({errors:[...i??[],...r??[]]})}),this.context.store.state$.pipe(h.takeUntil(this.destroy$),d.touchedControlsByPath$(t.path)).subscribe(i=>this.setTemplateData({touched:i})),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,a){return t?this.context.itemRenderers[t]:a}onBlur(){this.context.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"blur",path:this.widget.path,uid:this.widget.uid}})}}const W=l.createContext("guiDisplayWidgetAdapter");class $ extends g{constructor(){super(...arguments),this.templateData={}}init(t){this.widget=t,this.setTemplateData({...this.widget.props}),this.addWidgetToTheStore(t),this.templateDataUpdater()}}const I=l.createContext("guiActionWidgetAdapter");class A extends g{constructor(){super(...arguments),this.templateData={}}init(t){this.widget=t,this.setTemplateData({label:this.widget.label}),this.addWidgetToTheStore(t),this.templateDataUpdater(),this.context.emitEvent("load",this.widget)}click(){this.context.emitEvent("click",this.widget)}}const O=l.createContext("guiLayoutWidgetAdapter");class F extends g{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(h.takeUntil(this.destroy$)).subscribe(a=>{this.setTemplateData({children:a})}),this.addWidgetToTheStore(t),this.templateDataUpdater()}change(t){this.context.emitEvent("change",this.widget,t)}}const y=l.createContext("guiFormContext");class w extends d.FormContext{}const f=l.createContext("guiRepeaterIndexContext");class v{constructor(){this.index=-1}}var R=Object.defineProperty,b=(n,t,a,s)=>{for(var i=void 0,r=n.length-1,p;r>=0;r--)(p=n[r])&&(i=p(t,a,i)||i);return i&&R(t,a,i),i};const _=n=>{class t extends n{connectedCallback(){super.connectedCallback?.(),this.loadWidgetComponent()}async loadWidgetComponent(){if(this.widget)try{const s=await this.formContext.widgetRegistry.loadWidget(this.widget.type),i=new s,r=this.repeaterIndex??this.repeaterIndexToken?.index;i.widget=typeof r=="number"&&!Number.isNaN(r)&&r>-1?d.makeRepeaterItemConfig(d.cloneObject(this.widget),r):this.widget,i.id=`host-${this.widget.uid}`,this.replaceWith(i)}catch(s){console.error(`Widget "${this.widget.type}" could not be loaded`,s),this.dispatchEvent(new CustomEvent("formHealth",{detail:{status:"errored",message:`Widget "${this.widget.type}" could not be loaded`},bubbles:!0,composed:!0}))}}render(){return null}}return b([l.consume({context:y}),o.property({attribute:!1})],t.prototype,"formContext"),b([o.property({type:Object})],t.prototype,"widget"),b([o.property({type:Number})],t.prototype,"repeaterIndex"),b([l.consume({context:f,subscribe:!0}),o.property({attribute:!1})],t.prototype,"repeaterIndexToken"),t};var L=Object.getOwnPropertyDescriptor,k=(n,t,a,s)=>{for(var i=s>1?void 0:s?L(t,a):t,r=n.length-1,p;r>=0;r--)(p=n[r])&&(i=p(i)||i);return i};e.WidgetElement=class extends _(m.LitElement){},e.WidgetElement=k([o.customElement("gui-widget")],e.WidgetElement);var N=Object.defineProperty,E=(n,t,a,s)=>{for(var i=void 0,r=n.length-1,p;r>=0;r--)(p=n[r])&&(i=p(t,a,i)||i);return i&&N(t,a,i),i};const P=n=>{class t extends n{constructor(){super(...arguments),this.repeaterIndex=-1,this.repeaterIndexToken=new v}connectedCallback(){super.connectedCallback(),this.loadWidgetComponent(this.repeaterIndex)}async loadWidgetComponent(s){if(this.widget)try{const i=await this.formContext.widgetRegistry.loadWidget(this.widget.type),r=new i;this.repeaterIndexToken.index=s,new l.ContextProvider(r,f,this.repeaterIndexToken),r.widget=d.makeRepeaterItemConfig(d.cloneObject(this.widget),s),r.id=`host-${this.widget.uid}`,this.replaceWith(r)}catch(i){console.error(`Widget "${this.widget.type}" could not be loaded`,i),this.dispatchEvent(new CustomEvent("formHealth",{detail:{status:"errored",message:`Widget "${this.widget.type}" could not be loaded`},bubbles:!0,composed:!0}))}}render(){return null}}return E([l.consume({context:y}),o.property({attribute:!1})],t.prototype,"formContext"),E([o.property({type:Object})],t.prototype,"widget"),E([o.property({type:Number})],t.prototype,"repeaterIndex"),E([l.provide({context:f})],t.prototype,"repeaterIndexToken"),t};var S=Object.getOwnPropertyDescriptor,U=(n,t,a,s)=>{for(var i=s>1?void 0:s?S(t,a):t,r=n.length-1,p;r>=0;r--)(p=n[r])&&(i=p(i)||i);return i};e.RepeaterWidgetElement=class extends P(m.LitElement){},e.RepeaterWidgetElement=U([o.customElement("gui-repeater-widget")],e.RepeaterWidgetElement);const V={fromAttribute(n){if(n!==null){try{const t=JSON.parse(n);if(Array.isArray(t))return t}catch{}return n}}};var M=Object.defineProperty,B=Object.getOwnPropertyDescriptor,c=(n,t,a,s)=>{for(var i=s>1?void 0:s?B(t,a):t,r=n.length-1,p;r>=0;r--)(p=n[r])&&(i=(s?p(t,a,i):p(i))||i);return s&&i&&M(t,a,i),i};e.FormElement=class extends m.LitElement{constructor(){super(...arguments),this.context=new w,this.formDef={},this.middlewares=[],this.data={},this.formName=d.shortUUID(),this.validateOn="eager",this.itemRenderers={},this.direction="ltr",this.subscriptions=[],this.unsubscribeI18n=()=>{}}connectedCallback(){super.connectedCallback(),this.classList.add("gui-form"),this.context.initialize(this.widgetLoaders,this.middlewares,this.validators,this.validateOn,this.itemRenderers,this.localization),this.direction=d.getDirectionFromLanguage(this.context.localization.lang),this.subscriptions.push(this.context.store.state$.subscribe(t=>this.state=t),d.formHealth(this.context.store.state$).subscribe(t=>{this.dispatchEvent(new CustomEvent(e.FormElement.FORM_HEALTH_EVENT,{detail:t,bubbles:!0}))}),this.context.events$.subscribe(t=>this.dispatchEvent(new CustomEvent(e.FormElement.FORM_EVENT,{detail:t,bubbles:!0})))),this.context.store.dispatch({type:"INITIALIZE",payload:{formName:this.formName,formDef:this.formDef}}),this.context.store.dispatch({type:"SET_DATA",payload:{data:this.data}}),this.unsubscribeI18n=this.context.localization.subscribe(t=>{this.direction=d.getDirectionFromLanguage(t),this.context.store.dispatch({type:"SET_LANGUAGE",payload:{lang:t}})})}createRenderRoot(){return this}render(){const t=this.state?.formDef&&this.context.widgetRegistry.ready;return m.html`
|
|
2
|
+
<form id=${this.formName} novalidate dir=${this.direction}>
|
|
3
|
+
${C.when(t,()=>m.html` <gui-widget .widget=${this.state?.formDef.form}></gui-widget>`,()=>m.html` <div>Loading form...</div>`)}
|
|
4
|
+
</form>
|
|
5
|
+
`}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(t=>t.unsubscribe()),this.unsubscribeI18n()}},e.FormElement.FORM_HEALTH_EVENT="formHealth",e.FormElement.FORM_EVENT="formEvent",c([l.provide({context:y})],e.FormElement.prototype,"context",2),c([o.property({type:Object})],e.FormElement.prototype,"formDef",2),c([o.property({type:Object})],e.FormElement.prototype,"widgetLoaders",2),c([o.property({attribute:!1})],e.FormElement.prototype,"validators",2),c([o.property({type:Array})],e.FormElement.prototype,"middlewares",2),c([o.property({type:Object})],e.FormElement.prototype,"data",2),c([o.property({type:String})],e.FormElement.prototype,"formName",2),c([o.property({converter:V})],e.FormElement.prototype,"validateOn",2),c([o.property({type:Object})],e.FormElement.prototype,"itemRenderers",2),c([o.property({type:Object})],e.FormElement.prototype,"localization",2),c([o.state()],e.FormElement.prototype,"direction",2),e.FormElement=c([o.customElement("gui-core-form")],e.FormElement),e.ActionWidgetAdapter=A,e.BaseWidgetAdapter=g,e.DisplayWidgetAdapter=$,e.InputWidgetAdapter=D,e.LayoutWidgetAdapter=F,e.LitFormContext=w,e.RepeaterIndexTokenContext=v,e.actionContext=I,e.displayWidgetContext=W,e.formContext=y,e.inputContext=x,e.layoutContext=O,e.repeaterIndexTokenContext=f,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseWidgetAdapter } from './base-widget.adapter';
|
|
2
|
+
import * as Core from '@golemui/core';
|
|
3
|
+
export declare const actionContext: {
|
|
4
|
+
__context__: ActionWidgetAdapter;
|
|
5
|
+
};
|
|
6
|
+
export declare class ActionWidgetAdapter extends BaseWidgetAdapter<Core.ActionWidget> {
|
|
7
|
+
templateData: Core.ActionWidgetTemplateData;
|
|
8
|
+
init(widget: Core.ActionWidget): void;
|
|
9
|
+
click(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WithWidget } from '@golemui/core';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import { LitFormContext } from '../context/form.context';
|
|
4
|
+
import * as Core from '@golemui/core';
|
|
5
|
+
export declare abstract class BaseWidgetAdapter<F extends Core.FormWidget> {
|
|
6
|
+
context: LitFormContext<WithWidget>;
|
|
7
|
+
templateData: any;
|
|
8
|
+
protected destroy$: Subject<void>;
|
|
9
|
+
protected widget: F;
|
|
10
|
+
templateDataChanged$: Subject<void>;
|
|
11
|
+
protected setTemplateData(patch: any): void;
|
|
12
|
+
protected addWidgetToTheStore(widget: F): void;
|
|
13
|
+
protected templateDataUpdater(): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseWidgetAdapter } from './base-widget.adapter';
|
|
2
|
+
import * as Core from '@golemui/core';
|
|
3
|
+
export declare const displayWidgetContext: {
|
|
4
|
+
__context__: DisplayWidgetAdapter<any>;
|
|
5
|
+
};
|
|
6
|
+
export declare class DisplayWidgetAdapter<ExtraProps extends Record<string, any>> extends BaseWidgetAdapter<Core.DisplayWidget> {
|
|
7
|
+
templateData: Core.DisplayWidgetTemplateData & ExtraProps;
|
|
8
|
+
init(widget: Core.DisplayWidget): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitItemRenderer } from '../components/item-renderers/item-renderer';
|
|
2
|
+
import { BaseWidgetAdapter } from './base-widget.adapter';
|
|
3
|
+
import * as Core from '@golemui/core';
|
|
4
|
+
export declare const inputContext: {
|
|
5
|
+
__context__: InputWidgetAdapter<any, any>;
|
|
6
|
+
};
|
|
7
|
+
export declare class InputWidgetAdapter<T, ExtraProps extends Record<string, any>> extends BaseWidgetAdapter<Core.InputWidget<T>> {
|
|
8
|
+
templateData: Core.ControlTemplateData<T> & ExtraProps;
|
|
9
|
+
init(widget: Core.InputWidget<T>): void;
|
|
10
|
+
valueChanged<T>(value: T): void;
|
|
11
|
+
filterChanged<T>(value: T): void;
|
|
12
|
+
injectValidationIssues(issues: string[] | null): void;
|
|
13
|
+
/**
|
|
14
|
+
* This is a helper to get the item renderer from the context
|
|
15
|
+
*/
|
|
16
|
+
getItemRenderer<T extends Core.ItemRenderItemData>(itemRendererKey: string | undefined, defaultItemRenderer: LitItemRenderer<T>): LitItemRenderer<T>;
|
|
17
|
+
onBlur(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseWidgetAdapter } from './base-widget.adapter';
|
|
2
|
+
import * as Core from '@golemui/core';
|
|
3
|
+
export declare const layoutContext: {
|
|
4
|
+
__context__: LayoutWidgetAdapter<any>;
|
|
5
|
+
};
|
|
6
|
+
export declare class LayoutWidgetAdapter<ExtraProps extends Record<string, any>> extends BaseWidgetAdapter<Core.LayoutWidget> {
|
|
7
|
+
templateData: Core.LayoutTemplateData & ExtraProps;
|
|
8
|
+
init(widget: Core.LayoutWidget): void;
|
|
9
|
+
change<T>(detail?: T): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { State, WidgetLoaders, WithWidget } from '@golemui/core';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
4
|
+
import { LitFormContext } from '../../context/form.context';
|
|
5
|
+
import * as Core from '@golemui/core';
|
|
6
|
+
export declare class FormElement extends LitElement {
|
|
7
|
+
context: LitFormContext<Core.WithWidget>;
|
|
8
|
+
formDef: any;
|
|
9
|
+
widgetLoaders: WidgetLoaders<WithWidget>;
|
|
10
|
+
validators: Core.ValidatorFn<any>;
|
|
11
|
+
middlewares: Core.Middleware<Core.State, Core.Action>[];
|
|
12
|
+
data: any;
|
|
13
|
+
formName: string;
|
|
14
|
+
validateOn: Core.ValidateOn;
|
|
15
|
+
itemRenderers: Record<string, Core.ItemRenderer>;
|
|
16
|
+
localization?: Core.I18nTranslator;
|
|
17
|
+
direction: 'ltr' | 'rtl';
|
|
18
|
+
state: State | undefined;
|
|
19
|
+
subscriptions: Subscription[];
|
|
20
|
+
private unsubscribeI18n;
|
|
21
|
+
static FORM_HEALTH_EVENT: string;
|
|
22
|
+
static FORM_EVENT: string;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
createRenderRoot(): this;
|
|
25
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
26
|
+
disconnectedCallback(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import * as Core from '@golemui/core';
|
|
3
|
+
/**
|
|
4
|
+
* The Lit-specific Core.ItemRenderer type.
|
|
5
|
+
* @template T The type of the data item.
|
|
6
|
+
*/
|
|
7
|
+
export type LitItemRenderer<T extends Core.ItemRenderItemData> = (ctx: Core.ItemRenderContext<T>) => TemplateResult;
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@golemui/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
|
+
"*.md"
|
|
21
|
+
],
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@golemui/core": "*",
|
|
24
|
+
"@lit/context": "^1.1.6",
|
|
25
|
+
"lit": "^3.3.1",
|
|
26
|
+
"rxjs": "^7.8.0"
|
|
27
|
+
}
|
|
28
|
+
}
|