@famalabs/web-form 1.0.0-beta.20 → 1.0.0-beta.22

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.
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ItemSchema, Item, Question, QuestionSchema } from '@famalabs/survey';
3
3
 
4
4
  declare const QuestionTextMap: {
@@ -9,7 +9,7 @@ declare const QuestionTextMap: {
9
9
  readonly types: {
10
10
  readonly text: {
11
11
  readonly type: "text";
12
- readonly icon: react_jsx_runtime.JSX.Element;
12
+ readonly icon: react.JSX.Element;
13
13
  readonly defaults: {
14
14
  readonly min: null;
15
15
  readonly max: null;
@@ -17,7 +17,7 @@ declare const QuestionTextMap: {
17
17
  };
18
18
  readonly textArea: {
19
19
  readonly type: "textArea";
20
- readonly icon: react_jsx_runtime.JSX.Element;
20
+ readonly icon: react.JSX.Element;
21
21
  readonly defaults: {
22
22
  readonly min: null;
23
23
  readonly max: null;
@@ -25,14 +25,14 @@ declare const QuestionTextMap: {
25
25
  };
26
26
  readonly time: {
27
27
  readonly type: "time";
28
- readonly icon: react_jsx_runtime.JSX.Element;
28
+ readonly icon: react.JSX.Element;
29
29
  readonly defaults: {
30
30
  readonly format: "/^(?:[01]d|2[0-3]):[0-5]d:[0-5]d$/";
31
31
  };
32
32
  };
33
33
  readonly signature: {
34
34
  readonly type: "signature";
35
- readonly icon: react_jsx_runtime.JSX.Element;
35
+ readonly icon: react.JSX.Element;
36
36
  };
37
37
  };
38
38
  readonly options: {};
@@ -54,7 +54,7 @@ declare const QuestionNumberMap: {
54
54
  readonly types: {
55
55
  readonly number: {
56
56
  readonly type: "number";
57
- readonly icon: react_jsx_runtime.JSX.Element;
57
+ readonly icon: react.JSX.Element;
58
58
  readonly defaults: {
59
59
  readonly min: 0;
60
60
  readonly max: null;
@@ -63,7 +63,7 @@ declare const QuestionNumberMap: {
63
63
  };
64
64
  readonly range: {
65
65
  readonly type: "range";
66
- readonly icon: react_jsx_runtime.JSX.Element;
66
+ readonly icon: react.JSX.Element;
67
67
  readonly defaults: {
68
68
  readonly min: 0;
69
69
  readonly max: 100;
@@ -72,7 +72,7 @@ declare const QuestionNumberMap: {
72
72
  };
73
73
  readonly rating: {
74
74
  readonly type: "rating";
75
- readonly icon: react_jsx_runtime.JSX.Element;
75
+ readonly icon: react.JSX.Element;
76
76
  readonly defaults: {
77
77
  readonly min: 0;
78
78
  readonly max: 10;
@@ -106,22 +106,22 @@ declare const QuestionNumberMap: {
106
106
  readonly star: {
107
107
  readonly type: "star";
108
108
  readonly element: {
109
- readonly selected: react_jsx_runtime.JSX.Element;
110
- readonly unselected: react_jsx_runtime.JSX.Element;
109
+ readonly selected: react.JSX.Element;
110
+ readonly unselected: react.JSX.Element;
111
111
  };
112
112
  };
113
113
  readonly heart: {
114
114
  readonly type: "heart";
115
115
  readonly element: {
116
- readonly selected: react_jsx_runtime.JSX.Element;
117
- readonly unselected: react_jsx_runtime.JSX.Element;
116
+ readonly selected: react.JSX.Element;
117
+ readonly unselected: react.JSX.Element;
118
118
  };
119
119
  };
120
120
  readonly thumb: {
121
121
  readonly type: "thumb";
122
122
  readonly element: {
123
- readonly selected: react_jsx_runtime.JSX.Element;
124
- readonly unselected: react_jsx_runtime.JSX.Element;
123
+ readonly selected: react.JSX.Element;
124
+ readonly unselected: react.JSX.Element;
125
125
  };
126
126
  };
127
127
  };
@@ -136,11 +136,11 @@ declare const QuestionSelectMap: {
136
136
  readonly types: {
137
137
  readonly select: {
138
138
  readonly type: "select";
139
- readonly icon: react_jsx_runtime.JSX.Element;
139
+ readonly icon: react.JSX.Element;
140
140
  };
141
141
  readonly dropdown: {
142
142
  readonly type: "dropdown";
143
- readonly icon: react_jsx_runtime.JSX.Element;
143
+ readonly icon: react.JSX.Element;
144
144
  };
145
145
  };
146
146
  readonly options: {
@@ -168,11 +168,11 @@ declare const QuestionCheckMap: {
168
168
  readonly types: {
169
169
  readonly check: {
170
170
  readonly type: "check";
171
- readonly icon: react_jsx_runtime.JSX.Element;
171
+ readonly icon: react.JSX.Element;
172
172
  };
173
173
  readonly switch: {
174
174
  readonly type: "switch";
175
- readonly icon: react_jsx_runtime.JSX.Element;
175
+ readonly icon: react.JSX.Element;
176
176
  };
177
177
  };
178
178
  readonly options: {
@@ -204,7 +204,7 @@ declare const QuestionDateMap: {
204
204
  readonly types: {
205
205
  readonly date: {
206
206
  readonly type: "date";
207
- readonly icon: react_jsx_runtime.JSX.Element;
207
+ readonly icon: react.JSX.Element;
208
208
  readonly defaults: {
209
209
  readonly min: null;
210
210
  readonly max: null;
@@ -221,7 +221,7 @@ declare const QuestionListMap: {
221
221
  readonly types: {
222
222
  readonly sourceList: {
223
223
  readonly type: "sourceList";
224
- readonly icon: react_jsx_runtime.JSX.Element;
224
+ readonly icon: react.JSX.Element;
225
225
  readonly defaults: {
226
226
  readonly source: null;
227
227
  readonly min: null;
@@ -240,11 +240,11 @@ declare const ItemFunctionMap: {
240
240
  readonly types: {
241
241
  readonly fn: {
242
242
  readonly type: "fn";
243
- readonly icon: react_jsx_runtime.JSX.Element;
243
+ readonly icon: react.JSX.Element;
244
244
  };
245
245
  readonly score: {
246
246
  readonly type: "score";
247
- readonly icon: react_jsx_runtime.JSX.Element;
247
+ readonly icon: react.JSX.Element;
248
248
  };
249
249
  };
250
250
  readonly parameters: readonly [];
@@ -274,11 +274,11 @@ declare const ItemConditionalMap: {
274
274
  readonly types: {
275
275
  readonly cond: {
276
276
  readonly type: "cond";
277
- readonly icon: react_jsx_runtime.JSX.Element;
277
+ readonly icon: react.JSX.Element;
278
278
  };
279
279
  readonly alert: {
280
280
  readonly type: "alert";
281
- readonly icon: react_jsx_runtime.JSX.Element;
281
+ readonly icon: react.JSX.Element;
282
282
  };
283
283
  };
284
284
  readonly expression: {
@@ -320,40 +320,40 @@ declare const ItemMap: {
320
320
  readonly types: {
321
321
  readonly root: {
322
322
  readonly type: "root";
323
- readonly icon: react_jsx_runtime.JSX.Element;
323
+ readonly icon: react.JSX.Element;
324
324
  };
325
325
  readonly multipleSelect: {
326
326
  readonly type: "multipleSelect";
327
- readonly icon: react_jsx_runtime.JSX.Element;
327
+ readonly icon: react.JSX.Element;
328
328
  };
329
329
  readonly autocomplete: {
330
330
  readonly type: "autocomplete";
331
- readonly icon: react_jsx_runtime.JSX.Element;
331
+ readonly icon: react.JSX.Element;
332
332
  };
333
333
  readonly selectTable: {
334
334
  readonly type: "selectTable";
335
- readonly icon: react_jsx_runtime.JSX.Element;
335
+ readonly icon: react.JSX.Element;
336
336
  };
337
337
  readonly section: {
338
338
  readonly type: "section";
339
- readonly icon: react_jsx_runtime.JSX.Element;
339
+ readonly icon: react.JSX.Element;
340
340
  readonly hint: "Gruppo di domande";
341
341
  };
342
342
  readonly folder: {
343
343
  readonly type: "folder";
344
- readonly icon: react_jsx_runtime.JSX.Element;
344
+ readonly icon: react.JSX.Element;
345
345
  };
346
346
  readonly page: {
347
347
  readonly type: "page";
348
- readonly icon: react_jsx_runtime.JSX.Element;
348
+ readonly icon: react.JSX.Element;
349
349
  };
350
350
  readonly landing: {
351
351
  readonly type: "landing";
352
- readonly icon: react_jsx_runtime.JSX.Element;
352
+ readonly icon: react.JSX.Element;
353
353
  };
354
354
  readonly fileUpload: {
355
355
  readonly type: "fileUpload";
356
- readonly icon: react_jsx_runtime.JSX.Element;
356
+ readonly icon: react.JSX.Element;
357
357
  };
358
358
  };
359
359
  readonly options: {
@@ -388,7 +388,7 @@ type ItemMap = keyof typeof ItemMap;
388
388
  declare const Mapper: {
389
389
  text: {
390
390
  readonly type: "text";
391
- readonly icon: react_jsx_runtime.JSX.Element;
391
+ readonly icon: react.JSX.Element;
392
392
  readonly defaults: {
393
393
  readonly min: null;
394
394
  readonly max: null;
@@ -396,7 +396,7 @@ declare const Mapper: {
396
396
  };
397
397
  textArea: {
398
398
  readonly type: "textArea";
399
- readonly icon: react_jsx_runtime.JSX.Element;
399
+ readonly icon: react.JSX.Element;
400
400
  readonly defaults: {
401
401
  readonly min: null;
402
402
  readonly max: null;
@@ -404,7 +404,7 @@ declare const Mapper: {
404
404
  };
405
405
  number: {
406
406
  readonly type: "number";
407
- readonly icon: react_jsx_runtime.JSX.Element;
407
+ readonly icon: react.JSX.Element;
408
408
  readonly defaults: {
409
409
  readonly min: 0;
410
410
  readonly max: null;
@@ -413,7 +413,7 @@ declare const Mapper: {
413
413
  };
414
414
  range: {
415
415
  readonly type: "range";
416
- readonly icon: react_jsx_runtime.JSX.Element;
416
+ readonly icon: react.JSX.Element;
417
417
  readonly defaults: {
418
418
  readonly min: 0;
419
419
  readonly max: 100;
@@ -422,7 +422,7 @@ declare const Mapper: {
422
422
  };
423
423
  rating: {
424
424
  readonly type: "rating";
425
- readonly icon: react_jsx_runtime.JSX.Element;
425
+ readonly icon: react.JSX.Element;
426
426
  readonly defaults: {
427
427
  readonly min: 0;
428
428
  readonly max: 10;
@@ -431,31 +431,31 @@ declare const Mapper: {
431
431
  };
432
432
  select: {
433
433
  readonly type: "select";
434
- readonly icon: react_jsx_runtime.JSX.Element;
434
+ readonly icon: react.JSX.Element;
435
435
  };
436
436
  multipleSelect: {
437
437
  readonly type: "multipleSelect";
438
- readonly icon: react_jsx_runtime.JSX.Element;
438
+ readonly icon: react.JSX.Element;
439
439
  };
440
440
  autocomplete: {
441
441
  readonly type: "autocomplete";
442
- readonly icon: react_jsx_runtime.JSX.Element;
442
+ readonly icon: react.JSX.Element;
443
443
  };
444
444
  dropdown: {
445
445
  readonly type: "dropdown";
446
- readonly icon: react_jsx_runtime.JSX.Element;
446
+ readonly icon: react.JSX.Element;
447
447
  };
448
448
  check: {
449
449
  readonly type: "check";
450
- readonly icon: react_jsx_runtime.JSX.Element;
450
+ readonly icon: react.JSX.Element;
451
451
  };
452
452
  switch: {
453
453
  readonly type: "switch";
454
- readonly icon: react_jsx_runtime.JSX.Element;
454
+ readonly icon: react.JSX.Element;
455
455
  };
456
456
  date: {
457
457
  readonly type: "date";
458
- readonly icon: react_jsx_runtime.JSX.Element;
458
+ readonly icon: react.JSX.Element;
459
459
  readonly defaults: {
460
460
  readonly min: null;
461
461
  readonly max: null;
@@ -463,34 +463,34 @@ declare const Mapper: {
463
463
  };
464
464
  time: {
465
465
  readonly type: "time";
466
- readonly icon: react_jsx_runtime.JSX.Element;
466
+ readonly icon: react.JSX.Element;
467
467
  readonly defaults: {
468
468
  readonly format: "/^(?:[01]d|2[0-3]):[0-5]d:[0-5]d$/";
469
469
  };
470
470
  };
471
471
  signature: {
472
472
  readonly type: "signature";
473
- readonly icon: react_jsx_runtime.JSX.Element;
473
+ readonly icon: react.JSX.Element;
474
474
  };
475
475
  fn: {
476
476
  readonly type: "fn";
477
- readonly icon: react_jsx_runtime.JSX.Element;
477
+ readonly icon: react.JSX.Element;
478
478
  };
479
479
  score: {
480
480
  readonly type: "score";
481
- readonly icon: react_jsx_runtime.JSX.Element;
481
+ readonly icon: react.JSX.Element;
482
482
  };
483
483
  cond: {
484
484
  readonly type: "cond";
485
- readonly icon: react_jsx_runtime.JSX.Element;
485
+ readonly icon: react.JSX.Element;
486
486
  };
487
487
  selectTable: {
488
488
  readonly type: "selectTable";
489
- readonly icon: react_jsx_runtime.JSX.Element;
489
+ readonly icon: react.JSX.Element;
490
490
  };
491
491
  sourceList: {
492
492
  readonly type: "sourceList";
493
- readonly icon: react_jsx_runtime.JSX.Element;
493
+ readonly icon: react.JSX.Element;
494
494
  readonly defaults: {
495
495
  readonly source: null;
496
496
  readonly min: null;
@@ -499,32 +499,32 @@ declare const Mapper: {
499
499
  };
500
500
  fileUpload: {
501
501
  readonly type: "fileUpload";
502
- readonly icon: react_jsx_runtime.JSX.Element;
502
+ readonly icon: react.JSX.Element;
503
503
  };
504
504
  section: {
505
505
  readonly type: "section";
506
- readonly icon: react_jsx_runtime.JSX.Element;
506
+ readonly icon: react.JSX.Element;
507
507
  readonly hint: "Gruppo di domande";
508
508
  };
509
509
  landing: {
510
510
  readonly type: "landing";
511
- readonly icon: react_jsx_runtime.JSX.Element;
511
+ readonly icon: react.JSX.Element;
512
512
  };
513
513
  root: {
514
514
  readonly type: "root";
515
- readonly icon: react_jsx_runtime.JSX.Element;
515
+ readonly icon: react.JSX.Element;
516
516
  };
517
517
  page: {
518
518
  readonly type: "page";
519
- readonly icon: react_jsx_runtime.JSX.Element;
519
+ readonly icon: react.JSX.Element;
520
520
  };
521
521
  folder: {
522
522
  readonly type: "folder";
523
- readonly icon: react_jsx_runtime.JSX.Element;
523
+ readonly icon: react.JSX.Element;
524
524
  };
525
525
  alert: {
526
526
  readonly type: "alert";
527
- readonly icon: react_jsx_runtime.JSX.Element;
527
+ readonly icon: react.JSX.Element;
528
528
  };
529
529
  };
530
530
  type Mapper = keyof typeof Mapper;
@@ -1 +1 @@
1
- import{getMapType as e,Mapper as t}from"../../utils/config-map.js";import"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{isTimeFormat as r}from"../../utils/time-utils.js";const n=r=>r&&0!==r.length?r.reduce((r,o)=>e(o)===t.cond.type||e(o)===t.section.type?(o.items&&o.items.length>0&&(r={...r,...n(o.items)}),r):e(o)===t.multipleSelect.type&&o.items&&o.items.length>0?(o.items.forEach(n=>{if(e(n)===t.fn?.type)return;const o=n;o&&(r[o.id]={answer:o?.answer??!1,score:!0===o?.answer?1:!1===o?.answer?0:null})}),r):e(o)===t.selectTable.type&&o.items&&o.items.length>0?(o.items.forEach(e=>{const t=e;t&&(r[t.id]={answer:t?.answer??null,score:null})}),r):(r[o.id]={answer:o.answer??null,score:null},r),{}):{},o="Questo campo è obbligatorio",i=(e,t)=>{if("HH"===t){const t=e.match(/^([01]\d|2[0-3])$/);return t?3600*Number(t[1]):null}if("HH:mm"===t){const t=e.match(/^([01]\d|2[0-3]):([0-5]\d)$/);return t?3600*Number(t[1])+60*Number(t[2]):null}const r=e.match(/^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/);return r?3600*Number(r[1])+60*Number(r[2])+Number(r[3]):null},s=e=>i(e,"HH:mm:ss")??i(e,"HH:mm")??i(e,"HH"),a=(e,t)=>{const r=Math.max(0,Math.min(86399,Math.floor(e))),n=Math.floor(r/3600).toString().padStart(2,"0"),o=Math.floor(r%3600/60).toString().padStart(2,"0"),i=(r%60).toString().padStart(2,"0");return"HH"===t?n:"HH:mm"===t?`${n}:${o}`:`${n}:${o}:${i}`},l=(n,i)=>{switch(e(n)){case t.text.type:case t.textArea.type:{const e=n.options??{};return null==i||""===i?e.required?o:void 0:"string"!=typeof i?"Valore non valido":e.min&&i.length<e.min?`Deve contenere almeno ${e.min} caratteri`:e.max&&i.length>e.max?`Può contenere al massimo ${e.max} caratteri`:e.format&&!new RegExp(e.format).test(i)?"Il formato non è corretto":void 0}case t.number.type:case t.range.type:case t.rating.type:{const e=n.options??{};if(null==i||""===i)return e.required?o:void 0;const t="number"==typeof i?i:"string"==typeof i&&""!==i.trim()?Number(i):NaN;return Number.isFinite(t)?void 0!==e.min&&t<e.min?`Deve essere almeno ${e.min}`:void 0!==e.max&&t>e.max?`Può essere al massimo ${e.max}`:void 0:"Valore numerico non valido"}case t.date.type:{const e=n.options??{};if(null==i||""===i)return e.required?o:void 0;const t="string"==typeof i?new Date(i):i instanceof Date?i:null;if(!t||Number.isNaN(t.getTime()))return"Data non valida";const r=t.getFullYear();if(r<1900||r>2099)return"La data deve essere compresa tra il 1900 e il 2099";if(e.min){const r=new Date(e.min);if(t<=r)return`La data deve essere successiva al ${r.toLocaleDateString()}`}if(e.max){const r=new Date(e.max);if(t>=r)return`La data deve essere precedente al ${r.toLocaleDateString()}`}return}case t.time.type:{const e=n.options??{},t=n.layout??{};if(null==i||""===i)return e.required?o:void 0;if("string"!=typeof i)return"Orario non valido";const l="string"==typeof t.format?t.format:"",u=r(l)?l:"HH:mm",m=s(i);if(null===m)return"Orario non valido";const c="string"==typeof t.min&&t.min?s(t.min):null;if(null!==c&&m<c)return`L'orario deve essere uguale o successivo a ${a(c,u)}`;const d="string"==typeof t.max&&t.max?s(t.max):null;return null!==d&&m>d?`L'orario deve essere uguale o precedente a ${a(d,u)}`:void 0}case t.signature.type:{const e=n.options??{};return null==i||""===i?e.required?o:void 0:"string"==typeof i&&i.startsWith("data:image")?void 0:(console.error("Invalid signature value:",i),"Firma non valida")}case t.select.type:case t.dropdown.type:case t.selectTable.type:return(null==i||""===i||Array.isArray(i)&&0===i.length)&&n.options?.required?o:void 0;case t.check.type:case t.switch.type:return null!=i&&!1!==i||!n.options?.required?void 0:o;case t.sourceList.type:return null==i||""===i||Array.isArray(i)&&0===i.length?n.options?.required?o:void 0:Array.isArray(i)?i.some(e=>"string"!=typeof e)?"Valore non valido":void 0:"Valore non valido";default:return(null==i||""===i||Array.isArray(i)&&0===i.length)&&n.options?.required?o:void 0}};function u(e){return n(e)}function m(r){const n=(r=>{if(!r||0===r.length)return[];const n=[],o=r=>{for(const i of r){const r=e(i);if(r!==t.alert.type)if(r!==t.section.type&&r!==t.cond.type)if(r===t.multipleSelect.type&&i.items&&i.items.length>0)for(const r of i.items){if(e(r)===t.fn?.type)continue;const o=r;o&&n.push(o)}else if(r===t.selectTable.type&&i.items&&i.items.length>0)for(const e of i.items){const t=e;t&&n.push(t)}else n.push(i);else i.items&&i.items.length>0&&o(i.items)}};return o(r),n})(r);return async e=>{const t={};for(const r of n){const n=e[r.id];if(!n)continue;const o=l(r,n.answer);o&&(t[`${r.id}.answer`]={type:"validate",message:o})}return 0===Object.keys(t).length?{values:e,errors:{}}:{values:{},errors:t}}}export{m as useCompilerResolver,u as useParseQuestionsForm};
1
+ import{getMapType as e,Mapper as t}from"../../utils/config-map.js";import"../../utils/locale.js";import"@famalabs/survey";import"acorn";import{isTimeFormat as r}from"../../utils/time-utils.js";const n=r=>r&&0!==r.length?r.reduce((r,o)=>e(o)===t.cond.type||e(o)===t.section.type?(o.items&&o.items.length>0&&(r={...r,...n(o.items)}),r):e(o)===t.multipleSelect.type&&o.items&&o.items.length>0?(o.items.forEach(n=>{if(e(n)===t.fn?.type)return;const o=n;o&&(r[o.id]={answer:o?.answer??!1,score:!0===o?.answer?1:!1===o?.answer?0:null})}),r):e(o)===t.selectTable.type&&o.items&&o.items.length>0?(o.items.forEach(e=>{const t=e;t&&(r[t.id]={answer:t?.answer??null,score:null})}),r):(r[o.id]={answer:o.answer??null,score:null},r),{}):{},o="Questo campo è obbligatorio",i=(e,t)=>{if("HH"===t){const t=e.match(/^([01]\d|2[0-3])$/);return t?3600*Number(t[1]):null}if("HH:mm"===t){const t=e.match(/^([01]\d|2[0-3]):([0-5]\d)$/);return t?3600*Number(t[1])+60*Number(t[2]):null}const r=e.match(/^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/);return r?3600*Number(r[1])+60*Number(r[2])+Number(r[3]):null},s=e=>i(e,"HH:mm:ss")??i(e,"HH:mm")??i(e,"HH"),a=(e,t)=>{const r=Math.max(0,Math.min(86399,Math.floor(e))),n=Math.floor(r/3600).toString().padStart(2,"0"),o=Math.floor(r%3600/60).toString().padStart(2,"0"),i=(r%60).toString().padStart(2,"0");return"HH"===t?n:"HH:mm"===t?`${n}:${o}`:`${n}:${o}:${i}`},l=(n,i)=>{switch(e(n)){case t.text.type:case t.textArea.type:{const e=n.options??{};return null==i||""===i?e.required?o:void 0:"string"!=typeof i?"Valore non valido":e.min&&i.length<e.min?`Deve contenere almeno ${e.min} caratteri`:e.max&&i.length>e.max?`Può contenere al massimo ${e.max} caratteri`:e.format&&!new RegExp(e.format).test(i)?"Il formato non è corretto":void 0}case t.number.type:case t.range.type:case t.rating.type:{const e=n.options??{};if(null==i||""===i)return e.required?o:void 0;const t="number"==typeof i?i:"string"==typeof i&&""!==i.trim()?Number(i):NaN;return Number.isFinite(t)?void 0!==e.min&&t<e.min?`Deve essere almeno ${e.min}`:void 0!==e.max&&t>e.max?`Può essere al massimo ${e.max}`:void 0:"Valore numerico non valido"}case t.date.type:{const e=n.options??{};if(null==i||""===i)return e.required?o:void 0;const t="string"==typeof i?new Date(i):i instanceof Date?i:null;if(!t||Number.isNaN(t.getTime()))return"Data non valida";const r=t.getFullYear();if(r<1900||r>2099)return"La data deve essere compresa tra il 1900 e il 2099";if(e.min){const r=new Date(e.min);if(t<=r)return`La data deve essere successiva al ${r.toLocaleDateString()}`}if(e.max){const r=new Date(e.max);if(t>=r)return`La data deve essere precedente al ${r.toLocaleDateString()}`}return}case t.time.type:{const e=n.options??{},t=n.layout??{};if(null==i||""===i)return e.required?o:void 0;if("string"!=typeof i)return"Orario non valido";const l="string"==typeof t.format?t.format:"",u=r(l)?l:"HH:mm",m=s(i);if(null===m)return"Orario non valido";const c="string"==typeof t.min&&t.min?s(t.min):null;if(null!==c&&m<c)return`L'orario deve essere uguale o successivo a ${a(c,u)}`;const d="string"==typeof t.max&&t.max?s(t.max):null;return null!==d&&m>d?`L'orario deve essere uguale o precedente a ${a(d,u)}`:void 0}case t.signature.type:{const e=n.options??{};return null==i||""===i?e.required?o:void 0:"string"==typeof i&&i.startsWith("data:image")?void 0:(console.error("Invalid signature value:",i),"Firma non valida")}case t.select.type:case t.dropdown.type:case t.selectTable.type:return(null==i||""===i||Array.isArray(i)&&0===i.length)&&n.options?.required?o:void 0;case t.check.type:case t.switch.type:return null!=i&&!1!==i||!n.options?.required?void 0:o;case t.sourceList.type:return null==i||""===i||Array.isArray(i)&&0===i.length?n.options?.required?o:void 0:Array.isArray(i)?i.some(e=>"string"!=typeof e)?"Valore non valido":void 0:"Valore non valido";default:return(null==i||""===i||Array.isArray(i)&&0===i.length)&&n.options?.required?o:void 0}};function u(e){return n(e)}function m(r){const n=(r=>{if(!r||0===r.length)return[];const n=[],o=r=>{for(const i of r){const r=e(i);if(r!==t.alert.type)if(r!==t.section.type&&r!==t.cond.type)if(r===t.multipleSelect.type&&i.items&&i.items.length>0)for(const r of i.items){if(e(r)===t.fn?.type)continue;const o=r;o&&n.push(o)}else if(r===t.selectTable.type&&i.items&&i.items.length>0)for(const e of i.items){const t=e;t&&n.push(t)}else n.push(i);else i.items&&i.items.length>0&&o(i.items)}};return o(r),n})(r);return async e=>{const t={};for(const[r,o]of n.entries()){const r=e[o.id];if(!r)continue;const n=l(o,r.answer);n&&(t[`${o.id}.answer`]={type:"validate",message:n})}return 0===Object.keys(t).length?{values:e,errors:{}}:{values:{},errors:t}}}export{m as useCompilerResolver,u as useParseQuestionsForm};
package/dist/index.d.ts CHANGED
@@ -4,6 +4,6 @@ export { AvailableQuestions, FormEditorConfiguration, OperationData, OperationDt
4
4
  export { ItemConditionalMap, ItemFunctionMap, ItemMap, Mapper, ProtoItemSchema, QuestionCheckMap, QuestionDateMap, QuestionFileMap, QuestionListMap, QuestionNumberMap, QuestionSelectMap, QuestionTextMap, getDefaultData, getMapType } from './core/utils/config-map.js';
5
5
  export { LocaleMap, getLocale, getLocaleItemTypeId } from './core/utils/locale.js';
6
6
  export { formatId, formatName, isNameValid, resolvePath } from './core/utils/format-utils.js';
7
+ export { AssetManagerProps, DynamicVariableSelectorProps, FormGlobalConfiguration, FormUploadMethods, SourceConfiguration } from './core/types/FormGlobalTypes.js';
7
8
  export { isFormValid } from './core/hooks/common/NavigationHook.js';
8
9
  export { ExecutionMode } from './core/hooks/editor/EditorOperations.js';
9
- export { AssetManagerProps, DynamicVariableSelectorProps, FormGlobalConfiguration, FormUploadMethods, SourceConfiguration } from './core/types/FormGlobalTypes.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@famalabs/web-form",
3
- "version": "1.0.0-beta.20",
3
+ "version": "1.0.0-beta.22",
4
4
  "author": " Fama Labs <info@famalabs.com>",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",