@itcase/forms 1.1.32 → 1.1.34
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/Checkbox/FormFieldCheckbox.css +0 -1
- package/dist/css/form/Field/MaskedInput/FormFieldMaskedInput.css +2 -10
- package/dist/css/form/Field/RadioGroup/RadioGroup.css +0 -6
- package/dist/css/form/Field/Switch/FormFieldSwitch.css +1 -1
- package/dist/itcase-forms.cjs.js +200 -205
- package/dist/itcase-forms.esm.js +200 -205
- package/package.json +7 -7
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -218,8 +218,10 @@ function useValidationAppearanceInputProps(props) {
|
|
|
218
218
|
updatedInputProps[propKey] = propValue;
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
|
+
return updatedInputProps;
|
|
222
|
+
} else {
|
|
223
|
+
return inputProps;
|
|
221
224
|
}
|
|
222
|
-
return updatedInputProps;
|
|
223
225
|
}, [validationStateKey, inputProps]);
|
|
224
226
|
return validationAppearanceInputProps;
|
|
225
227
|
}
|
|
@@ -373,8 +375,8 @@ function FieldWrapperBase(props) {
|
|
|
373
375
|
sizeMobile: labelTextSizeMobile,
|
|
374
376
|
sizeTablet: labelTextSizeTablet
|
|
375
377
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React.createElement("div", {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
+
dataTestId: `${inputName}FieldDesc`,
|
|
379
|
+
className: "form-field__desc"
|
|
378
380
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
379
381
|
size: descTextSize,
|
|
380
382
|
textColor: descTextColor,
|
|
@@ -1093,6 +1095,7 @@ const FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(pro
|
|
|
1093
1095
|
errorKey,
|
|
1094
1096
|
errorMessage,
|
|
1095
1097
|
isErrorState,
|
|
1098
|
+
successKey,
|
|
1096
1099
|
isValidState
|
|
1097
1100
|
} = useFieldValidationState({
|
|
1098
1101
|
fieldProps: fieldProps,
|
|
@@ -1101,7 +1104,7 @@ const FormFieldCheckbox = /*#__PURE__*/React.memo(function FormFieldCheckbox(pro
|
|
|
1101
1104
|
});
|
|
1102
1105
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1103
1106
|
inputProps: inputProps,
|
|
1104
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1107
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1105
1108
|
});
|
|
1106
1109
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1107
1110
|
className: clsx('form-field-checkbox', 'form__item_checkbox', classNameGroupItem),
|
|
@@ -1140,6 +1143,8 @@ const defaultChipsProps = {
|
|
|
1140
1143
|
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
1141
1144
|
// Required
|
|
1142
1145
|
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
1146
|
+
// Success
|
|
1147
|
+
// successAppearance: 'successPrimary sizeM solid rounded',
|
|
1143
1148
|
};
|
|
1144
1149
|
|
|
1145
1150
|
function FormFieldChips(props) {
|
|
@@ -1184,6 +1189,7 @@ function FormFieldChips(props) {
|
|
|
1184
1189
|
errorKey,
|
|
1185
1190
|
errorMessage,
|
|
1186
1191
|
isErrorState,
|
|
1192
|
+
successKey,
|
|
1187
1193
|
isValidState
|
|
1188
1194
|
} = useFieldValidationState({
|
|
1189
1195
|
fieldProps: fieldProps,
|
|
@@ -1192,7 +1198,7 @@ function FormFieldChips(props) {
|
|
|
1192
1198
|
});
|
|
1193
1199
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1194
1200
|
inputProps: inputProps,
|
|
1195
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1201
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1196
1202
|
});
|
|
1197
1203
|
const activeOptionsList = useMemo(() => {
|
|
1198
1204
|
const emptyOptionsList = [{
|
|
@@ -1253,11 +1259,11 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
|
|
|
1253
1259
|
name,
|
|
1254
1260
|
initialValue,
|
|
1255
1261
|
label,
|
|
1262
|
+
messageType,
|
|
1256
1263
|
isDisabled,
|
|
1257
1264
|
classNameGroupItem,
|
|
1258
1265
|
fieldProps,
|
|
1259
1266
|
inputProps,
|
|
1260
|
-
messageType,
|
|
1261
1267
|
options,
|
|
1262
1268
|
placeholder,
|
|
1263
1269
|
showMessage,
|
|
@@ -1299,10 +1305,11 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
|
|
|
1299
1305
|
return emptyOption;
|
|
1300
1306
|
}, [input.value]);
|
|
1301
1307
|
const {
|
|
1302
|
-
isErrorState,
|
|
1303
|
-
isValidState,
|
|
1304
1308
|
errorKey,
|
|
1305
|
-
errorMessage
|
|
1309
|
+
errorMessage,
|
|
1310
|
+
isErrorState,
|
|
1311
|
+
successKey,
|
|
1312
|
+
isValidState
|
|
1306
1313
|
} = useFieldValidationState({
|
|
1307
1314
|
fieldProps: fieldProps,
|
|
1308
1315
|
input: input,
|
|
@@ -1310,7 +1317,7 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
|
|
|
1310
1317
|
});
|
|
1311
1318
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1312
1319
|
inputProps: inputProps,
|
|
1313
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1320
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1314
1321
|
});
|
|
1315
1322
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1316
1323
|
className: clsx('form-field_choice', 'form__item_choice', classNameGroupItem),
|
|
@@ -1336,9 +1343,9 @@ const FormFieldChoice = /*#__PURE__*/React.memo(function FormFieldChoice(props)
|
|
|
1336
1343
|
inputValue: input.value || [],
|
|
1337
1344
|
options: options,
|
|
1338
1345
|
placeholder: placeholder,
|
|
1346
|
+
setActiveSegment: setActiveSegment,
|
|
1339
1347
|
isCheckbox: isCheckbox,
|
|
1340
|
-
isRequired: isRequired
|
|
1341
|
-
setActiveSegment: setActiveSegment
|
|
1348
|
+
isRequired: isRequired
|
|
1342
1349
|
}, updatedInputProps)));
|
|
1343
1350
|
});
|
|
1344
1351
|
});
|
|
@@ -1356,6 +1363,8 @@ const FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
|
1356
1363
|
const {
|
|
1357
1364
|
name,
|
|
1358
1365
|
initialValue,
|
|
1366
|
+
messageType,
|
|
1367
|
+
label,
|
|
1359
1368
|
isDisabled,
|
|
1360
1369
|
classNameGroupItem,
|
|
1361
1370
|
fieldProps = {},
|
|
@@ -1378,19 +1387,27 @@ const FormFieldCode = /*#__PURE__*/React.memo(function FormFieldCode(props) {
|
|
|
1378
1387
|
*/
|
|
1379
1388
|
|
|
1380
1389
|
const {
|
|
1390
|
+
errorKey,
|
|
1391
|
+
errorMessage,
|
|
1381
1392
|
isErrorState,
|
|
1382
|
-
|
|
1383
|
-
|
|
1393
|
+
successKey,
|
|
1394
|
+
isValidState
|
|
1395
|
+
} = useFieldValidationState({
|
|
1384
1396
|
fieldProps: fieldProps,
|
|
1385
1397
|
input: input,
|
|
1386
1398
|
meta: meta
|
|
1387
1399
|
});
|
|
1388
1400
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1389
1401
|
inputProps: inputProps,
|
|
1390
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1402
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1391
1403
|
});
|
|
1392
1404
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1393
1405
|
className: clsx('form-field-code', 'form__item_code', classNameGroupItem),
|
|
1406
|
+
label: label,
|
|
1407
|
+
messageType: messageType,
|
|
1408
|
+
errorKey: errorKey,
|
|
1409
|
+
errorMessage: errorMessage,
|
|
1410
|
+
isErrorState: isErrorState,
|
|
1394
1411
|
fieldClassName: 'form-code',
|
|
1395
1412
|
inputName: input.name,
|
|
1396
1413
|
inputValue: input.value,
|
|
@@ -1545,6 +1562,7 @@ function FormFieldDatePicker(props) {
|
|
|
1545
1562
|
errorKey,
|
|
1546
1563
|
errorMessage,
|
|
1547
1564
|
isErrorState,
|
|
1565
|
+
successKey,
|
|
1548
1566
|
isValidState
|
|
1549
1567
|
} = useFieldValidationState({
|
|
1550
1568
|
fieldProps: fieldProps,
|
|
@@ -1553,7 +1571,7 @@ function FormFieldDatePicker(props) {
|
|
|
1553
1571
|
});
|
|
1554
1572
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1555
1573
|
inputProps: inputProps,
|
|
1556
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1574
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1557
1575
|
});
|
|
1558
1576
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1559
1577
|
className: clsx('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
|
|
@@ -1590,7 +1608,9 @@ const defaultInputProps = {
|
|
|
1590
1608
|
// Error
|
|
1591
1609
|
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
1592
1610
|
// Required
|
|
1593
|
-
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
1611
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded',
|
|
1612
|
+
// Success
|
|
1613
|
+
successAppearance: 'successPrimary sizeM solid rounded'
|
|
1594
1614
|
};
|
|
1595
1615
|
|
|
1596
1616
|
const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
@@ -1640,6 +1660,7 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
1640
1660
|
errorKey,
|
|
1641
1661
|
errorMessage,
|
|
1642
1662
|
isErrorState,
|
|
1663
|
+
successKey,
|
|
1643
1664
|
isValidState
|
|
1644
1665
|
} = useFieldValidationState({
|
|
1645
1666
|
fieldProps: fieldProps,
|
|
@@ -1648,7 +1669,7 @@ const FormFieldInput = /*#__PURE__*/React.memo(function FormFieldInput(props) {
|
|
|
1648
1669
|
});
|
|
1649
1670
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1650
1671
|
inputProps: inputProps,
|
|
1651
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1672
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1652
1673
|
});
|
|
1653
1674
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1654
1675
|
className: clsx('form-field_input', 'form__item_input', classNameGroupItem),
|
|
@@ -1745,6 +1766,7 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
|
|
|
1745
1766
|
errorKey,
|
|
1746
1767
|
errorMessage,
|
|
1747
1768
|
isErrorState,
|
|
1769
|
+
successKey,
|
|
1748
1770
|
isValidState
|
|
1749
1771
|
} = useFieldValidationState({
|
|
1750
1772
|
fieldProps: fieldProps,
|
|
@@ -1753,7 +1775,7 @@ const FormFieldPassword = /*#__PURE__*/React.memo(function FormFieldPassword(pro
|
|
|
1753
1775
|
});
|
|
1754
1776
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1755
1777
|
inputProps: inputProps,
|
|
1756
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1778
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1757
1779
|
});
|
|
1758
1780
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1759
1781
|
className: clsx('form-field_input', 'form__item_input', classNameGroupItem),
|
|
@@ -1844,6 +1866,7 @@ function FormFieldSegmented(props) {
|
|
|
1844
1866
|
errorKey,
|
|
1845
1867
|
errorMessage,
|
|
1846
1868
|
isErrorState,
|
|
1869
|
+
successKey,
|
|
1847
1870
|
isValidState
|
|
1848
1871
|
} = useFieldValidationState({
|
|
1849
1872
|
fieldProps: fieldProps,
|
|
@@ -1852,7 +1875,7 @@ function FormFieldSegmented(props) {
|
|
|
1852
1875
|
});
|
|
1853
1876
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1854
1877
|
inputProps: inputProps,
|
|
1855
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1878
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1856
1879
|
});
|
|
1857
1880
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1858
1881
|
className: clsx('form-field_segmented', 'form__item_segmented'),
|
|
@@ -1958,10 +1981,11 @@ const FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props)
|
|
|
1958
1981
|
setSelectedOptions(defaultValue);
|
|
1959
1982
|
}, [defaultValue]);
|
|
1960
1983
|
const {
|
|
1961
|
-
isErrorState,
|
|
1962
|
-
isValidState,
|
|
1963
1984
|
errorKey,
|
|
1964
|
-
errorMessage
|
|
1985
|
+
errorMessage,
|
|
1986
|
+
isErrorState,
|
|
1987
|
+
successKey,
|
|
1988
|
+
isValidState
|
|
1965
1989
|
} = useFieldValidationState({
|
|
1966
1990
|
fieldProps: fieldProps,
|
|
1967
1991
|
input: input,
|
|
@@ -1969,7 +1993,7 @@ const FormFieldSelect = /*#__PURE__*/React.memo(function FormFieldSelect(props)
|
|
|
1969
1993
|
});
|
|
1970
1994
|
const updatedSelectProps = useValidationAppearanceInputProps({
|
|
1971
1995
|
inputProps: selectProps,
|
|
1972
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1996
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1973
1997
|
});
|
|
1974
1998
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
1975
1999
|
className: clsx('form-field_select', 'form__item_select', classNameGroupItem),
|
|
@@ -2042,6 +2066,7 @@ const FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props)
|
|
|
2042
2066
|
errorKey,
|
|
2043
2067
|
errorMessage,
|
|
2044
2068
|
isErrorState,
|
|
2069
|
+
successKey,
|
|
2045
2070
|
isValidState
|
|
2046
2071
|
} = useFieldValidationState({
|
|
2047
2072
|
fieldProps: fieldProps,
|
|
@@ -2050,7 +2075,7 @@ const FormFieldSwitch = /*#__PURE__*/React.memo(function FormFieldSwitch(props)
|
|
|
2050
2075
|
});
|
|
2051
2076
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2052
2077
|
inputProps: inputProps,
|
|
2053
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2078
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2054
2079
|
});
|
|
2055
2080
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2056
2081
|
className: clsx('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
@@ -2116,6 +2141,7 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
|
|
|
2116
2141
|
errorKey,
|
|
2117
2142
|
errorMessage,
|
|
2118
2143
|
isErrorState,
|
|
2144
|
+
successKey,
|
|
2119
2145
|
isValidState
|
|
2120
2146
|
} = useFieldValidationState({
|
|
2121
2147
|
fieldProps: fieldProps,
|
|
@@ -2124,7 +2150,7 @@ const FormFieldTextarea = /*#__PURE__*/React.memo(function FormFieldTextarea(pro
|
|
|
2124
2150
|
});
|
|
2125
2151
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2126
2152
|
inputProps: inputProps,
|
|
2127
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2153
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2128
2154
|
});
|
|
2129
2155
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2130
2156
|
className: clsx('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
@@ -2208,6 +2234,7 @@ const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInp
|
|
|
2208
2234
|
errorKey,
|
|
2209
2235
|
errorMessage,
|
|
2210
2236
|
isErrorState,
|
|
2237
|
+
successKey,
|
|
2211
2238
|
isValidState
|
|
2212
2239
|
} = useFieldValidationState({
|
|
2213
2240
|
fieldProps: fieldProps,
|
|
@@ -2216,10 +2243,10 @@ const FormFieldMaskedInput = /*#__PURE__*/React.memo(function FormFieldMaskedInp
|
|
|
2216
2243
|
});
|
|
2217
2244
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2218
2245
|
inputProps: inputProps,
|
|
2219
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2246
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2220
2247
|
});
|
|
2221
2248
|
return /*#__PURE__*/React.createElement(FieldWrapper, Object.assign({
|
|
2222
|
-
className: clsx('form-
|
|
2249
|
+
className: clsx('form-field-masked-input', 'form__item_masked-input', classNameGroupItem),
|
|
2223
2250
|
errorKey: errorKey,
|
|
2224
2251
|
errorMessage: errorMessage,
|
|
2225
2252
|
isErrorState: isErrorState,
|
|
@@ -2255,75 +2282,13 @@ const defaultRadioProps = {
|
|
|
2255
2282
|
appearance: 'defaultPrimary sizeM solid circular'
|
|
2256
2283
|
};
|
|
2257
2284
|
|
|
2258
|
-
function RadioGroupInput(props) {
|
|
2259
|
-
const {
|
|
2260
|
-
input,
|
|
2261
|
-
value,
|
|
2262
|
-
onChange
|
|
2263
|
-
} = props;
|
|
2264
|
-
const onChangeField = useCallback(event => onChange(event.target.value), [onChange]);
|
|
2265
|
-
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
2266
|
-
name: input.name,
|
|
2267
|
-
autoComplete: "nope",
|
|
2268
|
-
value: value,
|
|
2269
|
-
onBlur: input.onBlur,
|
|
2270
|
-
onChange: onChangeField,
|
|
2271
|
-
onFocus: input.onFocus
|
|
2272
|
-
}, props));
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
function RadioGroupItem(props) {
|
|
2276
|
-
const {
|
|
2277
|
-
input,
|
|
2278
|
-
inputProps,
|
|
2279
|
-
option,
|
|
2280
|
-
onChange
|
|
2281
|
-
} = props;
|
|
2282
|
-
const onChangeField = useCallback(event => {
|
|
2283
|
-
if (event.target.checked) {
|
|
2284
|
-
onChange(option.value);
|
|
2285
|
-
}
|
|
2286
|
-
}, [onChange]);
|
|
2287
|
-
return /*#__PURE__*/React.createElement(Radio, Object.assign({
|
|
2288
|
-
className: "form-radio__item",
|
|
2289
|
-
type: "radio",
|
|
2290
|
-
name: input.name,
|
|
2291
|
-
label: option.label,
|
|
2292
|
-
checked: option.value === input.value,
|
|
2293
|
-
value: option.value,
|
|
2294
|
-
onBlur: input.onBlur,
|
|
2295
|
-
onChange: onChangeField,
|
|
2296
|
-
onFocus: input.onFocus
|
|
2297
|
-
}, inputProps));
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
2285
|
function RadioGroupList(props) {
|
|
2301
2286
|
const {
|
|
2302
|
-
editableProps,
|
|
2303
2287
|
input,
|
|
2304
2288
|
inputProps,
|
|
2305
2289
|
options,
|
|
2306
2290
|
onChange
|
|
2307
2291
|
} = props;
|
|
2308
|
-
const [editableValue, setEditableValue] = useState(() => {
|
|
2309
|
-
const isRadioValue = options.find(option => option.value === input.value);
|
|
2310
|
-
if (!isRadioValue) {
|
|
2311
|
-
return input.value;
|
|
2312
|
-
}
|
|
2313
|
-
return '';
|
|
2314
|
-
});
|
|
2315
|
-
useEffect(() => {
|
|
2316
|
-
// When a new value from outside enters the form
|
|
2317
|
-
if (input.value) {
|
|
2318
|
-
// Check value for radio type
|
|
2319
|
-
const isRadioValue = options.find(option => option.value === input.value && !option.editable);
|
|
2320
|
-
// If new value not in radio list - set to editable input
|
|
2321
|
-
setEditableValue(isRadioValue ? '' : input.value);
|
|
2322
|
-
} else {
|
|
2323
|
-
// If new value is empty - clear editable input
|
|
2324
|
-
setEditableValue('');
|
|
2325
|
-
}
|
|
2326
|
-
}, [input.value]);
|
|
2327
2292
|
|
|
2328
2293
|
// Callback for value changes
|
|
2329
2294
|
const onChangeSomeInput = useCallback(value => {
|
|
@@ -2336,31 +2301,23 @@ function RadioGroupList(props) {
|
|
|
2336
2301
|
}, [input, onChange]);
|
|
2337
2302
|
|
|
2338
2303
|
// Handle for radio inputs
|
|
2339
|
-
const onChangeRadio = useCallback(
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
setEditableValue(value);
|
|
2347
|
-
onChangeSomeInput(value);
|
|
2348
|
-
}, [onChangeSomeInput]);
|
|
2349
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(option => option.editable ? /*#__PURE__*/React.createElement(RadioGroupInput, {
|
|
2350
|
-
key: option.label,
|
|
2351
|
-
editableProps: editableProps,
|
|
2352
|
-
input: input,
|
|
2353
|
-
inputProps: inputProps,
|
|
2354
|
-
option: option,
|
|
2355
|
-
value: editableValue,
|
|
2356
|
-
onChange: onChangeEditable
|
|
2357
|
-
}) : /*#__PURE__*/React.createElement(RadioGroupItem, {
|
|
2304
|
+
const onChangeRadio = useCallback(event => {
|
|
2305
|
+
if (event.target.checked) {
|
|
2306
|
+
onChangeSomeInput(event.target.value);
|
|
2307
|
+
}
|
|
2308
|
+
}, [onChange]);
|
|
2309
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(option => /*#__PURE__*/React.createElement(Radio, Object.assign({
|
|
2310
|
+
className: "form-radio__item",
|
|
2358
2311
|
key: option.value,
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2312
|
+
type: "radio",
|
|
2313
|
+
name: input.name,
|
|
2314
|
+
label: option.label,
|
|
2315
|
+
checked: option.value === input.value,
|
|
2316
|
+
value: option.value,
|
|
2317
|
+
onBlur: input.onBlur,
|
|
2318
|
+
onChange: onChangeRadio,
|
|
2319
|
+
onFocus: input.onFocus
|
|
2320
|
+
}, inputProps))));
|
|
2364
2321
|
}
|
|
2365
2322
|
|
|
2366
2323
|
const RadioGroup = /*#__PURE__*/React.memo(function RadioGroup(props) {
|
|
@@ -2429,6 +2386,7 @@ const RadioGroup = /*#__PURE__*/React.memo(function RadioGroup(props) {
|
|
|
2429
2386
|
});
|
|
2430
2387
|
|
|
2431
2388
|
const formTypes = {
|
|
2389
|
+
password: 'password',
|
|
2432
2390
|
code: 'code',
|
|
2433
2391
|
text: 'text',
|
|
2434
2392
|
textarea: 'textarea',
|
|
@@ -2448,6 +2406,12 @@ const formTypes = {
|
|
|
2448
2406
|
};
|
|
2449
2407
|
function generateField(field, config, props) {
|
|
2450
2408
|
switch (field.type) {
|
|
2409
|
+
case formTypes.password:
|
|
2410
|
+
{
|
|
2411
|
+
return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
|
|
2412
|
+
key: config.key
|
|
2413
|
+
}, field, props));
|
|
2414
|
+
}
|
|
2451
2415
|
case formTypes.checkbox:
|
|
2452
2416
|
{
|
|
2453
2417
|
return /*#__PURE__*/React.createElement(FormFieldCheckbox, Object.assign({
|
|
@@ -2460,15 +2424,15 @@ function generateField(field, config, props) {
|
|
|
2460
2424
|
key: config.key
|
|
2461
2425
|
}, field, props));
|
|
2462
2426
|
}
|
|
2463
|
-
case formTypes.
|
|
2427
|
+
case formTypes.code:
|
|
2464
2428
|
{
|
|
2465
|
-
return /*#__PURE__*/React.createElement(
|
|
2429
|
+
return /*#__PURE__*/React.createElement(FormFieldCode, Object.assign({
|
|
2466
2430
|
key: config.key
|
|
2467
2431
|
}, field, props));
|
|
2468
2432
|
}
|
|
2469
|
-
case formTypes.
|
|
2433
|
+
case formTypes.chips:
|
|
2470
2434
|
{
|
|
2471
|
-
return /*#__PURE__*/React.createElement(
|
|
2435
|
+
return /*#__PURE__*/React.createElement(FormFieldChips, Object.assign({
|
|
2472
2436
|
key: config.key
|
|
2473
2437
|
}, field, props));
|
|
2474
2438
|
}
|
|
@@ -2514,12 +2478,6 @@ function generateField(field, config, props) {
|
|
|
2514
2478
|
key: config.key
|
|
2515
2479
|
}, field, props));
|
|
2516
2480
|
}
|
|
2517
|
-
case formTypes.password:
|
|
2518
|
-
{
|
|
2519
|
-
return /*#__PURE__*/React.createElement(FormFieldPassword, Object.assign({
|
|
2520
|
-
key: config.key
|
|
2521
|
-
}, field, props));
|
|
2522
|
-
}
|
|
2523
2481
|
case formTypes.textarea:
|
|
2524
2482
|
{
|
|
2525
2483
|
return /*#__PURE__*/React.createElement(FormFieldTextarea, Object.assign({
|
|
@@ -2756,6 +2714,7 @@ const FinalForm = /*#__PURE__*/React.forwardRef(function FinalForm(props, ref) {
|
|
|
2756
2714
|
onChangeFormValues,
|
|
2757
2715
|
onSubmit
|
|
2758
2716
|
} = props;
|
|
2717
|
+
console.log(buttonJustifyContent);
|
|
2759
2718
|
const validate = useYupValidationSchema(validationSchema, language);
|
|
2760
2719
|
const onRefFormInstance = useCallback(formInstance => {
|
|
2761
2720
|
if (ref) {
|
|
@@ -2908,116 +2867,152 @@ FinalForm.defaultProps = {
|
|
|
2908
2867
|
direction: 'vertical'
|
|
2909
2868
|
};
|
|
2910
2869
|
|
|
2911
|
-
const
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2870
|
+
const DEFAULT_MESSAGES_REQUIRED = {
|
|
2871
|
+
required: {
|
|
2872
|
+
key: 'required',
|
|
2873
|
+
message: 'Обязательное поле'
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
const DEFAULT_MESSAGES_ERROR = {
|
|
2877
|
+
invalid_value: {
|
|
2878
|
+
key: 'error',
|
|
2879
|
+
message: 'Некорректное значение'
|
|
2880
|
+
}
|
|
2881
|
+
};
|
|
2882
|
+
const DEFAULT_MESSAGES_URL = {
|
|
2883
|
+
url: {
|
|
2884
|
+
key: 'error',
|
|
2885
|
+
message: 'Введите корректный URL-адрес'
|
|
2886
|
+
}
|
|
2887
|
+
};
|
|
2888
|
+
const DEFAULT_MESSAGES_PASSWORD = {
|
|
2889
|
+
password_required: {
|
|
2890
|
+
key: 'required',
|
|
2891
|
+
message: 'Введите пароль'
|
|
2892
|
+
}
|
|
2893
|
+
};
|
|
2894
|
+
const DEFAULT_MESSAGES_NUMBER = {
|
|
2895
|
+
matches: {
|
|
2896
|
+
key: 'error',
|
|
2897
|
+
message: 'Допускается ввод только цифр от 0 до 9'
|
|
2898
|
+
},
|
|
2899
|
+
numeric_value: {
|
|
2900
|
+
key: 'error',
|
|
2901
|
+
message: 'Только числовое значение'
|
|
2902
|
+
}
|
|
2903
|
+
};
|
|
2904
|
+
const DEFAULT_MESSAGES_MIN_MAX = {
|
|
2905
|
+
min: {
|
|
2906
|
+
key: 'error',
|
|
2907
|
+
message: ({
|
|
2908
|
+
min
|
|
2909
|
+
}) => `Значение должно быть не менее ${min} символов`
|
|
2910
|
+
},
|
|
2911
|
+
max: {
|
|
2912
|
+
key: 'error',
|
|
2913
|
+
message: ({
|
|
2914
|
+
max
|
|
2915
|
+
}) => `Значение должно быть не менее ${max} символов`
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
const DEFAULT_MESSAGES_PHONE = {
|
|
2919
|
+
phone_error: {
|
|
2920
|
+
key: 'error',
|
|
2921
|
+
message: 'Введите корректный номер телефона'
|
|
2922
|
+
},
|
|
2923
|
+
phone_or_email_required: {
|
|
2924
|
+
key: 'required',
|
|
2925
|
+
message: 'Введите телефон или адрес эл. почты'
|
|
2926
|
+
},
|
|
2927
|
+
phone_required: {
|
|
2928
|
+
key: 'required',
|
|
2929
|
+
message: 'Укажите номер телефона'
|
|
2930
|
+
}
|
|
2931
|
+
};
|
|
2932
|
+
const DEFAULT_MESSAGES_EMAIL = {
|
|
2933
|
+
email_error: {
|
|
2934
|
+
key: 'error',
|
|
2935
|
+
message: 'Введите корректный адрес электронной почты'
|
|
2936
|
+
},
|
|
2937
|
+
email_required: {
|
|
2938
|
+
key: 'required',
|
|
2939
|
+
message: 'Укажите адрес электронной почты'
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
|
|
2943
|
+
/*
|
|
2944
|
+
|
|
2945
|
+
!!! It also works without props simply based on the class and key as before `input_state_${meta.error.key}`
|
|
2946
|
+
|
|
2947
|
+
The KEY is needed for example for border color
|
|
2948
|
+
|
|
2949
|
+
The name of the key is anything you want, the main thing is that there is a props with the same KEY and color in FieldProps
|
|
2916
2950
|
...example
|
|
2917
|
-
|
|
2951
|
+
|
|
2952
|
+
required - KEY for yellow color
|
|
2918
2953
|
error - KEY for red color
|
|
2919
2954
|
custom or blue - KEY blue or other color
|
|
2920
|
-
|
|
2955
|
+
|
|
2956
|
+
requiredBorderColor: 'warningBorderPrimary',
|
|
2921
2957
|
errorBorderColor: 'errorBorderPrimary',
|
|
2922
2958
|
customBorderColor: 'customBorderPrimary',
|
|
2923
2959
|
blueBorderColor: 'blueBorderPrimary',
|
|
2924
|
-
|
|
2925
|
-
|
|
2960
|
+
|
|
2961
|
+
const defaultFieldProps = {
|
|
2962
|
+
|
|
2963
|
+
messageTextSize: 's',
|
|
2926
2964
|
messageTextColor: 'surfaceTextSecondary',
|
|
2927
|
-
|
|
2965
|
+
|
|
2966
|
+
requiredMessageTextSize: 's',
|
|
2928
2967
|
requiredMessageTextColor: 'warningTextPrimary',
|
|
2929
|
-
|
|
2968
|
+
|
|
2969
|
+
errorMessageTextSize: 's',
|
|
2930
2970
|
errorMessageTextColor: 'errorTextPrimary',
|
|
2931
2971
|
}
|
|
2932
|
-
|
|
2972
|
+
|
|
2973
|
+
// INPUT
|
|
2933
2974
|
const defaultInputProps = {
|
|
2934
2975
|
... other
|
|
2935
|
-
|
|
2976
|
+
|
|
2977
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2936
2978
|
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2937
2979
|
errorStateBorderColor: 'errorBorderPrimary',
|
|
2938
2980
|
}
|
|
2939
|
-
|
|
2981
|
+
|
|
2982
|
+
// RADIO
|
|
2940
2983
|
const defaultRadioProps = {
|
|
2941
2984
|
... other
|
|
2942
|
-
|
|
2985
|
+
|
|
2986
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2943
2987
|
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2944
2988
|
errorStateBorderColor: 'errorBorderPrimary',
|
|
2945
2989
|
}
|
|
2946
|
-
|
|
2990
|
+
|
|
2991
|
+
// SELECT
|
|
2947
2992
|
const defaultSelectProps = {
|
|
2948
2993
|
... other
|
|
2949
|
-
|
|
2994
|
+
|
|
2995
|
+
borderColor: 'surfaceBorderTertiary',
|
|
2950
2996
|
requiredBorderColor: 'warningBorderPrimary',
|
|
2951
2997
|
errorBorderColor: 'errorBorderPrimary',
|
|
2952
|
-
|
|
2998
|
+
|
|
2999
|
+
inputBorderColor: 'surfaceBorderTertiary',
|
|
2953
3000
|
requiredInputBorderColor: 'warningBorderPrimary',
|
|
2954
3001
|
errorInputBorderColor: 'errorBorderPrimary',
|
|
2955
3002
|
}
|
|
2956
|
-
... etc
|
|
2957
|
-
*/
|
|
2958
3003
|
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
// error - KEY for red color
|
|
3004
|
+
... etc
|
|
3005
|
+
*/
|
|
2962
3006
|
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
max
|
|
2973
|
-
}) => `Значение должно быть не менее ${max} символов`
|
|
2974
|
-
},
|
|
2975
|
-
url: {
|
|
2976
|
-
key: 'error',
|
|
2977
|
-
message: 'Введите корректный URL-адрес'
|
|
2978
|
-
},
|
|
2979
|
-
email_error: {
|
|
2980
|
-
key: 'error',
|
|
2981
|
-
message: 'Введите корректный адрес электронной почты'
|
|
2982
|
-
},
|
|
2983
|
-
phone_error: {
|
|
2984
|
-
key: 'error',
|
|
2985
|
-
message: 'Введите корректный номер телефона'
|
|
2986
|
-
},
|
|
2987
|
-
email_required: {
|
|
2988
|
-
key: 'required',
|
|
2989
|
-
message: 'Укажите адрес электронной почты'
|
|
2990
|
-
},
|
|
2991
|
-
invalid_value: {
|
|
2992
|
-
key: 'error',
|
|
2993
|
-
message: 'Некорректное значение'
|
|
2994
|
-
},
|
|
2995
|
-
// key: 'error'
|
|
2996
|
-
matches: {
|
|
2997
|
-
key: 'error',
|
|
2998
|
-
message: 'Допускается ввод только цифр от 0 до 9'
|
|
2999
|
-
},
|
|
3000
|
-
numeric_value: {
|
|
3001
|
-
key: 'error',
|
|
3002
|
-
message: 'Только числовое значение'
|
|
3003
|
-
},
|
|
3004
|
-
password_required: {
|
|
3005
|
-
key: 'required',
|
|
3006
|
-
message: 'Введите пароль'
|
|
3007
|
-
},
|
|
3008
|
-
phone_or_email_required: {
|
|
3009
|
-
key: 'required',
|
|
3010
|
-
message: 'Введите телефон или адрес эл. почты'
|
|
3011
|
-
},
|
|
3012
|
-
phone_required: {
|
|
3013
|
-
key: 'required',
|
|
3014
|
-
message: 'Укажите номер телефона'
|
|
3015
|
-
},
|
|
3016
|
-
// key: 'required'
|
|
3017
|
-
required: {
|
|
3018
|
-
key: 'required',
|
|
3019
|
-
message: 'Обязательное поле'
|
|
3020
|
-
}
|
|
3007
|
+
const DEFAULT_MESSAGES_FIELDS = {
|
|
3008
|
+
...DEFAULT_MESSAGES_EMAIL,
|
|
3009
|
+
...DEFAULT_MESSAGES_ERROR,
|
|
3010
|
+
...DEFAULT_MESSAGES_MIN_MAX,
|
|
3011
|
+
...DEFAULT_MESSAGES_NUMBER,
|
|
3012
|
+
...DEFAULT_MESSAGES_PASSWORD,
|
|
3013
|
+
...DEFAULT_MESSAGES_PHONE,
|
|
3014
|
+
...DEFAULT_MESSAGES_REQUIRED,
|
|
3015
|
+
...DEFAULT_MESSAGES_URL
|
|
3021
3016
|
};
|
|
3022
3017
|
|
|
3023
3018
|
const parseNumericField = value => {
|