@apia/validations 4.0.60 → 4.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +22 -3
- package/dist/index.js +176 -102
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { FC, ChangeEvent, ReactNode } from 'react';
|
|
3
3
|
import { TModify, TPropsSelector, TPropsComparator, TPropsConfiguration, TId, EventEmitter, TLabel } from '@apia/util';
|
|
4
|
-
import { TNumberInput, ApiaUtilModalHandler, TOpenModal, TFieldLabel } from '@apia/components';
|
|
4
|
+
import { TNumberInput, SwitchMultipleOption, ApiaUtilModalHandler, TOpenModal, TFieldLabel } from '@apia/components';
|
|
5
5
|
import { BoxProps, ButtonProps, InputProps, RadioProps, SelectProps, SwitchProps, TextareaProps } from '@apia/theme';
|
|
6
6
|
import { TModalContext } from '@apia/components/src/components/modals/ModalContext';
|
|
7
7
|
|
|
@@ -620,7 +620,7 @@ declare abstract class ValidatedCollectorField<ValueType = any, FieldProps = any
|
|
|
620
620
|
}>);
|
|
621
621
|
set collector(c: Collector);
|
|
622
622
|
get initialValue(): ValueType | undefined;
|
|
623
|
-
get value():
|
|
623
|
+
get value(): ValueType;
|
|
624
624
|
setInitialValue: (newValue: ValueType) => void;
|
|
625
625
|
setValidationFunction: (newFunction: TValidationFunction<ValueType>) => void;
|
|
626
626
|
setValidationRules: (newRules: TValidationRules) => void;
|
|
@@ -718,6 +718,23 @@ declare class CollectorAutogrowTextarea extends ValidatedCollectorField<string,
|
|
|
718
718
|
Component: () => React.JSX.Element;
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
+
type SwitchInputProps<T extends string> = {
|
|
722
|
+
name: string;
|
|
723
|
+
label?: string;
|
|
724
|
+
title?: string;
|
|
725
|
+
options: SwitchMultipleOption<T>[];
|
|
726
|
+
formName?: string;
|
|
727
|
+
initialValue?: T;
|
|
728
|
+
removeOnUnmount?: boolean;
|
|
729
|
+
validationFunction?: any;
|
|
730
|
+
validationRules?: any;
|
|
731
|
+
onChange?: (ev: T) => void;
|
|
732
|
+
};
|
|
733
|
+
declare class CollectorSwitchMultiple<T extends string = string> extends ValidatedCollectorField<T, Omit<InputProps, 'name' | 'onChange'> & SwitchInputProps<T>> {
|
|
734
|
+
type: string;
|
|
735
|
+
Component: () => React.JSX.Element;
|
|
736
|
+
}
|
|
737
|
+
|
|
721
738
|
declare class Collector {
|
|
722
739
|
#private;
|
|
723
740
|
fields: {
|
|
@@ -735,6 +752,7 @@ declare class Collector {
|
|
|
735
752
|
switch: typeof CollectorSwitch;
|
|
736
753
|
textarea: typeof CollectorTextarea;
|
|
737
754
|
title: typeof CollectorTitle;
|
|
755
|
+
switchMultiple: typeof CollectorSwitchMultiple;
|
|
738
756
|
};
|
|
739
757
|
private private__id;
|
|
740
758
|
get id(): string;
|
|
@@ -742,6 +760,7 @@ declare class Collector {
|
|
|
742
760
|
protected fieldsStore: Record<string, CollectorField>;
|
|
743
761
|
add(...fields: CollectorField[]): this;
|
|
744
762
|
forEach(cb: (field: CollectorField, i: number) => void): void;
|
|
763
|
+
getByName<T extends CollectorField = CollectorField>(name: string): T;
|
|
745
764
|
readonly Render: ({ hideConfirm, modal, resolve, className, }: {
|
|
746
765
|
className?: string;
|
|
747
766
|
hideConfirm?: boolean;
|
|
@@ -954,5 +973,5 @@ declare abstract class Validable<T extends object> {
|
|
|
954
973
|
validate(): Promise<true | Record<string, string>>;
|
|
955
974
|
}
|
|
956
975
|
|
|
957
|
-
export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorField, DeletableInput, FieldWrapper, FileInput, Form, FormContext, type IWrapper, Input, NumberInputf, Radio, Select, Switchbox, type TCheckbox, type TCheckboxProps, type TDefaultFieldType, type TInput$1 as TInput, type TObjectInspection, type TOnValidate, type TOption, type TRadio, type TSelect, type TSelectProps, type TSwitchbox, type TUseField, type TValidationFunction, type TValidationResult, type TValidationRules, Textarea, Validable, ValidableCheck, ValidableContext, ValidableField, ValidableInput, ValidableSelect, ValidableTextarea, ValidatedCollectorField, ValidationError, type ValidationRules, type ValidationsMap, WithMemoryCollector, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidableContext, useValidationClass, validate, validationsStore };
|
|
976
|
+
export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorAutogrowTextarea, CollectorButton, CollectorCheckbox, CollectorField, CollectorInput, CollectorLabel, CollectorSelect, CollectorSeparator, CollectorSwitch, CollectorSwitchMultiple, CollectorTextarea, CollectorTitle, DeletableInput, FieldWrapper, FileInput, Form, FormContext, type IWrapper, Input, NumberInputf, Radio, Select, Switchbox, type TCheckbox, type TCheckboxProps, type TDefaultFieldType, type TInput$1 as TInput, type TObjectInspection, type TOnValidate, type TOption, type TRadio, type TSelect, type TSelectProps, type TSwitchbox, type TUseField, type TValidationFunction, type TValidationResult, type TValidationRules, Textarea, Validable, ValidableCheck, ValidableContext, ValidableField, ValidableInput, ValidableSelect, ValidableTextarea, ValidatedCollectorField, ValidationError, type ValidationRules, type ValidationsMap, WithMemoryCollector, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidableContext, useValidationClass, validate, validationsStore };
|
|
958
977
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import uniqueId from 'lodash-es/uniqueId';
|
|
|
4
4
|
import React, { useRef, useState, createContext, useContext } from 'react';
|
|
5
5
|
import { 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
6
|
import { notify } from '@apia/notifications';
|
|
7
|
-
import { RequiredMark, Captcha, Checkbox as Checkbox$1, IconButton, getFieldErrorStyles, DateInput, ApiaUtil, NumberInput, SimpleButton, AutogrowTextarea as AutogrowTextarea$1, useModalContext, FieldLabel } from '@apia/components';
|
|
7
|
+
import { RequiredMark, Captcha, Checkbox as Checkbox$1, IconButton, getFieldErrorStyles, DateInput, ApiaUtil, NumberInput, SimpleButton, AutogrowTextarea as AutogrowTextarea$1, SwitchMultiple, useModalContext, FieldLabel } from '@apia/components';
|
|
8
8
|
import { shallowEqual } from 'react-redux';
|
|
9
|
-
import { makeObservable, observable } from 'mobx';
|
|
10
9
|
import { observer } from 'mobx-react-lite';
|
|
10
|
+
import { makeObservable, observable } from 'mobx';
|
|
11
11
|
|
|
12
12
|
const FormContext = React.createContext(
|
|
13
13
|
{}
|
|
@@ -234,20 +234,20 @@ function getValidations(outerValidation) {
|
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
var __defProp$
|
|
238
|
-
var __defNormalProp$
|
|
239
|
-
var __publicField$
|
|
240
|
-
__defNormalProp$
|
|
237
|
+
var __defProp$f = Object.defineProperty;
|
|
238
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
239
|
+
var __publicField$f = (obj, key, value) => {
|
|
240
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
241
241
|
return value;
|
|
242
242
|
};
|
|
243
243
|
const validationsStore = new class {
|
|
244
244
|
constructor() {
|
|
245
|
-
__publicField$
|
|
246
|
-
__publicField$
|
|
247
|
-
__publicField$
|
|
245
|
+
__publicField$f(this, "activeForms", []);
|
|
246
|
+
__publicField$f(this, "timeouts", {});
|
|
247
|
+
__publicField$f(this, "existsField", (formName, fieldName) => {
|
|
248
248
|
return !!this.getFormStore(formName)?.fields?.includes(fieldName);
|
|
249
249
|
});
|
|
250
|
-
__publicField$
|
|
250
|
+
__publicField$f(this, "registerField", (formName, registerData, options = { registerIfExists: true }) => {
|
|
251
251
|
const formProps = this.getFormStore(formName);
|
|
252
252
|
if (formProps === void 0)
|
|
253
253
|
this.registerForm(formName);
|
|
@@ -271,7 +271,7 @@ const validationsStore = new class {
|
|
|
271
271
|
/**
|
|
272
272
|
* Inicializa el estado de un nuevo formulario
|
|
273
273
|
*/
|
|
274
|
-
__publicField$
|
|
274
|
+
__publicField$f(this, "registerForm", (formName, props = { avoidFieldsOverride: false }) => {
|
|
275
275
|
props.persistToSessionStorage && this.loadFromSessionStorage(formName);
|
|
276
276
|
if (this.activeForms.includes(formName)) {
|
|
277
277
|
this.updateFormStore(
|
|
@@ -317,7 +317,7 @@ const validationsStore = new class {
|
|
|
317
317
|
* Setea el valor del campo con el nombre provisto. Si el campo no existe
|
|
318
318
|
* en el formulario lo crea.
|
|
319
319
|
*/
|
|
320
|
-
__publicField$
|
|
320
|
+
__publicField$f(this, "setFieldValue", (formName, fieldName, newValue, options) => {
|
|
321
321
|
if (!this.getFieldStore(formName, fieldName))
|
|
322
322
|
this.registerField(formName, { name: fieldName, value: newValue });
|
|
323
323
|
else
|
|
@@ -333,7 +333,7 @@ const validationsStore = new class {
|
|
|
333
333
|
if (this.getFormStore(formName).isValid)
|
|
334
334
|
this.updateFormStore(formName, { isValid: false });
|
|
335
335
|
});
|
|
336
|
-
__publicField$
|
|
336
|
+
__publicField$f(this, "setFormIsTouched", (formName, isTouched = true) => {
|
|
337
337
|
this.updateFormStore(formName, { isTouched }, true);
|
|
338
338
|
});
|
|
339
339
|
/**
|
|
@@ -341,7 +341,7 @@ const validationsStore = new class {
|
|
|
341
341
|
* forma cualquier validación que pudiera aplicarse sobre el mismo, ya no se
|
|
342
342
|
* aplicará.
|
|
343
343
|
*/
|
|
344
|
-
__publicField$
|
|
344
|
+
__publicField$f(this, "unregisterField", (formName, fieldName) => {
|
|
345
345
|
if (this.getFormStore(formName))
|
|
346
346
|
this.updateFormStore(formName, {
|
|
347
347
|
fields: this.getFormStore(formName).fields.filter((current) => {
|
|
@@ -354,7 +354,7 @@ const validationsStore = new class {
|
|
|
354
354
|
* Elimina un formulario del store de validación junto con todos los campos
|
|
355
355
|
* asociados al mismo.
|
|
356
356
|
*/
|
|
357
|
-
__publicField$
|
|
357
|
+
__publicField$f(this, "unregisterForm", (formName) => {
|
|
358
358
|
this.getFormStore(formName)?.fields?.forEach((current) => {
|
|
359
359
|
return propsStore.removeField(this.makeFieldName(formName, current));
|
|
360
360
|
});
|
|
@@ -368,7 +368,7 @@ const validationsStore = new class {
|
|
|
368
368
|
* Actualiza las propiedades de un campo, si no existe, lo registra en el
|
|
369
369
|
* formulario.
|
|
370
370
|
*/
|
|
371
|
-
__publicField$
|
|
371
|
+
__publicField$f(this, "updateField", (formName, field, options) => {
|
|
372
372
|
const previousValue = this.getFieldStore(formName, field.name)?.value;
|
|
373
373
|
if (this.getFormStore(formName))
|
|
374
374
|
this.updateFormStore(formName, { isValid: false }, true);
|
|
@@ -396,7 +396,7 @@ const validationsStore = new class {
|
|
|
396
396
|
/**
|
|
397
397
|
* Actualiza múltiples campos al mismo tiempo.
|
|
398
398
|
*/
|
|
399
|
-
__publicField$
|
|
399
|
+
__publicField$f(this, "updateMultipleFields", (formName, fields, options) => {
|
|
400
400
|
fields.forEach((current) => {
|
|
401
401
|
return this.updateField(formName, current, options);
|
|
402
402
|
});
|
|
@@ -425,7 +425,7 @@ const validationsStore = new class {
|
|
|
425
425
|
* console.error('Validation error', result);
|
|
426
426
|
* }
|
|
427
427
|
*/
|
|
428
|
-
__publicField$
|
|
428
|
+
__publicField$f(this, "validateForm", async (formName) => {
|
|
429
429
|
const state = this.getFormStore(formName);
|
|
430
430
|
if (!state)
|
|
431
431
|
return { errors: { form: "No form with name " + formName } };
|
|
@@ -1644,9 +1644,9 @@ const Switchbox = React.forwardRef(
|
|
|
1644
1644
|
value: innerValue ? "on" : "off",
|
|
1645
1645
|
ref: (el) => {
|
|
1646
1646
|
ref?.(el);
|
|
1647
|
-
if (el &&
|
|
1648
|
-
putValue.current =
|
|
1649
|
-
if (innerValue) {
|
|
1647
|
+
if (el && putValue.current !== innerValue) {
|
|
1648
|
+
putValue.current = innerValue;
|
|
1649
|
+
if (innerValue !== void 0 && innerValue !== null && putValue.current !== el.checked) {
|
|
1650
1650
|
el.click();
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
@@ -1731,10 +1731,10 @@ const Textarea = React.forwardRef(
|
|
|
1731
1731
|
);
|
|
1732
1732
|
Textarea.displayName = "Textarea";
|
|
1733
1733
|
|
|
1734
|
-
var __defProp$
|
|
1735
|
-
var __defNormalProp$
|
|
1736
|
-
var __publicField$
|
|
1737
|
-
__defNormalProp$
|
|
1734
|
+
var __defProp$e = Object.defineProperty;
|
|
1735
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1736
|
+
var __publicField$e = (obj, key, value) => {
|
|
1737
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1738
1738
|
return value;
|
|
1739
1739
|
};
|
|
1740
1740
|
var __accessCheck$2 = (obj, member, msg) => {
|
|
@@ -1759,17 +1759,17 @@ class CollectorField extends EventEmitter {
|
|
|
1759
1759
|
__privateAdd$2(this, _emitter, new StatefulEmitter({
|
|
1760
1760
|
isHidden: false
|
|
1761
1761
|
}));
|
|
1762
|
-
__publicField$
|
|
1763
|
-
__publicField$
|
|
1764
|
-
__publicField$
|
|
1762
|
+
__publicField$e(this, "_collector", {});
|
|
1763
|
+
__publicField$e(this, "isHidden", () => __privateGet$2(this, _emitter).getState("isHidden"));
|
|
1764
|
+
__publicField$e(this, "setIsHidden", (isHidden) => {
|
|
1765
1765
|
__privateGet$2(this, _emitter).emit("isHidden", isHidden);
|
|
1766
1766
|
});
|
|
1767
|
-
__publicField$
|
|
1768
|
-
__publicField$
|
|
1767
|
+
__publicField$e(this, "properties", {});
|
|
1768
|
+
__publicField$e(this, "setProperties", (newProps) => {
|
|
1769
1769
|
this.properties = { ...this.properties, ...newProps };
|
|
1770
1770
|
this.emit("propsUpdate", { ...this.properties });
|
|
1771
1771
|
});
|
|
1772
|
-
__publicField$
|
|
1772
|
+
__publicField$e(this, "useProperties", () => {
|
|
1773
1773
|
return useSubscription({
|
|
1774
1774
|
getInitialState: () => this.properties,
|
|
1775
1775
|
makeSubscription: (setProps) => this.on("propsUpdate", setProps)
|
|
@@ -1779,7 +1779,7 @@ class CollectorField extends EventEmitter {
|
|
|
1779
1779
|
* Este componente se utiliza para controlar propiedades comunes a todos los
|
|
1780
1780
|
* campos.
|
|
1781
1781
|
*/
|
|
1782
|
-
__publicField$
|
|
1782
|
+
__publicField$e(this, "SuperComponent", () => {
|
|
1783
1783
|
if (__privateGet$2(this, _emitter).useState("isHidden"))
|
|
1784
1784
|
return null;
|
|
1785
1785
|
return /* @__PURE__ */ jsx(Box, { className: `collector__field ${this.type}`, children: /* @__PURE__ */ jsx(this.Component, {}) });
|
|
@@ -1797,10 +1797,10 @@ class CollectorField extends EventEmitter {
|
|
|
1797
1797
|
}
|
|
1798
1798
|
_emitter = new WeakMap();
|
|
1799
1799
|
|
|
1800
|
-
var __defProp$
|
|
1801
|
-
var __defNormalProp$
|
|
1802
|
-
var __publicField$
|
|
1803
|
-
__defNormalProp$
|
|
1800
|
+
var __defProp$d = Object.defineProperty;
|
|
1801
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1802
|
+
var __publicField$d = (obj, key, value) => {
|
|
1803
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1804
1804
|
return value;
|
|
1805
1805
|
};
|
|
1806
1806
|
class ValidatedCollectorField extends CollectorField {
|
|
@@ -1809,24 +1809,24 @@ class ValidatedCollectorField extends CollectorField {
|
|
|
1809
1809
|
this.name = name;
|
|
1810
1810
|
this.label = label;
|
|
1811
1811
|
this.config = config;
|
|
1812
|
-
__publicField$
|
|
1812
|
+
__publicField$d(this, "setInitialValue", (newValue) => {
|
|
1813
1813
|
this.config.initialValue = newValue;
|
|
1814
1814
|
});
|
|
1815
|
-
__publicField$
|
|
1815
|
+
__publicField$d(this, "setValidationFunction", (newFunction) => {
|
|
1816
1816
|
this.config.validationFunction = newFunction;
|
|
1817
1817
|
this.emit("functionUpdate", this.config.validationFunction);
|
|
1818
1818
|
});
|
|
1819
|
-
__publicField$
|
|
1819
|
+
__publicField$d(this, "setValidationRules", (newRules) => {
|
|
1820
1820
|
this.config.validationRules = newRules;
|
|
1821
1821
|
this.emit("rulesUpdate", { ...this.config.validationRules });
|
|
1822
1822
|
});
|
|
1823
|
-
__publicField$
|
|
1823
|
+
__publicField$d(this, "toggleRequired", (isReq = this.config?.validationRules?.required ?? false) => {
|
|
1824
1824
|
if (!this.config.validationRules) {
|
|
1825
1825
|
this.config.validationRules = {};
|
|
1826
1826
|
}
|
|
1827
1827
|
this.config.validationRules.required = isReq;
|
|
1828
1828
|
});
|
|
1829
|
-
__publicField$
|
|
1829
|
+
__publicField$d(this, "useValidationFunction", () => {
|
|
1830
1830
|
return useSubscription({
|
|
1831
1831
|
getInitialState: () => () => this.config.validationFunction,
|
|
1832
1832
|
makeSubscription: (setValidationFunction) => {
|
|
@@ -1834,7 +1834,7 @@ class ValidatedCollectorField extends CollectorField {
|
|
|
1834
1834
|
}
|
|
1835
1835
|
});
|
|
1836
1836
|
});
|
|
1837
|
-
__publicField$
|
|
1837
|
+
__publicField$d(this, "useValidationRules", () => {
|
|
1838
1838
|
return useSubscription({
|
|
1839
1839
|
getInitialState: () => this.config.validationRules,
|
|
1840
1840
|
makeSubscription: (setValidationRules) => {
|
|
@@ -1863,17 +1863,17 @@ class ValidatedCollectorField extends CollectorField {
|
|
|
1863
1863
|
}
|
|
1864
1864
|
}
|
|
1865
1865
|
|
|
1866
|
-
var __defProp$
|
|
1867
|
-
var __defNormalProp$
|
|
1868
|
-
var __publicField$
|
|
1869
|
-
__defNormalProp$
|
|
1866
|
+
var __defProp$c = Object.defineProperty;
|
|
1867
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1868
|
+
var __publicField$c = (obj, key, value) => {
|
|
1869
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1870
1870
|
return value;
|
|
1871
1871
|
};
|
|
1872
1872
|
class CollectorCheckbox extends ValidatedCollectorField {
|
|
1873
1873
|
constructor() {
|
|
1874
1874
|
super(...arguments);
|
|
1875
|
-
__publicField$
|
|
1876
|
-
__publicField$
|
|
1875
|
+
__publicField$c(this, "type", "checkbox");
|
|
1876
|
+
__publicField$c(this, "Component", () => {
|
|
1877
1877
|
const rules = this.useValidationRules();
|
|
1878
1878
|
const validationFunction = this.useValidationFunction();
|
|
1879
1879
|
const props = this.useProperties();
|
|
@@ -1896,17 +1896,17 @@ class CollectorCheckbox extends ValidatedCollectorField {
|
|
|
1896
1896
|
}
|
|
1897
1897
|
}
|
|
1898
1898
|
|
|
1899
|
-
var __defProp$
|
|
1900
|
-
var __defNormalProp$
|
|
1901
|
-
var __publicField$
|
|
1902
|
-
__defNormalProp$
|
|
1899
|
+
var __defProp$b = Object.defineProperty;
|
|
1900
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1901
|
+
var __publicField$b = (obj, key, value) => {
|
|
1902
|
+
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1903
1903
|
return value;
|
|
1904
1904
|
};
|
|
1905
1905
|
class CollectorInput extends ValidatedCollectorField {
|
|
1906
1906
|
constructor() {
|
|
1907
1907
|
super(...arguments);
|
|
1908
|
-
__publicField$
|
|
1909
|
-
__publicField$
|
|
1908
|
+
__publicField$b(this, "type", "input");
|
|
1909
|
+
__publicField$b(this, "Component", () => {
|
|
1910
1910
|
const rules = this.useValidationRules();
|
|
1911
1911
|
const validationFunction = this.useValidationFunction();
|
|
1912
1912
|
const props = this.useProperties();
|
|
@@ -1927,10 +1927,10 @@ class CollectorInput extends ValidatedCollectorField {
|
|
|
1927
1927
|
}
|
|
1928
1928
|
}
|
|
1929
1929
|
|
|
1930
|
-
var __defProp$
|
|
1931
|
-
var __defNormalProp$
|
|
1932
|
-
var __publicField$
|
|
1933
|
-
__defNormalProp$
|
|
1930
|
+
var __defProp$a = Object.defineProperty;
|
|
1931
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1932
|
+
var __publicField$a = (obj, key, value) => {
|
|
1933
|
+
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1934
1934
|
return value;
|
|
1935
1935
|
};
|
|
1936
1936
|
var __accessCheck$1 = (obj, member, msg) => {
|
|
@@ -1957,13 +1957,13 @@ class CollectorSelect extends ValidatedCollectorField {
|
|
|
1957
1957
|
super(_name, label, config);
|
|
1958
1958
|
this._name = _name;
|
|
1959
1959
|
this.label = label;
|
|
1960
|
-
__publicField$
|
|
1960
|
+
__publicField$a(this, "type", "select");
|
|
1961
1961
|
__privateAdd$1(this, _options, []);
|
|
1962
|
-
__publicField$
|
|
1962
|
+
__publicField$a(this, "addOption", (newOption) => {
|
|
1963
1963
|
__privateSet(this, _options, [...__privateGet$1(this, _options), newOption]);
|
|
1964
1964
|
this.emit("optionsUpdate", __privateGet$1(this, _options));
|
|
1965
1965
|
});
|
|
1966
|
-
__publicField$
|
|
1966
|
+
__publicField$a(this, "setOptions", (newOptions) => {
|
|
1967
1967
|
__privateSet(this, _options, [...newOptions]);
|
|
1968
1968
|
this.emit("optionsUpdate", __privateGet$1(this, _options));
|
|
1969
1969
|
});
|
|
@@ -1974,7 +1974,7 @@ class CollectorSelect extends ValidatedCollectorField {
|
|
|
1974
1974
|
});
|
|
1975
1975
|
return options;
|
|
1976
1976
|
});
|
|
1977
|
-
__publicField$
|
|
1977
|
+
__publicField$a(this, "Component", () => {
|
|
1978
1978
|
const rules = this.useValidationRules();
|
|
1979
1979
|
const validationFunction = this.useValidationFunction();
|
|
1980
1980
|
const options = __privateGet$1(this, _useOptions).call(this);
|
|
@@ -2003,17 +2003,17 @@ class CollectorSelect extends ValidatedCollectorField {
|
|
|
2003
2003
|
_options = new WeakMap();
|
|
2004
2004
|
_useOptions = new WeakMap();
|
|
2005
2005
|
|
|
2006
|
-
var __defProp$
|
|
2007
|
-
var __defNormalProp$
|
|
2008
|
-
var __publicField$
|
|
2009
|
-
__defNormalProp$
|
|
2006
|
+
var __defProp$9 = Object.defineProperty;
|
|
2007
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2008
|
+
var __publicField$9 = (obj, key, value) => {
|
|
2009
|
+
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2010
2010
|
return value;
|
|
2011
2011
|
};
|
|
2012
2012
|
class CollectorTextarea extends ValidatedCollectorField {
|
|
2013
2013
|
constructor() {
|
|
2014
2014
|
super(...arguments);
|
|
2015
|
-
__publicField$
|
|
2016
|
-
__publicField$
|
|
2015
|
+
__publicField$9(this, "type", "textarea");
|
|
2016
|
+
__publicField$9(this, "Component", () => {
|
|
2017
2017
|
const rules = this.useValidationRules();
|
|
2018
2018
|
const validationFunction = this.useValidationFunction();
|
|
2019
2019
|
const props = this.useProperties();
|
|
@@ -2035,29 +2035,29 @@ class CollectorTextarea extends ValidatedCollectorField {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
2037
|
|
|
2038
|
-
var __defProp$
|
|
2039
|
-
var __defNormalProp$
|
|
2040
|
-
var __publicField$
|
|
2041
|
-
__defNormalProp$
|
|
2038
|
+
var __defProp$8 = Object.defineProperty;
|
|
2039
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2040
|
+
var __publicField$8 = (obj, key, value) => {
|
|
2041
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2042
2042
|
return value;
|
|
2043
2043
|
};
|
|
2044
2044
|
const _CollectorLabel = class _CollectorLabel extends CollectorField {
|
|
2045
2045
|
constructor(label, kind = "label") {
|
|
2046
2046
|
super(`label${_CollectorLabel.maxId++}`, label);
|
|
2047
2047
|
this.kind = kind;
|
|
2048
|
-
__publicField$
|
|
2049
|
-
__publicField$
|
|
2048
|
+
__publicField$8(this, "type", "label");
|
|
2049
|
+
__publicField$8(this, "Component", () => {
|
|
2050
2050
|
return /* @__PURE__ */ jsx(Box, { as: this.kind, children: getLabelName(this.label) });
|
|
2051
2051
|
});
|
|
2052
2052
|
}
|
|
2053
2053
|
};
|
|
2054
|
-
__publicField$
|
|
2054
|
+
__publicField$8(_CollectorLabel, "maxId", 0);
|
|
2055
2055
|
let CollectorLabel = _CollectorLabel;
|
|
2056
2056
|
|
|
2057
|
-
var __defProp$
|
|
2058
|
-
var __defNormalProp$
|
|
2059
|
-
var __publicField$
|
|
2060
|
-
__defNormalProp$
|
|
2057
|
+
var __defProp$7 = Object.defineProperty;
|
|
2058
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2059
|
+
var __publicField$7 = (obj, key, value) => {
|
|
2060
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2061
2061
|
return value;
|
|
2062
2062
|
};
|
|
2063
2063
|
let i = 0;
|
|
@@ -2065,25 +2065,25 @@ class CollectorButton extends CollectorField {
|
|
|
2065
2065
|
constructor(label, properties) {
|
|
2066
2066
|
super(`Button${i++}`, label, properties);
|
|
2067
2067
|
this.label = label;
|
|
2068
|
-
__publicField$
|
|
2069
|
-
__publicField$
|
|
2068
|
+
__publicField$7(this, "type", "button");
|
|
2069
|
+
__publicField$7(this, "Component", () => {
|
|
2070
2070
|
const props = this.useProperties();
|
|
2071
2071
|
return /* @__PURE__ */ jsx(SimpleButton, { ...props, children: getLabelName(this.label) });
|
|
2072
2072
|
});
|
|
2073
2073
|
}
|
|
2074
2074
|
}
|
|
2075
2075
|
|
|
2076
|
-
var __defProp$
|
|
2077
|
-
var __defNormalProp$
|
|
2078
|
-
var __publicField$
|
|
2079
|
-
__defNormalProp$
|
|
2076
|
+
var __defProp$6 = Object.defineProperty;
|
|
2077
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2078
|
+
var __publicField$6 = (obj, key, value) => {
|
|
2079
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2080
2080
|
return value;
|
|
2081
2081
|
};
|
|
2082
2082
|
class CollectorSwitch extends ValidatedCollectorField {
|
|
2083
2083
|
constructor() {
|
|
2084
2084
|
super(...arguments);
|
|
2085
|
-
__publicField$
|
|
2086
|
-
__publicField$
|
|
2085
|
+
__publicField$6(this, "type", "switch");
|
|
2086
|
+
__publicField$6(this, "Component", () => {
|
|
2087
2087
|
const rules = this.useValidationRules();
|
|
2088
2088
|
const validationFunction = this.useValidationFunction();
|
|
2089
2089
|
const props = this.useProperties();
|
|
@@ -2115,22 +2115,22 @@ class CollectorTitle extends CollectorLabel {
|
|
|
2115
2115
|
}
|
|
2116
2116
|
}
|
|
2117
2117
|
|
|
2118
|
-
var __defProp$
|
|
2119
|
-
var __defNormalProp$
|
|
2120
|
-
var __publicField$
|
|
2121
|
-
__defNormalProp$
|
|
2118
|
+
var __defProp$5 = Object.defineProperty;
|
|
2119
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2120
|
+
var __publicField$5 = (obj, key, value) => {
|
|
2121
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2122
2122
|
return value;
|
|
2123
2123
|
};
|
|
2124
2124
|
const _CollectorSeparator = class _CollectorSeparator extends CollectorField {
|
|
2125
2125
|
constructor() {
|
|
2126
2126
|
super(`separator${_CollectorSeparator.maxId++}`, "");
|
|
2127
|
-
__publicField$
|
|
2128
|
-
__publicField$
|
|
2127
|
+
__publicField$5(this, "type", "label");
|
|
2128
|
+
__publicField$5(this, "Component", () => {
|
|
2129
2129
|
return /* @__PURE__ */ jsx(Box, { className: "separator" });
|
|
2130
2130
|
});
|
|
2131
2131
|
}
|
|
2132
2132
|
};
|
|
2133
|
-
__publicField$
|
|
2133
|
+
__publicField$5(_CollectorSeparator, "maxId", 0);
|
|
2134
2134
|
let CollectorSeparator = _CollectorSeparator;
|
|
2135
2135
|
|
|
2136
2136
|
const AutogrowTextarea = React.forwardRef(
|
|
@@ -2206,17 +2206,17 @@ const AutogrowTextarea = React.forwardRef(
|
|
|
2206
2206
|
);
|
|
2207
2207
|
AutogrowTextarea.displayName = "Textarea";
|
|
2208
2208
|
|
|
2209
|
-
var __defProp$
|
|
2210
|
-
var __defNormalProp$
|
|
2211
|
-
var __publicField$
|
|
2212
|
-
__defNormalProp$
|
|
2209
|
+
var __defProp$4 = Object.defineProperty;
|
|
2210
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2211
|
+
var __publicField$4 = (obj, key, value) => {
|
|
2212
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2213
2213
|
return value;
|
|
2214
2214
|
};
|
|
2215
2215
|
class CollectorAutogrowTextarea extends ValidatedCollectorField {
|
|
2216
2216
|
constructor() {
|
|
2217
2217
|
super(...arguments);
|
|
2218
|
-
__publicField$
|
|
2219
|
-
__publicField$
|
|
2218
|
+
__publicField$4(this, "type", "autogrowtextarea");
|
|
2219
|
+
__publicField$4(this, "Component", () => {
|
|
2220
2220
|
const rules = this.useValidationRules();
|
|
2221
2221
|
const validationFunction = this.useValidationFunction();
|
|
2222
2222
|
const props = this.useProperties();
|
|
@@ -2238,6 +2238,73 @@ class CollectorAutogrowTextarea extends ValidatedCollectorField {
|
|
|
2238
2238
|
}
|
|
2239
2239
|
}
|
|
2240
2240
|
|
|
2241
|
+
const Component = observer(
|
|
2242
|
+
({
|
|
2243
|
+
name,
|
|
2244
|
+
label,
|
|
2245
|
+
title,
|
|
2246
|
+
options,
|
|
2247
|
+
formName,
|
|
2248
|
+
initialValue,
|
|
2249
|
+
removeOnUnmount,
|
|
2250
|
+
validationFunction,
|
|
2251
|
+
validationRules,
|
|
2252
|
+
onChange: outerOnChange
|
|
2253
|
+
}) => {
|
|
2254
|
+
const { value, onChange } = useField({
|
|
2255
|
+
formName,
|
|
2256
|
+
name,
|
|
2257
|
+
initialValue,
|
|
2258
|
+
removeOnUnmount,
|
|
2259
|
+
validationFunction,
|
|
2260
|
+
validationRules
|
|
2261
|
+
});
|
|
2262
|
+
return /* @__PURE__ */ jsx(FieldWrapper, { name, label, title, children: /* @__PURE__ */ jsx(
|
|
2263
|
+
SwitchMultiple,
|
|
2264
|
+
{
|
|
2265
|
+
defaultValue: initialValue,
|
|
2266
|
+
value,
|
|
2267
|
+
options,
|
|
2268
|
+
onChange: (ev) => {
|
|
2269
|
+
onChange(ev);
|
|
2270
|
+
outerOnChange && outerOnChange(ev);
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
) });
|
|
2274
|
+
}
|
|
2275
|
+
);
|
|
2276
|
+
|
|
2277
|
+
var __defProp$3 = Object.defineProperty;
|
|
2278
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2279
|
+
var __publicField$3 = (obj, key, value) => {
|
|
2280
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2281
|
+
return value;
|
|
2282
|
+
};
|
|
2283
|
+
class CollectorSwitchMultiple extends ValidatedCollectorField {
|
|
2284
|
+
constructor() {
|
|
2285
|
+
super(...arguments);
|
|
2286
|
+
__publicField$3(this, "type", "switchInput");
|
|
2287
|
+
__publicField$3(this, "Component", () => {
|
|
2288
|
+
const rules = this.useValidationRules();
|
|
2289
|
+
const validationFunction = this.useValidationFunction();
|
|
2290
|
+
const props = this.useProperties();
|
|
2291
|
+
return /* @__PURE__ */ jsx(
|
|
2292
|
+
Component,
|
|
2293
|
+
{
|
|
2294
|
+
...props,
|
|
2295
|
+
name: this.name,
|
|
2296
|
+
label: getLabelName(this.label),
|
|
2297
|
+
title: getLabelTooltip(this.label),
|
|
2298
|
+
initialValue: props.initialValue,
|
|
2299
|
+
validationRules: rules,
|
|
2300
|
+
validationFunction,
|
|
2301
|
+
options: props.options
|
|
2302
|
+
}
|
|
2303
|
+
);
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2241
2308
|
var __defProp$2 = Object.defineProperty;
|
|
2242
2309
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2243
2310
|
var __publicField$2 = (obj, key, value) => {
|
|
@@ -2281,7 +2348,8 @@ class Collector {
|
|
|
2281
2348
|
separator: CollectorSeparator,
|
|
2282
2349
|
switch: CollectorSwitch,
|
|
2283
2350
|
textarea: CollectorTextarea,
|
|
2284
|
-
title: CollectorTitle
|
|
2351
|
+
title: CollectorTitle,
|
|
2352
|
+
switchMultiple: CollectorSwitchMultiple
|
|
2285
2353
|
});
|
|
2286
2354
|
__publicField$2(this, "private__id", `Collector${maxId++}`);
|
|
2287
2355
|
__publicField$2(this, "modal", null);
|
|
@@ -2339,12 +2407,18 @@ class Collector {
|
|
|
2339
2407
|
fields.forEach((field) => {
|
|
2340
2408
|
this.fieldsStore[field.name] = field;
|
|
2341
2409
|
field.collector = this;
|
|
2410
|
+
if (field instanceof ValidatedCollectorField) {
|
|
2411
|
+
validationsStore.setFieldValue(this.id, field.name, field.initialValue);
|
|
2412
|
+
}
|
|
2342
2413
|
});
|
|
2343
2414
|
return this;
|
|
2344
2415
|
}
|
|
2345
2416
|
forEach(cb) {
|
|
2346
2417
|
Object.values(this.fieldsStore).forEach(cb);
|
|
2347
2418
|
}
|
|
2419
|
+
getByName(name) {
|
|
2420
|
+
return this.fieldsStore[name];
|
|
2421
|
+
}
|
|
2348
2422
|
show(modalProps) {
|
|
2349
2423
|
const { onConfirm, ...actualModalProps } = modalProps ?? {};
|
|
2350
2424
|
return new Promise((resolve) => {
|
|
@@ -2686,5 +2760,5 @@ class Validable {
|
|
|
2686
2760
|
}
|
|
2687
2761
|
}
|
|
2688
2762
|
|
|
2689
|
-
export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorField, DeletableInput, FieldWrapper, FileInput, Form, FormContext, Input, NumberInputf, Radio, Select, Switchbox, Textarea, Validable, ValidableCheck, ValidableContext, ValidableField, ValidableInput, ValidableSelect, ValidableTextarea, ValidatedCollectorField, ValidationError, WithMemoryCollector, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidableContext, useValidationClass, validate, validationsStore };
|
|
2763
|
+
export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorAutogrowTextarea, CollectorButton, CollectorCheckbox, CollectorField, CollectorInput, CollectorLabel, CollectorSelect, CollectorSeparator, CollectorSwitch, CollectorSwitchMultiple, CollectorTextarea, CollectorTitle, DeletableInput, FieldWrapper, FileInput, Form, FormContext, Input, NumberInputf, Radio, Select, Switchbox, Textarea, Validable, ValidableCheck, ValidableContext, ValidableField, ValidableInput, ValidableSelect, ValidableTextarea, ValidatedCollectorField, ValidationError, WithMemoryCollector, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidableContext, useValidationClass, validate, validationsStore };
|
|
2690
2764
|
//# sourceMappingURL=index.js.map
|