@itcase/forms 1.1.51 → 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/css/form/Field/InputNumber/FormFieldInputNumber.css +52 -0
- package/dist/css/styles/main.css +188 -0
- package/dist/itcase-forms.cjs.js +204 -118
- package/dist/itcase-forms.esm.js +203 -119
- package/package.json +9 -9
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';
|
|
@@ -372,12 +373,12 @@ function FieldWrapperBase(props) {
|
|
|
372
373
|
const errorTextWeight = props[`${errorKey}MessageTextWeight`];
|
|
373
374
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
374
375
|
className: clsx(formFieldClass, 'form__item', 'form-field', type && `form-field_type_${type}`, sizeClass, fillClass, shapeClass, isDisabled && `form-field_state_disabled`, isHidden && `form-field_state_hidden`, directionClass, widthClass),
|
|
375
|
-
"data-testid": `${inputName}
|
|
376
|
+
"data-testid": `${inputName}-field`,
|
|
376
377
|
"data-tour": dataTour,
|
|
377
378
|
style: formFieldStyles
|
|
378
379
|
}, before, (label || labelHidden) && /*#__PURE__*/React.createElement("div", {
|
|
379
380
|
className: clsx('form-field__label'),
|
|
380
|
-
"data-testid": `${inputName}
|
|
381
|
+
"data-testid": `${inputName}-field-label`,
|
|
381
382
|
htmlFor: id
|
|
382
383
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
383
384
|
size: labelTextSize,
|
|
@@ -387,7 +388,7 @@ function FieldWrapperBase(props) {
|
|
|
387
388
|
sizeTablet: labelTextSizeTablet
|
|
388
389
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React.createElement("div", {
|
|
389
390
|
className: "form-field__desc",
|
|
390
|
-
"data-testid": `${inputName}
|
|
391
|
+
"data-testid": `${inputName}-field-desc`
|
|
391
392
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
392
393
|
size: descTextSize,
|
|
393
394
|
textColor: descTextColor,
|
|
@@ -404,24 +405,24 @@ function FieldWrapperBase(props) {
|
|
|
404
405
|
fill: dividerFill
|
|
405
406
|
})), showMessage && /*#__PURE__*/React.createElement("div", {
|
|
406
407
|
className: "form-field__message",
|
|
407
|
-
"data-testid": `${inputName}
|
|
408
|
+
"data-testid": `${inputName}-field-message`
|
|
408
409
|
}, isErrorState && errorMessage && /*#__PURE__*/React.createElement(Text, {
|
|
409
410
|
id: `${inputName}-error`,
|
|
410
411
|
className: "form-field__message-item form-field__message-item_type-error",
|
|
411
|
-
dataTestId: `${inputName}
|
|
412
|
+
dataTestId: `${inputName}-field-message-error`,
|
|
412
413
|
size: errorTextSize,
|
|
413
414
|
textColor: errorTextColor,
|
|
414
415
|
textWeight: errorTextWeight
|
|
415
416
|
}, errorMessage), Boolean(helpText) && (!isErrorState || !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
416
417
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
417
|
-
dataTestId: `${inputName}
|
|
418
|
+
dataTestId: `${inputName}-field-message-help-text`,
|
|
418
419
|
size: helpTextSize,
|
|
419
420
|
textColor: isValidState ? helpTextColorSuccess : helpTextColor,
|
|
420
421
|
textWeight: helpTextWeight,
|
|
421
422
|
sizeMobile: helpTextSizeMobile
|
|
422
423
|
}, helpText), (!isErrorState && !helpText || isErrorState && !helpText && !errorMessage) && /*#__PURE__*/React.createElement(Text, {
|
|
423
424
|
className: "form-field__message-item form-field__message-item_type_help-text",
|
|
424
|
-
dataTestId: `${inputName}
|
|
425
|
+
dataTestId: `${inputName}field-message-help-text`,
|
|
425
426
|
size: messageTextSize
|
|
426
427
|
}, '\u00A0')), after);
|
|
427
428
|
}
|
|
@@ -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',
|
|
@@ -1714,7 +1811,7 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
1714
1811
|
isValidState: isValidState
|
|
1715
1812
|
}, fieldProps), /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
1716
1813
|
className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1717
|
-
dataTestId: `${input.name}
|
|
1814
|
+
dataTestId: `${input.name}-field-input`,
|
|
1718
1815
|
type: "text",
|
|
1719
1816
|
name: input.name,
|
|
1720
1817
|
autoComplete: "nope",
|
|
@@ -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,
|
|
@@ -1911,7 +2079,7 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
|
|
|
1911
2079
|
isValidState: isValidState
|
|
1912
2080
|
}, fieldProps), /*#__PURE__*/React.createElement(InputPassword, Object.assign({
|
|
1913
2081
|
className: clsx(meta.active && 'input-password_state_focus', meta.error && meta.touched && `input-password_state_${errorKey}`),
|
|
1914
|
-
dataTestId: `${input.name}
|
|
2082
|
+
dataTestId: `${input.name}-field-input-password`,
|
|
1915
2083
|
name: input.name,
|
|
1916
2084
|
autoComplete: "nope",
|
|
1917
2085
|
value: input.value || '',
|
|
@@ -2337,11 +2505,11 @@ const defaultTextareaProps = {
|
|
|
2337
2505
|
const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(props) {
|
|
2338
2506
|
const {
|
|
2339
2507
|
name,
|
|
2340
|
-
isDisabled,
|
|
2341
2508
|
classNameGroupItem,
|
|
2342
2509
|
fieldProps = {},
|
|
2343
2510
|
inputProps = {},
|
|
2344
2511
|
showMessage,
|
|
2512
|
+
isDisabled,
|
|
2345
2513
|
isRequired
|
|
2346
2514
|
} = props;
|
|
2347
2515
|
return /*#__PURE__*/React.createElement(Field, {
|
|
@@ -2360,8 +2528,8 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
|
|
|
2360
2528
|
const {
|
|
2361
2529
|
errorKey,
|
|
2362
2530
|
errorMessage,
|
|
2363
|
-
isErrorState,
|
|
2364
2531
|
successKey,
|
|
2532
|
+
isErrorState,
|
|
2365
2533
|
isValidState
|
|
2366
2534
|
} = useFieldValidationState({
|
|
2367
2535
|
fieldProps: fieldProps,
|
|
@@ -2376,23 +2544,23 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
|
|
|
2376
2544
|
className: clsx('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
2377
2545
|
errorKey: errorKey,
|
|
2378
2546
|
errorMessage: errorMessage,
|
|
2379
|
-
isErrorState: isErrorState,
|
|
2380
|
-
metaError: meta.error,
|
|
2381
|
-
isDisabled: isDisabled,
|
|
2382
2547
|
fieldClassName: 'form-textarea',
|
|
2383
2548
|
inputName: input.name,
|
|
2384
2549
|
inputValue: input.value,
|
|
2385
2550
|
metaActive: meta.active,
|
|
2551
|
+
metaError: meta.error,
|
|
2386
2552
|
showMessage: showMessage,
|
|
2553
|
+
isDisabled: isDisabled,
|
|
2554
|
+
isErrorState: isErrorState,
|
|
2387
2555
|
isRequired: isRequired,
|
|
2388
2556
|
isValidState: isValidState
|
|
2389
2557
|
}, fieldProps), /*#__PURE__*/React.createElement(Textarea, Object.assign({
|
|
2390
|
-
dataTestId: `${input.name}FieldTextarea`,
|
|
2391
2558
|
className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && `textarea_state_${errorKey}`),
|
|
2559
|
+
dataTestId: `${input.name}-field-textarea`,
|
|
2392
2560
|
name: input.name,
|
|
2393
|
-
isDisabled: isDisabled,
|
|
2394
2561
|
autoComplete: "nope",
|
|
2395
2562
|
value: input.value || '',
|
|
2563
|
+
isDisabled: isDisabled,
|
|
2396
2564
|
onBlur: input.onBlur,
|
|
2397
2565
|
onChange: input.onChange,
|
|
2398
2566
|
onFocus: input.onFocus
|
|
@@ -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({
|
|
@@ -2751,6 +2830,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2751
2830
|
dataTestId,
|
|
2752
2831
|
dataTour,
|
|
2753
2832
|
type,
|
|
2833
|
+
name,
|
|
2754
2834
|
initialValues,
|
|
2755
2835
|
initialValuesEqual,
|
|
2756
2836
|
config,
|
|
@@ -2801,6 +2881,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2801
2881
|
primaryButtonAppearance,
|
|
2802
2882
|
primaryButtonFill,
|
|
2803
2883
|
primaryButtonFillHover,
|
|
2884
|
+
primaryButtonHtmlType,
|
|
2804
2885
|
primaryButtonIsDisabled,
|
|
2805
2886
|
primaryButtonIsLoading,
|
|
2806
2887
|
primaryButtonLabel,
|
|
@@ -2808,6 +2889,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2808
2889
|
primaryButtonLabelTextColor,
|
|
2809
2890
|
primaryButtonLabelTextWeight,
|
|
2810
2891
|
primaryButtonSize,
|
|
2892
|
+
primarySecondaryHtmlType,
|
|
2811
2893
|
renderFieldsWrapper = wrapperChildren => wrapperChildren,
|
|
2812
2894
|
secondaryButton,
|
|
2813
2895
|
secondaryButtonAppearance,
|
|
@@ -2866,14 +2948,14 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2866
2948
|
}) => {
|
|
2867
2949
|
return /*#__PURE__*/React.createElement("form", {
|
|
2868
2950
|
className: clsx(className, 'form', type && `form_type_${type}`, widthClass && `width_${widthClass}`, heightClass && `height_${heightClass}`, titlePosition && `form_title-position_${titlePosition}`, buttonPosition && `form_button-position_${buttonPosition}`, directionClass && `direction_${directionClass}`, fillClass && `fill_${fillClass}`, shapeClass && `shape_${shapeClass}`, shapeStrengthClass && `shape-strength_${shapeStrengthClass}`, elevationClass && `elevation_${elevationClass}`),
|
|
2869
|
-
name: formName
|
|
2951
|
+
name: formName || 'form'
|
|
2870
2952
|
// We no need set reference to html element, we need reference to "final-form" instance
|
|
2871
2953
|
,
|
|
2872
2954
|
ref: () => onRefFormInstance(form),
|
|
2873
2955
|
autoCapitalize: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2874
2956
|
autoComplete: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2875
2957
|
autoCorrect: disableFieldsAutoComplete ? 'off' : undefined,
|
|
2876
|
-
"data-testid": dataTestId,
|
|
2958
|
+
"data-testid": dataTestId || name,
|
|
2877
2959
|
"data-tour": dataTour,
|
|
2878
2960
|
spellCheck: disableFieldsAutoComplete ? 'false' : undefined,
|
|
2879
2961
|
style: formStyles,
|
|
@@ -2930,7 +3012,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2930
3012
|
}, primaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
2931
3013
|
appearance: primaryButtonAppearance,
|
|
2932
3014
|
className: "form__button-item",
|
|
2933
|
-
dataTestId: dataTestIdPrimaryButton,
|
|
3015
|
+
dataTestId: dataTestIdPrimaryButton || (name ? `${name}-primary` : 'form-primary'),
|
|
2934
3016
|
dataTour: dataTourPrimaryButton,
|
|
2935
3017
|
width: "fill",
|
|
2936
3018
|
size: primaryButtonSize,
|
|
@@ -2940,12 +3022,13 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2940
3022
|
labelTextColor: primaryButtonLabelTextColor,
|
|
2941
3023
|
labelTextSize: primaryButtonLabelSize,
|
|
2942
3024
|
labelTextWeight: primaryButtonLabelTextWeight,
|
|
3025
|
+
htmlType: primaryButtonHtmlType || 'submit',
|
|
2943
3026
|
loading: primaryButtonIsLoading,
|
|
2944
3027
|
isDisabled: primaryButtonIsDisabled
|
|
2945
3028
|
}) : primaryButton, secondaryButtonLabel ? /*#__PURE__*/React.createElement(Button, {
|
|
2946
3029
|
appearance: secondaryButtonAppearance,
|
|
2947
3030
|
className: "form__button-item",
|
|
2948
|
-
dataTestId: dataTestIdSecondaryButton,
|
|
3031
|
+
dataTestId: dataTestIdSecondaryButton || (name ? `${name}-secondary` : 'form-secondary'),
|
|
2949
3032
|
dataTour: dataTourSecondaryButton,
|
|
2950
3033
|
width: "fill",
|
|
2951
3034
|
size: secondaryButtonSize,
|
|
@@ -2955,6 +3038,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2955
3038
|
labelTextColor: secondaryButtonLabelTextColor,
|
|
2956
3039
|
labelTextSize: secondaryButtonLabelSize,
|
|
2957
3040
|
labelTextWeight: secondaryButtonLabelTextWeight,
|
|
3041
|
+
htmlType: primarySecondaryHtmlType,
|
|
2958
3042
|
loading: secondaryButtonIsLoading,
|
|
2959
3043
|
isDisabled: secondaryButtonIsDisabled,
|
|
2960
3044
|
onClick: onClickSecondaryButton
|
|
@@ -3235,4 +3319,4 @@ const getErrorsForFinalForm = error => {
|
|
|
3235
3319
|
return formErrors;
|
|
3236
3320
|
};
|
|
3237
3321
|
|
|
3238
|
-
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/forms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.53",
|
|
4
4
|
"description": "Forms fields, inputs, etc.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build-css": "rm -rf dist/css && postcss 'src/form/**/!(css)/!(*.tokens.css)*.css' 'src/styles/!(.css)/**/*.css' 'src/styles/main.css' --base src --dir dist/css/ --env production",
|
|
14
14
|
"dev-js": "rollup -c -w",
|
|
15
15
|
"dev-css": "postcss 'src/form/**/!(css)/!(*.tokens.css)*.css' 'src/styles/!(.css)/**/*.css' 'src/styles/main.css' --base src --dir dist/css/ --env production -w --verbose",
|
|
16
|
-
"prepare": "
|
|
16
|
+
"prepare": "husky",
|
|
17
17
|
"prepack": "npm run build",
|
|
18
18
|
"semantic-release": "semantic-release",
|
|
19
19
|
"storybook": "storybook dev -p 6006",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@itcase/common": "^1.2.34",
|
|
36
|
-
"@itcase/config": "^1.0.
|
|
36
|
+
"@itcase/config": "^1.0.79",
|
|
37
37
|
"@itcase/icons": "^1.2.28",
|
|
38
38
|
"@itcase/storybook-config": "^1.2.29",
|
|
39
|
-
"@itcase/tokens-am": "^1.1.
|
|
40
|
-
"@itcase/tokens-baikal": "^1.1.
|
|
41
|
-
"@itcase/ui": "^1.9.
|
|
39
|
+
"@itcase/tokens-am": "^1.1.39",
|
|
40
|
+
"@itcase/tokens-baikal": "^1.1.39",
|
|
41
|
+
"@itcase/ui": "^1.9.35",
|
|
42
42
|
"axios": "^1.13.2",
|
|
43
43
|
"clsx": "^2.1.1",
|
|
44
44
|
"final-form": "4.20.10",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"luxon": "^3.7.2",
|
|
49
49
|
"react": "^18.3.1",
|
|
50
50
|
"react-date-range": "^2.0.1",
|
|
51
|
-
"react-datepicker": "^
|
|
51
|
+
"react-datepicker": "^9.0.0",
|
|
52
52
|
"react-dom": "^18.3.1",
|
|
53
53
|
"react-dropzone": "^14.3.8",
|
|
54
54
|
"react-final-form": "6.5.9",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
75
75
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
76
76
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
77
|
-
"eslint": "9.39.
|
|
77
|
+
"eslint": "9.39.2",
|
|
78
78
|
"husky": "^9.1.7",
|
|
79
79
|
"lint-staged": "^16.2.7",
|
|
80
80
|
"postcss": "^8.5.6",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"rollup": "^4.53.3",
|
|
83
83
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
84
84
|
"semantic-release": "^25.0.2",
|
|
85
|
-
"storybook": "^10.1.
|
|
85
|
+
"storybook": "^10.1.9",
|
|
86
86
|
"stylelint": "^16.26.1",
|
|
87
87
|
"typescript": "^5.9.3",
|
|
88
88
|
"yup": "^1.7.1"
|