@skbkontur/react-ui 4.11.0 → 4.12.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/CHANGELOG.md +17 -0
- package/cjs/components/Autocomplete/Autocomplete.d.ts +2 -0
- package/cjs/components/Autocomplete/Autocomplete.js +31 -7
- package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
- package/cjs/components/Autocomplete/locale/index.d.ts +4 -0
- package/cjs/components/Autocomplete/locale/index.js +11 -0
- package/cjs/components/Autocomplete/locale/index.js.map +1 -0
- package/cjs/components/Autocomplete/locale/locales/en.d.ts +2 -0
- package/cjs/components/Autocomplete/locale/locales/en.js +6 -0
- package/cjs/components/Autocomplete/locale/locales/en.js.map +1 -0
- package/cjs/components/Autocomplete/locale/locales/ru.d.ts +2 -0
- package/cjs/components/Autocomplete/locale/locales/ru.js +6 -0
- package/cjs/components/Autocomplete/locale/locales/ru.js.map +1 -0
- package/cjs/components/Autocomplete/locale/types.d.ts +5 -0
- package/cjs/components/Autocomplete/locale/types.js +1 -0
- package/cjs/components/Autocomplete/locale/types.js.map +1 -0
- package/cjs/components/ComboBox/ComboBox.md +42 -0
- package/cjs/components/CurrencyInput/CurrencyInputKeyboardActions.d.ts +1 -1
- package/cjs/components/Dropdown/Dropdown.d.ts +2 -1
- package/cjs/components/Dropdown/Dropdown.js +3 -1
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/DropdownMenu/DropdownMenu.md +27 -0
- package/cjs/components/Hint/Hint.d.ts +0 -3
- package/cjs/components/Hint/Hint.js +2 -27
- package/cjs/components/Hint/Hint.js.map +1 -1
- package/cjs/components/Hint/Hint.md +29 -0
- package/cjs/components/Hint/Hint.styles.d.ts +0 -1
- package/cjs/components/Hint/Hint.styles.js +2 -10
- package/cjs/components/Hint/Hint.styles.js.map +1 -1
- package/cjs/components/MenuItem/MenuItem.js +10 -8
- package/cjs/components/MenuItem/MenuItem.js.map +1 -1
- package/cjs/components/MenuItem/MenuItem.styles.d.ts +5 -1
- package/cjs/components/MenuItem/MenuItem.styles.js +28 -12
- package/cjs/components/MenuItem/MenuItem.styles.js.map +1 -1
- package/cjs/components/MenuSeparator/MenuSeparator.js +12 -1
- package/cjs/components/MenuSeparator/MenuSeparator.js.map +1 -1
- package/cjs/components/MenuSeparator/MenuSeparator.styles.d.ts +1 -0
- package/cjs/components/MenuSeparator/MenuSeparator.styles.js +8 -1
- package/cjs/components/MenuSeparator/MenuSeparator.styles.js.map +1 -1
- package/cjs/components/Modal/Modal.js +1 -5
- package/cjs/components/Modal/Modal.js.map +1 -1
- package/cjs/components/Select/Select.d.ts +2 -1
- package/cjs/components/Select/Select.js +13 -8
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/SidePage/SidePage.js +0 -2
- package/cjs/components/SidePage/SidePage.js.map +1 -1
- package/cjs/components/Toast/Toast.d.ts +6 -3
- package/cjs/components/Toast/Toast.js +15 -8
- package/cjs/components/Toast/Toast.js.map +1 -1
- package/cjs/components/Toast/Toast.md +129 -0
- package/cjs/components/Toast/ToastStatic.d.ts +3 -2
- package/cjs/components/Toast/ToastStatic.js +5 -5
- package/cjs/components/Toast/ToastStatic.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.d.ts +0 -2
- package/cjs/components/Tooltip/Tooltip.js +3 -23
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/cjs/components/TooltipMenu/TooltipMenu.md +27 -0
- package/cjs/internal/CustomComboBox/ComboBoxMenu.js +2 -3
- package/cjs/internal/CustomComboBox/ComboBoxMenu.js.map +1 -1
- package/cjs/internal/CustomComboBox/ComboBoxView.js +0 -1
- package/cjs/internal/CustomComboBox/ComboBoxView.js.map +1 -1
- package/cjs/internal/Menu/Menu.d.ts +1 -0
- package/cjs/internal/Menu/Menu.js +20 -8
- package/cjs/internal/Menu/Menu.js.map +1 -1
- package/cjs/internal/Menu/Menu.styles.d.ts +2 -0
- package/cjs/internal/Menu/Menu.styles.js +19 -6
- package/cjs/internal/Menu/Menu.styles.js.map +1 -1
- package/cjs/internal/MenuMessage/MenuMessage.d.ts +10 -0
- package/cjs/internal/MenuMessage/MenuMessage.js +42 -0
- package/cjs/internal/MenuMessage/MenuMessage.js.map +1 -0
- package/cjs/internal/MenuMessage/MenuMessage.styles.d.ts +5 -0
- package/cjs/internal/MenuMessage/MenuMessage.styles.js +33 -0
- package/cjs/internal/MenuMessage/MenuMessage.styles.js.map +1 -0
- package/cjs/internal/MenuMessage/index.d.ts +1 -0
- package/cjs/internal/MenuMessage/index.js +1 -0
- package/cjs/internal/MenuMessage/index.js.map +1 -0
- package/cjs/internal/MobilePopup/MobilePopup.d.ts +13 -12
- package/cjs/internal/MobilePopup/MobilePopup.js +6 -60
- package/cjs/internal/MobilePopup/MobilePopup.js.map +1 -1
- package/cjs/internal/MobilePopup/MobilePopup.styles.d.ts +3 -3
- package/cjs/internal/MobilePopup/MobilePopup.styles.js +22 -24
- package/cjs/internal/MobilePopup/MobilePopup.styles.js.map +1 -1
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.d.ts +3 -4
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.js +26 -37
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.js.map +1 -1
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.d.ts +2 -4
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.js +8 -32
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.js.map +1 -1
- package/cjs/internal/Popup/Popup.js +1 -1
- package/cjs/internal/Popup/Popup.js.map +1 -1
- package/cjs/internal/RenderLayer/RenderLayer.js +5 -1
- package/cjs/internal/RenderLayer/RenderLayer.js.map +1 -1
- package/cjs/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
- package/cjs/internal/themes/DefaultTheme.d.ts +22 -3
- package/cjs/internal/themes/DefaultTheme.js +52 -7
- package/cjs/internal/themes/DefaultTheme.js.map +1 -1
- package/cjs/lib/locale/LOCALECONTEXT.md +1 -0
- package/cjs/typings/html-props.d.ts +2 -2
- package/components/Autocomplete/Autocomplete/Autocomplete.js +27 -6
- package/components/Autocomplete/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Autocomplete/Autocomplete.d.ts +2 -0
- package/components/Autocomplete/locale/index/index.js +8 -0
- package/components/Autocomplete/locale/index/index.js.map +1 -0
- package/components/Autocomplete/locale/index/package.json +6 -0
- package/components/Autocomplete/locale/index.d.ts +4 -0
- package/components/Autocomplete/locale/locales/en/en.js +5 -0
- package/components/Autocomplete/locale/locales/en/en.js.map +1 -0
- package/components/Autocomplete/locale/locales/en/package.json +6 -0
- package/components/Autocomplete/locale/locales/en.d.ts +2 -0
- package/components/Autocomplete/locale/locales/ru/package.json +6 -0
- package/components/Autocomplete/locale/locales/ru/ru.js +5 -0
- package/components/Autocomplete/locale/locales/ru/ru.js.map +1 -0
- package/components/Autocomplete/locale/locales/ru.d.ts +2 -0
- package/components/Autocomplete/locale/package.json +6 -0
- package/components/Autocomplete/locale/types/package.json +6 -0
- package/components/Autocomplete/locale/types/types.js +1 -0
- package/components/Autocomplete/locale/types/types.js.map +1 -0
- package/components/Autocomplete/locale/types.d.ts +5 -0
- package/components/ComboBox/ComboBox.md +42 -0
- package/components/CurrencyInput/CurrencyInputKeyboardActions.d.ts +1 -1
- package/components/Dropdown/Dropdown/Dropdown.js +2 -1
- package/components/Dropdown/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/Dropdown.d.ts +2 -1
- package/components/DropdownMenu/DropdownMenu.md +27 -0
- package/components/Hint/Hint/Hint.js +7 -24
- package/components/Hint/Hint/Hint.js.map +1 -1
- package/components/Hint/Hint.d.ts +0 -3
- package/components/Hint/Hint.md +29 -0
- package/components/Hint/Hint.styles/Hint.styles.js +2 -5
- package/components/Hint/Hint.styles/Hint.styles.js.map +1 -1
- package/components/Hint/Hint.styles.d.ts +0 -1
- package/components/MenuItem/MenuItem/MenuItem.js +10 -8
- package/components/MenuItem/MenuItem/MenuItem.js.map +1 -1
- package/components/MenuItem/MenuItem.styles/MenuItem.styles.js +27 -8
- package/components/MenuItem/MenuItem.styles/MenuItem.styles.js.map +1 -1
- package/components/MenuItem/MenuItem.styles.d.ts +5 -1
- package/components/MenuSeparator/MenuSeparator/MenuSeparator.js +10 -3
- package/components/MenuSeparator/MenuSeparator/MenuSeparator.js.map +1 -1
- package/components/MenuSeparator/MenuSeparator.styles/MenuSeparator.styles.js +4 -1
- package/components/MenuSeparator/MenuSeparator.styles/MenuSeparator.styles.js.map +1 -1
- package/components/MenuSeparator/MenuSeparator.styles.d.ts +1 -0
- package/components/Modal/Modal/Modal.js +1 -1
- package/components/Modal/Modal/Modal.js.map +1 -1
- package/components/Select/Select/Select.js +20 -21
- package/components/Select/Select/Select.js.map +1 -1
- package/components/Select/Select.d.ts +2 -1
- package/components/SidePage/SidePage/SidePage.js.map +1 -1
- package/components/Toast/Toast/Toast.js +15 -8
- package/components/Toast/Toast/Toast.js.map +1 -1
- package/components/Toast/Toast.d.ts +6 -3
- package/components/Toast/Toast.md +129 -0
- package/components/Toast/ToastStatic/ToastStatic.js +5 -5
- package/components/Toast/ToastStatic/ToastStatic.js.map +1 -1
- package/components/Toast/ToastStatic.d.ts +3 -2
- package/components/Tooltip/Tooltip/Tooltip.js +5 -25
- package/components/Tooltip/Tooltip/Tooltip.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +0 -2
- package/components/TooltipMenu/TooltipMenu.md +27 -0
- package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js +9 -15
- package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js +0 -1
- package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js.map +1 -1
- package/internal/Menu/Menu/Menu.js +9 -7
- package/internal/Menu/Menu/Menu.js.map +1 -1
- package/internal/Menu/Menu.d.ts +1 -0
- package/internal/Menu/Menu.styles/Menu.styles.js +12 -6
- package/internal/Menu/Menu.styles/Menu.styles.js.map +1 -1
- package/internal/Menu/Menu.styles.d.ts +2 -0
- package/internal/MenuMessage/MenuMessage/MenuMessage.js +30 -0
- package/internal/MenuMessage/MenuMessage/MenuMessage.js.map +1 -0
- package/internal/MenuMessage/MenuMessage/package.json +6 -0
- package/internal/MenuMessage/MenuMessage.d.ts +10 -0
- package/internal/MenuMessage/MenuMessage.styles/MenuMessage.styles.js +23 -0
- package/internal/MenuMessage/MenuMessage.styles/MenuMessage.styles.js.map +1 -0
- package/internal/MenuMessage/MenuMessage.styles/package.json +6 -0
- package/internal/MenuMessage/MenuMessage.styles.d.ts +5 -0
- package/internal/MenuMessage/index/index.js +1 -0
- package/internal/MenuMessage/index/index.js.map +1 -0
- package/internal/MenuMessage/index/package.json +6 -0
- package/internal/MenuMessage/index.d.ts +1 -0
- package/internal/MenuMessage/package.json +6 -0
- package/internal/MobilePopup/MobilePopup/MobilePopup.js +23 -53
- package/internal/MobilePopup/MobilePopup/MobilePopup.js.map +1 -1
- package/internal/MobilePopup/MobilePopup.d.ts +13 -12
- package/internal/MobilePopup/MobilePopup.styles/MobilePopup.styles.js +11 -11
- package/internal/MobilePopup/MobilePopup.styles/MobilePopup.styles.js.map +1 -1
- package/internal/MobilePopup/MobilePopup.styles.d.ts +3 -3
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader/MobilePopupHeader.js +11 -35
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader/MobilePopupHeader.js.map +1 -1
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.d.ts +3 -4
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles/MobilePopupHeader.styles.js +6 -12
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles/MobilePopupHeader.styles.js.map +1 -1
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.d.ts +2 -4
- package/internal/Popup/Popup/Popup.js +1 -1
- package/internal/Popup/Popup/Popup.js.map +1 -1
- package/internal/RenderLayer/RenderLayer/RenderLayer.js +2 -2
- package/internal/RenderLayer/RenderLayer/RenderLayer.js.map +1 -1
- package/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
- package/internal/themes/DefaultTheme/DefaultTheme.js +77 -9
- package/internal/themes/DefaultTheme/DefaultTheme.js.map +1 -1
- package/internal/themes/DefaultTheme.d.ts +22 -3
- package/lib/locale/LOCALECONTEXT.md +1 -0
- package/package.json +2 -2
- package/typings/html-props.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.12.0](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.11.0...@skbkontur/react-ui@4.12.0) (2023-02-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **Toast:** add `showTime` arg to the `push` method ([#3062](https://github.com/skbkontur/retail-ui/issues/3062)) ([e4196da](https://github.com/skbkontur/retail-ui/commit/e4196da2e6c1b39d9cb73fe5352b5a5d7d9d79a6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **Autocomplete,Select,ComboBox:** new design of mobile popups ([#3019](https://github.com/skbkontur/retail-ui/issues/3019)) ([c8e4d9a](https://github.com/skbkontur/retail-ui/commit/c8e4d9a4c9adcd4b504b866b4fb2eea9920c6db6))
|
|
17
|
+
* **Dropdown:** add prop `menuPos` for manual control ([#3099](https://github.com/skbkontur/retail-ui/issues/3099)) ([a215cec](https://github.com/skbkontur/retail-ui/commit/a215cecb58a4344fca4096c7a164430cfef3722c))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
# [4.11.0](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.10.0...@skbkontur/react-ui@4.11.0) (2023-01-13)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -76,6 +76,7 @@ export declare class Autocomplete extends React.Component<AutocompleteProps, Aut
|
|
|
76
76
|
static defaultProps: DefaultProps;
|
|
77
77
|
state: AutocompleteState;
|
|
78
78
|
private theme;
|
|
79
|
+
private readonly locale;
|
|
79
80
|
private isMobileLayout;
|
|
80
81
|
private opened;
|
|
81
82
|
private input;
|
|
@@ -96,6 +97,7 @@ export declare class Autocomplete extends React.Component<AutocompleteProps, Aut
|
|
|
96
97
|
componentDidUpdate(prevProps: AutocompleteProps): void;
|
|
97
98
|
render(): JSX.Element;
|
|
98
99
|
renderMain: (props: CommonWrapperRestProps<AutocompleteProps>) => JSX.Element;
|
|
100
|
+
private renderHints;
|
|
99
101
|
private renderMenu;
|
|
100
102
|
private renderMobileMenu;
|
|
101
103
|
private getItems;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
var _react = _interopRequireDefault(require("react"));
|
|
4
4
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
5
5
|
|
|
6
|
+
var _MenuMessage = require("../../internal/MenuMessage");
|
|
7
|
+
var _decorators = require("../../lib/locale/decorators");
|
|
8
|
+
var _utils = require("../../lib/utils");
|
|
6
9
|
var _ThemeContext = require("../../lib/theming/ThemeContext");
|
|
7
10
|
|
|
8
11
|
var _identifiers = require("../../lib/events/keyboard/identifiers");
|
|
@@ -20,7 +23,8 @@ var _decorator = require("../ResponsiveLayout/decorator");
|
|
|
20
23
|
var _rootNode = require("../../lib/rootNode");
|
|
21
24
|
var _getDOMRect = require("../../lib/dom/getDOMRect");
|
|
22
25
|
|
|
23
|
-
var _Autocomplete = require("./Autocomplete.styles");
|
|
26
|
+
var _Autocomplete = require("./Autocomplete.styles");
|
|
27
|
+
var _locale = require("./locale");var _excluded = ["onValueChange", "onKeyDown", "onFocus", "onBlur", "renderItem", "disablePortal", "hasShadow", "menuAlign", "menuMaxHeight", "preventWindowScroll", "source", "width", "mobileMenuHeaderText"];var _dec, _class, _class2, _temp;
|
|
24
28
|
|
|
25
29
|
function match(pattern, items) {
|
|
26
30
|
if (!pattern || !items) {
|
|
@@ -101,7 +105,8 @@ var AutocompleteDataTids = {
|
|
|
101
105
|
*/var
|
|
102
106
|
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
|
|
109
|
+
Autocomplete = (_dec = (0, _decorators.locale)('Autocomplete', _locale.AutocompleteLocaleHelper), (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)(_class = _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default)(Autocomplete, _React$Component);function Autocomplete() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;_this.
|
|
105
110
|
|
|
106
111
|
|
|
107
112
|
|
|
@@ -146,6 +151,7 @@ Autocomplete = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)
|
|
|
146
151
|
|
|
147
152
|
|
|
148
153
|
|
|
154
|
+
|
|
149
155
|
opened = false;_this.
|
|
150
156
|
input = null;_this.
|
|
151
157
|
|
|
@@ -258,6 +264,24 @@ Autocomplete = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)
|
|
|
258
264
|
|
|
259
265
|
|
|
260
266
|
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
261
285
|
|
|
262
286
|
|
|
263
287
|
|
|
@@ -274,7 +298,7 @@ Autocomplete = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)
|
|
|
274
298
|
onValueChange: _this.handleValueChange,
|
|
275
299
|
onKeyPress: _this.handleKeyPressMobile,
|
|
276
300
|
value: _this.props.value,
|
|
277
|
-
placeholder:
|
|
301
|
+
placeholder: _this.locale.enterValue };
|
|
278
302
|
|
|
279
303
|
|
|
280
304
|
var items = _this.state.items;
|
|
@@ -283,13 +307,13 @@ Autocomplete = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)
|
|
|
283
307
|
_react.default.createElement(_MobilePopup.MobilePopup, {
|
|
284
308
|
headerChildComponent: /*#__PURE__*/_react.default.createElement(_Input.Input, inputProps),
|
|
285
309
|
caption: _this.props.mobileMenuHeaderText,
|
|
286
|
-
useFullHeight: true,
|
|
287
310
|
opened: _this.state.isMobileOpened,
|
|
288
311
|
onCloseRequest: _this.handleCloseMobile,
|
|
289
312
|
ref: _this.refMobilePopup }, /*#__PURE__*/
|
|
290
313
|
|
|
291
314
|
_react.default.createElement(_Menu.Menu, { ref: _this.refMenu, onItemClick: (_this$mobilePopup = _this.mobilePopup) == null ? void 0 : _this$mobilePopup.close, disableScrollContainer: true, maxHeight: 'auto' },
|
|
292
|
-
items && items.length > 0 && _this.getItems()
|
|
315
|
+
items && items.length > 0 && _this.getItems(),
|
|
316
|
+
_this.renderHints())));
|
|
293
317
|
|
|
294
318
|
|
|
295
319
|
|
|
@@ -484,7 +508,7 @@ Autocomplete = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)
|
|
|
484
508
|
* @public
|
|
485
509
|
*/_proto.focus = function focus() {if (this.input) {this.input.focus();}} /**
|
|
486
510
|
* @public
|
|
487
|
-
*/;_proto.blur = function blur() {this.handleBlur();};_proto.componentDidUpdate = function componentDidUpdate(prevProps) {if (prevProps.value !== this.props.value) {this.updateItems(this.props.value || '');}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this2.setRootNode }, _this2.props), _this2.renderMain);});};_proto.renderMenu = function renderMenu() {var items = this.state.items;var _this$getProps = this.getProps(),menuMaxHeight = _this$getProps.menuMaxHeight,hasShadow = _this$getProps.hasShadow,menuWidth = _this$getProps.menuWidth,width = _this$getProps.width,preventWindowScroll = _this$getProps.preventWindowScroll,menuAlign = _this$getProps.menuAlign,disablePortal = _this$getProps.disablePortal,menuPos = _this$getProps.menuPos;var menuProps = { ref: this.refMenu, maxHeight: menuMaxHeight, hasShadow: hasShadow, width: menuWidth || width && (0, _getDOMRect.getDOMRect)(this.rootSpan).width, preventWindowScroll: preventWindowScroll };if (!items || items.length === 0) {return null;}return /*#__PURE__*/_react.default.createElement(_DropdownContainer.DropdownContainer, { offsetY: 1, getParent: this.getAnchor, align: menuAlign, disablePortal: disablePortal, menuPos: menuPos }, /*#__PURE__*/_react.default.createElement(_Menu.Menu, menuProps, this.getItems()));};_proto.handleMenuItemClick = function handleMenuItemClick(i) {var _this3 = this;return function (event) {return _this3.handleItemClick(event, i);};};_proto.handleItemClick = function handleItemClick(event, index) {if (event.button) {return;}event.preventDefault();this.choose(index);};_proto.choose = function choose(index) {if (!this.state.items) {return;}var value = this.state.items[index];this.opened = false;this.setState({ selected: -1, items: null });this.fireChange(value);this.blur();};_proto.updateItems = function updateItems(value) {var _this4 = this;if (!this.opened) {return;}var pattern = value.trim();var source = this.props.source;if (!source) {return;}var promise;this.requestId += 1;var expectingId = this.requestId;if (typeof source === 'function') {promise = source(pattern);} else {promise = match(pattern, source);}promise.then(function (items) {if (_this4.opened && expectingId === _this4.requestId) {_this4.setState({ items: items, selected: -1 });}});};_proto.fireChange = function fireChange(value) {if (this.props.onValueChange) {this.props.onValueChange(value);}};return Autocomplete;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Autocomplete', _class2.propTypes = { /**
|
|
511
|
+
*/;_proto.blur = function blur() {this.handleBlur();};_proto.componentDidUpdate = function componentDidUpdate(prevProps) {if (prevProps.value !== this.props.value) {this.updateItems(this.props.value || '');}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this2.setRootNode }, _this2.props), _this2.renderMain);});};_proto.renderHints = function renderHints() {var items = this.state.items;if (!this.props.value) {return /*#__PURE__*/_react.default.createElement(_MenuMessage.MenuMessage, null, this.locale.enterValue);}if ((items == null ? void 0 : items.length) === 0 && this.props.value) {return /*#__PURE__*/_react.default.createElement(_MenuMessage.MenuMessage, null, this.locale.notFound);}if ((0, _utils.isNullable)(items) && this.props.value) {return /*#__PURE__*/_react.default.createElement(_MenuMessage.MenuMessage, null, this.locale.updateValue);}return null;};_proto.renderMenu = function renderMenu() {var items = this.state.items;var _this$getProps = this.getProps(),menuMaxHeight = _this$getProps.menuMaxHeight,hasShadow = _this$getProps.hasShadow,menuWidth = _this$getProps.menuWidth,width = _this$getProps.width,preventWindowScroll = _this$getProps.preventWindowScroll,menuAlign = _this$getProps.menuAlign,disablePortal = _this$getProps.disablePortal,menuPos = _this$getProps.menuPos;var menuProps = { ref: this.refMenu, maxHeight: menuMaxHeight, hasShadow: hasShadow, width: menuWidth || width && (0, _getDOMRect.getDOMRect)(this.rootSpan).width, preventWindowScroll: preventWindowScroll };if (!items || items.length === 0) {return null;}return /*#__PURE__*/_react.default.createElement(_DropdownContainer.DropdownContainer, { offsetY: 1, getParent: this.getAnchor, align: menuAlign, disablePortal: disablePortal, menuPos: menuPos }, /*#__PURE__*/_react.default.createElement(_Menu.Menu, menuProps, this.getItems()));};_proto.handleMenuItemClick = function handleMenuItemClick(i) {var _this3 = this;return function (event) {return _this3.handleItemClick(event, i);};};_proto.handleItemClick = function handleItemClick(event, index) {if (event.button) {return;}event.preventDefault();this.choose(index);};_proto.choose = function choose(index) {if (!this.state.items) {return;}var value = this.state.items[index];this.opened = false;this.setState({ selected: -1, items: null });this.fireChange(value);this.blur();};_proto.updateItems = function updateItems(value) {var _this4 = this;if (!this.opened) {return;}var pattern = value.trim();var source = this.props.source;if (!source) {return;}var promise;this.requestId += 1;var expectingId = this.requestId;if (typeof source === 'function') {promise = source(pattern);} else {promise = match(pattern, source);}promise.then(function (items) {if (_this4.opened && expectingId === _this4.requestId) {_this4.setState({ items: items, selected: -1 });}});};_proto.fireChange = function fireChange(value) {if (this.props.onValueChange) {this.props.onValueChange(value);}};return Autocomplete;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Autocomplete', _class2.propTypes = { /**
|
|
488
512
|
* Функция для отрисовки элемента в выпадающем списке. Единственный аргумент
|
|
489
513
|
* — *item*.
|
|
490
514
|
*/renderItem: _propTypes.default.func, /**
|
|
@@ -499,4 +523,4 @@ Autocomplete = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)
|
|
|
499
523
|
* return service.findAll(pattern);
|
|
500
524
|
* }
|
|
501
525
|
* ```
|
|
502
|
-
*/source: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.func]) }, _class2.defaultProps = { renderItem: renderItem, size: 'small', disablePortal: false, hasShadow: true, menuMaxHeight: 300, menuAlign: 'left', preventWindowScroll: true }, _temp)) || _class) || _class;exports.Autocomplete = Autocomplete;
|
|
526
|
+
*/source: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.func]) }, _class2.defaultProps = { renderItem: renderItem, size: 'small', disablePortal: false, hasShadow: true, menuMaxHeight: 300, menuAlign: 'left', preventWindowScroll: true }, _temp)) || _class) || _class) || _class);exports.Autocomplete = Autocomplete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Autocomplete.tsx"],"names":["match","pattern","items","Promise","resolve","lowerCasedPattern","toLowerCase","itemsMatchingPattern","filter","item","includes","renderItem","AutocompleteDataTids","root","Autocomplete","responsiveLayout","rootNode","state","selected","focused","isMobileOpened","opened","input","requestId","getProps","defaultProps","renderMain","props","isMobile","isMobileLayout","onValueChange","onKeyDown","onFocus","onBlur","_renderItem","disablePortal","hasShadow","menuAlign","menuMaxHeight","preventWindowScroll","source","width","theme","inputWidth","mobileMenuHeaderText","rest","inputProps","handleValueChange","handleKeyDown","handleFocus","ref","refInput","handleBlur","handleClickOutside","styles","refRootSpan","renderMobileMenu","renderMenu","autoFocus","onKeyPress","handleKeyPressMobile","value","placeholder","handleCloseMobile","refMobilePopup","refMenu","mobilePopup","close","length","getItems","map","i","handleMenuItemClick","fireChange","setState","e","key","event","blur","preventDefault","menu","up","down","enter","getAnchor","el","span","rootSpan","focus","componentDidUpdate","prevProps","updateItems","render","setRootNode","menuWidth","menuPos","menuProps","maxHeight","handleItemClick","index","button","choose","trim","promise","expectingId","then","React","Component","__KONTUR_REACT_UI__","propTypes","PropTypes","func","oneOfType","array","size"],"mappings":";;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,qD;;AAEA,SAASA,KAAT,CAAeC,OAAf,EAAgCC,KAAhC,EAAiD;AAC/C,MAAI,CAACD,OAAD,IAAY,CAACC,KAAjB,EAAwB;AACtB,WAAOC,OAAO,CAACC,OAAR,CAAgB,EAAhB,CAAP;AACD;;AAED,MAAMC,iBAAiB,GAAGJ,OAAO,CAACK,WAAR,EAA1B;AACA,MAAMC,oBAAoB,GAAGL,KAAK,CAACM,MAAN,CAAa,UAACC,IAAD,EAAU;AAClD,WAAOA,IAAI,CAACH,WAAL,GAAmBI,QAAnB,CAA4BL,iBAA5B,CAAP;AACD,GAF4B,CAA7B;;AAIA,SAAOF,OAAO,CAACC,OAAR,CAAgBG,oBAAhB,CAAP;AACD;;AAED,SAASI,UAAT,CAAoBF,IAApB,EAA+B;AAC7B,SAAOA,IAAP;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,CAACvC,OAAD,CAAhB,CACD,CAFD,MAEO,CACLsG,OAAO,GAAGvG,KAAK,CAACC,OAAD,EAAUuC,MAAV,CAAf,CACD,CACD+D,OAAO,CAACE,IAAR,CAAa,UAACvG,KAAD,EAAW,CACtB,IAAI,MAAI,CAACmB,MAAL,IAAemF,WAAW,KAAK,MAAI,CAACjF,SAAxC,EAAmD,CACjD,MAAI,CAACmD,QAAL,CAAc,EACZxE,KAAK,EAALA,KADY,EAEZgB,QAAQ,EAAE,CAAC,CAFC,EAAd,EAID,CACF,CAPD,EAQD,C,QAEOuD,U,GAAR,oBAAmBZ,KAAnB,EAAkC,CAChC,IAAI,KAAKlC,KAAL,CAAWG,aAAf,EAA8B,CAC5B,KAAKH,KAAL,CAAWG,aAAX,CAAyB+B,KAAzB,EACD,CACF,C,uBA3W+B6C,eAAMC,S,WACxBC,mB,GAAsB,c,UAEtBC,S,GAAY,EACxB;AACJ;AACA;AACA,KACIlG,UAAU,EAAEmG,mBAAUC,IALE,EAOxB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KACIvE,MAAM,EAAEsE,mBAAUE,SAAV,CAAoB,CAACF,mBAAUG,KAAX,EAAkBH,mBAAUC,IAA5B,CAApB,CApBgB,E,UAuBZtF,Y,GAA6B,EACzCd,UAAU,EAAVA,UADyC,EAEzCuG,IAAI,EAAE,OAFmC,EAGzC/E,aAAa,EAAE,KAH0B,EAIzCC,SAAS,EAAE,IAJ8B,EAKzCE,aAAa,EAAE,GAL0B,EAMzCD,SAAS,EAAE,MAN8B,EAOzCE,mBAAmB,EAAE,IAPoB,E","sourcesContent":["// TODO: Enable this rule in functional components.\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport React, { KeyboardEvent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { isKeyArrowDown, isKeyArrowUp, isKeyEnter, isKeyEscape } from '../../lib/events/keyboard/identifiers';\nimport { Input, InputProps } from '../Input';\nimport { DropdownContainer, DropdownContainerProps } from '../../internal/DropdownContainer';\nimport { Menu } from '../../internal/Menu';\nimport { MenuItem } from '../MenuItem';\nimport { RenderLayer } from '../../internal/RenderLayer';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { Nullable, Override } from '../../typings/utility-types';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { MobilePopup } from '../../internal/MobilePopup';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\n\nimport { styles } from './Autocomplete.styles';\n\nfunction match(pattern: string, items: string[]) {\n if (!pattern || !items) {\n return Promise.resolve([]);\n }\n\n const lowerCasedPattern = pattern.toLowerCase();\n const itemsMatchingPattern = items.filter((item) => {\n return item.toLowerCase().includes(lowerCasedPattern);\n });\n\n return Promise.resolve(itemsMatchingPattern);\n}\n\nfunction renderItem(item: any) {\n return item;\n}\n\nexport interface AutocompleteProps\n extends CommonProps,\n Pick<DropdownContainerProps, 'menuPos'>,\n Override<\n InputProps,\n {\n /** Функция отрисовки элемента меню */\n renderItem?: (item: string) => React.ReactNode;\n /** Промис, резолвящий элементы меню */\n source?: string[] | ((patter: string) => Promise<string[]>);\n /** Отключает использование портала */\n disablePortal?: boolean;\n /** Отрисовка тени у выпадающего меню */\n hasShadow?: boolean;\n /** Выравнивание выпадающего меню */\n menuAlign?: 'left' | 'right';\n /** Максимальная высота меню */\n menuMaxHeight?: number | string;\n /** Ширина меню */\n menuWidth?: number | string;\n /** Отключить скролл окна, когда меню открыто */\n preventWindowScroll?: boolean;\n /** Вызывается при изменении `value` */\n onValueChange: (value: string) => void;\n /** onBlur */\n onBlur?: () => void;\n /** Размер инпута */\n size?: InputProps['size'];\n /** value */\n value: string;\n /**\n * Текст заголовка выпадающего меню в мобильной версии\n */\n mobileMenuHeaderText?: string;\n }\n > {}\n\nexport interface AutocompleteState {\n items: Nullable<string[]>;\n selected: number;\n focused: boolean;\n isMobileOpened: boolean;\n}\n\nexport const AutocompleteDataTids = {\n root: 'Autocomplete__root',\n} as const;\n\ntype DefaultProps = Required<\n Pick<\n AutocompleteProps,\n 'renderItem' | 'size' | 'disablePortal' | 'hasShadow' | 'menuMaxHeight' | 'menuAlign' | 'preventWindowScroll'\n >\n>;\n\n/**\n * Стандартный инпут с подсказками.\n *\n * Все свойства передаются во внутренний *Input*.\n */\n@responsiveLayout\n@rootNode\nexport class Autocomplete extends React.Component<AutocompleteProps, AutocompleteState> {\n public static __KONTUR_REACT_UI__ = 'Autocomplete';\n\n public static propTypes = {\n /**\n * Функция для отрисовки элемента в выпадающем списке. Единственный аргумент\n * — *item*.\n */\n renderItem: PropTypes.func,\n\n /**\n * Если передан массив, то совпадения ищутся по этому массиву.\n *\n * Если передается функция, то она должна возвращать thenable, который\n * резолвится уже отфильтрованным массивом. Возвращенный thenable может\n * иметь метод cancel, который будет вызван при отмене поиска (пользователь\n * изменил строку поиска, автокомплит потерял фокус).\n * ```\n * function(pattern) {\n * return service.findAll(pattern);\n * }\n * ```\n */\n source: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),\n };\n\n public static defaultProps: DefaultProps = {\n renderItem,\n size: 'small',\n disablePortal: false,\n hasShadow: true,\n menuMaxHeight: 300,\n menuAlign: 'left',\n preventWindowScroll: true,\n };\n\n public state: AutocompleteState = {\n items: null,\n selected: -1,\n focused: false,\n isMobileOpened: false,\n };\n\n private theme!: Theme;\n private isMobileLayout!: boolean;\n private opened = false;\n private input: Nullable<Input> = null;\n private menu: Nullable<Menu>;\n private rootSpan: Nullable<HTMLSpanElement>;\n private mobilePopup: Nullable<MobilePopup>;\n\n private requestId = 0;\n\n private getProps = createPropsGetter(Autocomplete.defaultProps);\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public focus() {\n if (this.input) {\n this.input.focus();\n }\n }\n\n /**\n * @public\n */\n public blur() {\n this.handleBlur();\n }\n\n public componentDidUpdate(prevProps: AutocompleteProps) {\n if (prevProps.value !== this.props.value) {\n this.updateItems(this.props.value || '');\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n public renderMain = (props: CommonWrapperRestProps<AutocompleteProps>) => {\n const { focused } = this.state;\n\n const isMobile = this.isMobileLayout;\n\n const {\n onValueChange,\n onKeyDown,\n onFocus,\n onBlur,\n renderItem: _renderItem,\n disablePortal,\n hasShadow,\n menuAlign,\n menuMaxHeight,\n preventWindowScroll,\n source,\n width = this.theme.inputWidth,\n mobileMenuHeaderText,\n ...rest\n } = props;\n\n const inputProps = {\n ...rest,\n width: '100%',\n onValueChange: this.handleValueChange,\n onKeyDown: this.handleKeyDown,\n onFocus: this.handleFocus,\n ref: this.refInput,\n };\n\n return (\n <RenderLayer onFocusOutside={this.handleBlur} onClickOutside={this.handleClickOutside} active={focused}>\n <span\n data-tid={AutocompleteDataTids.root}\n className={styles.root(this.theme)}\n style={{ width }}\n ref={this.refRootSpan}\n >\n <Input {...inputProps} />\n {isMobile ? this.renderMobileMenu() : this.renderMenu()}\n </span>\n </RenderLayer>\n );\n };\n\n private renderMenu(): React.ReactNode {\n const items = this.state.items;\n const { menuMaxHeight, hasShadow, menuWidth, width, preventWindowScroll, menuAlign, disablePortal, menuPos } =\n this.getProps();\n const menuProps = {\n ref: this.refMenu,\n maxHeight: menuMaxHeight,\n hasShadow,\n width: menuWidth || (width && getDOMRect(this.rootSpan).width),\n preventWindowScroll,\n };\n if (!items || items.length === 0) {\n return null;\n }\n\n return (\n <DropdownContainer\n offsetY={1}\n getParent={this.getAnchor}\n align={menuAlign}\n disablePortal={disablePortal}\n menuPos={menuPos}\n >\n <Menu {...menuProps}>{this.getItems()}</Menu>\n </DropdownContainer>\n );\n }\n\n private renderMobileMenu = () => {\n const inputProps: InputProps = {\n autoFocus: true,\n width: '100%',\n onValueChange: this.handleValueChange,\n onKeyPress: this.handleKeyPressMobile,\n value: this.props.value,\n placeholder: 'Начните вводить',\n };\n\n const items = this.state.items;\n\n return (\n <MobilePopup\n headerChildComponent={<Input {...inputProps} />}\n caption={this.props.mobileMenuHeaderText}\n useFullHeight\n opened={this.state.isMobileOpened}\n onCloseRequest={this.handleCloseMobile}\n ref={this.refMobilePopup}\n >\n <Menu ref={this.refMenu} onItemClick={this.mobilePopup?.close} disableScrollContainer maxHeight={'auto'}>\n {items && items.length > 0 && this.getItems()}\n </Menu>\n </MobilePopup>\n );\n };\n\n private getItems = () => {\n const items = this.state.items;\n const isMobile = this.isMobileLayout;\n\n return items\n ? items.map((item, i) => {\n return (\n <MenuItem onClick={this.handleMenuItemClick(i)} key={i} isMobile={isMobile}>\n {this.getProps().renderItem(item)}\n </MenuItem>\n );\n })\n : null;\n };\n\n private handleValueChange = (value: string) => {\n this.opened = true;\n\n this.fireChange(value);\n };\n\n private handleCloseMobile = () => {\n this.setState({\n isMobileOpened: false,\n });\n\n this.handleBlur();\n };\n\n private handleKeyPressMobile = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n this.mobilePopup?.close();\n }\n };\n\n private handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (this.isMobileLayout) {\n this.setState({ isMobileOpened: true });\n }\n\n if (this.state.focused) {\n return;\n }\n\n this.setState({ focused: true });\n\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleBlur = () => {\n if (!this.state.focused) {\n return;\n }\n\n this.opened = false;\n this.setState({ items: null, focused: false });\n\n if (this.input) {\n this.input.blur();\n }\n\n if (this.props.onBlur) {\n this.props.onBlur();\n }\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n }\n switch (true) {\n case isKeyEscape(e):\n e.preventDefault();\n this.setState({ items: null });\n return;\n case isKeyArrowUp(e):\n e.preventDefault();\n if (this.menu) {\n this.menu.up();\n }\n return;\n case isKeyArrowDown(e):\n e.preventDefault();\n if (this.menu) {\n this.menu.down();\n }\n return;\n case isKeyEnter(e):\n e.preventDefault(); // To prevent form submission.\n if (this.menu) {\n this.menu.enter(e);\n }\n return;\n }\n };\n\n private handleMenuItemClick(i: number) {\n return (event: React.SyntheticEvent<HTMLElement>) => this.handleItemClick(event, i);\n }\n\n private getAnchor = () => {\n return getRootNode(this);\n };\n\n private handleItemClick(event: React.SyntheticEvent<HTMLElement> | React.MouseEvent<HTMLElement>, index: number) {\n if ((event as React.MouseEvent<HTMLElement>).button) {\n return;\n }\n\n event.preventDefault();\n this.choose(index);\n }\n\n private choose(index: number) {\n if (!this.state.items) {\n return;\n }\n\n const value = this.state.items[index];\n this.opened = false;\n this.setState({\n selected: -1,\n items: null,\n });\n\n this.fireChange(value);\n this.blur();\n }\n\n private updateItems(value: string) {\n if (!this.opened) {\n return;\n }\n const pattern = value.trim();\n const source = this.props.source;\n\n if (!source) {\n return;\n }\n\n let promise;\n this.requestId += 1;\n const expectingId = this.requestId;\n if (typeof source === 'function') {\n promise = source(pattern);\n } else {\n promise = match(pattern, source);\n }\n promise.then((items) => {\n if (this.opened && expectingId === this.requestId) {\n this.setState({\n items,\n selected: -1,\n });\n }\n });\n }\n\n private fireChange(value: string) {\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n }\n\n private refInput = (el: Input | null) => {\n this.input = el;\n };\n\n private refMenu = (menu: Menu | null) => {\n this.menu = menu;\n };\n\n private refRootSpan = (span: HTMLSpanElement) => {\n this.rootSpan = span;\n };\n\n private refMobilePopup = (mobilePopup: MobilePopup | null) => {\n this.mobilePopup = mobilePopup;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Autocomplete.tsx"],"names":["match","pattern","items","Promise","resolve","lowerCasedPattern","toLowerCase","itemsMatchingPattern","filter","item","includes","renderItem","AutocompleteDataTids","root","Autocomplete","AutocompleteLocaleHelper","responsiveLayout","rootNode","state","selected","focused","isMobileOpened","opened","input","requestId","getProps","defaultProps","renderMain","props","isMobile","isMobileLayout","onValueChange","onKeyDown","onFocus","onBlur","_renderItem","disablePortal","hasShadow","menuAlign","menuMaxHeight","preventWindowScroll","source","width","theme","inputWidth","mobileMenuHeaderText","rest","inputProps","handleValueChange","handleKeyDown","handleFocus","ref","refInput","handleBlur","handleClickOutside","styles","refRootSpan","renderMobileMenu","renderMenu","autoFocus","onKeyPress","handleKeyPressMobile","value","placeholder","locale","enterValue","handleCloseMobile","refMobilePopup","refMenu","mobilePopup","close","length","getItems","renderHints","map","i","handleMenuItemClick","fireChange","setState","e","key","event","blur","preventDefault","menu","up","down","enter","getAnchor","el","span","rootSpan","focus","componentDidUpdate","prevProps","updateItems","render","setRootNode","notFound","updateValue","menuWidth","menuPos","menuProps","maxHeight","handleItemClick","index","button","choose","trim","promise","expectingId","then","React","Component","__KONTUR_REACT_UI__","propTypes","PropTypes","func","oneOfType","array","size"],"mappings":";;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kC;;AAEA,SAASA,KAAT,CAAeC,OAAf,EAAgCC,KAAhC,EAAiD;AAC/C,MAAI,CAACD,OAAD,IAAY,CAACC,KAAjB,EAAwB;AACtB,WAAOC,OAAO,CAACC,OAAR,CAAgB,EAAhB,CAAP;AACD;;AAED,MAAMC,iBAAiB,GAAGJ,OAAO,CAACK,WAAR,EAA1B;AACA,MAAMC,oBAAoB,GAAGL,KAAK,CAACM,MAAN,CAAa,UAACC,IAAD,EAAU;AAClD,WAAOA,IAAI,CAACH,WAAL,GAA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,CACF,CAPD,EAQD,C,QAEO0D,U,GAAR,oBAAmBf,KAAnB,EAAkC,CAChC,IAAI,KAAKlC,KAAL,CAAWG,aAAf,EAA8B,CAC5B,KAAKH,KAAL,CAAWG,aAAX,CAAyB+B,KAAzB,EACD,CACF,C,uBA9X+BkD,eAAMC,S,WACxBC,mB,GAAsB,c,UAEtBC,S,GAAY,EACxB;AACJ;AACA;AACA,KACIxG,UAAU,EAAEyG,mBAAUC,IALE,EAOxB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KACI5E,MAAM,EAAE2E,mBAAUE,SAAV,CAAoB,CAACF,mBAAUG,KAAX,EAAkBH,mBAAUC,IAA5B,CAApB,CApBgB,E,UAuBZ3F,Y,GAA6B,EACzCf,UAAU,EAAVA,UADyC,EAEzC6G,IAAI,EAAE,OAFmC,EAGzCpF,aAAa,EAAE,KAH0B,EAIzCC,SAAS,EAAE,IAJ8B,EAKzCE,aAAa,EAAE,GAL0B,EAMzCD,SAAS,EAAE,MAN8B,EAOzCE,mBAAmB,EAAE,IAPoB,E","sourcesContent":["// TODO: Enable this rule in functional components.\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport React, { KeyboardEvent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { MenuMessage } from '../../internal/MenuMessage';\nimport { locale } from '../../lib/locale/decorators';\nimport { isNullable } from '../../lib/utils';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { isKeyArrowDown, isKeyArrowUp, isKeyEnter, isKeyEscape } from '../../lib/events/keyboard/identifiers';\nimport { Input, InputProps } from '../Input';\nimport { DropdownContainer, DropdownContainerProps } from '../../internal/DropdownContainer';\nimport { Menu } from '../../internal/Menu';\nimport { MenuItem } from '../MenuItem';\nimport { RenderLayer } from '../../internal/RenderLayer';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { Nullable, Override } from '../../typings/utility-types';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { MobilePopup } from '../../internal/MobilePopup';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\n\nimport { styles } from './Autocomplete.styles';\nimport { AutocompleteLocale, AutocompleteLocaleHelper } from './locale';\n\nfunction match(pattern: string, items: string[]) {\n if (!pattern || !items) {\n return Promise.resolve([]);\n }\n\n const lowerCasedPattern = pattern.toLowerCase();\n const itemsMatchingPattern = items.filter((item) => {\n return item.toLowerCase().includes(lowerCasedPattern);\n });\n\n return Promise.resolve(itemsMatchingPattern);\n}\n\nfunction renderItem(item: any) {\n return item;\n}\n\nexport interface AutocompleteProps\n extends CommonProps,\n Pick<DropdownContainerProps, 'menuPos'>,\n Override<\n InputProps,\n {\n /** Функция отрисовки элемента меню */\n renderItem?: (item: string) => React.ReactNode;\n /** Промис, резолвящий элементы меню */\n source?: string[] | ((patter: string) => Promise<string[]>);\n /** Отключает использование портала */\n disablePortal?: boolean;\n /** Отрисовка тени у выпадающего меню */\n hasShadow?: boolean;\n /** Выравнивание выпадающего меню */\n menuAlign?: 'left' | 'right';\n /** Максимальная высота меню */\n menuMaxHeight?: number | string;\n /** Ширина меню */\n menuWidth?: number | string;\n /** Отключить скролл окна, когда меню открыто */\n preventWindowScroll?: boolean;\n /** Вызывается при изменении `value` */\n onValueChange: (value: string) => void;\n /** onBlur */\n onBlur?: () => void;\n /** Размер инпута */\n size?: InputProps['size'];\n /** value */\n value: string;\n /**\n * Текст заголовка выпадающего меню в мобильной версии\n */\n mobileMenuHeaderText?: string;\n }\n > {}\n\nexport interface AutocompleteState {\n items: Nullable<string[]>;\n selected: number;\n focused: boolean;\n isMobileOpened: boolean;\n}\n\nexport const AutocompleteDataTids = {\n root: 'Autocomplete__root',\n} as const;\n\ntype DefaultProps = Required<\n Pick<\n AutocompleteProps,\n 'renderItem' | 'size' | 'disablePortal' | 'hasShadow' | 'menuMaxHeight' | 'menuAlign' | 'preventWindowScroll'\n >\n>;\n\n/**\n * Стандартный инпут с подсказками.\n *\n * Все свойства передаются во внутренний *Input*.\n */\n@responsiveLayout\n@rootNode\n@locale('Autocomplete', AutocompleteLocaleHelper)\nexport class Autocomplete extends React.Component<AutocompleteProps, AutocompleteState> {\n public static __KONTUR_REACT_UI__ = 'Autocomplete';\n\n public static propTypes = {\n /**\n * Функция для отрисовки элемента в выпадающем списке. Единственный аргумент\n * — *item*.\n */\n renderItem: PropTypes.func,\n\n /**\n * Если передан массив, то совпадения ищутся по этому массиву.\n *\n * Если передается функция, то она должна возвращать thenable, который\n * резолвится уже отфильтрованным массивом. Возвращенный thenable может\n * иметь метод cancel, который будет вызван при отмене поиска (пользователь\n * изменил строку поиска, автокомплит потерял фокус).\n * ```\n * function(pattern) {\n * return service.findAll(pattern);\n * }\n * ```\n */\n source: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),\n };\n\n public static defaultProps: DefaultProps = {\n renderItem,\n size: 'small',\n disablePortal: false,\n hasShadow: true,\n menuMaxHeight: 300,\n menuAlign: 'left',\n preventWindowScroll: true,\n };\n\n public state: AutocompleteState = {\n items: null,\n selected: -1,\n focused: false,\n isMobileOpened: false,\n };\n\n private theme!: Theme;\n private readonly locale!: AutocompleteLocale;\n private isMobileLayout!: boolean;\n private opened = false;\n private input: Nullable<Input> = null;\n private menu: Nullable<Menu>;\n private rootSpan: Nullable<HTMLSpanElement>;\n private mobilePopup: Nullable<MobilePopup>;\n\n private requestId = 0;\n\n private getProps = createPropsGetter(Autocomplete.defaultProps);\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public focus() {\n if (this.input) {\n this.input.focus();\n }\n }\n\n /**\n * @public\n */\n public blur() {\n this.handleBlur();\n }\n\n public componentDidUpdate(prevProps: AutocompleteProps) {\n if (prevProps.value !== this.props.value) {\n this.updateItems(this.props.value || '');\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n public renderMain = (props: CommonWrapperRestProps<AutocompleteProps>) => {\n const { focused } = this.state;\n\n const isMobile = this.isMobileLayout;\n\n const {\n onValueChange,\n onKeyDown,\n onFocus,\n onBlur,\n renderItem: _renderItem,\n disablePortal,\n hasShadow,\n menuAlign,\n menuMaxHeight,\n preventWindowScroll,\n source,\n width = this.theme.inputWidth,\n mobileMenuHeaderText,\n ...rest\n } = props;\n\n const inputProps = {\n ...rest,\n width: '100%',\n onValueChange: this.handleValueChange,\n onKeyDown: this.handleKeyDown,\n onFocus: this.handleFocus,\n ref: this.refInput,\n };\n\n return (\n <RenderLayer onFocusOutside={this.handleBlur} onClickOutside={this.handleClickOutside} active={focused}>\n <span\n data-tid={AutocompleteDataTids.root}\n className={styles.root(this.theme)}\n style={{ width }}\n ref={this.refRootSpan}\n >\n <Input {...inputProps} />\n {isMobile ? this.renderMobileMenu() : this.renderMenu()}\n </span>\n </RenderLayer>\n );\n };\n\n private renderHints(): React.ReactNode {\n const items = this.state.items;\n\n if (!this.props.value) {\n return <MenuMessage>{this.locale.enterValue}</MenuMessage>;\n }\n\n if (items?.length === 0 && this.props.value) {\n return <MenuMessage>{this.locale.notFound}</MenuMessage>;\n }\n\n if (isNullable(items) && this.props.value) {\n return <MenuMessage>{this.locale.updateValue}</MenuMessage>;\n }\n\n return null;\n }\n\n private renderMenu(): React.ReactNode {\n const items = this.state.items;\n const { menuMaxHeight, hasShadow, menuWidth, width, preventWindowScroll, menuAlign, disablePortal, menuPos } =\n this.getProps();\n const menuProps = {\n ref: this.refMenu,\n maxHeight: menuMaxHeight,\n hasShadow,\n width: menuWidth || (width && getDOMRect(this.rootSpan).width),\n preventWindowScroll,\n };\n if (!items || items.length === 0) {\n return null;\n }\n\n return (\n <DropdownContainer\n offsetY={1}\n getParent={this.getAnchor}\n align={menuAlign}\n disablePortal={disablePortal}\n menuPos={menuPos}\n >\n <Menu {...menuProps}>{this.getItems()}</Menu>\n </DropdownContainer>\n );\n }\n\n private renderMobileMenu = () => {\n const inputProps: InputProps = {\n autoFocus: true,\n width: '100%',\n onValueChange: this.handleValueChange,\n onKeyPress: this.handleKeyPressMobile,\n value: this.props.value,\n placeholder: this.locale.enterValue,\n };\n\n const items = this.state.items;\n\n return (\n <MobilePopup\n headerChildComponent={<Input {...inputProps} />}\n caption={this.props.mobileMenuHeaderText}\n opened={this.state.isMobileOpened}\n onCloseRequest={this.handleCloseMobile}\n ref={this.refMobilePopup}\n >\n <Menu ref={this.refMenu} onItemClick={this.mobilePopup?.close} disableScrollContainer maxHeight={'auto'}>\n {items && items.length > 0 && this.getItems()}\n {this.renderHints()}\n </Menu>\n </MobilePopup>\n );\n };\n\n private getItems = () => {\n const items = this.state.items;\n const isMobile = this.isMobileLayout;\n\n return items\n ? items.map((item, i) => {\n return (\n <MenuItem onClick={this.handleMenuItemClick(i)} key={i} isMobile={isMobile}>\n {this.getProps().renderItem(item)}\n </MenuItem>\n );\n })\n : null;\n };\n\n private handleValueChange = (value: string) => {\n this.opened = true;\n\n this.fireChange(value);\n };\n\n private handleCloseMobile = () => {\n this.setState({\n isMobileOpened: false,\n });\n\n this.handleBlur();\n };\n\n private handleKeyPressMobile = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n this.mobilePopup?.close();\n }\n };\n\n private handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (this.isMobileLayout) {\n this.setState({ isMobileOpened: true });\n }\n\n if (this.state.focused) {\n return;\n }\n\n this.setState({ focused: true });\n\n if (this.props.onFocus) {\n this.props.onFocus(event);\n }\n };\n\n private handleBlur = () => {\n if (!this.state.focused) {\n return;\n }\n\n this.opened = false;\n this.setState({ items: null, focused: false });\n\n if (this.input) {\n this.input.blur();\n }\n\n if (this.props.onBlur) {\n this.props.onBlur();\n }\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n }\n switch (true) {\n case isKeyEscape(e):\n e.preventDefault();\n this.setState({ items: null });\n return;\n case isKeyArrowUp(e):\n e.preventDefault();\n if (this.menu) {\n this.menu.up();\n }\n return;\n case isKeyArrowDown(e):\n e.preventDefault();\n if (this.menu) {\n this.menu.down();\n }\n return;\n case isKeyEnter(e):\n e.preventDefault(); // To prevent form submission.\n if (this.menu) {\n this.menu.enter(e);\n }\n return;\n }\n };\n\n private handleMenuItemClick(i: number) {\n return (event: React.SyntheticEvent<HTMLElement>) => this.handleItemClick(event, i);\n }\n\n private getAnchor = () => {\n return getRootNode(this);\n };\n\n private handleItemClick(event: React.SyntheticEvent<HTMLElement> | React.MouseEvent<HTMLElement>, index: number) {\n if ((event as React.MouseEvent<HTMLElement>).button) {\n return;\n }\n\n event.preventDefault();\n this.choose(index);\n }\n\n private choose(index: number) {\n if (!this.state.items) {\n return;\n }\n\n const value = this.state.items[index];\n this.opened = false;\n this.setState({\n selected: -1,\n items: null,\n });\n\n this.fireChange(value);\n this.blur();\n }\n\n private updateItems(value: string) {\n if (!this.opened) {\n return;\n }\n const pattern = value.trim();\n const source = this.props.source;\n\n if (!source) {\n return;\n }\n\n let promise;\n this.requestId += 1;\n const expectingId = this.requestId;\n if (typeof source === 'function') {\n promise = source(pattern);\n } else {\n promise = match(pattern, source);\n }\n promise.then((items) => {\n if (this.opened && expectingId === this.requestId) {\n this.setState({\n items,\n selected: -1,\n });\n }\n });\n }\n\n private fireChange(value: string) {\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n }\n\n private refInput = (el: Input | null) => {\n this.input = el;\n };\n\n private refMenu = (menu: Menu | null) => {\n this.menu = menu;\n };\n\n private refRootSpan = (span: HTMLSpanElement) => {\n this.rootSpan = span;\n };\n\n private refMobilePopup = (mobilePopup: MobilePopup | null) => {\n this.mobilePopup = mobilePopup;\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";exports.__esModule = true;var _exportNames = { AutocompleteLocaleHelper: true };exports.AutocompleteLocaleHelper = void 0;var _LocaleHelper = require("../../../lib/locale/LocaleHelper");
|
|
2
|
+
|
|
3
|
+
var _en = require("./locales/en");
|
|
4
|
+
var _ru = require("./locales/ru");
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _types = require("./types");Object.keys(_types).forEach(function (key) {if (key === "default" || key === "__esModule") return;if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;if (key in exports && exports[key] === _types[key]) return;exports[key] = _types[key];});
|
|
8
|
+
|
|
9
|
+
var AutocompleteLocaleHelper = new _LocaleHelper.LocaleHelper({
|
|
10
|
+
ru_RU: _ru.componentsLocales,
|
|
11
|
+
en_GB: _en.componentsLocales });exports.AutocompleteLocaleHelper = AutocompleteLocaleHelper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["AutocompleteLocaleHelper","LocaleHelper","ru_RU","en_GB"],"mappings":"uIAAA;;AAEA;AACA;;;AAGA;;AAEO,IAAMA,wBAAwB,GAAG,IAAIC,0BAAJ,CAAqC;AAC3EC,EAAAA,KAAK,EAALA,qBAD2E;AAE3EC,EAAAA,KAAK,EAALA,qBAF2E,EAArC,CAAjC,C","sourcesContent":["import { LocaleHelper } from '../../../lib/locale/LocaleHelper';\n\nimport { componentsLocales as en_GB } from './locales/en';\nimport { componentsLocales as ru_RU } from './locales/ru';\nimport { AutocompleteLocale } from './types';\n\nexport * from './types';\n\nexport const AutocompleteLocaleHelper = new LocaleHelper<AutocompleteLocale>({\n ru_RU,\n en_GB,\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["en.ts"],"names":["componentsLocales","enterValue","notFound","updateValue"],"mappings":";;AAEO,IAAMA,iBAAqC,GAAG;AACnDC,EAAAA,UAAU,EAAE,cADuC;AAEnDC,EAAAA,QAAQ,EAAE,mBAFyC;AAGnDC,EAAAA,WAAW,EAAE,oCAHsC,EAA9C,C","sourcesContent":["import { AutocompleteLocale } from '../types';\n\nexport const componentsLocales: AutocompleteLocale = {\n enterValue: 'Start typing',\n notFound: 'Nothing was found',\n updateValue: 'Start typing or changing the value',\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";exports.__esModule = true;exports.componentsLocales = void 0;
|
|
2
|
+
|
|
3
|
+
var componentsLocales = {
|
|
4
|
+
enterValue: 'Начните вводить значение',
|
|
5
|
+
notFound: 'Ничего не найдено',
|
|
6
|
+
updateValue: 'Начните вводить или изменять значение' };exports.componentsLocales = componentsLocales;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ru.ts"],"names":["componentsLocales","enterValue","notFound","updateValue"],"mappings":";;AAEO,IAAMA,iBAAqC,GAAG;AACnDC,EAAAA,UAAU,EAAE,0BADuC;AAEnDC,EAAAA,QAAQ,EAAE,mBAFyC;AAGnDC,EAAAA,WAAW,EAAE,uCAHsC,EAA9C,C","sourcesContent":["import { AutocompleteLocale } from '../types';\n\nexport const componentsLocales: AutocompleteLocale = {\n enterValue: 'Начните вводить значение',\n notFound: 'Ничего не найдено',\n updateValue: 'Начните вводить или изменять значение',\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.__esModule = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -463,6 +463,48 @@ class ComboboxExample extends React.Component {
|
|
|
463
463
|
<ComboboxExample />;
|
|
464
464
|
```
|
|
465
465
|
|
|
466
|
+
|
|
467
|
+
При изменении значения и блюре `ComboBox` остается в состоянии `editing` и не дает изменить значение через проп `value`. Поэтому, для того чтобы задать новое значение, необходимо вызвать метод `reset`.
|
|
468
|
+
|
|
469
|
+
```jsx harmony
|
|
470
|
+
import { Button } from '@skbkontur/react-ui';
|
|
471
|
+
|
|
472
|
+
const [selected, setSelected] = React.useState({ value: 1, label: "First" });
|
|
473
|
+
const ref = React.useRef();
|
|
474
|
+
|
|
475
|
+
const handleButtonClick = () => {
|
|
476
|
+
if (ref.current) {
|
|
477
|
+
ref.current.reset();
|
|
478
|
+
}
|
|
479
|
+
setSelected({ value: 3, label: "Third" });
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
const getItems = (q) =>
|
|
483
|
+
Promise.resolve(
|
|
484
|
+
[
|
|
485
|
+
{ value: 1, label: "First" },
|
|
486
|
+
{ value: 2, label: "Second" },
|
|
487
|
+
{ value: 3, label: "Third" }
|
|
488
|
+
].filter(
|
|
489
|
+
(x) =>
|
|
490
|
+
x.label.toLowerCase().includes(q.toLowerCase()) ||
|
|
491
|
+
x.value.toString(10) === q
|
|
492
|
+
)
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
<div>
|
|
496
|
+
<ComboBox
|
|
497
|
+
ref={ref}
|
|
498
|
+
getItems={getItems}
|
|
499
|
+
onValueChange={setSelected}
|
|
500
|
+
placeholder="Enter number"
|
|
501
|
+
value={selected}
|
|
502
|
+
/>
|
|
503
|
+
<Button onClick={handleButtonClick}>Make it three!</Button>
|
|
504
|
+
</div>
|
|
505
|
+
|
|
506
|
+
```
|
|
507
|
+
|
|
466
508
|
#### Локали по умолчанию
|
|
467
509
|
|
|
468
510
|
```typescript static
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const commaAliases: ((e: import("react").KeyboardEvent<HTMLElement>
|
|
2
|
+
export declare const commaAliases: ((e: KeyboardEvent | import("react").KeyboardEvent<HTMLElement>) => boolean)[];
|
|
3
3
|
export declare const CURRENCY_INPUT_ACTIONS: {
|
|
4
4
|
Unknown: number;
|
|
5
5
|
Ignore: number;
|
|
@@ -5,7 +5,8 @@ import { MenuItem } from '../MenuItem';
|
|
|
5
5
|
import { MenuSeparator } from '../MenuSeparator';
|
|
6
6
|
import { ButtonSize, ButtonUse } from '../Button';
|
|
7
7
|
import { CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';
|
|
8
|
-
|
|
8
|
+
import { DropdownContainerProps } from '../../internal/DropdownContainer';
|
|
9
|
+
export interface DropdownProps extends CommonProps, Pick<DropdownContainerProps, 'menuPos'> {
|
|
9
10
|
/**
|
|
10
11
|
* Подпись на кнопке.
|
|
11
12
|
*/
|
|
@@ -14,6 +14,7 @@ var _ThemeContext = require("../../lib/theming/ThemeContext");
|
|
|
14
14
|
|
|
15
15
|
var _ThemeFactory = require("../../lib/theming/ThemeFactory");var _excluded = ["caption", "icon"];var _class, _class2, _temp;
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
var PASS_PROPS = {
|
|
18
19
|
_renderButton: true,
|
|
19
20
|
error: true,
|
|
@@ -30,7 +31,8 @@ var PASS_PROPS = {
|
|
|
30
31
|
onClose: true,
|
|
31
32
|
onMouseEnter: true,
|
|
32
33
|
onMouseLeave: true,
|
|
33
|
-
onMouseOver: true
|
|
34
|
+
onMouseOver: true,
|
|
35
|
+
menuPos: true };
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Dropdown.tsx"],"names":["PASS_PROPS","_renderButton","error","disabled","disablePortal","menuAlign","menuWidth","maxMenuHeight","use","size","warning","width","onOpen","onClose","onMouseEnter","onMouseLeave","onMouseOver","DropdownDataTids","root","Dropdown","rootNode","renderMain","caption","icon","props","items","React","Children","map","children","item","ThemeFactory","create","selectDefaultBg","theme","btnDefaultBg","setRootNode","_refSelect","renderValue","element","_select","render","open","close","Component","__KONTUR_REACT_UI__","Header","MenuHeader","MenuItem","Separator","MenuSeparator","propTypes","PropTypes","node","isRequired","bool","number","oneOf","oneOfType","string","any","func","value"],"mappings":"6dAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA,8D
|
|
1
|
+
{"version":3,"sources":["Dropdown.tsx"],"names":["PASS_PROPS","_renderButton","error","disabled","disablePortal","menuAlign","menuWidth","maxMenuHeight","use","size","warning","width","onOpen","onClose","onMouseEnter","onMouseLeave","onMouseOver","menuPos","DropdownDataTids","root","Dropdown","rootNode","renderMain","caption","icon","props","items","React","Children","map","children","item","ThemeFactory","create","selectDefaultBg","theme","btnDefaultBg","setRootNode","_refSelect","renderValue","element","_select","render","open","close","Component","__KONTUR_REACT_UI__","Header","MenuHeader","MenuItem","Separator","MenuSeparator","propTypes","PropTypes","node","isRequired","bool","number","oneOf","oneOfType","string","any","func","value"],"mappings":"6dAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA,8D;;;AAGA,IAAMA,UAAU,GAAG;AACjBC,EAAAA,aAAa,EAAE,IADE;AAEjBC,EAAAA,KAAK,EAAE,IAFU;AAGjBC,EAAAA,QAAQ,EAAE,IAHO;AAIjBC,EAAAA,aAAa,EAAE,IAJE;AAKjBC,EAAAA,SAAS,EAAE,IALM;AAMjBC,EAAAA,SAAS,EAAE,IANM;AAOjBC,EAAAA,aAAa,EAAE,IAPE;AAQjBC,EAAAA,GAAG,EAAE,IARY;AASjBC,EAAAA,IAAI,EAAE,IATW;AAUjBC,EAAAA,OAAO,EAAE,IAVQ;AAWjBC,EAAAA,KAAK,EAAE,IAXU;AAYjBC,EAAAA,MAAM,EAAE,IAZS;AAajBC,EAAAA,OAAO,EAAE,IAbQ;AAcjBC,EAAAA,YAAY,EAAE,IAdG;AAejBC,EAAAA,YAAY,EAAE,IAfG;AAgBjBC,EAAAA,WAAW,EAAE,IAhBI;AAiBjBC,EAAAA,OAAO,EAAE,IAjBQ,EAAnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EO,IAAMC,gBAAgB,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A4CxB7C,KAAK,EAAE0C,mBAAUM,SAAV,CAAoB,CAACN,mBAAUI,MAAX,EAAmBJ,mBAAUO,MAA7B,CAApB,CA5CiB,EA8CxB;AACJ;AACA,KACI/C,OAAO,EAAEwC,mBAAUS,IAjDK,EAmDxBhD,YAAY,EAAEuC,mBAAUS,IAnDA,EAqDxB/C,YAAY,EAAEsC,mBAAUS,IArDA,EAuDxB9C,WAAW,EAAEqC,mBAAUS,IAvDC,EAyDxB;AACJ;AACA,KACIlD,MAAM,EAAEyC,mBAAUS,IA5DM,E,gDAgI5B,SAASvB,WAAT,CAAqBwB,KAArB,EAAiC,CAC/B,OAAOA,KAAP,CACD","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { filterProps } from '../../lib/filterProps';\nimport { MenuHeader } from '../MenuHeader';\nimport { MenuItem } from '../MenuItem';\nimport { MenuSeparator } from '../MenuSeparator';\nimport { Select } from '../Select';\nimport { Nullable } from '../../typings/utility-types';\nimport { ButtonSize, ButtonUse } from '../Button';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory';\nimport { DropdownContainerProps } from '../../internal/DropdownContainer';\n\nconst PASS_PROPS = {\n _renderButton: true,\n error: true,\n disabled: true,\n disablePortal: true,\n menuAlign: true,\n menuWidth: true,\n maxMenuHeight: true,\n use: true,\n size: true,\n warning: true,\n width: true,\n onOpen: true,\n onClose: true,\n onMouseEnter: true,\n onMouseLeave: true,\n onMouseOver: true,\n menuPos: true,\n};\n\nexport interface DropdownProps extends CommonProps, Pick<DropdownContainerProps, 'menuPos'> {\n /**\n * Подпись на кнопке.\n */\n caption: React.ReactNode;\n /**\n * Иконка слева от текста кнопки\n */\n icon?: React.ReactElement<any>;\n width?: React.CSSProperties['width'];\n\n /** @ignore */\n _renderButton?: (params: any) => JSX.Element;\n\n /**\n * Отключает использование портала\n */\n disablePortal?: boolean;\n\n /**\n * Визуально отключает Dropdown\n */\n disabled?: boolean;\n\n /**\n * Состояние валидации при ошибке.\n */\n error?: boolean;\n /**\n * Состояние валидации при предупреждении.\n */\n warning?: boolean;\n maxMenuHeight?: number;\n menuAlign?: 'left' | 'right';\n menuWidth?: number | string;\n size?: ButtonSize;\n\n /**\n * Смотри Button.\n */\n use?: ButtonUse;\n\n /**\n * Вызывается при закрытии меню.\n */\n onClose?: () => void;\n /**\n * Вызывается при открытии меню.\n */\n onOpen?: () => void;\n onMouseEnter?: (event: React.MouseEvent<HTMLElement>) => void;\n onMouseLeave?: (event: React.MouseEvent<HTMLElement>) => void;\n onMouseOver?: (event: React.MouseEvent<HTMLElement>) => void;\n}\n\ntype DropdownSelectType = Select<React.ReactNode, React.ReactNode>;\n\nexport const DropdownDataTids = {\n root: 'Dropdown__root',\n} as const;\n\n/**\n * Выпадающее меню.\n *\n */\n@rootNode\nexport class Dropdown extends React.Component<DropdownProps> {\n public static __KONTUR_REACT_UI__ = 'Dropdown';\n\n public static Header = MenuHeader;\n public static MenuItem = MenuItem;\n public static Separator = MenuSeparator;\n\n public static propTypes = {\n /**\n * Подпись на кнопке.\n */\n caption: PropTypes.node.isRequired,\n\n /**\n * Отключает использование портала\n */\n disablePortal: PropTypes.bool,\n\n /**\n * Визуально отключает Dropdown\n */\n disabled: PropTypes.bool,\n\n /**\n * Визуально показать наличие ошибки.\n */\n error: PropTypes.bool,\n\n /**\n * Иконка слева от текста кнопки\n */\n icon: PropTypes.node,\n\n maxMenuHeight: PropTypes.number,\n\n menuAlign: PropTypes.oneOf(['left', 'right']),\n\n menuWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n size: PropTypes.oneOf(['small', 'medium', 'large']),\n\n /**\n * Смотри Button.\n */\n use: PropTypes.any,\n\n /**\n * Визуально показать наличие предупреждения.\n */\n warning: PropTypes.bool,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n /**\n * Вызывается при закрытии меню.\n */\n onClose: PropTypes.func,\n\n onMouseEnter: PropTypes.func,\n\n onMouseLeave: PropTypes.func,\n\n onMouseOver: PropTypes.func,\n\n /**\n * Вызывается при открытии меню.\n */\n onOpen: PropTypes.func,\n };\n\n private _select: Nullable<DropdownSelectType>;\n private setRootNode!: TSetRootNode;\n private theme!: Theme;\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return <ThemeContext.Provider value={this.theme}>{this.renderMain(this.props)}</ThemeContext.Provider>;\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain = ({ caption, icon, ...props }: CommonWrapperRestProps<DropdownProps>) => {\n const items = React.Children.map(this.props.children, (item) => item) || [];\n\n return (\n <ThemeContext.Provider\n value={ThemeFactory.create(\n {\n selectDefaultBg: this.theme.btnDefaultBg,\n },\n this.theme,\n )}\n >\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <Select<React.ReactNode, React.ReactNode>\n data-tid={DropdownDataTids.root}\n ref={this._refSelect}\n {...filterProps(props, PASS_PROPS)}\n value={caption}\n items={items}\n _icon={icon}\n renderValue={renderValue}\n />\n </CommonWrapper>\n </ThemeContext.Provider>\n );\n };\n\n /**\n * @public\n */\n public open() {\n if (this._select) {\n this._select.open();\n }\n }\n\n /**\n * @public\n */\n public close() {\n if (this._select) {\n this._select.close();\n }\n }\n\n private _refSelect = (element: DropdownSelectType): void => {\n this._select = element;\n };\n}\n\nfunction renderValue(value: any) {\n return value;\n}\n"]}
|
|
@@ -16,6 +16,33 @@ import { Button, MenuHeader, MenuItem, MenuSeparator } from '@skbkontur/react-ui
|
|
|
16
16
|
</DropdownMenu>;
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
В проп `caption` помимо компонента можно передать функцию, возвращающую компонент, с помощью которой можно управлять текущим состоянием меню.
|
|
20
|
+
|
|
21
|
+
```jsx harmony
|
|
22
|
+
import { Button, MenuHeader, MenuItem, MenuSeparator } from '@skbkontur/react-ui';
|
|
23
|
+
|
|
24
|
+
<DropdownMenu caption={({ opened, openMenu, closeMenu, toggleMenu }) => {
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<p>Сейчас меню { opened ? 'окрыто' : 'закрыто' }</p>
|
|
28
|
+
<Button onClick={toggleMenu}>Переключить меню</Button>
|
|
29
|
+
<Button onClick={openMenu}>Открыть меню</Button>
|
|
30
|
+
<Button onClick={closeMenu}>Закрыть меню</Button>
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}}>
|
|
34
|
+
<MenuHeader>Заголовок меню</MenuHeader>
|
|
35
|
+
<MenuSeparator />
|
|
36
|
+
<MenuItem>Раз</MenuItem>
|
|
37
|
+
<MenuItem>Два</MenuItem>
|
|
38
|
+
<MenuItem>Три</MenuItem>
|
|
39
|
+
<MenuSeparator />
|
|
40
|
+
<MenuItem>Раз</MenuItem>
|
|
41
|
+
<MenuItem>Два</MenuItem>
|
|
42
|
+
<MenuItem>Три</MenuItem>
|
|
43
|
+
</DropdownMenu>;
|
|
44
|
+
```
|
|
45
|
+
|
|
19
46
|
Меню с заданной шириной.
|
|
20
47
|
|
|
21
48
|
```jsx harmony
|
|
@@ -61,7 +61,6 @@ declare type DefaultProps = Required<Pick<HintProps, 'pos' | 'manual' | 'opened'
|
|
|
61
61
|
*/
|
|
62
62
|
export declare class Hint extends React.PureComponent<HintProps, HintState> implements InstanceWithAnchorElement {
|
|
63
63
|
static __KONTUR_REACT_UI__: string;
|
|
64
|
-
private isMobileLayout;
|
|
65
64
|
static defaultProps: DefaultProps;
|
|
66
65
|
private getProps;
|
|
67
66
|
state: HintState;
|
|
@@ -72,14 +71,12 @@ export declare class Hint extends React.PureComponent<HintProps, HintState> impl
|
|
|
72
71
|
componentDidUpdate(prevProps: HintProps): void;
|
|
73
72
|
componentWillUnmount(): void;
|
|
74
73
|
render(): JSX.Element;
|
|
75
|
-
renderMobile(): JSX.Element;
|
|
76
74
|
renderMain(): JSX.Element;
|
|
77
75
|
getAnchorElement: () => Nullable<Element>;
|
|
78
76
|
private renderContent;
|
|
79
77
|
private getPositions;
|
|
80
78
|
private handleMouseEnter;
|
|
81
79
|
private handleMouseLeave;
|
|
82
|
-
private close;
|
|
83
80
|
private open;
|
|
84
81
|
}
|
|
85
82
|
export {};
|