@salutejs/plasma-new-hope 0.194.0-canary.1562.11857238836.0 → 0.194.0-canary.1565.11870784206.0
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/cjs/components/Combobox/ComboboxNew/Combobox.js +1 -0
- package/cjs/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js.map +1 -1
- package/cjs/components/Combobox/ComboboxOld/Combobox.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +4 -5
- package/cjs/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +4 -5
- package/cjs/components/Dropdown/Dropdown.css +4 -5
- package/cjs/components/Dropdown/Dropdown.js +2 -4
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.css +4 -5
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +1 -7
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/{DropdownItem.styles_14yih1y.css → DropdownItem.styles_1b439rx.css} +0 -1
- package/cjs/components/Select/Select.js +1 -0
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/cjs/components/Select/ui/Inner/ui/Item/Item.js.map +1 -1
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -18
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/cjs/components/TextField/TextField.js +27 -3
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/components/TextField/hooks/useValidation.js +273 -0
- package/cjs/components/TextField/hooks/useValidation.js.map +1 -0
- package/cjs/index.css +4 -5
- package/cjs/utils/constants.js +4 -0
- package/cjs/utils/constants.js.map +1 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.js +1 -0
- package/emotion/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/cjs/components/Dropdown/Dropdown.js +2 -4
- package/emotion/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
- package/emotion/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +11 -15
- package/emotion/cjs/components/Select/Select.js +1 -0
- package/emotion/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/emotion/cjs/components/TextField/TextField.js +27 -4
- package/emotion/cjs/components/TextField/TextField.template-doc.mdx +330 -0
- package/emotion/cjs/components/TextField/hooks/index.js +8 -1
- package/emotion/cjs/components/TextField/hooks/useValidation.js +276 -0
- package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
- package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
- package/emotion/cjs/utils/constants.js +4 -2
- package/emotion/es/components/Combobox/ComboboxNew/Combobox.js +1 -0
- package/emotion/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/es/components/Dropdown/Dropdown.js +2 -4
- package/emotion/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
- package/emotion/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +11 -15
- package/emotion/es/components/Select/Select.js +1 -0
- package/emotion/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/emotion/es/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/emotion/es/components/TextField/TextField.js +28 -5
- package/emotion/es/components/TextField/TextField.template-doc.mdx +330 -0
- package/emotion/es/components/TextField/hooks/index.js +2 -1
- package/emotion/es/components/TextField/hooks/useValidation.js +270 -0
- package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
- package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
- package/emotion/es/utils/constants.js +3 -1
- package/es/components/Combobox/ComboboxNew/Combobox.js +1 -0
- package/es/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
- package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js.map +1 -1
- package/es/components/Combobox/ComboboxOld/Combobox.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +4 -5
- package/es/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +4 -5
- package/es/components/Dropdown/Dropdown.css +4 -5
- package/es/components/Dropdown/Dropdown.js +2 -4
- package/es/components/Dropdown/Dropdown.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.css +4 -5
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -7
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/{DropdownItem.styles_14yih1y.css → DropdownItem.styles_1b439rx.css} +0 -1
- package/es/components/Select/Select.js +1 -0
- package/es/components/Select/Select.js.map +1 -1
- package/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/es/components/Select/ui/Inner/ui/Item/Item.js.map +1 -1
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js +4 -19
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/es/components/TextField/TextField.js +27 -3
- package/es/components/TextField/TextField.js.map +1 -1
- package/es/components/TextField/hooks/useValidation.js +269 -0
- package/es/components/TextField/hooks/useValidation.js.map +1 -0
- package/es/index.css +4 -5
- package/es/utils/constants.js +3 -1
- package/es/utils/constants.js.map +1 -1
- package/package.json +2 -3
- package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.js +1 -0
- package/styled-components/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/cjs/components/Dropdown/Dropdown.js +2 -4
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -5
- package/styled-components/cjs/components/Select/Select.js +1 -0
- package/styled-components/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/styled-components/cjs/components/TextField/TextField.js +26 -3
- package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +330 -0
- package/styled-components/cjs/components/TextField/hooks/index.js +8 -1
- package/styled-components/cjs/components/TextField/hooks/useValidation.js +276 -0
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
- package/styled-components/cjs/utils/constants.js +4 -2
- package/styled-components/es/components/Combobox/ComboboxNew/Combobox.js +1 -0
- package/styled-components/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/es/components/Dropdown/Dropdown.js +2 -4
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -5
- package/styled-components/es/components/Select/Select.js +1 -0
- package/styled-components/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
- package/styled-components/es/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
- package/styled-components/es/components/TextField/TextField.js +27 -4
- package/styled-components/es/components/TextField/TextField.template-doc.mdx +330 -0
- package/styled-components/es/components/TextField/hooks/index.js +2 -1
- package/styled-components/es/components/TextField/hooks/useValidation.js +270 -0
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
- package/styled-components/es/utils/constants.js +3 -1
- package/types/components/Autocomplete/Autocomplete.types.d.ts +2 -2
- package/types/components/Autocomplete/Autocomplete.types.d.ts.map +1 -1
- package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts +1676 -92
- package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/Combobox.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +2 -1
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts +1676 -92
- package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts.map +1 -1
- package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts +1676 -92
- package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.d.ts +2 -50
- package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/components/Dropdown/Dropdown.types.d.ts +6 -11
- package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
- package/types/components/Dropdown/index.d.ts +0 -1
- package/types/components/Dropdown/index.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts +0 -1
- package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts.map +1 -1
- package/types/components/Range/Range.styles.d.ts +1676 -92
- package/types/components/Range/Range.styles.d.ts.map +1 -1
- package/types/components/Select/Select.d.ts.map +1 -1
- package/types/components/Select/Select.types.d.ts +2 -1
- package/types/components/Select/Select.types.d.ts.map +1 -1
- package/types/components/Select/ui/Inner/ui/Item/Item.d.ts.map +1 -1
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.d.ts.map +1 -1
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts +1676 -92
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts.map +1 -1
- package/types/components/Slider/components/Double/Double.styles.d.ts +1676 -92
- package/types/components/Slider/components/Double/Double.styles.d.ts.map +1 -1
- package/types/components/TextField/TextField.d.ts.map +1 -1
- package/types/components/TextField/TextField.types.d.ts +51 -1
- package/types/components/TextField/TextField.types.d.ts.map +1 -1
- package/types/components/TextField/hooks/index.d.ts +1 -0
- package/types/components/TextField/hooks/index.d.ts.map +1 -1
- package/types/components/TextField/hooks/useValidation.d.ts +7 -0
- package/types/components/TextField/hooks/useValidation.d.ts.map +1 -0
- package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts +64 -2
- package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Dropdown/Dropdown.d.ts +1 -25
- package/types/examples/plasma_b2c/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Mask/Mask.d.ts +2732 -92
- package/types/examples/plasma_b2c/components/Mask/Mask.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +1676 -92
- package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts +64 -2
- package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts +1 -25
- package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Mask/Mask.d.ts +2732 -92
- package/types/examples/plasma_web/components/Mask/Mask.d.ts.map +1 -1
- package/types/examples/plasma_web/components/TextField/TextField.d.ts +1676 -92
- package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -1
- package/types/utils/constants.d.ts +2 -0
- package/types/utils/constants.d.ts.map +1 -1
@@ -357,6 +357,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
357
357
|
handleItemClick: handleItemClick,
|
358
358
|
variant: variant,
|
359
359
|
renderItem: renderItem,
|
360
|
+
valueToItemMap: valueToItemMap,
|
360
361
|
treeId: treeId
|
361
362
|
}
|
362
363
|
}, /*#__PURE__*/_react["default"].createElement(_FloatingPopover.FloatingPopover, {
|
@@ -40,6 +40,7 @@ var Item = exports.Item = function Item(_ref) {
|
|
40
40
|
handleItemClick = _useContext.handleItemClick,
|
41
41
|
variant = _useContext.variant,
|
42
42
|
renderItem = _useContext.renderItem,
|
43
|
+
valueToItemMap = _useContext.valueToItemMap,
|
43
44
|
treeId = _useContext.treeId;
|
44
45
|
var disabledClassName = disabled ? _Combobox.classes.dropdownItemIsDisabled : undefined;
|
45
46
|
var focusedClass = currentLevel === focusedPath.length - 1 && index === (focusedPath === null || focusedPath === void 0 ? void 0 : focusedPath[currentLevel]) ? _Combobox.classes.dropdownItemIsFocused : undefined;
|
@@ -93,7 +94,7 @@ var Item = exports.Item = function Item(_ref) {
|
|
93
94
|
}))), !multiple && checked.get(item.value) === 'done' && /*#__PURE__*/_react["default"].createElement(_Icon.IconDone, {
|
94
95
|
size: (0, _utils.sizeToIconSize)(size, variant),
|
95
96
|
color: "inherit"
|
96
|
-
})), renderItem ? /*#__PURE__*/_react["default"].createElement(_Item.StyledText, null, renderItem(
|
97
|
+
})), renderItem ? /*#__PURE__*/_react["default"].createElement(_Item.StyledText, null, renderItem(valueToItemMap.get(value))) : /*#__PURE__*/_react["default"].createElement(_Item.StyledWrapper, null, /*#__PURE__*/_react["default"].createElement(_Item.StyledCell, {
|
97
98
|
view: "default",
|
98
99
|
size: "l",
|
99
100
|
contentLeft: contentLeft,
|
@@ -20,7 +20,7 @@ var _Dropdown2 = /*#__PURE__*/require("./Dropdown.tokens");
|
|
20
20
|
var _useKeyboardNavigation = /*#__PURE__*/require("./hooks/useKeyboardNavigation");
|
21
21
|
var _useHashMaps3 = /*#__PURE__*/require("./hooks/useHashMaps");
|
22
22
|
var _FloatingPopover = /*#__PURE__*/require("./FloatingPopover");
|
23
|
-
var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "alwaysOpened", "portal"
|
23
|
+
var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "alwaysOpened", "portal"];
|
24
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
25
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
26
26
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -69,7 +69,6 @@ var dropdownRoot = exports.dropdownRoot = function dropdownRoot(Root) {
|
|
69
69
|
_ref$alwaysOpened = _ref.alwaysOpened,
|
70
70
|
alwaysOpened = _ref$alwaysOpened === void 0 ? false : _ref$alwaysOpened,
|
71
71
|
portal = _ref.portal,
|
72
|
-
renderItem = _ref.renderItem,
|
73
72
|
rest = _objectWithoutProperties(_ref, _excluded);
|
74
73
|
var _useReducer = (0, _react.useReducer)(_pathReducer.pathReducer, []),
|
75
74
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
@@ -145,8 +144,7 @@ var dropdownRoot = exports.dropdownRoot = function dropdownRoot(Root) {
|
|
145
144
|
onItemClick: onItemClick,
|
146
145
|
onItemSelect: onItemSelect,
|
147
146
|
hasArrow: hasArrow,
|
148
|
-
treeId: treeId
|
149
|
-
renderItem: renderItem
|
147
|
+
treeId: treeId
|
150
148
|
}
|
151
149
|
}, /*#__PURE__*/_react["default"].createElement(_FloatingPopover.FloatingPopover, {
|
152
150
|
ref: floatingPopoverRef,
|
@@ -43,8 +43,7 @@ var DropdownItem = exports.DropdownItem = function DropdownItem(_ref) {
|
|
43
43
|
onItemSelect = _useContext.onItemSelect,
|
44
44
|
onItemClick = _useContext.onItemClick,
|
45
45
|
hasArrow = _useContext.hasArrow,
|
46
|
-
treeId = _useContext.treeId
|
47
|
-
renderItem = _useContext.renderItem;
|
46
|
+
treeId = _useContext.treeId;
|
48
47
|
var hasDescendants = Boolean(item.items);
|
49
48
|
var disclosureIconSize = size === 'xs' ? 'xs' : 's';
|
50
49
|
var isDisabledClassName = disabled || isDisabled ? _Dropdown.classes.dropdownItemIsDisabled : undefined;
|
@@ -95,7 +94,7 @@ var DropdownItem = exports.DropdownItem = function DropdownItem(_ref) {
|
|
95
94
|
"aria-expanded": ariaExpanded,
|
96
95
|
"aria-level": ariaLevel,
|
97
96
|
"aria-label": ariaLabel
|
98
|
-
},
|
97
|
+
}, /*#__PURE__*/_react["default"].createElement(_DropdownItem.CellWrapper, null, /*#__PURE__*/_react["default"].createElement(_DropdownItem.StyledCell, {
|
99
98
|
contentLeft: contentLeft,
|
100
99
|
contentRight: contentRight,
|
101
100
|
alignContentLeft: "center",
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.Wrapper = exports.StyledCell = exports.
|
6
|
+
exports.Wrapper = exports.StyledCell = exports.Divider = exports.DisclosureIconWrapper = exports.CellWrapper = void 0;
|
7
7
|
var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("styled-components"));
|
8
8
|
var _Dropdown = /*#__PURE__*/require("../../Dropdown.tokens");
|
9
9
|
var _mixins = /*#__PURE__*/require("../../../../mixins");
|
@@ -42,7 +42,4 @@ var Wrapper = exports.Wrapper = /*#__PURE__*/_styledComponents["default"].li.wit
|
|
42
42
|
outlineRadius: /*#__PURE__*/"var(".concat(_Dropdown.tokens.itemBorderRadius, ")"),
|
43
43
|
hasTransition: false,
|
44
44
|
customFocusRules: /*#__PURE__*/"\n &.".concat(_Dropdown.classes.dropdownItemIsFocused, ":before {\n outline: none;\n box-shadow: 0 0 0 0.0625rem var(").concat(_Dropdown.constants.focusColor, ");\n }\n ")
|
45
|
-
}));
|
46
|
-
var RenderItemWrapper = exports.RenderItemWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
47
|
-
componentId: "plasma-new-hope__sc-hs0ek1-5"
|
48
|
-
})(["", ";flex:1;"], /*#__PURE__*/(0, _mixins.applyEllipsis)());
|
45
|
+
}));
|
@@ -281,6 +281,7 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
|
|
281
281
|
handleItemClick: handleItemClick,
|
282
282
|
variant: variant,
|
283
283
|
renderItem: renderItem,
|
284
|
+
valueToItemMap: valueToItemMap,
|
284
285
|
treeId: treeId
|
285
286
|
}
|
286
287
|
}, /*#__PURE__*/_react["default"].createElement(_FloatingPopover.FloatingPopover, {
|
@@ -41,6 +41,7 @@ var Item = exports.Item = function Item(_ref) {
|
|
41
41
|
handleItemClick = _useContext.handleItemClick,
|
42
42
|
variant = _useContext.variant,
|
43
43
|
renderItem = _useContext.renderItem,
|
44
|
+
valueToItemMap = _useContext.valueToItemMap,
|
44
45
|
treeId = _useContext.treeId;
|
45
46
|
var itemDisabled = Boolean(disabled || isDisabled);
|
46
47
|
var disabledClassName = itemDisabled ? _Select.classes.dropdownItemIsDisabled : undefined;
|
@@ -95,7 +96,7 @@ var Item = exports.Item = function Item(_ref) {
|
|
95
96
|
}))), !multiselect && checked.get(item.value) === 'done' && /*#__PURE__*/_react["default"].createElement(_Icon.IconDone, {
|
96
97
|
size: (0, _utils.sizeToIconSize)(size, variant),
|
97
98
|
color: "inherit"
|
98
|
-
})), renderItem ? /*#__PURE__*/_react["default"].createElement(_Item.StyledText, null, renderItem(
|
99
|
+
})), renderItem ? /*#__PURE__*/_react["default"].createElement(_Item.StyledText, null, renderItem(valueToItemMap.get(value))) : /*#__PURE__*/_react["default"].createElement(_Item.StyledWrapper, null, /*#__PURE__*/_react["default"].createElement(_Item.StyledCell, {
|
99
100
|
contentLeft: contentLeft,
|
100
101
|
contentRight: contentRight
|
101
102
|
// TODO: #1548
|
@@ -12,12 +12,6 @@ var _Textfield = /*#__PURE__*/require("./Textfield.styles");
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
14
14
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
15
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
16
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
19
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
21
15
|
var Textfield = exports.Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
22
16
|
var _valueToItemMap$get;
|
23
17
|
var inputWrapperRef = _ref.inputWrapperRef,
|
@@ -62,24 +56,9 @@ var Textfield = exports.Textfield = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
62
56
|
|
63
57
|
// Обработчик чипов
|
64
58
|
var handleChipsChange = function handleChipsChange(chipLabels) {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
// Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
|
69
|
-
if (renderValue && !isTargetAmount) {
|
70
|
-
var resultValues = _toConsumableArray(value);
|
71
|
-
value.forEach(function (_, index) {
|
72
|
-
var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
|
73
|
-
if (!chipLabels.includes(labelAfterRenderValue)) {
|
74
|
-
resultValues.splice(index, 1);
|
75
|
-
}
|
76
|
-
});
|
77
|
-
onChange(resultValues);
|
78
|
-
} else {
|
79
|
-
onChange(chipLabels.map(function (chipLabel) {
|
80
|
-
return labelToItemMap.get(chipLabel).value;
|
81
|
-
}));
|
82
|
-
}
|
59
|
+
onChange(chipLabels.map(function (chipLabel) {
|
60
|
+
return labelToItemMap.get(chipLabel).value;
|
61
|
+
}));
|
83
62
|
};
|
84
63
|
return /*#__PURE__*/_react["default"].createElement(_Textfield.StyledTextField, _extends({
|
85
64
|
ref: ref,
|
@@ -23,7 +23,7 @@ var _TextField2 = /*#__PURE__*/require("./TextField.tokens");
|
|
23
23
|
var _ui = /*#__PURE__*/require("./ui");
|
24
24
|
var _hooks2 = /*#__PURE__*/require("./hooks");
|
25
25
|
var _Hint = /*#__PURE__*/require("./ui/Hint/Hint");
|
26
|
-
var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "titleCaption", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "hasDivider", "value", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
|
26
|
+
var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "titleCaption", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "hasDivider", "value", "chips", "validationType", "options", "passwordHidden", "onValidate", "onChange", "onBlur", "onChangeChips", "onSearch", "onKeyDown"];
|
27
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
28
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
29
29
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -86,7 +86,12 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
86
86
|
hasDivider = _ref.hasDivider,
|
87
87
|
outerValue = _ref.value,
|
88
88
|
values = _ref.chips,
|
89
|
+
validationType = _ref.validationType,
|
90
|
+
options = _ref.options,
|
91
|
+
passwordHidden = _ref.passwordHidden,
|
92
|
+
onValidate = _ref.onValidate,
|
89
93
|
onChange = _ref.onChange,
|
94
|
+
onBlur = _ref.onBlur,
|
90
95
|
onChangeChips = _ref.onChangeChips,
|
91
96
|
onSearch = _ref.onSearch,
|
92
97
|
onKeyDown = _ref.onKeyDown,
|
@@ -136,6 +141,7 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
136
141
|
var hasValueClass = hasValue ? _TextField2.classes.hasValue : undefined;
|
137
142
|
var wrapperWithoutLeftContent = !contentLeft && isChipsVisible ? _TextField2.classes.hasEmptyContentLeft : undefined;
|
138
143
|
var wrapperWithoutRightContent = !contentRight && isChipsVisible ? _TextField2.classes.hasEmptyContentRight : undefined;
|
144
|
+
var isPasswordHidden = validationType === 'password' && passwordHidden;
|
139
145
|
var hintRef = (0, _hooks.useOutsideClick)(function () {
|
140
146
|
setIsHintVisible(false);
|
141
147
|
});
|
@@ -178,6 +184,13 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
178
184
|
setChips(newChips);
|
179
185
|
onChangeChips === null || onChangeChips === void 0 || onChangeChips(newValues);
|
180
186
|
};
|
187
|
+
var _useValidation = (0, _hooks2.useValidation)({
|
188
|
+
validationType: validationType,
|
189
|
+
options: options,
|
190
|
+
onValidate: onValidate
|
191
|
+
}),
|
192
|
+
handleValidationBlur = _useValidation.handleValidationBlur,
|
193
|
+
handleValidationKeyDown = _useValidation.handleValidationKeyDown;
|
181
194
|
var _useKeyNavigation = (0, _hooks2.useKeyNavigation)({
|
182
195
|
controlledRefs: controlledRefs,
|
183
196
|
disabled: disabled,
|
@@ -207,6 +220,12 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
207
220
|
});
|
208
221
|
inputRef.current.focus();
|
209
222
|
};
|
223
|
+
var handleInputBlur = function handleInputBlur(event) {
|
224
|
+
if (onBlur) {
|
225
|
+
onBlur(event);
|
226
|
+
}
|
227
|
+
handleValidationBlur(event);
|
228
|
+
};
|
210
229
|
var getRef = function getRef(element, index) {
|
211
230
|
if (element && chipsRefs !== null && chipsRefs !== void 0 && chipsRefs.current) {
|
212
231
|
chipsRefs.current[index] = element;
|
@@ -214,6 +233,7 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
214
233
|
};
|
215
234
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
216
235
|
handleInputKeydown(event);
|
236
|
+
handleValidationKeyDown(event);
|
217
237
|
if (onKeyDown) {
|
218
238
|
onKeyDown(event);
|
219
239
|
}
|
@@ -347,8 +367,11 @@ var textFieldRoot = exports.textFieldRoot = function textFieldRoot(Root) {
|
|
347
367
|
readOnly: !disabled && readOnly,
|
348
368
|
onInput: handleInput,
|
349
369
|
onChange: handleChange,
|
350
|
-
onKeyDown: handleOnKeyDown
|
351
|
-
|
370
|
+
onKeyDown: handleOnKeyDown,
|
371
|
+
onBlur: handleInputBlur
|
372
|
+
}, rest, isPasswordHidden && {
|
373
|
+
type: 'password'
|
374
|
+
})), hasInnerLabel && /*#__PURE__*/_react["default"].createElement(_TextField.Label, {
|
352
375
|
id: labelId,
|
353
376
|
htmlFor: innerId
|
354
377
|
}, innerLabelValue, optionalTextNode), placeholderShown && !hasValue && /*#__PURE__*/_react["default"].createElement(_TextField.InputPlaceholder, null, innerPlaceholderValue, hasPlaceholderOptional && optionalTextNode)), textAfter && /*#__PURE__*/_react["default"].createElement(_TextField.StyledTextAfter, null, textAfter)), contentRight && /*#__PURE__*/_react["default"].createElement(_TextField.StyledContentRight, null, contentRight)), leftHelper && /*#__PURE__*/_react["default"].createElement(_TextField.LeftHelper, {
|
@@ -5,6 +5,9 @@ title: TextField
|
|
5
5
|
|
6
6
|
import { PropsTable, Description } from '@site/src/components';
|
7
7
|
|
8
|
+
import Tabs from '@theme/Tabs';
|
9
|
+
import TabItem from '@theme/TabItem';
|
10
|
+
|
8
11
|
# TextField
|
9
12
|
<Description name="TextField" />
|
10
13
|
<PropsTable name="TextField" exclude={['$isFocused']} />
|
@@ -198,3 +201,330 @@ export function App() {
|
|
198
201
|
);
|
199
202
|
}
|
200
203
|
```
|
204
|
+
|
205
|
+
### Валидация
|
206
|
+
Поддерживается валидация почты и пароля:
|
207
|
+
|
208
|
+
<Tabs>
|
209
|
+
<TabItem value="email" label="Email" default>
|
210
|
+
Свойства доступные при валидации почты:
|
211
|
+
```tsx
|
212
|
+
type ValidationProps = {
|
213
|
+
/*
|
214
|
+
* Тип валидации
|
215
|
+
*/
|
216
|
+
validationType: 'email';
|
217
|
+
/*
|
218
|
+
* Опции валидации
|
219
|
+
*/
|
220
|
+
options?: EmailValidationOptions;
|
221
|
+
/*
|
222
|
+
* Функция, вызываемая при валидации значения.
|
223
|
+
* Вызывается при событии onBlur и по нажатию Enter, когда фокус на поле ввода
|
224
|
+
*/
|
225
|
+
onValidate?: (args: OnValidateArgs) => void;
|
226
|
+
}
|
227
|
+
```
|
228
|
+
Свойство `options` имеет следующий вид:
|
229
|
+
```tsx
|
230
|
+
type EmailValidationOptions = {
|
231
|
+
/*
|
232
|
+
* Пользовательское регулярное выражение, для проверки почты на валидность
|
233
|
+
*/
|
234
|
+
customEmailRegex?: {
|
235
|
+
value?: RegExp;
|
236
|
+
errorMessage?: string;
|
237
|
+
};
|
238
|
+
/*
|
239
|
+
* Минимальная длина почты
|
240
|
+
*/
|
241
|
+
minLength?: {
|
242
|
+
value?: number;
|
243
|
+
errorMessage?: string;
|
244
|
+
};
|
245
|
+
/*
|
246
|
+
* Максимальная длина почты
|
247
|
+
*/
|
248
|
+
maxLength?: {
|
249
|
+
value?: number;
|
250
|
+
errorMessage?: string;
|
251
|
+
};
|
252
|
+
/*
|
253
|
+
* Минимальная длина хоста (часть почты до `@`)
|
254
|
+
*/
|
255
|
+
minHostLength?: {
|
256
|
+
value?: number;
|
257
|
+
errorMessage?: string;
|
258
|
+
};
|
259
|
+
/*
|
260
|
+
* Максимальная длина хоста (часть почты до `@`)
|
261
|
+
*/
|
262
|
+
maxHostLength?: {
|
263
|
+
value?: number;
|
264
|
+
errorMessage?: string;
|
265
|
+
};
|
266
|
+
/*
|
267
|
+
* Минимальная длина домена (часть почты от `@` до `.` перед доменной зоной)
|
268
|
+
*/
|
269
|
+
minDomainLength?: {
|
270
|
+
value?: number;
|
271
|
+
errorMessage?: string;
|
272
|
+
};
|
273
|
+
/*
|
274
|
+
* Максимальная длина домена (часть почты от `@` до `.` перед доменной зоной)
|
275
|
+
*/
|
276
|
+
maxDomainLength?: {
|
277
|
+
value?: number;
|
278
|
+
errorMessage?: string;
|
279
|
+
};
|
280
|
+
/*
|
281
|
+
* Минимальная длина доменной зоны (часть почты от `.`; например `ru`, `com`...)
|
282
|
+
*/
|
283
|
+
minZoneLength?: {
|
284
|
+
value?: number;
|
285
|
+
errorMessage?: string;
|
286
|
+
};
|
287
|
+
/*
|
288
|
+
* Максимальная длина доменной зоны (часть почты от `.`; например `ru`, `com`...)
|
289
|
+
*/
|
290
|
+
maxZoneLength?: {
|
291
|
+
value?: number;
|
292
|
+
errorMessage?: string;
|
293
|
+
};
|
294
|
+
/*
|
295
|
+
* Список разрешенных доменов (например `['mail.ru', 'yahoo.ru', 'gmail.com']`)
|
296
|
+
*/
|
297
|
+
whitelistDomains?: {
|
298
|
+
value?: string[];
|
299
|
+
errorMessage?: string;
|
300
|
+
};
|
301
|
+
/*
|
302
|
+
* Список запрещенных доменов (например `['org.biz', 'expressmail.com']`)
|
303
|
+
*/
|
304
|
+
blacklistDomains?: {
|
305
|
+
value?: string[];
|
306
|
+
errorMessage?: string;
|
307
|
+
};
|
308
|
+
};
|
309
|
+
```
|
310
|
+
|
311
|
+
```tsx live
|
312
|
+
import React, { useState } from 'react';
|
313
|
+
import { TextField } from '@salutejs/{{ package }}';
|
314
|
+
|
315
|
+
export function App() {
|
316
|
+
const options = {
|
317
|
+
minLength: {
|
318
|
+
value: 7,
|
319
|
+
errorMessage: 'Почта слишком короткая',
|
320
|
+
},
|
321
|
+
maxLength: {
|
322
|
+
value: 30,
|
323
|
+
errorMessage: 'Почта слишком длинная',
|
324
|
+
},
|
325
|
+
minHostLength: {
|
326
|
+
value: 2,
|
327
|
+
errorMessage: 'Хост слишком короткий',
|
328
|
+
},
|
329
|
+
maxHostLength: {
|
330
|
+
value: 12,
|
331
|
+
errorMessage: 'Хост слишком длинный',
|
332
|
+
},
|
333
|
+
minDomainLength: {
|
334
|
+
value: 3,
|
335
|
+
errorMessage: 'Домен слишком короткий',
|
336
|
+
},
|
337
|
+
maxDomainLength: {
|
338
|
+
value: 6,
|
339
|
+
errorMessage: 'Домен слишком длинный',
|
340
|
+
},
|
341
|
+
minZoneLength: {
|
342
|
+
value: 2,
|
343
|
+
errorMessage: 'Доменная зона слишком короткая',
|
344
|
+
},
|
345
|
+
maxZoneLength: {
|
346
|
+
value: 5,
|
347
|
+
errorMessage: 'Доменная зона слишком длинная',
|
348
|
+
},
|
349
|
+
whitelistDomains: {
|
350
|
+
value: ['plasma.ru', 'gmail.com', 'mail.ru'],
|
351
|
+
errorMessage: 'Домен не разрешен',
|
352
|
+
},
|
353
|
+
blacklistDomains: {
|
354
|
+
value: ['hah.ah', 'heh.eh'],
|
355
|
+
errorMessage: 'Домен запрещен',
|
356
|
+
},
|
357
|
+
};
|
358
|
+
|
359
|
+
const [error, setError] = useState('');
|
360
|
+
|
361
|
+
const handleOnChange = () => {
|
362
|
+
setError('');
|
363
|
+
};
|
364
|
+
|
365
|
+
const handleOnValidate = ({ errorMessage }: { errorMessage?: string }) => {
|
366
|
+
setError(errorMessage || '');
|
367
|
+
};
|
368
|
+
|
369
|
+
return (
|
370
|
+
<div>
|
371
|
+
<TextField
|
372
|
+
label="Валидация почты"
|
373
|
+
placeholder="Заполните поле"
|
374
|
+
validationType="email"
|
375
|
+
options={options}
|
376
|
+
view={error ? 'negative' : 'default}
|
377
|
+
helperText={error || 'Валидация почты'}
|
378
|
+
onChange={handleOnChange}
|
379
|
+
onValidate={handleOnValidate}
|
380
|
+
/>
|
381
|
+
</div>
|
382
|
+
);
|
383
|
+
}
|
384
|
+
```
|
385
|
+
</TabItem>
|
386
|
+
|
387
|
+
<TabItem value="password" label="Password" default>
|
388
|
+
Свойства доступные при валидации пароля:
|
389
|
+
```tsx
|
390
|
+
type ValidationProps = {
|
391
|
+
/*
|
392
|
+
* Тип валидации
|
393
|
+
*/
|
394
|
+
validationType: 'password';
|
395
|
+
/*
|
396
|
+
* Опции валидации
|
397
|
+
*/
|
398
|
+
options?: PasswordValidationOptions;
|
399
|
+
/*
|
400
|
+
* Состояние сокрытия оригинального пароля
|
401
|
+
*/
|
402
|
+
passwordHidden?: boolean;
|
403
|
+
/*
|
404
|
+
* Функция, вызываемая при валидации значения.
|
405
|
+
* Вызывается при событии onBlur и по нажатию Enter, когда фокус на поле ввода
|
406
|
+
*/
|
407
|
+
onValidate?: (args: OnValidateArgs) => void;
|
408
|
+
}
|
409
|
+
```
|
410
|
+
Свойство `options` имеет следующий вид:
|
411
|
+
```tsx
|
412
|
+
type PasswordValidationOptions = {
|
413
|
+
/*
|
414
|
+
* Минимальная длина пароля
|
415
|
+
*/
|
416
|
+
minLength?: {
|
417
|
+
value?: number;
|
418
|
+
errorMessage?: string;
|
419
|
+
};
|
420
|
+
/*
|
421
|
+
* Максимальная длина пароля
|
422
|
+
*/
|
423
|
+
maxLength?: {
|
424
|
+
value?: number;
|
425
|
+
errorMessage?: string;
|
426
|
+
};
|
427
|
+
/*
|
428
|
+
* Должны ли быть буквы верхнего регистра в пароле
|
429
|
+
*/
|
430
|
+
includeUppercase?: {
|
431
|
+
value?: boolean;
|
432
|
+
errorMessage?: string;
|
433
|
+
};
|
434
|
+
/*
|
435
|
+
* Должны ли быть буквы нижнего регистра в пароле
|
436
|
+
*/
|
437
|
+
includeLowercase?: {
|
438
|
+
value?: boolean;
|
439
|
+
errorMessage?: string;
|
440
|
+
};
|
441
|
+
/*
|
442
|
+
* Должны ли быть цифры в пароле
|
443
|
+
*/
|
444
|
+
includeDigits?: {
|
445
|
+
value?: boolean;
|
446
|
+
errorMessage?: string;
|
447
|
+
};
|
448
|
+
/*
|
449
|
+
* Должны ли быть специальные символы в пароле
|
450
|
+
*/
|
451
|
+
includeSpecialSymbols?: {
|
452
|
+
value?: boolean;
|
453
|
+
errorMessage?: string;
|
454
|
+
};
|
455
|
+
};
|
456
|
+
```
|
457
|
+
|
458
|
+
```tsx live
|
459
|
+
import React, { useState } from 'react';
|
460
|
+
import { TextField, IconButton } from '@salutejs/{{ package }}';
|
461
|
+
import { IconEyeFill, IconEyeClosedFill } from '@salutejs/plasma-icons';
|
462
|
+
|
463
|
+
export function App() {
|
464
|
+
const options = {
|
465
|
+
minLength: {
|
466
|
+
value: 5,
|
467
|
+
errorMessage: 'Пароль слишком короткий',
|
468
|
+
},
|
469
|
+
maxLength: {
|
470
|
+
value: 20,
|
471
|
+
errorMessage: 'Пароль слишком длинный',
|
472
|
+
},
|
473
|
+
includeUppercase: {
|
474
|
+
value: true,
|
475
|
+
errorMessage: 'Пароль должен содержать хотя бы одну заглавную букву',
|
476
|
+
},
|
477
|
+
includeLowercase: {
|
478
|
+
value: true,
|
479
|
+
errorMessage: 'Пароль должен содержать хотя бы одну строчную букву',
|
480
|
+
},
|
481
|
+
includeDigits: {
|
482
|
+
value: true,
|
483
|
+
errorMessage: 'Пароль должен содержать хотя бы одну цифру',
|
484
|
+
},
|
485
|
+
includeSpecialSymbols: {
|
486
|
+
value: true,
|
487
|
+
errorMessage: 'Пароль должен содержать хотя бы один специальный символ',
|
488
|
+
},
|
489
|
+
};
|
490
|
+
|
491
|
+
const [error, setError] = useState('');
|
492
|
+
const [hidden, setHidden] = useState(false);
|
493
|
+
|
494
|
+
const handleOnChange = () => {
|
495
|
+
setError('');
|
496
|
+
};
|
497
|
+
|
498
|
+
const handleOnValidate = ({ errorMessage }: { errorMessage?: string }) => {
|
499
|
+
setError(errorMessage || '');
|
500
|
+
};
|
501
|
+
|
502
|
+
const toggleShowPassword = () => setHidden(!hidden);
|
503
|
+
|
504
|
+
const HideButton = () => (
|
505
|
+
<IconButton size="s" view="clear" onClick={toggleShowPassword}>
|
506
|
+
{hidden ? <IconEyeClosedFill size="xs" color="inherit" /> : <IconEyeFill size="xs" color="inherit" />}
|
507
|
+
</IconButton>
|
508
|
+
)
|
509
|
+
|
510
|
+
return (
|
511
|
+
<div>
|
512
|
+
<TextField
|
513
|
+
label="Валидация пароля"
|
514
|
+
placeholder="Заполните поле"
|
515
|
+
validationType="password"
|
516
|
+
options={options}
|
517
|
+
view={error ? 'negative' : 'default'}
|
518
|
+
leftHelper={error || 'Валидация пароля'}
|
519
|
+
onChange={handleOnChange}
|
520
|
+
onValidate={handleOnValidate}
|
521
|
+
passwordHidden={hidden}
|
522
|
+
contentLeft={<HideButton />}
|
523
|
+
/>
|
524
|
+
</div>
|
525
|
+
);
|
526
|
+
}
|
527
|
+
```
|
528
|
+
</TabItem>
|
529
|
+
</Tabs>
|
530
|
+
|
@@ -9,4 +9,11 @@ Object.defineProperty(exports, "useKeyNavigation", {
|
|
9
9
|
return _useKeyNavigation.useKeyNavigation;
|
10
10
|
}
|
11
11
|
});
|
12
|
-
|
12
|
+
Object.defineProperty(exports, "useValidation", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function get() {
|
15
|
+
return _useValidation.useValidation;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
var _useKeyNavigation = /*#__PURE__*/require("./useKeyNavigation");
|
19
|
+
var _useValidation = /*#__PURE__*/require("./useValidation");
|