@effect-app/vue 0.87.0-next.5 → 0.87.0-next.51
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 +417 -0
- package/_cjs/form.cjs +149 -1
- package/_cjs/form.cjs.map +1 -1
- package/_cjs/hooks.cjs +9 -3
- package/_cjs/hooks.cjs.map +1 -1
- package/_src/form.ts +231 -174
- package/_src/hooks.ts +18 -8
- package/_src/routeParams.ts +1 -1
- package/dist/form.d.ts +26 -4
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +164 -2
- package/dist/hooks.d.ts +8 -7
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +12 -4
- package/dist/routeParams.d.ts +1 -1
- package/dist/routeParams.d.ts.map +1 -1
- package/package.json +14 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,422 @@
|
|
|
1
1
|
# @effect-app/vue
|
|
2
2
|
|
|
3
|
+
## 0.87.0-next.51
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- update packages
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @effect-app/prelude@0.107.0-next.44
|
|
10
|
+
- @effect-app/schema@0.150.0-next.29
|
|
11
|
+
- @effect-app/core@0.97.0-next.8
|
|
12
|
+
- @effect-app/vue@0.87.0-next.51
|
|
13
|
+
|
|
14
|
+
## 0.87.0-next.50
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [19dc3b1]
|
|
19
|
+
- @effect-app/prelude@0.107.0-next.43
|
|
20
|
+
- @effect-app/schema@0.150.0-next.28
|
|
21
|
+
- @effect-app/vue@0.87.0-next.50
|
|
22
|
+
|
|
23
|
+
## 0.87.0-next.49
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [09ed839]
|
|
28
|
+
- @effect-app/prelude@0.107.0-next.42
|
|
29
|
+
- @effect-app/vue@0.87.0-next.49
|
|
30
|
+
|
|
31
|
+
## 0.87.0-next.48
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- b6d4272: update packages
|
|
36
|
+
- Updated dependencies [0bc4207]
|
|
37
|
+
- Updated dependencies [b6d4272]
|
|
38
|
+
- @effect-app/schema@0.150.0-next.27
|
|
39
|
+
- @effect-app/prelude@0.107.0-next.41
|
|
40
|
+
- @effect-app/core@0.97.0-next.7
|
|
41
|
+
- @effect-app/vue@0.87.0-next.48
|
|
42
|
+
|
|
43
|
+
## 0.87.0-next.47
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- 8a75cac: update vue
|
|
48
|
+
- Updated dependencies [8a75cac]
|
|
49
|
+
- @effect-app/vue@0.87.0-next.47
|
|
50
|
+
|
|
51
|
+
## 0.87.0-next.46
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- 14b33a9: cleanup errors and use decodeSyc over parseSync
|
|
56
|
+
- Updated dependencies [14b33a9]
|
|
57
|
+
- @effect-app/prelude@0.107.0-next.40
|
|
58
|
+
- @effect-app/schema@0.150.0-next.26
|
|
59
|
+
- @effect-app/vue@0.87.0-next.46
|
|
60
|
+
|
|
61
|
+
## 0.87.0-next.45
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [aa1b654]
|
|
66
|
+
- @effect-app/schema@0.150.0-next.25
|
|
67
|
+
- @effect-app/prelude@0.107.0-next.39
|
|
68
|
+
- @effect-app/vue@0.87.0-next.45
|
|
69
|
+
|
|
70
|
+
## 0.87.0-next.44
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [64793a8]
|
|
75
|
+
- @effect-app/prelude@0.107.0-next.38
|
|
76
|
+
- @effect-app/vue@0.87.0-next.44
|
|
77
|
+
|
|
78
|
+
## 0.87.0-next.43
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- 9e151ed: update packages
|
|
83
|
+
- Updated dependencies [9e151ed]
|
|
84
|
+
- @effect-app/prelude@0.107.0-next.37
|
|
85
|
+
- @effect-app/schema@0.150.0-next.24
|
|
86
|
+
- @effect-app/core@0.97.0-next.6
|
|
87
|
+
- @effect-app/vue@0.87.0-next.43
|
|
88
|
+
|
|
89
|
+
## 0.87.0-next.42
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [6b89c27]
|
|
94
|
+
- @effect-app/core@0.97.0-next.5
|
|
95
|
+
- @effect-app/prelude@0.107.0-next.36
|
|
96
|
+
- @effect-app/schema@0.150.0-next.23
|
|
97
|
+
- @effect-app/vue@0.87.0-next.42
|
|
98
|
+
|
|
99
|
+
## 0.87.0-next.41
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- Updated dependencies [169c159]
|
|
104
|
+
- @effect-app/prelude@0.107.0-next.35
|
|
105
|
+
- @effect-app/schema@0.150.0-next.22
|
|
106
|
+
- @effect-app/vue@0.87.0-next.41
|
|
107
|
+
|
|
108
|
+
## 0.87.0-next.40
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [b46e30d]
|
|
113
|
+
- @effect-app/prelude@0.107.0-next.34
|
|
114
|
+
- @effect-app/vue@0.87.0-next.40
|
|
115
|
+
|
|
116
|
+
## 0.87.0-next.39
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [c57bb66]
|
|
121
|
+
- @effect-app/schema@0.150.0-next.21
|
|
122
|
+
- @effect-app/prelude@0.107.0-next.33
|
|
123
|
+
- @effect-app/vue@0.87.0-next.39
|
|
124
|
+
|
|
125
|
+
## 0.87.0-next.38
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- ce46673: update packages
|
|
130
|
+
- Updated dependencies [735dea9]
|
|
131
|
+
- Updated dependencies [ce46673]
|
|
132
|
+
- @effect-app/prelude@0.107.0-next.32
|
|
133
|
+
- @effect-app/vue@0.87.0-next.38
|
|
134
|
+
|
|
135
|
+
## 0.87.0-next.37
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [21482c6]
|
|
140
|
+
- @effect-app/prelude@0.107.0-next.31
|
|
141
|
+
- @effect-app/vue@0.87.0-next.37
|
|
142
|
+
|
|
143
|
+
## 0.87.0-next.36
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- Updated dependencies [eab24be]
|
|
148
|
+
- @effect-app/prelude@0.107.0-next.30
|
|
149
|
+
- @effect-app/vue@0.87.0-next.36
|
|
150
|
+
|
|
151
|
+
## 0.87.0-next.35
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- Updated dependencies [def06a7]
|
|
156
|
+
- @effect-app/prelude@0.107.0-next.29
|
|
157
|
+
- @effect-app/vue@0.87.0-next.35
|
|
158
|
+
|
|
159
|
+
## 0.87.0-next.34
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- Updated dependencies [eb31797]
|
|
164
|
+
- @effect-app/prelude@0.107.0-next.28
|
|
165
|
+
- @effect-app/vue@0.87.0-next.34
|
|
166
|
+
|
|
167
|
+
## 0.87.0-next.33
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Updated dependencies [65696a6]
|
|
172
|
+
- @effect-app/prelude@0.107.0-next.27
|
|
173
|
+
- @effect-app/vue@0.87.0-next.33
|
|
174
|
+
|
|
175
|
+
## 0.87.0-next.32
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- Updated dependencies [777162f]
|
|
180
|
+
- @effect-app/prelude@0.107.0-next.26
|
|
181
|
+
- @effect-app/schema@0.150.0-next.20
|
|
182
|
+
- @effect-app/vue@0.87.0-next.32
|
|
183
|
+
|
|
184
|
+
## 0.87.0-next.31
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- Updated dependencies [0776693]
|
|
189
|
+
- @effect-app/prelude@0.107.0-next.25
|
|
190
|
+
- @effect-app/vue@0.87.0-next.31
|
|
191
|
+
|
|
192
|
+
## 0.87.0-next.30
|
|
193
|
+
|
|
194
|
+
### Patch Changes
|
|
195
|
+
|
|
196
|
+
- c96bc2f: f
|
|
197
|
+
- Updated dependencies [c96bc2f]
|
|
198
|
+
- @effect-app/vue@0.87.0-next.30
|
|
199
|
+
|
|
200
|
+
## 0.87.0-next.29
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- 68eaf52: form and client fixes
|
|
205
|
+
- Updated dependencies [68eaf52]
|
|
206
|
+
- @effect-app/prelude@0.107.0-next.24
|
|
207
|
+
- @effect-app/vue@0.87.0-next.29
|
|
208
|
+
|
|
209
|
+
## 0.87.0-next.28
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- Updated dependencies [ca927a5]
|
|
214
|
+
- @effect-app/schema@0.150.0-next.19
|
|
215
|
+
- @effect-app/prelude@0.107.0-next.23
|
|
216
|
+
- @effect-app/vue@0.87.0-next.28
|
|
217
|
+
|
|
218
|
+
## 0.87.0-next.27
|
|
219
|
+
|
|
220
|
+
### Patch Changes
|
|
221
|
+
|
|
222
|
+
- Updated dependencies [5f62f5a]
|
|
223
|
+
- @effect-app/prelude@0.107.0-next.22
|
|
224
|
+
- @effect-app/schema@0.150.0-next.18
|
|
225
|
+
- @effect-app/vue@0.87.0-next.27
|
|
226
|
+
|
|
227
|
+
## 0.87.0-next.26
|
|
228
|
+
|
|
229
|
+
### Patch Changes
|
|
230
|
+
|
|
231
|
+
- Updated dependencies [53d4b3e]
|
|
232
|
+
- @effect-app/schema@0.150.0-next.17
|
|
233
|
+
- @effect-app/prelude@0.107.0-next.21
|
|
234
|
+
- @effect-app/vue@0.87.0-next.26
|
|
235
|
+
|
|
236
|
+
## 0.87.0-next.25
|
|
237
|
+
|
|
238
|
+
### Patch Changes
|
|
239
|
+
|
|
240
|
+
- Updated dependencies [63d4549]
|
|
241
|
+
- @effect-app/schema@0.150.0-next.16
|
|
242
|
+
- @effect-app/prelude@0.107.0-next.20
|
|
243
|
+
- @effect-app/vue@0.87.0-next.25
|
|
244
|
+
|
|
245
|
+
## 0.87.0-next.24
|
|
246
|
+
|
|
247
|
+
### Patch Changes
|
|
248
|
+
|
|
249
|
+
- b19ce70: S
|
|
250
|
+
- Updated dependencies [b19ce70]
|
|
251
|
+
- @effect-app/prelude@0.107.0-next.19
|
|
252
|
+
- @effect-app/vue@0.87.0-next.24
|
|
253
|
+
|
|
254
|
+
## 0.87.0-next.23
|
|
255
|
+
|
|
256
|
+
### Patch Changes
|
|
257
|
+
|
|
258
|
+
- Updated dependencies [92ff6b9]
|
|
259
|
+
- @effect-app/prelude@0.107.0-next.18
|
|
260
|
+
- @effect-app/schema@0.150.0-next.15
|
|
261
|
+
- @effect-app/vue@0.87.0-next.23
|
|
262
|
+
|
|
263
|
+
## 0.87.0-next.22
|
|
264
|
+
|
|
265
|
+
### Patch Changes
|
|
266
|
+
|
|
267
|
+
- 15e7b7a: d
|
|
268
|
+
- Updated dependencies [15e7b7a]
|
|
269
|
+
- @effect-app/vue@0.87.0-next.22
|
|
270
|
+
|
|
271
|
+
## 0.87.0-next.21
|
|
272
|
+
|
|
273
|
+
### Patch Changes
|
|
274
|
+
|
|
275
|
+
- Updated dependencies [c234016]
|
|
276
|
+
- @effect-app/schema@0.150.0-next.14
|
|
277
|
+
- @effect-app/prelude@0.107.0-next.17
|
|
278
|
+
- @effect-app/vue@0.87.0-next.21
|
|
279
|
+
|
|
280
|
+
## 0.87.0-next.20
|
|
281
|
+
|
|
282
|
+
### Patch Changes
|
|
283
|
+
|
|
284
|
+
- 5d53b26: fix exclusive min/max
|
|
285
|
+
- Updated dependencies [5d53b26]
|
|
286
|
+
- @effect-app/schema@0.150.0-next.13
|
|
287
|
+
- @effect-app/vue@0.87.0-next.20
|
|
288
|
+
- @effect-app/prelude@0.107.0-next.16
|
|
289
|
+
|
|
290
|
+
## 0.87.0-next.19
|
|
291
|
+
|
|
292
|
+
### Patch Changes
|
|
293
|
+
|
|
294
|
+
- fd785c2: improve error
|
|
295
|
+
- Updated dependencies [fd785c2]
|
|
296
|
+
- @effect-app/vue@0.87.0-next.19
|
|
297
|
+
|
|
298
|
+
## 0.87.0-next.18
|
|
299
|
+
|
|
300
|
+
### Patch Changes
|
|
301
|
+
|
|
302
|
+
- 99310c3: fix error message
|
|
303
|
+
- Updated dependencies [99310c3]
|
|
304
|
+
- @effect-app/vue@0.87.0-next.18
|
|
305
|
+
|
|
306
|
+
## 0.87.0-next.17
|
|
307
|
+
|
|
308
|
+
### Patch Changes
|
|
309
|
+
|
|
310
|
+
- Updated dependencies [147bc14]
|
|
311
|
+
- @effect-app/schema@0.150.0-next.12
|
|
312
|
+
- @effect-app/prelude@0.107.0-next.15
|
|
313
|
+
- @effect-app/vue@0.87.0-next.17
|
|
314
|
+
|
|
315
|
+
## 0.87.0-next.16
|
|
316
|
+
|
|
317
|
+
### Patch Changes
|
|
318
|
+
|
|
319
|
+
- 660d57a: upd
|
|
320
|
+
- Updated dependencies [660d57a]
|
|
321
|
+
- @effect-app/schema@0.150.0-next.11
|
|
322
|
+
- @effect-app/vue@0.87.0-next.16
|
|
323
|
+
- @effect-app/prelude@0.107.0-next.14
|
|
324
|
+
|
|
325
|
+
## 0.87.0-next.15
|
|
326
|
+
|
|
327
|
+
### Patch Changes
|
|
328
|
+
|
|
329
|
+
- 5f76678: reimplement vue form
|
|
330
|
+
- Updated dependencies [5f76678]
|
|
331
|
+
- @effect-app/vue@0.87.0-next.15
|
|
332
|
+
|
|
333
|
+
## 0.87.0-next.14
|
|
334
|
+
|
|
335
|
+
### Patch Changes
|
|
336
|
+
|
|
337
|
+
- 20076e0: update
|
|
338
|
+
- Updated dependencies [20076e0]
|
|
339
|
+
- @effect-app/prelude@0.107.0-next.13
|
|
340
|
+
- @effect-app/schema@0.150.0-next.10
|
|
341
|
+
- @effect-app/vue@0.87.0-next.14
|
|
342
|
+
|
|
343
|
+
## 0.87.0-next.13
|
|
344
|
+
|
|
345
|
+
### Patch Changes
|
|
346
|
+
|
|
347
|
+
- Updated dependencies
|
|
348
|
+
- @effect-app/core@0.97.0-next.4
|
|
349
|
+
- @effect-app/prelude@0.107.0-next.12
|
|
350
|
+
- @effect-app/schema@0.150.0-next.9
|
|
351
|
+
- @effect-app/vue@0.87.0-next.13
|
|
352
|
+
|
|
353
|
+
## 0.87.0-next.12
|
|
354
|
+
|
|
355
|
+
### Patch Changes
|
|
356
|
+
|
|
357
|
+
- ac35466: use schema fork
|
|
358
|
+
- Updated dependencies [ac35466]
|
|
359
|
+
- @effect-app/prelude@0.107.0-next.11
|
|
360
|
+
- @effect-app/schema@0.150.0-next.8
|
|
361
|
+
- @effect-app/vue@0.87.0-next.12
|
|
362
|
+
|
|
363
|
+
## 0.87.0-next.11
|
|
364
|
+
|
|
365
|
+
### Patch Changes
|
|
366
|
+
|
|
367
|
+
- Updated dependencies [4f8ade3]
|
|
368
|
+
- @effect-app/core@0.97.0-next.3
|
|
369
|
+
- @effect-app/prelude@0.107.0-next.10
|
|
370
|
+
- @effect-app/schema@0.150.0-next.7
|
|
371
|
+
- @effect-app/vue@0.87.0-next.11
|
|
372
|
+
|
|
373
|
+
## 0.87.0-next.10
|
|
374
|
+
|
|
375
|
+
### Patch Changes
|
|
376
|
+
|
|
377
|
+
- Updated dependencies [8897586]
|
|
378
|
+
- @effect-app/schema@0.150.0-next.6
|
|
379
|
+
- @effect-app/prelude@0.107.0-next.9
|
|
380
|
+
- @effect-app/vue@0.87.0-next.10
|
|
381
|
+
|
|
382
|
+
## 0.87.0-next.9
|
|
383
|
+
|
|
384
|
+
### Patch Changes
|
|
385
|
+
|
|
386
|
+
- c550ee5: updates
|
|
387
|
+
- Updated dependencies [c550ee5]
|
|
388
|
+
- @effect-app/prelude@0.107.0-next.8
|
|
389
|
+
- @effect-app/schema@0.150.0-next.5
|
|
390
|
+
- @effect-app/core@0.97.0-next.2
|
|
391
|
+
- @effect-app/vue@0.87.0-next.9
|
|
392
|
+
|
|
393
|
+
## 0.87.0-next.8
|
|
394
|
+
|
|
395
|
+
### Patch Changes
|
|
396
|
+
|
|
397
|
+
- Updated dependencies [82b3ca0]
|
|
398
|
+
- @effect-app/prelude@0.107.0-next.7
|
|
399
|
+
- @effect-app/vue@0.87.0-next.8
|
|
400
|
+
|
|
401
|
+
## 0.87.0-next.7
|
|
402
|
+
|
|
403
|
+
### Patch Changes
|
|
404
|
+
|
|
405
|
+
- Updated dependencies [ace7afb]
|
|
406
|
+
- @effect-app/schema@0.150.0-next.4
|
|
407
|
+
- @effect-app/prelude@0.107.0-next.6
|
|
408
|
+
- @effect-app/vue@0.87.0-next.7
|
|
409
|
+
|
|
410
|
+
## 0.87.0-next.6
|
|
411
|
+
|
|
412
|
+
### Patch Changes
|
|
413
|
+
|
|
414
|
+
- 3320864: cleanup schema ext
|
|
415
|
+
- Updated dependencies [3320864]
|
|
416
|
+
- @effect-app/prelude@0.107.0-next.5
|
|
417
|
+
- @effect-app/schema@0.150.0-next.3
|
|
418
|
+
- @effect-app/vue@0.87.0-next.6
|
|
419
|
+
|
|
3
420
|
## 0.87.0-next.5
|
|
4
421
|
|
|
5
422
|
### Patch Changes
|
package/_cjs/form.cjs
CHANGED
|
@@ -3,12 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.buildFieldInfoFromFields = buildFieldInfoFromFields;
|
|
7
|
+
exports.buildFormFromSchema = void 0;
|
|
6
8
|
exports.convertIn = convertIn;
|
|
7
9
|
exports.convertOut = convertOut;
|
|
8
10
|
exports.convertOutInt = convertOutInt;
|
|
9
|
-
exports.
|
|
11
|
+
exports.customSchemaErrors = void 0;
|
|
12
|
+
exports.getMetadataFromSchema = getMetadataFromSchema;
|
|
13
|
+
exports.translate = void 0;
|
|
14
|
+
var tsplus_module_1 = _interopRequireWildcard(require("@effect/schema/Parser"));
|
|
15
|
+
var tsplus_module_2 = _interopRequireWildcard(require("effect/Either"));
|
|
16
|
+
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/core/Function"));
|
|
17
|
+
var _schema = require("@effect-app/schema");
|
|
10
18
|
var _intl = require("@formatjs/intl");
|
|
11
19
|
var _vue = require("vue");
|
|
20
|
+
var JSONSchema = _interopRequireWildcard(require("@effect/schema/JSONSchema"));
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
23
|
function convertIn(v, type) {
|
|
13
24
|
return v === null ? "" : type === "text" ? v : `${v}`;
|
|
14
25
|
}
|
|
@@ -20,6 +31,21 @@ function convertOutInt(v, type) {
|
|
|
20
31
|
function convertOut(v, set, type) {
|
|
21
32
|
return set(convertOutInt(v, type));
|
|
22
33
|
}
|
|
34
|
+
function buildFieldInfoFromFields(fields) {
|
|
35
|
+
let ast = fields.ast;
|
|
36
|
+
// todo: or look at from?
|
|
37
|
+
if (_schema.AST.isTransform(ast)) {
|
|
38
|
+
if (_schema.AST.isDeclaration(ast.to)) {
|
|
39
|
+
ast = ast.to.type;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!_schema.AST.isTypeLiteral(ast)) throw new Error("not a struct type");
|
|
43
|
+
return ast.propertySignatures.reduce((prev, cur) => {
|
|
44
|
+
;
|
|
45
|
+
prev[cur.name] = buildFieldInfo(cur);
|
|
46
|
+
return prev;
|
|
47
|
+
}, {});
|
|
48
|
+
}
|
|
23
49
|
const f = Symbol();
|
|
24
50
|
class PhantomTypeParameter {}
|
|
25
51
|
// type GetSchemaFromProp<T> = T extends Field<infer S, any, any, any> ? S
|
|
@@ -29,4 +55,126 @@ const defaultIntl = (0, _intl.createIntl)({
|
|
|
29
55
|
});
|
|
30
56
|
const translate = exports.translate = (0, _vue.ref)(defaultIntl.formatMessage.bind(defaultIntl));
|
|
31
57
|
const customSchemaErrors = exports.customSchemaErrors = (0, _vue.ref)(new Map());
|
|
58
|
+
function buildFieldInfo(property) {
|
|
59
|
+
const propertyKey = property.name;
|
|
60
|
+
const schema = _schema.S.make(property.type);
|
|
61
|
+
const metadata = getMetadataFromSchema(property.type); // TODO
|
|
62
|
+
const parse = tsplus_module_1.parseEither(schema);
|
|
63
|
+
const nullable = _schema.AST.isUnion(property.type) && property.type.types.includes(_schema.S.null.ast);
|
|
64
|
+
const realSelf = nullable && _schema.AST.isUnion(property.type) ? property.type.types.filter(_ => _ !== _schema.S.null.ast)[0] : property.type;
|
|
65
|
+
function renderError(e, v) {
|
|
66
|
+
const err = e.toString();
|
|
67
|
+
const custom = customSchemaErrors.value.get(realSelf);
|
|
68
|
+
return custom ? custom(err, e, v) : translate.value({
|
|
69
|
+
defaultMessage: "The entered value is not a valid {type}: {message}",
|
|
70
|
+
id: "validation.not_a_valid"
|
|
71
|
+
}, {
|
|
72
|
+
type: translate.value({
|
|
73
|
+
defaultMessage: (0, _vue.capitalize)(propertyKey.toString()),
|
|
74
|
+
id: `fieldNames.${String(propertyKey)}`
|
|
75
|
+
}),
|
|
76
|
+
message: metadata.description ? "expected " + metadata.description : err.slice(err.indexOf("Expected")) // TODO: this is not translated.
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const stringRules = [v => v === null || metadata.minLength === undefined || v.length >= metadata.minLength || translate.value({
|
|
80
|
+
defaultMessage: "The field requires at least {minLength} characters",
|
|
81
|
+
id: "validation.string.minLength"
|
|
82
|
+
}, {
|
|
83
|
+
minLength: metadata.minLength
|
|
84
|
+
}), v => v === null || metadata.maxLength === undefined || v.length <= metadata.maxLength || translate.value({
|
|
85
|
+
defaultMessage: "The field cannot have more than {maxLength} characters",
|
|
86
|
+
id: "validation.string.maxLength"
|
|
87
|
+
}, {
|
|
88
|
+
maxLength: metadata.maxLength
|
|
89
|
+
})];
|
|
90
|
+
const numberRules = [v => v === null || metadata.minimum === undefined && metadata.exclusiveMinimum === undefined || metadata.exclusiveMinimum !== undefined && v > metadata.exclusiveMinimum || metadata.minimum !== undefined && v >= metadata.minimum || translate.value({
|
|
91
|
+
defaultMessage: "The value should be {isExclusive, select, true {larger than} other {at least}} {minimum}",
|
|
92
|
+
id: "validation.number.min"
|
|
93
|
+
}, {
|
|
94
|
+
isExclusive: metadata.exclusiveMinimum !== undefined,
|
|
95
|
+
minimum: metadata.exclusiveMinimum ?? metadata.minimum
|
|
96
|
+
}), v => v === null || metadata.maximum === undefined && metadata.exclusiveMaximum === undefined || metadata.exclusiveMaximum !== undefined && v < metadata.exclusiveMaximum || metadata.maximum !== undefined && v <= metadata.maximum || translate.value({
|
|
97
|
+
defaultMessage: "The value should be {isExclusive, select, true {smaller than} other {at most}} {maximum}",
|
|
98
|
+
id: "validation.number.max"
|
|
99
|
+
}, {
|
|
100
|
+
isExclusive: metadata.exclusiveMaximum !== undefined,
|
|
101
|
+
maximum: metadata.exclusiveMaximum ?? metadata.maximum
|
|
102
|
+
})];
|
|
103
|
+
const parseRule = v => tsplus_module_3.pipe(parse(v), _ => tsplus_module_2.match(_, {
|
|
104
|
+
onLeft: _ => renderError(_, v),
|
|
105
|
+
onRight: () => true
|
|
106
|
+
}));
|
|
107
|
+
const rules = [...(metadata.type === "text" ? stringRules : numberRules), parseRule];
|
|
108
|
+
const info = {
|
|
109
|
+
type: metadata.type,
|
|
110
|
+
rules: [v => !metadata.required || v !== "" || translate.value({
|
|
111
|
+
defaultMessage: "The field cannot be empty",
|
|
112
|
+
id: "validation.empty"
|
|
113
|
+
}), v => {
|
|
114
|
+
const converted = convertOutInt(v, metadata.type);
|
|
115
|
+
for (const r of rules) {
|
|
116
|
+
const res = r(converted);
|
|
117
|
+
if (res !== true) {
|
|
118
|
+
return res;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}],
|
|
123
|
+
metadata
|
|
124
|
+
};
|
|
125
|
+
return info;
|
|
126
|
+
}
|
|
127
|
+
const buildFormFromSchema = (s, state, onSubmit) => {
|
|
128
|
+
const fields = buildFieldInfoFromFields(s);
|
|
129
|
+
const parse = tsplus_module_1.decodeSync(s);
|
|
130
|
+
const isDirty = (0, _vue.ref)(false);
|
|
131
|
+
const isValid = (0, _vue.ref)(true);
|
|
132
|
+
const submit1 = onSubmit => async e => {
|
|
133
|
+
const r = await e;
|
|
134
|
+
if (!r.valid) return;
|
|
135
|
+
return onSubmit(parse(state.value));
|
|
136
|
+
};
|
|
137
|
+
const submit = submit1(onSubmit);
|
|
138
|
+
(0, _vue.watch)(state, v => {
|
|
139
|
+
// TODO: do better
|
|
140
|
+
isDirty.value = JSON.stringify(v) !== JSON.stringify(state.value);
|
|
141
|
+
}, {
|
|
142
|
+
deep: true
|
|
143
|
+
});
|
|
144
|
+
const submitFromState = () => submit(Promise.resolve({
|
|
145
|
+
valid: isValid.value
|
|
146
|
+
}));
|
|
147
|
+
return {
|
|
148
|
+
fields,
|
|
149
|
+
submit,
|
|
150
|
+
submitFromState,
|
|
151
|
+
isDirty,
|
|
152
|
+
isValid
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
exports.buildFormFromSchema = buildFormFromSchema;
|
|
156
|
+
function getMetadataFromSchema(ast) {
|
|
157
|
+
const nullable = _schema.AST.isUnion(ast) && ast.types.includes(_schema.S.null.ast);
|
|
158
|
+
const realSelf = nullable && _schema.AST.isUnion(ast) ? ast.types.filter(_ => _ !== _schema.S.null.ast)[0] : ast;
|
|
159
|
+
let jschema;
|
|
160
|
+
try {
|
|
161
|
+
jschema = JSONSchema.to(_schema.S.make(realSelf));
|
|
162
|
+
} catch (err) {
|
|
163
|
+
jschema = {};
|
|
164
|
+
console.warn("error getting jsonschema from ", err, ast);
|
|
165
|
+
}
|
|
166
|
+
const isNumber = jschema.type === "number" || jschema.type === "integer";
|
|
167
|
+
const isInt = jschema.type === "integer";
|
|
168
|
+
return {
|
|
169
|
+
type: isInt ? "int" : isNumber ? "float" : "text",
|
|
170
|
+
minimum: jschema.minimum,
|
|
171
|
+
exclusiveMinimum: jschema.exclusiveMinimum,
|
|
172
|
+
maximum: jschema.maximum,
|
|
173
|
+
exclusiveMaximum: jschema.exclusiveMaximum,
|
|
174
|
+
minLength: jschema.minLength,
|
|
175
|
+
maxLength: jschema.maxLength,
|
|
176
|
+
description: jschema.description,
|
|
177
|
+
required: !nullable
|
|
178
|
+
};
|
|
179
|
+
}
|
|
32
180
|
//# sourceMappingURL=form.cjs.map
|
package/_cjs/form.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.cjs","names":["
|
|
1
|
+
{"version":3,"file":"form.cjs","names":["_schema","require","_intl","_vue","JSONSchema","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","convertIn","v","type","convertOutInt","trim","c","parseFloat","parseInt","convertOut","buildFieldInfoFromFields","fields","ast","AST","isTransform","isDeclaration","to","isTypeLiteral","Error","propertySignatures","reduce","prev","cur","name","buildFieldInfo","f","Symbol","PhantomTypeParameter","defaultIntl","createIntl","locale","translate","exports","ref","formatMessage","bind","customSchemaErrors","Map","property","propertyKey","schema","S","make","metadata","getMetadataFromSchema","parse","tsplus_module_1","parseEither","nullable","isUnion","types","includes","null","realSelf","filter","_","renderError","err","toString","custom","value","defaultMessage","id","capitalize","String","message","description","slice","indexOf","stringRules","minLength","undefined","length","maxLength","numberRules","minimum","exclusiveMinimum","isExclusive","maximum","exclusiveMaximum","parseRule","tsplus_module_3","pipe","tsplus_module_2","match","onLeft","onRight","rules","info","required","converted","res","buildFormFromSchema","s","state","onSubmit","decodeSync","isDirty","isValid","submit1","valid","submit","watch","JSON","stringify","deep","submitFromState","Promise","resolve","jschema","console","warn","isNumber","isInt"],"sources":["../_src/form.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAuD,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAA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vC,SAAS;IAC5BG,SAAS,EAAEoC,OAAO,CAACpC,SAAS;IAC5BP,WAAW,EAAE2C,OAAO,CAAC3C,WAAW;IAChCuB,QAAQ,EAAE,CAACzC;GACZ;AACH"}
|
package/_cjs/hooks.cjs
CHANGED
|
@@ -73,10 +73,16 @@ function useSafeQueryWithArg(self, arg, config) {
|
|
|
73
73
|
return useSafeQueryWithArg_(self, self.mapPath, arg, config);
|
|
74
74
|
}
|
|
75
75
|
function useSafeQuery(self, config) {
|
|
76
|
-
return useSafeQuery_(self.mapPath, self, config);
|
|
76
|
+
return useSafeQuery_(self.mapPath, () => self, config);
|
|
77
77
|
}
|
|
78
78
|
function useSafeQueryWithArg_(self, mapPath, arg, config) {
|
|
79
|
-
|
|
79
|
+
const arr = arg;
|
|
80
|
+
const r = typeof arr === "function" ? {
|
|
81
|
+
get value() {
|
|
82
|
+
return arr();
|
|
83
|
+
}
|
|
84
|
+
} : (0, _vue.ref)(arg);
|
|
85
|
+
return useSafeQuery_((0, _vue.computed)(() => mapPath(r.value)), () => self(r.value), config);
|
|
80
86
|
}
|
|
81
87
|
function useSafeQuery_(key, self, config) {
|
|
82
88
|
// const [result, latestSuccess, execute] = make(self)
|
|
@@ -107,7 +113,7 @@ function useSafeQuery_(key, self, config) {
|
|
|
107
113
|
// })
|
|
108
114
|
// }
|
|
109
115
|
// const swr = useSWRV<A, E>(key, () => execWithInterruption().then(_ => _?.body as any)) // Effect.runPromise(self.provide(Layers))
|
|
110
|
-
const swr = useSWRV(key, () => _internal.run.value(self).then(_ => _.body), config);
|
|
116
|
+
const swr = useSWRV(key, () => _internal.run.value(self()).then(_ => _.body), config);
|
|
111
117
|
const result = (0, _vue.computed)(() => swrToQuery({
|
|
112
118
|
data: swr.data.value,
|
|
113
119
|
error: swr.error.value,
|