@apia/validations 1.0.4 → 2.0.1

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.
Files changed (122) hide show
  1. package/dist/collector/Collector.d.ts +34 -0
  2. package/dist/collector/Collector.d.ts.map +1 -0
  3. package/dist/collector/CollectorField.d.ts +41 -0
  4. package/dist/collector/CollectorField.d.ts.map +1 -0
  5. package/dist/collector/ValidatedCollectorField.d.ts +44 -0
  6. package/dist/collector/ValidatedCollectorField.d.ts.map +1 -0
  7. package/dist/collector/fields/Button.d.ts +13 -0
  8. package/dist/collector/fields/Button.d.ts.map +1 -0
  9. package/dist/collector/fields/Checkbox.d.ts +13 -0
  10. package/dist/collector/fields/Checkbox.d.ts.map +1 -0
  11. package/dist/collector/fields/Input.d.ts +11 -0
  12. package/dist/collector/fields/Input.d.ts.map +1 -0
  13. package/dist/collector/fields/Label.d.ts +13 -0
  14. package/dist/collector/fields/Label.d.ts.map +1 -0
  15. package/dist/collector/fields/Select.d.ts +26 -0
  16. package/dist/collector/fields/Select.d.ts.map +1 -0
  17. package/dist/collector/fields/Textarea.d.ts +11 -0
  18. package/dist/collector/fields/Textarea.d.ts.map +1 -0
  19. package/dist/components/Captcha.d.ts +13 -0
  20. package/dist/components/Captcha.d.ts.map +1 -0
  21. package/dist/components/Checkbox.d.ts +12 -0
  22. package/dist/components/Checkbox.d.ts.map +1 -0
  23. package/dist/components/DeletableInput.d.ts +9 -0
  24. package/dist/components/DeletableInput.d.ts.map +1 -0
  25. package/dist/components/FieldWrapper.d.ts +20 -0
  26. package/dist/components/FieldWrapper.d.ts.map +1 -0
  27. package/dist/components/FileInput.d.ts +11 -0
  28. package/dist/components/FileInput.d.ts.map +1 -0
  29. package/dist/components/Input.d.ts +9 -0
  30. package/dist/components/Input.d.ts.map +1 -0
  31. package/dist/components/NumberInput.d.ts +14 -0
  32. package/dist/components/NumberInput.d.ts.map +1 -0
  33. package/dist/components/Radio.d.ts +14 -0
  34. package/dist/components/Radio.d.ts.map +1 -0
  35. package/dist/components/Select.d.ts +17 -0
  36. package/dist/components/Select.d.ts.map +1 -0
  37. package/dist/components/Switchbox.d.ts +11 -0
  38. package/dist/components/Switchbox.d.ts.map +1 -0
  39. package/dist/components/Textarea.d.ts +9 -0
  40. package/dist/components/Textarea.d.ts.map +1 -0
  41. package/dist/components/ValidationError.d.ts +17 -0
  42. package/dist/components/ValidationError.d.ts.map +1 -0
  43. package/dist/components/types.d.ts +11 -0
  44. package/dist/components/types.d.ts.map +1 -0
  45. package/dist/da.js +30 -0
  46. package/dist/da.js.map +1 -0
  47. package/dist/de.js +26 -0
  48. package/dist/de.js.map +1 -0
  49. package/dist/en.js +32 -0
  50. package/dist/en.js.map +1 -0
  51. package/dist/es.js +32 -0
  52. package/dist/es.js.map +1 -0
  53. package/dist/fa.js +29 -0
  54. package/dist/fa.js.map +1 -0
  55. package/dist/form/Form.d.ts +89 -0
  56. package/dist/form/Form.d.ts.map +1 -0
  57. package/dist/form/FormContext.d.ts +27 -0
  58. package/dist/form/FormContext.d.ts.map +1 -0
  59. package/dist/fr.js +31 -0
  60. package/dist/fr.js.map +1 -0
  61. package/dist/gr.js +24 -0
  62. package/dist/gr.js.map +1 -0
  63. package/dist/hooks/useField.d.ts +76 -0
  64. package/dist/hooks/useField.d.ts.map +1 -0
  65. package/dist/hooks/useFieldStatesClassNames.d.ts +4 -0
  66. package/dist/hooks/useFieldStatesClassNames.d.ts.map +1 -0
  67. package/dist/hooks/useFieldValue.d.ts +8 -0
  68. package/dist/hooks/useFieldValue.d.ts.map +1 -0
  69. package/dist/hooks/useValidationClass.d.ts +49 -0
  70. package/dist/hooks/useValidationClass.d.ts.map +1 -0
  71. package/dist/hr.js +31 -0
  72. package/dist/hr.js.map +1 -0
  73. package/dist/hu.js +29 -0
  74. package/dist/hu.js.map +1 -0
  75. package/dist/index.d.ts +26 -684
  76. package/dist/index.js +865 -1225
  77. package/dist/index.js.map +1 -1
  78. package/dist/it.js +25 -0
  79. package/dist/it.js.map +1 -0
  80. package/dist/ja.js +25 -0
  81. package/dist/ja.js.map +1 -0
  82. package/dist/jp.js +25 -0
  83. package/dist/jp.js.map +1 -0
  84. package/dist/lang/es.d.ts +32 -0
  85. package/dist/lang/es.d.ts.map +1 -0
  86. package/dist/nl.js +26 -0
  87. package/dist/nl.js.map +1 -0
  88. package/dist/pl.js +31 -0
  89. package/dist/pl.js.map +1 -0
  90. package/dist/pt.js +26 -0
  91. package/dist/pt.js.map +1 -0
  92. package/dist/ro.js +30 -0
  93. package/dist/ro.js.map +1 -0
  94. package/dist/types.d.ts +130 -0
  95. package/dist/types.d.ts.map +1 -0
  96. package/dist/util.d.ts +36 -0
  97. package/dist/util.d.ts.map +1 -0
  98. package/dist/validationStore.d.ts +112 -0
  99. package/dist/validationStore.d.ts.map +1 -0
  100. package/package.json +21 -34
  101. package/rollup.validations.mjs +69 -0
  102. package/LICENSE.md +0 -21
  103. package/README.md +0 -28
  104. package/cleanDist.json +0 -3
  105. package/lang/bg.ts +0 -27
  106. package/lang/da.ts +0 -31
  107. package/lang/de.ts +0 -26
  108. package/lang/en.ts +0 -34
  109. package/lang/es.ts +0 -38
  110. package/lang/fa.ts +0 -39
  111. package/lang/fr.ts +0 -36
  112. package/lang/gr.ts +0 -24
  113. package/lang/hr.ts +0 -31
  114. package/lang/hu.ts +0 -30
  115. package/lang/it.ts +0 -25
  116. package/lang/ja.ts +0 -25
  117. package/lang/jp.ts +0 -25
  118. package/lang/nl.ts +0 -26
  119. package/lang/pl.ts +0 -35
  120. package/lang/pt.ts +0 -27
  121. package/lang/ro.ts +0 -37
  122. package/lang/ru.ts +0 -26
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { customEvents, propsStore, usePropsSelector, useUpdateEffect, useUnmount, useMount, PropsSelectorUndefinedObject, formatMessage, toBoolean, EventEmitter, getLabel } from '@apia/util';
3
- import { uniqueId } from 'lodash';
1
+ import { jsx, jsxs } from '@apia/theme/jsx-runtime';
2
+ import { customEvents, propsStore, usePropsSelector, useUpdateEffect, useUnmount, useMount, PropsSelectorUndefinedObject, formatMessage, toBoolean, EventEmitter, StatefulEmitter, useSubscription, getLabel } from '@apia/util';
3
+ import uniqueId from 'lodash-es/uniqueId';
4
4
  import React, { useState } from 'react';
5
5
  import { shallowEqual } from 'react-redux';
6
- import { injectStyles, Box, getVariant, Input as Input$1, Label, Radio as Radio$1, Select as Select$1, Switch, Textarea as Textarea$1, Button } from '@apia/theme';
6
+ import { Box, getVariant, injectStyles, Input as Input$1, Label, Radio as Radio$1, Select as Select$1, Switch, Textarea as Textarea$1, Button } from '@apia/theme';
7
7
  import { notify } from '@apia/notifications';
8
- import { RequiredMark, Captcha, Checkbox as Checkbox$1, IconButton, getFieldErrorStyles, DateInput, parseNumberInputValueToNumber, NumberInput, ApiaUtil } from '@apia/components';
8
+ import { RequiredMark, Captcha, Checkbox as Checkbox$1, IconButton, getFieldErrorStyles, DateInput, parseNumberInputValueToNumber, NumberInput, SimpleButton, useModalContext, ApiaUtil } from '@apia/components';
9
9
 
10
10
  const FormContext = React.createContext(
11
11
  {}
@@ -25,58 +25,45 @@ function validateByRules({
25
25
  return validationResult;
26
26
  }
27
27
 
28
- var __defProp$f = Object.defineProperty;
29
- var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
30
- var __hasOwnProp$g = Object.prototype.hasOwnProperty;
31
- var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
32
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
33
- var __spreadValues$f = (a, b) => {
34
- for (var prop in b || (b = {}))
35
- if (__hasOwnProp$g.call(b, prop))
36
- __defNormalProp$f(a, prop, b[prop]);
37
- if (__getOwnPropSymbols$g)
38
- for (var prop of __getOwnPropSymbols$g(b)) {
39
- if (__propIsEnum$g.call(b, prop))
40
- __defNormalProp$f(a, prop, b[prop]);
41
- }
42
- return a;
43
- };
44
- var __async$2 = (__this, __arguments, generator) => {
45
- return new Promise((resolve, reject) => {
46
- var fulfilled = (value) => {
47
- try {
48
- step(generator.next(value));
49
- } catch (e) {
50
- reject(e);
51
- }
52
- };
53
- var rejected = (value) => {
54
- try {
55
- step(generator.throw(value));
56
- } catch (e) {
57
- reject(e);
58
- }
59
- };
60
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
61
- step((generator = generator.apply(__this, __arguments)).next());
62
- });
63
- };
64
- function validateField(field, formName) {
65
- return __async$2(this, null, function* () {
66
- let validationResult = null;
67
- const fieldValue = field.validationValueParser ? field.validationValueParser(field.value) : field.value;
68
- if (field.validationFunction) {
69
- validationResult = yield field.validationFunction(fieldValue, formName);
70
- }
71
- if ((!field.validationFunction || validationResult === true) && field.validationRules) {
72
- validationResult = validateByRules({
73
- rules: field.validationRules,
74
- value: fieldValue
75
- });
76
- } else if (validationResult === null)
77
- validationResult = true;
78
- return validationResult;
79
- });
28
+ function __variableDynamicImportRuntime2__(path) {
29
+ switch (path) {
30
+ case './lang/da.ts': return import('./da.js');
31
+ case './lang/de.ts': return import('./de.js');
32
+ case './lang/en.ts': return import('./en.js');
33
+ case './lang/es.ts': return import('./es.js');
34
+ case './lang/fa.ts': return import('./fa.js');
35
+ case './lang/fr.ts': return import('./fr.js');
36
+ case './lang/gr.ts': return import('./gr.js');
37
+ case './lang/hr.ts': return import('./hr.js');
38
+ case './lang/hu.ts': return import('./hu.js');
39
+ case './lang/it.ts': return import('./it.js');
40
+ case './lang/ja.ts': return import('./ja.js');
41
+ case './lang/jp.ts': return import('./jp.js');
42
+ case './lang/nl.ts': return import('./nl.js');
43
+ case './lang/pl.ts': return import('./pl.js');
44
+ case './lang/pt.ts': return import('./pt.js');
45
+ case './lang/ro.ts': return import('./ro.js');
46
+ default: return new Promise(function(resolve, reject) {
47
+ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
48
+ reject.bind(null, new Error("Unknown variable dynamic import: " + path))
49
+ );
50
+ })
51
+ }
52
+ }
53
+ async function validateField(field, formName) {
54
+ let validationResult = null;
55
+ const fieldValue = field.validationValueParser ? field.validationValueParser(field.value) : field.value;
56
+ if (field.validationFunction) {
57
+ validationResult = await field.validationFunction(fieldValue, formName);
58
+ }
59
+ if ((!field.validationFunction || validationResult === true) && field.validationRules) {
60
+ validationResult = validateByRules({
61
+ rules: field.validationRules,
62
+ value: fieldValue
63
+ });
64
+ } else if (validationResult === null)
65
+ validationResult = true;
66
+ return validationResult;
80
67
  }
81
68
  function hasSucceedFieldValidation(result) {
82
69
  return result === true;
@@ -84,28 +71,26 @@ function hasSucceedFieldValidation(result) {
84
71
  function hasSucceedFormValidation(result) {
85
72
  return !("errors" in result);
86
73
  }
87
- function focusOnField(formName, field) {
88
- return __async$2(this, null, function* () {
89
- const formElement = document.getElementById(
90
- `ValidationForm-${formName}`
91
- );
92
- const fieldElement = formElement == null ? void 0 : formElement.querySelector(
93
- `[name="${field.name}"], #${field.name}`
94
- );
95
- if (fieldElement) {
96
- return new Promise((resolve) => {
97
- const event = new CustomEvent(customEvents.focus, { bubbles: true });
98
- fieldElement.focus();
99
- fieldElement.dispatchEvent(event);
100
- fieldElement.scrollIntoView({
101
- block: "center",
102
- behavior: "auto"
103
- });
104
- resolve(true);
74
+ async function focusOnField(formName, field) {
75
+ const formElement = document.getElementById(
76
+ `ValidationForm-${formName}`
77
+ );
78
+ const fieldElement = formElement?.querySelector(
79
+ `[name="${field.name}"], #${field.name}`
80
+ );
81
+ if (fieldElement) {
82
+ return new Promise((resolve) => {
83
+ const event = new CustomEvent(customEvents.focus, { bubbles: true });
84
+ fieldElement.focus();
85
+ fieldElement.dispatchEvent(event);
86
+ fieldElement.scrollIntoView({
87
+ block: "center",
88
+ behavior: "auto"
105
89
  });
106
- }
107
- return false;
108
- });
90
+ resolve(true);
91
+ });
92
+ }
93
+ return false;
109
94
  }
110
95
  let langDefinition;
111
96
  function lang(errorCode, ...replacements) {
@@ -118,11 +103,10 @@ function lang(errorCode, ...replacements) {
118
103
  return returnString;
119
104
  }
120
105
  function classToValidationFunction(className) {
121
- const match = className == null ? void 0 : className.match(/'confirm:(\w+):(.+?)']/);
106
+ const match = className?.match(/'confirm:(\w+):(.+?)']/);
122
107
  if (match) {
123
108
  const validationFunction = (value, formName) => {
124
- var _a, _b;
125
- return value === ((_a = validationsStore.getFieldStore(formName, match[1])) == null ? void 0 : _a.value) ? true : lang("confirm", (_b = match[2]) != null ? _b : match[1]);
109
+ return value === validationsStore.getFieldStore(formName, match[1])?.value ? true : lang("confirm", match[2] ?? match[1]);
126
110
  };
127
111
  return validationFunction;
128
112
  }
@@ -153,26 +137,23 @@ function classToValidate(className) {
153
137
  }
154
138
  return {};
155
139
  }
156
- function initValidations() {
157
- return __async$2(this, null, function* () {
158
- var _a;
159
- if (langDefinition)
160
- return;
161
- const code = (_a = document.documentElement.lang) != null ? _a : "es";
162
- langDefinition = (yield import(
163
- /* webpackChunkName: "val-lang-[request]" */
164
- `../lang/${code}.ts`
165
- ).catch((error) => {
166
- notify({
167
- type: "danger",
168
- message: window.NO_LANGUAGE_EXCEPTION
169
- });
170
- throw error;
171
- })).default;
172
- });
140
+ async function initValidations() {
141
+ if (langDefinition)
142
+ return;
143
+ const code = document.documentElement.lang ?? "es";
144
+ langDefinition = (await __variableDynamicImportRuntime2__(
145
+ /* webpackChunkName: "val-lang-[request]" */
146
+ `./lang/${code}.ts`
147
+ ).catch((error) => {
148
+ notify({
149
+ type: "danger",
150
+ message: window.NO_LANGUAGE_EXCEPTION
151
+ });
152
+ throw error;
153
+ })).default;
173
154
  }
174
155
  function getValidations(outerValidation) {
175
- const validation = __spreadValues$f({}, outerValidation);
156
+ const validation = { ...outerValidation };
176
157
  if (!validation)
177
158
  return {
178
159
  validate: () => {
@@ -181,8 +162,7 @@ function getValidations(outerValidation) {
181
162
  };
182
163
  return {
183
164
  validate: (outerV) => {
184
- var _a;
185
- const v = outerV != null ? outerV : "";
165
+ const v = outerV ?? "";
186
166
  let returnValue = true;
187
167
  if (returnValue && validation.pattern) {
188
168
  let actualRegexp;
@@ -199,7 +179,7 @@ function getValidations(outerValidation) {
199
179
  );
200
180
  } else
201
181
  actualRegexp = validation.pattern;
202
- returnValue = !!outerV.match(actualRegexp) || ((_a = validation.patternMessage) != null ? _a : window.MSG_INVALID_REG_EXP);
182
+ returnValue = !!outerV.match(actualRegexp) || (validation.patternMessage ?? window.MSG_INVALID_REG_EXP);
203
183
  }
204
184
  if (returnValue === true && validation.maxLength)
205
185
  returnValue = v.length <= validation.maxLength || lang("lengthmax", validation.maxLength);
@@ -249,80 +229,33 @@ function getValidations(outerValidation) {
249
229
  };
250
230
  }
251
231
 
252
- var __defProp$e = Object.defineProperty;
253
- var __defProps$c = Object.defineProperties;
254
- var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
255
- var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
256
- var __hasOwnProp$f = Object.prototype.hasOwnProperty;
257
- var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
258
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
259
- var __spreadValues$e = (a, b) => {
260
- for (var prop in b || (b = {}))
261
- if (__hasOwnProp$f.call(b, prop))
262
- __defNormalProp$e(a, prop, b[prop]);
263
- if (__getOwnPropSymbols$f)
264
- for (var prop of __getOwnPropSymbols$f(b)) {
265
- if (__propIsEnum$f.call(b, prop))
266
- __defNormalProp$e(a, prop, b[prop]);
267
- }
268
- return a;
269
- };
270
- var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
271
- var __objRest$b = (source, exclude) => {
272
- var target = {};
273
- for (var prop in source)
274
- if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
275
- target[prop] = source[prop];
276
- if (source != null && __getOwnPropSymbols$f)
277
- for (var prop of __getOwnPropSymbols$f(source)) {
278
- if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
279
- target[prop] = source[prop];
280
- }
281
- return target;
282
- };
283
- var __async$1 = (__this, __arguments, generator) => {
284
- return new Promise((resolve, reject) => {
285
- var fulfilled = (value) => {
286
- try {
287
- step(generator.next(value));
288
- } catch (e) {
289
- reject(e);
290
- }
291
- };
292
- var rejected = (value) => {
293
- try {
294
- step(generator.throw(value));
295
- } catch (e) {
296
- reject(e);
297
- }
298
- };
299
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
300
- step((generator = generator.apply(__this, __arguments)).next());
301
- });
232
+ var __defProp$9 = Object.defineProperty;
233
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
234
+ var __publicField$9 = (obj, key, value) => {
235
+ __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
236
+ return value;
302
237
  };
303
238
  const validationsStore = new class {
304
239
  constructor() {
305
- this.activeForms = [];
306
- this.timeouts = {};
307
- this.existsField = (formName, fieldName) => {
308
- var _a, _b;
309
- return !!((_b = (_a = this.getFormStore(formName)) == null ? void 0 : _a.fields) == null ? void 0 : _b.includes(fieldName));
310
- };
311
- this.registerField = (formName, registerData, options = { registerIfExists: true }) => {
312
- var _a, _b, _c;
240
+ __publicField$9(this, "activeForms", []);
241
+ __publicField$9(this, "timeouts", {});
242
+ __publicField$9(this, "existsField", (formName, fieldName) => {
243
+ return !!this.getFormStore(formName)?.fields?.includes(fieldName);
244
+ });
245
+ __publicField$9(this, "registerField", (formName, registerData, options = { registerIfExists: true }) => {
313
246
  const formProps = this.getFormStore(formName);
314
247
  if (formProps === void 0)
315
248
  this.registerForm(formName);
316
- if (!((_a = this.getFormStore(formName)) == null ? void 0 : _a.fields.includes(registerData.name)))
249
+ if (!this.getFormStore(formName)?.fields.includes(registerData.name))
317
250
  this.updateFormStore(formName, {
318
251
  fields: [
319
- ...(_c = (_b = this.getFormStore(formName)) == null ? void 0 : _b.fields) != null ? _c : [],
252
+ ...this.getFormStore(formName)?.fields ?? [],
320
253
  registerData.name
321
254
  ]
322
255
  });
323
256
  const existsInStore = this.getFieldStore(formName, registerData.name);
324
- if (((formProps == null ? void 0 : formProps.avoidFieldsOverride) || !options.registerIfExists) && existsInStore) {
325
- const _d = registerData, updateData = __objRest$b(_d, ["value"]);
257
+ if ((formProps?.avoidFieldsOverride || !options.registerIfExists) && existsInStore) {
258
+ const { value, ...updateData } = registerData;
326
259
  this.updateField(formName, updateData, {
327
260
  markFormAsTouched: false,
328
261
  avoidPropagation: options.avoidPropagation
@@ -335,12 +268,11 @@ const validationsStore = new class {
335
268
  registerData,
336
269
  options.avoidPropagation
337
270
  );
338
- };
271
+ });
339
272
  /**
340
273
  * Inicializa el estado de un nuevo formulario
341
274
  */
342
- this.registerForm = (formName, props = { avoidFieldsOverride: false }) => {
343
- var _a;
275
+ __publicField$9(this, "registerForm", (formName, props = { avoidFieldsOverride: false }) => {
344
276
  if (this.activeForms.includes(formName)) {
345
277
  this.updateFormStore(formName, {
346
278
  avoidFieldsOverride: props.avoidFieldsOverride
@@ -348,7 +280,7 @@ const validationsStore = new class {
348
280
  if (props.initialValues)
349
281
  Object.entries(props.initialValues).forEach(([fieldId, fieldProps]) => {
350
282
  if (fieldProps instanceof Object)
351
- this.updateField(formName, __spreadValues$e({ name: fieldId }, fieldProps));
283
+ this.updateField(formName, { name: fieldId, ...fieldProps });
352
284
  });
353
285
  return;
354
286
  }
@@ -361,15 +293,15 @@ const validationsStore = new class {
361
293
  name: formName,
362
294
  validationResult: null
363
295
  });
364
- Object.entries((_a = props.initialValues) != null ? _a : {}).forEach(([name, value]) => {
296
+ Object.entries(props.initialValues ?? {}).forEach(([name, value]) => {
365
297
  this.updateField(formName, { name, value }, { markFormAsTouched: false });
366
298
  });
367
- };
299
+ });
368
300
  /**
369
301
  * Setea el valor del campo con el nombre provisto. Si el campo no existe
370
302
  * en el formulario lo crea.
371
303
  */
372
- this.setFieldValue = (formName, fieldName, newValue, options) => {
304
+ __publicField$9(this, "setFieldValue", (formName, fieldName, newValue, options) => {
373
305
  if (!this.getFieldStore(formName, fieldName))
374
306
  this.registerField(formName, { name: fieldName, value: newValue });
375
307
  else
@@ -384,16 +316,16 @@ const validationsStore = new class {
384
316
  );
385
317
  if (this.getFormStore(formName).isValid)
386
318
  this.updateFormStore(formName, { isValid: false });
387
- };
388
- this.setFormIsTouched = (formName, isTouched = true) => {
319
+ });
320
+ __publicField$9(this, "setFormIsTouched", (formName, isTouched = true) => {
389
321
  this.updateFormStore(formName, { isTouched });
390
- };
322
+ });
391
323
  /**
392
324
  * Elimina un campo del registro de validación de un formulario. De esta
393
325
  * forma cualquier validación que pudiera aplicarse sobre el mismo, ya no se
394
326
  * aplicará.
395
327
  */
396
- this.unregisterField = (formName, fieldName) => {
328
+ __publicField$9(this, "unregisterField", (formName, fieldName) => {
397
329
  if (this.getFormStore(formName))
398
330
  this.updateFormStore(formName, {
399
331
  fields: this.getFormStore(formName).fields.filter((current) => {
@@ -401,14 +333,13 @@ const validationsStore = new class {
401
333
  })
402
334
  });
403
335
  propsStore.removeField(this.makeFieldName(formName, fieldName));
404
- };
336
+ });
405
337
  /**
406
338
  * Elimina un formulario del store de validación junto con todos los campos
407
339
  * asociados al mismo.
408
340
  */
409
- this.unregisterForm = (formName) => {
410
- var _a, _b;
411
- (_b = (_a = this.getFormStore(formName)) == null ? void 0 : _a.fields) == null ? void 0 : _b.forEach((current) => {
341
+ __publicField$9(this, "unregisterForm", (formName) => {
342
+ this.getFormStore(formName)?.fields?.forEach((current) => {
412
343
  return propsStore.removeField(this.makeFieldName(formName, current));
413
344
  });
414
345
  this.activeForms = this.activeForms.filter((current) => {
@@ -416,42 +347,42 @@ const validationsStore = new class {
416
347
  });
417
348
  propsStore.removeField(this.makeFormName(formName));
418
349
  delete this.timeouts[formName];
419
- };
350
+ });
420
351
  /**
421
352
  * Actualiza las propiedades de un campo, si no existe, lo registra en el
422
353
  * formulario.
423
354
  */
424
- this.updateField = (formName, field, options) => {
425
- var _a, _b;
426
- const previousValue = (_a = this.getFieldStore(formName, field.name)) == null ? void 0 : _a.value;
355
+ __publicField$9(this, "updateField", (formName, field, options) => {
356
+ const previousValue = this.getFieldStore(formName, field.name)?.value;
427
357
  if (this.getFormStore(formName))
428
358
  this.updateFormStore(formName, { isValid: false });
429
359
  else
430
360
  this.registerForm(formName);
431
- const isTouched = field.value !== void 0 && field.value !== previousValue && (options == null ? void 0 : options.markFormAsTouched) !== false;
361
+ const isTouched = field.value !== void 0 && field.value !== previousValue && options?.markFormAsTouched !== false;
432
362
  if (!this.existsField(formName, field.name))
433
363
  this.registerField(formName, field, {
434
- avoidPropagation: options == null ? void 0 : options.avoidPropagation
364
+ avoidPropagation: options?.avoidPropagation
435
365
  });
436
366
  this.updateFieldStore(
437
367
  formName,
438
368
  field.name,
439
- __spreadProps$c(__spreadValues$e({}, field), {
440
- isTouched: isTouched || ((_b = this.getFieldStore(formName, field.name)) == null ? void 0 : _b.isTouched)
441
- }),
442
- options == null ? void 0 : options.avoidPropagation
369
+ {
370
+ ...field,
371
+ isTouched: isTouched || this.getFieldStore(formName, field.name)?.isTouched
372
+ },
373
+ options?.avoidPropagation
443
374
  );
444
375
  if (isTouched)
445
376
  this.setFormIsTouched(formName);
446
- };
377
+ });
447
378
  /**
448
379
  * Actualiza múltiples campos al mismo tiempo.
449
380
  */
450
- this.updateMultipleFields = (formName, fields, options) => {
381
+ __publicField$9(this, "updateMultipleFields", (formName, fields, options) => {
451
382
  fields.forEach((current) => {
452
383
  return this.updateField(formName, current, options);
453
384
  });
454
- };
385
+ });
455
386
  /**
456
387
  * Ejecuta la validación sobre un formulario. En caso de que la validación
457
388
  * falle, se intenta hacer foco sobre el campo que no pudo validar.
@@ -476,8 +407,7 @@ const validationsStore = new class {
476
407
  * console.error('Validation error', result);
477
408
  * }
478
409
  */
479
- this.validateForm = (formName) => __async$1(this, null, function* () {
480
- var _a;
410
+ __publicField$9(this, "validateForm", async (formName) => {
481
411
  const state = this.getFormStore(formName);
482
412
  const fields = state.fields.map((current) => {
483
413
  return this.getFieldStore(formName, current);
@@ -493,10 +423,10 @@ const validationsStore = new class {
493
423
  for (const field of fields.filter((current) => {
494
424
  return current !== void 0;
495
425
  })) {
496
- const validationResult = yield validateField(field, formName);
426
+ const validationResult = await validateField(field, formName);
497
427
  fieldsWithError[field.name] = validationResult;
498
428
  if (hasSucceedFieldValidation(validationResult)) {
499
- validationValues.submitValues[(_a = field.submitName) != null ? _a : field.name] = field.submitValueParser ? field.submitValueParser(field.value) : field.value;
429
+ validationValues.submitValues[field.submitName ?? field.name] = field.submitValueParser ? await field.submitValueParser(field.value) : field.value;
500
430
  validationValues.values[field.name] = field.value;
501
431
  } else {
502
432
  this.updateField(formName, {
@@ -504,7 +434,7 @@ const validationsStore = new class {
504
434
  error: validationResult
505
435
  });
506
436
  if (!hasFiredFocus) {
507
- if (yield focusOnField(formName, field))
437
+ if (await focusOnField(formName, field))
508
438
  hasFiredFocus = true;
509
439
  }
510
440
  existsErrors = true;
@@ -543,7 +473,10 @@ const validationsStore = new class {
543
473
  updateFieldStore(formName, fieldName, props, noEmit) {
544
474
  propsStore.updateField(
545
475
  this.makeFieldName(formName, fieldName),
546
- __spreadValues$e(__spreadValues$e({}, this.getFieldStore(formName, fieldName)), props),
476
+ {
477
+ ...this.getFieldStore(formName, fieldName),
478
+ ...props
479
+ },
547
480
  { noEmit }
548
481
  );
549
482
  }
@@ -593,45 +526,6 @@ const formStyles = {
593
526
  }
594
527
  };
595
528
 
596
- var __defProp$d = Object.defineProperty;
597
- var __defProps$b = Object.defineProperties;
598
- var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
599
- var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
600
- var __hasOwnProp$e = Object.prototype.hasOwnProperty;
601
- var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
602
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
603
- var __spreadValues$d = (a, b) => {
604
- for (var prop in b || (b = {}))
605
- if (__hasOwnProp$e.call(b, prop))
606
- __defNormalProp$d(a, prop, b[prop]);
607
- if (__getOwnPropSymbols$e)
608
- for (var prop of __getOwnPropSymbols$e(b)) {
609
- if (__propIsEnum$e.call(b, prop))
610
- __defNormalProp$d(a, prop, b[prop]);
611
- }
612
- return a;
613
- };
614
- var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
615
- var __async = (__this, __arguments, generator) => {
616
- return new Promise((resolve, reject) => {
617
- var fulfilled = (value) => {
618
- try {
619
- step(generator.next(value));
620
- } catch (e) {
621
- reject(e);
622
- }
623
- };
624
- var rejected = (value) => {
625
- try {
626
- step(generator.throw(value));
627
- } catch (e) {
628
- reject(e);
629
- }
630
- };
631
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
632
- step((generator = generator.apply(__this, __arguments)).next());
633
- });
634
- };
635
529
  const Form = ({
636
530
  avoidFieldsOverride,
637
531
  avoidFieldsTouch,
@@ -644,7 +538,7 @@ const Form = ({
644
538
  unregisterOnUnmount
645
539
  }) => {
646
540
  const actualName = React.useMemo(
647
- () => name != null ? name : `ValidationForm${uniqueId()}`,
541
+ () => name ?? `ValidationForm${uniqueId()}`,
648
542
  // eslint-disable-next-line react-hooks/exhaustive-deps
649
543
  []
650
544
  );
@@ -668,21 +562,19 @@ const Form = ({
668
562
  () => ({
669
563
  avoidFieldsTouch,
670
564
  name: actualName,
671
- validate: () => __async(void 0, null, function* () {
672
- return validationsStore.validateForm(actualName);
673
- })
565
+ validate: async () => validationsStore.validateForm(actualName)
674
566
  }),
675
567
  [actualName, avoidFieldsTouch]
676
568
  );
677
569
  useUnmount(() => {
678
- onUnmount == null ? void 0 : onUnmount();
570
+ onUnmount?.();
679
571
  if (unregisterOnUnmount !== false)
680
572
  validationsStore.unregisterForm(actualName);
681
573
  });
682
574
  const [hasRegistered, setHasRegistered] = React.useState(false);
683
575
  useMount(() => {
684
576
  validationsStore.registerForm(actualName, {
685
- avoidFieldsOverride: avoidFieldsOverride != null ? avoidFieldsOverride : initialValues !== void 0,
577
+ avoidFieldsOverride: avoidFieldsOverride ?? initialValues !== void 0,
686
578
  initialValues
687
579
  });
688
580
  setHasRegistered(true);
@@ -691,39 +583,22 @@ const Form = ({
691
583
  return null;
692
584
  return /* @__PURE__ */ jsx(FormContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
693
585
  Box,
694
- __spreadProps$b(__spreadValues$d(__spreadProps$b(__spreadValues$d({
695
- as: "form"
696
- }, getVariant("layout.common.validations.form")), {
586
+ {
587
+ as: "form",
588
+ ...getVariant("layout.common.validations.form"),
697
589
  className,
698
- id: `ValidationForm-${actualName}`
699
- }), { name: actualName }), {
590
+ id: `ValidationForm-${actualName}`,
591
+ ...{ name: actualName },
700
592
  onSubmit: handleSubmit,
701
593
  children
702
- })
594
+ }
703
595
  ) });
704
596
  };
705
597
  injectStyles("layout.common.validations.form", formStyles);
706
598
 
707
- var __defProp$c = Object.defineProperty;
708
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
709
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
710
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
711
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
712
- var __spreadValues$c = (a, b) => {
713
- for (var prop in b || (b = {}))
714
- if (__hasOwnProp$d.call(b, prop))
715
- __defNormalProp$c(a, prop, b[prop]);
716
- if (__getOwnPropSymbols$d)
717
- for (var prop of __getOwnPropSymbols$d(b)) {
718
- if (__propIsEnum$d.call(b, prop))
719
- __defNormalProp$c(a, prop, b[prop]);
720
- }
721
- return a;
722
- };
723
599
  function useField(fieldDefinition) {
724
- var _a;
725
600
  const formContext = React.useContext(FormContext);
726
- const formName = (_a = fieldDefinition.formName) != null ? _a : formContext.name;
601
+ const formName = fieldDefinition.formName ?? formContext.name;
727
602
  if (!formName) {
728
603
  console.error(fieldDefinition);
729
604
  throw new Error(
@@ -733,7 +608,10 @@ function useField(fieldDefinition) {
733
608
  React.useMemo(() => {
734
609
  validationsStore.registerField(
735
610
  formName,
736
- __spreadValues$c(__spreadValues$c({}, fieldDefinition), fieldDefinition.initialValue !== void 0 ? { value: fieldDefinition.initialValue } : null),
611
+ {
612
+ ...fieldDefinition,
613
+ ...fieldDefinition.initialValue !== void 0 ? { value: fieldDefinition.initialValue } : null
614
+ },
737
615
  {
738
616
  avoidPropagation: true,
739
617
  registerIfExists: !fieldDefinition.avoidRegisterIfExists
@@ -741,8 +619,7 @@ function useField(fieldDefinition) {
741
619
  );
742
620
  }, []);
743
621
  useMount(() => {
744
- var _a2;
745
- if (fieldDefinition.initialValue !== void 0 && (!((_a2 = validationsStore.getFormStore(formName)) == null ? void 0 : _a2.avoidFieldsOverride) && !fieldDefinition.avoidRegisterIfExists || validationsStore.getFieldStore(formName, fieldDefinition.name) === void 0))
622
+ if (fieldDefinition.initialValue !== void 0 && (!validationsStore.getFormStore(formName)?.avoidFieldsOverride && !fieldDefinition.avoidRegisterIfExists || validationsStore.getFieldStore(formName, fieldDefinition.name) === void 0))
746
623
  validationsStore.setFieldValue(
747
624
  formName,
748
625
  fieldDefinition.name,
@@ -807,7 +684,7 @@ function useField(fieldDefinition) {
807
684
  },
808
685
  [formName, fieldDefinition.name]
809
686
  ),
810
- value: localValue != null ? localValue : fieldDefinition.initialValue
687
+ value: localValue ?? fieldDefinition.initialValue
811
688
  };
812
689
  }
813
690
 
@@ -834,36 +711,20 @@ function useFieldValue({ formName, name }) {
834
711
  );
835
712
  }
836
713
  const { value } = useFieldSelector(
837
- formName != null ? formName : hookFormName,
714
+ formName ?? hookFormName,
838
715
  name,
839
716
  (props) => {
840
717
  return props;
841
718
  },
842
719
  (a, b) => {
843
- if (a === PropsSelectorUndefinedObject && (b == null ? void 0 : b.value) === void 0)
720
+ if (a === PropsSelectorUndefinedObject && b?.value === void 0)
844
721
  return true;
845
- return shallowEqual(a == null ? void 0 : a.value, b == null ? void 0 : b.value);
722
+ return shallowEqual(a?.value, b?.value);
846
723
  }
847
724
  );
848
725
  return value;
849
726
  }
850
727
 
851
- var __defProp$b = Object.defineProperty;
852
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
853
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
854
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
855
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
856
- var __spreadValues$b = (a, b) => {
857
- for (var prop in b || (b = {}))
858
- if (__hasOwnProp$c.call(b, prop))
859
- __defNormalProp$b(a, prop, b[prop]);
860
- if (__getOwnPropSymbols$c)
861
- for (var prop of __getOwnPropSymbols$c(b)) {
862
- if (__propIsEnum$c.call(b, prop))
863
- __defNormalProp$b(a, prop, b[prop]);
864
- }
865
- return a;
866
- };
867
728
  function useValidationClass({
868
729
  customValidation,
869
730
  formName,
@@ -878,16 +739,12 @@ function useValidationClass({
878
739
  [validationClass]
879
740
  );
880
741
  const initialValidationFunction = React.useMemo(
881
- () => {
882
- var _a;
883
- return (_a = validationsStore.getFieldStore(formName != null ? formName : contextFormName, name)) == null ? void 0 : _a.validationFunction;
884
- },
742
+ () => validationsStore.getFieldStore(formName ?? contextFormName, name)?.validationFunction,
885
743
  [contextFormName, formName, name]
886
744
  );
887
745
  const actualValidationFunction = React.useCallback(
888
746
  (currentValue, parameterFormName) => {
889
- var _a, _b;
890
- let result = (_b = (_a = initialValidationFunction == null ? void 0 : initialValidationFunction(currentValue, parameterFormName)) != null ? _a : validationFunction == null ? void 0 : validationFunction(currentValue, parameterFormName)) != null ? _b : true;
747
+ let result = initialValidationFunction?.(currentValue, parameterFormName) ?? validationFunction?.(currentValue, parameterFormName) ?? true;
891
748
  if (typeof result === "string")
892
749
  return result;
893
750
  if (customValidation) {
@@ -907,7 +764,10 @@ function useValidationClass({
907
764
  ]
908
765
  );
909
766
  const actualValidationRules = React.useMemo(() => {
910
- return __spreadValues$b(__spreadValues$b({}, validationRules), validationClass !== void 0 ? classToValidate(validationClass) : {});
767
+ return {
768
+ ...validationRules,
769
+ ...validationClass !== void 0 ? classToValidate(validationClass) : {}
770
+ };
911
771
  }, [validationClass, validationRules]);
912
772
  return {
913
773
  actualValidationFunction,
@@ -918,7 +778,7 @@ function useValidationClass({
918
778
  const ValidationError = ({ name }) => {
919
779
  const formContext = useFormContext();
920
780
  const error = useFieldSelector(formContext.name, name, (state) => {
921
- return state == null ? void 0 : state.error;
781
+ return state?.error;
922
782
  });
923
783
  return error ? /* @__PURE__ */ jsx(
924
784
  Box,
@@ -933,70 +793,28 @@ const ValidationError = ({ name }) => {
933
793
  ) : null;
934
794
  };
935
795
 
936
- var __defProp$a = Object.defineProperty;
937
- var __defProps$a = Object.defineProperties;
938
- var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
939
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
940
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
941
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
942
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
943
- var __spreadValues$a = (a, b) => {
944
- for (var prop in b || (b = {}))
945
- if (__hasOwnProp$b.call(b, prop))
946
- __defNormalProp$a(a, prop, b[prop]);
947
- if (__getOwnPropSymbols$b)
948
- for (var prop of __getOwnPropSymbols$b(b)) {
949
- if (__propIsEnum$b.call(b, prop))
950
- __defNormalProp$a(a, prop, b[prop]);
951
- }
952
- return a;
953
- };
954
- var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
955
- var __objRest$a = (source, exclude) => {
956
- var target = {};
957
- for (var prop in source)
958
- if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
959
- target[prop] = source[prop];
960
- if (source != null && __getOwnPropSymbols$b)
961
- for (var prop of __getOwnPropSymbols$b(source)) {
962
- if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
963
- target[prop] = source[prop];
964
- }
965
- return target;
966
- };
967
- const FieldWrapper = (_a) => {
968
- var _b = _a, {
969
- name,
970
- label,
971
- avoidSemicolon,
972
- children,
973
- className,
974
- as = "label",
975
- type
976
- } = _b, props = __objRest$a(_b, [
977
- "name",
978
- "label",
979
- "avoidSemicolon",
980
- "children",
981
- "className",
982
- "as",
983
- "type"
984
- ]);
796
+ const FieldWrapper = ({
797
+ name,
798
+ label,
799
+ avoidSemicolon,
800
+ children,
801
+ className,
802
+ as = "label",
803
+ type,
804
+ ...props
805
+ }) => {
985
806
  const { name: formName } = useFormContext();
986
807
  const isRequired = useFieldSelector(
987
808
  formName,
988
809
  name,
989
- (global) => {
990
- var _a2;
991
- return (_a2 = global == null ? void 0 : global.validationRules) == null ? void 0 : _a2.required;
992
- }
810
+ (global) => global?.validationRules?.required
993
811
  );
994
812
  if (type === "checkbox") {
995
813
  return /* @__PURE__ */ jsxs(
996
814
  Box,
997
- __spreadProps$a(__spreadValues$a({
998
- className: `fieldWrapper checkboxWrapper ${className != null ? className : ""}`
999
- }, props), {
815
+ {
816
+ className: `fieldWrapper checkboxWrapper ${className ?? ""}`,
817
+ ...props,
1000
818
  as,
1001
819
  children: [
1002
820
  window.SHOW_REQUIRED_POSITION !== "0" && label && /* @__PURE__ */ jsx(RequiredMark, { isRequired }),
@@ -1007,7 +825,7 @@ const FieldWrapper = (_a) => {
1007
825
  ] }),
1008
826
  /* @__PURE__ */ jsx(ValidationError, { name })
1009
827
  ]
1010
- })
828
+ }
1011
829
  );
1012
830
  }
1013
831
  if (!label) {
@@ -1016,8 +834,8 @@ const FieldWrapper = (_a) => {
1016
834
  /* @__PURE__ */ jsx(ValidationError, { name })
1017
835
  ] });
1018
836
  }
1019
- return /* @__PURE__ */ jsxs(Box, __spreadProps$a(__spreadValues$a({ className: `fieldWrapper ${className != null ? className : ""}` }, props), { as, children: [
1020
- /* @__PURE__ */ jsxs(Box, { as: "span", children: [
837
+ return /* @__PURE__ */ jsxs(Box, { className: `fieldWrapper ${className ?? ""}`, ...props, as, children: [
838
+ /* @__PURE__ */ jsxs(Box, { as: "span", className: "fieldWrapper__label", children: [
1021
839
  window.SHOW_REQUIRED_POSITION !== "0" && label && /* @__PURE__ */ jsx(RequiredMark, { isRequired }),
1022
840
  label,
1023
841
  !avoidSemicolon && label && /* @__PURE__ */ jsx("abbr", { className: "semicolon", children: ": " }),
@@ -1025,24 +843,9 @@ const FieldWrapper = (_a) => {
1025
843
  ] }),
1026
844
  children,
1027
845
  /* @__PURE__ */ jsx(ValidationError, { name })
1028
- ] }));
846
+ ] });
1029
847
  };
1030
848
 
1031
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
1032
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
1033
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
1034
- var __objRest$9 = (source, exclude) => {
1035
- var target = {};
1036
- for (var prop in source)
1037
- if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
1038
- target[prop] = source[prop];
1039
- if (source != null && __getOwnPropSymbols$a)
1040
- for (var prop of __getOwnPropSymbols$a(source)) {
1041
- if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
1042
- target[prop] = source[prop];
1043
- }
1044
- return target;
1045
- };
1046
849
  const InnerCaptcha = ({
1047
850
  className,
1048
851
  name,
@@ -1059,7 +862,7 @@ const InnerCaptcha = ({
1059
862
  submitValueParser,
1060
863
  validationValueParser
1061
864
  }) => {
1062
- const _a = useField({
865
+ const { error, updateValidations, onChange, isTouched, ...validationProps } = useField({
1063
866
  name,
1064
867
  avoidRegisterIfExists,
1065
868
  formName,
@@ -1069,7 +872,7 @@ const InnerCaptcha = ({
1069
872
  submitValueParser,
1070
873
  validationValueParser,
1071
874
  validationRules: { required: true }
1072
- }), { error, updateValidations, onChange, isTouched } = _a, validationProps = __objRest$9(_a, ["error", "updateValidations", "onChange", "isTouched"]);
875
+ });
1073
876
  const handleOnChange = React.useCallback(
1074
877
  (ev) => {
1075
878
  onChange(ev);
@@ -1082,7 +885,7 @@ const InnerCaptcha = ({
1082
885
  {
1083
886
  name,
1084
887
  label,
1085
- className: `input ${className != null ? className : ""}`,
888
+ className: `input ${className ?? ""}`,
1086
889
  avoidSemicolon,
1087
890
  children: /* @__PURE__ */ jsx(
1088
891
  Captcha,
@@ -1098,78 +901,29 @@ const InnerCaptcha = ({
1098
901
  );
1099
902
  };
1100
903
 
1101
- var __defProp$9 = Object.defineProperty;
1102
- var __defProps$9 = Object.defineProperties;
1103
- var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
1104
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1105
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1106
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1107
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1108
- var __spreadValues$9 = (a, b) => {
1109
- for (var prop in b || (b = {}))
1110
- if (__hasOwnProp$9.call(b, prop))
1111
- __defNormalProp$9(a, prop, b[prop]);
1112
- if (__getOwnPropSymbols$9)
1113
- for (var prop of __getOwnPropSymbols$9(b)) {
1114
- if (__propIsEnum$9.call(b, prop))
1115
- __defNormalProp$9(a, prop, b[prop]);
1116
- }
1117
- return a;
1118
- };
1119
- var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
1120
- var __objRest$8 = (source, exclude) => {
1121
- var target = {};
1122
- for (var prop in source)
1123
- if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
1124
- target[prop] = source[prop];
1125
- if (source != null && __getOwnPropSymbols$9)
1126
- for (var prop of __getOwnPropSymbols$9(source)) {
1127
- if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
1128
- target[prop] = source[prop];
1129
- }
1130
- return target;
1131
- };
1132
904
  const Checkbox = React.forwardRef(
1133
- (_a, ref) => {
1134
- var _b = _a, {
1135
- avoidSemicolon,
1136
- className,
1137
- label,
1138
- native,
1139
- onChange: outerOnChange,
1140
- type,
1141
- avoidRegisterIfExists: avoidRegisterIfExists,
1142
- formName,
1143
- initialValue,
1144
- name,
1145
- removeOnUnmount,
1146
- submitValueParser,
1147
- validationClass,
1148
- validationFunction,
1149
- validationRules,
1150
- value
1151
- } = _b, props = __objRest$8(_b, [
1152
- "avoidSemicolon",
1153
- "className",
1154
- "label",
1155
- "native",
1156
- "onChange",
1157
- "type",
1158
- /**
1159
- * useField
1160
- */
1161
- "avoidRegisterIfExists",
1162
- "formName",
1163
- "initialValue",
1164
- "name",
1165
- "removeOnUnmount",
1166
- "submitValueParser",
1167
- "validationClass",
1168
- "validationFunction",
1169
- "validationRules",
1170
- "value"
1171
- ]);
1172
- var _a2, _c;
905
+ ({
906
+ avoidSemicolon,
907
+ className,
908
+ label,
909
+ native,
910
+ onChange: outerOnChange,
911
+ type,
912
+ /**
913
+ * useField
914
+ */
915
+ avoidRegisterIfExists,
916
+ formName,
917
+ initialValue,
918
+ name,
919
+ removeOnUnmount,
920
+ submitValueParser,
921
+ validationClass,
922
+ validationFunction,
923
+ validationRules,
924
+ value,
925
+ ...props
926
+ }, ref) => {
1173
927
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1174
928
  formName,
1175
929
  name,
@@ -1177,38 +931,36 @@ const Checkbox = React.forwardRef(
1177
931
  validationFunction,
1178
932
  validationRules
1179
933
  });
1180
- const _b2 = useField({
934
+ const {
935
+ value: innerValue,
936
+ onChange,
937
+ updateValidations,
938
+ isTouched,
939
+ ...inputProps
940
+ } = useField({
1181
941
  avoidRegisterIfExists,
1182
942
  formName,
1183
943
  name,
1184
- initialValue: (_a2 = initialValue === true || initialValue === "on") != null ? _a2 : false,
944
+ initialValue: (initialValue === true || initialValue === "on") ?? false,
1185
945
  removeOnUnmount,
1186
946
  submitValueParser,
1187
947
  validationFunction: actualValidationFunction,
1188
948
  validationRules: actualValidationRules
1189
- }), {
1190
- value: innerValue,
1191
- onChange,
1192
- updateValidations,
1193
- isTouched
1194
- } = _b2, inputProps = __objRest$8(_b2, [
1195
- "value",
1196
- "onChange",
1197
- "updateValidations",
1198
- "isTouched"
1199
- ]);
949
+ });
1200
950
  return /* @__PURE__ */ jsx(
1201
951
  FieldWrapper,
1202
952
  {
1203
953
  name,
1204
954
  label,
1205
- className: `checkbox ${className != null ? className : ""}`,
955
+ className: `checkbox ${className ?? ""}`,
1206
956
  avoidSemicolon,
1207
957
  children: /* @__PURE__ */ jsx(
1208
958
  Checkbox$1,
1209
- __spreadProps$9(__spreadValues$9(__spreadValues$9({}, props), inputProps), {
959
+ {
960
+ ...props,
961
+ ...inputProps,
1210
962
  native,
1211
- "aria-label": (_c = props["aria-label"]) != null ? _c : label,
963
+ "aria-label": props["aria-label"] ?? label,
1212
964
  onChange: (ev) => {
1213
965
  onChange(ev.target.checked);
1214
966
  if (outerOnChange)
@@ -1216,7 +968,7 @@ const Checkbox = React.forwardRef(
1216
968
  },
1217
969
  checked: innerValue === true || innerValue === "on",
1218
970
  ref
1219
- })
971
+ }
1220
972
  )
1221
973
  }
1222
974
  );
@@ -1224,78 +976,30 @@ const Checkbox = React.forwardRef(
1224
976
  );
1225
977
  Checkbox.displayName = "Checkbox";
1226
978
 
1227
- var __defProp$8 = Object.defineProperty;
1228
- var __defProps$8 = Object.defineProperties;
1229
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
1230
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1231
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1232
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1233
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1234
- var __spreadValues$8 = (a, b) => {
1235
- for (var prop in b || (b = {}))
1236
- if (__hasOwnProp$8.call(b, prop))
1237
- __defNormalProp$8(a, prop, b[prop]);
1238
- if (__getOwnPropSymbols$8)
1239
- for (var prop of __getOwnPropSymbols$8(b)) {
1240
- if (__propIsEnum$8.call(b, prop))
1241
- __defNormalProp$8(a, prop, b[prop]);
1242
- }
1243
- return a;
1244
- };
1245
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
1246
- var __objRest$7 = (source, exclude) => {
1247
- var target = {};
1248
- for (var prop in source)
1249
- if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
1250
- target[prop] = source[prop];
1251
- if (source != null && __getOwnPropSymbols$8)
1252
- for (var prop of __getOwnPropSymbols$8(source)) {
1253
- if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
1254
- target[prop] = source[prop];
1255
- }
1256
- return target;
1257
- };
1258
979
  const DeletableInput = React.forwardRef(
1259
- (_a, ref) => {
1260
- var _b = _a, {
1261
- avoidSemicolon,
1262
- className,
1263
- label,
1264
- onChange: outerOnChange,
1265
- type,
1266
- avoidRegisterIfExists: avoidRegisterIfExists,
1267
- formName: propsFormName,
1268
- initialValue,
1269
- name,
1270
- removeOnUnmount,
1271
- submitValueParser,
1272
- validationClass,
1273
- validationFunction,
1274
- validationRules,
1275
- value
1276
- } = _b, props = __objRest$7(_b, [
1277
- "avoidSemicolon",
1278
- "className",
1279
- "label",
1280
- "onChange",
1281
- "type",
1282
- /**
1283
- * useField
1284
- */
1285
- "avoidRegisterIfExists",
1286
- "formName",
1287
- "initialValue",
1288
- "name",
1289
- "removeOnUnmount",
1290
- "submitValueParser",
1291
- "validationClass",
1292
- "validationFunction",
1293
- "validationRules",
1294
- "value"
1295
- ]);
1296
- var _a2, _b2, _c, _e, _f;
980
+ ({
981
+ avoidSemicolon,
982
+ className,
983
+ label,
984
+ onChange: outerOnChange,
985
+ type,
986
+ /**
987
+ * useField
988
+ */
989
+ avoidRegisterIfExists,
990
+ formName: propsFormName,
991
+ initialValue,
992
+ name,
993
+ removeOnUnmount,
994
+ submitValueParser,
995
+ validationClass,
996
+ validationFunction,
997
+ validationRules,
998
+ value,
999
+ ...props
1000
+ }, ref) => {
1297
1001
  const { name: contextFormName } = React.useContext(FormContext);
1298
- const formName = propsFormName != null ? propsFormName : contextFormName;
1002
+ const formName = propsFormName ?? contextFormName;
1299
1003
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1300
1004
  formName,
1301
1005
  name,
@@ -1303,29 +1007,25 @@ const DeletableInput = React.forwardRef(
1303
1007
  validationFunction,
1304
1008
  validationRules
1305
1009
  });
1306
- const _d = useField({
1010
+ const {
1011
+ error,
1012
+ updateValidations,
1013
+ onChange,
1014
+ isTouched,
1015
+ ...validationProps
1016
+ } = useField({
1307
1017
  formName,
1308
1018
  name,
1309
- initialValue: (_c = (_b2 = initialValue != null ? initialValue : value) != null ? _b2 : (_a2 = validationsStore.getFieldStore(formName, name)) == null ? void 0 : _a2.value) != null ? _c : "",
1019
+ initialValue: initialValue ?? value ?? validationsStore.getFieldStore(formName, name)?.value ?? "",
1310
1020
  removeOnUnmount,
1311
1021
  submitValueParser,
1312
1022
  validationFunction: actualValidationFunction,
1313
1023
  validationRules: actualValidationRules
1314
- }), {
1315
- error,
1316
- updateValidations,
1317
- onChange,
1318
- isTouched
1319
- } = _d, validationProps = __objRest$7(_d, [
1320
- "error",
1321
- "updateValidations",
1322
- "onChange",
1323
- "isTouched"
1324
- ]);
1024
+ });
1325
1025
  const handleOnChange = React.useCallback(
1326
1026
  (ev) => {
1327
1027
  onChange(ev);
1328
- outerOnChange == null ? void 0 : outerOnChange(ev);
1028
+ outerOnChange?.(ev);
1329
1029
  },
1330
1030
  [onChange, outerOnChange]
1331
1031
  );
@@ -1343,20 +1043,21 @@ const DeletableInput = React.forwardRef(
1343
1043
  }),
1344
1044
  []
1345
1045
  ),
1346
- className: `deletableInput ${className != null ? className : ""}`,
1046
+ className: `deletableInput ${className ?? ""}`,
1347
1047
  avoidSemicolon,
1348
1048
  children: [
1349
1049
  /* @__PURE__ */ jsx(
1350
1050
  Input$1,
1351
- __spreadProps$8(__spreadValues$8(__spreadValues$8({
1352
- type
1353
- }, props), validationProps), {
1354
- "aria-label": (_e = props["aria-label"]) != null ? _e : label,
1051
+ {
1052
+ type,
1053
+ ...props,
1054
+ ...validationProps,
1055
+ "aria-label": props["aria-label"] ?? label,
1355
1056
  ref,
1356
1057
  onChange: handleOnChange,
1357
- value: (_f = validationProps.value) != null ? _f : "",
1358
- className: `deletableInput__input ${stateClassName != null ? stateClassName : ""}`
1359
- })
1058
+ value: validationProps.value ?? "",
1059
+ className: `deletableInput__input ${stateClassName ?? ""}`
1060
+ }
1360
1061
  ),
1361
1062
  /* @__PURE__ */ jsx(
1362
1063
  IconButton,
@@ -1373,71 +1074,26 @@ const DeletableInput = React.forwardRef(
1373
1074
  );
1374
1075
  DeletableInput.displayName = "DeletableInput";
1375
1076
 
1376
- var __defProp$7 = Object.defineProperty;
1377
- var __defProps$7 = Object.defineProperties;
1378
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
1379
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1380
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1381
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1382
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1383
- var __spreadValues$7 = (a, b) => {
1384
- for (var prop in b || (b = {}))
1385
- if (__hasOwnProp$7.call(b, prop))
1386
- __defNormalProp$7(a, prop, b[prop]);
1387
- if (__getOwnPropSymbols$7)
1388
- for (var prop of __getOwnPropSymbols$7(b)) {
1389
- if (__propIsEnum$7.call(b, prop))
1390
- __defNormalProp$7(a, prop, b[prop]);
1391
- }
1392
- return a;
1393
- };
1394
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
1395
- var __objRest$6 = (source, exclude) => {
1396
- var target = {};
1397
- for (var prop in source)
1398
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
1399
- target[prop] = source[prop];
1400
- if (source != null && __getOwnPropSymbols$7)
1401
- for (var prop of __getOwnPropSymbols$7(source)) {
1402
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
1403
- target[prop] = source[prop];
1404
- }
1405
- return target;
1406
- };
1407
1077
  const FileInput = React.memo(
1408
1078
  React.forwardRef(
1409
- (_a, ref) => {
1410
- var _b = _a, {
1411
- avoidSemicolon,
1412
- className,
1413
- label,
1414
- avoidRegisterIfExists: avoidRegisterIfExists,
1415
- formName: propsFormName,
1416
- initialValue,
1417
- name,
1418
- removeOnUnmount,
1419
- submitValueParser,
1420
- validationClass,
1421
- validationFunction,
1422
- validationRules
1423
- } = _b, props = __objRest$6(_b, [
1424
- "avoidSemicolon",
1425
- "className",
1426
- "label",
1427
- /**
1428
- * useField
1429
- */
1430
- "avoidRegisterIfExists",
1431
- "formName",
1432
- "initialValue",
1433
- "name",
1434
- "removeOnUnmount",
1435
- "submitValueParser",
1436
- "validationClass",
1437
- "validationFunction",
1438
- "validationRules"
1439
- ]);
1440
- var _b2;
1079
+ ({
1080
+ avoidSemicolon,
1081
+ className,
1082
+ label,
1083
+ /**
1084
+ * useField
1085
+ */
1086
+ avoidRegisterIfExists,
1087
+ formName: propsFormName,
1088
+ initialValue,
1089
+ name,
1090
+ removeOnUnmount,
1091
+ submitValueParser,
1092
+ validationClass,
1093
+ validationFunction,
1094
+ validationRules,
1095
+ ...props
1096
+ }, ref) => {
1441
1097
  const { name: formName } = useFormContext();
1442
1098
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1443
1099
  formName,
@@ -1449,48 +1105,44 @@ const FileInput = React.memo(
1449
1105
  validationFunction,
1450
1106
  validationRules
1451
1107
  });
1452
- const _a2 = useField({
1108
+ const {
1109
+ error,
1110
+ onChange,
1111
+ value,
1112
+ updateValidations,
1113
+ isTouched,
1114
+ ...validationProps
1115
+ } = useField({
1453
1116
  formName,
1454
1117
  name,
1455
1118
  removeOnUnmount,
1456
1119
  submitValueParser,
1457
1120
  validationFunction: actualValidationFunction,
1458
1121
  validationRules: actualValidationRules
1459
- }), {
1460
- error,
1461
- onChange,
1462
- value,
1463
- updateValidations,
1464
- isTouched
1465
- } = _a2, validationProps = __objRest$6(_a2, [
1466
- "error",
1467
- "onChange",
1468
- "value",
1469
- "updateValidations",
1470
- "isTouched"
1471
- ]);
1122
+ });
1472
1123
  return /* @__PURE__ */ jsx(
1473
1124
  FieldWrapper,
1474
1125
  {
1475
1126
  name,
1476
1127
  label,
1477
- className: `input ${className != null ? className : ""}`,
1128
+ className: `input ${className ?? ""}`,
1478
1129
  avoidSemicolon,
1479
1130
  children: /* @__PURE__ */ jsx(
1480
1131
  Input$1,
1481
- __spreadProps$7(__spreadValues$7(__spreadValues$7({}, props), validationProps), {
1132
+ {
1133
+ ...props,
1134
+ ...validationProps,
1482
1135
  type: "file",
1483
- "aria-label": (_b2 = props["aria-label"]) != null ? _b2 : label,
1136
+ "aria-label": props["aria-label"] ?? label,
1484
1137
  ref,
1485
1138
  sx: getFieldErrorStyles(!error),
1486
1139
  onChange: React.useCallback(
1487
1140
  (ev) => {
1488
- var _a3, _b3, _c;
1489
- onChange((_c = (_b3 = (_a3 = ev.target) == null ? void 0 : _a3.files) == null ? void 0 : _b3[0]) != null ? _c : null);
1141
+ onChange(ev.target?.files?.[0] ?? null);
1490
1142
  },
1491
1143
  [onChange]
1492
1144
  )
1493
- })
1145
+ }
1494
1146
  )
1495
1147
  }
1496
1148
  );
@@ -1499,79 +1151,31 @@ const FileInput = React.memo(
1499
1151
  );
1500
1152
  FileInput.displayName = "FileInput";
1501
1153
 
1502
- var __defProp$6 = Object.defineProperty;
1503
- var __defProps$6 = Object.defineProperties;
1504
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
1505
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1506
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1507
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1508
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1509
- var __spreadValues$6 = (a, b) => {
1510
- for (var prop in b || (b = {}))
1511
- if (__hasOwnProp$6.call(b, prop))
1512
- __defNormalProp$6(a, prop, b[prop]);
1513
- if (__getOwnPropSymbols$6)
1514
- for (var prop of __getOwnPropSymbols$6(b)) {
1515
- if (__propIsEnum$6.call(b, prop))
1516
- __defNormalProp$6(a, prop, b[prop]);
1517
- }
1518
- return a;
1519
- };
1520
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
1521
- var __objRest$5 = (source, exclude) => {
1522
- var target = {};
1523
- for (var prop in source)
1524
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1525
- target[prop] = source[prop];
1526
- if (source != null && __getOwnPropSymbols$6)
1527
- for (var prop of __getOwnPropSymbols$6(source)) {
1528
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1529
- target[prop] = source[prop];
1530
- }
1531
- return target;
1532
- };
1533
1154
  const Input = React.memo(
1534
1155
  React.forwardRef(
1535
- (_a, ref) => {
1536
- var _b = _a, {
1537
- avoidSemicolon,
1538
- className,
1539
- label,
1540
- onChange: outerOnChange,
1541
- type,
1542
- avoidRegisterIfExists: avoidRegisterIfExists,
1543
- formName: propsFormName,
1544
- initialValue,
1545
- name,
1546
- removeOnUnmount,
1547
- submitValueParser,
1548
- validationClass,
1549
- validationFunction,
1550
- validationRules,
1551
- value
1552
- } = _b, props = __objRest$5(_b, [
1553
- "avoidSemicolon",
1554
- "className",
1555
- "label",
1556
- "onChange",
1557
- "type",
1558
- /**
1559
- * useField
1560
- */
1561
- "avoidRegisterIfExists",
1562
- "formName",
1563
- "initialValue",
1564
- "name",
1565
- "removeOnUnmount",
1566
- "submitValueParser",
1567
- "validationClass",
1568
- "validationFunction",
1569
- "validationRules",
1570
- "value"
1571
- ]);
1572
- var _a2, _b2, _c, _e, _f, _g, _h;
1156
+ ({
1157
+ avoidSemicolon,
1158
+ className,
1159
+ label,
1160
+ onChange: outerOnChange,
1161
+ type,
1162
+ /**
1163
+ * useField
1164
+ */
1165
+ avoidRegisterIfExists,
1166
+ formName: propsFormName,
1167
+ initialValue,
1168
+ name,
1169
+ removeOnUnmount,
1170
+ submitValueParser,
1171
+ validationClass,
1172
+ validationFunction,
1173
+ validationRules,
1174
+ value,
1175
+ ...props
1176
+ }, ref) => {
1573
1177
  const { name: contextFormName } = React.useContext(FormContext);
1574
- const formName = propsFormName != null ? propsFormName : contextFormName;
1178
+ const formName = propsFormName ?? contextFormName;
1575
1179
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1576
1180
  formName,
1577
1181
  name,
@@ -1579,34 +1183,30 @@ const Input = React.memo(
1579
1183
  validationFunction,
1580
1184
  validationRules
1581
1185
  });
1582
- const _d = useField({
1186
+ const {
1187
+ error,
1188
+ updateValidations,
1189
+ onChange,
1190
+ isTouched,
1191
+ ...validationProps
1192
+ } = useField({
1583
1193
  formName,
1584
1194
  name,
1585
- initialValue: (_c = (_b2 = initialValue != null ? initialValue : value) != null ? _b2 : (_a2 = validationsStore.getFieldStore(formName, name)) == null ? void 0 : _a2.value) != null ? _c : "",
1195
+ initialValue: initialValue ?? value ?? validationsStore.getFieldStore(formName, name)?.value ?? "",
1586
1196
  removeOnUnmount,
1587
1197
  submitValueParser,
1588
1198
  validationFunction: actualValidationFunction,
1589
1199
  validationRules: actualValidationRules
1590
- }), {
1591
- error,
1592
- updateValidations,
1593
- onChange,
1594
- isTouched
1595
- } = _d, validationProps = __objRest$5(_d, [
1596
- "error",
1597
- "updateValidations",
1598
- "onChange",
1599
- "isTouched"
1600
- ]);
1200
+ });
1601
1201
  const handleOnChange = React.useCallback(
1602
1202
  (ev) => {
1603
1203
  onChange(ev);
1604
1204
  if (typeof ev === "string") {
1605
- outerOnChange == null ? void 0 : outerOnChange({
1205
+ outerOnChange?.({
1606
1206
  target: ref
1607
1207
  });
1608
1208
  } else {
1609
- outerOnChange == null ? void 0 : outerOnChange(ev);
1209
+ outerOnChange?.(ev);
1610
1210
  }
1611
1211
  },
1612
1212
  [onChange, outerOnChange, ref]
@@ -1617,29 +1217,32 @@ const Input = React.memo(
1617
1217
  {
1618
1218
  name,
1619
1219
  label,
1620
- className: `input ${className != null ? className : ""}`,
1220
+ className: `input ${className ?? ""}`,
1621
1221
  avoidSemicolon,
1622
1222
  children: type === "date" ? /* @__PURE__ */ jsx(
1623
1223
  DateInput,
1624
- __spreadProps$6(__spreadValues$6(__spreadValues$6({}, props), validationProps), {
1625
- "aria-label": (_e = props["aria-label"]) != null ? _e : label,
1224
+ {
1225
+ ...props,
1226
+ ...validationProps,
1227
+ "aria-label": props["aria-label"] ?? label,
1626
1228
  onError: void 0,
1627
1229
  ref,
1628
1230
  onChange: handleOnChange,
1629
- value: (_f = validationProps.value) != null ? _f : "",
1231
+ value: validationProps.value ?? "",
1630
1232
  className: stateClassName
1631
- })
1233
+ }
1632
1234
  ) : /* @__PURE__ */ jsx(
1633
1235
  Input$1,
1634
- __spreadProps$6(__spreadValues$6(__spreadValues$6({
1635
- type
1636
- }, props), validationProps), {
1637
- "aria-label": (_g = props["aria-label"]) != null ? _g : label,
1236
+ {
1237
+ type,
1238
+ ...props,
1239
+ ...validationProps,
1240
+ "aria-label": props["aria-label"] ?? label,
1638
1241
  ref,
1639
1242
  onChange: handleOnChange,
1640
- value: (_h = validationProps.value) != null ? _h : "",
1243
+ value: validationProps.value ?? "",
1641
1244
  className: stateClassName
1642
- })
1245
+ }
1643
1246
  )
1644
1247
  }
1645
1248
  );
@@ -1648,77 +1251,30 @@ const Input = React.memo(
1648
1251
  );
1649
1252
  Input.displayName = "Input";
1650
1253
 
1651
- var __defProp$5 = Object.defineProperty;
1652
- var __defProps$5 = Object.defineProperties;
1653
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
1654
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1655
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1656
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1657
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1658
- var __spreadValues$5 = (a, b) => {
1659
- for (var prop in b || (b = {}))
1660
- if (__hasOwnProp$5.call(b, prop))
1661
- __defNormalProp$5(a, prop, b[prop]);
1662
- if (__getOwnPropSymbols$5)
1663
- for (var prop of __getOwnPropSymbols$5(b)) {
1664
- if (__propIsEnum$5.call(b, prop))
1665
- __defNormalProp$5(a, prop, b[prop]);
1666
- }
1667
- return a;
1668
- };
1669
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1670
- var __objRest$4 = (source, exclude) => {
1671
- var target = {};
1672
- for (var prop in source)
1673
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1674
- target[prop] = source[prop];
1675
- if (source != null && __getOwnPropSymbols$5)
1676
- for (var prop of __getOwnPropSymbols$5(source)) {
1677
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1678
- target[prop] = source[prop];
1679
- }
1680
- return target;
1681
- };
1682
1254
  const NumberInputf = React.memo(
1683
1255
  React.forwardRef(
1684
- (_a, ref) => {
1685
- var _b = _a, {
1686
- avoidSemicolon,
1687
- className,
1688
- label,
1689
- onChange: outerOnChange,
1690
- avoidRegisterIfExists: avoidRegisterIfExists,
1691
- formName: propsFormName,
1692
- initialValue,
1693
- name,
1694
- removeOnUnmount,
1695
- submitValueParser,
1696
- validationClass,
1697
- validationFunction,
1698
- validationRules,
1699
- value
1700
- } = _b, props = __objRest$4(_b, [
1701
- "avoidSemicolon",
1702
- "className",
1703
- "label",
1704
- "onChange",
1705
- /**
1706
- * useField
1707
- */
1708
- "avoidRegisterIfExists",
1709
- "formName",
1710
- "initialValue",
1711
- "name",
1712
- "removeOnUnmount",
1713
- "submitValueParser",
1714
- "validationClass",
1715
- "validationFunction",
1716
- "validationRules",
1717
- "value"
1718
- ]);
1719
- var _a2, _b2, _c;
1256
+ ({
1257
+ avoidSemicolon,
1258
+ className,
1259
+ label,
1260
+ onChange: outerOnChange,
1261
+ /**
1262
+ * useField
1263
+ */
1264
+ avoidRegisterIfExists,
1265
+ formName: propsFormName,
1266
+ initialValue,
1267
+ name,
1268
+ removeOnUnmount,
1269
+ submitValueParser,
1270
+ validationClass,
1271
+ validationFunction,
1272
+ validationRules,
1273
+ value,
1274
+ ...props
1275
+ }, ref) => {
1720
1276
  const { name: contextFormName } = React.useContext(FormContext);
1721
- const formName = propsFormName != null ? propsFormName : contextFormName;
1277
+ const formName = propsFormName ?? contextFormName;
1722
1278
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1723
1279
  formName,
1724
1280
  name,
@@ -1729,14 +1285,14 @@ const NumberInputf = React.memo(
1729
1285
  const { onChange, value: innerValue } = useField({
1730
1286
  formName,
1731
1287
  name,
1732
- initialValue: (_c = (_b2 = initialValue != null ? initialValue : value) != null ? _b2 : (_a2 = validationsStore.getFieldStore(formName, name)) == null ? void 0 : _a2.value) != null ? _c : "",
1288
+ initialValue: initialValue ?? value ?? validationsStore.getFieldStore(formName, name)?.value ?? "",
1733
1289
  removeOnUnmount,
1734
1290
  submitValueParser: React.useCallback(
1735
- (current) => parseNumberInputValueToNumber(current != null ? current : ""),
1291
+ (current) => parseNumberInputValueToNumber(current ?? ""),
1736
1292
  []
1737
1293
  ),
1738
1294
  validationValueParser: React.useCallback(
1739
- (current) => parseNumberInputValueToNumber(current != null ? current : ""),
1295
+ (current) => parseNumberInputValueToNumber(current ?? ""),
1740
1296
  []
1741
1297
  ),
1742
1298
  validationFunction: actualValidationFunction,
@@ -1745,7 +1301,7 @@ const NumberInputf = React.memo(
1745
1301
  const handleOnChange = React.useCallback(
1746
1302
  (ev) => {
1747
1303
  if (ev.error) {
1748
- outerOnChange == null ? void 0 : outerOnChange(__spreadProps$5(__spreadValues$5({}, ev), { value: "" }));
1304
+ outerOnChange?.({ ...ev, value: "" });
1749
1305
  onChange("");
1750
1306
  validationsStore.updateField(formName, {
1751
1307
  name,
@@ -1753,7 +1309,7 @@ const NumberInputf = React.memo(
1753
1309
  });
1754
1310
  } else {
1755
1311
  onChange(ev.value);
1756
- outerOnChange == null ? void 0 : outerOnChange(ev);
1312
+ outerOnChange?.(ev);
1757
1313
  validationsStore.updateField(formName, { name, error: null });
1758
1314
  }
1759
1315
  },
@@ -1773,18 +1329,18 @@ const NumberInputf = React.memo(
1773
1329
  }),
1774
1330
  []
1775
1331
  ),
1776
- className: `input ${className != null ? className : ""}`,
1332
+ className: `input ${className ?? ""}`,
1777
1333
  avoidSemicolon,
1778
1334
  children: /* @__PURE__ */ jsx(
1779
1335
  NumberInput,
1780
- __spreadProps$5(__spreadValues$5({
1781
- ref
1782
- }, props), {
1336
+ {
1337
+ ref,
1338
+ ...props,
1783
1339
  name,
1784
1340
  value: innerValue,
1785
1341
  onChange: handleOnChange,
1786
1342
  className: stateClassName
1787
- })
1343
+ }
1788
1344
  )
1789
1345
  }
1790
1346
  );
@@ -1793,75 +1349,28 @@ const NumberInputf = React.memo(
1793
1349
  );
1794
1350
  NumberInputf.displayName = "NumberInputf";
1795
1351
 
1796
- var __defProp$4 = Object.defineProperty;
1797
- var __defProps$4 = Object.defineProperties;
1798
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1799
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1800
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1801
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1802
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1803
- var __spreadValues$4 = (a, b) => {
1804
- for (var prop in b || (b = {}))
1805
- if (__hasOwnProp$4.call(b, prop))
1806
- __defNormalProp$4(a, prop, b[prop]);
1807
- if (__getOwnPropSymbols$4)
1808
- for (var prop of __getOwnPropSymbols$4(b)) {
1809
- if (__propIsEnum$4.call(b, prop))
1810
- __defNormalProp$4(a, prop, b[prop]);
1811
- }
1812
- return a;
1813
- };
1814
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1815
- var __objRest$3 = (source, exclude) => {
1816
- var target = {};
1817
- for (var prop in source)
1818
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1819
- target[prop] = source[prop];
1820
- if (source != null && __getOwnPropSymbols$4)
1821
- for (var prop of __getOwnPropSymbols$4(source)) {
1822
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1823
- target[prop] = source[prop];
1824
- }
1825
- return target;
1826
- };
1827
1352
  const Radio = React.forwardRef(
1828
- (_a, ref) => {
1829
- var _b = _a, {
1830
- avoidSemicolon,
1831
- className,
1832
- formName,
1833
- label,
1834
- onChange: outerOnChange,
1835
- options,
1836
- value: outerValue,
1837
- avoidRegisterIfExists: avoidRegisterIfExists,
1838
- initialValue,
1839
- name,
1840
- removeOnUnmount,
1841
- submitValueParser,
1842
- validationClass,
1843
- validationFunction,
1844
- validationRules
1845
- } = _b, props = __objRest$3(_b, [
1846
- "avoidSemicolon",
1847
- "className",
1848
- "formName",
1849
- "label",
1850
- "onChange",
1851
- "options",
1852
- "value",
1853
- /**
1854
- * useField
1855
- */
1856
- "avoidRegisterIfExists",
1857
- "initialValue",
1858
- "name",
1859
- "removeOnUnmount",
1860
- "submitValueParser",
1861
- "validationClass",
1862
- "validationFunction",
1863
- "validationRules"
1864
- ]);
1353
+ ({
1354
+ avoidSemicolon,
1355
+ className,
1356
+ formName,
1357
+ label,
1358
+ onChange: outerOnChange,
1359
+ options,
1360
+ value: outerValue,
1361
+ /**
1362
+ * useField
1363
+ */
1364
+ avoidRegisterIfExists,
1365
+ initialValue,
1366
+ name,
1367
+ removeOnUnmount,
1368
+ submitValueParser,
1369
+ validationClass,
1370
+ validationFunction,
1371
+ validationRules,
1372
+ ...props
1373
+ }, ref) => {
1865
1374
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1866
1375
  formName,
1867
1376
  name,
@@ -1869,15 +1378,15 @@ const Radio = React.forwardRef(
1869
1378
  validationFunction,
1870
1379
  validationRules
1871
1380
  });
1872
- const _a2 = useField({
1381
+ const { value, updateValidations, onChange, isTouched, ...inputProps } = useField({
1873
1382
  formName,
1874
1383
  name,
1875
- initialValue: initialValue != null ? initialValue : outerValue,
1384
+ initialValue: initialValue ?? outerValue,
1876
1385
  removeOnUnmount,
1877
1386
  submitValueParser,
1878
1387
  validationFunction: actualValidationFunction,
1879
1388
  validationRules: actualValidationRules
1880
- }), { value, updateValidations, onChange, isTouched } = _a2, inputProps = __objRest$3(_a2, ["value", "updateValidations", "onChange", "isTouched"]);
1389
+ });
1881
1390
  const handleOnChange = React.useCallback(
1882
1391
  (ev) => {
1883
1392
  onChange(ev);
@@ -1892,13 +1401,15 @@ const Radio = React.forwardRef(
1892
1401
  {
1893
1402
  name,
1894
1403
  label,
1895
- className: `radio ${className != null ? className : ""}`,
1404
+ className: `radio ${className ?? ""}`,
1896
1405
  avoidSemicolon,
1897
1406
  as: "ul",
1898
- children: options == null ? void 0 : options.map((option) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Label, { title: option.label, className: "radio-label", children: [
1407
+ children: options?.map((option) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(Label, { title: option.label, className: "radio-label", children: [
1899
1408
  /* @__PURE__ */ jsx(
1900
1409
  Radio$1,
1901
- __spreadProps$4(__spreadValues$4(__spreadValues$4({}, props), inputProps), {
1410
+ {
1411
+ ...props,
1412
+ ...inputProps,
1902
1413
  role: "radio",
1903
1414
  className: "radio-button",
1904
1415
  "aria-label": option.label,
@@ -1906,7 +1417,7 @@ const Radio = React.forwardRef(
1906
1417
  value: option.value,
1907
1418
  checked: value === option.value,
1908
1419
  onChange: handleOnChange
1909
- })
1420
+ }
1910
1421
  ),
1911
1422
  /* @__PURE__ */ jsx(Box, { as: "span", className: "radio-text", children: option.label })
1912
1423
  ] }) }, option.value))
@@ -1916,76 +1427,28 @@ const Radio = React.forwardRef(
1916
1427
  );
1917
1428
  Radio.displayName = "Radio";
1918
1429
 
1919
- var __defProp$3 = Object.defineProperty;
1920
- var __defProps$3 = Object.defineProperties;
1921
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1922
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1923
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1924
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1925
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1926
- var __spreadValues$3 = (a, b) => {
1927
- for (var prop in b || (b = {}))
1928
- if (__hasOwnProp$3.call(b, prop))
1929
- __defNormalProp$3(a, prop, b[prop]);
1930
- if (__getOwnPropSymbols$3)
1931
- for (var prop of __getOwnPropSymbols$3(b)) {
1932
- if (__propIsEnum$3.call(b, prop))
1933
- __defNormalProp$3(a, prop, b[prop]);
1934
- }
1935
- return a;
1936
- };
1937
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1938
- var __objRest$2 = (source, exclude) => {
1939
- var target = {};
1940
- for (var prop in source)
1941
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
1942
- target[prop] = source[prop];
1943
- if (source != null && __getOwnPropSymbols$3)
1944
- for (var prop of __getOwnPropSymbols$3(source)) {
1945
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
1946
- target[prop] = source[prop];
1947
- }
1948
- return target;
1949
- };
1950
1430
  const Select = React.forwardRef(
1951
- (_a, ref) => {
1952
- var _b = _a, {
1953
- avoidSemicolon,
1954
- className,
1955
- formName,
1956
- label,
1957
- onChange: outerOnChange,
1958
- options,
1959
- avoidRegisterIfExists: avoidRegisterIfExists,
1960
- initialValue,
1961
- name,
1962
- removeOnUnmount,
1963
- submitValueParser,
1964
- validationClass,
1965
- validationFunction,
1966
- validationRules,
1967
- value
1968
- } = _b, props = __objRest$2(_b, [
1969
- "avoidSemicolon",
1970
- "className",
1971
- "formName",
1972
- "label",
1973
- "onChange",
1974
- "options",
1975
- /**
1976
- * useField
1977
- */
1978
- "avoidRegisterIfExists",
1979
- "initialValue",
1980
- "name",
1981
- "removeOnUnmount",
1982
- "submitValueParser",
1983
- "validationClass",
1984
- "validationFunction",
1985
- "validationRules",
1986
- "value"
1987
- ]);
1988
- var _a2, _b2, _d, _e;
1431
+ ({
1432
+ avoidSemicolon,
1433
+ className,
1434
+ formName,
1435
+ label,
1436
+ onChange: outerOnChange,
1437
+ options,
1438
+ /**
1439
+ * useField
1440
+ */
1441
+ avoidRegisterIfExists,
1442
+ initialValue,
1443
+ name,
1444
+ removeOnUnmount,
1445
+ submitValueParser,
1446
+ validationClass,
1447
+ validationFunction,
1448
+ validationRules,
1449
+ value,
1450
+ ...props
1451
+ }, ref) => {
1989
1452
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
1990
1453
  formName,
1991
1454
  name,
@@ -1993,25 +1456,28 @@ const Select = React.forwardRef(
1993
1456
  validationFunction,
1994
1457
  validationRules
1995
1458
  });
1996
- const _c = useField({
1459
+ const { updateValidations, onChange, isTouched, ...inputProps } = useField({
1997
1460
  avoidRegisterIfExists,
1998
- initialValue: (_b2 = initialValue != null ? initialValue : value) != null ? _b2 : (_a2 = options[0]) == null ? void 0 : _a2.value,
1461
+ initialValue: initialValue ?? value ?? options[0]?.value,
1999
1462
  name,
2000
1463
  removeOnUnmount,
2001
1464
  submitValueParser,
2002
1465
  validationFunction: actualValidationFunction,
2003
1466
  validationRules: actualValidationRules
2004
- }), { updateValidations, onChange, isTouched } = _c, inputProps = __objRest$2(_c, ["updateValidations", "onChange", "isTouched"]);
1467
+ });
2005
1468
  return /* @__PURE__ */ jsx(
2006
1469
  FieldWrapper,
2007
1470
  {
2008
1471
  name,
2009
1472
  label,
2010
- className: `select ${className != null ? className : ""}`,
1473
+ className: `select ${className ?? ""}`,
2011
1474
  avoidSemicolon,
2012
1475
  children: /* @__PURE__ */ jsxs(
2013
1476
  Select$1,
2014
- __spreadProps$3(__spreadValues$3(__spreadValues$3(__spreadValues$3({}, getVariant("forms.select")), props), inputProps), {
1477
+ {
1478
+ ...getVariant("forms.select"),
1479
+ ...props,
1480
+ ...inputProps,
2015
1481
  onChange: React.useCallback(
2016
1482
  (ev) => {
2017
1483
  onChange(ev);
@@ -2021,14 +1487,14 @@ const Select = React.forwardRef(
2021
1487
  },
2022
1488
  [onChange, outerOnChange]
2023
1489
  ),
2024
- "aria-label": (_d = props["aria-label"]) != null ? _d : label,
1490
+ "aria-label": props["aria-label"] ?? label,
2025
1491
  ref,
2026
- value: (_e = inputProps.value) != null ? _e : "",
1492
+ value: inputProps.value ?? "",
2027
1493
  children: [
2028
- options == null ? void 0 : options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
1494
+ options?.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)),
2029
1495
  props.children
2030
1496
  ]
2031
- })
1497
+ }
2032
1498
  )
2033
1499
  }
2034
1500
  );
@@ -2036,75 +1502,26 @@ const Select = React.forwardRef(
2036
1502
  );
2037
1503
  Select.displayName = "Select";
2038
1504
 
2039
- var __defProp$2 = Object.defineProperty;
2040
- var __defProps$2 = Object.defineProperties;
2041
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2042
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
2043
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
2044
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
2045
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2046
- var __spreadValues$2 = (a, b) => {
2047
- for (var prop in b || (b = {}))
2048
- if (__hasOwnProp$2.call(b, prop))
2049
- __defNormalProp$2(a, prop, b[prop]);
2050
- if (__getOwnPropSymbols$2)
2051
- for (var prop of __getOwnPropSymbols$2(b)) {
2052
- if (__propIsEnum$2.call(b, prop))
2053
- __defNormalProp$2(a, prop, b[prop]);
2054
- }
2055
- return a;
2056
- };
2057
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2058
- var __objRest$1 = (source, exclude) => {
2059
- var target = {};
2060
- for (var prop in source)
2061
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
2062
- target[prop] = source[prop];
2063
- if (source != null && __getOwnPropSymbols$2)
2064
- for (var prop of __getOwnPropSymbols$2(source)) {
2065
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
2066
- target[prop] = source[prop];
2067
- }
2068
- return target;
2069
- };
2070
1505
  const Switchbox = React.forwardRef(
2071
- (_a, ref) => {
2072
- var _b = _a, {
2073
- avoidSemicolon,
2074
- className,
2075
- label,
2076
- onChange: outerOnChange,
2077
- type,
2078
- reverse = false,
2079
- avoidRegisterIfExists,
2080
- formName,
2081
- initialValue,
2082
- name,
2083
- removeOnUnmount,
2084
- submitValueParser,
2085
- validationClass,
2086
- validationFunction,
2087
- validationRules,
2088
- value
2089
- } = _b, props = __objRest$1(_b, [
2090
- "avoidSemicolon",
2091
- "className",
2092
- "label",
2093
- "onChange",
2094
- "type",
2095
- "reverse",
2096
- "avoidRegisterIfExists",
2097
- "formName",
2098
- "initialValue",
2099
- "name",
2100
- "removeOnUnmount",
2101
- "submitValueParser",
2102
- "validationClass",
2103
- "validationFunction",
2104
- "validationRules",
2105
- "value"
2106
- ]);
2107
- var _b2, _c;
1506
+ ({
1507
+ avoidSemicolon,
1508
+ className,
1509
+ label,
1510
+ onChange: outerOnChange,
1511
+ type,
1512
+ reverse = false,
1513
+ avoidRegisterIfExists,
1514
+ formName,
1515
+ initialValue,
1516
+ name,
1517
+ removeOnUnmount,
1518
+ submitValueParser,
1519
+ validationClass,
1520
+ validationFunction,
1521
+ validationRules,
1522
+ value,
1523
+ ...props
1524
+ }, ref) => {
2108
1525
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
2109
1526
  formName,
2110
1527
  name,
@@ -2112,36 +1529,38 @@ const Switchbox = React.forwardRef(
2112
1529
  validationFunction,
2113
1530
  validationRules
2114
1531
  });
2115
- const _a2 = useField({
1532
+ const { onChange, updateValidations, isTouched, ...inputProps } = useField({
2116
1533
  avoidRegisterIfExists,
2117
1534
  formName,
2118
1535
  name,
2119
- initialValue: (initialValue != null ? initialValue : "off") === "on" || toBoolean(initialValue) ? "on" : "off",
1536
+ initialValue: (initialValue ?? "off") === "on" || toBoolean(initialValue) ? "on" : "off",
2120
1537
  removeOnUnmount,
2121
1538
  submitValueParser,
2122
1539
  validationFunction: actualValidationFunction,
2123
1540
  validationRules: actualValidationRules
2124
- }), { onChange, updateValidations, isTouched } = _a2, inputProps = __objRest$1(_a2, ["onChange", "updateValidations", "isTouched"]);
1541
+ });
2125
1542
  return /* @__PURE__ */ jsx(
2126
1543
  FieldWrapper,
2127
1544
  {
2128
1545
  name,
2129
1546
  label,
2130
- className: `switchbox ${className != null ? className : ""}`,
1547
+ className: `switchbox ${className ?? ""}`,
2131
1548
  avoidSemicolon,
2132
1549
  children: /* @__PURE__ */ jsx(
2133
1550
  Switch,
2134
- __spreadProps$2(__spreadValues$2(__spreadValues$2({}, props), inputProps), {
2135
- "aria-label": (_b2 = props["aria-label"]) != null ? _b2 : label,
1551
+ {
1552
+ ...props,
1553
+ ...inputProps,
1554
+ "aria-label": props["aria-label"] ?? label,
2136
1555
  onChange: (ev) => {
2137
1556
  onChange(ev.target.checked !== reverse ? "on" : "off");
2138
1557
  if (outerOnChange) {
2139
1558
  outerOnChange(ev);
2140
1559
  }
2141
1560
  },
2142
- checked: ((_c = inputProps.value) != null ? _c : "off") === "on" !== reverse,
1561
+ checked: (inputProps.value ?? "off") === "on" !== reverse,
2143
1562
  ref
2144
- })
1563
+ }
2145
1564
  )
2146
1565
  }
2147
1566
  );
@@ -2149,74 +1568,27 @@ const Switchbox = React.forwardRef(
2149
1568
  );
2150
1569
  Switchbox.displayName = "Switchbox";
2151
1570
 
2152
- var __defProp$1 = Object.defineProperty;
2153
- var __defProps$1 = Object.defineProperties;
2154
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
2155
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
2156
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
2157
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
2158
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2159
- var __spreadValues$1 = (a, b) => {
2160
- for (var prop in b || (b = {}))
2161
- if (__hasOwnProp$1.call(b, prop))
2162
- __defNormalProp$1(a, prop, b[prop]);
2163
- if (__getOwnPropSymbols$1)
2164
- for (var prop of __getOwnPropSymbols$1(b)) {
2165
- if (__propIsEnum$1.call(b, prop))
2166
- __defNormalProp$1(a, prop, b[prop]);
2167
- }
2168
- return a;
2169
- };
2170
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2171
- var __objRest = (source, exclude) => {
2172
- var target = {};
2173
- for (var prop in source)
2174
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
2175
- target[prop] = source[prop];
2176
- if (source != null && __getOwnPropSymbols$1)
2177
- for (var prop of __getOwnPropSymbols$1(source)) {
2178
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
2179
- target[prop] = source[prop];
2180
- }
2181
- return target;
2182
- };
2183
1571
  const Textarea = React.forwardRef(
2184
- (_a, ref) => {
2185
- var _b = _a, {
2186
- avoidSemicolon,
2187
- className,
2188
- formName,
2189
- label,
2190
- onChange: outerOnChange,
2191
- avoidRegisterIfExists: avoidRegisterIfExists,
2192
- initialValue,
2193
- name,
2194
- removeOnUnmount,
2195
- submitValueParser,
2196
- validationClass,
2197
- validationFunction,
2198
- validationRules,
2199
- value
2200
- } = _b, props = __objRest(_b, [
2201
- "avoidSemicolon",
2202
- "className",
2203
- "formName",
2204
- "label",
2205
- "onChange",
2206
- /**
2207
- * useField
2208
- */
2209
- "avoidRegisterIfExists",
2210
- "initialValue",
2211
- "name",
2212
- "removeOnUnmount",
2213
- "submitValueParser",
2214
- "validationClass",
2215
- "validationFunction",
2216
- "validationRules",
2217
- "value"
2218
- ]);
2219
- var _b2, _c;
1572
+ ({
1573
+ avoidSemicolon,
1574
+ className,
1575
+ formName,
1576
+ label,
1577
+ onChange: outerOnChange,
1578
+ /**
1579
+ * useField
1580
+ */
1581
+ avoidRegisterIfExists,
1582
+ initialValue,
1583
+ name,
1584
+ removeOnUnmount,
1585
+ submitValueParser,
1586
+ validationClass,
1587
+ validationFunction,
1588
+ validationRules,
1589
+ value,
1590
+ ...props
1591
+ }, ref) => {
2220
1592
  const { actualValidationFunction, actualValidationRules } = useValidationClass({
2221
1593
  formName,
2222
1594
  name,
@@ -2224,16 +1596,16 @@ const Textarea = React.forwardRef(
2224
1596
  validationFunction,
2225
1597
  validationRules
2226
1598
  });
2227
- const _a2 = useField({
1599
+ const { updateValidations, onChange, isTouched, ...inputProps } = useField({
2228
1600
  avoidRegisterIfExists,
2229
1601
  formName,
2230
- initialValue: initialValue != null ? initialValue : value,
1602
+ initialValue: initialValue ?? value,
2231
1603
  name,
2232
1604
  removeOnUnmount,
2233
1605
  submitValueParser,
2234
1606
  validationRules: actualValidationRules,
2235
1607
  validationFunction: actualValidationFunction
2236
- }), { updateValidations, onChange, isTouched } = _a2, inputProps = __objRest(_a2, ["updateValidations", "onChange", "isTouched"]);
1608
+ });
2237
1609
  const handleOnChange = React.useCallback(
2238
1610
  (ev) => {
2239
1611
  onChange(ev);
@@ -2248,16 +1620,18 @@ const Textarea = React.forwardRef(
2248
1620
  {
2249
1621
  name,
2250
1622
  label,
2251
- className: `textarea ${className != null ? className : ""}`,
1623
+ className: `textarea ${className ?? ""}`,
2252
1624
  avoidSemicolon,
2253
1625
  children: /* @__PURE__ */ jsx(
2254
1626
  Textarea$1,
2255
- __spreadProps$1(__spreadValues$1(__spreadValues$1({}, props), inputProps), {
2256
- "aria-label": (_b2 = props["aria-label"]) != null ? _b2 : label,
1627
+ {
1628
+ ...props,
1629
+ ...inputProps,
1630
+ "aria-label": props["aria-label"] ?? label,
2257
1631
  ref,
2258
- value: (_c = inputProps.value) != null ? _c : "",
1632
+ value: inputProps.value ?? "",
2259
1633
  onChange: handleOnChange
2260
- })
1634
+ }
2261
1635
  )
2262
1636
  }
2263
1637
  );
@@ -2265,104 +1639,197 @@ const Textarea = React.forwardRef(
2265
1639
  );
2266
1640
  Textarea.displayName = "Textarea";
2267
1641
 
2268
- var __defProp = Object.defineProperty;
2269
- var __defProps = Object.defineProperties;
2270
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2271
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2272
- var __hasOwnProp = Object.prototype.hasOwnProperty;
2273
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
2274
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2275
- var __spreadValues = (a, b) => {
2276
- for (var prop in b || (b = {}))
2277
- if (__hasOwnProp.call(b, prop))
2278
- __defNormalProp(a, prop, b[prop]);
2279
- if (__getOwnPropSymbols)
2280
- for (var prop of __getOwnPropSymbols(b)) {
2281
- if (__propIsEnum.call(b, prop))
2282
- __defNormalProp(a, prop, b[prop]);
2283
- }
2284
- return a;
1642
+ var __defProp$8 = Object.defineProperty;
1643
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1644
+ var __publicField$8 = (obj, key, value) => {
1645
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
1646
+ return value;
2285
1647
  };
2286
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2287
- var __accessCheck = (obj, member, msg) => {
1648
+ var __accessCheck$3 = (obj, member, msg) => {
2288
1649
  if (!member.has(obj))
2289
1650
  throw TypeError("Cannot " + msg);
2290
1651
  };
2291
- var __privateGet = (obj, member, getter) => {
2292
- __accessCheck(obj, member, "read from private field");
1652
+ var __privateGet$3 = (obj, member, getter) => {
1653
+ __accessCheck$3(obj, member, "read from private field");
2293
1654
  return getter ? getter.call(obj) : member.get(obj);
2294
1655
  };
2295
- var __privateAdd = (obj, member, value) => {
1656
+ var __privateAdd$3 = (obj, member, value) => {
2296
1657
  if (member.has(obj))
2297
1658
  throw TypeError("Cannot add the same private member more than once");
2298
1659
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2299
1660
  };
2300
- var __privateSet = (obj, member, value, setter) => {
2301
- __accessCheck(obj, member, "write to private field");
2302
- setter ? setter.call(obj, value) : member.set(obj, value);
2303
- return value;
2304
- };
2305
- var _rules, _validationFunction, _fields;
2306
- try {
2307
- void initValidations().catch(() => {
2308
- });
2309
- } catch (e) {
2310
- }
1661
+ var _emitter;
2311
1662
  class CollectorField extends EventEmitter {
2312
- constructor(_name, label) {
1663
+ constructor(_name, label, properties) {
2313
1664
  super();
2314
1665
  this._name = _name;
2315
1666
  this.label = label;
1667
+ __privateAdd$3(this, _emitter, new StatefulEmitter({
1668
+ isHidden: false
1669
+ }));
1670
+ __publicField$8(this, "collector", {});
1671
+ __publicField$8(this, "isHidden", () => __privateGet$3(this, _emitter).getState("isHidden"));
1672
+ __publicField$8(this, "setIsHidden", (isHidden) => {
1673
+ __privateGet$3(this, _emitter).emit("isHidden", isHidden);
1674
+ });
1675
+ __publicField$8(this, "properties", {});
1676
+ __publicField$8(this, "setProperties", (newProps) => {
1677
+ this.properties = newProps;
1678
+ this.emit("propsUpdate", { ...this.properties });
1679
+ });
1680
+ __publicField$8(this, "useProperties", () => {
1681
+ return useSubscription({
1682
+ getInitialState: () => this.properties,
1683
+ makeSubscription: (setProps) => this.on("propsUpdate", setProps)
1684
+ });
1685
+ });
1686
+ /**
1687
+ * Este componente se utiliza para controlar propiedades comunes a todos los
1688
+ * campos.
1689
+ */
1690
+ __publicField$8(this, "SuperComponent", () => {
1691
+ if (__privateGet$3(this, _emitter).useState("isHidden"))
1692
+ return null;
1693
+ return /* @__PURE__ */ jsx(Box, { className: `collector__field ${this.type}`, children: /* @__PURE__ */ jsx(this.Component, {}) });
1694
+ });
1695
+ if (properties) {
1696
+ this.properties = properties;
1697
+ }
2316
1698
  }
2317
1699
  get name() {
2318
1700
  return this._name;
2319
1701
  }
1702
+ set name(name) {
1703
+ this._name = name;
1704
+ }
2320
1705
  }
1706
+ _emitter = new WeakMap();
1707
+
1708
+ var __defProp$7 = Object.defineProperty;
1709
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1710
+ var __publicField$7 = (obj, key, value) => {
1711
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
1712
+ return value;
1713
+ };
1714
+ var __accessCheck$2 = (obj, member, msg) => {
1715
+ if (!member.has(obj))
1716
+ throw TypeError("Cannot " + msg);
1717
+ };
1718
+ var __privateGet$2 = (obj, member, getter) => {
1719
+ __accessCheck$2(obj, member, "read from private field");
1720
+ return getter ? getter.call(obj) : member.get(obj);
1721
+ };
1722
+ var __privateAdd$2 = (obj, member, value) => {
1723
+ if (member.has(obj))
1724
+ throw TypeError("Cannot add the same private member more than once");
1725
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1726
+ };
1727
+ var __privateSet$1 = (obj, member, value, setter) => {
1728
+ __accessCheck$2(obj, member, "write to private field");
1729
+ setter ? setter.call(obj, value) : member.set(obj, value);
1730
+ return value;
1731
+ };
1732
+ var _rules, _validationFunction;
2321
1733
  class ValidatedCollectorField extends CollectorField {
2322
- constructor() {
2323
- super(...arguments);
2324
- this.initialValue = void 0;
2325
- __privateAdd(this, _rules, {});
2326
- __privateAdd(this, _validationFunction, () => true);
2327
- this.setInitialValue = (newValue) => {
1734
+ constructor(_name, label, config) {
1735
+ super(_name, label, config?.properties);
1736
+ this._name = _name;
1737
+ this.label = label;
1738
+ __publicField$7(this, "initialValue");
1739
+ __privateAdd$2(this, _rules, {});
1740
+ __privateAdd$2(this, _validationFunction, () => true);
1741
+ __publicField$7(this, "setInitialValue", (newValue) => {
2328
1742
  this.initialValue = newValue;
2329
- };
2330
- this.setValidationFunction = (newFunction) => {
2331
- __privateSet(this, _validationFunction, newFunction);
2332
- this.emit("functionUpdate", __privateGet(this, _validationFunction));
2333
- };
2334
- this.setValidationRules = (newRules) => {
2335
- __privateSet(this, _rules, newRules);
2336
- this.emit("rulesUpdate", __spreadValues({}, __privateGet(this, _rules)));
2337
- };
2338
- this.useValidationFunction = () => {
2339
- const [validationFunction, setValidationFunction] = useState(() => __privateGet(this, _validationFunction));
2340
- useMount(() => {
2341
- return this.on("functionUpdate", setValidationFunction);
1743
+ });
1744
+ __publicField$7(this, "setValidationFunction", (newFunction) => {
1745
+ __privateSet$1(this, _validationFunction, newFunction);
1746
+ this.emit("functionUpdate", __privateGet$2(this, _validationFunction));
1747
+ });
1748
+ __publicField$7(this, "setValidationRules", (newRules) => {
1749
+ __privateSet$1(this, _rules, newRules);
1750
+ this.emit("rulesUpdate", { ...__privateGet$2(this, _rules) });
1751
+ });
1752
+ __publicField$7(this, "setValue", (newValue) => {
1753
+ validationsStore.setFieldValue(this.collector.id, this.name, newValue);
1754
+ });
1755
+ __publicField$7(this, "useValidationFunction", () => {
1756
+ return useSubscription({
1757
+ getInitialState: () => () => __privateGet$2(this, _validationFunction),
1758
+ makeSubscription: (setValidationFunction) => {
1759
+ return this.on("functionUpdate", setValidationFunction);
1760
+ }
2342
1761
  });
2343
- return validationFunction;
2344
- };
2345
- this.useValidationRules = () => {
2346
- const [validationRules, setValidationRules] = useState(__privateGet(this, _rules));
2347
- useMount(() => {
2348
- return this.on("rulesUpdate", setValidationRules);
1762
+ });
1763
+ __publicField$7(this, "useValidationRules", () => {
1764
+ return useSubscription({
1765
+ getInitialState: () => __privateGet$2(this, _rules),
1766
+ makeSubscription: (setValidationRules) => {
1767
+ return this.on("rulesUpdate", setValidationRules);
1768
+ }
2349
1769
  });
2350
- return validationRules;
2351
- };
1770
+ });
1771
+ if (config?.initialValue) {
1772
+ this.initialValue = config.initialValue;
1773
+ }
1774
+ if (config?.validationFunction) {
1775
+ __privateSet$1(this, _validationFunction, config.validationFunction);
1776
+ }
1777
+ if (config?.validationRules) {
1778
+ __privateSet$1(this, _rules, config.validationRules);
1779
+ }
2352
1780
  }
2353
1781
  }
2354
1782
  _rules = new WeakMap();
2355
1783
  _validationFunction = new WeakMap();
1784
+
1785
+ var __defProp$6 = Object.defineProperty;
1786
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1787
+ var __publicField$6 = (obj, key, value) => {
1788
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1789
+ return value;
1790
+ };
1791
+ class CollectorCheckbox extends ValidatedCollectorField {
1792
+ constructor() {
1793
+ super(...arguments);
1794
+ __publicField$6(this, "type", "checkbox");
1795
+ __publicField$6(this, "Component", () => {
1796
+ const rules = this.useValidationRules();
1797
+ const validationFunction = this.useValidationFunction();
1798
+ const props = this.useProperties();
1799
+ return /* @__PURE__ */ jsx(
1800
+ Checkbox,
1801
+ {
1802
+ ...props,
1803
+ initialValue: this.initialValue,
1804
+ validationFunction,
1805
+ name: this.name,
1806
+ label: this.label,
1807
+ validationRules: rules,
1808
+ avoidSemicolon: true
1809
+ }
1810
+ );
1811
+ });
1812
+ }
1813
+ }
1814
+
1815
+ var __defProp$5 = Object.defineProperty;
1816
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1817
+ var __publicField$5 = (obj, key, value) => {
1818
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
1819
+ return value;
1820
+ };
2356
1821
  class CollectorInput extends ValidatedCollectorField {
2357
1822
  constructor() {
2358
1823
  super(...arguments);
2359
- this.type = "input";
2360
- this.Component = () => {
1824
+ __publicField$5(this, "type", "input");
1825
+ __publicField$5(this, "Component", () => {
2361
1826
  const rules = this.useValidationRules();
2362
1827
  const validationFunction = this.useValidationFunction();
1828
+ const props = this.useProperties();
2363
1829
  return /* @__PURE__ */ jsx(
2364
1830
  Input,
2365
1831
  {
1832
+ ...props,
2366
1833
  initialValue: this.initialValue,
2367
1834
  validationFunction,
2368
1835
  name: this.name,
@@ -2370,31 +1837,101 @@ class CollectorInput extends ValidatedCollectorField {
2370
1837
  validationRules: rules
2371
1838
  }
2372
1839
  );
2373
- };
1840
+ });
2374
1841
  }
2375
1842
  }
2376
- const _CollectorLabel = class extends CollectorField {
2377
- constructor(label, kind = "label") {
2378
- super(`label${_CollectorLabel.maxId++}`, label);
2379
- this.kind = kind;
2380
- this.type = "label";
2381
- this.Component = () => {
2382
- return /* @__PURE__ */ jsx(Box, { as: this.kind, children: this.label });
2383
- };
1843
+
1844
+ var __defProp$4 = Object.defineProperty;
1845
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1846
+ var __publicField$4 = (obj, key, value) => {
1847
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1848
+ return value;
1849
+ };
1850
+ var __accessCheck$1 = (obj, member, msg) => {
1851
+ if (!member.has(obj))
1852
+ throw TypeError("Cannot " + msg);
1853
+ };
1854
+ var __privateGet$1 = (obj, member, getter) => {
1855
+ __accessCheck$1(obj, member, "read from private field");
1856
+ return getter ? getter.call(obj) : member.get(obj);
1857
+ };
1858
+ var __privateAdd$1 = (obj, member, value) => {
1859
+ if (member.has(obj))
1860
+ throw TypeError("Cannot add the same private member more than once");
1861
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1862
+ };
1863
+ var __privateSet = (obj, member, value, setter) => {
1864
+ __accessCheck$1(obj, member, "write to private field");
1865
+ setter ? setter.call(obj, value) : member.set(obj, value);
1866
+ return value;
1867
+ };
1868
+ var _options, _useOptions;
1869
+ class CollectorSelect extends ValidatedCollectorField {
1870
+ constructor(_name, label, config) {
1871
+ super(_name, label, config);
1872
+ this._name = _name;
1873
+ this.label = label;
1874
+ __publicField$4(this, "type", "select");
1875
+ __privateAdd$1(this, _options, []);
1876
+ __publicField$4(this, "addOption", (newOption) => {
1877
+ __privateSet(this, _options, [...__privateGet$1(this, _options), newOption]);
1878
+ this.emit("optionsUpdate", __privateGet$1(this, _options));
1879
+ });
1880
+ __publicField$4(this, "setOptions", (newOptions) => {
1881
+ __privateSet(this, _options, [...newOptions]);
1882
+ this.emit("optionsUpdate", __privateGet$1(this, _options));
1883
+ });
1884
+ __privateAdd$1(this, _useOptions, () => {
1885
+ const [options, setOptions] = useState(__privateGet$1(this, _options));
1886
+ useMount(() => {
1887
+ return this.on("optionsUpdate", setOptions);
1888
+ });
1889
+ return options;
1890
+ });
1891
+ __publicField$4(this, "Component", () => {
1892
+ const rules = this.useValidationRules();
1893
+ const validationFunction = this.useValidationFunction();
1894
+ const options = __privateGet$1(this, _useOptions).call(this);
1895
+ const props = this.useProperties();
1896
+ return /* @__PURE__ */ jsx(
1897
+ Select,
1898
+ {
1899
+ ...props,
1900
+ initialValue: this.initialValue,
1901
+ validationFunction,
1902
+ name: this.name,
1903
+ label: this.label,
1904
+ validationRules: rules,
1905
+ options
1906
+ }
1907
+ );
1908
+ });
1909
+ if (config?.options) {
1910
+ __privateSet(this, _options, config.options);
1911
+ }
2384
1912
  }
1913
+ }
1914
+ _options = new WeakMap();
1915
+ _useOptions = new WeakMap();
1916
+
1917
+ var __defProp$3 = Object.defineProperty;
1918
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1919
+ var __publicField$3 = (obj, key, value) => {
1920
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1921
+ return value;
2385
1922
  };
2386
- let CollectorLabel = _CollectorLabel;
2387
- CollectorLabel.maxId = 0;
2388
1923
  class CollectorTextarea extends ValidatedCollectorField {
2389
1924
  constructor() {
2390
1925
  super(...arguments);
2391
- this.type = "textarea";
2392
- this.Component = () => {
1926
+ __publicField$3(this, "type", "textarea");
1927
+ __publicField$3(this, "Component", () => {
2393
1928
  const rules = this.useValidationRules();
2394
1929
  const validationFunction = this.useValidationFunction();
1930
+ const props = this.useProperties();
2395
1931
  return /* @__PURE__ */ jsx(
2396
1932
  Textarea,
2397
1933
  {
1934
+ ...props,
2398
1935
  initialValue: this.initialValue,
2399
1936
  name: this.name,
2400
1937
  validationFunction,
@@ -2402,59 +1939,162 @@ class CollectorTextarea extends ValidatedCollectorField {
2402
1939
  label: this.label
2403
1940
  }
2404
1941
  );
2405
- };
1942
+ });
2406
1943
  }
2407
1944
  }
1945
+
1946
+ var __defProp$2 = Object.defineProperty;
1947
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1948
+ var __publicField$2 = (obj, key, value) => {
1949
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1950
+ return value;
1951
+ };
1952
+ const _CollectorLabel = class _CollectorLabel extends CollectorField {
1953
+ constructor(label, kind = "label") {
1954
+ super(`label${_CollectorLabel.maxId++}`, label);
1955
+ this.kind = kind;
1956
+ __publicField$2(this, "type", "label");
1957
+ __publicField$2(this, "Component", () => {
1958
+ if (this.kind === "label")
1959
+ return /* @__PURE__ */ jsx(Box, { as: this.kind, children: /* @__PURE__ */ jsx("span", { children: this.label }) });
1960
+ return /* @__PURE__ */ jsx(Box, { as: this.kind, children: this.label });
1961
+ });
1962
+ }
1963
+ };
1964
+ __publicField$2(_CollectorLabel, "maxId", 0);
1965
+ let CollectorLabel = _CollectorLabel;
1966
+
1967
+ var __defProp$1 = Object.defineProperty;
1968
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1969
+ var __publicField$1 = (obj, key, value) => {
1970
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1971
+ return value;
1972
+ };
1973
+ let i = 0;
1974
+ class CollectorButton extends CollectorField {
1975
+ constructor(label, properties) {
1976
+ super(`Button${i++}`, label, properties);
1977
+ this.label = label;
1978
+ __publicField$1(this, "type", "button");
1979
+ __publicField$1(this, "Component", () => {
1980
+ const props = this.useProperties();
1981
+ return /* @__PURE__ */ jsx(SimpleButton, { ...props, children: this.label });
1982
+ });
1983
+ }
1984
+ }
1985
+
1986
+ var __defProp = Object.defineProperty;
1987
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1988
+ var __publicField = (obj, key, value) => {
1989
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1990
+ return value;
1991
+ };
1992
+ var __accessCheck = (obj, member, msg) => {
1993
+ if (!member.has(obj))
1994
+ throw TypeError("Cannot " + msg);
1995
+ };
1996
+ var __privateGet = (obj, member, getter) => {
1997
+ __accessCheck(obj, member, "read from private field");
1998
+ return getter ? getter.call(obj) : member.get(obj);
1999
+ };
2000
+ var __privateAdd = (obj, member, value) => {
2001
+ if (member.has(obj))
2002
+ throw TypeError("Cannot add the same private member more than once");
2003
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2004
+ };
2005
+ var _fields, _Component;
2006
+ try {
2007
+ void initValidations().catch(() => {
2008
+ });
2009
+ } catch (e) {
2010
+ console.error(e);
2011
+ }
2408
2012
  let maxId = 0;
2409
2013
  class Collector {
2410
2014
  constructor() {
2411
- this.fields = {
2015
+ __publicField(this, "fields", {
2016
+ button: CollectorButton,
2017
+ checkbox: CollectorCheckbox,
2412
2018
  input: CollectorInput,
2019
+ /**
2020
+ * Muestra una etiqueta con tag personalizable: h1...h6, p, label. (Por
2021
+ * defecto: label)
2022
+ */
2413
2023
  label: CollectorLabel,
2024
+ select: CollectorSelect,
2414
2025
  textarea: CollectorTextarea
2415
- };
2416
- this.id = `Collector${maxId++}`;
2026
+ });
2027
+ __publicField(this, "private__id", `Collector${maxId++}`);
2417
2028
  __privateAdd(this, _fields, {});
2418
- this.add = (field) => {
2029
+ __publicField(this, "add", (field) => {
2419
2030
  __privateGet(this, _fields)[field.name] = field;
2420
- };
2421
- this.show = (modalProps) => {
2031
+ field.collector = this;
2032
+ });
2033
+ __publicField(this, "forEach", (cb) => {
2034
+ Object.values(__privateGet(this, _fields)).forEach(cb);
2035
+ });
2036
+ __privateAdd(this, _Component, ({
2037
+ hideConfirm,
2038
+ resolve
2039
+ }) => {
2040
+ const modal = useModalContext();
2041
+ let hasValidated = false;
2042
+ return /* @__PURE__ */ jsx(Box, { ...getVariant("layout.util.collector.formContainer"), children: /* @__PURE__ */ jsxs(
2043
+ Form,
2044
+ {
2045
+ name: this.private__id,
2046
+ onValidate: (result) => {
2047
+ if (hasSucceedFormValidation(result)) {
2048
+ resolve(result.submitValues);
2049
+ modal.close();
2050
+ }
2051
+ },
2052
+ children: [
2053
+ Object.values(__privateGet(this, _fields)).map((current) => {
2054
+ if (current instanceof ValidatedCollectorField)
2055
+ hasValidated = true;
2056
+ return /* @__PURE__ */ jsx(current.SuperComponent, {}, current.name);
2057
+ }),
2058
+ hasValidated && !hideConfirm && /* @__PURE__ */ jsx(Box, { className: "collector__buttons", children: /* @__PURE__ */ jsx(Button, { variant: "outline", children: getLabel("btnCon").text }) })
2059
+ ]
2060
+ }
2061
+ ) });
2062
+ });
2063
+ __publicField(this, "show", (modalProps) => {
2422
2064
  return new Promise((resolve) => {
2423
- const modal = new ApiaUtil().modals.open(__spreadValues({
2424
- children: /* @__PURE__ */ jsx(Box, __spreadProps(__spreadValues({}, getVariant("layout.util.collector.formContainer")), { children: /* @__PURE__ */ jsxs(
2425
- Form,
2065
+ const C = __privateGet(this, _Component);
2066
+ ApiaUtil.instance.modals.open({
2067
+ onExited() {
2426
2068
  {
2427
- name: this.id,
2428
- onValidate: (result) => {
2429
- if (hasSucceedFormValidation(result)) {
2430
- resolve(result.submitValues);
2431
- modal.close();
2432
- }
2433
- },
2434
- children: [
2435
- Object.values(__privateGet(this, _fields)).map((current) => /* @__PURE__ */ jsx(
2436
- Box,
2437
- {
2438
- className: `collector__field ${current.type}`,
2439
- children: /* @__PURE__ */ jsx(current.Component, {})
2440
- },
2441
- current.name
2442
- )),
2443
- /* @__PURE__ */ jsx(Box, { className: "collector__buttons", children: /* @__PURE__ */ jsx(Button, { variant: "outline", children: getLabel("btnCon").text }) })
2444
- ]
2069
+ resolve(null);
2445
2070
  }
2446
- ) })),
2071
+ },
2072
+ children: /* @__PURE__ */ jsx(
2073
+ C,
2074
+ {
2075
+ hideConfirm: modalProps?.hideConfirm,
2076
+ resolve: (values) => {
2077
+ resolve(values);
2078
+ }
2079
+ }
2080
+ ),
2447
2081
  variant: "layout.util.collector.modal",
2448
2082
  initialFocusGetter(modalInnerRef) {
2449
2083
  return modalInnerRef.querySelector(
2450
2084
  "input,textarea,select,button:not(.modal__closeButton)"
2451
2085
  );
2452
- }
2453
- }, modalProps));
2086
+ },
2087
+ ...modalProps
2088
+ });
2454
2089
  });
2455
- };
2090
+ });
2091
+ }
2092
+ get id() {
2093
+ return this.private__id;
2456
2094
  }
2457
2095
  }
2458
2096
  _fields = new WeakMap();
2097
+ _Component = new WeakMap();
2459
2098
 
2460
2099
  export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorField, DeletableInput, FieldWrapper, FileInput, Form, FormContext, Input, NumberInputf, Radio, Select, Switchbox, Textarea, ValidatedCollectorField, ValidationError, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidationClass, validationsStore };
2100
+ //# sourceMappingURL=index.js.map