@itcase/forms 1.1.52 → 1.1.53
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/itcase-forms.cjs.js
CHANGED
|
@@ -16,6 +16,7 @@ var Chips = require('@itcase/ui/components/Chips');
|
|
|
16
16
|
var Choice = require('@itcase/ui/components/Choice');
|
|
17
17
|
var Code = require('@itcase/ui/components/Code');
|
|
18
18
|
var Icon = require('@itcase/ui/components/Icon');
|
|
19
|
+
var Dadata = require('@itcase/ui/components/Dadata');
|
|
19
20
|
var DatePicker = require('@itcase/ui/components/DatePicker');
|
|
20
21
|
var useDevicePropsGenerator = require('@itcase/ui/hooks/useDevicePropsGenerator');
|
|
21
22
|
var axios = require('axios');
|
|
@@ -27,6 +28,7 @@ var Button = require('@itcase/ui/components/Button');
|
|
|
27
28
|
var Loader = require('@itcase/ui/components/Loader');
|
|
28
29
|
var Title = require('@itcase/ui/components/Title');
|
|
29
30
|
var Input = require('@itcase/ui/components/Input');
|
|
31
|
+
var InputNumber = require('@itcase/ui/components/InputNumber');
|
|
30
32
|
var reactImask = require('react-imask');
|
|
31
33
|
var InputPassword = require('@itcase/ui/components/InputPassword');
|
|
32
34
|
var Radio = require('@itcase/ui/components/Radio');
|
|
@@ -34,7 +36,6 @@ var Segmented = require('@itcase/ui/components/Segmented');
|
|
|
34
36
|
var Select = require('@itcase/ui/components/Select');
|
|
35
37
|
var Switch = require('@itcase/ui/components/Switch');
|
|
36
38
|
var Textarea = require('@itcase/ui/components/Textarea');
|
|
37
|
-
var Dadata = require('@itcase/ui/components/Dadata');
|
|
38
39
|
var Group = require('@itcase/ui/components/Group');
|
|
39
40
|
var Notification = require('@itcase/ui/components/Notification');
|
|
40
41
|
var createDecorator = require('final-form-focus');
|
|
@@ -898,6 +899,102 @@ const FormFieldCustom = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
898
899
|
});
|
|
899
900
|
});
|
|
900
901
|
|
|
902
|
+
const defaultDadataInputProps = {
|
|
903
|
+
appearance: 'defaultPrimary sizeM solid rounded',
|
|
904
|
+
// useValidationAppearanceInputProps
|
|
905
|
+
// Error
|
|
906
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
907
|
+
// Success
|
|
908
|
+
successAppearance: 'successPrimary sizeM solid rounded',
|
|
909
|
+
// Required
|
|
910
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
const FormFieldDadataInput = /*#__PURE__*/React__default.default.memo(function FormFieldDadataInput(props) {
|
|
914
|
+
const {
|
|
915
|
+
name,
|
|
916
|
+
initialValue,
|
|
917
|
+
isDisabled,
|
|
918
|
+
classNameGroupItem,
|
|
919
|
+
fieldProps,
|
|
920
|
+
inputProps,
|
|
921
|
+
parse,
|
|
922
|
+
showMessage,
|
|
923
|
+
token,
|
|
924
|
+
isRequired,
|
|
925
|
+
onDadataAutocomplete
|
|
926
|
+
} = props;
|
|
927
|
+
if (process.env.NODE_ENV === 'development') {
|
|
928
|
+
const hint = `Check your form config at field "${name}".`;
|
|
929
|
+
if (!token) {
|
|
930
|
+
const message = `FormFieldDadataInput: 'token' prop is missing, instead got ${token}.`;
|
|
931
|
+
throw new Error(message + '\n' + hint);
|
|
932
|
+
}
|
|
933
|
+
if (!onDadataAutocomplete) {
|
|
934
|
+
const message = `FormFieldDadataInput: 'onDadataAutocomplete' prop is missing, instead got ${onDadataAutocomplete}.`;
|
|
935
|
+
throw new Error(message + '\n' + hint);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
939
|
+
name: name,
|
|
940
|
+
initialValue: initialValue,
|
|
941
|
+
parse: parse
|
|
942
|
+
}, function Render({
|
|
943
|
+
input,
|
|
944
|
+
meta
|
|
945
|
+
}) {
|
|
946
|
+
/** Note:
|
|
947
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
948
|
+
* React Hooks cannot be called inside a callback.
|
|
949
|
+
* React Hooks must be called in a React function component or a
|
|
950
|
+
* custom React Hook function.
|
|
951
|
+
*/
|
|
952
|
+
|
|
953
|
+
const {
|
|
954
|
+
errorKey,
|
|
955
|
+
errorMessage,
|
|
956
|
+
isErrorState,
|
|
957
|
+
successKey,
|
|
958
|
+
isValidState
|
|
959
|
+
} = useFieldValidationState({
|
|
960
|
+
fieldProps: fieldProps,
|
|
961
|
+
input: input,
|
|
962
|
+
meta: meta
|
|
963
|
+
});
|
|
964
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
965
|
+
inputProps: inputProps,
|
|
966
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
967
|
+
});
|
|
968
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
969
|
+
className: clsx__default.default('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
|
|
970
|
+
errorKey: errorKey,
|
|
971
|
+
errorMessage: errorMessage,
|
|
972
|
+
isErrorState: isErrorState,
|
|
973
|
+
metaError: meta.error,
|
|
974
|
+
isDisabled: isDisabled,
|
|
975
|
+
fieldClassName: "form-dadata",
|
|
976
|
+
inputName: input.name,
|
|
977
|
+
inputValue: input.value || '',
|
|
978
|
+
metaActive: meta.active,
|
|
979
|
+
showMessage: showMessage,
|
|
980
|
+
isRequired: isRequired,
|
|
981
|
+
isValidState: isValidState
|
|
982
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Dadata.Dadata
|
|
983
|
+
// dataTestId={`${input.name}FieldInputDadata`}
|
|
984
|
+
// className={clsx(
|
|
985
|
+
// meta.active && 'input-dadata_state_focus',
|
|
986
|
+
// meta.error && meta.touched && `input-dadata_state_${errorKey}`,
|
|
987
|
+
// )}
|
|
988
|
+
, {
|
|
989
|
+
input: input,
|
|
990
|
+
inputProps: updatedInputProps,
|
|
991
|
+
meta: meta,
|
|
992
|
+
setValue: onDadataAutocomplete,
|
|
993
|
+
token: token
|
|
994
|
+
}));
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
|
|
901
998
|
const defaultDatepickerProps = {
|
|
902
999
|
appearance: 'surfacePrimary sizeS',
|
|
903
1000
|
dateFormat: 'dd/MM/yyyy - HH:mm',
|
|
@@ -1747,6 +1844,77 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1747
1844
|
});
|
|
1748
1845
|
});
|
|
1749
1846
|
|
|
1847
|
+
const defaultInputNumberProps = {
|
|
1848
|
+
appearance: 'surfaceSecondary sizeM solid rounded',
|
|
1849
|
+
width: 'fill'
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
const FormFieldInputNumber = /*#__PURE__*/React__default.default.memo(function FormFieldInputNumber(props) {
|
|
1853
|
+
const {
|
|
1854
|
+
type = 'custom',
|
|
1855
|
+
name,
|
|
1856
|
+
initialValue,
|
|
1857
|
+
classNameGroupItem,
|
|
1858
|
+
fieldProps = {},
|
|
1859
|
+
inputProps = {},
|
|
1860
|
+
parse,
|
|
1861
|
+
showMessage,
|
|
1862
|
+
isDisabled,
|
|
1863
|
+
isRequired,
|
|
1864
|
+
onChange
|
|
1865
|
+
} = props;
|
|
1866
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1867
|
+
name: name,
|
|
1868
|
+
initialValue: initialValue,
|
|
1869
|
+
parse: parse
|
|
1870
|
+
}, function Render({
|
|
1871
|
+
input,
|
|
1872
|
+
meta
|
|
1873
|
+
}) {
|
|
1874
|
+
const onChangeField = React.useCallback(event => {
|
|
1875
|
+
input.onChange(event);
|
|
1876
|
+
if (onChange) {
|
|
1877
|
+
onChange(event.target.value);
|
|
1878
|
+
}
|
|
1879
|
+
}, [onChange, input.onChange]);
|
|
1880
|
+
const {
|
|
1881
|
+
errorKey,
|
|
1882
|
+
errorMessage,
|
|
1883
|
+
isErrorState,
|
|
1884
|
+
isValidState
|
|
1885
|
+
} = useFieldValidationState({
|
|
1886
|
+
fieldProps: fieldProps,
|
|
1887
|
+
input: input,
|
|
1888
|
+
meta: meta
|
|
1889
|
+
});
|
|
1890
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1891
|
+
inputProps: inputProps
|
|
1892
|
+
});
|
|
1893
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1894
|
+
className: clsx__default.default('form-field_input-number', 'form__item_input-number', classNameGroupItem),
|
|
1895
|
+
errorKey: errorKey,
|
|
1896
|
+
errorMessage: errorMessage,
|
|
1897
|
+
fieldClassName: "form-input-number",
|
|
1898
|
+
inputName: input.name,
|
|
1899
|
+
inputValue: input.value || '',
|
|
1900
|
+
metaActive: meta.active,
|
|
1901
|
+
metaError: meta.error,
|
|
1902
|
+
showMessage: showMessage,
|
|
1903
|
+
isDisabled: isDisabled,
|
|
1904
|
+
isErrorState: isErrorState,
|
|
1905
|
+
isRequired: isRequired,
|
|
1906
|
+
isValidState: isValidState
|
|
1907
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(InputNumber.InputNumber, Object.assign({
|
|
1908
|
+
className: clsx__default.default(meta.active && 'input_state_focus', (meta.submitFailed || meta.touched) && meta.error && `input_state_${errorKey}`),
|
|
1909
|
+
dataTestId: `${input.name}FieldInputNumber`,
|
|
1910
|
+
type: type,
|
|
1911
|
+
name: input.name,
|
|
1912
|
+
value: input.value || 0,
|
|
1913
|
+
onChange: onChangeField
|
|
1914
|
+
}, updatedInputProps)));
|
|
1915
|
+
});
|
|
1916
|
+
});
|
|
1917
|
+
|
|
1750
1918
|
const FormFieldMaskedInput = /*#__PURE__*/React__default.default.memo(function FormFieldMaskedInput(props) {
|
|
1751
1919
|
const {
|
|
1752
1920
|
name,
|
|
@@ -2411,108 +2579,12 @@ const FormFieldTextarea = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
2411
2579
|
});
|
|
2412
2580
|
});
|
|
2413
2581
|
|
|
2414
|
-
const defaultDadataInputProps = {
|
|
2415
|
-
appearance: 'defaultPrimary sizeM solid rounded',
|
|
2416
|
-
// useValidationAppearanceInputProps
|
|
2417
|
-
// Error
|
|
2418
|
-
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
2419
|
-
// Success
|
|
2420
|
-
successAppearance: 'successPrimary sizeM solid rounded',
|
|
2421
|
-
// Required
|
|
2422
|
-
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
2423
|
-
};
|
|
2424
|
-
|
|
2425
|
-
const FormFieldDadataInput = /*#__PURE__*/React__default.default.memo(function FormFieldDadataInput(props) {
|
|
2426
|
-
const {
|
|
2427
|
-
name,
|
|
2428
|
-
initialValue,
|
|
2429
|
-
isDisabled,
|
|
2430
|
-
classNameGroupItem,
|
|
2431
|
-
fieldProps,
|
|
2432
|
-
inputProps,
|
|
2433
|
-
parse,
|
|
2434
|
-
showMessage,
|
|
2435
|
-
token,
|
|
2436
|
-
isRequired,
|
|
2437
|
-
onDadataAutocomplete
|
|
2438
|
-
} = props;
|
|
2439
|
-
if (process.env.NODE_ENV === 'development') {
|
|
2440
|
-
const hint = `Check your form config at field "${name}".`;
|
|
2441
|
-
if (!token) {
|
|
2442
|
-
const message = `FormFieldDadataInput: 'token' prop is missing, instead got ${token}.`;
|
|
2443
|
-
throw new Error(message + '\n' + hint);
|
|
2444
|
-
}
|
|
2445
|
-
if (!onDadataAutocomplete) {
|
|
2446
|
-
const message = `FormFieldDadataInput: 'onDadataAutocomplete' prop is missing, instead got ${onDadataAutocomplete}.`;
|
|
2447
|
-
throw new Error(message + '\n' + hint);
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
2451
|
-
name: name,
|
|
2452
|
-
initialValue: initialValue,
|
|
2453
|
-
parse: parse
|
|
2454
|
-
}, function Render({
|
|
2455
|
-
input,
|
|
2456
|
-
meta
|
|
2457
|
-
}) {
|
|
2458
|
-
/** Note:
|
|
2459
|
-
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2460
|
-
* React Hooks cannot be called inside a callback.
|
|
2461
|
-
* React Hooks must be called in a React function component or a
|
|
2462
|
-
* custom React Hook function.
|
|
2463
|
-
*/
|
|
2464
|
-
|
|
2465
|
-
const {
|
|
2466
|
-
errorKey,
|
|
2467
|
-
errorMessage,
|
|
2468
|
-
isErrorState,
|
|
2469
|
-
successKey,
|
|
2470
|
-
isValidState
|
|
2471
|
-
} = useFieldValidationState({
|
|
2472
|
-
fieldProps: fieldProps,
|
|
2473
|
-
input: input,
|
|
2474
|
-
meta: meta
|
|
2475
|
-
});
|
|
2476
|
-
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2477
|
-
inputProps: inputProps,
|
|
2478
|
-
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2479
|
-
});
|
|
2480
|
-
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2481
|
-
className: clsx__default.default('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
|
|
2482
|
-
errorKey: errorKey,
|
|
2483
|
-
errorMessage: errorMessage,
|
|
2484
|
-
isErrorState: isErrorState,
|
|
2485
|
-
metaError: meta.error,
|
|
2486
|
-
isDisabled: isDisabled,
|
|
2487
|
-
fieldClassName: "form-dadata",
|
|
2488
|
-
inputName: input.name,
|
|
2489
|
-
inputValue: input.value || '',
|
|
2490
|
-
metaActive: meta.active,
|
|
2491
|
-
showMessage: showMessage,
|
|
2492
|
-
isRequired: isRequired,
|
|
2493
|
-
isValidState: isValidState
|
|
2494
|
-
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Dadata.Dadata
|
|
2495
|
-
// dataTestId={`${input.name}FieldInputDadata`}
|
|
2496
|
-
// className={clsx(
|
|
2497
|
-
// meta.active && 'input-dadata_state_focus',
|
|
2498
|
-
// meta.error && meta.touched && `input-dadata_state_${errorKey}`,
|
|
2499
|
-
// )}
|
|
2500
|
-
, {
|
|
2501
|
-
input: input,
|
|
2502
|
-
inputProps: updatedInputProps,
|
|
2503
|
-
meta: meta,
|
|
2504
|
-
setValue: onDadataAutocomplete,
|
|
2505
|
-
token: token
|
|
2506
|
-
}));
|
|
2507
|
-
});
|
|
2508
|
-
});
|
|
2509
|
-
|
|
2510
2582
|
const formTypes = {
|
|
2583
|
+
custom: 'custom',
|
|
2511
2584
|
password: 'password',
|
|
2512
2585
|
code: 'code',
|
|
2513
2586
|
text: 'text',
|
|
2514
2587
|
textarea: 'textarea',
|
|
2515
|
-
custom: 'custom',
|
|
2516
2588
|
checkbox: 'checkbox',
|
|
2517
2589
|
chips: 'chips',
|
|
2518
2590
|
choice: 'choice',
|
|
@@ -2521,6 +2593,7 @@ const formTypes = {
|
|
|
2521
2593
|
dateRangePicker: 'dateRangePicker',
|
|
2522
2594
|
fileInput: 'fileInput',
|
|
2523
2595
|
group: 'group',
|
|
2596
|
+
inputNumber: 'inputNumber',
|
|
2524
2597
|
maskedInput: 'maskedInput',
|
|
2525
2598
|
radioGroup: 'radioGroup',
|
|
2526
2599
|
segmented: 'segmented',
|
|
@@ -2625,6 +2698,12 @@ function generateField(field, config, props) {
|
|
|
2625
2698
|
key: config.key
|
|
2626
2699
|
}, field, props));
|
|
2627
2700
|
}
|
|
2701
|
+
case formTypes.inputNumber:
|
|
2702
|
+
{
|
|
2703
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldInputNumber, Object.assign({
|
|
2704
|
+
key: config.key
|
|
2705
|
+
}, field, props));
|
|
2706
|
+
}
|
|
2628
2707
|
case formTypes.group:
|
|
2629
2708
|
{
|
|
2630
2709
|
return /*#__PURE__*/React__default.default.createElement(FormBlockGroup, Object.assign({
|
|
@@ -3277,6 +3356,7 @@ exports.FormFieldDadataInput = FormFieldDadataInput;
|
|
|
3277
3356
|
exports.FormFieldDatePicker = FormFieldDatePicker;
|
|
3278
3357
|
exports.FormFieldFileInput = FormFieldFileInput;
|
|
3279
3358
|
exports.FormFieldInput = FormFieldInput;
|
|
3359
|
+
exports.FormFieldInputNumber = FormFieldInputNumber;
|
|
3280
3360
|
exports.FormFieldMaskedInput = FormFieldMaskedInput;
|
|
3281
3361
|
exports.FormFieldPassword = FormFieldPassword;
|
|
3282
3362
|
exports.FormFieldRadioGroup = FormFieldRadioGroup;
|
|
@@ -3299,6 +3379,7 @@ exports.defaultFieldSizeM = defaultFieldSizeM;
|
|
|
3299
3379
|
exports.defaultFieldSizeS = defaultFieldSizeS;
|
|
3300
3380
|
exports.defaultFieldSizeXL = defaultFieldSizeXL;
|
|
3301
3381
|
exports.defaultGroupProps = defaultGroupProps;
|
|
3382
|
+
exports.defaultInputNumberProps = defaultInputNumberProps;
|
|
3302
3383
|
exports.defaultInputProps = defaultInputProps;
|
|
3303
3384
|
exports.defaultPasswordProps = defaultPasswordProps;
|
|
3304
3385
|
exports.defaultRadioProps = defaultRadioProps;
|
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -15,6 +15,7 @@ import { ChipsGroup, Chips } from '@itcase/ui/components/Chips';
|
|
|
15
15
|
import { Choice } from '@itcase/ui/components/Choice';
|
|
16
16
|
import { Code } from '@itcase/ui/components/Code';
|
|
17
17
|
import { Icon } from '@itcase/ui/components/Icon';
|
|
18
|
+
import { Dadata } from '@itcase/ui/components/Dadata';
|
|
18
19
|
import { DatePickerInput } from '@itcase/ui/components/DatePicker';
|
|
19
20
|
import { useDevicePropsGenerator } from '@itcase/ui/hooks/useDevicePropsGenerator';
|
|
20
21
|
import axios from 'axios';
|
|
@@ -26,6 +27,7 @@ import { Button } from '@itcase/ui/components/Button';
|
|
|
26
27
|
import { Loader } from '@itcase/ui/components/Loader';
|
|
27
28
|
import { Title } from '@itcase/ui/components/Title';
|
|
28
29
|
import { Input } from '@itcase/ui/components/Input';
|
|
30
|
+
import { InputNumber } from '@itcase/ui/components/InputNumber';
|
|
29
31
|
import { useIMask } from 'react-imask';
|
|
30
32
|
import { InputPassword } from '@itcase/ui/components/InputPassword';
|
|
31
33
|
import { Radio } from '@itcase/ui/components/Radio';
|
|
@@ -33,7 +35,6 @@ import { Segmented } from '@itcase/ui/components/Segmented';
|
|
|
33
35
|
import { Select } from '@itcase/ui/components/Select';
|
|
34
36
|
import { Switch } from '@itcase/ui/components/Switch';
|
|
35
37
|
import { Textarea } from '@itcase/ui/components/Textarea';
|
|
36
|
-
import { Dadata } from '@itcase/ui/components/Dadata';
|
|
37
38
|
import { Group } from '@itcase/ui/components/Group';
|
|
38
39
|
import { Notification } from '@itcase/ui/components/Notification';
|
|
39
40
|
import createDecorator from 'final-form-focus';
|
|
@@ -887,6 +888,102 @@ const FormFieldCustom = /*#__PURE__*/React.memo(function FormFieldCustom(props)
|
|
|
887
888
|
});
|
|
888
889
|
});
|
|
889
890
|
|
|
891
|
+
const defaultDadataInputProps = {
|
|
892
|
+
appearance: 'defaultPrimary sizeM solid rounded',
|
|
893
|
+
// useValidationAppearanceInputProps
|
|
894
|
+
// Error
|
|
895
|
+
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
896
|
+
// Success
|
|
897
|
+
successAppearance: 'successPrimary sizeM solid rounded',
|
|
898
|
+
// Required
|
|
899
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
const FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput(props) {
|
|
903
|
+
const {
|
|
904
|
+
name,
|
|
905
|
+
initialValue,
|
|
906
|
+
isDisabled,
|
|
907
|
+
classNameGroupItem,
|
|
908
|
+
fieldProps,
|
|
909
|
+
inputProps,
|
|
910
|
+
parse,
|
|
911
|
+
showMessage,
|
|
912
|
+
token,
|
|
913
|
+
isRequired,
|
|
914
|
+
onDadataAutocomplete
|
|
915
|
+
} = props;
|
|
916
|
+
if (process.env.NODE_ENV === 'development') {
|
|
917
|
+
const hint = `Check your form config at field "${name}".`;
|
|
918
|
+
if (!token) {
|
|
919
|
+
const message = `FormFieldDadataInput: 'token' prop is missing, instead got ${token}.`;
|
|
920
|
+
throw new Error(message + '\n' + hint);
|
|
921
|
+
}
|
|
922
|
+
if (!onDadataAutocomplete) {
|
|
923
|
+
const message = `FormFieldDadataInput: 'onDadataAutocomplete' prop is missing, instead got ${onDadataAutocomplete}.`;
|
|
924
|
+
throw new Error(message + '\n' + hint);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return /*#__PURE__*/React.createElement(Field, {
|
|
928
|
+
name: name,
|
|
929
|
+
initialValue: initialValue,
|
|
930
|
+
parse: parse
|
|
931
|
+
}, function Render({
|
|
932
|
+
input,
|
|
933
|
+
meta
|
|
934
|
+
}) {
|
|
935
|
+
/** Note:
|
|
936
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
937
|
+
* React Hooks cannot be called inside a callback.
|
|
938
|
+
* React Hooks must be called in a React function component or a
|
|
939
|
+
* custom React Hook function.
|
|
940
|
+
*/
|
|
941
|
+
|
|
942
|
+
const {
|
|
943
|
+
errorKey,
|
|
944
|
+
errorMessage,
|
|
945
|
+
isErrorState,
|
|
946
|
+
successKey,
|
|
947
|
+
isValidState
|
|
948
|
+
} = useFieldValidationState({
|
|
949
|
+
fieldProps: fieldProps,
|
|
950
|
+
input: input,
|
|
951
|
+
meta: meta
|
|
952
|
+
});
|
|
953
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
954
|
+
inputProps: inputProps,
|
|
955
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
956
|
+
});
|
|
957
|
+
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
958
|
+
className: clsx('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
|
|
959
|
+
errorKey: errorKey,
|
|
960
|
+
errorMessage: errorMessage,
|
|
961
|
+
isErrorState: isErrorState,
|
|
962
|
+
metaError: meta.error,
|
|
963
|
+
isDisabled: isDisabled,
|
|
964
|
+
fieldClassName: "form-dadata",
|
|
965
|
+
inputName: input.name,
|
|
966
|
+
inputValue: input.value || '',
|
|
967
|
+
metaActive: meta.active,
|
|
968
|
+
showMessage: showMessage,
|
|
969
|
+
isRequired: isRequired,
|
|
970
|
+
isValidState: isValidState
|
|
971
|
+
}, fieldProps), /*#__PURE__*/React.createElement(Dadata
|
|
972
|
+
// dataTestId={`${input.name}FieldInputDadata`}
|
|
973
|
+
// className={clsx(
|
|
974
|
+
// meta.active && 'input-dadata_state_focus',
|
|
975
|
+
// meta.error && meta.touched && `input-dadata_state_${errorKey}`,
|
|
976
|
+
// )}
|
|
977
|
+
, {
|
|
978
|
+
input: input,
|
|
979
|
+
inputProps: updatedInputProps,
|
|
980
|
+
meta: meta,
|
|
981
|
+
setValue: onDadataAutocomplete,
|
|
982
|
+
token: token
|
|
983
|
+
}));
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
|
|
890
987
|
const defaultDatepickerProps = {
|
|
891
988
|
appearance: 'surfacePrimary sizeS',
|
|
892
989
|
dateFormat: 'dd/MM/yyyy - HH:mm',
|
|
@@ -1736,6 +1833,77 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
1736
1833
|
});
|
|
1737
1834
|
});
|
|
1738
1835
|
|
|
1836
|
+
const defaultInputNumberProps = {
|
|
1837
|
+
appearance: 'surfaceSecondary sizeM solid rounded',
|
|
1838
|
+
width: 'fill'
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
const FormFieldInputNumber = /*#__PURE__*/React.memo(function FormFieldInputNumber(props) {
|
|
1842
|
+
const {
|
|
1843
|
+
type = 'custom',
|
|
1844
|
+
name,
|
|
1845
|
+
initialValue,
|
|
1846
|
+
classNameGroupItem,
|
|
1847
|
+
fieldProps = {},
|
|
1848
|
+
inputProps = {},
|
|
1849
|
+
parse,
|
|
1850
|
+
showMessage,
|
|
1851
|
+
isDisabled,
|
|
1852
|
+
isRequired,
|
|
1853
|
+
onChange
|
|
1854
|
+
} = props;
|
|
1855
|
+
return /*#__PURE__*/React.createElement(Field, {
|
|
1856
|
+
name: name,
|
|
1857
|
+
initialValue: initialValue,
|
|
1858
|
+
parse: parse
|
|
1859
|
+
}, function Render({
|
|
1860
|
+
input,
|
|
1861
|
+
meta
|
|
1862
|
+
}) {
|
|
1863
|
+
const onChangeField = useCallback(event => {
|
|
1864
|
+
input.onChange(event);
|
|
1865
|
+
if (onChange) {
|
|
1866
|
+
onChange(event.target.value);
|
|
1867
|
+
}
|
|
1868
|
+
}, [onChange, input.onChange]);
|
|
1869
|
+
const {
|
|
1870
|
+
errorKey,
|
|
1871
|
+
errorMessage,
|
|
1872
|
+
isErrorState,
|
|
1873
|
+
isValidState
|
|
1874
|
+
} = useFieldValidationState({
|
|
1875
|
+
fieldProps: fieldProps,
|
|
1876
|
+
input: input,
|
|
1877
|
+
meta: meta
|
|
1878
|
+
});
|
|
1879
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1880
|
+
inputProps: inputProps
|
|
1881
|
+
});
|
|
1882
|
+
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1883
|
+
className: clsx('form-field_input-number', 'form__item_input-number', classNameGroupItem),
|
|
1884
|
+
errorKey: errorKey,
|
|
1885
|
+
errorMessage: errorMessage,
|
|
1886
|
+
fieldClassName: "form-input-number",
|
|
1887
|
+
inputName: input.name,
|
|
1888
|
+
inputValue: input.value || '',
|
|
1889
|
+
metaActive: meta.active,
|
|
1890
|
+
metaError: meta.error,
|
|
1891
|
+
showMessage: showMessage,
|
|
1892
|
+
isDisabled: isDisabled,
|
|
1893
|
+
isErrorState: isErrorState,
|
|
1894
|
+
isRequired: isRequired,
|
|
1895
|
+
isValidState: isValidState
|
|
1896
|
+
}, fieldProps), /*#__PURE__*/React.createElement(InputNumber, Object.assign({
|
|
1897
|
+
className: clsx(meta.active && 'input_state_focus', (meta.submitFailed || meta.touched) && meta.error && `input_state_${errorKey}`),
|
|
1898
|
+
dataTestId: `${input.name}FieldInputNumber`,
|
|
1899
|
+
type: type,
|
|
1900
|
+
name: input.name,
|
|
1901
|
+
value: input.value || 0,
|
|
1902
|
+
onChange: onChangeField
|
|
1903
|
+
}, updatedInputProps)));
|
|
1904
|
+
});
|
|
1905
|
+
});
|
|
1906
|
+
|
|
1739
1907
|
const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInput(props) {
|
|
1740
1908
|
const {
|
|
1741
1909
|
name,
|
|
@@ -2400,108 +2568,12 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
|
|
|
2400
2568
|
});
|
|
2401
2569
|
});
|
|
2402
2570
|
|
|
2403
|
-
const defaultDadataInputProps = {
|
|
2404
|
-
appearance: 'defaultPrimary sizeM solid rounded',
|
|
2405
|
-
// useValidationAppearanceInputProps
|
|
2406
|
-
// Error
|
|
2407
|
-
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
2408
|
-
// Success
|
|
2409
|
-
successAppearance: 'successPrimary sizeM solid rounded',
|
|
2410
|
-
// Required
|
|
2411
|
-
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
2412
|
-
};
|
|
2413
|
-
|
|
2414
|
-
const FormFieldDadataInput = /*#__PURE__*/React.memo(function FormFieldDadataInput(props) {
|
|
2415
|
-
const {
|
|
2416
|
-
name,
|
|
2417
|
-
initialValue,
|
|
2418
|
-
isDisabled,
|
|
2419
|
-
classNameGroupItem,
|
|
2420
|
-
fieldProps,
|
|
2421
|
-
inputProps,
|
|
2422
|
-
parse,
|
|
2423
|
-
showMessage,
|
|
2424
|
-
token,
|
|
2425
|
-
isRequired,
|
|
2426
|
-
onDadataAutocomplete
|
|
2427
|
-
} = props;
|
|
2428
|
-
if (process.env.NODE_ENV === 'development') {
|
|
2429
|
-
const hint = `Check your form config at field "${name}".`;
|
|
2430
|
-
if (!token) {
|
|
2431
|
-
const message = `FormFieldDadataInput: 'token' prop is missing, instead got ${token}.`;
|
|
2432
|
-
throw new Error(message + '\n' + hint);
|
|
2433
|
-
}
|
|
2434
|
-
if (!onDadataAutocomplete) {
|
|
2435
|
-
const message = `FormFieldDadataInput: 'onDadataAutocomplete' prop is missing, instead got ${onDadataAutocomplete}.`;
|
|
2436
|
-
throw new Error(message + '\n' + hint);
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
return /*#__PURE__*/React.createElement(Field, {
|
|
2440
|
-
name: name,
|
|
2441
|
-
initialValue: initialValue,
|
|
2442
|
-
parse: parse
|
|
2443
|
-
}, function Render({
|
|
2444
|
-
input,
|
|
2445
|
-
meta
|
|
2446
|
-
}) {
|
|
2447
|
-
/** Note:
|
|
2448
|
-
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
2449
|
-
* React Hooks cannot be called inside a callback.
|
|
2450
|
-
* React Hooks must be called in a React function component or a
|
|
2451
|
-
* custom React Hook function.
|
|
2452
|
-
*/
|
|
2453
|
-
|
|
2454
|
-
const {
|
|
2455
|
-
errorKey,
|
|
2456
|
-
errorMessage,
|
|
2457
|
-
isErrorState,
|
|
2458
|
-
successKey,
|
|
2459
|
-
isValidState
|
|
2460
|
-
} = useFieldValidationState({
|
|
2461
|
-
fieldProps: fieldProps,
|
|
2462
|
-
input: input,
|
|
2463
|
-
meta: meta
|
|
2464
|
-
});
|
|
2465
|
-
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2466
|
-
inputProps: inputProps,
|
|
2467
|
-
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2468
|
-
});
|
|
2469
|
-
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2470
|
-
className: clsx('form-field_input-dadata', 'form__item_input-dadata', classNameGroupItem),
|
|
2471
|
-
errorKey: errorKey,
|
|
2472
|
-
errorMessage: errorMessage,
|
|
2473
|
-
isErrorState: isErrorState,
|
|
2474
|
-
metaError: meta.error,
|
|
2475
|
-
isDisabled: isDisabled,
|
|
2476
|
-
fieldClassName: "form-dadata",
|
|
2477
|
-
inputName: input.name,
|
|
2478
|
-
inputValue: input.value || '',
|
|
2479
|
-
metaActive: meta.active,
|
|
2480
|
-
showMessage: showMessage,
|
|
2481
|
-
isRequired: isRequired,
|
|
2482
|
-
isValidState: isValidState
|
|
2483
|
-
}, fieldProps), /*#__PURE__*/React.createElement(Dadata
|
|
2484
|
-
// dataTestId={`${input.name}FieldInputDadata`}
|
|
2485
|
-
// className={clsx(
|
|
2486
|
-
// meta.active && 'input-dadata_state_focus',
|
|
2487
|
-
// meta.error && meta.touched && `input-dadata_state_${errorKey}`,
|
|
2488
|
-
// )}
|
|
2489
|
-
, {
|
|
2490
|
-
input: input,
|
|
2491
|
-
inputProps: updatedInputProps,
|
|
2492
|
-
meta: meta,
|
|
2493
|
-
setValue: onDadataAutocomplete,
|
|
2494
|
-
token: token
|
|
2495
|
-
}));
|
|
2496
|
-
});
|
|
2497
|
-
});
|
|
2498
|
-
|
|
2499
2571
|
const formTypes = {
|
|
2572
|
+
custom: 'custom',
|
|
2500
2573
|
password: 'password',
|
|
2501
2574
|
code: 'code',
|
|
2502
2575
|
text: 'text',
|
|
2503
2576
|
textarea: 'textarea',
|
|
2504
|
-
custom: 'custom',
|
|
2505
2577
|
checkbox: 'checkbox',
|
|
2506
2578
|
chips: 'chips',
|
|
2507
2579
|
choice: 'choice',
|
|
@@ -2510,6 +2582,7 @@ const formTypes = {
|
|
|
2510
2582
|
dateRangePicker: 'dateRangePicker',
|
|
2511
2583
|
fileInput: 'fileInput',
|
|
2512
2584
|
group: 'group',
|
|
2585
|
+
inputNumber: 'inputNumber',
|
|
2513
2586
|
maskedInput: 'maskedInput',
|
|
2514
2587
|
radioGroup: 'radioGroup',
|
|
2515
2588
|
segmented: 'segmented',
|
|
@@ -2614,6 +2687,12 @@ function generateField(field, config, props) {
|
|
|
2614
2687
|
key: config.key
|
|
2615
2688
|
}, field, props));
|
|
2616
2689
|
}
|
|
2690
|
+
case formTypes.inputNumber:
|
|
2691
|
+
{
|
|
2692
|
+
return /*#__PURE__*/React.createElement(FormFieldInputNumber, Object.assign({
|
|
2693
|
+
key: config.key
|
|
2694
|
+
}, field, props));
|
|
2695
|
+
}
|
|
2617
2696
|
case formTypes.group:
|
|
2618
2697
|
{
|
|
2619
2698
|
return /*#__PURE__*/React.createElement(FormBlockGroup, Object.assign({
|
|
@@ -3240,4 +3319,4 @@ const getErrorsForFinalForm = error => {
|
|
|
3240
3319
|
return formErrors;
|
|
3241
3320
|
};
|
|
3242
3321
|
|
|
3243
|
-
export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDadataInput, FormFieldDatePicker, FormFieldFileInput, FormFieldInput, FormFieldMaskedInput, FormFieldPassword, FormFieldRadioGroup, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDadataInputProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeL, defaultFieldSizeM, defaultFieldSizeS, defaultFieldSizeXL, defaultGroupProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
|
3322
|
+
export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDadataInput, FormFieldDatePicker, FormFieldFileInput, FormFieldInput, FormFieldInputNumber, FormFieldMaskedInput, FormFieldPassword, FormFieldRadioGroup, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDadataInputProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeL, defaultFieldSizeM, defaultFieldSizeS, defaultFieldSizeXL, defaultGroupProps, defaultInputNumberProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|