@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.cjs.js
CHANGED
|
@@ -229,8 +229,10 @@ function useValidationAppearanceInputProps(props) {
|
|
|
229
229
|
updatedInputProps[propKey] = propValue;
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
|
+
return updatedInputProps;
|
|
233
|
+
} else {
|
|
234
|
+
return inputProps;
|
|
232
235
|
}
|
|
233
|
-
return updatedInputProps;
|
|
234
236
|
}, [validationStateKey, inputProps]);
|
|
235
237
|
return validationAppearanceInputProps;
|
|
236
238
|
}
|
|
@@ -384,8 +386,8 @@ function FieldWrapperBase(props) {
|
|
|
384
386
|
sizeMobile: labelTextSizeMobile,
|
|
385
387
|
sizeTablet: labelTextSizeTablet
|
|
386
388
|
}, label, labelHidden && '\u00A0')), desc && /*#__PURE__*/React__default.default.createElement("div", {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
+
dataTestId: `${inputName}FieldDesc`,
|
|
390
|
+
className: "form-field__desc"
|
|
389
391
|
}, /*#__PURE__*/React__default.default.createElement(Text.Text, {
|
|
390
392
|
size: descTextSize,
|
|
391
393
|
textColor: descTextColor,
|
|
@@ -1104,6 +1106,7 @@ const FormFieldCheckbox = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
1104
1106
|
errorKey,
|
|
1105
1107
|
errorMessage,
|
|
1106
1108
|
isErrorState,
|
|
1109
|
+
successKey,
|
|
1107
1110
|
isValidState
|
|
1108
1111
|
} = useFieldValidationState({
|
|
1109
1112
|
fieldProps: fieldProps,
|
|
@@ -1112,7 +1115,7 @@ const FormFieldCheckbox = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
1112
1115
|
});
|
|
1113
1116
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1114
1117
|
inputProps: inputProps,
|
|
1115
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1118
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1116
1119
|
});
|
|
1117
1120
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1118
1121
|
className: clsx__default.default('form-field-checkbox', 'form__item_checkbox', classNameGroupItem),
|
|
@@ -1151,6 +1154,8 @@ const defaultChipsProps = {
|
|
|
1151
1154
|
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
1152
1155
|
// Required
|
|
1153
1156
|
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
1157
|
+
// Success
|
|
1158
|
+
// successAppearance: 'successPrimary sizeM solid rounded',
|
|
1154
1159
|
};
|
|
1155
1160
|
|
|
1156
1161
|
function FormFieldChips(props) {
|
|
@@ -1195,6 +1200,7 @@ function FormFieldChips(props) {
|
|
|
1195
1200
|
errorKey,
|
|
1196
1201
|
errorMessage,
|
|
1197
1202
|
isErrorState,
|
|
1203
|
+
successKey,
|
|
1198
1204
|
isValidState
|
|
1199
1205
|
} = useFieldValidationState({
|
|
1200
1206
|
fieldProps: fieldProps,
|
|
@@ -1203,7 +1209,7 @@ function FormFieldChips(props) {
|
|
|
1203
1209
|
});
|
|
1204
1210
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1205
1211
|
inputProps: inputProps,
|
|
1206
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1212
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1207
1213
|
});
|
|
1208
1214
|
const activeOptionsList = React.useMemo(() => {
|
|
1209
1215
|
const emptyOptionsList = [{
|
|
@@ -1264,11 +1270,11 @@ const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1264
1270
|
name,
|
|
1265
1271
|
initialValue,
|
|
1266
1272
|
label,
|
|
1273
|
+
messageType,
|
|
1267
1274
|
isDisabled,
|
|
1268
1275
|
classNameGroupItem,
|
|
1269
1276
|
fieldProps,
|
|
1270
1277
|
inputProps,
|
|
1271
|
-
messageType,
|
|
1272
1278
|
options,
|
|
1273
1279
|
placeholder,
|
|
1274
1280
|
showMessage,
|
|
@@ -1310,10 +1316,11 @@ const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1310
1316
|
return emptyOption;
|
|
1311
1317
|
}, [input.value]);
|
|
1312
1318
|
const {
|
|
1313
|
-
isErrorState,
|
|
1314
|
-
isValidState,
|
|
1315
1319
|
errorKey,
|
|
1316
|
-
errorMessage
|
|
1320
|
+
errorMessage,
|
|
1321
|
+
isErrorState,
|
|
1322
|
+
successKey,
|
|
1323
|
+
isValidState
|
|
1317
1324
|
} = useFieldValidationState({
|
|
1318
1325
|
fieldProps: fieldProps,
|
|
1319
1326
|
input: input,
|
|
@@ -1321,7 +1328,7 @@ const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1321
1328
|
});
|
|
1322
1329
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1323
1330
|
inputProps: inputProps,
|
|
1324
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1331
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1325
1332
|
});
|
|
1326
1333
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1327
1334
|
className: clsx__default.default('form-field_choice', 'form__item_choice', classNameGroupItem),
|
|
@@ -1347,9 +1354,9 @@ const FormFieldChoice = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1347
1354
|
inputValue: input.value || [],
|
|
1348
1355
|
options: options,
|
|
1349
1356
|
placeholder: placeholder,
|
|
1357
|
+
setActiveSegment: setActiveSegment,
|
|
1350
1358
|
isCheckbox: isCheckbox,
|
|
1351
|
-
isRequired: isRequired
|
|
1352
|
-
setActiveSegment: setActiveSegment
|
|
1359
|
+
isRequired: isRequired
|
|
1353
1360
|
}, updatedInputProps)));
|
|
1354
1361
|
});
|
|
1355
1362
|
});
|
|
@@ -1367,6 +1374,8 @@ const FormFieldCode = /*#__PURE__*/React__default.default.memo(function FormFiel
|
|
|
1367
1374
|
const {
|
|
1368
1375
|
name,
|
|
1369
1376
|
initialValue,
|
|
1377
|
+
messageType,
|
|
1378
|
+
label,
|
|
1370
1379
|
isDisabled,
|
|
1371
1380
|
classNameGroupItem,
|
|
1372
1381
|
fieldProps = {},
|
|
@@ -1389,19 +1398,27 @@ const FormFieldCode = /*#__PURE__*/React__default.default.memo(function FormFiel
|
|
|
1389
1398
|
*/
|
|
1390
1399
|
|
|
1391
1400
|
const {
|
|
1401
|
+
errorKey,
|
|
1402
|
+
errorMessage,
|
|
1392
1403
|
isErrorState,
|
|
1393
|
-
|
|
1394
|
-
|
|
1404
|
+
successKey,
|
|
1405
|
+
isValidState
|
|
1406
|
+
} = useFieldValidationState({
|
|
1395
1407
|
fieldProps: fieldProps,
|
|
1396
1408
|
input: input,
|
|
1397
1409
|
meta: meta
|
|
1398
1410
|
});
|
|
1399
1411
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1400
1412
|
inputProps: inputProps,
|
|
1401
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1413
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1402
1414
|
});
|
|
1403
1415
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1404
1416
|
className: clsx__default.default('form-field-code', 'form__item_code', classNameGroupItem),
|
|
1417
|
+
label: label,
|
|
1418
|
+
messageType: messageType,
|
|
1419
|
+
errorKey: errorKey,
|
|
1420
|
+
errorMessage: errorMessage,
|
|
1421
|
+
isErrorState: isErrorState,
|
|
1405
1422
|
fieldClassName: 'form-code',
|
|
1406
1423
|
inputName: input.name,
|
|
1407
1424
|
inputValue: input.value,
|
|
@@ -1556,6 +1573,7 @@ function FormFieldDatePicker(props) {
|
|
|
1556
1573
|
errorKey,
|
|
1557
1574
|
errorMessage,
|
|
1558
1575
|
isErrorState,
|
|
1576
|
+
successKey,
|
|
1559
1577
|
isValidState
|
|
1560
1578
|
} = useFieldValidationState({
|
|
1561
1579
|
fieldProps: fieldProps,
|
|
@@ -1564,7 +1582,7 @@ function FormFieldDatePicker(props) {
|
|
|
1564
1582
|
});
|
|
1565
1583
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1566
1584
|
inputProps: inputProps,
|
|
1567
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1585
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1568
1586
|
});
|
|
1569
1587
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1570
1588
|
className: clsx__default.default('form-field_datepicker', 'form__item_datepicker', classNameGroupItem),
|
|
@@ -1601,7 +1619,9 @@ const defaultInputProps = {
|
|
|
1601
1619
|
// Error
|
|
1602
1620
|
errorAppearance: 'errorPrimary sizeM solid rounded',
|
|
1603
1621
|
// Required
|
|
1604
|
-
requiredAppearance: 'requirePrimary sizeM solid rounded'
|
|
1622
|
+
requiredAppearance: 'requirePrimary sizeM solid rounded',
|
|
1623
|
+
// Success
|
|
1624
|
+
successAppearance: 'successPrimary sizeM solid rounded'
|
|
1605
1625
|
};
|
|
1606
1626
|
|
|
1607
1627
|
const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFieldInput(props) {
|
|
@@ -1651,6 +1671,7 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1651
1671
|
errorKey,
|
|
1652
1672
|
errorMessage,
|
|
1653
1673
|
isErrorState,
|
|
1674
|
+
successKey,
|
|
1654
1675
|
isValidState
|
|
1655
1676
|
} = useFieldValidationState({
|
|
1656
1677
|
fieldProps: fieldProps,
|
|
@@ -1659,7 +1680,7 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1659
1680
|
});
|
|
1660
1681
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1661
1682
|
inputProps: inputProps,
|
|
1662
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1683
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1663
1684
|
});
|
|
1664
1685
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1665
1686
|
className: clsx__default.default('form-field_input', 'form__item_input', classNameGroupItem),
|
|
@@ -1756,6 +1777,7 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
1756
1777
|
errorKey,
|
|
1757
1778
|
errorMessage,
|
|
1758
1779
|
isErrorState,
|
|
1780
|
+
successKey,
|
|
1759
1781
|
isValidState
|
|
1760
1782
|
} = useFieldValidationState({
|
|
1761
1783
|
fieldProps: fieldProps,
|
|
@@ -1764,7 +1786,7 @@ const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
1764
1786
|
});
|
|
1765
1787
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1766
1788
|
inputProps: inputProps,
|
|
1767
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1789
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1768
1790
|
});
|
|
1769
1791
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1770
1792
|
className: clsx__default.default('form-field_input', 'form__item_input', classNameGroupItem),
|
|
@@ -1855,6 +1877,7 @@ function FormFieldSegmented(props) {
|
|
|
1855
1877
|
errorKey,
|
|
1856
1878
|
errorMessage,
|
|
1857
1879
|
isErrorState,
|
|
1880
|
+
successKey,
|
|
1858
1881
|
isValidState
|
|
1859
1882
|
} = useFieldValidationState({
|
|
1860
1883
|
fieldProps: fieldProps,
|
|
@@ -1863,7 +1886,7 @@ function FormFieldSegmented(props) {
|
|
|
1863
1886
|
});
|
|
1864
1887
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1865
1888
|
inputProps: inputProps,
|
|
1866
|
-
validationStateKey: isErrorState ? errorKey :
|
|
1889
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1867
1890
|
});
|
|
1868
1891
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1869
1892
|
className: clsx__default.default('form-field_segmented', 'form__item_segmented'),
|
|
@@ -1969,10 +1992,11 @@ const FormFieldSelect = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1969
1992
|
setSelectedOptions(defaultValue);
|
|
1970
1993
|
}, [defaultValue]);
|
|
1971
1994
|
const {
|
|
1972
|
-
isErrorState,
|
|
1973
|
-
isValidState,
|
|
1974
1995
|
errorKey,
|
|
1975
|
-
errorMessage
|
|
1996
|
+
errorMessage,
|
|
1997
|
+
isErrorState,
|
|
1998
|
+
successKey,
|
|
1999
|
+
isValidState
|
|
1976
2000
|
} = useFieldValidationState({
|
|
1977
2001
|
fieldProps: fieldProps,
|
|
1978
2002
|
input: input,
|
|
@@ -1980,7 +2004,7 @@ const FormFieldSelect = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
1980
2004
|
});
|
|
1981
2005
|
const updatedSelectProps = useValidationAppearanceInputProps({
|
|
1982
2006
|
inputProps: selectProps,
|
|
1983
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2007
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
1984
2008
|
});
|
|
1985
2009
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1986
2010
|
className: clsx__default.default('form-field_select', 'form__item_select', classNameGroupItem),
|
|
@@ -2053,6 +2077,7 @@ const FormFieldSwitch = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
2053
2077
|
errorKey,
|
|
2054
2078
|
errorMessage,
|
|
2055
2079
|
isErrorState,
|
|
2080
|
+
successKey,
|
|
2056
2081
|
isValidState
|
|
2057
2082
|
} = useFieldValidationState({
|
|
2058
2083
|
fieldProps: fieldProps,
|
|
@@ -2061,7 +2086,7 @@ const FormFieldSwitch = /*#__PURE__*/React__default.default.memo(function FormFi
|
|
|
2061
2086
|
});
|
|
2062
2087
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2063
2088
|
inputProps: inputProps,
|
|
2064
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2089
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2065
2090
|
});
|
|
2066
2091
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2067
2092
|
className: clsx__default.default('form-field-switch', 'form__item_switch', classNameGroupItem),
|
|
@@ -2127,6 +2152,7 @@ const FormFieldTextarea = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
2127
2152
|
errorKey,
|
|
2128
2153
|
errorMessage,
|
|
2129
2154
|
isErrorState,
|
|
2155
|
+
successKey,
|
|
2130
2156
|
isValidState
|
|
2131
2157
|
} = useFieldValidationState({
|
|
2132
2158
|
fieldProps: fieldProps,
|
|
@@ -2135,7 +2161,7 @@ const FormFieldTextarea = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
2135
2161
|
});
|
|
2136
2162
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2137
2163
|
inputProps: inputProps,
|
|
2138
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2164
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2139
2165
|
});
|
|
2140
2166
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2141
2167
|
className: clsx__default.default('form-field_textarea', 'form__item_textarea', classNameGroupItem),
|
|
@@ -2219,6 +2245,7 @@ const FormFieldMaskedInput = /*#__PURE__*/React__default.default.memo(function F
|
|
|
2219
2245
|
errorKey,
|
|
2220
2246
|
errorMessage,
|
|
2221
2247
|
isErrorState,
|
|
2248
|
+
successKey,
|
|
2222
2249
|
isValidState
|
|
2223
2250
|
} = useFieldValidationState({
|
|
2224
2251
|
fieldProps: fieldProps,
|
|
@@ -2227,10 +2254,10 @@ const FormFieldMaskedInput = /*#__PURE__*/React__default.default.memo(function F
|
|
|
2227
2254
|
});
|
|
2228
2255
|
const updatedInputProps = useValidationAppearanceInputProps({
|
|
2229
2256
|
inputProps: inputProps,
|
|
2230
|
-
validationStateKey: isErrorState ? errorKey :
|
|
2257
|
+
validationStateKey: isErrorState ? errorKey : isValidState ? successKey : null
|
|
2231
2258
|
});
|
|
2232
2259
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
2233
|
-
className: clsx__default.default('form-
|
|
2260
|
+
className: clsx__default.default('form-field-masked-input', 'form__item_masked-input', classNameGroupItem),
|
|
2234
2261
|
errorKey: errorKey,
|
|
2235
2262
|
errorMessage: errorMessage,
|
|
2236
2263
|
isErrorState: isErrorState,
|
|
@@ -2266,75 +2293,13 @@ const defaultRadioProps = {
|
|
|
2266
2293
|
appearance: 'defaultPrimary sizeM solid circular'
|
|
2267
2294
|
};
|
|
2268
2295
|
|
|
2269
|
-
function RadioGroupInput(props) {
|
|
2270
|
-
const {
|
|
2271
|
-
input,
|
|
2272
|
-
value,
|
|
2273
|
-
onChange
|
|
2274
|
-
} = props;
|
|
2275
|
-
const onChangeField = React.useCallback(event => onChange(event.target.value), [onChange]);
|
|
2276
|
-
return /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
2277
|
-
name: input.name,
|
|
2278
|
-
autoComplete: "nope",
|
|
2279
|
-
value: value,
|
|
2280
|
-
onBlur: input.onBlur,
|
|
2281
|
-
onChange: onChangeField,
|
|
2282
|
-
onFocus: input.onFocus
|
|
2283
|
-
}, props));
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
function RadioGroupItem(props) {
|
|
2287
|
-
const {
|
|
2288
|
-
input,
|
|
2289
|
-
inputProps,
|
|
2290
|
-
option,
|
|
2291
|
-
onChange
|
|
2292
|
-
} = props;
|
|
2293
|
-
const onChangeField = React.useCallback(event => {
|
|
2294
|
-
if (event.target.checked) {
|
|
2295
|
-
onChange(option.value);
|
|
2296
|
-
}
|
|
2297
|
-
}, [onChange]);
|
|
2298
|
-
return /*#__PURE__*/React__default.default.createElement(Radio.Radio, Object.assign({
|
|
2299
|
-
className: "form-radio__item",
|
|
2300
|
-
type: "radio",
|
|
2301
|
-
name: input.name,
|
|
2302
|
-
label: option.label,
|
|
2303
|
-
checked: option.value === input.value,
|
|
2304
|
-
value: option.value,
|
|
2305
|
-
onBlur: input.onBlur,
|
|
2306
|
-
onChange: onChangeField,
|
|
2307
|
-
onFocus: input.onFocus
|
|
2308
|
-
}, inputProps));
|
|
2309
|
-
}
|
|
2310
|
-
|
|
2311
2296
|
function RadioGroupList(props) {
|
|
2312
2297
|
const {
|
|
2313
|
-
editableProps,
|
|
2314
2298
|
input,
|
|
2315
2299
|
inputProps,
|
|
2316
2300
|
options,
|
|
2317
2301
|
onChange
|
|
2318
2302
|
} = props;
|
|
2319
|
-
const [editableValue, setEditableValue] = React.useState(() => {
|
|
2320
|
-
const isRadioValue = options.find(option => option.value === input.value);
|
|
2321
|
-
if (!isRadioValue) {
|
|
2322
|
-
return input.value;
|
|
2323
|
-
}
|
|
2324
|
-
return '';
|
|
2325
|
-
});
|
|
2326
|
-
React.useEffect(() => {
|
|
2327
|
-
// When a new value from outside enters the form
|
|
2328
|
-
if (input.value) {
|
|
2329
|
-
// Check value for radio type
|
|
2330
|
-
const isRadioValue = options.find(option => option.value === input.value && !option.editable);
|
|
2331
|
-
// If new value not in radio list - set to editable input
|
|
2332
|
-
setEditableValue(isRadioValue ? '' : input.value);
|
|
2333
|
-
} else {
|
|
2334
|
-
// If new value is empty - clear editable input
|
|
2335
|
-
setEditableValue('');
|
|
2336
|
-
}
|
|
2337
|
-
}, [input.value]);
|
|
2338
2303
|
|
|
2339
2304
|
// Callback for value changes
|
|
2340
2305
|
const onChangeSomeInput = React.useCallback(value => {
|
|
@@ -2347,31 +2312,23 @@ function RadioGroupList(props) {
|
|
|
2347
2312
|
}, [input, onChange]);
|
|
2348
2313
|
|
|
2349
2314
|
// Handle for radio inputs
|
|
2350
|
-
const onChangeRadio = React.useCallback(
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
setEditableValue(value);
|
|
2358
|
-
onChangeSomeInput(value);
|
|
2359
|
-
}, [onChangeSomeInput]);
|
|
2360
|
-
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => option.editable ? /*#__PURE__*/React__default.default.createElement(RadioGroupInput, {
|
|
2361
|
-
key: option.label,
|
|
2362
|
-
editableProps: editableProps,
|
|
2363
|
-
input: input,
|
|
2364
|
-
inputProps: inputProps,
|
|
2365
|
-
option: option,
|
|
2366
|
-
value: editableValue,
|
|
2367
|
-
onChange: onChangeEditable
|
|
2368
|
-
}) : /*#__PURE__*/React__default.default.createElement(RadioGroupItem, {
|
|
2315
|
+
const onChangeRadio = React.useCallback(event => {
|
|
2316
|
+
if (event.target.checked) {
|
|
2317
|
+
onChangeSomeInput(event.target.value);
|
|
2318
|
+
}
|
|
2319
|
+
}, [onChange]);
|
|
2320
|
+
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, options.map(option => /*#__PURE__*/React__default.default.createElement(Radio.Radio, Object.assign({
|
|
2321
|
+
className: "form-radio__item",
|
|
2369
2322
|
key: option.value,
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2323
|
+
type: "radio",
|
|
2324
|
+
name: input.name,
|
|
2325
|
+
label: option.label,
|
|
2326
|
+
checked: option.value === input.value,
|
|
2327
|
+
value: option.value,
|
|
2328
|
+
onBlur: input.onBlur,
|
|
2329
|
+
onChange: onChangeRadio,
|
|
2330
|
+
onFocus: input.onFocus
|
|
2331
|
+
}, inputProps))));
|
|
2375
2332
|
}
|
|
2376
2333
|
|
|
2377
2334
|
const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(props) {
|
|
@@ -2440,6 +2397,7 @@ const RadioGroup = /*#__PURE__*/React__default.default.memo(function RadioGroup(
|
|
|
2440
2397
|
});
|
|
2441
2398
|
|
|
2442
2399
|
const formTypes = {
|
|
2400
|
+
password: 'password',
|
|
2443
2401
|
code: 'code',
|
|
2444
2402
|
text: 'text',
|
|
2445
2403
|
textarea: 'textarea',
|
|
@@ -2459,6 +2417,12 @@ const formTypes = {
|
|
|
2459
2417
|
};
|
|
2460
2418
|
function generateField(field, config, props) {
|
|
2461
2419
|
switch (field.type) {
|
|
2420
|
+
case formTypes.password:
|
|
2421
|
+
{
|
|
2422
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldPassword, Object.assign({
|
|
2423
|
+
key: config.key
|
|
2424
|
+
}, field, props));
|
|
2425
|
+
}
|
|
2462
2426
|
case formTypes.checkbox:
|
|
2463
2427
|
{
|
|
2464
2428
|
return /*#__PURE__*/React__default.default.createElement(FormFieldCheckbox, Object.assign({
|
|
@@ -2471,15 +2435,15 @@ function generateField(field, config, props) {
|
|
|
2471
2435
|
key: config.key
|
|
2472
2436
|
}, field, props));
|
|
2473
2437
|
}
|
|
2474
|
-
case formTypes.
|
|
2438
|
+
case formTypes.code:
|
|
2475
2439
|
{
|
|
2476
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
2440
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldCode, Object.assign({
|
|
2477
2441
|
key: config.key
|
|
2478
2442
|
}, field, props));
|
|
2479
2443
|
}
|
|
2480
|
-
case formTypes.
|
|
2444
|
+
case formTypes.chips:
|
|
2481
2445
|
{
|
|
2482
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
2446
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldChips, Object.assign({
|
|
2483
2447
|
key: config.key
|
|
2484
2448
|
}, field, props));
|
|
2485
2449
|
}
|
|
@@ -2525,12 +2489,6 @@ function generateField(field, config, props) {
|
|
|
2525
2489
|
key: config.key
|
|
2526
2490
|
}, field, props));
|
|
2527
2491
|
}
|
|
2528
|
-
case formTypes.password:
|
|
2529
|
-
{
|
|
2530
|
-
return /*#__PURE__*/React__default.default.createElement(FormFieldPassword, Object.assign({
|
|
2531
|
-
key: config.key
|
|
2532
|
-
}, field, props));
|
|
2533
|
-
}
|
|
2534
2492
|
case formTypes.textarea:
|
|
2535
2493
|
{
|
|
2536
2494
|
return /*#__PURE__*/React__default.default.createElement(FormFieldTextarea, Object.assign({
|
|
@@ -2767,6 +2725,7 @@ const FinalForm = /*#__PURE__*/React__default.default.forwardRef(function FinalF
|
|
|
2767
2725
|
onChangeFormValues,
|
|
2768
2726
|
onSubmit
|
|
2769
2727
|
} = props;
|
|
2728
|
+
console.log(buttonJustifyContent);
|
|
2770
2729
|
const validate = useYupValidationSchema(validationSchema, language);
|
|
2771
2730
|
const onRefFormInstance = React.useCallback(formInstance => {
|
|
2772
2731
|
if (ref) {
|
|
@@ -2919,116 +2878,152 @@ FinalForm.defaultProps = {
|
|
|
2919
2878
|
direction: 'vertical'
|
|
2920
2879
|
};
|
|
2921
2880
|
|
|
2922
|
-
const
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2881
|
+
const DEFAULT_MESSAGES_REQUIRED = {
|
|
2882
|
+
required: {
|
|
2883
|
+
key: 'required',
|
|
2884
|
+
message: 'Обязательное поле'
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
const DEFAULT_MESSAGES_ERROR = {
|
|
2888
|
+
invalid_value: {
|
|
2889
|
+
key: 'error',
|
|
2890
|
+
message: 'Некорректное значение'
|
|
2891
|
+
}
|
|
2892
|
+
};
|
|
2893
|
+
const DEFAULT_MESSAGES_URL = {
|
|
2894
|
+
url: {
|
|
2895
|
+
key: 'error',
|
|
2896
|
+
message: 'Введите корректный URL-адрес'
|
|
2897
|
+
}
|
|
2898
|
+
};
|
|
2899
|
+
const DEFAULT_MESSAGES_PASSWORD = {
|
|
2900
|
+
password_required: {
|
|
2901
|
+
key: 'required',
|
|
2902
|
+
message: 'Введите пароль'
|
|
2903
|
+
}
|
|
2904
|
+
};
|
|
2905
|
+
const DEFAULT_MESSAGES_NUMBER = {
|
|
2906
|
+
matches: {
|
|
2907
|
+
key: 'error',
|
|
2908
|
+
message: 'Допускается ввод только цифр от 0 до 9'
|
|
2909
|
+
},
|
|
2910
|
+
numeric_value: {
|
|
2911
|
+
key: 'error',
|
|
2912
|
+
message: 'Только числовое значение'
|
|
2913
|
+
}
|
|
2914
|
+
};
|
|
2915
|
+
const DEFAULT_MESSAGES_MIN_MAX = {
|
|
2916
|
+
min: {
|
|
2917
|
+
key: 'error',
|
|
2918
|
+
message: ({
|
|
2919
|
+
min
|
|
2920
|
+
}) => `Значение должно быть не менее ${min} символов`
|
|
2921
|
+
},
|
|
2922
|
+
max: {
|
|
2923
|
+
key: 'error',
|
|
2924
|
+
message: ({
|
|
2925
|
+
max
|
|
2926
|
+
}) => `Значение должно быть не менее ${max} символов`
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
const DEFAULT_MESSAGES_PHONE = {
|
|
2930
|
+
phone_error: {
|
|
2931
|
+
key: 'error',
|
|
2932
|
+
message: 'Введите корректный номер телефона'
|
|
2933
|
+
},
|
|
2934
|
+
phone_or_email_required: {
|
|
2935
|
+
key: 'required',
|
|
2936
|
+
message: 'Введите телефон или адрес эл. почты'
|
|
2937
|
+
},
|
|
2938
|
+
phone_required: {
|
|
2939
|
+
key: 'required',
|
|
2940
|
+
message: 'Укажите номер телефона'
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
const DEFAULT_MESSAGES_EMAIL = {
|
|
2944
|
+
email_error: {
|
|
2945
|
+
key: 'error',
|
|
2946
|
+
message: 'Введите корректный адрес электронной почты'
|
|
2947
|
+
},
|
|
2948
|
+
email_required: {
|
|
2949
|
+
key: 'required',
|
|
2950
|
+
message: 'Укажите адрес электронной почты'
|
|
2951
|
+
}
|
|
2952
|
+
};
|
|
2953
|
+
|
|
2954
|
+
/*
|
|
2955
|
+
|
|
2956
|
+
!!! It also works without props simply based on the class and key as before `input_state_${meta.error.key}`
|
|
2957
|
+
|
|
2958
|
+
The KEY is needed for example for border color
|
|
2959
|
+
|
|
2960
|
+
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
|
|
2927
2961
|
...example
|
|
2928
|
-
|
|
2962
|
+
|
|
2963
|
+
required - KEY for yellow color
|
|
2929
2964
|
error - KEY for red color
|
|
2930
2965
|
custom or blue - KEY blue or other color
|
|
2931
|
-
|
|
2966
|
+
|
|
2967
|
+
requiredBorderColor: 'warningBorderPrimary',
|
|
2932
2968
|
errorBorderColor: 'errorBorderPrimary',
|
|
2933
2969
|
customBorderColor: 'customBorderPrimary',
|
|
2934
2970
|
blueBorderColor: 'blueBorderPrimary',
|
|
2935
|
-
|
|
2936
|
-
|
|
2971
|
+
|
|
2972
|
+
const defaultFieldProps = {
|
|
2973
|
+
|
|
2974
|
+
messageTextSize: 's',
|
|
2937
2975
|
messageTextColor: 'surfaceTextSecondary',
|
|
2938
|
-
|
|
2976
|
+
|
|
2977
|
+
requiredMessageTextSize: 's',
|
|
2939
2978
|
requiredMessageTextColor: 'warningTextPrimary',
|
|
2940
|
-
|
|
2979
|
+
|
|
2980
|
+
errorMessageTextSize: 's',
|
|
2941
2981
|
errorMessageTextColor: 'errorTextPrimary',
|
|
2942
2982
|
}
|
|
2943
|
-
|
|
2983
|
+
|
|
2984
|
+
// INPUT
|
|
2944
2985
|
const defaultInputProps = {
|
|
2945
2986
|
... other
|
|
2946
|
-
|
|
2987
|
+
|
|
2988
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2947
2989
|
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2948
2990
|
errorStateBorderColor: 'errorBorderPrimary',
|
|
2949
2991
|
}
|
|
2950
|
-
|
|
2992
|
+
|
|
2993
|
+
// RADIO
|
|
2951
2994
|
const defaultRadioProps = {
|
|
2952
2995
|
... other
|
|
2953
|
-
|
|
2996
|
+
|
|
2997
|
+
stateBorderColor: 'surfaceBorderTertiary',
|
|
2954
2998
|
requiredStateBorderColor: 'warningBorderPrimary',
|
|
2955
2999
|
errorStateBorderColor: 'errorBorderPrimary',
|
|
2956
3000
|
}
|
|
2957
|
-
|
|
3001
|
+
|
|
3002
|
+
// SELECT
|
|
2958
3003
|
const defaultSelectProps = {
|
|
2959
3004
|
... other
|
|
2960
|
-
|
|
3005
|
+
|
|
3006
|
+
borderColor: 'surfaceBorderTertiary',
|
|
2961
3007
|
requiredBorderColor: 'warningBorderPrimary',
|
|
2962
3008
|
errorBorderColor: 'errorBorderPrimary',
|
|
2963
|
-
|
|
3009
|
+
|
|
3010
|
+
inputBorderColor: 'surfaceBorderTertiary',
|
|
2964
3011
|
requiredInputBorderColor: 'warningBorderPrimary',
|
|
2965
3012
|
errorInputBorderColor: 'errorBorderPrimary',
|
|
2966
3013
|
}
|
|
2967
|
-
... etc
|
|
2968
|
-
*/
|
|
2969
3014
|
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
// error - KEY for red color
|
|
3015
|
+
... etc
|
|
3016
|
+
*/
|
|
2973
3017
|
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
max
|
|
2984
|
-
}) => `Значение должно быть не менее ${max} символов`
|
|
2985
|
-
},
|
|
2986
|
-
url: {
|
|
2987
|
-
key: 'error',
|
|
2988
|
-
message: 'Введите корректный URL-адрес'
|
|
2989
|
-
},
|
|
2990
|
-
email_error: {
|
|
2991
|
-
key: 'error',
|
|
2992
|
-
message: 'Введите корректный адрес электронной почты'
|
|
2993
|
-
},
|
|
2994
|
-
phone_error: {
|
|
2995
|
-
key: 'error',
|
|
2996
|
-
message: 'Введите корректный номер телефона'
|
|
2997
|
-
},
|
|
2998
|
-
email_required: {
|
|
2999
|
-
key: 'required',
|
|
3000
|
-
message: 'Укажите адрес электронной почты'
|
|
3001
|
-
},
|
|
3002
|
-
invalid_value: {
|
|
3003
|
-
key: 'error',
|
|
3004
|
-
message: 'Некорректное значение'
|
|
3005
|
-
},
|
|
3006
|
-
// key: 'error'
|
|
3007
|
-
matches: {
|
|
3008
|
-
key: 'error',
|
|
3009
|
-
message: 'Допускается ввод только цифр от 0 до 9'
|
|
3010
|
-
},
|
|
3011
|
-
numeric_value: {
|
|
3012
|
-
key: 'error',
|
|
3013
|
-
message: 'Только числовое значение'
|
|
3014
|
-
},
|
|
3015
|
-
password_required: {
|
|
3016
|
-
key: 'required',
|
|
3017
|
-
message: 'Введите пароль'
|
|
3018
|
-
},
|
|
3019
|
-
phone_or_email_required: {
|
|
3020
|
-
key: 'required',
|
|
3021
|
-
message: 'Введите телефон или адрес эл. почты'
|
|
3022
|
-
},
|
|
3023
|
-
phone_required: {
|
|
3024
|
-
key: 'required',
|
|
3025
|
-
message: 'Укажите номер телефона'
|
|
3026
|
-
},
|
|
3027
|
-
// key: 'required'
|
|
3028
|
-
required: {
|
|
3029
|
-
key: 'required',
|
|
3030
|
-
message: 'Обязательное поле'
|
|
3031
|
-
}
|
|
3018
|
+
const DEFAULT_MESSAGES_FIELDS = {
|
|
3019
|
+
...DEFAULT_MESSAGES_EMAIL,
|
|
3020
|
+
...DEFAULT_MESSAGES_ERROR,
|
|
3021
|
+
...DEFAULT_MESSAGES_MIN_MAX,
|
|
3022
|
+
...DEFAULT_MESSAGES_NUMBER,
|
|
3023
|
+
...DEFAULT_MESSAGES_PASSWORD,
|
|
3024
|
+
...DEFAULT_MESSAGES_PHONE,
|
|
3025
|
+
...DEFAULT_MESSAGES_REQUIRED,
|
|
3026
|
+
...DEFAULT_MESSAGES_URL
|
|
3032
3027
|
};
|
|
3033
3028
|
|
|
3034
3029
|
const parseNumericField = value => {
|