@skbkontur/react-ui 4.15.6 → 4.15.7
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 +12 -0
- package/cjs/components/Input/InputLayout/InputLayoutAside.js +1 -1
- package/cjs/components/Input/InputLayout/InputLayoutAside.js.map +1 -1
- package/cjs/components/Input/InputLayout/InputLayoutAsideIcon.js +4 -4
- package/cjs/components/Input/InputLayout/InputLayoutAsideIcon.js.map +1 -1
- package/cjs/internal/CustomComboBox/CustomComboBox.js +3 -3
- package/cjs/internal/CustomComboBox/CustomComboBox.js.map +1 -1
- package/components/Input/InputLayout/InputLayoutAside/InputLayoutAside.js +1 -2
- package/components/Input/InputLayout/InputLayoutAside/InputLayoutAside.js.map +1 -1
- package/components/Input/InputLayout/InputLayoutAsideIcon/InputLayoutAsideIcon.js +7 -5
- package/components/Input/InputLayout/InputLayoutAsideIcon/InputLayoutAsideIcon.js.map +1 -1
- package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js +8 -4
- package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.15.7](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.15.6...@skbkontur/react-ui@4.15.7) (2023-08-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ComboBox:** remove flushSync console error for React18 ([#3253](https://github.com/skbkontur/retail-ui/issues/3253)) ([e71cbad](https://github.com/skbkontur/retail-ui/commit/e71cbad60e3c7be20ead3381b49800cda9c383f7))
|
|
12
|
+
* **Input:** repair icon props ([#3248](https://github.com/skbkontur/retail-ui/issues/3248)) ([54d0349](https://github.com/skbkontur/retail-ui/commit/54d03496a834aa044314f51788048eea2af0ed58))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [4.15.6](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.15.5...@skbkontur/react-ui@4.15.6) (2023-08-02)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @skbkontur/react-ui
|
|
@@ -13,7 +13,7 @@ var _InputLayoutAsideText = require("./InputLayoutAsideText");
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var InputLayoutAside = function InputLayoutAside(_ref) {var
|
|
16
|
+
var InputLayoutAside = function InputLayoutAside(_ref) {var icon = _ref.icon,text = _ref.text,side = _ref.side;
|
|
17
17
|
var asideClassName = _InputLayout.stylesLayout.aside();
|
|
18
18
|
|
|
19
19
|
var _icon = /*#__PURE__*/_react.default.createElement(_InputLayoutAsideIcon.InputLayoutAsideIcon, { key: "icon", icon: icon, side: side });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["InputLayoutAside.tsx"],"names":["InputLayoutAside","icon","text","side","asideClassName","stylesLayout","aside","_icon","_text","child","ZERO_WIDTH_SPACE"],"mappings":"8JAAA;;;AAGA;;AAEA;AACA;AACA;;;;;;;;AAQO,IAAMA,gBAAgE,GAAG,SAAnEA,gBAAmE,
|
|
1
|
+
{"version":3,"sources":["InputLayoutAside.tsx"],"names":["InputLayoutAside","icon","text","side","asideClassName","stylesLayout","aside","_icon","_text","child","ZERO_WIDTH_SPACE"],"mappings":"8JAAA;;;AAGA;;AAEA;AACA;AACA;;;;;;;;AAQO,IAAMA,gBAAgE,GAAG,SAAnEA,gBAAmE,OAA0B,KAAvBC,IAAuB,QAAvBA,IAAuB,CAAjBC,IAAiB,QAAjBA,IAAiB,CAAXC,IAAW,QAAXA,IAAW;AACxG,MAAMC,cAAc,GAAGC,0BAAaC,KAAb,EAAvB;;AAEA,MAAMC,KAAK,gBAAG,6BAAC,0CAAD,IAAsB,GAAG,EAAC,MAA1B,EAAiC,IAAI,EAAEN,IAAvC,EAA6C,IAAI,EAAEE,IAAnD,GAAd;AACA,MAAMK,KAAK,gBAAG,6BAAC,0CAAD,IAAsB,GAAG,EAAC,MAA1B,EAAiC,IAAI,EAAEN,IAAvC,GAAd;;AAEA,MAAMO,KAAK,GAAGN,IAAI,KAAK,MAAT,GAAkB,CAACI,KAAD,EAAQC,KAAR,CAAlB,GAAmC,CAACA,KAAD,EAAQD,KAAR,CAAjD;;AAEA;AACE,2CAAM,SAAS,EAAEH,cAAjB;AACGM,2BADH;AAEGD,IAAAA,KAFH,CADF;;;AAMD,CAdM,C","sourcesContent":["import React from 'react';\n\nimport { InputProps } from '../Input';\nimport { ZERO_WIDTH_SPACE } from '../../../lib/chars';\n\nimport { stylesLayout } from './InputLayout.styles';\nimport { InputLayoutAsideIcon } from './InputLayoutAsideIcon';\nimport { InputLayoutAsideText } from './InputLayoutAsideText';\n\nexport interface InputLayoutAsideProps {\n icon: InputProps['leftIcon'] | InputProps['rightIcon'];\n text: InputProps['prefix'] | InputProps['suffix'];\n side: 'left' | 'right';\n}\n\nexport const InputLayoutAside: React.FunctionComponent<InputLayoutAsideProps> = ({ icon, text, side }) => {\n const asideClassName = stylesLayout.aside();\n\n const _icon = <InputLayoutAsideIcon key=\"icon\" icon={icon} side={side} />;\n const _text = <InputLayoutAsideText key=\"text\" text={text} />;\n\n const child = side === 'left' ? [_icon, _text] : [_text, _icon];\n\n return (\n <span className={asideClassName}>\n {ZERO_WIDTH_SPACE}\n {child}\n </span>\n );\n};\n"]}
|
|
@@ -13,7 +13,7 @@ var _InputLayout = require("./InputLayout.styles");
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var InputLayoutAsideIcon = function InputLayoutAsideIcon(_ref) {var icon = _ref.icon,side = _ref.side;
|
|
16
|
+
var InputLayoutAsideIcon = function InputLayoutAsideIcon(_ref) {var _ref$icon = _ref.icon,icon = _ref$icon === void 0 ? null : _ref$icon,side = _ref.side;
|
|
17
17
|
var theme = _react.default.useContext(_ThemeContext.ThemeContext);
|
|
18
18
|
var _React$useContext = _react.default.useContext(_InputLayoutContext.InputLayoutContext),focused = _React$useContext.focused,disabled = _React$useContext.disabled,size = _React$useContext.size;
|
|
19
19
|
|
|
@@ -28,9 +28,9 @@ var InputLayoutAsideIcon = function InputLayoutAsideIcon(_ref) {var icon = _ref.
|
|
|
28
28
|
large: parseInt(theme.inputIconGapLarge) };
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
var _icon =
|
|
32
|
-
if (icon && (0,
|
|
33
|
-
_icon =
|
|
31
|
+
var _icon = icon instanceof Function ? icon() : icon;
|
|
32
|
+
if ((0, _reactIs.isElement)(icon) && (0, _utils.isKonturIcon)(icon)) {var _icon$props$size;
|
|
33
|
+
_icon = /*#__PURE__*/_react.default.cloneElement(icon, { size: (_icon$props$size = icon.props.size) != null ? _icon$props$size : sizes[size] });
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
var style = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["InputLayoutAsideIcon.tsx"],"names":["InputLayoutAsideIcon","icon","side","theme","React","useContext","ThemeContext","InputLayoutContext","focused","disabled","size","sizes","small","parseInt","inputIconSizeSmall","medium","inputIconSizeMedium","large","inputIconSizeLarge","gaps","inputIconGapSmall","inputIconGapMedium","inputIconGapLarge","_icon","cloneElement","props","style","marginLeft","marginRight","stylesLayout","aside","iconFocus","iconDisabled"],"mappings":"kKAAA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;;;;;AAMO,IAAMA,oBAAwE,GAAG,SAA3EA,oBAA2E,
|
|
1
|
+
{"version":3,"sources":["InputLayoutAsideIcon.tsx"],"names":["InputLayoutAsideIcon","icon","side","theme","React","useContext","ThemeContext","InputLayoutContext","focused","disabled","size","sizes","small","parseInt","inputIconSizeSmall","medium","inputIconSizeMedium","large","inputIconSizeLarge","gaps","inputIconGapSmall","inputIconGapMedium","inputIconGapLarge","_icon","Function","cloneElement","props","style","marginLeft","marginRight","stylesLayout","aside","iconFocus","iconDisabled"],"mappings":"kKAAA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;;;;;AAMO,IAAMA,oBAAwE,GAAG,SAA3EA,oBAA2E,OAA2B,sBAAxBC,IAAwB,CAAxBA,IAAwB,0BAAjB,IAAiB,aAAXC,IAAW,QAAXA,IAAW;AACjH,MAAMC,KAAK,GAAGC,eAAMC,UAAN,CAAiBC,0BAAjB,CAAd;AACA,0BAAoCF,eAAMC,UAAN,CAAiBE,sCAAjB,CAApC,CAAQC,OAAR,qBAAQA,OAAR,CAAiBC,QAAjB,qBAAiBA,QAAjB,CAA2BC,IAA3B,qBAA2BA,IAA3B;;AAEA,MAAMC,KAAgC,GAAG;AACvCC,IAAAA,KAAK,EAAEC,QAAQ,CAACV,KAAK,CAACW,kBAAP,CADwB;AAEvCC,IAAAA,MAAM,EAAEF,QAAQ,CAACV,KAAK,CAACa,mBAAP,CAFuB;AAGvCC,IAAAA,KAAK,EAAEJ,QAAQ,CAACV,KAAK,CAACe,kBAAP,CAHwB,EAAzC;;AAKA,MAAMC,IAA+B,GAAG;AACtCP,IAAAA,KAAK,EAAEC,QAAQ,CAACV,KAAK,CAACiB,iBAAP,CADuB;AAEtCL,IAAAA,MAAM,EAAEF,QAAQ,CAACV,KAAK,CAACkB,kBAAP,CAFsB;AAGtCJ,IAAAA,KAAK,EAAEJ,QAAQ,CAACV,KAAK,CAACmB,iBAAP,CAHuB,EAAxC;;;AAMA,MAAIC,KAAK,GAAGtB,IAAI,YAAYuB,QAAhB,GAA2BvB,IAAI,EAA/B,GAAoCA,IAAhD;AACA,MAAI,wBAAUA,IAAV,KAAmB,yBAAaA,IAAb,CAAvB,EAA2C;AACzCsB,IAAAA,KAAK,gBAAGnB,eAAMqB,YAAN,CAAmBxB,IAAnB,EAAyB,EAAES,IAAI,sBAAET,IAAI,CAACyB,KAAL,CAAWhB,IAAb,+BAAqBC,KAAK,CAACD,IAAD,CAAhC,EAAzB,CAAR;AACD;;AAED,MAAMiB,KAA0B,GAAG,EAAnC;AACA,MAAIzB,IAAJ,EAAU;AACR,QAAIA,IAAI,KAAK,OAAb,EAAsB;AACpByB,MAAAA,KAAK,CAACC,UAAN,GAAmBT,IAAI,CAACT,IAAD,CAAvB;AACD,KAFD,MAEO;AACLiB,MAAAA,KAAK,CAACE,WAAN,GAAoBV,IAAI,CAACT,IAAD,CAAxB;AACD;AACF;;AAED;AACEa,IAAAA,KAAK;AACH;AACE,MAAA,KAAK,EAAEI,KADT;AAEE,MAAA,SAAS,EAAE;AACTG,gCAAaC,KAAb,EADS;AAETD,gCAAa7B,IAAb,CAAkBE,KAAlB,CAFS;AAGTK,MAAAA,OAAO,IAAIsB,0BAAaE,SAAb,CAAuB7B,KAAvB,CAHF;AAITM,MAAAA,QAAQ,IAAIqB,0BAAaG,YAAb,EAJH,CAFb;;;AASGV,IAAAA,KATH,CAFJ;;;;AAeD,CA5CM,C","sourcesContent":["import React from 'react';\nimport { isElement } from 'react-is';\n\nimport { isKonturIcon } from '../../../lib/utils';\nimport { InputProps, InputSize } from '../Input';\nimport { cx } from '../../../lib/theming/Emotion';\nimport { ThemeContext } from '../../../lib/theming/ThemeContext';\n\nimport { InputLayoutContext } from './InputLayoutContext';\nimport { stylesLayout } from './InputLayout.styles';\nexport interface InputLayoutAsideIconProps {\n icon: InputProps['leftIcon'] | InputProps['rightIcon'];\n side: 'left' | 'right';\n}\n\nexport const InputLayoutAsideIcon: React.FunctionComponent<InputLayoutAsideIconProps> = ({ icon = null, side }) => {\n const theme = React.useContext(ThemeContext);\n const { focused, disabled, size } = React.useContext(InputLayoutContext);\n\n const sizes: Record<InputSize, number> = {\n small: parseInt(theme.inputIconSizeSmall),\n medium: parseInt(theme.inputIconSizeMedium),\n large: parseInt(theme.inputIconSizeLarge),\n };\n const gaps: Record<InputSize, number> = {\n small: parseInt(theme.inputIconGapSmall),\n medium: parseInt(theme.inputIconGapMedium),\n large: parseInt(theme.inputIconGapLarge),\n };\n\n let _icon = icon instanceof Function ? icon() : icon;\n if (isElement(icon) && isKonturIcon(icon)) {\n _icon = React.cloneElement(icon, { size: icon.props.size ?? sizes[size] });\n }\n\n const style: React.CSSProperties = {};\n if (side) {\n if (side === 'right') {\n style.marginLeft = gaps[size];\n } else {\n style.marginRight = gaps[size];\n }\n }\n\n return (\n _icon && (\n <span\n style={style}\n className={cx(\n stylesLayout.aside(),\n stylesLayout.icon(theme),\n focused && stylesLayout.iconFocus(theme),\n disabled && stylesLayout.iconDisabled(),\n )}\n >\n {_icon}\n </span>\n )\n );\n};\n"]}
|
|
@@ -329,7 +329,7 @@ CustomComboBox = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNod
|
|
|
329
329
|
|
|
330
330
|
|
|
331
331
|
|
|
332
|
-
dispatch = function (action) {
|
|
332
|
+
dispatch = function (action, sync) {if (sync === void 0) {sync = true;}
|
|
333
333
|
var updateState = function updateState(action) {
|
|
334
334
|
var effects;
|
|
335
335
|
var nextState;
|
|
@@ -348,7 +348,7 @@ CustomComboBox = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNod
|
|
|
348
348
|
|
|
349
349
|
// Auto-batching React@18 creates problems that are fixed with flushSync
|
|
350
350
|
// https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366
|
|
351
|
-
if (_react.default.version.search('18') === 0) {
|
|
351
|
+
if (sync && _react.default.version.search('18') === 0) {
|
|
352
352
|
_reactDom.default.flushSync(function () {return updateState(action);});
|
|
353
353
|
} else {
|
|
354
354
|
updateState(action);
|
|
@@ -426,6 +426,6 @@ CustomComboBox = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNod
|
|
|
426
426
|
* @public
|
|
427
427
|
*/;_proto.open = function open() {this.dispatch({ type: 'Open' });} /**
|
|
428
428
|
* @public
|
|
429
|
-
*/;_proto.close = function close() {this.dispatch({ type: 'Close' });};_proto.render = function render() {var _this3 = this;var viewProps = { align: this.props.align, borderless: this.props.borderless, disabled: this.props.disabled, disablePortal: this.props.disablePortal, editing: this.state.editing, error: this.props.error, items: this.state.items, loading: this.state.loading, menuAlign: this.props.menuAlign, opened: this.state.opened, drawArrow: this.props.drawArrow, menuPos: this.props.menuPos, placeholder: this.props.placeholder, size: this.props.size, textValue: this.state.textValue, totalCount: this.props.totalCount, value: this.props.value, warning: this.props.warning, 'aria-describedby': this.props['aria-describedby'], width: this.props.width, maxLength: this.props.maxLength, maxMenuHeight: this.props.maxMenuHeight, leftIcon: this.props.leftIcon, rightIcon: this.props.rightIcon, inputMode: this.props.inputMode, onValueChange: this.handleValueChange, onClickOutside: this.handleClickOutside, onFocus: this.handleFocus, onFocusOutside: this.handleBlur, onInputBlur: this.handleInputBlur, onInputValueChange: function onInputValueChange(value) {return _this3.dispatch({ type: 'TextChange', value: value });}, onInputFocus: this.handleFocus, onInputClick: this.handleInputClick, onInputKeyDown: function onInputKeyDown(event) {event.persist();_this3.dispatch({ type: 'KeyPress', event: event });}, onMouseEnter: this.props.onMouseEnter, onMouseOver: this.props.onMouseOver, onMouseLeave: this.props.onMouseLeave, renderItem: this.props.renderItem, renderNotFound: this.props.renderNotFound, itemWrapper: this.props.itemWrapper, renderValue: this.props.renderValue, renderTotalCount: this.props.renderTotalCount, renderAddButton: this.props.renderAddButton, repeatRequest: this.state.repeatRequest, requestStatus: this.state.requestStatus, refInput: function refInput(input) {_this3.input = input;}, refMenu: function refMenu(menu) {_this3.menu = menu;}, refInputLikeText: function refInputLikeText(inputLikeText) {_this3.inputLikeText = inputLikeText;} };return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, this.props, /*#__PURE__*/_react.default.createElement(_ComboBoxView.ComboBoxView, (0, _extends2.default)({}, viewProps, { ref: this.setRootNode })));};_proto.componentDidMount = function componentDidMount() {this.dispatch({ type: 'Mount' });if (this.props.autoFocus) {this.focus();}};_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {if (prevState.editing && !this.state.editing) {this.handleBlur();}this.dispatch({ type: 'DidUpdate', prevProps: prevProps, prevState: prevState });} /**
|
|
429
|
+
*/;_proto.close = function close() {this.dispatch({ type: 'Close' });};_proto.render = function render() {var _this3 = this;var viewProps = { align: this.props.align, borderless: this.props.borderless, disabled: this.props.disabled, disablePortal: this.props.disablePortal, editing: this.state.editing, error: this.props.error, items: this.state.items, loading: this.state.loading, menuAlign: this.props.menuAlign, opened: this.state.opened, drawArrow: this.props.drawArrow, menuPos: this.props.menuPos, placeholder: this.props.placeholder, size: this.props.size, textValue: this.state.textValue, totalCount: this.props.totalCount, value: this.props.value, warning: this.props.warning, 'aria-describedby': this.props['aria-describedby'], width: this.props.width, maxLength: this.props.maxLength, maxMenuHeight: this.props.maxMenuHeight, leftIcon: this.props.leftIcon, rightIcon: this.props.rightIcon, inputMode: this.props.inputMode, onValueChange: this.handleValueChange, onClickOutside: this.handleClickOutside, onFocus: this.handleFocus, onFocusOutside: this.handleBlur, onInputBlur: this.handleInputBlur, onInputValueChange: function onInputValueChange(value) {return _this3.dispatch({ type: 'TextChange', value: value });}, onInputFocus: this.handleFocus, onInputClick: this.handleInputClick, onInputKeyDown: function onInputKeyDown(event) {event.persist();_this3.dispatch({ type: 'KeyPress', event: event });}, onMouseEnter: this.props.onMouseEnter, onMouseOver: this.props.onMouseOver, onMouseLeave: this.props.onMouseLeave, renderItem: this.props.renderItem, renderNotFound: this.props.renderNotFound, itemWrapper: this.props.itemWrapper, renderValue: this.props.renderValue, renderTotalCount: this.props.renderTotalCount, renderAddButton: this.props.renderAddButton, repeatRequest: this.state.repeatRequest, requestStatus: this.state.requestStatus, refInput: function refInput(input) {_this3.input = input;}, refMenu: function refMenu(menu) {_this3.menu = menu;}, refInputLikeText: function refInputLikeText(inputLikeText) {_this3.inputLikeText = inputLikeText;} };return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, this.props, /*#__PURE__*/_react.default.createElement(_ComboBoxView.ComboBoxView, (0, _extends2.default)({}, viewProps, { ref: this.setRootNode })));};_proto.componentDidMount = function componentDidMount() {this.dispatch({ type: 'Mount' }, false);if (this.props.autoFocus) {this.focus();}};_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {if (prevState.editing && !this.state.editing) {this.handleBlur();}this.dispatch({ type: 'DidUpdate', prevProps: prevProps, prevState: prevState }, false);} /**
|
|
430
430
|
* @public
|
|
431
431
|
*/;_proto.reset = function reset() {this.dispatch({ type: 'Reset' });};return CustomComboBox;}(_react.default.PureComponent), _class2.__KONTUR_REACT_UI__ = 'CustomComboBox', _temp)) || _class) || _class;exports.CustomComboBox = CustomComboBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CustomComboBox.tsx"],"names":["DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","ComboBoxRequestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","responsiveLayout","rootNode","state","requestId","cancelationToken","reducer","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","updateState","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","React","version","search","ReactDOM","flushSync","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","catch","race","code","cancelSearch","CancelationError","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"quBAAA;AACA;;;;;;;AAOA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA,8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DO,IAAMA,wBAAwB,GAAG,GAAjC,C;AACA,IAAMC,gBAAgB,GAAG,IAAzB,C;;AAEA,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,YAAY,EAAE,KADY;AAE1BC,EAAAA,OAAO,EAAE,KAFiB;AAG1BC,EAAAA,KAAK,EAAE,IAHmB;AAI1BC,EAAAA,OAAO,EAAE,KAJiB;AAK1BC,EAAAA,MAAM,EAAE,KALkB;AAM1BC,EAAAA,OAAO,EAAE,KANiB;AAO1BC,EAAAA,SAAS,EAAE,EAPe;AAQ1BC,EAAAA,aAAa,EAAE,iCAAMC,SAAN,EARW;AAS1BC,EAAAA,aAAa,EAAEC,2CAAsBC,OATX,EAArB,C;;;AAYA,IAAMC,sBAAsB,GAAG;AACpCC,EAAAA,YAAY,EAAE,oBADsB,EAA/B,C;;;;;AAMMC,c,OAFZC,2B,eACAC,kB;;;AAIQC,IAAAA,K,GAAgClB,Y;;;;AAIhCmB,IAAAA,S,GAAY,C;;AAEXb,IAAAA,O,GAAU,K;AACVc,IAAAA,gB,GAAuD,I;;;AAGvDC,IAAAA,O,GAAUA,8B;AACXC,IAAAA,iB,GAAgC,oBAAM,IAAN,E;;;;;AAKhCC,IAAAA,K,GAAQ,YAAM;AACnB,UAAI,MAAKC,KAAL,CAAWC,QAAf,EAAyB;AACvB;AACD;;AAED,UAAI,MAAKC,KAAT,EAAgB;AACd,cAAKA,KAAL,CAAWH,KAAX;AACD,OAFD,MAEO,IAAI,MAAKI,aAAT,EAAwB;AAC7B,cAAKA,aAAL,CAAmBJ,KAAnB;AACD;AACF,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AxDe,EAyDhBC,gBAAgB,EAAE,0BAAC7F,aAAD,EAA4C,CAC5D,MAAI,CAACA,aAAL,GAAqBA,aAArB,CACD,CA3De,EAAlB,CA8DA,oBACE,6BAAC,4BAAD,EAAmB,KAAKH,KAAxB,eACE,6BAAC,0BAAD,6BAAkBuD,SAAlB,IAA6B,GAAG,EAAE,KAAK0C,WAAvC,IADF,CADF,CAKD,C,QAEMC,iB,GAAP,6BAA2B,CACzB,KAAK1F,QAAL,CAAc,EAAEoB,IAAI,EAAE,OAAR,EAAd,EACA,IAAI,KAAK5B,KAAL,CAAWmG,SAAf,EAA0B,CACxB,KAAKpG,KAAL,GACD,CACF,C,QAEMqG,kB,GAAP,4BAA0BC,SAA1B,EAA6DC,SAA7D,EAAgG,CAC9F,IAAIA,SAAS,CAAC5H,OAAV,IAAqB,CAAC,KAAKgB,KAAL,CAAWhB,OAArC,EAA8C,CAC5C,KAAK6B,UAAL,GACD,CACD,KAAKC,QAAL,CAAc,EAAEoB,IAAI,EAAE,WAAR,EAAqByE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EACD,C,CAED;AACF;AACA,K,QACSC,K,GAAP,iBAAe,CACb,KAAK/F,QAAL,CAAc,EAAEoB,IAAI,EAAE,OAAR,EAAd,EACD,C,yBArOoCV,eAAMsF,a,WAC7BC,mB,GAAsB,gB","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n 'aria-describedby': this.props['aria-describedby'],\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' });\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState });\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>) => {\n const updateState = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n // Auto-batching React@18 creates problems that are fixed with flushSync\n // https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366\n if (React.version.search('18') === 0) {\n ReactDOM.flushSync(() => updateState(action));\n } else {\n updateState(action);\n }\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["CustomComboBox.tsx"],"names":["DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","ComboBoxRequestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","responsiveLayout","rootNode","state","requestId","cancelationToken","reducer","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","sync","updateState","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","React","version","search","ReactDOM","flushSync","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","catch","race","code","cancelSearch","CancelationError","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"quBAAA;AACA;;;;;;;AAOA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA,8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DO,IAAMA,wBAAwB,GAAG,GAAjC,C;AACA,IAAMC,gBAAgB,GAAG,IAAzB,C;;AAEA,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,YAAY,EAAE,KADY;AAE1BC,EAAAA,OAAO,EAAE,KAFiB;AAG1BC,EAAAA,KAAK,EAAE,IAHmB;AAI1BC,EAAAA,OAAO,EAAE,KAJiB;AAK1BC,EAAAA,MAAM,EAAE,KALkB;AAM1BC,EAAAA,OAAO,EAAE,KANiB;AAO1BC,EAAAA,SAAS,EAAE,EAPe;AAQ1BC,EAAAA,aAAa,EAAE,iCAAMC,SAAN,EARW;AAS1BC,EAAAA,aAAa,EAAEC,2CAAsBC,OATX,EAArB,C;;;AAYA,IAAMC,sBAAsB,GAAG;AACp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qByE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EAA2D,KAA3D,EACD,C,CAED;AACF;AACA,K,QACSC,K,GAAP,iBAAe,CACb,KAAKhG,QAAL,CAAc,EAAEqB,IAAI,EAAE,OAAR,EAAd,EACD,C,yBArOoCV,eAAMsF,a,WAC7BC,mB,GAAsB,gB","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n 'aria-describedby': this.props['aria-describedby'],\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' }, false);\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState }, false);\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>, sync = true) => {\n const updateState = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n // Auto-batching React@18 creates problems that are fixed with flushSync\n // https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366\n if (sync && React.version.search('18') === 0) {\n ReactDOM.flushSync(() => updateState(action));\n } else {\n updateState(action);\n }\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
|
|
@@ -4,8 +4,7 @@ import { stylesLayout } from "../InputLayout.styles";
|
|
|
4
4
|
import { InputLayoutAsideIcon } from "../InputLayoutAsideIcon";
|
|
5
5
|
import { InputLayoutAsideText } from "../InputLayoutAsideText";
|
|
6
6
|
export var InputLayoutAside = function InputLayoutAside(_ref) {
|
|
7
|
-
var
|
|
8
|
-
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
7
|
+
var icon = _ref.icon,
|
|
9
8
|
text = _ref.text,
|
|
10
9
|
side = _ref.side;
|
|
11
10
|
var asideClassName = stylesLayout.aside();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["InputLayoutAside.tsx"],"names":["React","ZERO_WIDTH_SPACE","stylesLayout","InputLayoutAsideIcon","InputLayoutAsideText","InputLayoutAside","icon","text","side","asideClassName","aside","_icon","_text","child"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;;;AAGA,SAASC,gBAAT,QAAiC,oBAAjC;;AAEA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,oBAAT,QAAqC,wBAArC;;;;;;;;AAQA,OAAO,IAAMC,gBAAgE,GAAG,SAAnEA,gBAAmE,
|
|
1
|
+
{"version":3,"sources":["InputLayoutAside.tsx"],"names":["React","ZERO_WIDTH_SPACE","stylesLayout","InputLayoutAsideIcon","InputLayoutAsideText","InputLayoutAside","icon","text","side","asideClassName","aside","_icon","_text","child"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;;;AAGA,SAASC,gBAAT,QAAiC,oBAAjC;;AAEA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,oBAAT,QAAqC,wBAArC;;;;;;;;AAQA,OAAO,IAAMC,gBAAgE,GAAG,SAAnEA,gBAAmE,OAA0B,KAAvBC,IAAuB,QAAvBA,IAAuB,CAAjBC,IAAiB,QAAjBA,IAAiB,CAAXC,IAAW,QAAXA,IAAW;AACxG,MAAMC,cAAc,GAAGP,YAAY,CAACQ,KAAb,EAAvB;;AAEA,MAAMC,KAAK,gBAAG,oBAAC,oBAAD,IAAsB,GAAG,EAAC,MAA1B,EAAiC,IAAI,EAAEL,IAAvC,EAA6C,IAAI,EAAEE,IAAnD,GAAd;AACA,MAAMI,KAAK,gBAAG,oBAAC,oBAAD,IAAsB,GAAG,EAAC,MAA1B,EAAiC,IAAI,EAAEL,IAAvC,GAAd;;AAEA,MAAMM,KAAK,GAAGL,IAAI,KAAK,MAAT,GAAkB,CAACG,KAAD,EAAQC,KAAR,CAAlB,GAAmC,CAACA,KAAD,EAAQD,KAAR,CAAjD;;AAEA;AACE,kCAAM,SAAS,EAAEF,cAAjB;AACGR,IAAAA,gBADH;AAEGY,IAAAA,KAFH,CADF;;;AAMD,CAdM","sourcesContent":["import React from 'react';\n\nimport { InputProps } from '../Input';\nimport { ZERO_WIDTH_SPACE } from '../../../lib/chars';\n\nimport { stylesLayout } from './InputLayout.styles';\nimport { InputLayoutAsideIcon } from './InputLayoutAsideIcon';\nimport { InputLayoutAsideText } from './InputLayoutAsideText';\n\nexport interface InputLayoutAsideProps {\n icon: InputProps['leftIcon'] | InputProps['rightIcon'];\n text: InputProps['prefix'] | InputProps['suffix'];\n side: 'left' | 'right';\n}\n\nexport const InputLayoutAside: React.FunctionComponent<InputLayoutAsideProps> = ({ icon, text, side }) => {\n const asideClassName = stylesLayout.aside();\n\n const _icon = <InputLayoutAsideIcon key=\"icon\" icon={icon} side={side} />;\n const _text = <InputLayoutAsideText key=\"text\" text={text} />;\n\n const child = side === 'left' ? [_icon, _text] : [_text, _icon];\n\n return (\n <span className={asideClassName}>\n {ZERO_WIDTH_SPACE}\n {child}\n </span>\n );\n};\n"]}
|
|
@@ -6,7 +6,8 @@ import { ThemeContext } from "../../../../lib/theming/ThemeContext";
|
|
|
6
6
|
import { InputLayoutContext } from "../InputLayoutContext";
|
|
7
7
|
import { stylesLayout } from "../InputLayout.styles";
|
|
8
8
|
export var InputLayoutAsideIcon = function InputLayoutAsideIcon(_ref) {
|
|
9
|
-
var icon = _ref.icon,
|
|
9
|
+
var _ref$icon = _ref.icon,
|
|
10
|
+
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
10
11
|
side = _ref.side;
|
|
11
12
|
var theme = React.useContext(ThemeContext);
|
|
12
13
|
|
|
@@ -25,14 +26,15 @@ export var InputLayoutAsideIcon = function InputLayoutAsideIcon(_ref) {
|
|
|
25
26
|
medium: parseInt(theme.inputIconGapMedium),
|
|
26
27
|
large: parseInt(theme.inputIconGapLarge)
|
|
27
28
|
};
|
|
28
|
-
var _icon = null;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
var _icon = icon instanceof Function ? icon() : icon;
|
|
31
|
+
|
|
32
|
+
if (isElement(icon) && isKonturIcon(icon)) {
|
|
31
33
|
var _icon$props$size;
|
|
32
34
|
|
|
33
|
-
_icon =
|
|
35
|
+
_icon = /*#__PURE__*/React.cloneElement(icon, {
|
|
34
36
|
size: (_icon$props$size = icon.props.size) != null ? _icon$props$size : sizes[size]
|
|
35
|
-
})
|
|
37
|
+
});
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
var style = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["InputLayoutAsideIcon.tsx"],"names":["React","isElement","isKonturIcon","cx","ThemeContext","InputLayoutContext","stylesLayout","InputLayoutAsideIcon","icon","side","theme","useContext","focused","disabled","size","sizes","small","parseInt","inputIconSizeSmall","medium","inputIconSizeMedium","large","inputIconSizeLarge","gaps","inputIconGapSmall","inputIconGapMedium","inputIconGapLarge","_icon","cloneElement","props","style","marginLeft","marginRight","aside","iconFocus","iconDisabled"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAEA,SAASC,YAAT,QAA6B,oBAA7B;;AAEA,SAASC,EAAT,QAAmB,8BAAnB;AACA,SAASC,YAAT,QAA6B,mCAA7B;;AAEA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,YAAT,QAA6B,sBAA7B;;;;;;AAMA,OAAO,IAAMC,oBAAwE,GAAG,SAA3EA,oBAA2E,
|
|
1
|
+
{"version":3,"sources":["InputLayoutAsideIcon.tsx"],"names":["React","isElement","isKonturIcon","cx","ThemeContext","InputLayoutContext","stylesLayout","InputLayoutAsideIcon","icon","side","theme","useContext","focused","disabled","size","sizes","small","parseInt","inputIconSizeSmall","medium","inputIconSizeMedium","large","inputIconSizeLarge","gaps","inputIconGapSmall","inputIconGapMedium","inputIconGapLarge","_icon","Function","cloneElement","props","style","marginLeft","marginRight","aside","iconFocus","iconDisabled"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAEA,SAASC,YAAT,QAA6B,oBAA7B;;AAEA,SAASC,EAAT,QAAmB,8BAAnB;AACA,SAASC,YAAT,QAA6B,mCAA7B;;AAEA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,YAAT,QAA6B,sBAA7B;;;;;;AAMA,OAAO,IAAMC,oBAAwE,GAAG,SAA3EA,oBAA2E,OAA2B,sBAAxBC,IAAwB,CAAxBA,IAAwB,0BAAjB,IAAiB,aAAXC,IAAW,QAAXA,IAAW;AACjH,MAAMC,KAAK,GAAGV,KAAK,CAACW,UAAN,CAAiBP,YAAjB,CAAd;AACA,0BAAoCJ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AACEa,IAAAA,KAAK;AACH;AACE,MAAA,KAAK,EAAEI,KADT;AAEE,MAAA,SAAS,EAAE5B,EAAE;AACXG,MAAAA,YAAY,CAAC4B,KAAb,EADW;AAEX5B,MAAAA,YAAY,CAACE,IAAb,CAAkBE,KAAlB,CAFW;AAGXE,MAAAA,OAAO,IAAIN,YAAY,CAAC6B,SAAb,CAAuBzB,KAAvB,CAHA;AAIXG,MAAAA,QAAQ,IAAIP,YAAY,CAAC8B,YAAb,EAJD,CAFf;;;AASGT,IAAAA,KATH,CAFJ;;;;AAeD,CA5CM","sourcesContent":["import React from 'react';\nimport { isElement } from 'react-is';\n\nimport { isKonturIcon } from '../../../lib/utils';\nimport { InputProps, InputSize } from '../Input';\nimport { cx } from '../../../lib/theming/Emotion';\nimport { ThemeContext } from '../../../lib/theming/ThemeContext';\n\nimport { InputLayoutContext } from './InputLayoutContext';\nimport { stylesLayout } from './InputLayout.styles';\nexport interface InputLayoutAsideIconProps {\n icon: InputProps['leftIcon'] | InputProps['rightIcon'];\n side: 'left' | 'right';\n}\n\nexport const InputLayoutAsideIcon: React.FunctionComponent<InputLayoutAsideIconProps> = ({ icon = null, side }) => {\n const theme = React.useContext(ThemeContext);\n const { focused, disabled, size } = React.useContext(InputLayoutContext);\n\n const sizes: Record<InputSize, number> = {\n small: parseInt(theme.inputIconSizeSmall),\n medium: parseInt(theme.inputIconSizeMedium),\n large: parseInt(theme.inputIconSizeLarge),\n };\n const gaps: Record<InputSize, number> = {\n small: parseInt(theme.inputIconGapSmall),\n medium: parseInt(theme.inputIconGapMedium),\n large: parseInt(theme.inputIconGapLarge),\n };\n\n let _icon = icon instanceof Function ? icon() : icon;\n if (isElement(icon) && isKonturIcon(icon)) {\n _icon = React.cloneElement(icon, { size: icon.props.size ?? sizes[size] });\n }\n\n const style: React.CSSProperties = {};\n if (side) {\n if (side === 'right') {\n style.marginLeft = gaps[size];\n } else {\n style.marginRight = gaps[size];\n }\n }\n\n return (\n _icon && (\n <span\n style={style}\n className={cx(\n stylesLayout.aside(),\n stylesLayout.icon(theme),\n focused && stylesLayout.iconFocus(theme),\n disabled && stylesLayout.iconDisabled(),\n )}\n >\n {_icon}\n </span>\n )\n );\n};\n"]}
|
|
@@ -85,7 +85,11 @@ export var CustomComboBox = responsiveLayout(_class = rootNode(_class = (_temp =
|
|
|
85
85
|
_this.handleBlur();
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
_this.dispatch = function (action) {
|
|
88
|
+
_this.dispatch = function (action, sync) {
|
|
89
|
+
if (sync === void 0) {
|
|
90
|
+
sync = true;
|
|
91
|
+
}
|
|
92
|
+
|
|
89
93
|
var updateState = function updateState(action) {
|
|
90
94
|
var effects;
|
|
91
95
|
var nextState;
|
|
@@ -105,7 +109,7 @@ export var CustomComboBox = responsiveLayout(_class = rootNode(_class = (_temp =
|
|
|
105
109
|
// https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366
|
|
106
110
|
|
|
107
111
|
|
|
108
|
-
if (React.version.search('18') === 0) {
|
|
112
|
+
if (sync && React.version.search('18') === 0) {
|
|
109
113
|
ReactDOM.flushSync(function () {
|
|
110
114
|
return updateState(action);
|
|
111
115
|
});
|
|
@@ -427,7 +431,7 @@ export var CustomComboBox = responsiveLayout(_class = rootNode(_class = (_temp =
|
|
|
427
431
|
_proto.componentDidMount = function componentDidMount() {
|
|
428
432
|
this.dispatch({
|
|
429
433
|
type: 'Mount'
|
|
430
|
-
});
|
|
434
|
+
}, false);
|
|
431
435
|
|
|
432
436
|
if (this.props.autoFocus) {
|
|
433
437
|
this.focus();
|
|
@@ -443,7 +447,7 @@ export var CustomComboBox = responsiveLayout(_class = rootNode(_class = (_temp =
|
|
|
443
447
|
type: 'DidUpdate',
|
|
444
448
|
prevProps: prevProps,
|
|
445
449
|
prevState: prevState
|
|
446
|
-
});
|
|
450
|
+
}, false);
|
|
447
451
|
}
|
|
448
452
|
/**
|
|
449
453
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CustomComboBox.tsx"],"names":["React","ReactDOM","CancelationError","taskWithDelay","fixClickFocusIE","CommonWrapper","responsiveLayout","rootNode","ComboBoxRequestStatus","reducer","ComboBoxView","DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","state","requestId","cancelationToken","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","updateState","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","version","search","flushSync","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","race","code","cancelSearch","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"0XAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,OAAOC,QAAP,MAAqB,WAArB;;;;;;;AAOA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,eAAT,QAAgC,kCAAhC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,QAAuC,oBAAvC;;;AAGA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SA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,aAhDV,EAiDhBE,aAAa,EAAE,KAAKK,KAAL,CAAWL,aAjDV,EAmDhBmG,QAAQ,EAAE,kBAACvF,KAAD,EAA4B,CACpC,MAAI,CAACA,KAAL,GAAaA,KAAb,CACD,CArDe,EAsDhBwF,OAAO,EAAE,iBAACC,IAAD,EAA0B,CACjC,MAAI,CAACA,IAAL,GAAYA,IAAZ,CACD,CAxDe,EAyDhBC,gBAAgB,EAAE,0BAACzF,aAAD,EAA4C,CAC5D,MAAI,CAACA,aAAL,GAAqBA,aAArB,CACD,CA3De,EAAlB,CA8DA,oBACE,oBAAC,aAAD,EAAmB,KAAKH,KAAxB,eACE,oBAAC,YAAD,eAAkBmD,SAAlB,IAA6B,GAAG,EAAE,KAAK0C,WAAvC,IADF,CADF,CAKD,CAhNH,QAkNSC,iBAlNT,GAkNE,6BAA2B,CACzB,KAAKtF,QAAL,CAAc,EAAEkB,IAAI,EAAE,OAAR,EAAd,EACA,IAAI,KAAK1B,KAAL,CAAW+F,SAAf,EAA0B,CACxB,KAAKhG,KAAL,GACD,CACF,CAvNH,QAyNSiG,kBAzNT,GAyNE,4BAA0BC,SAA1B,EAA6DC,SAA7D,EAAgG,CAC9F,IAAIA,SAAS,CAACpH,OAAV,IAAqB,CAAC,KAAKa,KAAL,CAAWb,OAArC,EAA8C,CAC5C,KAAKyB,UAAL,GACD,CACD,KAAKC,QAAL,CAAc,EAAEkB,IAAI,EAAE,WAAR,EAAqBuE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EACD,CA9NH,CAgOE;AACF;AACA,KAlOA,QAmOSC,KAnOT,GAmOE,iBAAe,CACb,KAAK3F,QAAL,CAAc,EAAEkB,IAAI,EAAE,OAAR,EAAd,EACD,CArOH,yBAAuC3D,KAAK,CAACqI,aAA7C,WACgBC,mBADhB,GACsC,gBADtC","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n 'aria-describedby': this.props['aria-describedby'],\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' });\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState });\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>) => {\n const updateState = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n // Auto-batching React@18 creates problems that are fixed with flushSync\n // https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366\n if (React.version.search('18') === 0) {\n ReactDOM.flushSync(() => updateState(action));\n } else {\n updateState(action);\n }\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["CustomComboBox.tsx"],"names":["React","ReactDOM","CancelationError","taskWithDelay","fixClickFocusIE","CommonWrapper","responsiveLayout","rootNode","ComboBoxRequestStatus","reducer","ComboBoxView","DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","state","requestId","cancelationToken","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","sync","updateState","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","version","search","flushSync","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","race","code","cancelSearch","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"0XAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,OAAOC,QAAP,MAAqB,WAArB;;;;;;;AAOA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,eAAT,QAAgC,kCAAhC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,QAAuC,oBAAvC;;;AAGA,SAASC,qBAAT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A7C,WACgBC,mBADhB,GACsC,gBADtC","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n 'aria-describedby': this.props['aria-describedby'],\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' }, false);\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState }, false);\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>, sync = true) => {\n const updateState = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n // Auto-batching React@18 creates problems that are fixed with flushSync\n // https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366\n if (sync && React.version.search('18') === 0) {\n ReactDOM.flushSync(() => updateState(action));\n } else {\n updateState(action);\n }\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/react-ui",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.7",
|
|
4
4
|
"description": "UI Components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"sideEffects": false,
|
|
8
|
-
"homepage": "https://tech.skbkontur.ru/react-ui/4.15.
|
|
8
|
+
"homepage": "https://tech.skbkontur.ru/react-ui/4.15.7/",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git@github.com:skbkontur/retail-ui.git"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build": "run-p build:esm build:cjs && node scripts/build/postbuild",
|
|
22
22
|
"clean": "git clean -fdxqe node_modules",
|
|
23
23
|
"prerelease": "node scripts/publish/prepublish && yarn build",
|
|
24
|
-
"release": "
|
|
24
|
+
"release": "npm publish ./build --workspaces=false",
|
|
25
25
|
"postrelease": "yarn deploy",
|
|
26
26
|
"predeploy": "rimraf .styleguide/deploy && yarn run styleguide:build",
|
|
27
27
|
"deploy": "gh-pages -a -d .styleguide/deploy -r git@github.com:skbkontur/react-ui.git",
|