@toptal/picasso-forms 39.1.0 → 39.2.0
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/Autocomplete/Autocomplete.d.ts +1 -1
- package/Autocomplete/Autocomplete.js +19 -4
- package/Autocomplete/Autocomplete.js.map +1 -1
- package/ButtonCheckbox/ButtonCheckbox.d.ts +1 -1
- package/ButtonCheckbox/ButtonCheckbox.js +2 -2
- package/ButtonCheckbox/ButtonCheckbox.js.map +1 -1
- package/Checkbox/Checkbox.d.ts +2 -2
- package/Checkbox/Checkbox.js +6 -6
- package/Checkbox/Checkbox.js.map +1 -1
- package/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/CheckboxGroup/CheckboxGroup.js +4 -3
- package/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/DatePicker/DatePicker.d.ts +1 -1
- package/DatePicker/DatePicker.js +19 -4
- package/DatePicker/DatePicker.js.map +1 -1
- package/Dropzone/Dropzone.d.ts +1 -1
- package/Dropzone/Dropzone.js +3 -2
- package/Dropzone/Dropzone.js.map +1 -1
- package/Field/Field.d.ts +29 -0
- package/Field/Field.js +88 -0
- package/Field/Field.js.map +1 -0
- package/Field/index.d.ts +2 -0
- package/Field/index.js +3 -0
- package/Field/index.js.map +1 -0
- package/FieldLabel/FieldLabel.d.ts +12 -0
- package/FieldLabel/FieldLabel.js +23 -0
- package/FieldLabel/FieldLabel.js.map +1 -0
- package/FieldLabel/index.d.ts +2 -0
- package/FieldLabel/index.js +3 -0
- package/FieldLabel/index.js.map +1 -0
- package/FieldWrapper/FieldWrapper.d.ts +4 -22
- package/FieldWrapper/FieldWrapper.js +5 -132
- package/FieldWrapper/FieldWrapper.js.map +1 -1
- package/FieldWrapper/index.d.ts +1 -0
- package/FileInput/FileInput.d.ts +1 -1
- package/FileInput/FileInput.js +3 -2
- package/FileInput/FileInput.js.map +1 -1
- package/Form/Form.d.ts +4 -4
- package/Form/FormContext.d.ts +2 -2
- package/Form/FormContext.js.map +1 -1
- package/Form/index.d.ts +1 -0
- package/Form/index.js +1 -0
- package/Form/index.js.map +1 -1
- package/FormConfig/FormConfig.d.ts +1 -0
- package/FormConfig/FormConfig.js.map +1 -1
- package/Input/Input.d.ts +1 -1
- package/Input/Input.js +15 -2
- package/Input/Input.js.map +1 -1
- package/Input/index.d.ts +1 -0
- package/Input/index.js +1 -0
- package/Input/index.js.map +1 -1
- package/InputField/InputField.d.ts +11 -0
- package/InputField/InputField.js +50 -0
- package/InputField/InputField.js.map +1 -0
- package/InputField/index.d.ts +1 -0
- package/InputField/index.js +2 -0
- package/InputField/index.js.map +1 -0
- package/NumberInput/NumberInput.d.ts +1 -1
- package/NumberInput/NumberInput.js +15 -3
- package/NumberInput/NumberInput.js.map +1 -1
- package/PasswordInput/FieldRenderer.d.ts +7 -0
- package/PasswordInput/FieldRenderer.js +27 -0
- package/PasswordInput/FieldRenderer.js.map +1 -0
- package/PasswordInput/PasswordInput.d.ts +1 -1
- package/PasswordInput/PasswordInput.js +15 -18
- package/PasswordInput/PasswordInput.js.map +1 -1
- package/RadioGroup/RadioGroup.d.ts +1 -1
- package/RadioGroup/RadioGroup.js +4 -7
- package/RadioGroup/RadioGroup.js.map +1 -1
- package/Rating/Rating.d.ts +2 -2
- package/Rating/Rating.js +9 -5
- package/Rating/Rating.js.map +1 -1
- package/Select/Select.d.ts +2 -2
- package/Select/Select.js +5 -4
- package/Select/Select.js.map +1 -1
- package/Switch/Switch.d.ts +1 -1
- package/Switch/Switch.js +3 -3
- package/Switch/Switch.js.map +1 -1
- package/TagSelector/TagSelector.d.ts +1 -1
- package/TagSelector/TagSelector.js +19 -4
- package/TagSelector/TagSelector.js.map +1 -1
- package/TimePicker/TimePicker.d.ts +1 -1
- package/TimePicker/TimePicker.js +21 -4
- package/TimePicker/TimePicker.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js.map +1 -1
- package/package.json +2 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/index.js.map +1 -1
- package/utils/use-field-validation/index.d.ts +1 -0
- package/utils/use-field-validation/index.js +2 -0
- package/utils/use-field-validation/index.js.map +1 -0
- package/utils/use-field-validation/use-field-validation.d.ts +12 -0
- package/utils/use-field-validation/use-field-validation.js +34 -0
- package/utils/use-field-validation/use-field-validation.js.map +1 -0
- package/utils/use-form-input-reset/index.d.ts +1 -0
- package/utils/use-form-input-reset/index.js +2 -0
- package/utils/use-form-input-reset/index.js.map +1 -0
- package/utils/use-form-input-reset/use-form-input-reset.d.ts +8 -0
- package/utils/use-form-input-reset/use-form-input-reset.js +17 -0
- package/utils/use-form-input-reset/use-form-input-reset.js.map +1 -0
|
@@ -9,139 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { useFormContext } from '../Form/FormContext';
|
|
16
|
-
import { useFormConfig } from '../FormConfig';
|
|
17
|
-
import { validators } from '../utils';
|
|
18
|
-
const { composeValidators, required: requiredValidator } = validators;
|
|
19
|
-
const getInputError = (meta, formConfig) => {
|
|
20
|
-
if (formConfig.validateOnSubmit && meta.modifiedSinceLastSubmit) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
if (!meta.error && !meta.submitError) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
if (!meta.touched) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
if (meta.error) {
|
|
30
|
-
return meta.error;
|
|
31
|
-
}
|
|
32
|
-
if (meta.dirtySinceLastSubmit) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return meta.submitError;
|
|
36
|
-
};
|
|
37
|
-
const getValidators = (required, validate) => {
|
|
38
|
-
if (required && validate) {
|
|
39
|
-
return composeValidators([requiredValidator, validate]);
|
|
40
|
-
}
|
|
41
|
-
if (required && !validate) {
|
|
42
|
-
return requiredValidator;
|
|
43
|
-
}
|
|
44
|
-
return validate;
|
|
45
|
-
};
|
|
46
|
-
const getProps = ({ hideFieldLabel, error, label }) => {
|
|
47
|
-
if (hideFieldLabel) {
|
|
48
|
-
return {
|
|
49
|
-
label
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
error: Boolean(error)
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const getRequiredDecoration = (hideLabelRequiredDecoration, required, requiredVariant) => {
|
|
57
|
-
if (hideLabelRequiredDecoration) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const showAsterisk = required && requiredVariant === 'asterisk';
|
|
61
|
-
if (showAsterisk) {
|
|
62
|
-
return 'asterisk';
|
|
63
|
-
}
|
|
64
|
-
const showOptional = !required && (!requiredVariant || requiredVariant === 'default');
|
|
65
|
-
if (showOptional) {
|
|
66
|
-
return 'optional';
|
|
67
|
-
}
|
|
68
|
-
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import Field from '../Field';
|
|
14
|
+
import FieldLabel from '../FieldLabel';
|
|
69
15
|
const FieldWrapper = (props) => {
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
afterSubmit, allowNull, beforeSubmit, children, data, defaultValue, format, formatOnBlur, initialValue, isEqual, name, id = name, parse, subscription, validate, validateFields, value, titleCase } = props,
|
|
73
|
-
//
|
|
74
|
-
rest = __rest(props, ["type", "hideFieldLabel", "hideLabelRequiredDecoration", "hint", "label", "required", "enableReset", "onResetClick", 'data-testid', "renderFieldRequirements", "afterSubmit", "allowNull", "beforeSubmit", "children", "data", "defaultValue", "format", "formatOnBlur", "initialValue", "isEqual", "name", "id", "parse", "subscription", "validate", "validateFields", "value", "titleCase"]);
|
|
75
|
-
const formConfig = useFormConfig();
|
|
76
|
-
const { setValidators, clearValidators } = useFormContext();
|
|
77
|
-
const validators = getValidators(required, validate);
|
|
78
|
-
if (formConfig.validateOnSubmit) {
|
|
79
|
-
setValidators(name, validators);
|
|
80
|
-
}
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
return () => {
|
|
83
|
-
if (formConfig.validateOnSubmit) {
|
|
84
|
-
clearValidators(name);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}, [clearValidators, formConfig.validateOnSubmit, name]);
|
|
88
|
-
const { meta, input } = useField(name, {
|
|
89
|
-
validate: formConfig.validateOnSubmit ? undefined : validators,
|
|
90
|
-
type,
|
|
91
|
-
afterSubmit,
|
|
92
|
-
allowNull,
|
|
93
|
-
beforeSubmit,
|
|
94
|
-
data,
|
|
95
|
-
defaultValue,
|
|
96
|
-
format,
|
|
97
|
-
formatOnBlur,
|
|
98
|
-
initialValue,
|
|
99
|
-
isEqual,
|
|
100
|
-
parse,
|
|
101
|
-
subscription,
|
|
102
|
-
validateFields,
|
|
103
|
-
value
|
|
104
|
-
});
|
|
105
|
-
const defaultResetClickHandler = useCallback(() => {
|
|
106
|
-
input.onChange('');
|
|
107
|
-
}, [input]);
|
|
108
|
-
const resetClickHandler = useCallback(() => {
|
|
109
|
-
onResetClick((resetValue) => {
|
|
110
|
-
input.onChange(resetValue);
|
|
111
|
-
});
|
|
112
|
-
}, [input, onResetClick]);
|
|
113
|
-
const error = getInputError(meta, formConfig);
|
|
114
|
-
const childProps = Object.assign(Object.assign(Object.assign(Object.assign({ id }, rest), input), getProps({ hideFieldLabel, error, label })), {
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
-
onChange: (event) => {
|
|
117
|
-
input.onChange(event);
|
|
118
|
-
if (rest.onChange) {
|
|
119
|
-
rest.onChange(event);
|
|
120
|
-
}
|
|
121
|
-
}, onBlur: (event) => {
|
|
122
|
-
input.onBlur(event);
|
|
123
|
-
if (rest.onBlur) {
|
|
124
|
-
rest.onBlur(event);
|
|
125
|
-
}
|
|
126
|
-
}, onFocus: (event) => {
|
|
127
|
-
input.onFocus(event);
|
|
128
|
-
if (rest.onFocus) {
|
|
129
|
-
rest.onFocus(event);
|
|
130
|
-
}
|
|
131
|
-
} });
|
|
132
|
-
if (enableReset) {
|
|
133
|
-
childProps.onResetClick = onResetClick
|
|
134
|
-
? resetClickHandler
|
|
135
|
-
: defaultResetClickHandler;
|
|
136
|
-
childProps.enableReset = enableReset;
|
|
137
|
-
}
|
|
138
|
-
const requiredDecoration = getRequiredDecoration(hideLabelRequiredDecoration, required, formConfig.requiredVariant);
|
|
139
|
-
return (React.createElement(PicassoForm.Field, { error: error, hint: hint, "data-testid": dataTestId, fieldRequirements: renderFieldRequirements === null || renderFieldRequirements === void 0 ? void 0 : renderFieldRequirements({
|
|
140
|
-
value: input.value,
|
|
141
|
-
error: error
|
|
142
|
-
}) },
|
|
143
|
-
!hideFieldLabel && label && (React.createElement(PicassoForm.Label, { requiredDecoration: requiredDecoration, htmlFor: id, titleCase: titleCase }, label)),
|
|
144
|
-
children(childProps)));
|
|
16
|
+
const { label, name, titleCase, children } = props, rest = __rest(props, ["label", "name", "titleCase", "children"]);
|
|
17
|
+
return (React.createElement(Field, Object.assign({}, rest, { name: name, label: label ? (React.createElement(FieldLabel, { name: props.name, required: props.required, label: label, titleCase: titleCase })) : null }), children));
|
|
145
18
|
};
|
|
146
19
|
FieldWrapper.defaultProps = {};
|
|
147
20
|
FieldWrapper.displayName = 'FieldWrapper';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldWrapper.js","sourceRoot":"","sources":["../../src/FieldWrapper/FieldWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"FieldWrapper.js","sourceRoot":"","sources":["../../src/FieldWrapper/FieldWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAIN,MAAM,UAAU,CAAA;AACjB,OAAO,UAAU,MAAM,eAAe,CAAA;AAOtC,MAAM,YAAY,GAAG,CAInB,KAAiD,EACjD,EAAE;IACF,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAArD,0CAA6C,CAAQ,CAAA;IAE3D,OAAO,CACL,oBAAC,KAAK,oBACA,IAAI,IACR,IAAI,EAAE,IAAI,EACV,KAAK,EACH,KAAK,CAAC,CAAC,CAAC,CACN,oBAAC,UAAU,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,GACpB,CACH,CAAC,CAAC,CAAC,IAAI,KAGT,QAAQ,CACH,CACT,CAAA;AACH,CAAC,CAAA;AAED,YAAY,CAAC,YAAY,GAAG,EAAE,CAAA;AAE9B,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAEzC,eAAe,YAAY,CAAA"}
|
package/FieldWrapper/index.d.ts
CHANGED
package/FileInput/FileInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileInputProps } from '@toptal/picasso';
|
|
2
|
-
import { FieldProps } from '../
|
|
2
|
+
import { FieldProps } from '../Field';
|
|
3
3
|
export declare type Props = FileInputProps & FieldProps<FileInputProps['value']>;
|
|
4
4
|
export declare const FileInput: {
|
|
5
5
|
(props: Props): JSX.Element;
|
package/FileInput/FileInput.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FileInput as PicassoFileInput } from '@toptal/picasso';
|
|
3
|
-
import
|
|
3
|
+
import PicassoField from '../Field';
|
|
4
|
+
import FieldLabel from '../FieldLabel';
|
|
4
5
|
export const FileInput = (props) => {
|
|
5
6
|
const handleChange = (event, value = [], finalFormOnChange) => {
|
|
6
7
|
if (!event.target || !event.target.files || !event.target.files.length) {
|
|
@@ -18,7 +19,7 @@ export const FileInput = (props) => {
|
|
|
18
19
|
const updatedFiles = value.filter((_, index) => index !== fileIndex);
|
|
19
20
|
finalFormOnChange(updatedFiles);
|
|
20
21
|
};
|
|
21
|
-
return (React.createElement(
|
|
22
|
+
return (React.createElement(PicassoField, Object.assign({}, props, { label: props.label ? (React.createElement(FieldLabel, { name: props.name, required: props.required, label: props.label, titleCase: props.titleCase })) : null }), inputProps => (React.createElement(PicassoFileInput, Object.assign({}, inputProps, { onChange: (event) => {
|
|
22
23
|
handleChange(event, inputProps.value, inputProps.onChange);
|
|
23
24
|
}, onRemove: (fileName, index) => {
|
|
24
25
|
handleRemove(index, inputProps.value, inputProps.onChange);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAkB,MAAM,iBAAiB,CAAA;AAI/E,OAAO,YAA4B,MAAM,
|
|
1
|
+
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAkB,MAAM,iBAAiB,CAAA;AAI/E,OAAO,YAA4B,MAAM,UAAU,CAAA;AACnD,OAAO,UAAU,MAAM,eAAe,CAAA;AAQtC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAY,EAAE,EAAE;IACxC,MAAM,YAAY,GAAG,CACnB,KAA0C,EAC1C,QAAkC,EAAE,EACpC,iBAAwC,EACxC,EAAE;QACF,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE;YACtE,OAAO,IAAI,CAAA;SACZ;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CA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AA;AACH,CAAC,CAAA;AAED,SAAS,CAAC,YAAY,GAAG,EAAE,CAAA;AAE3B,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,eAAe,SAAS,CAAA"}
|
package/Form/Form.d.ts
CHANGED
|
@@ -17,9 +17,9 @@ export declare const Form: {
|
|
|
17
17
|
(props: import("../Autocomplete/Autocomplete").Props): JSX.Element;
|
|
18
18
|
displayName: string;
|
|
19
19
|
};
|
|
20
|
-
Input: React.ForwardRefExoticComponent<Pick<import("../Input
|
|
20
|
+
Input: React.ForwardRefExoticComponent<Pick<import("../Input").Props, string | number> & React.RefAttributes<HTMLInputElement>>;
|
|
21
21
|
Select: {
|
|
22
|
-
<T_1 extends import("@toptal/picasso").SelectValueType, M extends boolean = false>(
|
|
22
|
+
<T_1 extends import("@toptal/picasso").SelectValueType, M extends boolean = false>(props: import("../Select/Select").Props<T_1, M>): JSX.Element;
|
|
23
23
|
defaultProps: {};
|
|
24
24
|
displayName: string;
|
|
25
25
|
};
|
|
@@ -34,7 +34,7 @@ export declare const Form: {
|
|
|
34
34
|
displayName: string;
|
|
35
35
|
};
|
|
36
36
|
Checkbox: {
|
|
37
|
-
({ name, value, required, defaultValue, ...restProps }: import("../Checkbox/Checkbox").Props): JSX.Element;
|
|
37
|
+
({ name, value, required, label, defaultValue, ...restProps }: import("../Checkbox/Checkbox").Props): JSX.Element;
|
|
38
38
|
displayName: string;
|
|
39
39
|
};
|
|
40
40
|
ButtonCheckbox: {
|
|
@@ -86,7 +86,7 @@ export declare const Form: {
|
|
|
86
86
|
};
|
|
87
87
|
Rating: {
|
|
88
88
|
readonly Stars: (props: import("../Rating/Rating").RatingStarsProps) => JSX.Element;
|
|
89
|
-
readonly Thumbs: (
|
|
89
|
+
readonly Thumbs: (props: import("../Rating/Rating").RatingThumbsProps) => JSX.Element;
|
|
90
90
|
};
|
|
91
91
|
Dropzone: {
|
|
92
92
|
({ dropzoneHint, ...props }: import("../Dropzone/Dropzone").Props): JSX.Element;
|
package/Form/FormContext.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
2
|
import { FieldValidator } from 'final-form';
|
|
3
|
-
export declare type Validators = Record<string, FieldValidator<
|
|
3
|
+
export declare type Validators = Record<string, FieldValidator<any>>;
|
|
4
4
|
export declare type FormContextProps = {
|
|
5
5
|
getValidators: () => Validators;
|
|
6
|
-
setValidators: (fieldName: string, validator: FieldValidator<
|
|
6
|
+
setValidators: (fieldName: string, validator: FieldValidator<any>) => void;
|
|
7
7
|
clearValidators: (fieldName: string) => void;
|
|
8
8
|
};
|
|
9
9
|
export declare const createFormContext: () => FormContextProps;
|
package/Form/FormContext.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormContext.js","sourceRoot":"","sources":["../../src/Form/FormContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAoB,MAAM,OAAO,CAAA;AAWnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAqB,EAAE;IACtD,MAAM,UAAU,GAAe,EAAE,CAAA;IAEjC,OAAO;QACL,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,aAAa,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACtC,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,CAAA;QACnC,CAAC;QACD,eAAe,EAAE,SAAS,CAAC,EAAE;YAC3B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"FormContext.js","sourceRoot":"","sources":["../../src/Form/FormContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAoB,MAAM,OAAO,CAAA;AAWnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAqB,EAAE;IACtD,MAAM,UAAU,GAAe,EAAE,CAAA;IAEjC,OAAO;QACL,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,aAAa,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACtC,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,CAAA;QACnC,CAAC;QACD,eAAe,EAAE,SAAS,CAAC,EAAE;YAC3B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GACtB,aAAa,CAA4C,IAAI,CAAC,CAAA;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IAEvC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;KACxE;IAED,OAAO,OAAO,CAAC,OAAO,CAAA;AACxB,CAAC,CAAA"}
|
package/Form/index.d.ts
CHANGED
package/Form/index.js
CHANGED
package/Form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,cAAc,QAAQ,CAAA"}
|
|
@@ -2,6 +2,7 @@ export declare type RequiredVariant = 'default' | 'asterisk';
|
|
|
2
2
|
export interface FormConfigProps {
|
|
3
3
|
validateOnSubmit?: boolean;
|
|
4
4
|
requiredVariant?: RequiredVariant;
|
|
5
|
+
showValidState?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare const FormConfigContext: import("react").Context<FormConfigProps>;
|
|
7
8
|
export declare const useFormConfig: () => FormConfigProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormConfig.js","sourceRoot":"","sources":["../../src/FormConfig/FormConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FormConfig.js","sourceRoot":"","sources":["../../src/FormConfig/FormConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAUjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAkB,EAAE,CAAC,CAAA;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA"}
|
package/Input/Input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputProps } from '@toptal/picasso';
|
|
3
|
-
import { FieldProps } from '../
|
|
3
|
+
import { FieldProps } from '../Field';
|
|
4
4
|
export declare type FormInputProps = Omit<InputProps, 'onResetClick'> & {
|
|
5
5
|
/** Callback invoked when reset button was clicked */
|
|
6
6
|
onResetClick?: (set: (value: string) => void) => void;
|
package/Input/Input.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import React, { useEffect } from 'react';
|
|
2
13
|
import { Input as PicassoInput } from '@toptal/picasso';
|
|
3
|
-
import
|
|
14
|
+
import FieldLabel from '../FieldLabel';
|
|
15
|
+
import InputField from '../InputField';
|
|
4
16
|
const warnAutocompleteDisabledInput = (name) => {
|
|
5
17
|
const autocompleteDisabled = name && /^(((field|input)(_|-)?\d+)|tan|otp|title|captcha)$/.test(name);
|
|
6
18
|
if (autocompleteDisabled) {
|
|
@@ -17,7 +29,8 @@ export const Input = React.forwardRef((props, ref) => {
|
|
|
17
29
|
// according to https://bugs.chromium.org/p/chromium/issues/detail?id=1255609
|
|
18
30
|
warnAutocompleteDisabledInput(props.name);
|
|
19
31
|
}, [props.name]);
|
|
20
|
-
|
|
32
|
+
const { label, titleCase } = props, rest = __rest(props, ["label", "titleCase"]);
|
|
33
|
+
return (React.createElement(InputField, Object.assign({}, rest, { label: label ? (React.createElement(FieldLabel, { name: props.name, required: props.required, label: label, titleCase: titleCase })) : null }), (inputProps) => React.createElement(PicassoInput, Object.assign({}, inputProps, { ref: ref }))));
|
|
21
34
|
});
|
|
22
35
|
Input.defaultProps = {};
|
|
23
36
|
Input.displayName = 'Input';
|
package/Input/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAc,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/Input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAc,MAAM,iBAAiB,CAAA;AAGnE,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAA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 -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OutlinedInputStatus } from '@toptal/picasso';
|
|
2
|
+
import { FieldMetaState } from 'react-final-form';
|
|
3
|
+
import { Props as FieldProps, ValueType, IFormComponentProps } from '../Field';
|
|
4
|
+
import { FormConfigProps } from '../FormConfig';
|
|
5
|
+
export declare const getInputStatus: <T extends ValueType>(meta: FieldMetaState<T>, formConfig: FormConfigProps) => OutlinedInputStatus;
|
|
6
|
+
declare const InputField: {
|
|
7
|
+
<TWrappedComponentProps extends IFormComponentProps, TInputValue extends ValueType = TWrappedComponentProps["value"]>(props: FieldProps<TWrappedComponentProps, TInputValue>): JSX.Element;
|
|
8
|
+
defaultProps: {};
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export default InputField;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { useField } from 'react-final-form';
|
|
14
|
+
import Field from '../Field';
|
|
15
|
+
import { useFormConfig } from '../FormConfig';
|
|
16
|
+
import useFormInputReset from '../utils/use-form-input-reset';
|
|
17
|
+
export const getInputStatus = (meta, formConfig) => {
|
|
18
|
+
if (formConfig.validateOnSubmit && meta.modifiedSinceLastSubmit) {
|
|
19
|
+
return 'default';
|
|
20
|
+
}
|
|
21
|
+
if (!meta.touched) {
|
|
22
|
+
return 'default';
|
|
23
|
+
}
|
|
24
|
+
if (meta.error) {
|
|
25
|
+
return 'error';
|
|
26
|
+
}
|
|
27
|
+
if (meta.dirtySinceLastSubmit) {
|
|
28
|
+
return 'default';
|
|
29
|
+
}
|
|
30
|
+
if (meta.submitError) {
|
|
31
|
+
return 'error';
|
|
32
|
+
}
|
|
33
|
+
return formConfig.showValidState ? 'success' : 'default';
|
|
34
|
+
};
|
|
35
|
+
const InputField = (props) => {
|
|
36
|
+
const { name, children, enableReset, onResetClick } = props, rest = __rest(props, ["name", "children", "enableReset", "onResetClick"]);
|
|
37
|
+
const { meta, input } = useField(name);
|
|
38
|
+
const formConfig = useFormConfig();
|
|
39
|
+
const status = getInputStatus(meta, formConfig);
|
|
40
|
+
const onFormInputResetClick = useFormInputReset({
|
|
41
|
+
input,
|
|
42
|
+
enableReset,
|
|
43
|
+
onResetClick
|
|
44
|
+
});
|
|
45
|
+
return (React.createElement(Field, Object.assign({ status: status, name: name, onResetClick: onFormInputResetClick, enableReset: enableReset }, rest), children));
|
|
46
|
+
};
|
|
47
|
+
InputField.defaultProps = {};
|
|
48
|
+
InputField.displayName = 'InputField';
|
|
49
|
+
export default InputField;
|
|
50
|
+
//# sourceMappingURL=InputField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputField.js","sourceRoot":"","sources":["../../src/InputField/InputField.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAkB,QAAQ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,EACV,YAAY,EAAE,qBAAqB,EACnC,WAAW,EAAE,WAAW,IACpB,IAAI,GAEP,QAAQ,CACH,CACT,CAAA;AACH,CAAC,CAAA;AAED,UAAU,CAAC,YAAY,GAAG,EAAE,CAAA;AAE5B,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAErC,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './InputField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/InputField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NumberInputProps } from '@toptal/picasso';
|
|
2
|
-
import { FieldProps } from '../
|
|
2
|
+
import { FieldProps } from '../Field';
|
|
3
3
|
export declare type Props = NumberInputProps & FieldProps<NumberInputProps['value']>;
|
|
4
4
|
export declare const NumberInput: {
|
|
5
5
|
(props: Props): JSX.Element;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import React from 'react';
|
|
2
13
|
import { NumberInput as PicassoNumberInput } from '@toptal/picasso';
|
|
3
14
|
import { validators } from '../utils';
|
|
4
|
-
import
|
|
15
|
+
import FieldLabel from '../FieldLabel';
|
|
16
|
+
import InputField from '../InputField';
|
|
5
17
|
const MIN = -2147483648;
|
|
6
18
|
const MAX = 2147483647;
|
|
7
19
|
const { composeValidators } = validators;
|
|
8
20
|
export const NumberInput = (props) => {
|
|
9
|
-
const { min = MIN, max = MAX, validate } = props;
|
|
21
|
+
const { min = MIN, max = MAX, validate, label, titleCase } = props, rest = __rest(props, ["min", "max", "validate", "label", "titleCase"]);
|
|
10
22
|
const validateNumberLimits = value => {
|
|
11
23
|
if (Number(value) > max) {
|
|
12
24
|
return `Must be less than or equal to ${max}.`;
|
|
@@ -15,7 +27,7 @@ export const NumberInput = (props) => {
|
|
|
15
27
|
return `Must be greater than or equal to ${min}.`;
|
|
16
28
|
}
|
|
17
29
|
};
|
|
18
|
-
return (React.createElement(
|
|
30
|
+
return (React.createElement(InputField, Object.assign({}, rest, { validate: composeValidators([validateNumberLimits, validate]), label: label ? (React.createElement(FieldLabel, { name: props.name, required: props.required, label: label, titleCase: titleCase })) : null }), (inputProps) => {
|
|
19
31
|
return React.createElement(PicassoNumberInput, Object.assign({}, inputProps));
|
|
20
32
|
}));
|
|
21
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../src/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACL,WAAW,IAAI,kBAAkB,EAElC,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../src/NumberInput/NumberInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACL,WAAW,IAAI,kBAAkB,EAElC,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC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,7 @@
|
|
|
1
|
+
import { PasswordInputProps } from '@toptal/picasso';
|
|
2
|
+
interface FieldRendererProps extends PasswordInputProps {
|
|
3
|
+
onShowContent: () => void;
|
|
4
|
+
onHideContent: () => void;
|
|
5
|
+
}
|
|
6
|
+
declare const FieldRenderer: (props: FieldRendererProps) => JSX.Element;
|
|
7
|
+
export default FieldRenderer;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useCallback } from 'react';
|
|
13
|
+
import { PasswordInput as PicassoPasswordInput } from '@toptal/picasso';
|
|
14
|
+
const FieldRenderer = (props) => {
|
|
15
|
+
const { onFocus, onBlur, onShowContent, onHideContent } = props, rest = __rest(props, ["onFocus", "onBlur", "onShowContent", "onHideContent"]);
|
|
16
|
+
const handleFocus = useCallback((event) => {
|
|
17
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
18
|
+
onShowContent();
|
|
19
|
+
}, [onFocus, onShowContent]);
|
|
20
|
+
const handleBlur = useCallback((event) => {
|
|
21
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
22
|
+
onHideContent();
|
|
23
|
+
}, [onBlur, onHideContent]);
|
|
24
|
+
return (React.createElement(PicassoPasswordInput, Object.assign({}, rest, { onFocus: handleFocus, onBlur: handleBlur })));
|
|
25
|
+
};
|
|
26
|
+
export default FieldRenderer;
|
|
27
|
+
//# sourceMappingURL=FieldRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldRenderer.js","sourceRoot":"","sources":["../../src/PasswordInput/FieldRenderer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAc,WAAW,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,EACL,aAAa,IAAI,oBAAoB,EAEtC,MAAM,iBAAiB,CAAA;AAMxB,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAE,EAAE;IAClD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAAlE,uDAA0D,CAAQ,CAAA;IAExE,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,KAAmC,EAAE,EAAE;QACtC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAA;QAEhB,aAAa,EAAE,CAAA;IACjB,CAAC,EACD,CAAC,OAAO,EAAE,aAAa,CAAC,CACzB,CAAA;IAED,MAAM,UAAU,GAAG,WAAW,CAC5B,CAAC,KAAmC,EAAE,EAAE;QACtC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,KAAK,CAAC,CAAA;QAEf,aAAa,EAAE,CAAA;IACjB,CAAC,EACD,CAAC,MAAM,EAAE,aAAa,CAAC,CACxB,CAAA;IAED,OAAO,CACL,oBAAC,oBAAoB,oBAAK,IAAI,IAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,IAAI,CAC7E,CAAA;AACH,CAAC,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PasswordInputProps } from '@toptal/picasso';
|
|
2
|
-
import { FieldProps } from '../
|
|
2
|
+
import { FieldProps } from '../Field';
|
|
3
3
|
export declare type Props = PasswordInputProps & FieldProps<PasswordInputProps['value']> & {
|
|
4
4
|
hideRequirements?: boolean;
|
|
5
5
|
};
|
|
@@ -9,12 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useState } from 'react';
|
|
13
|
-
import { PasswordInput as PicassoPasswordInput } from '@toptal/picasso';
|
|
12
|
+
import React, { useState, useCallback } from 'react';
|
|
14
13
|
import { validators } from '../utils';
|
|
15
|
-
import
|
|
14
|
+
import FieldLabel from '../FieldLabel';
|
|
16
15
|
import passwordValidators from './validators';
|
|
17
16
|
import Form from '../Form';
|
|
17
|
+
import InputField from '../InputField';
|
|
18
|
+
import FieldRenderer from './FieldRenderer';
|
|
18
19
|
const { composeValidators } = validators;
|
|
19
20
|
const ANIMATION_TIMEOUT = 500; // same as in Picasso/FieldRequirements
|
|
20
21
|
const validatePassword = (value) => {
|
|
@@ -56,21 +57,17 @@ export const PasswordInput = (_a) => {
|
|
|
56
57
|
validator: passwordValidators.atLeastOneLowerCaseCharacter
|
|
57
58
|
}
|
|
58
59
|
] }));
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
setShowContent(false);
|
|
71
|
-
}, ANIMATION_TIMEOUT);
|
|
72
|
-
};
|
|
73
|
-
return (React.createElement(PicassoPasswordInput, Object.assign({}, inputProps, { onFocus: handleFocus, onBlur: handleBlur })));
|
|
60
|
+
const handleShowContent = useCallback(() => {
|
|
61
|
+
setShowContent(true);
|
|
62
|
+
}, []);
|
|
63
|
+
const handleHideContent = useCallback(() => {
|
|
64
|
+
// Hide the requirements after a short delay
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
setShowContent(false);
|
|
67
|
+
}, ANIMATION_TIMEOUT);
|
|
68
|
+
}, []);
|
|
69
|
+
return (React.createElement(InputField, Object.assign({}, rest, { validate: validationsObject, renderFieldRequirements: !hideRequirements ? renderFieldRequirements : undefined, label: rest.label ? (React.createElement(FieldLabel, { name: rest.name, required: rest.required, label: rest.label, titleCase: rest.titleCase })) : null }), (inputProps) => {
|
|
70
|
+
return (React.createElement(FieldRenderer, Object.assign({}, inputProps, { onHideContent: handleHideContent, onShowContent: handleShowContent })));
|
|
74
71
|
}));
|
|
75
72
|
};
|
|
76
73
|
PasswordInput.displayName = 'PasswordInput';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordInput.js","sourceRoot":"","sources":["../../src/PasswordInput/PasswordInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"PasswordInput.js","sourceRoot":"","sources":["../../src/PasswordInput/PasswordInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAa,WAAW,EAAE,MAAM,OAAO,CAAA;AAI/D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,kBAAkB,MAAM,cAAc,CAAA;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAK3C,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAA;AAExC,MAAM,iBAAiB,GAAG,GAAG,CAAA,CAAC,uCAAuC;AAErE,MAAM,gBAAgB,GAAgD,CACpE,KAAc,EACd,EAAE;IACF,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,eAAe,GACnB,kBAAkB,CAAC,sBAAsB,CAAC,KAAK,CAAC;QAChD,kBAAkB,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAC1C,kBAAkB,CAAC,4BAA4B,CAAC,KAAK,CAAC;QAC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,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,cAAc,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,4CAA4C;QAC5C,UAAU,CAAC,GAAG,EAAE;YACd,cAAc,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC,EAAE,iBAAiB,CAAC,CAAA;IACvB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,oBAAC,UAAU,oBACL,IAAI,IACR,QAAQ,EAAE,iBAAiB,EAC3B,uBAAuB,EACrB,CAAC,gBAAgB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,EAEzD,KAAK,EACH,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACX,oBAAC,UAAU,IACT,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,SAAS,EAAE,IAAI,CAAC,SAAS,GACzB,CACH,CAAC,CAAC,CAAC,IAAI,KAGT,CAAC,UAA8B,EAAE,EAAE;QAClC,OAAO,CACL,oBAAC,aAAa,oBACR,UAAU,IACd,aAAa,EAAE,iBAAiB,EAChC,aAAa,EAAE,iBAAiB,IAChC,CACH,CAAA;IACH,CAAC,CACU,CACd,CAAA;AACH,CAAC,CAAA;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;AAE3C,eAAe,aAAa,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RadioProps, RadioGroupProps } from '@toptal/picasso';
|
|
2
|
-
import { FieldProps } from '../
|
|
2
|
+
import { FieldProps } from '../Field';
|
|
3
3
|
export declare type Props = RadioGroupProps & FieldProps<RadioProps['value']>;
|
|
4
4
|
export declare const RadioGroup: {
|
|
5
5
|
(props: Props): JSX.Element;
|