@skbkontur/react-ui 4.20.2 → 4.21.0-displayname.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 +22 -0
- package/LICENSE +21 -21
- package/cjs/components/Button/Button.d.ts +1 -0
- package/cjs/components/Button/Button.js +2 -1
- package/cjs/components/Button/Button.js.map +1 -1
- package/cjs/components/FileUploader/FileUploader.js +2 -1
- package/cjs/components/FileUploader/FileUploader.js.map +1 -1
- package/cjs/components/Gapped/Gapped.md +43 -43
- package/cjs/components/GlobalLoader/GlobalLoader.d.ts +1 -0
- package/cjs/components/GlobalLoader/GlobalLoader.js +2 -1
- package/cjs/components/GlobalLoader/GlobalLoader.js.map +1 -1
- package/cjs/components/Input/Input.d.ts +23 -5
- package/cjs/components/Input/Input.js +35 -15
- package/cjs/components/Input/Input.js.map +1 -1
- package/cjs/components/Input/Input.typings.d.ts +7 -0
- package/cjs/components/Input/Input.typings.js +1 -0
- package/cjs/components/Input/Input.typings.js.map +1 -0
- package/cjs/components/Input/index.d.ts +1 -0
- package/cjs/components/Input/index.js +2 -1
- package/cjs/components/Input/index.js.map +1 -1
- package/cjs/components/MaskedInput/MaskedInput.d.ts +24 -0
- package/cjs/components/MaskedInput/MaskedInput.js +78 -0
- package/cjs/components/MaskedInput/MaskedInput.js.map +1 -0
- package/cjs/components/MaskedInput/MaskedInput.md +21 -0
- package/cjs/components/MaskedInput/index.js.map +1 -0
- package/cjs/components/MiniModal/MiniModal.js +0 -2
- package/cjs/components/MiniModal/MiniModal.js.map +1 -1
- package/cjs/components/RadioGroup/RadioGroup.md +43 -43
- package/cjs/components/ResponsiveLayout/ResponsiveLayout.d.ts +3 -0
- package/cjs/components/ResponsiveLayout/ResponsiveLayout.js +3 -1
- package/cjs/components/ResponsiveLayout/ResponsiveLayout.js.map +1 -1
- package/cjs/components/SingleToast/SingleToast.d.ts +2 -0
- package/cjs/components/SingleToast/SingleToast.js +3 -1
- package/cjs/components/SingleToast/SingleToast.js.map +1 -1
- package/cjs/components/Token/Token.js +1 -1
- package/cjs/components/Token/Token.js.map +1 -1
- package/cjs/internal/{MaskedInput/MaskedInput.d.ts → InternalMaskedInput/InternalMaskedInput.d.ts} +8 -5
- package/cjs/internal/{MaskedInput/MaskedInput.js → InternalMaskedInput/InternalMaskedInput.js} +11 -8
- package/cjs/internal/InternalMaskedInput/InternalMaskedInput.js.map +1 -0
- package/cjs/internal/InternalMaskedInput/InternalMaskedInput.styles.js.map +1 -0
- package/cjs/internal/InternalMaskedInput/index.d.ts +1 -0
- package/cjs/internal/InternalMaskedInput/index.js +1 -0
- package/cjs/internal/InternalMaskedInput/index.js.map +1 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.d.ts +14 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.helpers.d.ts +16 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.helpers.js +52 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.helpers.js.map +1 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.js +196 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.js.map +1 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.styles.js +29 -0
- package/cjs/internal/MaskedInputElement/MaskedInputElement.styles.js.map +1 -0
- package/cjs/internal/MaskedInputElement/index.d.ts +1 -0
- package/cjs/internal/MaskedInputElement/index.js +1 -0
- package/cjs/internal/MaskedInputElement/index.js.map +1 -0
- package/cjs/internal/ThemeShowcase/ThemeShowcase.md +13 -13
- package/cjs/lib/utils.d.ts +7 -0
- package/cjs/lib/utils.js +25 -2
- package/cjs/lib/utils.js.map +1 -1
- package/components/Button/Button/Button.js +1 -1
- package/components/Button/Button/Button.js.map +1 -1
- package/components/Button/Button.d.ts +1 -0
- package/components/FileUploader/FileUploader/FileUploader.js +2 -1
- package/components/FileUploader/FileUploader/FileUploader.js.map +1 -1
- package/components/Gapped/Gapped.md +43 -43
- package/components/GlobalLoader/GlobalLoader/GlobalLoader.js +1 -1
- package/components/GlobalLoader/GlobalLoader/GlobalLoader.js.map +1 -1
- package/components/GlobalLoader/GlobalLoader.d.ts +1 -0
- package/components/Input/Input/Input.js +15 -6
- package/components/Input/Input/Input.js.map +1 -1
- package/components/Input/Input.d.ts +23 -5
- package/components/Input/Input.typings/Input.typings.js +1 -0
- package/components/Input/Input.typings/Input.typings.js.map +1 -0
- package/components/Input/Input.typings/package.json +6 -0
- package/components/Input/Input.typings.d.ts +7 -0
- package/components/Input/index/index.js +2 -1
- package/components/Input/index/index.js.map +1 -1
- package/components/Input/index.d.ts +1 -0
- package/components/MaskedInput/MaskedInput/MaskedInput.js +62 -0
- package/components/MaskedInput/MaskedInput/MaskedInput.js.map +1 -0
- package/{internal → components}/MaskedInput/MaskedInput/package.json +1 -1
- package/components/MaskedInput/MaskedInput.d.ts +24 -0
- package/components/MaskedInput/MaskedInput.md +21 -0
- package/components/MaskedInput/index/index.js.map +1 -0
- package/{internal → components}/MaskedInput/index/package.json +1 -1
- package/{internal → components}/MaskedInput/package.json +1 -1
- package/components/MiniModal/MiniModal/MiniModal.js +0 -1
- package/components/MiniModal/MiniModal/MiniModal.js.map +1 -1
- package/components/RadioGroup/RadioGroup.md +43 -43
- package/components/ResponsiveLayout/ResponsiveLayout/ResponsiveLayout.js +2 -1
- package/components/ResponsiveLayout/ResponsiveLayout/ResponsiveLayout.js.map +1 -1
- package/components/ResponsiveLayout/ResponsiveLayout.d.ts +3 -0
- package/components/SingleToast/SingleToast/SingleToast.js +2 -0
- package/components/SingleToast/SingleToast/SingleToast.js.map +1 -1
- package/components/SingleToast/SingleToast.d.ts +2 -0
- package/components/Token/Token/Token.js +4 -3
- package/components/Token/Token/Token.js.map +1 -1
- package/internal/{MaskedInput/MaskedInput/MaskedInput.js → InternalMaskedInput/InternalMaskedInput/InternalMaskedInput.js} +13 -9
- package/internal/InternalMaskedInput/InternalMaskedInput/InternalMaskedInput.js.map +1 -0
- package/internal/InternalMaskedInput/InternalMaskedInput/package.json +6 -0
- package/internal/{MaskedInput/MaskedInput.d.ts → InternalMaskedInput/InternalMaskedInput.d.ts} +8 -5
- package/{cjs/internal/MaskedInput/MaskedInput.styles.js.map → internal/InternalMaskedInput/InternalMaskedInput.styles/InternalMaskedInput.styles.js.map} +1 -1
- package/internal/InternalMaskedInput/InternalMaskedInput.styles/package.json +6 -0
- package/internal/InternalMaskedInput/InternalMaskedInput.styles.d.ts +6 -0
- package/internal/InternalMaskedInput/index/index.js +1 -0
- package/internal/InternalMaskedInput/index/index.js.map +1 -0
- package/internal/InternalMaskedInput/index/package.json +6 -0
- package/internal/InternalMaskedInput/index.d.ts +1 -0
- package/internal/InternalMaskedInput/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement/MaskedInputElement.js +206 -0
- package/internal/MaskedInputElement/MaskedInputElement/MaskedInputElement.js.map +1 -0
- package/internal/MaskedInputElement/MaskedInputElement/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement.d.ts +14 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers/MaskedInputElement.helpers.js +43 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers/MaskedInputElement.helpers.js.map +1 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement.helpers.d.ts +16 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles/MaskedInputElement.styles.js +16 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles/MaskedInputElement.styles.js.map +1 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles/package.json +6 -0
- package/internal/MaskedInputElement/MaskedInputElement.styles.d.ts +6 -0
- package/internal/MaskedInputElement/index/index.js +1 -0
- package/internal/MaskedInputElement/index/index.js.map +1 -0
- package/internal/MaskedInputElement/index/package.json +6 -0
- package/internal/MaskedInputElement/index.d.ts +1 -0
- package/internal/MaskedInputElement/package.json +6 -0
- package/internal/ThemeShowcase/ThemeShowcase.md +13 -13
- package/lib/utils/utils.js +27 -1
- package/lib/utils/utils.js.map +1 -1
- package/lib/utils.d.ts +7 -0
- package/package.json +3 -5
- package/cjs/internal/MaskedInput/MaskedInput.js.map +0 -1
- package/cjs/internal/MaskedInput/index.js.map +0 -1
- package/internal/MaskedInput/MaskedInput/MaskedInput.js.map +0 -1
- package/internal/MaskedInput/MaskedInput.styles/MaskedInput.styles.js.map +0 -1
- package/internal/MaskedInput/MaskedInput.styles/package.json +0 -6
- package/internal/MaskedInput/index/index.js.map +0 -1
- /package/cjs/{internal → components}/MaskedInput/index.d.ts +0 -0
- /package/cjs/{internal → components}/MaskedInput/index.js +0 -0
- /package/cjs/internal/{MaskedInput/MaskedInput.styles.d.ts → InternalMaskedInput/InternalMaskedInput.styles.d.ts} +0 -0
- /package/cjs/internal/{MaskedInput/MaskedInput.styles.js → InternalMaskedInput/InternalMaskedInput.styles.js} +0 -0
- /package/{internal/MaskedInput/MaskedInput.styles.d.ts → cjs/internal/MaskedInputElement/MaskedInputElement.styles.d.ts} +0 -0
- /package/{internal → components}/MaskedInput/index/index.js +0 -0
- /package/{internal → components}/MaskedInput/index.d.ts +0 -0
- /package/internal/{MaskedInput/MaskedInput.styles/MaskedInput.styles.js → InternalMaskedInput/InternalMaskedInput.styles/InternalMaskedInput.styles.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.21.0](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.21.0-next.3...@skbkontur/react-ui@4.21.0) (2024-02-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **MuskedInput:** add MaskedInput component ([#3341](https://github.com/skbkontur/retail-ui/issues/3341)) ([4343d51](https://github.com/skbkontur/retail-ui/commit/223aa724d3497ae53d62ea8a86578c3564343d51))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [4.20.3](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.20.2...@skbkontur/react-ui@4.20.3) (2024-02-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **Token:** prevent focus on cross ([#3361](https://github.com/skbkontur/retail-ui/issues/3361)) ([757899c](https://github.com/skbkontur/retail-ui/commit/757899c17a1f5e040848ecd25a0eaf98ebe8e9e4))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [4.20.2](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@4.20.1...@skbkontur/react-ui@4.20.2) (2024-02-19)
|
|
7
29
|
|
|
8
30
|
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 SKB Kontur
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 SKB Kontur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -138,6 +138,7 @@ declare type DefaultProps = Required<Pick<ButtonProps, 'use' | 'size' | 'type'>>
|
|
|
138
138
|
export declare class Button extends React.Component<ButtonProps, ButtonState> {
|
|
139
139
|
static __KONTUR_REACT_UI__: string;
|
|
140
140
|
static __BUTTON__: boolean;
|
|
141
|
+
static displayName: string;
|
|
141
142
|
static defaultProps: DefaultProps;
|
|
142
143
|
private getProps;
|
|
143
144
|
state: {
|
|
@@ -208,6 +208,7 @@ Button = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functi
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
|
|
211
|
+
|
|
211
212
|
getProps = (0, _createPropsGetter.createPropsGetter)(Button.defaultProps);_this.
|
|
212
213
|
|
|
213
214
|
state = {
|
|
@@ -582,4 +583,4 @@ Button = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functi
|
|
|
582
583
|
// on this button if somewhere on the page user presses Enter while some
|
|
583
584
|
// input is focused. So we set type to 'button' by default.
|
|
584
585
|
type: type, role: role, 'aria-describedby': ariaDescribedby, 'aria-haspopup': ariaHasPopup, 'aria-controls': ariaControls, 'aria-label': ariaLabel, 'aria-checked': ariaChecked, 'aria-expanded': ariaExpanded, className: rootClassName, style: (0, _extends2.default)({ textAlign: align }, corners), disabled: disabled || loading, onClick: onClick, onFocus: this.handleFocus, onBlur: this.handleBlur, onKeyDown: onKeyDown, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseOver: onMouseOver, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onClickCapture: onClickCapture, tabIndex: disableFocus ? -1 : 0, title: this.props.title };var wrapProps = { className: (0, _Emotion.cx)(_Button.globalClasses.root, (_cx2 = {}, _cx2[_Button.styles.wrap(this.theme)] = true, _cx2[wrapClassNameWithArrow] = true, _cx2[this.getSizeWrapClassName()] = true, _cx2)), style: { width: width } };var innerShadowNode = _isTheme2022 ? null : /*#__PURE__*/_react.default.createElement("div", { className: _Button.globalClasses.innerShadow });var outlineNode = null;var isDisabled2022 = _isTheme2022 && (disabled || loading);if ((!isFocused || isLink) && !isDisabled2022) {var _cx3;outlineNode = /*#__PURE__*/_react.default.createElement("div", { style: { zIndex: _isTheme2022 && isLink ? -1 : undefined }, className: (0, _Emotion.cx)(_Button.styles.outline(), (_cx3 = {}, _cx3[_Button.styles.outlineWarning(this.theme)] = warning, _cx3[_Button.styles.outlineError(this.theme)] = error, _cx3[_Button.styles.outlineLink()] = isLink, _cx3[_Button.styles.outlineLinkWarning(this.theme)] = isLink && warning, _cx3[_Button.styles.outlineLinkError(this.theme)] = isLink && error, _cx3)) });}var iconNode = icon && /*#__PURE__*/_react.default.createElement(_ButtonIcon.ButtonIcon, { icon: icon, size: size, hasChildren: Boolean(children), disabled: disabled || false, loading: loading || false, use: use });var loadingNode = null;if (loading && !icon) {var loadingIcon = _isTheme2022 ? /*#__PURE__*/_react.default.createElement(_LoadingIcon.LoadingIcon, { size: size }) : /*#__PURE__*/_react.default.createElement(_Spinner.Spinner, { caption: null, dimmed: true, type: "mini" });loadingNode = /*#__PURE__*/_react.default.createElement("div", { "data-tid": ButtonDataTids.spinner, className: _Button.styles.loading() }, loadingIcon);} // Force disable all props and features, that cannot be use with Link
|
|
585
|
-
if (isLink) {var _cx4;rootProps.className = (0, _Emotion.cx)((_cx4 = {}, _cx4[_Button.styles.root(this.theme)] = true, _cx4[sizeClass] = true, _cx4[_Button.styles.link(this.theme)] = true, _cx4[_Button.styles.linkLineHeight()] = !_client.isSafari || _client.isSafari && !_isTheme2022, _cx4[_Button.styles.linkLineHeightSafariFallback()] = _client.isSafari && _isTheme2022, _cx4[_Button.styles.linkFocus(this.theme)] = isFocused, _cx4[_Button.styles.linkDisabled(this.theme)] = disabled || loading, _cx4));Object.assign(wrapProps, { className: (0, _Emotion.cx)(_Button.styles.wrap(this.theme), _Button.styles.wrapLink()), style: { width: wrapProps.style.width } });rootProps.style.textAlign = undefined;}var captionNode = /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_Button.styles.caption(), _Button.globalClasses.caption, (_cx5 = {}, _cx5[_Button.styles.captionTranslated()] = (active || checked) && !loading && !_isTheme2022, _cx5[_Button.styles.captionLink()] = isLink, _cx5[_Button.styles.captionDisabled()] = !checked && disabled, _cx5)) }, loadingNode, iconNode, /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)(_Button.globalClasses.text, (_cx6 = {}, _cx6[_Button.styles.visibilityHidden()] = !!loadingNode, _cx6)) }, children));if (_isTheme2022 && isLink && !loading) {captionNode = /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: (0, _getInnerLinkTheme.getInnerLinkTheme)(this.theme) }, /*#__PURE__*/_react.default.createElement(_Link.Link, { focused: isFocused, disabled: disabled, icon: this.renderIcon2022(icon), as: this.renderLinkRootWithoutHandlers, tabIndex: -1 }, children));}return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement("span", wrapProps, /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({ "data-tid": ButtonDataTids.root, ref: this._ref }, rootProps), innerShadowNode, outlineNode, arrowNode, captionNode)));};_proto.renderIcon2022 = function renderIcon2022(icon) {if (icon && (0, _utils.isKonturIcon)(icon)) {var _icon$props$size;var sizes = (0, _ButtonIcon.getButtonIconSizes)(this.theme);return /*#__PURE__*/_react.default.cloneElement(icon, { size: (_icon$props$size = icon.props.size) != null ? _icon$props$size : sizes[this.getProps().size] });}return icon;};_proto.getSizeClassName = function getSizeClassName() {var _cx7, _cx8, _cx9;var _isTheme2022 = (0, _ThemeHelpers.isTheme2022)(this.theme);switch (this.getProps().size) {case 'large':return (0, _Emotion.cx)(_Button.styles.sizeLarge(this.theme), (_cx7 = {}, _cx7[_Button.styles.sizeLargeIE11(this.theme)] = _client.isIE11 || _client.isEdge, _cx7[_Button.styles.sizeLargeWithIcon(this.theme)] = !!this.props.icon, _cx7[_Button.styles.sizeLargeWithIconWithoutText(this.theme)] = _isTheme2022 && !!this.props.icon && !this.props.children, _cx7));case 'medium':return (0, _Emotion.cx)(_Button.styles.sizeMedium(this.theme), (_cx8 = {}, _cx8[_Button.styles.sizeMediumIE11(this.theme)] = _client.isIE11 || _client.isEdge, _cx8[_Button.styles.sizeMediumWithIcon(this.theme)] = !!this.props.icon, _cx8[_Button.styles.sizeMediumWithIconWithoutText(this.theme)] = _isTheme2022 && !!this.props.icon && !this.props.children, _cx8));case 'small':default:return (0, _Emotion.cx)(_Button.styles.sizeSmall(this.theme), (_cx9 = {}, _cx9[_Button.styles.sizeSmallIE11(this.theme)] = _client.isIE11 || _client.isEdge, _cx9[_Button.styles.sizeSmallWithIcon(this.theme)] = !!this.props.icon, _cx9[_Button.styles.sizeSmallWithIconWithoutText(this.theme)] = _isTheme2022 && !!this.props.icon && !this.props.children, _cx9));}};_proto.getSizeWrapClassName = function getSizeWrapClassName() {switch (this.getProps().size) {case 'large':return _Button.styles.wrapLarge(this.theme);case 'medium':return _Button.styles.wrapMedium(this.theme);case 'small':default:return _Button.styles.wrapSmall(this.theme);}};return Button;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Button', _class2.__BUTTON__ = true, _class2.defaultProps = { use: 'default', size: 'small', type: 'button' }, _temp)) || _class;exports.Button = Button;var isButton = (0, _utils.isReactUIComponent)('Button');exports.isButton = isButton;
|
|
586
|
+
if (isLink) {var _cx4;rootProps.className = (0, _Emotion.cx)((_cx4 = {}, _cx4[_Button.styles.root(this.theme)] = true, _cx4[sizeClass] = true, _cx4[_Button.styles.link(this.theme)] = true, _cx4[_Button.styles.linkLineHeight()] = !_client.isSafari || _client.isSafari && !_isTheme2022, _cx4[_Button.styles.linkLineHeightSafariFallback()] = _client.isSafari && _isTheme2022, _cx4[_Button.styles.linkFocus(this.theme)] = isFocused, _cx4[_Button.styles.linkDisabled(this.theme)] = disabled || loading, _cx4));Object.assign(wrapProps, { className: (0, _Emotion.cx)(_Button.styles.wrap(this.theme), _Button.styles.wrapLink()), style: { width: wrapProps.style.width } });rootProps.style.textAlign = undefined;}var captionNode = /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_Button.styles.caption(), _Button.globalClasses.caption, (_cx5 = {}, _cx5[_Button.styles.captionTranslated()] = (active || checked) && !loading && !_isTheme2022, _cx5[_Button.styles.captionLink()] = isLink, _cx5[_Button.styles.captionDisabled()] = !checked && disabled, _cx5)) }, loadingNode, iconNode, /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)(_Button.globalClasses.text, (_cx6 = {}, _cx6[_Button.styles.visibilityHidden()] = !!loadingNode, _cx6)) }, children));if (_isTheme2022 && isLink && !loading) {captionNode = /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: (0, _getInnerLinkTheme.getInnerLinkTheme)(this.theme) }, /*#__PURE__*/_react.default.createElement(_Link.Link, { focused: isFocused, disabled: disabled, icon: this.renderIcon2022(icon), as: this.renderLinkRootWithoutHandlers, tabIndex: -1 }, children));}return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement("span", wrapProps, /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({ "data-tid": ButtonDataTids.root, ref: this._ref }, rootProps), innerShadowNode, outlineNode, arrowNode, captionNode)));};_proto.renderIcon2022 = function renderIcon2022(icon) {if (icon && (0, _utils.isKonturIcon)(icon)) {var _icon$props$size;var sizes = (0, _ButtonIcon.getButtonIconSizes)(this.theme);return /*#__PURE__*/_react.default.cloneElement(icon, { size: (_icon$props$size = icon.props.size) != null ? _icon$props$size : sizes[this.getProps().size] });}return icon;};_proto.getSizeClassName = function getSizeClassName() {var _cx7, _cx8, _cx9;var _isTheme2022 = (0, _ThemeHelpers.isTheme2022)(this.theme);switch (this.getProps().size) {case 'large':return (0, _Emotion.cx)(_Button.styles.sizeLarge(this.theme), (_cx7 = {}, _cx7[_Button.styles.sizeLargeIE11(this.theme)] = _client.isIE11 || _client.isEdge, _cx7[_Button.styles.sizeLargeWithIcon(this.theme)] = !!this.props.icon, _cx7[_Button.styles.sizeLargeWithIconWithoutText(this.theme)] = _isTheme2022 && !!this.props.icon && !this.props.children, _cx7));case 'medium':return (0, _Emotion.cx)(_Button.styles.sizeMedium(this.theme), (_cx8 = {}, _cx8[_Button.styles.sizeMediumIE11(this.theme)] = _client.isIE11 || _client.isEdge, _cx8[_Button.styles.sizeMediumWithIcon(this.theme)] = !!this.props.icon, _cx8[_Button.styles.sizeMediumWithIconWithoutText(this.theme)] = _isTheme2022 && !!this.props.icon && !this.props.children, _cx8));case 'small':default:return (0, _Emotion.cx)(_Button.styles.sizeSmall(this.theme), (_cx9 = {}, _cx9[_Button.styles.sizeSmallIE11(this.theme)] = _client.isIE11 || _client.isEdge, _cx9[_Button.styles.sizeSmallWithIcon(this.theme)] = !!this.props.icon, _cx9[_Button.styles.sizeSmallWithIconWithoutText(this.theme)] = _isTheme2022 && !!this.props.icon && !this.props.children, _cx9));}};_proto.getSizeWrapClassName = function getSizeWrapClassName() {switch (this.getProps().size) {case 'large':return _Button.styles.wrapLarge(this.theme);case 'medium':return _Button.styles.wrapMedium(this.theme);case 'small':default:return _Button.styles.wrapSmall(this.theme);}};return Button;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Button', _class2.__BUTTON__ = true, _class2.displayName = 'Button', _class2.defaultProps = { use: 'default', size: 'small', type: 'button' }, _temp)) || _class;exports.Button = Button;var isButton = (0, _utils.isReactUIComponent)('Button');exports.isButton = isButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Button.tsx"],"names":["ButtonDataTids","root","spinner","Button","rootNode","getProps","defaultProps","state","focusedByTab","node","handleFocus","e","props","disabled","disableFocus","globalObject","requestAnimationFrame","keyListener","isTabPressed","setState","onFocus","handleBlur","onBlur","_ref","componentDidMount","autoFocus","focus","getDerivedStateFromProps","loading","blur","render","theme","ThemeFactory","create","renderMain","renderLinkRootWithoutHandlers","onClick","children","rest","corners","active","borderless","checked","error","warning","narrow","icon","_noPadding","_noRightPadding","visuallyFocused","align","onMouseEnter","onMouseLeave","onMouseOver","onMouseDown","onMouseUp","onKeyDown","onClickCapture","width","ariaDescribedby","ariaHasPopup","ariaControls","ariaLabel","ariaChecked","ariaExpanded","role","use","type","size","sizeClass","getSizeClassName","isFocused","isLink","_isTheme2022","Boolean","wrapClassNameWithArrow","rootClassNameWithArrow","arrowNode","isUseStateWithoutOutlineInDisabledState","includes","rootClassName","trueDisabled","cx","styles","noPadding","noRightPadding","disabledWithoutOutline","checkedDisabled","checkedDisabled2022","borderless2022","activeStyles","checked2022","checkedFocused","simulatedPress","rootProps","className","style","textAlign","tabIndex","title","wrapProps","globalClasses","wrap","getSizeWrapClassName","innerShadowNode","innerShadow","outlineNode","isDisabled2022","zIndex","undefined","outline","outlineWarning","outlineError","outlineLink","outlineLinkWarning","outlineLinkError","iconNode","loadingNode","loadingIcon","link","linkLineHeight","isSafari","linkLineHeightSafariFallback","linkFocus","linkDisabled","Object","assign","wrapLink","captionNode","caption","captionTranslated","captionLink","captionDisabled","text","visibilityHidden","renderIcon2022","setRootNode","sizes","React","cloneElement","sizeLarge","sizeLargeIE11","isIE11","isEdge","sizeLargeWithIcon","sizeLargeWithIconWithoutText","sizeMedium","sizeMediumIE11","sizeMediumWithIcon","sizeMediumWithIconWithoutText","sizeSmall","sizeSmallIE11","sizeSmallWithIcon","sizeSmallWithIconWithoutText","wrapLarge","wrapMedium","wrapSmall","Component","__KONTUR_REACT_UI__","__BUTTON__","isButton"],"mappings":"4eAAA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,wD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyKO,IA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AOsE,4BAAP,CAAoC,KAAK1H,KAAzC,CAHI,IAG8C0C,YAAY,IAAI,CAAC,CAAC,KAAK7D,KAAL,CAAWkC,IAA7B,IAAqC,CAAC,KAAKlC,KAAL,CAAWyB,QAH/F,QAAP,CAfJ,CAqBD,C,QAEOkE,oB,GAAR,gCAA+B,CAC7B,QAAQ,KAAKlG,QAAL,GAAgB+D,IAAxB,GACE,KAAK,OAAL,CACE,OAAOe,eAAOuE,SAAP,CAAiB,KAAK3H,KAAtB,CAAP,CACF,KAAK,QAAL,CACE,OAAOoD,eAAOwE,UAAP,CAAkB,KAAK5H,KAAvB,CAAP,CACF,KAAK,OAAL,CACA,QACE,OAAOoD,eAAOyE,SAAP,CAAiB,KAAK7H,KAAtB,CAAP,CAPJ,CASD,C,iBA/VyB2G,eAAMmB,S,WAClBC,mB,GAAsB,Q,UACtBC,U,GAAa,I,UAEbzJ,Y,GAA6B,EACzC4D,GAAG,EAAE,SADoC,EAEzCE,IAAI,EAAE,OAFmC,EAGzCD,IAAI,EAAE,QAHmC,E,4CAsXtC,IAAM6F,QAAQ,GAAG,+BAAgC,QAAhC,CAAjB,C","sourcesContent":["import React, { AriaAttributes, HTMLAttributes } from 'react';\nimport { globalObject } from '@skbkontur/global-object';\n\nimport { HTMLProps } from '../../typings/html';\nimport { isKonturIcon, isReactUIComponent } from '../../lib/utils';\nimport { isIE11, isEdge, isSafari } from '../../lib/client';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { Theme, ThemeIn } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { CommonWrapper, CommonProps } from '../../internal/CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { Link, LinkProps } from '../Link';\nimport { Spinner } from '../Spinner';\nimport { LoadingIcon } from '../../internal/icons2022/LoadingIcon';\nimport { SizeProp } from '../../lib/types/props';\n\nimport { styles, activeStyles, globalClasses } from './Button.styles';\nimport { ButtonIcon, getButtonIconSizes } from './ButtonIcon';\nimport { useButtonArrow } from './ButtonArrow';\nimport { getInnerLinkTheme } from './getInnerLinkTheme';\n\n/**\n * @deprecated use SizeProp\n */\nexport type ButtonSize = SizeProp;\nexport type ButtonType = 'button' | 'submit' | 'reset';\nexport type ButtonUse = 'default' | 'primary' | 'success' | 'danger' | 'pay' | 'link' | 'text' | 'backless';\n\nexport interface ButtonProps\n extends CommonProps,\n Pick<\n AriaAttributes,\n 'aria-haspopup' | 'aria-describedby' | 'aria-controls' | 'aria-label' | 'aria-checked' | 'aria-expanded'\n >,\n Pick<HTMLAttributes<unknown>, 'role'>,\n Pick<HTMLProps['button'], 'onClickCapture' | 'onMouseUp' | 'onMouseDown'> {\n /** @ignore */\n _noPadding?: boolean;\n\n /** @ignore */\n _noRightPadding?: boolean;\n\n /**\n * Применяет к кнопке стили псевдокласса `:active`.\n */\n active?: boolean;\n\n /**\n * CSS-свойство `text-align`.\n */\n align?: React.CSSProperties['textAlign'];\n\n /**\n * Превращает обычную кнопку в кнопку со стрелкой.\n */\n arrow?: boolean | 'left';\n\n /**\n * Даёт кнопке фокус после окончания загрузки страницы.\n */\n autoFocus?: boolean;\n\n /**\n * Убирает обводку у кнопки.\n */\n borderless?: boolean;\n\n /**\n * @ignore\n */\n checked?: boolean;\n\n children?: React.ReactNode;\n\n /** @ignore */\n corners?: React.CSSProperties;\n\n /**\n * Отключенное состояние кнопки.\n */\n disabled?: boolean;\n\n /** @ignore */\n disableFocus?: boolean;\n\n /**\n * Состояние валидации при ошибке.\n */\n error?: boolean;\n\n /**\n * Иконка слева от текста кнопки.\n */\n icon?: React.ReactElement<any>;\n\n /**\n * Переводит кнопку в состояние загрузки.\n */\n loading?: boolean;\n\n /**\n * Сужает кнопку.\n */\n narrow?: boolean;\n\n /**\n * HTML-событие `onblur`.\n */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onclick`.\n */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onfocus`.\n */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `keydown`.\n */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onmouseenter`.\n */\n onMouseEnter?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `mouseleave`.\n */\n onMouseLeave?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onmouseover`.\n */\n onMouseOver?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * Задаёт размер кнопки.\n *\n * **Допустимые значения**: `\"small\"`, `\"medium\"`, `\"large\"`.\n */\n size?: SizeProp;\n\n /**\n * HTML-атрибут `type`.\n */\n type?: ButtonType;\n\n /**\n * HTML-атрибут `title`.\n */\n title?: string;\n\n /**\n * Стиль кнопки.\n *\n * **Допустимые значения**: `\"default\"`, `\"primary\"`, `\"success\"`, `\"danger\"`, `\"pay\"`, `\"link\"`, `\"text\"`, `\"backless\"`.\n */\n use?: ButtonUse;\n\n /** @ignore */\n visuallyFocused?: boolean;\n\n /**\n * Состояние валидации при предупреждении.\n */\n warning?: boolean;\n\n /**\n * CSS-свойство `width`.\n */\n width?: number | string;\n\n /**\n * Обычный объект с переменными темы.\n * Он будет объединён с темой из контекста.\n */\n theme?: ThemeIn;\n}\n\nexport interface ButtonState {\n focusedByTab: boolean;\n}\n\nexport const ButtonDataTids = {\n root: 'Button__root',\n spinner: 'Button__spinner',\n} as const;\n\ntype DefaultProps = Required<Pick<ButtonProps, 'use' | 'size' | 'type'>>;\n\n@rootNode\nexport class Button extends React.Component<ButtonProps, ButtonState> {\n public static __KONTUR_REACT_UI__ = 'Button';\n public static __BUTTON__ = true;\n\n public static defaultProps: DefaultProps = {\n use: 'default',\n size: 'small',\n type: 'button',\n };\n\n private getProps = createPropsGetter(Button.defaultProps);\n\n public state = {\n focusedByTab: false,\n };\n\n private theme!: Theme;\n private node: HTMLButtonElement | null = null;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.autoFocus) {\n keyListener.isTabPressed = true;\n this.focus();\n }\n }\n\n public static getDerivedStateFromProps(props: ButtonProps) {\n if (props.loading || props.disabled) {\n return { focusedByTab: false };\n }\n return null;\n }\n\n /**\n * @public\n */\n public focus() {\n this.node?.focus();\n }\n\n /**\n * @public\n */\n public blur() {\n this.node?.blur();\n }\n\n public render(): JSX.Element {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = this.props.theme ? ThemeFactory.create(this.props.theme as Theme, theme) : theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderLinkRootWithoutHandlers(props: LinkProps) {\n const { onClick, onFocus, onBlur, children, ...rest } = props;\n return <span {...rest}>{children}</span>;\n }\n\n private renderMain() {\n const {\n corners,\n active,\n disabled,\n borderless,\n checked,\n error,\n warning,\n loading,\n narrow,\n icon,\n _noPadding,\n _noRightPadding,\n visuallyFocused,\n align,\n disableFocus,\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n onMouseDown,\n onMouseUp,\n onKeyDown,\n onClick,\n onClickCapture,\n width,\n children,\n 'aria-describedby': ariaDescribedby,\n 'aria-haspopup': ariaHasPopup,\n 'aria-controls': ariaControls,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n 'aria-expanded': ariaExpanded,\n role,\n } = this.props;\n const { use, type, size } = this.getProps();\n const sizeClass = this.getSizeClassName();\n\n const isFocused = this.state.focusedByTab || visuallyFocused;\n const isLink = use === 'link';\n const _isTheme2022 = isTheme2022(this.theme);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [wrapClassNameWithArrow, rootClassNameWithArrow, arrowNode] = useButtonArrow(\n { ...this.props, isFocused: Boolean(isFocused) },\n this.theme,\n );\n const isUseStateWithoutOutlineInDisabledState = !['default', 'backless'].includes(use);\n let rootClassName = '';\n if (_isTheme2022) {\n const trueDisabled = disabled || loading;\n rootClassName = cx(\n styles.root(this.theme),\n styles[use](this.theme),\n sizeClass,\n narrow && styles.narrow(),\n _noPadding && styles.noPadding(),\n _noRightPadding && styles.noRightPadding(),\n rootClassNameWithArrow,\n ...(trueDisabled\n ? [\n styles.disabled(this.theme),\n isUseStateWithoutOutlineInDisabledState && styles.disabledWithoutOutline(this.theme),\n checked && styles.checkedDisabled(this.theme),\n checked && styles.checkedDisabled2022(this.theme),\n borderless && styles.borderless2022(),\n ]\n : [\n active && !checked && activeStyles[use](this.theme),\n isFocused && styles.focus(this.theme),\n checked && styles.checked2022(this.theme),\n checked && isFocused && styles.checkedFocused(this.theme),\n borderless && !checked && !isFocused && styles.borderless2022(),\n ]),\n );\n } else {\n rootClassName = cx({\n [styles.root(this.theme)]: true,\n [styles.simulatedPress()]: true,\n [styles[use](this.theme)]: true,\n [activeStyles[use](this.theme)]: active,\n [sizeClass]: true,\n [styles.focus(this.theme)]: isFocused,\n [styles.checked(this.theme)]: checked,\n [styles.checkedFocused(this.theme)]: checked && isFocused,\n [styles.disabled(this.theme)]: disabled || loading,\n [styles.checkedDisabled(this.theme)]: checked && disabled,\n [styles.borderless()]: borderless && !disabled && !loading && !checked && !isFocused && !active,\n [styles.narrow()]: narrow,\n [styles.noPadding()]: _noPadding,\n [styles.noRightPadding()]: _noRightPadding,\n });\n }\n\n const rootProps = {\n // By default the type attribute is 'submit'. IE8 will fire a click event\n // on this button if somewhere on the page user presses Enter while some\n // input is focused. So we set type to 'button' by default.\n type,\n role,\n 'aria-describedby': ariaDescribedby,\n 'aria-haspopup': ariaHasPopup,\n 'aria-controls': ariaControls,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n 'aria-expanded': ariaExpanded,\n className: rootClassName,\n style: {\n textAlign: align,\n ...corners,\n },\n disabled: disabled || loading,\n onClick,\n onFocus: this.handleFocus,\n onBlur: this.handleBlur,\n onKeyDown,\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n onMouseDown,\n onMouseUp,\n onClickCapture,\n tabIndex: disableFocus ? -1 : 0,\n title: this.props.title,\n };\n\n const wrapProps = {\n className: cx(globalClasses.root, {\n [styles.wrap(this.theme)]: true,\n [wrapClassNameWithArrow]: true,\n [this.getSizeWrapClassName()]: true,\n }),\n style: {\n width,\n },\n };\n\n const innerShadowNode = _isTheme2022 ? null : <div className={globalClasses.innerShadow} />;\n\n let outlineNode = null;\n const isDisabled2022 = _isTheme2022 && (disabled || loading);\n if ((!isFocused || isLink) && !isDisabled2022) {\n outlineNode = (\n <div\n style={{ zIndex: _isTheme2022 && isLink ? -1 : undefined }}\n className={cx(styles.outline(), {\n [styles.outlineWarning(this.theme)]: warning,\n [styles.outlineError(this.theme)]: error,\n [styles.outlineLink()]: isLink,\n [styles.outlineLinkWarning(this.theme)]: isLink && warning,\n [styles.outlineLinkError(this.theme)]: isLink && error,\n })}\n />\n );\n }\n\n const iconNode = icon && (\n <ButtonIcon\n icon={icon}\n size={size}\n hasChildren={Boolean(children)}\n disabled={disabled || false}\n loading={loading || false}\n use={use}\n />\n );\n let loadingNode = null;\n if (loading && !icon) {\n const loadingIcon = _isTheme2022 ? <LoadingIcon size={size} /> : <Spinner caption={null} dimmed type=\"mini\" />;\n loadingNode = (\n <div data-tid={ButtonDataTids.spinner} className={styles.loading()}>\n {loadingIcon}\n </div>\n );\n }\n\n // Force disable all props and features, that cannot be use with Link\n if (isLink) {\n rootProps.className = cx({\n [styles.root(this.theme)]: true,\n [sizeClass]: true,\n [styles.link(this.theme)]: true,\n [styles.linkLineHeight()]: !isSafari || (isSafari && !_isTheme2022),\n [styles.linkLineHeightSafariFallback()]: isSafari && _isTheme2022,\n [styles.linkFocus(this.theme)]: isFocused,\n [styles.linkDisabled(this.theme)]: disabled || loading,\n });\n Object.assign(wrapProps, {\n className: cx(styles.wrap(this.theme), styles.wrapLink()),\n style: { width: wrapProps.style.width },\n });\n rootProps.style.textAlign = undefined;\n }\n\n let captionNode = (\n <div\n className={cx(styles.caption(), globalClasses.caption, {\n [styles.captionTranslated()]: (active || checked) && !loading && !_isTheme2022,\n [styles.captionLink()]: isLink,\n [styles.captionDisabled()]: !checked && disabled,\n })}\n >\n {loadingNode}\n {iconNode}\n <span\n className={cx(globalClasses.text, {\n [styles.visibilityHidden()]: !!loadingNode,\n })}\n >\n {children}\n </span>\n </div>\n );\n if (_isTheme2022 && isLink && !loading) {\n captionNode = (\n <ThemeContext.Provider value={getInnerLinkTheme(this.theme)}>\n <Link\n focused={isFocused}\n disabled={disabled}\n icon={this.renderIcon2022(icon)}\n as={this.renderLinkRootWithoutHandlers}\n tabIndex={-1}\n >\n {children}\n </Link>\n </ThemeContext.Provider>\n );\n }\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <span {...wrapProps}>\n <button data-tid={ButtonDataTids.root} ref={this._ref} {...rootProps}>\n {innerShadowNode}\n {outlineNode}\n {arrowNode}\n {captionNode}\n </button>\n </span>\n </CommonWrapper>\n );\n }\n\n private renderIcon2022(icon: React.ReactElement | undefined) {\n if (icon && isKonturIcon(icon)) {\n const sizes = getButtonIconSizes(this.theme);\n return React.cloneElement(icon, { size: icon.props.size ?? sizes[this.getProps().size] });\n }\n\n return icon;\n }\n\n private getSizeClassName() {\n const _isTheme2022 = isTheme2022(this.theme);\n switch (this.getProps().size) {\n case 'large':\n return cx(styles.sizeLarge(this.theme), {\n [styles.sizeLargeIE11(this.theme)]: isIE11 || isEdge,\n [styles.sizeLargeWithIcon(this.theme)]: !!this.props.icon,\n [styles.sizeLargeWithIconWithoutText(this.theme)]: _isTheme2022 && !!this.props.icon && !this.props.children,\n });\n case 'medium':\n return cx(styles.sizeMedium(this.theme), {\n [styles.sizeMediumIE11(this.theme)]: isIE11 || isEdge,\n [styles.sizeMediumWithIcon(this.theme)]: !!this.props.icon,\n [styles.sizeMediumWithIconWithoutText(this.theme)]: _isTheme2022 && !!this.props.icon && !this.props.children,\n });\n case 'small':\n default:\n return cx(styles.sizeSmall(this.theme), {\n [styles.sizeSmallIE11(this.theme)]: isIE11 || isEdge,\n [styles.sizeSmallWithIcon(this.theme)]: !!this.props.icon,\n [styles.sizeSmallWithIconWithoutText(this.theme)]: _isTheme2022 && !!this.props.icon && !this.props.children,\n });\n }\n }\n\n private getSizeWrapClassName() {\n switch (this.getProps().size) {\n case 'large':\n return styles.wrapLarge(this.theme);\n case 'medium':\n return styles.wrapMedium(this.theme);\n case 'small':\n default:\n return styles.wrapSmall(this.theme);\n }\n }\n\n private handleFocus = (e: React.FocusEvent<HTMLButtonElement>) => {\n if (!this.props.disabled && !this.props.disableFocus) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed) {\n this.setState({ focusedByTab: true });\n }\n });\n this.props.onFocus?.(e);\n }\n };\n\n private handleBlur = (e: React.FocusEvent<HTMLButtonElement>) => {\n this.setState({ focusedByTab: false });\n if (!this.props.disabled && !this.props.disableFocus) {\n this.props.onBlur?.(e);\n }\n };\n\n private _ref = (node: HTMLButtonElement | null) => {\n this.node = node;\n };\n}\n\nexport const isButton = isReactUIComponent<ButtonProps>('Button');\n"]}
|
|
1
|
+
{"version":3,"sources":["Button.tsx"],"names":["ButtonDataTids","root","spinner","Button","rootNode","getProps","defaultProps","state","focusedByTab","node","handleFocus","e","props","disabled","disableFocus","globalObject","requestAnimationFrame","keyListener","isTabPressed","setState","onFocus","handleBlur","onBlur","_ref","componentDidMount","autoFocus","focus","getDerivedStateFromProps","loading","blur","render","theme","ThemeFactory","create","renderMain","renderLinkRootWithoutHandlers","onClick","children","rest","corners","active","borderless","checked","error","warning","narrow","icon","_noPadding","_noRightPadding","visuallyFocused","align","onMouseEnter","onMouseLeave","onMouseOver","onMouseDown","onMouseUp","onKeyDown","onClickCapture","width","ariaDescribedby","ariaHasPopup","ariaControls","ariaLabel","ariaChecked","ariaExpanded","role","use","type","size","sizeClass","getSizeClassName","isFocused","isLink","_isTheme2022","Boolean","wrapClassNameWithArrow","rootClassNameWithArrow","arrowNode","isUseStateWithoutOutlineInDisabledState","includes","rootClassName","trueDisabled","cx","styles","noPadding","noRightPadding","disabledWithoutOutline","checkedDisabled","checkedDisabled2022","borderless2022","activeStyles","checked2022","checkedFocused","simulatedPress","rootProps","className","style","textAlign","tabIndex","title","wrapProps","globalClasses","wrap","getSizeWrapClassName","innerShadowNode","innerShadow","outlineNode","isDisabled2022","zIndex","undefined","outline","outlineWarning","outlineError","outlineLink","outlineLinkWarning","outlineLinkError","iconNode","loadingNode","loadingIcon","link","linkLineHeight","isSafari","linkLineHeightSafariFallback","linkFocus","linkDisabled","Object","assign","wrapLink","captionNode","caption","captionTranslated","captionLink","captionDisabled","text","visibilityHidden","renderIcon2022","setRootNode","sizes","React","cloneElement","sizeLarge","sizeLargeIE11","isIE11","isEdge","sizeLargeWithIcon","sizeLargeWithIconWithoutText","sizeMedium","sizeMediumIE11","sizeMediumWithIcon","sizeMediumWithIconWithoutText","sizeSmall","sizeSmallIE11","sizeSmallWithIcon","sizeSmallWithIconWithoutText","wrapLarge","wrapMedium","wrapSmall","Component","__KONTUR_REACT_UI__","__BUTTON__","displayName","isButton"],"mappings":"4eAAA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,wD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyKO,IAAMA,cAAc,GAAG;AAC5BC,EAAAA,IAAI,EAAE,cADsB;AAE5BC,EAAAA,OAAO,EAAE,iBAFmB,EAAvB,C;;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C,IAA7B,IAAqC,CAAC,KAAKlC,KAAL,CAAWyB,QAH/F,QAAP,CAfJ,CAqBD,C,QAEOkE,oB,GAAR,gCAA+B,CAC7B,QAAQ,KAAKlG,QAAL,GAAgB+D,IAAxB,GACE,KAAK,OAAL,CACE,OAAOe,eAAOuE,SAAP,CAAiB,KAAK3H,KAAtB,CAAP,CACF,KAAK,QAAL,CACE,OAAOoD,eAAOwE,UAAP,CAAkB,KAAK5H,KAAvB,CAAP,CACF,KAAK,OAAL,CACA,QACE,OAAOoD,eAAOyE,SAAP,CAAiB,KAAK7H,KAAtB,CAAP,CAPJ,CASD,C,iBAhWyB2G,eAAMmB,S,WAClBC,mB,GAAsB,Q,UACtBC,U,GAAa,I,UACbC,W,GAAc,Q,UAEd1J,Y,GAA6B,EACzC4D,GAAG,EAAE,SADoC,EAEzCE,IAAI,EAAE,OAFmC,EAGzCD,IAAI,EAAE,QAHmC,E,4CAsXtC,IAAM8F,QAAQ,GAAG,+BAAgC,QAAhC,CAAjB,C","sourcesContent":["import React, { AriaAttributes, HTMLAttributes } from 'react';\nimport { globalObject } from '@skbkontur/global-object';\n\nimport { HTMLProps } from '../../typings/html';\nimport { isKonturIcon, isReactUIComponent } from '../../lib/utils';\nimport { isIE11, isEdge, isSafari } from '../../lib/client';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { Theme, ThemeIn } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { CommonWrapper, CommonProps } from '../../internal/CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { Link, LinkProps } from '../Link';\nimport { Spinner } from '../Spinner';\nimport { LoadingIcon } from '../../internal/icons2022/LoadingIcon';\nimport { SizeProp } from '../../lib/types/props';\n\nimport { styles, activeStyles, globalClasses } from './Button.styles';\nimport { ButtonIcon, getButtonIconSizes } from './ButtonIcon';\nimport { useButtonArrow } from './ButtonArrow';\nimport { getInnerLinkTheme } from './getInnerLinkTheme';\n\n/**\n * @deprecated use SizeProp\n */\nexport type ButtonSize = SizeProp;\nexport type ButtonType = 'button' | 'submit' | 'reset';\nexport type ButtonUse = 'default' | 'primary' | 'success' | 'danger' | 'pay' | 'link' | 'text' | 'backless';\n\nexport interface ButtonProps\n extends CommonProps,\n Pick<\n AriaAttributes,\n 'aria-haspopup' | 'aria-describedby' | 'aria-controls' | 'aria-label' | 'aria-checked' | 'aria-expanded'\n >,\n Pick<HTMLAttributes<unknown>, 'role'>,\n Pick<HTMLProps['button'], 'onClickCapture' | 'onMouseUp' | 'onMouseDown'> {\n /** @ignore */\n _noPadding?: boolean;\n\n /** @ignore */\n _noRightPadding?: boolean;\n\n /**\n * Применяет к кнопке стили псевдокласса `:active`.\n */\n active?: boolean;\n\n /**\n * CSS-свойство `text-align`.\n */\n align?: React.CSSProperties['textAlign'];\n\n /**\n * Превращает обычную кнопку в кнопку со стрелкой.\n */\n arrow?: boolean | 'left';\n\n /**\n * Даёт кнопке фокус после окончания загрузки страницы.\n */\n autoFocus?: boolean;\n\n /**\n * Убирает обводку у кнопки.\n */\n borderless?: boolean;\n\n /**\n * @ignore\n */\n checked?: boolean;\n\n children?: React.ReactNode;\n\n /** @ignore */\n corners?: React.CSSProperties;\n\n /**\n * Отключенное состояние кнопки.\n */\n disabled?: boolean;\n\n /** @ignore */\n disableFocus?: boolean;\n\n /**\n * Состояние валидации при ошибке.\n */\n error?: boolean;\n\n /**\n * Иконка слева от текста кнопки.\n */\n icon?: React.ReactElement<any>;\n\n /**\n * Переводит кнопку в состояние загрузки.\n */\n loading?: boolean;\n\n /**\n * Сужает кнопку.\n */\n narrow?: boolean;\n\n /**\n * HTML-событие `onblur`.\n */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onclick`.\n */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onfocus`.\n */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `keydown`.\n */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onmouseenter`.\n */\n onMouseEnter?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `mouseleave`.\n */\n onMouseLeave?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * HTML-событие `onmouseover`.\n */\n onMouseOver?: React.MouseEventHandler<HTMLButtonElement>;\n\n /**\n * Задаёт размер кнопки.\n *\n * **Допустимые значения**: `\"small\"`, `\"medium\"`, `\"large\"`.\n */\n size?: SizeProp;\n\n /**\n * HTML-атрибут `type`.\n */\n type?: ButtonType;\n\n /**\n * HTML-атрибут `title`.\n */\n title?: string;\n\n /**\n * Стиль кнопки.\n *\n * **Допустимые значения**: `\"default\"`, `\"primary\"`, `\"success\"`, `\"danger\"`, `\"pay\"`, `\"link\"`, `\"text\"`, `\"backless\"`.\n */\n use?: ButtonUse;\n\n /** @ignore */\n visuallyFocused?: boolean;\n\n /**\n * Состояние валидации при предупреждении.\n */\n warning?: boolean;\n\n /**\n * CSS-свойство `width`.\n */\n width?: number | string;\n\n /**\n * Обычный объект с переменными темы.\n * Он будет объединён с темой из контекста.\n */\n theme?: ThemeIn;\n}\n\nexport interface ButtonState {\n focusedByTab: boolean;\n}\n\nexport const ButtonDataTids = {\n root: 'Button__root',\n spinner: 'Button__spinner',\n} as const;\n\ntype DefaultProps = Required<Pick<ButtonProps, 'use' | 'size' | 'type'>>;\n\n@rootNode\nexport class Button extends React.Component<ButtonProps, ButtonState> {\n public static __KONTUR_REACT_UI__ = 'Button';\n public static __BUTTON__ = true;\n public static displayName = 'Button';\n\n public static defaultProps: DefaultProps = {\n use: 'default',\n size: 'small',\n type: 'button',\n };\n\n private getProps = createPropsGetter(Button.defaultProps);\n\n public state = {\n focusedByTab: false,\n };\n\n private theme!: Theme;\n private node: HTMLButtonElement | null = null;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.autoFocus) {\n keyListener.isTabPressed = true;\n this.focus();\n }\n }\n\n public static getDerivedStateFromProps(props: ButtonProps) {\n if (props.loading || props.disabled) {\n return { focusedByTab: false };\n }\n return null;\n }\n\n /**\n * @public\n */\n public focus() {\n this.node?.focus();\n }\n\n /**\n * @public\n */\n public blur() {\n this.node?.blur();\n }\n\n public render(): JSX.Element {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = this.props.theme ? ThemeFactory.create(this.props.theme as Theme, theme) : theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderLinkRootWithoutHandlers(props: LinkProps) {\n const { onClick, onFocus, onBlur, children, ...rest } = props;\n return <span {...rest}>{children}</span>;\n }\n\n private renderMain() {\n const {\n corners,\n active,\n disabled,\n borderless,\n checked,\n error,\n warning,\n loading,\n narrow,\n icon,\n _noPadding,\n _noRightPadding,\n visuallyFocused,\n align,\n disableFocus,\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n onMouseDown,\n onMouseUp,\n onKeyDown,\n onClick,\n onClickCapture,\n width,\n children,\n 'aria-describedby': ariaDescribedby,\n 'aria-haspopup': ariaHasPopup,\n 'aria-controls': ariaControls,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n 'aria-expanded': ariaExpanded,\n role,\n } = this.props;\n const { use, type, size } = this.getProps();\n const sizeClass = this.getSizeClassName();\n\n const isFocused = this.state.focusedByTab || visuallyFocused;\n const isLink = use === 'link';\n const _isTheme2022 = isTheme2022(this.theme);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [wrapClassNameWithArrow, rootClassNameWithArrow, arrowNode] = useButtonArrow(\n { ...this.props, isFocused: Boolean(isFocused) },\n this.theme,\n );\n const isUseStateWithoutOutlineInDisabledState = !['default', 'backless'].includes(use);\n let rootClassName = '';\n if (_isTheme2022) {\n const trueDisabled = disabled || loading;\n rootClassName = cx(\n styles.root(this.theme),\n styles[use](this.theme),\n sizeClass,\n narrow && styles.narrow(),\n _noPadding && styles.noPadding(),\n _noRightPadding && styles.noRightPadding(),\n rootClassNameWithArrow,\n ...(trueDisabled\n ? [\n styles.disabled(this.theme),\n isUseStateWithoutOutlineInDisabledState && styles.disabledWithoutOutline(this.theme),\n checked && styles.checkedDisabled(this.theme),\n checked && styles.checkedDisabled2022(this.theme),\n borderless && styles.borderless2022(),\n ]\n : [\n active && !checked && activeStyles[use](this.theme),\n isFocused && styles.focus(this.theme),\n checked && styles.checked2022(this.theme),\n checked && isFocused && styles.checkedFocused(this.theme),\n borderless && !checked && !isFocused && styles.borderless2022(),\n ]),\n );\n } else {\n rootClassName = cx({\n [styles.root(this.theme)]: true,\n [styles.simulatedPress()]: true,\n [styles[use](this.theme)]: true,\n [activeStyles[use](this.theme)]: active,\n [sizeClass]: true,\n [styles.focus(this.theme)]: isFocused,\n [styles.checked(this.theme)]: checked,\n [styles.checkedFocused(this.theme)]: checked && isFocused,\n [styles.disabled(this.theme)]: disabled || loading,\n [styles.checkedDisabled(this.theme)]: checked && disabled,\n [styles.borderless()]: borderless && !disabled && !loading && !checked && !isFocused && !active,\n [styles.narrow()]: narrow,\n [styles.noPadding()]: _noPadding,\n [styles.noRightPadding()]: _noRightPadding,\n });\n }\n\n const rootProps = {\n // By default the type attribute is 'submit'. IE8 will fire a click event\n // on this button if somewhere on the page user presses Enter while some\n // input is focused. So we set type to 'button' by default.\n type,\n role,\n 'aria-describedby': ariaDescribedby,\n 'aria-haspopup': ariaHasPopup,\n 'aria-controls': ariaControls,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n 'aria-expanded': ariaExpanded,\n className: rootClassName,\n style: {\n textAlign: align,\n ...corners,\n },\n disabled: disabled || loading,\n onClick,\n onFocus: this.handleFocus,\n onBlur: this.handleBlur,\n onKeyDown,\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n onMouseDown,\n onMouseUp,\n onClickCapture,\n tabIndex: disableFocus ? -1 : 0,\n title: this.props.title,\n };\n\n const wrapProps = {\n className: cx(globalClasses.root, {\n [styles.wrap(this.theme)]: true,\n [wrapClassNameWithArrow]: true,\n [this.getSizeWrapClassName()]: true,\n }),\n style: {\n width,\n },\n };\n\n const innerShadowNode = _isTheme2022 ? null : <div className={globalClasses.innerShadow} />;\n\n let outlineNode = null;\n const isDisabled2022 = _isTheme2022 && (disabled || loading);\n if ((!isFocused || isLink) && !isDisabled2022) {\n outlineNode = (\n <div\n style={{ zIndex: _isTheme2022 && isLink ? -1 : undefined }}\n className={cx(styles.outline(), {\n [styles.outlineWarning(this.theme)]: warning,\n [styles.outlineError(this.theme)]: error,\n [styles.outlineLink()]: isLink,\n [styles.outlineLinkWarning(this.theme)]: isLink && warning,\n [styles.outlineLinkError(this.theme)]: isLink && error,\n })}\n />\n );\n }\n\n const iconNode = icon && (\n <ButtonIcon\n icon={icon}\n size={size}\n hasChildren={Boolean(children)}\n disabled={disabled || false}\n loading={loading || false}\n use={use}\n />\n );\n let loadingNode = null;\n if (loading && !icon) {\n const loadingIcon = _isTheme2022 ? <LoadingIcon size={size} /> : <Spinner caption={null} dimmed type=\"mini\" />;\n loadingNode = (\n <div data-tid={ButtonDataTids.spinner} className={styles.loading()}>\n {loadingIcon}\n </div>\n );\n }\n\n // Force disable all props and features, that cannot be use with Link\n if (isLink) {\n rootProps.className = cx({\n [styles.root(this.theme)]: true,\n [sizeClass]: true,\n [styles.link(this.theme)]: true,\n [styles.linkLineHeight()]: !isSafari || (isSafari && !_isTheme2022),\n [styles.linkLineHeightSafariFallback()]: isSafari && _isTheme2022,\n [styles.linkFocus(this.theme)]: isFocused,\n [styles.linkDisabled(this.theme)]: disabled || loading,\n });\n Object.assign(wrapProps, {\n className: cx(styles.wrap(this.theme), styles.wrapLink()),\n style: { width: wrapProps.style.width },\n });\n rootProps.style.textAlign = undefined;\n }\n\n let captionNode = (\n <div\n className={cx(styles.caption(), globalClasses.caption, {\n [styles.captionTranslated()]: (active || checked) && !loading && !_isTheme2022,\n [styles.captionLink()]: isLink,\n [styles.captionDisabled()]: !checked && disabled,\n })}\n >\n {loadingNode}\n {iconNode}\n <span\n className={cx(globalClasses.text, {\n [styles.visibilityHidden()]: !!loadingNode,\n })}\n >\n {children}\n </span>\n </div>\n );\n if (_isTheme2022 && isLink && !loading) {\n captionNode = (\n <ThemeContext.Provider value={getInnerLinkTheme(this.theme)}>\n <Link\n focused={isFocused}\n disabled={disabled}\n icon={this.renderIcon2022(icon)}\n as={this.renderLinkRootWithoutHandlers}\n tabIndex={-1}\n >\n {children}\n </Link>\n </ThemeContext.Provider>\n );\n }\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <span {...wrapProps}>\n <button data-tid={ButtonDataTids.root} ref={this._ref} {...rootProps}>\n {innerShadowNode}\n {outlineNode}\n {arrowNode}\n {captionNode}\n </button>\n </span>\n </CommonWrapper>\n );\n }\n\n private renderIcon2022(icon: React.ReactElement | undefined) {\n if (icon && isKonturIcon(icon)) {\n const sizes = getButtonIconSizes(this.theme);\n return React.cloneElement(icon, { size: icon.props.size ?? sizes[this.getProps().size] });\n }\n\n return icon;\n }\n\n private getSizeClassName() {\n const _isTheme2022 = isTheme2022(this.theme);\n switch (this.getProps().size) {\n case 'large':\n return cx(styles.sizeLarge(this.theme), {\n [styles.sizeLargeIE11(this.theme)]: isIE11 || isEdge,\n [styles.sizeLargeWithIcon(this.theme)]: !!this.props.icon,\n [styles.sizeLargeWithIconWithoutText(this.theme)]: _isTheme2022 && !!this.props.icon && !this.props.children,\n });\n case 'medium':\n return cx(styles.sizeMedium(this.theme), {\n [styles.sizeMediumIE11(this.theme)]: isIE11 || isEdge,\n [styles.sizeMediumWithIcon(this.theme)]: !!this.props.icon,\n [styles.sizeMediumWithIconWithoutText(this.theme)]: _isTheme2022 && !!this.props.icon && !this.props.children,\n });\n case 'small':\n default:\n return cx(styles.sizeSmall(this.theme), {\n [styles.sizeSmallIE11(this.theme)]: isIE11 || isEdge,\n [styles.sizeSmallWithIcon(this.theme)]: !!this.props.icon,\n [styles.sizeSmallWithIconWithoutText(this.theme)]: _isTheme2022 && !!this.props.icon && !this.props.children,\n });\n }\n }\n\n private getSizeWrapClassName() {\n switch (this.getProps().size) {\n case 'large':\n return styles.wrapLarge(this.theme);\n case 'medium':\n return styles.wrapMedium(this.theme);\n case 'small':\n default:\n return styles.wrapSmall(this.theme);\n }\n }\n\n private handleFocus = (e: React.FocusEvent<HTMLButtonElement>) => {\n if (!this.props.disabled && !this.props.disableFocus) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed) {\n this.setState({ focusedByTab: true });\n }\n });\n this.props.onFocus?.(e);\n }\n };\n\n private handleBlur = (e: React.FocusEvent<HTMLButtonElement>) => {\n this.setState({ focusedByTab: false });\n if (!this.props.disabled && !this.props.disableFocus) {\n this.props.onBlur?.(e);\n }\n };\n\n private _ref = (node: HTMLButtonElement | null) => {\n this.node = node;\n };\n}\n\nexport const isButton = isReactUIComponent<ButtonProps>('Button');\n"]}
|
|
@@ -22,6 +22,7 @@ var _FileUploaderFileValidationResult = require("../../internal/FileUploaderCont
|
|
|
22
22
|
var _useFileUploaderSize = require("../../internal/FileUploaderControl/hooks/useFileUploaderSize");
|
|
23
23
|
var _ThemeHelpers = require("../../lib/theming/ThemeHelpers");
|
|
24
24
|
|
|
25
|
+
var _forwardRefAndName = require("../../lib/forwardRefAndName");
|
|
25
26
|
|
|
26
27
|
var _UploadIcon = require("./UploadIcon");
|
|
27
28
|
var _FileUploader2 = require("./FileUploader.styles");var _excluded = ["disabled", "error", "warning", "multiple", "width", "hideFiles", "onBlur", "onFocus", "onChange", "request", "validateBeforeUpload", "onRequestSuccess", "onRequestError", "size", "renderFile"];function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}
|
|
@@ -90,7 +91,7 @@ var FileUploaderDataTids = {
|
|
|
90
91
|
|
|
91
92
|
var defaultRenderFile = function defaultRenderFile(file, fileNode) {return fileNode;};
|
|
92
93
|
|
|
93
|
-
var _FileUploader =
|
|
94
|
+
var _FileUploader = (0, _forwardRefAndName.forwardRefAndName)('FileUploader', function (props, ref) {var _cx;
|
|
94
95
|
var theme = (0, _react.useContext)(_ThemeContext.ThemeContext);
|
|
95
96
|
var _isTheme2022 = (0, _ThemeHelpers.isTheme2022)(theme);
|
|
96
97
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FileUploader.tsx"],"names":["stopPropagation","e","FileUploaderDataTids","root","content","link","input","defaultRenderFile","file","fileNode","_FileUploader","React","forwardRef","props","ref","theme","ThemeContext","_isTheme2022","disabled","error","warning","multiple","width","fileUploaderWidth","hideFiles","onBlur","onFocus","onChange","request","validateBeforeUpload","onRequestSuccess","onRequestError","size","renderFile","inputProps","FileUploaderControlContext","files","setFiles","removeFile","reset","setFileValidationResult","isMinLengthReached","locale","inputRef","fileDivRef","isAsync","isSingleMode","isLinkVisible","setIsLinkVisible","upload","tryValidateAndUpload","forEach","validationMessage","id","FileUploaderFileValidationResult","sizeClassName","small","jsStyles","sizeSmall","medium","sizeMedium","large","sizeLarge","sizeIconClass","iconSmall","iconMedium","iconLarge","contentInnerClass","contentInnerSmall","contentInnerMedium","contentInnerLarge","handleChange","newFiles","filesArray","Array","from","attachedFiles","map","getAttachedFile","length","handleDrop","event","dataTransfer","clearData","onDrop","isDraggable","labelRef","isWindowDraggable","windowRef","globalObject","current","document","focus","keyListener","isTabPressed","blur","getRootNode","rootNodeRef","focusedByTab","setFocusedByTab","handleInputChange","target","handleFocus","requestAnimationFrame","handleBlur","hovered","setHovered","uploadButtonClassNames","uploadButton","uploadButtonFocus","dragOver","canDrop","uploadButtonWrapperClassNames","windowDragOver","windowDragOver2022","uploadButtonIconClassNames","icon","iconDisabled","hasOneFile","hasOneFileForSingle","contentClassNames","contentWithFiles","linkClassNames","linkHovered","linkDisabled","iconSizes","parseInt","btnIconSizeSmall","btnIconSizeMedium","btnIconSizeLarge","choosedFile","chooseFile","String","fromCharCode","globalClasses","afterLinkText","afterLinkText_HasFiles","singleFile","orDragHere","visuallyHidden","FileUploader","memo","displayName"],"mappings":"4jBAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA,sD;;AAEA,IAAMA,eAAwC,GAAG,SAA3CA,eAA2C,CAACC,CAAD,UAAOA,CAAC,CAACD,eAAF,EAAP,EAAjD;;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,IAAME,oBAAoB,GAAG;AAClCC,EAAAA,IAAI,EAAE,oBAD4B;AAElCC,EAAAA,OAAO,EAAE,uBAFyB;AAGlCC,EAAAA,IAAI,EAAE,oBAH4B;AAIlCC,EAAAA,KAAK,EAAE,qBAJ2B,EAA7B,C;;;AAOP,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AAA,SAAS,EAAEoC,wBAASkF,cAAT,EARb;AASE,MAAA,OAAO,EAAE3I,eATX;AAUE,MAAA,QAAQ,EAAEoG,iBAVZ;AAWE,MAAA,OAAO,EAAEE,WAXX;AAYE,MAAA,MAAM,EAAEE;AACR;AAbF,QAcE,KAAK,EAAE,EAdT,IAlCF,CADF,CAPF,CADF,CADF;;;;;;;AAiED,CAjRqB,CAAtB;;;;AAqRO,IAAMoC,YAAY,GAAG;AAC1BjI,eAAMkI,IAAN,CAAWnI,aAAX,CAD0B,CAArB,C;;AAGPkI,YAAY,CAACE,WAAb,GAA2B,cAA3B","sourcesContent":["import React, { useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { globalObject, isBrowser } from '@skbkontur/global-object';\n\nimport { FileUploaderAttachedFile, getAttachedFile } from '../../internal/FileUploaderControl/fileUtils';\nimport { cx } from '../../lib/theming/Emotion';\nimport { InstanceWithRootNode } from '../../lib/rootNode';\nimport { useMemoObject } from '../../hooks/useMemoObject';\nimport { FileUploaderControlContext } from '../../internal/FileUploaderControl/FileUploaderControlContext';\nimport { useControlLocale } from '../../internal/FileUploaderControl/hooks/useControlLocale';\nimport { useUpload } from '../../internal/FileUploaderControl/hooks/useUpload';\nimport { useDrop } from '../../hooks/useDrop';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { UploadIcon } from '../../internal/icons/16px';\nimport { FileUploaderControlProviderProps } from '../../internal/FileUploaderControl/FileUploaderControlProvider';\nimport { withFileUploaderControlProvider } from '../../internal/FileUploaderControl/withFileUploaderControlProvider';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { FileUploaderFile } from '../../internal/FileUploaderControl/FileUploaderFile/FileUploaderFile';\nimport { FileUploaderFileList } from '../../internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { Nullable } from '../../typings/utility-types';\nimport { FileUploaderFileValidationResult } from '../../internal/FileUploaderControl/FileUploaderFileValidationResult';\nimport { useFileUploaderSize } from '../../internal/FileUploaderControl/hooks/useFileUploaderSize';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { SizeProp } from '../../lib/types/props';\n\nimport { UploadIcon as UploadIcon2022 } from './UploadIcon';\nimport { globalClasses, jsStyles } from './FileUploader.styles';\n\nconst stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();\n\n/**\n * @deprecated use SizeProp\n */\nexport type FileUploaderSize = SizeProp;\n\ntype FileUploaderOverriddenProps = 'size';\n\ninterface _FileUploaderProps\n extends CommonProps,\n Omit<React.InputHTMLAttributes<HTMLInputElement>, FileUploaderOverriddenProps> {\n /** Состояние ошибки всего контрола */\n error?: boolean;\n /** Состояние предупреждения всего контрола */\n warning?: boolean;\n /** Свойство ширины. */\n width?: React.CSSProperties['width'];\n /**\n * Задаёт размер контрола.\n *\n * **Допустимые значения**: `\"small\"`, `\"medium\"`, `\"large\"`.\n */\n size?: SizeProp;\n /** Свойство, скрывающее отображение файлов. */\n hideFiles?: boolean;\n\n /** Функция, через которую отправляем файлы. Используется для отслеживания статуса загрузки файла. */\n request?: (file: FileUploaderAttachedFile) => Promise<void>;\n /** Срабатывает при удачной попытке отправки через request */\n onRequestSuccess?: (fileId: string) => void;\n /** Срабатывает при неудачной попытке отправки через request */\n onRequestError?: (fileId: string) => void;\n\n /**\n * Функция валидации каждого файла.\n * Срабатывает после выбора файлов и перед попыткой отправить в request.\n * Чтобы вывести валидацию ошибки, промис должен вернуть строку.\n * */\n validateBeforeUpload?: (file: FileUploaderAttachedFile) => Promise<Nullable<string>>;\n\n /**\n * Функция, позволяющая кастомизировать файлы.\n * Через нее можно вешать кастомные валидации на каждый файл.\n * */\n renderFile?: (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => React.ReactNode;\n}\n\nexport interface FileUploaderRef extends InstanceWithRootNode {\n focus: () => void;\n blur: () => void;\n /** Сбрасывает выбранные файлы */\n reset: () => void;\n}\n\nexport const FileUploaderDataTids = {\n root: 'FileUploader__root',\n content: 'FileUploader__content',\n link: 'FileUploader__link',\n input: 'FileUploader__input',\n} as const;\n\nconst defaultRenderFile = (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => fileNode;\n\nconst _FileUploader = React.forwardRef<FileUploaderRef, _FileUploaderProps>((props: _FileUploaderProps, ref) => {\n const theme = useContext(ThemeContext);\n const _isTheme2022 = isTheme2022(theme);\n\n const {\n disabled,\n error,\n warning,\n multiple = false,\n width = theme.fileUploaderWidth,\n hideFiles = false,\n onBlur,\n onFocus,\n onChange,\n request,\n validateBeforeUpload,\n onRequestSuccess,\n onRequestError,\n size = 'small',\n renderFile = defaultRenderFile,\n ...inputProps\n } = props;\n\n const { files, setFiles, removeFile, reset, setFileValidationResult, isMinLengthReached } =\n useContext(FileUploaderControlContext);\n\n const locale = useControlLocale();\n\n const inputRef = useRef<HTMLInputElement>(null);\n const fileDivRef = useRef<HTMLDivElement>(null);\n\n const isAsync = !!request;\n const isSingleMode = !multiple;\n\n const [isLinkVisible, setIsLinkVisible] = useState(true);\n const upload = useUpload(request, onRequestSuccess, onRequestError);\n\n const tryValidateAndUpload = useCallback(\n (files: FileUploaderAttachedFile[]) => {\n files.forEach(async (file) => {\n const validationMessage = validateBeforeUpload && (await validateBeforeUpload(file));\n\n if (!validationMessage) {\n isAsync && upload(file);\n } else {\n setFileValidationResult(file.id, FileUploaderFileValidationResult.error(validationMessage));\n }\n });\n },\n [validateBeforeUpload, isAsync, upload, setFileValidationResult],\n );\n\n const sizeClassName = useFileUploaderSize(size, {\n small: jsStyles.sizeSmall(theme),\n medium: jsStyles.sizeMedium(theme),\n large: jsStyles.sizeLarge(theme),\n });\n\n const sizeIconClass = useFileUploaderSize(size, {\n small: jsStyles.iconSmall(theme),\n medium: jsStyles.iconMedium(theme),\n large: jsStyles.iconLarge(theme),\n });\n\n const contentInnerClass = useFileUploaderSize(size, {\n small: jsStyles.contentInnerSmall(theme),\n medium: jsStyles.contentInnerMedium(theme),\n large: jsStyles.contentInnerLarge(theme),\n });\n\n /** common part **/\n const handleChange = useCallback(\n (newFiles: FileList | null) => {\n if (!newFiles) {\n return;\n }\n\n let filesArray = Array.from(newFiles);\n\n if (isSingleMode) {\n filesArray = [filesArray[0]];\n }\n\n const attachedFiles = filesArray.map(getAttachedFile);\n\n if (isSingleMode && attachedFiles.length && files.length) {\n removeFile(files[0].id);\n }\n\n if (attachedFiles.length) {\n setFiles(attachedFiles);\n tryValidateAndUpload(attachedFiles);\n }\n },\n [tryValidateAndUpload, setFiles, isSingleMode, files, removeFile],\n );\n\n const handleDrop = useCallback(\n (event) => {\n if (disabled) {\n return;\n }\n\n const { dataTransfer } = event;\n const { files } = dataTransfer;\n\n if (files?.length > 0) {\n handleChange(files);\n dataTransfer.clearData();\n }\n },\n [handleChange, disabled],\n );\n\n const { isDraggable, ref: labelRef } = useDrop<HTMLLabelElement>({ onDrop: handleDrop });\n const { isDraggable: isWindowDraggable, ref: windowRef } = useDrop<Document>();\n\n if (isBrowser(globalObject)) {\n windowRef.current = globalObject.document;\n }\n\n const focus = useCallback(() => {\n keyListener.isTabPressed = true;\n inputRef.current?.focus();\n }, []);\n\n const blur = useCallback(() => {\n inputRef.current?.blur();\n }, []);\n\n useImperativeHandle(ref, () => ({ focus, blur, reset, getRootNode: () => rootNodeRef.current }), [\n ref,\n blur,\n focus,\n reset,\n ]);\n\n const [focusedByTab, setFocusedByTab] = useState(false);\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n handleChange(event.target.files);\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n if (!disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed) {\n setFocusedByTab(true);\n }\n });\n onFocus?.(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocusedByTab(false);\n if (!disabled) {\n onBlur?.(e);\n }\n };\n\n const [hovered, setHovered] = useState(false);\n\n const uploadButtonClassNames = cx(\n jsStyles.uploadButton(theme),\n sizeClassName,\n focusedByTab && jsStyles.uploadButtonFocus(theme),\n disabled && jsStyles.disabled(theme),\n !disabled && hovered && jsStyles.hovered(theme),\n !!warning && jsStyles.warning(theme),\n !!error && jsStyles.error(theme),\n isDraggable && !disabled && jsStyles.dragOver(theme),\n );\n\n const canDrop = isWindowDraggable && !disabled;\n const uploadButtonWrapperClassNames = cx(\n !_isTheme2022 && canDrop && jsStyles.windowDragOver(theme),\n _isTheme2022 && canDrop && jsStyles.windowDragOver2022(theme),\n );\n\n const uploadButtonIconClassNames = cx(jsStyles.icon(theme), sizeIconClass, disabled && jsStyles.iconDisabled(theme));\n\n const hasOneFile = files.length === 1;\n const hasOneFileForSingle = isSingleMode && hasOneFile && !hideFiles;\n\n const contentClassNames = cx(jsStyles.content(), hasOneFileForSingle && jsStyles.contentWithFiles());\n\n const linkClassNames = cx(\n jsStyles.link(theme),\n !disabled && hovered && jsStyles.linkHovered(theme),\n disabled && jsStyles.linkDisabled(theme),\n );\n\n useEffect(() => {\n setIsLinkVisible(hasOneFileForSingle ? !isMinLengthReached : true);\n }, [isMinLengthReached, hasOneFileForSingle]);\n\n const rootNodeRef = useRef(null);\n\n const iconSizes: Record<SizeProp, number> = {\n small: parseInt(theme.btnIconSizeSmall),\n medium: parseInt(theme.btnIconSizeMedium),\n large: parseInt(theme.btnIconSizeLarge),\n };\n const icon = _isTheme2022 ? <UploadIcon2022 size={iconSizes[size]} /> : <UploadIcon />;\n\n return (\n <CommonWrapper {...props}>\n <div\n data-tid={FileUploaderDataTids.root}\n className={jsStyles.root(theme)}\n style={useMemoObject({ width })}\n ref={rootNodeRef}\n >\n {!hideFiles && !isSingleMode && !!files.length && <FileUploaderFileList renderFile={renderFile} size={size} />}\n <div className={uploadButtonWrapperClassNames}>\n <label\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={labelRef}\n className={uploadButtonClassNames}\n >\n <div\n data-tid={FileUploaderDataTids.content}\n className={cx(contentClassNames, { [contentInnerClass]: !files.length || !isSingleMode })}\n >\n {isLinkVisible && (\n <span data-tid={FileUploaderDataTids.link} className={linkClassNames}>\n {hasOneFileForSingle ? locale.choosedFile : locale.chooseFile}\n </span>\n )}\n {isLinkVisible && String.fromCharCode(0xa0) /* */}\n <div\n className={cx(\n globalClasses.afterLinkText,\n hasOneFileForSingle ? jsStyles.afterLinkText_HasFiles(theme) : jsStyles.afterLinkText(theme),\n )}\n >\n {hasOneFileForSingle ? (\n <div ref={fileDivRef} className={jsStyles.singleFile()}>\n {renderFile(files[0], <FileUploaderFile file={files[0]} size={size} />)}\n </div>\n ) : (\n <>\n {locale.orDragHere} \n <div className={uploadButtonIconClassNames}>{icon}</div>\n </>\n )}\n </div>\n </div>\n <input\n {...inputProps}\n data-tid={FileUploaderDataTids.input}\n ref={inputRef}\n tabIndex={disabled ? -1 : 0}\n type=\"file\"\n disabled={disabled}\n multiple={multiple}\n className={jsStyles.visuallyHidden()}\n onClick={stopPropagation}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n // для того, чтобы срабатывало событие change при выборе одного и того же файла подряд\n value={''}\n />\n </label>\n </div>\n </div>\n </CommonWrapper>\n );\n});\n\nexport interface FileUploaderProps extends _FileUploaderProps, FileUploaderControlProviderProps {}\n\nexport const FileUploader = withFileUploaderControlProvider<FileUploaderProps, FileUploaderRef>(\n React.memo(_FileUploader),\n);\nFileUploader.displayName = 'FileUploader';\n"]}
|
|
1
|
+
{"version":3,"sources":["FileUploader.tsx"],"names":["stopPropagation","e","FileUploaderDataTids","root","content","link","input","defaultRenderFile","file","fileNode","_FileUploader","props","ref","theme","ThemeContext","_isTheme2022","disabled","error","warning","multiple","width","fileUploaderWidth","hideFiles","onBlur","onFocus","onChange","request","validateBeforeUpload","onRequestSuccess","onRequestError","size","renderFile","inputProps","FileUploaderControlContext","files","setFiles","removeFile","reset","setFileValidationResult","isMinLengthReached","locale","inputRef","fileDivRef","isAsync","isSingleMode","isLinkVisible","setIsLinkVisible","upload","tryValidateAndUpload","forEach","validationMessage","id","FileUploaderFileValidationResult","sizeClassName","small","jsStyles","sizeSmall","medium","sizeMedium","large","sizeLarge","sizeIconClass","iconSmall","iconMedium","iconLarge","contentInnerClass","contentInnerSmall","contentInnerMedium","contentInnerLarge","handleChange","newFiles","filesArray","Array","from","attachedFiles","map","getAttachedFile","length","handleDrop","event","dataTransfer","clearData","onDrop","isDraggable","labelRef","isWindowDraggable","windowRef","globalObject","current","document","focus","keyListener","isTabPressed","blur","getRootNode","rootNodeRef","focusedByTab","setFocusedByTab","handleInputChange","target","handleFocus","requestAnimationFrame","handleBlur","hovered","setHovered","uploadButtonClassNames","uploadButton","uploadButtonFocus","dragOver","canDrop","uploadButtonWrapperClassNames","windowDragOver","windowDragOver2022","uploadButtonIconClassNames","icon","iconDisabled","hasOneFile","hasOneFileForSingle","contentClassNames","contentWithFiles","linkClassNames","linkHovered","linkDisabled","iconSizes","parseInt","btnIconSizeSmall","btnIconSizeMedium","btnIconSizeLarge","choosedFile","chooseFile","String","fromCharCode","globalClasses","afterLinkText","afterLinkText_HasFiles","singleFile","orDragHere","visuallyHidden","FileUploader","React","memo","displayName"],"mappings":"4jBAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,sD;;AAEA,IAAMA,eAAwC,GAAG,SAA3CA,eAA2C,CAACC,CAAD,UAAOA,CAAC,CAACD,eAAF,EAAP,EAAjD;;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,IAAME,oBAAoB,GAAG;AAClCC,EAAAA,IAAI,EAAE,oBAD4B;AAElCC,EAAAA,OAAO,EAAE,uBAFyB;AAGlCC,EAAAA,IAAI,EAAE,oBAH4B;AAIlC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,QANZ;AAOE,MAAA,QAAQ,EAAEG,QAPZ;AAQE,MAAA,SAAS,EAAEoC,wBAASkF,cAAT,EARb;AASE,MAAA,OAAO,EAAEzI,eATX;AAUE,MAAA,QAAQ,EAAEkG,iBAVZ;AAWE,MAAA,OAAO,EAAEE,WAXX;AAYE,MAAA,MAAM,EAAEE;AACR;AAbF,QAcE,KAAK,EAAE,EAdT,IAlCF,CADF,CAPF,CADF,CADF;;;;;;;AAiED,CAjRqB,CAAtB;;;;AAqRO,IAAMoC,YAAY,GAAG;AAC1BC,eAAMC,IAAN,CAAWlI,aAAX,CAD0B,CAArB,C;;AAGPgI,YAAY,CAACG,WAAb,GAA2B,cAA3B","sourcesContent":["import React, { useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { globalObject, isBrowser } from '@skbkontur/global-object';\n\nimport { FileUploaderAttachedFile, getAttachedFile } from '../../internal/FileUploaderControl/fileUtils';\nimport { cx } from '../../lib/theming/Emotion';\nimport { InstanceWithRootNode } from '../../lib/rootNode';\nimport { useMemoObject } from '../../hooks/useMemoObject';\nimport { FileUploaderControlContext } from '../../internal/FileUploaderControl/FileUploaderControlContext';\nimport { useControlLocale } from '../../internal/FileUploaderControl/hooks/useControlLocale';\nimport { useUpload } from '../../internal/FileUploaderControl/hooks/useUpload';\nimport { useDrop } from '../../hooks/useDrop';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { UploadIcon } from '../../internal/icons/16px';\nimport { FileUploaderControlProviderProps } from '../../internal/FileUploaderControl/FileUploaderControlProvider';\nimport { withFileUploaderControlProvider } from '../../internal/FileUploaderControl/withFileUploaderControlProvider';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { FileUploaderFile } from '../../internal/FileUploaderControl/FileUploaderFile/FileUploaderFile';\nimport { FileUploaderFileList } from '../../internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { Nullable } from '../../typings/utility-types';\nimport { FileUploaderFileValidationResult } from '../../internal/FileUploaderControl/FileUploaderFileValidationResult';\nimport { useFileUploaderSize } from '../../internal/FileUploaderControl/hooks/useFileUploaderSize';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { SizeProp } from '../../lib/types/props';\nimport { forwardRefAndName } from '../../lib/forwardRefAndName';\n\nimport { UploadIcon as UploadIcon2022 } from './UploadIcon';\nimport { globalClasses, jsStyles } from './FileUploader.styles';\n\nconst stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();\n\n/**\n * @deprecated use SizeProp\n */\nexport type FileUploaderSize = SizeProp;\n\ntype FileUploaderOverriddenProps = 'size';\n\ninterface _FileUploaderProps\n extends CommonProps,\n Omit<React.InputHTMLAttributes<HTMLInputElement>, FileUploaderOverriddenProps> {\n /** Состояние ошибки всего контрола */\n error?: boolean;\n /** Состояние предупреждения всего контрола */\n warning?: boolean;\n /** Свойство ширины. */\n width?: React.CSSProperties['width'];\n /**\n * Задаёт размер контрола.\n *\n * **Допустимые значения**: `\"small\"`, `\"medium\"`, `\"large\"`.\n */\n size?: SizeProp;\n /** Свойство, скрывающее отображение файлов. */\n hideFiles?: boolean;\n\n /** Функция, через которую отправляем файлы. Используется для отслеживания статуса загрузки файла. */\n request?: (file: FileUploaderAttachedFile) => Promise<void>;\n /** Срабатывает при удачной попытке отправки через request */\n onRequestSuccess?: (fileId: string) => void;\n /** Срабатывает при неудачной попытке отправки через request */\n onRequestError?: (fileId: string) => void;\n\n /**\n * Функция валидации каждого файла.\n * Срабатывает после выбора файлов и перед попыткой отправить в request.\n * Чтобы вывести валидацию ошибки, промис должен вернуть строку.\n * */\n validateBeforeUpload?: (file: FileUploaderAttachedFile) => Promise<Nullable<string>>;\n\n /**\n * Функция, позволяющая кастомизировать файлы.\n * Через нее можно вешать кастомные валидации на каждый файл.\n * */\n renderFile?: (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => React.ReactNode;\n}\n\nexport interface FileUploaderRef extends InstanceWithRootNode {\n focus: () => void;\n blur: () => void;\n /** Сбрасывает выбранные файлы */\n reset: () => void;\n}\n\nexport const FileUploaderDataTids = {\n root: 'FileUploader__root',\n content: 'FileUploader__content',\n link: 'FileUploader__link',\n input: 'FileUploader__input',\n} as const;\n\nconst defaultRenderFile = (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => fileNode;\n\nconst _FileUploader = forwardRefAndName<FileUploaderRef, _FileUploaderProps>('FileUploader', (props, ref) => {\n const theme = useContext(ThemeContext);\n const _isTheme2022 = isTheme2022(theme);\n\n const {\n disabled,\n error,\n warning,\n multiple = false,\n width = theme.fileUploaderWidth,\n hideFiles = false,\n onBlur,\n onFocus,\n onChange,\n request,\n validateBeforeUpload,\n onRequestSuccess,\n onRequestError,\n size = 'small',\n renderFile = defaultRenderFile,\n ...inputProps\n } = props;\n\n const { files, setFiles, removeFile, reset, setFileValidationResult, isMinLengthReached } =\n useContext(FileUploaderControlContext);\n\n const locale = useControlLocale();\n\n const inputRef = useRef<HTMLInputElement>(null);\n const fileDivRef = useRef<HTMLDivElement>(null);\n\n const isAsync = !!request;\n const isSingleMode = !multiple;\n\n const [isLinkVisible, setIsLinkVisible] = useState(true);\n const upload = useUpload(request, onRequestSuccess, onRequestError);\n\n const tryValidateAndUpload = useCallback(\n (files: FileUploaderAttachedFile[]) => {\n files.forEach(async (file) => {\n const validationMessage = validateBeforeUpload && (await validateBeforeUpload(file));\n\n if (!validationMessage) {\n isAsync && upload(file);\n } else {\n setFileValidationResult(file.id, FileUploaderFileValidationResult.error(validationMessage));\n }\n });\n },\n [validateBeforeUpload, isAsync, upload, setFileValidationResult],\n );\n\n const sizeClassName = useFileUploaderSize(size, {\n small: jsStyles.sizeSmall(theme),\n medium: jsStyles.sizeMedium(theme),\n large: jsStyles.sizeLarge(theme),\n });\n\n const sizeIconClass = useFileUploaderSize(size, {\n small: jsStyles.iconSmall(theme),\n medium: jsStyles.iconMedium(theme),\n large: jsStyles.iconLarge(theme),\n });\n\n const contentInnerClass = useFileUploaderSize(size, {\n small: jsStyles.contentInnerSmall(theme),\n medium: jsStyles.contentInnerMedium(theme),\n large: jsStyles.contentInnerLarge(theme),\n });\n\n /** common part **/\n const handleChange = useCallback(\n (newFiles: FileList | null) => {\n if (!newFiles) {\n return;\n }\n\n let filesArray = Array.from(newFiles);\n\n if (isSingleMode) {\n filesArray = [filesArray[0]];\n }\n\n const attachedFiles = filesArray.map(getAttachedFile);\n\n if (isSingleMode && attachedFiles.length && files.length) {\n removeFile(files[0].id);\n }\n\n if (attachedFiles.length) {\n setFiles(attachedFiles);\n tryValidateAndUpload(attachedFiles);\n }\n },\n [tryValidateAndUpload, setFiles, isSingleMode, files, removeFile],\n );\n\n const handleDrop = useCallback(\n (event) => {\n if (disabled) {\n return;\n }\n\n const { dataTransfer } = event;\n const { files } = dataTransfer;\n\n if (files?.length > 0) {\n handleChange(files);\n dataTransfer.clearData();\n }\n },\n [handleChange, disabled],\n );\n\n const { isDraggable, ref: labelRef } = useDrop<HTMLLabelElement>({ onDrop: handleDrop });\n const { isDraggable: isWindowDraggable, ref: windowRef } = useDrop<Document>();\n\n if (isBrowser(globalObject)) {\n windowRef.current = globalObject.document;\n }\n\n const focus = useCallback(() => {\n keyListener.isTabPressed = true;\n inputRef.current?.focus();\n }, []);\n\n const blur = useCallback(() => {\n inputRef.current?.blur();\n }, []);\n\n useImperativeHandle(ref, () => ({ focus, blur, reset, getRootNode: () => rootNodeRef.current }), [\n ref,\n blur,\n focus,\n reset,\n ]);\n\n const [focusedByTab, setFocusedByTab] = useState(false);\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n handleChange(event.target.files);\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n if (!disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed) {\n setFocusedByTab(true);\n }\n });\n onFocus?.(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocusedByTab(false);\n if (!disabled) {\n onBlur?.(e);\n }\n };\n\n const [hovered, setHovered] = useState(false);\n\n const uploadButtonClassNames = cx(\n jsStyles.uploadButton(theme),\n sizeClassName,\n focusedByTab && jsStyles.uploadButtonFocus(theme),\n disabled && jsStyles.disabled(theme),\n !disabled && hovered && jsStyles.hovered(theme),\n !!warning && jsStyles.warning(theme),\n !!error && jsStyles.error(theme),\n isDraggable && !disabled && jsStyles.dragOver(theme),\n );\n\n const canDrop = isWindowDraggable && !disabled;\n const uploadButtonWrapperClassNames = cx(\n !_isTheme2022 && canDrop && jsStyles.windowDragOver(theme),\n _isTheme2022 && canDrop && jsStyles.windowDragOver2022(theme),\n );\n\n const uploadButtonIconClassNames = cx(jsStyles.icon(theme), sizeIconClass, disabled && jsStyles.iconDisabled(theme));\n\n const hasOneFile = files.length === 1;\n const hasOneFileForSingle = isSingleMode && hasOneFile && !hideFiles;\n\n const contentClassNames = cx(jsStyles.content(), hasOneFileForSingle && jsStyles.contentWithFiles());\n\n const linkClassNames = cx(\n jsStyles.link(theme),\n !disabled && hovered && jsStyles.linkHovered(theme),\n disabled && jsStyles.linkDisabled(theme),\n );\n\n useEffect(() => {\n setIsLinkVisible(hasOneFileForSingle ? !isMinLengthReached : true);\n }, [isMinLengthReached, hasOneFileForSingle]);\n\n const rootNodeRef = useRef(null);\n\n const iconSizes: Record<SizeProp, number> = {\n small: parseInt(theme.btnIconSizeSmall),\n medium: parseInt(theme.btnIconSizeMedium),\n large: parseInt(theme.btnIconSizeLarge),\n };\n const icon = _isTheme2022 ? <UploadIcon2022 size={iconSizes[size]} /> : <UploadIcon />;\n\n return (\n <CommonWrapper {...props}>\n <div\n data-tid={FileUploaderDataTids.root}\n className={jsStyles.root(theme)}\n style={useMemoObject({ width })}\n ref={rootNodeRef}\n >\n {!hideFiles && !isSingleMode && !!files.length && <FileUploaderFileList renderFile={renderFile} size={size} />}\n <div className={uploadButtonWrapperClassNames}>\n <label\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={labelRef}\n className={uploadButtonClassNames}\n >\n <div\n data-tid={FileUploaderDataTids.content}\n className={cx(contentClassNames, { [contentInnerClass]: !files.length || !isSingleMode })}\n >\n {isLinkVisible && (\n <span data-tid={FileUploaderDataTids.link} className={linkClassNames}>\n {hasOneFileForSingle ? locale.choosedFile : locale.chooseFile}\n </span>\n )}\n {isLinkVisible && String.fromCharCode(0xa0) /* */}\n <div\n className={cx(\n globalClasses.afterLinkText,\n hasOneFileForSingle ? jsStyles.afterLinkText_HasFiles(theme) : jsStyles.afterLinkText(theme),\n )}\n >\n {hasOneFileForSingle ? (\n <div ref={fileDivRef} className={jsStyles.singleFile()}>\n {renderFile(files[0], <FileUploaderFile file={files[0]} size={size} />)}\n </div>\n ) : (\n <>\n {locale.orDragHere} \n <div className={uploadButtonIconClassNames}>{icon}</div>\n </>\n )}\n </div>\n </div>\n <input\n {...inputProps}\n data-tid={FileUploaderDataTids.input}\n ref={inputRef}\n tabIndex={disabled ? -1 : 0}\n type=\"file\"\n disabled={disabled}\n multiple={multiple}\n className={jsStyles.visuallyHidden()}\n onClick={stopPropagation}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n // для того, чтобы срабатывало событие change при выборе одного и того же файла подряд\n value={''}\n />\n </label>\n </div>\n </div>\n </CommonWrapper>\n );\n});\n\nexport interface FileUploaderProps extends _FileUploaderProps, FileUploaderControlProviderProps {}\n\nexport const FileUploader = withFileUploaderControlProvider<FileUploaderProps, FileUploaderRef>(\n React.memo(_FileUploader),\n);\nFileUploader.displayName = 'FileUploader';\n"]}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
Вывод элементов с горизонтальным расположением
|
|
2
|
-
|
|
3
|
-
```jsx harmony
|
|
4
|
-
import { Button } from '@skbkontur/react-ui';
|
|
5
|
-
|
|
6
|
-
<Gapped gap={20}>
|
|
7
|
-
<Button use="primary">Сохранить</Button>
|
|
8
|
-
<Button>Отмена</Button>
|
|
9
|
-
</Gapped>;
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Вертикальное расположение
|
|
13
|
-
|
|
14
|
-
```jsx harmony
|
|
15
|
-
import { Checkbox } from '@skbkontur/react-ui';
|
|
16
|
-
|
|
17
|
-
<Gapped vertical gap={20}>
|
|
18
|
-
<Checkbox checked>Write todos</Checkbox>
|
|
19
|
-
<Checkbox initialIndeterminate>Work in progress</Checkbox>
|
|
20
|
-
<Checkbox>Make things done</Checkbox>
|
|
21
|
-
</Gapped>;
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
По умолчанию `Gapped` выстраивает элементы в одну строчку, но с помощью свойства `wrap` можно включить перенос элементов на новую строку.
|
|
25
|
-
При этом между строчками будет отступ равный значению свойста `gap`
|
|
26
|
-
В таком случае из-за особенности верстки `Gapped` может перекрывать элементы расположенные сверху-слева.
|
|
27
|
-
|
|
28
|
-
```jsx harmony
|
|
29
|
-
import { Button, Checkbox, Toggle } from '@skbkontur/react-ui';
|
|
30
|
-
|
|
31
|
-
<>
|
|
32
|
-
{"U Can't Touch This! => "}
|
|
33
|
-
<Toggle />
|
|
34
|
-
|
|
35
|
-
<div style={{ paddingTop: '10px', position: 'relative', width: '250px' }}>
|
|
36
|
-
<Gapped wrap gap={50}>
|
|
37
|
-
<Button use="primary">Сохранить</Button>
|
|
38
|
-
<Button>Отмена</Button>
|
|
39
|
-
<Checkbox>Я не робот</Checkbox>
|
|
40
|
-
</Gapped>
|
|
41
|
-
</div>
|
|
42
|
-
</>;
|
|
43
|
-
```
|
|
1
|
+
Вывод элементов с горизонтальным расположением
|
|
2
|
+
|
|
3
|
+
```jsx harmony
|
|
4
|
+
import { Button } from '@skbkontur/react-ui';
|
|
5
|
+
|
|
6
|
+
<Gapped gap={20}>
|
|
7
|
+
<Button use="primary">Сохранить</Button>
|
|
8
|
+
<Button>Отмена</Button>
|
|
9
|
+
</Gapped>;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Вертикальное расположение
|
|
13
|
+
|
|
14
|
+
```jsx harmony
|
|
15
|
+
import { Checkbox } from '@skbkontur/react-ui';
|
|
16
|
+
|
|
17
|
+
<Gapped vertical gap={20}>
|
|
18
|
+
<Checkbox checked>Write todos</Checkbox>
|
|
19
|
+
<Checkbox initialIndeterminate>Work in progress</Checkbox>
|
|
20
|
+
<Checkbox>Make things done</Checkbox>
|
|
21
|
+
</Gapped>;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
По умолчанию `Gapped` выстраивает элементы в одну строчку, но с помощью свойства `wrap` можно включить перенос элементов на новую строку.
|
|
25
|
+
При этом между строчками будет отступ равный значению свойста `gap`
|
|
26
|
+
В таком случае из-за особенности верстки `Gapped` может перекрывать элементы расположенные сверху-слева.
|
|
27
|
+
|
|
28
|
+
```jsx harmony
|
|
29
|
+
import { Button, Checkbox, Toggle } from '@skbkontur/react-ui';
|
|
30
|
+
|
|
31
|
+
<>
|
|
32
|
+
{"U Can't Touch This! => "}
|
|
33
|
+
<Toggle />
|
|
34
|
+
|
|
35
|
+
<div style={{ paddingTop: '10px', position: 'relative', width: '250px' }}>
|
|
36
|
+
<Gapped wrap gap={50}>
|
|
37
|
+
<Button use="primary">Сохранить</Button>
|
|
38
|
+
<Button>Отмена</Button>
|
|
39
|
+
<Checkbox>Я не робот</Checkbox>
|
|
40
|
+
</Gapped>
|
|
41
|
+
</div>
|
|
42
|
+
</>;
|
|
43
|
+
```
|
|
@@ -58,6 +58,7 @@ export declare const GlobalLoaderDataTids: {
|
|
|
58
58
|
};
|
|
59
59
|
declare type DefaultProps = Required<Pick<GlobalLoaderProps, 'expectedResponseTime' | 'delayBeforeShow' | 'delayBeforeHide' | 'rejected' | 'active' | 'disableAnimations'>>;
|
|
60
60
|
export declare class GlobalLoader extends React.Component<GlobalLoaderProps, GlobalLoaderState> {
|
|
61
|
+
static __KONTUR_REACT_UI__: string;
|
|
61
62
|
private setRootNode;
|
|
62
63
|
private getProps;
|
|
63
64
|
private readonly startTask;
|
|
@@ -101,6 +101,7 @@ GlobalLoader = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
|
|
104
105
|
|
|
105
106
|
|
|
106
107
|
function GlobalLoader(props) {var _this;
|
|
@@ -271,4 +272,4 @@ GlobalLoader = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/
|
|
|
271
272
|
* Равносильно установке пропа `active = true`
|
|
272
273
|
*
|
|
273
274
|
* @public
|
|
274
|
-
*/;_proto.updateExpectedResponseTime = function updateExpectedResponseTime(expectedResponseTime) {this.setState({ expectedResponseTime: expectedResponseTime });};return GlobalLoader;}(_react.default.Component), _class2.defaultProps = { expectedResponseTime: 1000, delayBeforeShow: 1000, delayBeforeHide: 1000, rejected: false, active: false, disableAnimations: _currentEnvironment.isTestEnv }, _class2.start = function (expectedResponseTime) {currentGlobalLoader.setActive();if (typeof expectedResponseTime === 'number') {currentGlobalLoader.updateExpectedResponseTime(expectedResponseTime);}}, _class2.done = function () {currentGlobalLoader.setDone();}, _class2.reject = function () {currentGlobalLoader.setReject(true);}, _class2.accept = function () {currentGlobalLoader.setReject(false);}, _temp)) || _class;exports.GlobalLoader = GlobalLoader;
|
|
275
|
+
*/;_proto.updateExpectedResponseTime = function updateExpectedResponseTime(expectedResponseTime) {this.setState({ expectedResponseTime: expectedResponseTime });};return GlobalLoader;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'GlobalLoader', _class2.defaultProps = { expectedResponseTime: 1000, delayBeforeShow: 1000, delayBeforeHide: 1000, rejected: false, active: false, disableAnimations: _currentEnvironment.isTestEnv }, _class2.start = function (expectedResponseTime) {currentGlobalLoader.setActive();if (typeof expectedResponseTime === 'number') {currentGlobalLoader.updateExpectedResponseTime(expectedResponseTime);}}, _class2.done = function () {currentGlobalLoader.setDone();}, _class2.reject = function () {currentGlobalLoader.setReject(true);}, _class2.accept = function () {currentGlobalLoader.setReject(false);}, _temp)) || _class;exports.GlobalLoader = GlobalLoader;
|