@effect-app/vue 0.87.0-next.5 → 0.87.0-next.50

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 CHANGED
@@ -1,5 +1,411 @@
1
1
  # @effect-app/vue
2
2
 
3
+ ## 0.87.0-next.50
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [19dc3b1]
8
+ - @effect-app/prelude@0.107.0-next.43
9
+ - @effect-app/schema@0.150.0-next.28
10
+ - @effect-app/vue@0.87.0-next.50
11
+
12
+ ## 0.87.0-next.49
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [09ed839]
17
+ - @effect-app/prelude@0.107.0-next.42
18
+ - @effect-app/vue@0.87.0-next.49
19
+
20
+ ## 0.87.0-next.48
21
+
22
+ ### Patch Changes
23
+
24
+ - b6d4272: update packages
25
+ - Updated dependencies [0bc4207]
26
+ - Updated dependencies [b6d4272]
27
+ - @effect-app/schema@0.150.0-next.27
28
+ - @effect-app/prelude@0.107.0-next.41
29
+ - @effect-app/core@0.97.0-next.7
30
+ - @effect-app/vue@0.87.0-next.48
31
+
32
+ ## 0.87.0-next.47
33
+
34
+ ### Patch Changes
35
+
36
+ - 8a75cac: update vue
37
+ - Updated dependencies [8a75cac]
38
+ - @effect-app/vue@0.87.0-next.47
39
+
40
+ ## 0.87.0-next.46
41
+
42
+ ### Patch Changes
43
+
44
+ - 14b33a9: cleanup errors and use decodeSyc over parseSync
45
+ - Updated dependencies [14b33a9]
46
+ - @effect-app/prelude@0.107.0-next.40
47
+ - @effect-app/schema@0.150.0-next.26
48
+ - @effect-app/vue@0.87.0-next.46
49
+
50
+ ## 0.87.0-next.45
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [aa1b654]
55
+ - @effect-app/schema@0.150.0-next.25
56
+ - @effect-app/prelude@0.107.0-next.39
57
+ - @effect-app/vue@0.87.0-next.45
58
+
59
+ ## 0.87.0-next.44
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [64793a8]
64
+ - @effect-app/prelude@0.107.0-next.38
65
+ - @effect-app/vue@0.87.0-next.44
66
+
67
+ ## 0.87.0-next.43
68
+
69
+ ### Patch Changes
70
+
71
+ - 9e151ed: update packages
72
+ - Updated dependencies [9e151ed]
73
+ - @effect-app/prelude@0.107.0-next.37
74
+ - @effect-app/schema@0.150.0-next.24
75
+ - @effect-app/core@0.97.0-next.6
76
+ - @effect-app/vue@0.87.0-next.43
77
+
78
+ ## 0.87.0-next.42
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [6b89c27]
83
+ - @effect-app/core@0.97.0-next.5
84
+ - @effect-app/prelude@0.107.0-next.36
85
+ - @effect-app/schema@0.150.0-next.23
86
+ - @effect-app/vue@0.87.0-next.42
87
+
88
+ ## 0.87.0-next.41
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [169c159]
93
+ - @effect-app/prelude@0.107.0-next.35
94
+ - @effect-app/schema@0.150.0-next.22
95
+ - @effect-app/vue@0.87.0-next.41
96
+
97
+ ## 0.87.0-next.40
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [b46e30d]
102
+ - @effect-app/prelude@0.107.0-next.34
103
+ - @effect-app/vue@0.87.0-next.40
104
+
105
+ ## 0.87.0-next.39
106
+
107
+ ### Patch Changes
108
+
109
+ - Updated dependencies [c57bb66]
110
+ - @effect-app/schema@0.150.0-next.21
111
+ - @effect-app/prelude@0.107.0-next.33
112
+ - @effect-app/vue@0.87.0-next.39
113
+
114
+ ## 0.87.0-next.38
115
+
116
+ ### Patch Changes
117
+
118
+ - ce46673: update packages
119
+ - Updated dependencies [735dea9]
120
+ - Updated dependencies [ce46673]
121
+ - @effect-app/prelude@0.107.0-next.32
122
+ - @effect-app/vue@0.87.0-next.38
123
+
124
+ ## 0.87.0-next.37
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies [21482c6]
129
+ - @effect-app/prelude@0.107.0-next.31
130
+ - @effect-app/vue@0.87.0-next.37
131
+
132
+ ## 0.87.0-next.36
133
+
134
+ ### Patch Changes
135
+
136
+ - Updated dependencies [eab24be]
137
+ - @effect-app/prelude@0.107.0-next.30
138
+ - @effect-app/vue@0.87.0-next.36
139
+
140
+ ## 0.87.0-next.35
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [def06a7]
145
+ - @effect-app/prelude@0.107.0-next.29
146
+ - @effect-app/vue@0.87.0-next.35
147
+
148
+ ## 0.87.0-next.34
149
+
150
+ ### Patch Changes
151
+
152
+ - Updated dependencies [eb31797]
153
+ - @effect-app/prelude@0.107.0-next.28
154
+ - @effect-app/vue@0.87.0-next.34
155
+
156
+ ## 0.87.0-next.33
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies [65696a6]
161
+ - @effect-app/prelude@0.107.0-next.27
162
+ - @effect-app/vue@0.87.0-next.33
163
+
164
+ ## 0.87.0-next.32
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [777162f]
169
+ - @effect-app/prelude@0.107.0-next.26
170
+ - @effect-app/schema@0.150.0-next.20
171
+ - @effect-app/vue@0.87.0-next.32
172
+
173
+ ## 0.87.0-next.31
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies [0776693]
178
+ - @effect-app/prelude@0.107.0-next.25
179
+ - @effect-app/vue@0.87.0-next.31
180
+
181
+ ## 0.87.0-next.30
182
+
183
+ ### Patch Changes
184
+
185
+ - c96bc2f: f
186
+ - Updated dependencies [c96bc2f]
187
+ - @effect-app/vue@0.87.0-next.30
188
+
189
+ ## 0.87.0-next.29
190
+
191
+ ### Patch Changes
192
+
193
+ - 68eaf52: form and client fixes
194
+ - Updated dependencies [68eaf52]
195
+ - @effect-app/prelude@0.107.0-next.24
196
+ - @effect-app/vue@0.87.0-next.29
197
+
198
+ ## 0.87.0-next.28
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies [ca927a5]
203
+ - @effect-app/schema@0.150.0-next.19
204
+ - @effect-app/prelude@0.107.0-next.23
205
+ - @effect-app/vue@0.87.0-next.28
206
+
207
+ ## 0.87.0-next.27
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies [5f62f5a]
212
+ - @effect-app/prelude@0.107.0-next.22
213
+ - @effect-app/schema@0.150.0-next.18
214
+ - @effect-app/vue@0.87.0-next.27
215
+
216
+ ## 0.87.0-next.26
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [53d4b3e]
221
+ - @effect-app/schema@0.150.0-next.17
222
+ - @effect-app/prelude@0.107.0-next.21
223
+ - @effect-app/vue@0.87.0-next.26
224
+
225
+ ## 0.87.0-next.25
226
+
227
+ ### Patch Changes
228
+
229
+ - Updated dependencies [63d4549]
230
+ - @effect-app/schema@0.150.0-next.16
231
+ - @effect-app/prelude@0.107.0-next.20
232
+ - @effect-app/vue@0.87.0-next.25
233
+
234
+ ## 0.87.0-next.24
235
+
236
+ ### Patch Changes
237
+
238
+ - b19ce70: S
239
+ - Updated dependencies [b19ce70]
240
+ - @effect-app/prelude@0.107.0-next.19
241
+ - @effect-app/vue@0.87.0-next.24
242
+
243
+ ## 0.87.0-next.23
244
+
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies [92ff6b9]
248
+ - @effect-app/prelude@0.107.0-next.18
249
+ - @effect-app/schema@0.150.0-next.15
250
+ - @effect-app/vue@0.87.0-next.23
251
+
252
+ ## 0.87.0-next.22
253
+
254
+ ### Patch Changes
255
+
256
+ - 15e7b7a: d
257
+ - Updated dependencies [15e7b7a]
258
+ - @effect-app/vue@0.87.0-next.22
259
+
260
+ ## 0.87.0-next.21
261
+
262
+ ### Patch Changes
263
+
264
+ - Updated dependencies [c234016]
265
+ - @effect-app/schema@0.150.0-next.14
266
+ - @effect-app/prelude@0.107.0-next.17
267
+ - @effect-app/vue@0.87.0-next.21
268
+
269
+ ## 0.87.0-next.20
270
+
271
+ ### Patch Changes
272
+
273
+ - 5d53b26: fix exclusive min/max
274
+ - Updated dependencies [5d53b26]
275
+ - @effect-app/schema@0.150.0-next.13
276
+ - @effect-app/vue@0.87.0-next.20
277
+ - @effect-app/prelude@0.107.0-next.16
278
+
279
+ ## 0.87.0-next.19
280
+
281
+ ### Patch Changes
282
+
283
+ - fd785c2: improve error
284
+ - Updated dependencies [fd785c2]
285
+ - @effect-app/vue@0.87.0-next.19
286
+
287
+ ## 0.87.0-next.18
288
+
289
+ ### Patch Changes
290
+
291
+ - 99310c3: fix error message
292
+ - Updated dependencies [99310c3]
293
+ - @effect-app/vue@0.87.0-next.18
294
+
295
+ ## 0.87.0-next.17
296
+
297
+ ### Patch Changes
298
+
299
+ - Updated dependencies [147bc14]
300
+ - @effect-app/schema@0.150.0-next.12
301
+ - @effect-app/prelude@0.107.0-next.15
302
+ - @effect-app/vue@0.87.0-next.17
303
+
304
+ ## 0.87.0-next.16
305
+
306
+ ### Patch Changes
307
+
308
+ - 660d57a: upd
309
+ - Updated dependencies [660d57a]
310
+ - @effect-app/schema@0.150.0-next.11
311
+ - @effect-app/vue@0.87.0-next.16
312
+ - @effect-app/prelude@0.107.0-next.14
313
+
314
+ ## 0.87.0-next.15
315
+
316
+ ### Patch Changes
317
+
318
+ - 5f76678: reimplement vue form
319
+ - Updated dependencies [5f76678]
320
+ - @effect-app/vue@0.87.0-next.15
321
+
322
+ ## 0.87.0-next.14
323
+
324
+ ### Patch Changes
325
+
326
+ - 20076e0: update
327
+ - Updated dependencies [20076e0]
328
+ - @effect-app/prelude@0.107.0-next.13
329
+ - @effect-app/schema@0.150.0-next.10
330
+ - @effect-app/vue@0.87.0-next.14
331
+
332
+ ## 0.87.0-next.13
333
+
334
+ ### Patch Changes
335
+
336
+ - Updated dependencies
337
+ - @effect-app/core@0.97.0-next.4
338
+ - @effect-app/prelude@0.107.0-next.12
339
+ - @effect-app/schema@0.150.0-next.9
340
+ - @effect-app/vue@0.87.0-next.13
341
+
342
+ ## 0.87.0-next.12
343
+
344
+ ### Patch Changes
345
+
346
+ - ac35466: use schema fork
347
+ - Updated dependencies [ac35466]
348
+ - @effect-app/prelude@0.107.0-next.11
349
+ - @effect-app/schema@0.150.0-next.8
350
+ - @effect-app/vue@0.87.0-next.12
351
+
352
+ ## 0.87.0-next.11
353
+
354
+ ### Patch Changes
355
+
356
+ - Updated dependencies [4f8ade3]
357
+ - @effect-app/core@0.97.0-next.3
358
+ - @effect-app/prelude@0.107.0-next.10
359
+ - @effect-app/schema@0.150.0-next.7
360
+ - @effect-app/vue@0.87.0-next.11
361
+
362
+ ## 0.87.0-next.10
363
+
364
+ ### Patch Changes
365
+
366
+ - Updated dependencies [8897586]
367
+ - @effect-app/schema@0.150.0-next.6
368
+ - @effect-app/prelude@0.107.0-next.9
369
+ - @effect-app/vue@0.87.0-next.10
370
+
371
+ ## 0.87.0-next.9
372
+
373
+ ### Patch Changes
374
+
375
+ - c550ee5: updates
376
+ - Updated dependencies [c550ee5]
377
+ - @effect-app/prelude@0.107.0-next.8
378
+ - @effect-app/schema@0.150.0-next.5
379
+ - @effect-app/core@0.97.0-next.2
380
+ - @effect-app/vue@0.87.0-next.9
381
+
382
+ ## 0.87.0-next.8
383
+
384
+ ### Patch Changes
385
+
386
+ - Updated dependencies [82b3ca0]
387
+ - @effect-app/prelude@0.107.0-next.7
388
+ - @effect-app/vue@0.87.0-next.8
389
+
390
+ ## 0.87.0-next.7
391
+
392
+ ### Patch Changes
393
+
394
+ - Updated dependencies [ace7afb]
395
+ - @effect-app/schema@0.150.0-next.4
396
+ - @effect-app/prelude@0.107.0-next.6
397
+ - @effect-app/vue@0.87.0-next.7
398
+
399
+ ## 0.87.0-next.6
400
+
401
+ ### Patch Changes
402
+
403
+ - 3320864: cleanup schema ext
404
+ - Updated dependencies [3320864]
405
+ - @effect-app/prelude@0.107.0-next.5
406
+ - @effect-app/schema@0.150.0-next.3
407
+ - @effect-app/vue@0.87.0-next.6
408
+
3
409
  ## 0.87.0-next.5
4
410
 
5
411
  ### 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.translate = exports.customSchemaErrors = void 0;
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":["_intl","require","_vue","convertIn","v","type","convertOutInt","trim","c","parseFloat","parseInt","convertOut","set","f","Symbol","PhantomTypeParameter","defaultIntl","createIntl","locale","translate","exports","ref","formatMessage","bind","customSchemaErrors","Map"],"sources":["../_src/form.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEM,SAAUE,SAASA,CAACC,CAAgB,EAAEC,IAA+B;EACzE,OAAOD,CAAC,KAAK,IAAI,GAAG,EAAE,GAAGC,IAAI,KAAK,MAAM,GAAGD,CAAC,GAAG,GAAGA,CAAC,EAAE;AACvD;AAEM,SAAUE,aAAaA,CAACF,CAAS,EAAEC,IAA+B;EACtED,CAAC,GAAGA,CAAC,IAAI,IAAI,GAAGA,CAAC,GAAGA,CAAC,CAACG,IAAI,EAAE;EAC5B,MAAMC,CAAC,GAAGJ,CAAC,KAAK,EAAE,GAAG,IAAI,GAAGC,IAAI,KAAK,OAAO,GAAGI,UAAU,CAACL,CAAC,CAAC,GAAGC,IAAI,KAAK,KAAK,GAAGK,QAAQ,CAACN,CAAC,CAAC,GAAGA,CAAC;EAC/F,OAAOI,CAAC;AACV;AAEM,SAAUG,UAAUA,CAACP,CAAS,EAAEQ,GAAgC,EAAEP,IAA+B;EACrG,OAAOO,GAAG,CAACN,aAAa,CAACF,CAAC,EAAEC,IAAI,CAAC,CAAC;AACpC;AAyBA,MAAMQ,CAAC,GAAGC,MAAM,EAAE;AAClB,MAAeC,oBAAoB;AAcnC;AACA;AAEA,MAAMC,WAAW,GAAG,IAAAC,gBAAU,EAAC;EAAEC,MAAM,EAAE;AAAI,CAAE,CAAC;AACzC,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAAE,QAAG,EAAkCL,WAAW,CAACM,aAAa,CAACC,IAAI,CAACP,WAAW,CAAC,CAAC;AACnG,MAAMQ,kBAAkB,GAAAJ,OAAA,CAAAI,kBAAA,GAAG,IAAAH,QAAG,EACnC,IAAII,GAAG,EAAE,CACV"}
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,u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AG,MAAe;IAC5ErC,OAAO,EAAEkC,OAAO,CAAClC,OAAO;IACxBC,gBAAgB,EAAEiC,OAAO,CAACjC,gBAAgB;IAC1CE,OAAO,EAAE+B,OAAO,CAAC/B,OAAO;IACxBC,gBAAgB,EAAE8B,OAAO,CAAC9B,gBAAgB;IAC1CT,SAAS,EAAEuC,OAAO,CAACvC,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
- return useSafeQuery_(mapPath(arg), self(arg), config);
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,