@itcase/forms 1.1.26 → 1.1.27
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.
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
&-inner {
|
|
4
4
|
position: relative;
|
|
5
5
|
display: flex;
|
|
6
|
+
& > input {
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
}
|
|
8
11
|
&__message {
|
|
9
12
|
&-item {
|
|
10
|
-
height: var(--form-field-
|
|
11
|
-
line-height: var(--form-field-
|
|
12
|
-
padding: var(--form-field-
|
|
13
|
+
height: var(--form-field-help-text-height);
|
|
14
|
+
line-height: var(--form-field-help-text-line-height);
|
|
15
|
+
padding: var(--form-field-help-text-padding);
|
|
13
16
|
display: block;
|
|
14
17
|
}
|
|
15
18
|
}
|
|
@@ -24,7 +27,7 @@
|
|
|
24
27
|
}
|
|
25
28
|
.form {
|
|
26
29
|
&^&-field_type_float {
|
|
27
|
-
padding:
|
|
30
|
+
padding: 12px 0 12px 0;
|
|
28
31
|
margin: var(--form-field_type_float-margin);
|
|
29
32
|
position: relative;
|
|
30
33
|
gap: var(--form-field_type_float-gap);
|
|
@@ -42,11 +45,16 @@
|
|
|
42
45
|
opacity: 100%;
|
|
43
46
|
}
|
|
44
47
|
}
|
|
48
|
+
& .textarea {
|
|
49
|
+
&::placeholder {
|
|
50
|
+
opacity: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
45
53
|
}
|
|
46
54
|
& .form {
|
|
47
55
|
&-field {
|
|
48
56
|
&__label {
|
|
49
|
-
background:
|
|
57
|
+
background: #fff;
|
|
50
58
|
padding: 0 4px;
|
|
51
59
|
position: absolute;
|
|
52
60
|
display: flex;
|
|
@@ -58,7 +66,7 @@
|
|
|
58
66
|
transform-origin: top left;
|
|
59
67
|
}
|
|
60
68
|
&__message {
|
|
61
|
-
padding:
|
|
69
|
+
padding: 0 0 0 12px;
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
}
|
|
@@ -68,15 +76,21 @@
|
|
|
68
76
|
opacity: 0%;
|
|
69
77
|
}
|
|
70
78
|
}
|
|
79
|
+
& .textarea {
|
|
80
|
+
&::placeholder {
|
|
81
|
+
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
82
|
+
opacity: 0%;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
71
85
|
}
|
|
72
86
|
}
|
|
73
87
|
.form-field {
|
|
74
88
|
&_type {
|
|
75
89
|
&_classic {
|
|
76
|
-
padding: var(--form-
|
|
77
|
-
margin: var(--form-
|
|
90
|
+
padding: var(--form-field_type_classic-padding);
|
|
91
|
+
margin: var(--form-field_type_classic-margin);
|
|
78
92
|
position: relative;
|
|
79
|
-
gap: var(--form-
|
|
93
|
+
gap: var(--form-field_type_classic-gap);
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
96
|
}
|
package/dist/itcase-forms.cjs.js
CHANGED
|
@@ -27,6 +27,7 @@ var Code = require('@itcase/ui/components/Code');
|
|
|
27
27
|
var Icon = require('@itcase/ui/components/Icon');
|
|
28
28
|
var DatePicker = require('@itcase/ui/components/DatePicker');
|
|
29
29
|
var Input = require('@itcase/ui/components/Input');
|
|
30
|
+
var _default = require('@itcase/icons/default');
|
|
30
31
|
var Segmented = require('@itcase/ui/components/Segmented');
|
|
31
32
|
var Select = require('@itcase/ui/components/Select');
|
|
32
33
|
var Switch = require('@itcase/ui/components/Switch');
|
|
@@ -1582,33 +1583,13 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1582
1583
|
clearIconShape,
|
|
1583
1584
|
clearIconSize,
|
|
1584
1585
|
fieldProps = {},
|
|
1585
|
-
iconFill,
|
|
1586
|
-
iconFillHover,
|
|
1587
|
-
iconRevealableHide,
|
|
1588
|
-
iconRevealableShow,
|
|
1589
|
-
iconShape,
|
|
1590
|
-
iconSize,
|
|
1591
1586
|
inputProps = {},
|
|
1592
1587
|
parse,
|
|
1593
1588
|
showMessage,
|
|
1594
|
-
isPassword,
|
|
1595
1589
|
isRequired,
|
|
1596
|
-
isRevealable,
|
|
1597
1590
|
onChange,
|
|
1598
1591
|
onClickClearIcon
|
|
1599
1592
|
} = props;
|
|
1600
|
-
const [isRevealed, setIsRevealed] = React$1.useState(false);
|
|
1601
|
-
const inputType = React$1.useMemo(() => {
|
|
1602
|
-
if (isPassword) {
|
|
1603
|
-
return isRevealed ? 'text' : 'password';
|
|
1604
|
-
} else {
|
|
1605
|
-
return 'text';
|
|
1606
|
-
}
|
|
1607
|
-
}, [isRevealed, isPassword]);
|
|
1608
|
-
const onClickIconReveal = React$1.useCallback(event => {
|
|
1609
|
-
event.preventDefault();
|
|
1610
|
-
setIsRevealed(prev => !prev);
|
|
1611
|
-
}, []);
|
|
1612
1593
|
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1613
1594
|
name: name,
|
|
1614
1595
|
initialValue: initialValue,
|
|
@@ -1644,7 +1625,6 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1644
1625
|
inputProps: inputProps,
|
|
1645
1626
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1646
1627
|
});
|
|
1647
|
-
const isIconRevealableString = typeof iconRevealableHide === 'string' && typeof iconRevealableShow === 'string';
|
|
1648
1628
|
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1649
1629
|
className: clsx__default.default('form-field_type_input', 'form__item_type_input', classNameGroupItem),
|
|
1650
1630
|
errorKey: errorKey,
|
|
@@ -1652,7 +1632,7 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1652
1632
|
isErrorState: isErrorState,
|
|
1653
1633
|
metaError: meta.error,
|
|
1654
1634
|
isDisabled: isDisabled,
|
|
1655
|
-
fieldClassName:
|
|
1635
|
+
fieldClassName: "form-input",
|
|
1656
1636
|
inputName: input.name,
|
|
1657
1637
|
inputValue: input.value || '',
|
|
1658
1638
|
metaActive: meta.active,
|
|
@@ -1662,7 +1642,7 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1662
1642
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
1663
1643
|
dataTestId: `${input.name}FieldInput`,
|
|
1664
1644
|
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1665
|
-
type:
|
|
1645
|
+
type: "text",
|
|
1666
1646
|
name: input.name,
|
|
1667
1647
|
isDisabled: isDisabled,
|
|
1668
1648
|
autoComplete: "nope",
|
|
@@ -1670,16 +1650,7 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1670
1650
|
onBlur: input.onBlur,
|
|
1671
1651
|
onChange: onChangeField,
|
|
1672
1652
|
onFocus: input.onFocus
|
|
1673
|
-
}, updatedInputProps)),
|
|
1674
|
-
className: "form-field__icon",
|
|
1675
|
-
size: iconSize,
|
|
1676
|
-
iconFill: iconFill,
|
|
1677
|
-
iconFillHover: iconFillHover,
|
|
1678
|
-
imageSrc: isRevealed && isIconRevealableString ? iconRevealableHide : iconRevealableShow,
|
|
1679
|
-
shape: iconShape,
|
|
1680
|
-
SvgImage: isRevealed && !isIconRevealableString ? iconRevealableHide : iconRevealableShow,
|
|
1681
|
-
onClick: onClickIconReveal
|
|
1682
|
-
}), clearIcon && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1653
|
+
}, updatedInputProps)), clearIcon && /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1683
1654
|
className: "form-field__icon",
|
|
1684
1655
|
size: clearIconSize,
|
|
1685
1656
|
iconFill: clearIconFill,
|
|
@@ -1692,6 +1663,110 @@ const FormFieldInput = /*#__PURE__*/React__default.default.memo(function FormFie
|
|
|
1692
1663
|
});
|
|
1693
1664
|
});
|
|
1694
1665
|
|
|
1666
|
+
const defaultPasswordProps = {
|
|
1667
|
+
appearance: 'sizeM defaultSecondary solid rounded',
|
|
1668
|
+
iconRevealableHide: _default.icons24.View.HideValue,
|
|
1669
|
+
iconRevealableShow: _default.icons24.View.ShowValue,
|
|
1670
|
+
iconFill: 'surfaceItemQuaternary'
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
const FormFieldPassword = /*#__PURE__*/React__default.default.memo(function FormFieldPassword(props) {
|
|
1674
|
+
const {
|
|
1675
|
+
name,
|
|
1676
|
+
initialValue,
|
|
1677
|
+
isDisabled,
|
|
1678
|
+
classNameGroupItem,
|
|
1679
|
+
fieldProps,
|
|
1680
|
+
iconFill,
|
|
1681
|
+
iconFillHover,
|
|
1682
|
+
iconRevealableHide,
|
|
1683
|
+
iconRevealableShow,
|
|
1684
|
+
iconShape,
|
|
1685
|
+
iconSize,
|
|
1686
|
+
inputProps,
|
|
1687
|
+
parse,
|
|
1688
|
+
showMessage,
|
|
1689
|
+
isRequired,
|
|
1690
|
+
onChange
|
|
1691
|
+
} = props;
|
|
1692
|
+
const [isRevealed, setIsRevealed] = React$1.useState(false);
|
|
1693
|
+
const inputType = React$1.useMemo(() => {
|
|
1694
|
+
return isRevealed ? 'text' : 'password';
|
|
1695
|
+
}, [isRevealed]);
|
|
1696
|
+
const onClickIconReveal = React$1.useCallback(event => {
|
|
1697
|
+
event.preventDefault();
|
|
1698
|
+
setIsRevealed(prev => !prev);
|
|
1699
|
+
}, []);
|
|
1700
|
+
return /*#__PURE__*/React__default.default.createElement(reactFinalForm.Field, {
|
|
1701
|
+
name: name,
|
|
1702
|
+
initialValue: initialValue,
|
|
1703
|
+
parse: parse
|
|
1704
|
+
}, function Render({
|
|
1705
|
+
input,
|
|
1706
|
+
meta
|
|
1707
|
+
}) {
|
|
1708
|
+
/** Note:
|
|
1709
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1710
|
+
* React Hooks cannot be called inside a callback.
|
|
1711
|
+
* React Hooks must be called in a React function component or a
|
|
1712
|
+
* custom React Hook function.
|
|
1713
|
+
*/
|
|
1714
|
+
|
|
1715
|
+
const onChangeField = React$1.useCallback(event => {
|
|
1716
|
+
input.onChange(event);
|
|
1717
|
+
if (onChange) {
|
|
1718
|
+
onChange(event.target.value, input.name);
|
|
1719
|
+
}
|
|
1720
|
+
}, [onChange, input.onChange]);
|
|
1721
|
+
const {
|
|
1722
|
+
isErrorState,
|
|
1723
|
+
isValidState,
|
|
1724
|
+
errorKey,
|
|
1725
|
+
errorMessage
|
|
1726
|
+
} = useFieldValidationState({
|
|
1727
|
+
fieldProps: fieldProps,
|
|
1728
|
+
input: input,
|
|
1729
|
+
meta: meta
|
|
1730
|
+
});
|
|
1731
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1732
|
+
inputProps: inputProps,
|
|
1733
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1734
|
+
});
|
|
1735
|
+
return /*#__PURE__*/React__default.default.createElement(FieldWrapper, Object.assign({
|
|
1736
|
+
className: clsx__default.default('form-field_type_input', 'form__item_type_input', classNameGroupItem),
|
|
1737
|
+
errorKey: errorKey,
|
|
1738
|
+
errorMessage: errorMessage,
|
|
1739
|
+
isErrorState: isErrorState,
|
|
1740
|
+
metaError: meta.error,
|
|
1741
|
+
isDisabled: isDisabled,
|
|
1742
|
+
fieldClassName: "form-password",
|
|
1743
|
+
inputName: input.name,
|
|
1744
|
+
inputValue: input.value || '',
|
|
1745
|
+
metaActive: meta.active,
|
|
1746
|
+
showMessage: showMessage,
|
|
1747
|
+
isRequired: isRequired,
|
|
1748
|
+
isValidState: isValidState
|
|
1749
|
+
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Input.Input, Object.assign({
|
|
1750
|
+
dataTestId: `${input.name}FieldInputPassword`,
|
|
1751
|
+
className: clsx__default.default(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1752
|
+
type: inputType,
|
|
1753
|
+
name: input.name,
|
|
1754
|
+
isDisabled: isDisabled,
|
|
1755
|
+
autoComplete: "nope",
|
|
1756
|
+
value: input.value || '',
|
|
1757
|
+
onBlur: input.onBlur,
|
|
1758
|
+
onChange: onChangeField,
|
|
1759
|
+
onFocus: input.onFocus
|
|
1760
|
+
}, updatedInputProps)), /*#__PURE__*/React__default.default.createElement(Icon.Icon, {
|
|
1761
|
+
className: "form-field__icon",
|
|
1762
|
+
size: inputProps.iconSize,
|
|
1763
|
+
iconFill: inputProps.iconFill,
|
|
1764
|
+
SvgImage: isRevealed ? inputProps.iconRevealableHide : inputProps.iconRevealableShow,
|
|
1765
|
+
onClick: onClickIconReveal
|
|
1766
|
+
}));
|
|
1767
|
+
});
|
|
1768
|
+
});
|
|
1769
|
+
|
|
1695
1770
|
const defaultSegmentedProps = {
|
|
1696
1771
|
appearance: 'defaultPrimary sizeM solid rounded',
|
|
1697
1772
|
width: 'fill',
|
|
@@ -2027,10 +2102,12 @@ const FormFieldTextarea = /*#__PURE__*/React__default.default.memo(function Form
|
|
|
2027
2102
|
isRequired: isRequired,
|
|
2028
2103
|
isValidState: isValidState
|
|
2029
2104
|
}, fieldProps), /*#__PURE__*/React__default.default.createElement(Textarea.Textarea, Object.assign({
|
|
2105
|
+
dataTestId: `${input.name}FieldTextarea`,
|
|
2106
|
+
className: clsx__default.default(meta.active && 'textarea_state_focus', meta.error && meta.touched && `textarea_state_${errorKey}`),
|
|
2030
2107
|
name: input.name,
|
|
2031
2108
|
isDisabled: isDisabled,
|
|
2032
2109
|
autoComplete: "nope",
|
|
2033
|
-
value: input.value,
|
|
2110
|
+
value: input.value || '',
|
|
2034
2111
|
onBlur: input.onBlur,
|
|
2035
2112
|
onChange: input.onChange,
|
|
2036
2113
|
onFocus: input.onFocus
|
|
@@ -2398,6 +2475,12 @@ function generateField(field, config, props) {
|
|
|
2398
2475
|
key: config.key
|
|
2399
2476
|
}, field, props));
|
|
2400
2477
|
}
|
|
2478
|
+
case formTypes.password:
|
|
2479
|
+
{
|
|
2480
|
+
return /*#__PURE__*/React__default.default.createElement(FormFieldPassword, Object.assign({
|
|
2481
|
+
key: config.key
|
|
2482
|
+
}, field, props));
|
|
2483
|
+
}
|
|
2401
2484
|
case formTypes.textarea:
|
|
2402
2485
|
{
|
|
2403
2486
|
return /*#__PURE__*/React__default.default.createElement(FormFieldTextarea, Object.assign({
|
|
@@ -3021,6 +3104,7 @@ exports.FormFieldCustom = FormFieldCustom;
|
|
|
3021
3104
|
exports.FormFieldDatePicker = FormFieldDatePicker;
|
|
3022
3105
|
exports.FormFieldInput = FormFieldInput;
|
|
3023
3106
|
exports.FormFieldMaskedInput = FormFieldMaskedInput;
|
|
3107
|
+
exports.FormFieldPassword = FormFieldPassword;
|
|
3024
3108
|
exports.FormFieldSegmented = FormFieldSegmented;
|
|
3025
3109
|
exports.FormFieldSelect = FormFieldSelect;
|
|
3026
3110
|
exports.FormFieldSwitch = FormFieldSwitch;
|
|
@@ -3039,6 +3123,7 @@ exports.defaultFieldSizeM = defaultFieldSizeM;
|
|
|
3039
3123
|
exports.defaultFieldSizeXL = defaultFieldSizeXL;
|
|
3040
3124
|
exports.defaultGroupProps = defaultGroupProps;
|
|
3041
3125
|
exports.defaultInputProps = defaultInputProps;
|
|
3126
|
+
exports.defaultPasswordProps = defaultPasswordProps;
|
|
3042
3127
|
exports.defaultRadioProps = defaultRadioProps;
|
|
3043
3128
|
exports.defaultSegmentedProps = defaultSegmentedProps;
|
|
3044
3129
|
exports.defaultSelectProps = defaultSelectProps;
|
package/dist/itcase-forms.esm.js
CHANGED
|
@@ -26,6 +26,7 @@ import { Code } from '@itcase/ui/components/Code';
|
|
|
26
26
|
import { Icon } from '@itcase/ui/components/Icon';
|
|
27
27
|
import { DatePickerInput } from '@itcase/ui/components/DatePicker';
|
|
28
28
|
import { Input } from '@itcase/ui/components/Input';
|
|
29
|
+
import { icons24 } from '@itcase/icons/default';
|
|
29
30
|
import { Segmented } from '@itcase/ui/components/Segmented';
|
|
30
31
|
import { Select } from '@itcase/ui/components/Select';
|
|
31
32
|
import { Switch } from '@itcase/ui/components/Switch';
|
|
@@ -1571,33 +1572,13 @@ const FormFieldInput = /*#__PURE__*/React$1.memo(function FormFieldInput(props)
|
|
|
1571
1572
|
clearIconShape,
|
|
1572
1573
|
clearIconSize,
|
|
1573
1574
|
fieldProps = {},
|
|
1574
|
-
iconFill,
|
|
1575
|
-
iconFillHover,
|
|
1576
|
-
iconRevealableHide,
|
|
1577
|
-
iconRevealableShow,
|
|
1578
|
-
iconShape,
|
|
1579
|
-
iconSize,
|
|
1580
1575
|
inputProps = {},
|
|
1581
1576
|
parse,
|
|
1582
1577
|
showMessage,
|
|
1583
|
-
isPassword,
|
|
1584
1578
|
isRequired,
|
|
1585
|
-
isRevealable,
|
|
1586
1579
|
onChange,
|
|
1587
1580
|
onClickClearIcon
|
|
1588
1581
|
} = props;
|
|
1589
|
-
const [isRevealed, setIsRevealed] = useState(false);
|
|
1590
|
-
const inputType = useMemo(() => {
|
|
1591
|
-
if (isPassword) {
|
|
1592
|
-
return isRevealed ? 'text' : 'password';
|
|
1593
|
-
} else {
|
|
1594
|
-
return 'text';
|
|
1595
|
-
}
|
|
1596
|
-
}, [isRevealed, isPassword]);
|
|
1597
|
-
const onClickIconReveal = useCallback(event => {
|
|
1598
|
-
event.preventDefault();
|
|
1599
|
-
setIsRevealed(prev => !prev);
|
|
1600
|
-
}, []);
|
|
1601
1582
|
return /*#__PURE__*/React$1.createElement(Field, {
|
|
1602
1583
|
name: name,
|
|
1603
1584
|
initialValue: initialValue,
|
|
@@ -1633,7 +1614,6 @@ const FormFieldInput = /*#__PURE__*/React$1.memo(function FormFieldInput(props)
|
|
|
1633
1614
|
inputProps: inputProps,
|
|
1634
1615
|
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1635
1616
|
});
|
|
1636
|
-
const isIconRevealableString = typeof iconRevealableHide === 'string' && typeof iconRevealableShow === 'string';
|
|
1637
1617
|
return /*#__PURE__*/React$1.createElement(FieldWrapper, Object.assign({
|
|
1638
1618
|
className: clsx('form-field_type_input', 'form__item_type_input', classNameGroupItem),
|
|
1639
1619
|
errorKey: errorKey,
|
|
@@ -1641,7 +1621,7 @@ const FormFieldInput = /*#__PURE__*/React$1.memo(function FormFieldInput(props)
|
|
|
1641
1621
|
isErrorState: isErrorState,
|
|
1642
1622
|
metaError: meta.error,
|
|
1643
1623
|
isDisabled: isDisabled,
|
|
1644
|
-
fieldClassName:
|
|
1624
|
+
fieldClassName: "form-input",
|
|
1645
1625
|
inputName: input.name,
|
|
1646
1626
|
inputValue: input.value || '',
|
|
1647
1627
|
metaActive: meta.active,
|
|
@@ -1651,7 +1631,7 @@ const FormFieldInput = /*#__PURE__*/React$1.memo(function FormFieldInput(props)
|
|
|
1651
1631
|
}, fieldProps), /*#__PURE__*/React$1.createElement(Input, Object.assign({
|
|
1652
1632
|
dataTestId: `${input.name}FieldInput`,
|
|
1653
1633
|
className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1654
|
-
type:
|
|
1634
|
+
type: "text",
|
|
1655
1635
|
name: input.name,
|
|
1656
1636
|
isDisabled: isDisabled,
|
|
1657
1637
|
autoComplete: "nope",
|
|
@@ -1659,16 +1639,7 @@ const FormFieldInput = /*#__PURE__*/React$1.memo(function FormFieldInput(props)
|
|
|
1659
1639
|
onBlur: input.onBlur,
|
|
1660
1640
|
onChange: onChangeField,
|
|
1661
1641
|
onFocus: input.onFocus
|
|
1662
|
-
}, updatedInputProps)),
|
|
1663
|
-
className: "form-field__icon",
|
|
1664
|
-
size: iconSize,
|
|
1665
|
-
iconFill: iconFill,
|
|
1666
|
-
iconFillHover: iconFillHover,
|
|
1667
|
-
imageSrc: isRevealed && isIconRevealableString ? iconRevealableHide : iconRevealableShow,
|
|
1668
|
-
shape: iconShape,
|
|
1669
|
-
SvgImage: isRevealed && !isIconRevealableString ? iconRevealableHide : iconRevealableShow,
|
|
1670
|
-
onClick: onClickIconReveal
|
|
1671
|
-
}), clearIcon && /*#__PURE__*/React$1.createElement(Icon, {
|
|
1642
|
+
}, updatedInputProps)), clearIcon && /*#__PURE__*/React$1.createElement(Icon, {
|
|
1672
1643
|
className: "form-field__icon",
|
|
1673
1644
|
size: clearIconSize,
|
|
1674
1645
|
iconFill: clearIconFill,
|
|
@@ -1681,6 +1652,110 @@ const FormFieldInput = /*#__PURE__*/React$1.memo(function FormFieldInput(props)
|
|
|
1681
1652
|
});
|
|
1682
1653
|
});
|
|
1683
1654
|
|
|
1655
|
+
const defaultPasswordProps = {
|
|
1656
|
+
appearance: 'sizeM defaultSecondary solid rounded',
|
|
1657
|
+
iconRevealableHide: icons24.View.HideValue,
|
|
1658
|
+
iconRevealableShow: icons24.View.ShowValue,
|
|
1659
|
+
iconFill: 'surfaceItemQuaternary'
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
const FormFieldPassword = /*#__PURE__*/React$1.memo(function FormFieldPassword(props) {
|
|
1663
|
+
const {
|
|
1664
|
+
name,
|
|
1665
|
+
initialValue,
|
|
1666
|
+
isDisabled,
|
|
1667
|
+
classNameGroupItem,
|
|
1668
|
+
fieldProps,
|
|
1669
|
+
iconFill,
|
|
1670
|
+
iconFillHover,
|
|
1671
|
+
iconRevealableHide,
|
|
1672
|
+
iconRevealableShow,
|
|
1673
|
+
iconShape,
|
|
1674
|
+
iconSize,
|
|
1675
|
+
inputProps,
|
|
1676
|
+
parse,
|
|
1677
|
+
showMessage,
|
|
1678
|
+
isRequired,
|
|
1679
|
+
onChange
|
|
1680
|
+
} = props;
|
|
1681
|
+
const [isRevealed, setIsRevealed] = useState(false);
|
|
1682
|
+
const inputType = useMemo(() => {
|
|
1683
|
+
return isRevealed ? 'text' : 'password';
|
|
1684
|
+
}, [isRevealed]);
|
|
1685
|
+
const onClickIconReveal = useCallback(event => {
|
|
1686
|
+
event.preventDefault();
|
|
1687
|
+
setIsRevealed(prev => !prev);
|
|
1688
|
+
}, []);
|
|
1689
|
+
return /*#__PURE__*/React$1.createElement(Field, {
|
|
1690
|
+
name: name,
|
|
1691
|
+
initialValue: initialValue,
|
|
1692
|
+
parse: parse
|
|
1693
|
+
}, function Render({
|
|
1694
|
+
input,
|
|
1695
|
+
meta
|
|
1696
|
+
}) {
|
|
1697
|
+
/** Note:
|
|
1698
|
+
* Create "Render" function by "eslint-react-hooks/rules-of-hooks":
|
|
1699
|
+
* React Hooks cannot be called inside a callback.
|
|
1700
|
+
* React Hooks must be called in a React function component or a
|
|
1701
|
+
* custom React Hook function.
|
|
1702
|
+
*/
|
|
1703
|
+
|
|
1704
|
+
const onChangeField = useCallback(event => {
|
|
1705
|
+
input.onChange(event);
|
|
1706
|
+
if (onChange) {
|
|
1707
|
+
onChange(event.target.value, input.name);
|
|
1708
|
+
}
|
|
1709
|
+
}, [onChange, input.onChange]);
|
|
1710
|
+
const {
|
|
1711
|
+
isErrorState,
|
|
1712
|
+
isValidState,
|
|
1713
|
+
errorKey,
|
|
1714
|
+
errorMessage
|
|
1715
|
+
} = useFieldValidationState({
|
|
1716
|
+
fieldProps: fieldProps,
|
|
1717
|
+
input: input,
|
|
1718
|
+
meta: meta
|
|
1719
|
+
});
|
|
1720
|
+
const updatedInputProps = useValidationAppearanceInputProps({
|
|
1721
|
+
inputProps: inputProps,
|
|
1722
|
+
validationStateKey: isErrorState ? errorKey : 'success'
|
|
1723
|
+
});
|
|
1724
|
+
return /*#__PURE__*/React$1.createElement(FieldWrapper, Object.assign({
|
|
1725
|
+
className: clsx('form-field_type_input', 'form__item_type_input', classNameGroupItem),
|
|
1726
|
+
errorKey: errorKey,
|
|
1727
|
+
errorMessage: errorMessage,
|
|
1728
|
+
isErrorState: isErrorState,
|
|
1729
|
+
metaError: meta.error,
|
|
1730
|
+
isDisabled: isDisabled,
|
|
1731
|
+
fieldClassName: "form-password",
|
|
1732
|
+
inputName: input.name,
|
|
1733
|
+
inputValue: input.value || '',
|
|
1734
|
+
metaActive: meta.active,
|
|
1735
|
+
showMessage: showMessage,
|
|
1736
|
+
isRequired: isRequired,
|
|
1737
|
+
isValidState: isValidState
|
|
1738
|
+
}, fieldProps), /*#__PURE__*/React$1.createElement(Input, Object.assign({
|
|
1739
|
+
dataTestId: `${input.name}FieldInputPassword`,
|
|
1740
|
+
className: clsx(meta.active && 'input_state_focus', meta.error && meta.touched && `input_state_${errorKey}`),
|
|
1741
|
+
type: inputType,
|
|
1742
|
+
name: input.name,
|
|
1743
|
+
isDisabled: isDisabled,
|
|
1744
|
+
autoComplete: "nope",
|
|
1745
|
+
value: input.value || '',
|
|
1746
|
+
onBlur: input.onBlur,
|
|
1747
|
+
onChange: onChangeField,
|
|
1748
|
+
onFocus: input.onFocus
|
|
1749
|
+
}, updatedInputProps)), /*#__PURE__*/React$1.createElement(Icon, {
|
|
1750
|
+
className: "form-field__icon",
|
|
1751
|
+
size: inputProps.iconSize,
|
|
1752
|
+
iconFill: inputProps.iconFill,
|
|
1753
|
+
SvgImage: isRevealed ? inputProps.iconRevealableHide : inputProps.iconRevealableShow,
|
|
1754
|
+
onClick: onClickIconReveal
|
|
1755
|
+
}));
|
|
1756
|
+
});
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1684
1759
|
const defaultSegmentedProps = {
|
|
1685
1760
|
appearance: 'defaultPrimary sizeM solid rounded',
|
|
1686
1761
|
width: 'fill',
|
|
@@ -2016,10 +2091,12 @@ const FormFieldTextarea = /*#__PURE__*/React$1.memo(function FormFieldTextarea(p
|
|
|
2016
2091
|
isRequired: isRequired,
|
|
2017
2092
|
isValidState: isValidState
|
|
2018
2093
|
}, fieldProps), /*#__PURE__*/React$1.createElement(Textarea, Object.assign({
|
|
2094
|
+
dataTestId: `${input.name}FieldTextarea`,
|
|
2095
|
+
className: clsx(meta.active && 'textarea_state_focus', meta.error && meta.touched && `textarea_state_${errorKey}`),
|
|
2019
2096
|
name: input.name,
|
|
2020
2097
|
isDisabled: isDisabled,
|
|
2021
2098
|
autoComplete: "nope",
|
|
2022
|
-
value: input.value,
|
|
2099
|
+
value: input.value || '',
|
|
2023
2100
|
onBlur: input.onBlur,
|
|
2024
2101
|
onChange: input.onChange,
|
|
2025
2102
|
onFocus: input.onFocus
|
|
@@ -2387,6 +2464,12 @@ function generateField(field, config, props) {
|
|
|
2387
2464
|
key: config.key
|
|
2388
2465
|
}, field, props));
|
|
2389
2466
|
}
|
|
2467
|
+
case formTypes.password:
|
|
2468
|
+
{
|
|
2469
|
+
return /*#__PURE__*/React$1.createElement(FormFieldPassword, Object.assign({
|
|
2470
|
+
key: config.key
|
|
2471
|
+
}, field, props));
|
|
2472
|
+
}
|
|
2390
2473
|
case formTypes.textarea:
|
|
2391
2474
|
{
|
|
2392
2475
|
return /*#__PURE__*/React$1.createElement(FormFieldTextarea, Object.assign({
|
|
@@ -2984,4 +3067,4 @@ const getErrorsForFinalForm = error => {
|
|
|
2984
3067
|
return formErrors;
|
|
2985
3068
|
};
|
|
2986
3069
|
|
|
2987
|
-
export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FileInput, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDatePicker, FormFieldInput, FormFieldMaskedInput, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, RadioGroup, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeM, defaultFieldSizeXL, defaultGroupProps, defaultInputProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|
|
3070
|
+
export { DEFAULT_MESSAGES_FIELDS, FieldWrapper, FieldWrapperBase, FileInput, FinalForm, FormBlockGroup, FormFieldCheckbox, FormFieldChips, FormFieldChoice, FormFieldCode, FormFieldCustom, FormFieldDatePicker, FormFieldInput, FormFieldMaskedInput, FormFieldPassword, FormFieldSegmented, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, RadioGroup, addRequiredFieldsParamToSchema, dateValidation, defaultCheckboxProps, defaultChipsProps, defaultChoiceProps, defaultCodeProps, defaultDatepickerProps, defaultDropzoneProps, defaultFieldProps, defaultFieldSizeM, defaultFieldSizeXL, defaultGroupProps, defaultInputProps, defaultPasswordProps, defaultRadioProps, defaultSegmentedProps, defaultSelectProps, defaultSwitchProps, defaultTextareaProps, emailValidation, focusOnError, focusOnErrorDecorator, formTypes, generateField, getErrorsForFinalForm, parseNumericField, phoneValidation, sendFormDataToServer, setErrorsMutator, useYupValidationSchema };
|