@semcore/button 4.0.12 → 4.0.15
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 +20 -1
- package/lib/cjs/Button.js +41 -29
- package/lib/cjs/Button.js.map +1 -1
- package/lib/es6/Button.js +36 -29
- package/lib/es6/Button.js.map +1 -1
- package/package.json +2 -2
- package/src/Button.jsx +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [4.0.15] - 2022-08-29
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Fixed aria warning detection.
|
|
10
|
+
|
|
11
|
+
## [4.0.14] - 2022-08-24
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Update version `@semcore/utils` to use additional functions.
|
|
16
|
+
|
|
17
|
+
## [4.0.13] - 2022-08-19
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Added empty button aria-label check.
|
|
22
|
+
|
|
5
23
|
## [4.0.12] - 2022-08-18
|
|
6
24
|
|
|
7
25
|
### Changed
|
|
@@ -66,7 +84,8 @@ CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangel
|
|
|
66
84
|
|
|
67
85
|
### Changed
|
|
68
86
|
|
|
69
|
-
- Version patch update due to children dependencies update (`@semcore/utils` [3.32.0 ~> 3.32.1]
|
|
87
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.32.0 ~> 3.32.1]
|
|
88
|
+
, `@semcore/flex-box` [4.5.1 ~> 4.5.3]).
|
|
70
89
|
|
|
71
90
|
## [4.0.1] - 2022-05-19
|
|
72
91
|
|
package/lib/cjs/Button.js
CHANGED
|
@@ -33,6 +33,12 @@ var _keyboardFocusEnhance = _interopRequireDefault(require("@semcore/utils/lib/e
|
|
|
33
33
|
|
|
34
34
|
var _addonTextChildren = _interopRequireDefault(require("@semcore/utils/lib/addonTextChildren"));
|
|
35
35
|
|
|
36
|
+
var _logger = _interopRequireDefault(require("@semcore/utils/lib/logger"));
|
|
37
|
+
|
|
38
|
+
var _reactToText = _interopRequireDefault(require("@semcore/utils/lib/reactToText"));
|
|
39
|
+
|
|
40
|
+
var _getOriginChildren = _interopRequireDefault(require("@semcore/utils/lib/getOriginChildren"));
|
|
41
|
+
|
|
36
42
|
var _SpinButton = _interopRequireDefault(require("./SpinButton"));
|
|
37
43
|
|
|
38
44
|
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); }
|
|
@@ -52,36 +58,36 @@ var style = (
|
|
|
52
58
|
/*__reshadow_css_start__*/
|
|
53
59
|
_core.sstyled.insert(
|
|
54
60
|
/*__inner_css_start__*/
|
|
55
|
-
".
|
|
61
|
+
".___SButton_5h4zz_gg_{position:relative;display:inline-block;align-items:center;justify-content:center;padding:0;margin:0;white-space:nowrap;font-family:Inter,sans-serif;line-height:normal;text-decoration:none;text-align:center;vertical-align:middle;border:1px solid transparent;outline:0;box-shadow:none;cursor:pointer;box-sizing:border-box;overflow:visible;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;font-weight:500;color:#6c6e79}.___SButton_5h4zz_gg_::-moz-focus-inner{padding:0;border:none}.___SButton_5h4zz_gg_:active,.___SButton_5h4zz_gg_:focus,.___SButton_5h4zz_gg_:hover{outline:0;text-decoration:none}.___SButton_5h4zz_gg_.__disabled_5h4zz_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SButton_5h4zz_gg_.__keyboardFocused_5h4zz_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2);z-index:1}.___SButton_5h4zz_gg_._size_m_5h4zz_gg_{height:28px;min-width:28px;border-radius:6px;font-size:14px}.___SButton_5h4zz_gg_._size_l_5h4zz_gg_{height:40px;min-width:40px;border-radius:6px;font-size:16px}.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_{color:#ffffff;background-color:#008ff8}.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_:hover{background-color:#006dca}.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_.__active_5h4zz_gg_{background-color:#044792}.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_{color:#ffffff;background-color:#009f81}.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_:hover{background-color:#007c65}.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_.__active_5h4zz_gg_{background-color:#055345}.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_{background-color:#ff642d;color:#ffffff}.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_:hover{background-color:#c33909}.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_.__active_5h4zz_gg_{background-color:#8b1500}.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_{background-color:#ff4953;color:#ffffff}.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_:hover{background-color:#d1002f}.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_.__active_5h4zz_gg_{background-color:#8e0016}.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_{background-color:#fff;color:#191b23}.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_:hover{background-color:#f4f5f9}.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_.__active_5h4zz_gg_{background-color:#e0e1e9}.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_{color:#6c6e79;border-color:#c4c7cf;background-color:rgba(138,142,155,.1)}.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_{background-color:rgba(0,143,248,.05);color:#008ff8;border-color:#008ff8}.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_:hover{background-color:rgba(0,109,202,.2)}.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(0,109,202,.3)}.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_{background-color:hsla(0,0%,100%,.05);color:#fff;border-color:#fff}.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_.__active_5h4zz_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_{color:#006dca;background-color:transparent}.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_:hover{background-color:rgba(0,143,248,.2)}.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(0,143,248,.3)}.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_{color:#6c6e79;background-color:transparent}.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_{color:#fff;background-color:transparent}.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_.__active_5h4zz_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_5h4zz_gg_._neighborLocation_right_5h4zz_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_{border-radius:0;margin-left:-1px}.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-danger_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-info_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-success_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-warning_5h4zz_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-invert_5h4zz_gg_{border-left-color:rgba(0,0,0,.5)}.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-danger_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-info_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-success_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-warning_5h4zz_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-invert_5h4zz_gg_{border-left-color:rgba(0,0,0,.5)}.___SSpin_5h4zz_gg_{position:absolute;top:0;left:0;width:100%;height:100%;display:flex}.___SInner_5h4zz_gg_{display:inline-flex;align-items:center;justify-content:center;height:100%;width:100%}.___SInner_5h4zz_gg_.__loading_5h4zz_gg_{visibility:hidden}.___SText_5h4zz_gg_{display:inline-flex}.___SText_5h4zz_gg_._size_m_5h4zz_gg_{margin-left:8px;margin-right:8px;line-height:1.42}.___SText_5h4zz_gg_._size_l_5h4zz_gg_{margin-left:12px;margin-right:12px;line-height:1.5}.___SAddon_5h4zz_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_5h4zz_gg_._size_m_5h4zz_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_5h4zz_gg_._size_m_5h4zz_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_5h4zz_gg_._size_m_5h4zz_gg_:only-child{margin-left:-4px;margin-right:-4px}.___SAddon_5h4zz_gg_._size_l_5h4zz_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_5h4zz_gg_._size_l_5h4zz_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_5h4zz_gg_._size_l_5h4zz_gg_:only-child{margin-left:-4px;margin-right:-4px}"
|
|
56
62
|
/*__inner_css_end__*/
|
|
57
|
-
, "
|
|
63
|
+
, "5h4zz_gg_")
|
|
58
64
|
/*__reshadow_css_end__*/
|
|
59
65
|
, {
|
|
60
|
-
"__SButton": "
|
|
61
|
-
"_disabled": "
|
|
62
|
-
"_keyboardFocused": "
|
|
63
|
-
"_size_m": "
|
|
64
|
-
"_size_l": "
|
|
65
|
-
"_theme_primary-info": "_theme_primary-
|
|
66
|
-
"_active": "
|
|
67
|
-
"_theme_primary-success": "_theme_primary-
|
|
68
|
-
"_theme_primary-warning": "_theme_primary-
|
|
69
|
-
"_theme_primary-danger": "_theme_primary-
|
|
70
|
-
"_theme_primary-invert": "_theme_primary-
|
|
71
|
-
"_theme_secondary-muted": "_theme_secondary-
|
|
72
|
-
"_theme_secondary-info": "_theme_secondary-
|
|
73
|
-
"_theme_secondary-invert": "_theme_secondary-
|
|
74
|
-
"_theme_tertiary-info": "_theme_tertiary-
|
|
75
|
-
"_theme_tertiary-muted": "_theme_tertiary-
|
|
76
|
-
"_theme_tertiary-invert": "_theme_tertiary-
|
|
77
|
-
"_neighborLocation_right": "
|
|
78
|
-
"_neighborLocation_both": "
|
|
79
|
-
"_neighborLocation_left": "
|
|
80
|
-
"__SSpin": "
|
|
81
|
-
"__SInner": "
|
|
82
|
-
"_loading": "
|
|
83
|
-
"__SText": "
|
|
84
|
-
"__SAddon": "
|
|
66
|
+
"__SButton": "___SButton_5h4zz_gg_",
|
|
67
|
+
"_disabled": "__disabled_5h4zz_gg_",
|
|
68
|
+
"_keyboardFocused": "__keyboardFocused_5h4zz_gg_",
|
|
69
|
+
"_size_m": "_size_m_5h4zz_gg_",
|
|
70
|
+
"_size_l": "_size_l_5h4zz_gg_",
|
|
71
|
+
"_theme_primary-info": "_theme_primary-info_5h4zz_gg_",
|
|
72
|
+
"_active": "__active_5h4zz_gg_",
|
|
73
|
+
"_theme_primary-success": "_theme_primary-success_5h4zz_gg_",
|
|
74
|
+
"_theme_primary-warning": "_theme_primary-warning_5h4zz_gg_",
|
|
75
|
+
"_theme_primary-danger": "_theme_primary-danger_5h4zz_gg_",
|
|
76
|
+
"_theme_primary-invert": "_theme_primary-invert_5h4zz_gg_",
|
|
77
|
+
"_theme_secondary-muted": "_theme_secondary-muted_5h4zz_gg_",
|
|
78
|
+
"_theme_secondary-info": "_theme_secondary-info_5h4zz_gg_",
|
|
79
|
+
"_theme_secondary-invert": "_theme_secondary-invert_5h4zz_gg_",
|
|
80
|
+
"_theme_tertiary-info": "_theme_tertiary-info_5h4zz_gg_",
|
|
81
|
+
"_theme_tertiary-muted": "_theme_tertiary-muted_5h4zz_gg_",
|
|
82
|
+
"_theme_tertiary-invert": "_theme_tertiary-invert_5h4zz_gg_",
|
|
83
|
+
"_neighborLocation_right": "_neighborLocation_right_5h4zz_gg_",
|
|
84
|
+
"_neighborLocation_both": "_neighborLocation_both_5h4zz_gg_",
|
|
85
|
+
"_neighborLocation_left": "_neighborLocation_left_5h4zz_gg_",
|
|
86
|
+
"__SSpin": "___SSpin_5h4zz_gg_",
|
|
87
|
+
"__SInner": "___SInner_5h4zz_gg_",
|
|
88
|
+
"_loading": "__loading_5h4zz_gg_",
|
|
89
|
+
"__SText": "___SText_5h4zz_gg_",
|
|
90
|
+
"__SAddon": "___SAddon_5h4zz_gg_"
|
|
85
91
|
});
|
|
86
92
|
var MAP_USE_DEFAULT_THEME = {
|
|
87
93
|
primary: 'info',
|
|
@@ -136,13 +142,19 @@ var RootButton = /*#__PURE__*/function (_Component) {
|
|
|
136
142
|
disabled = _this$asProps$disable === void 0 ? loading : _this$asProps$disable,
|
|
137
143
|
size = _this$asProps.size,
|
|
138
144
|
addonLeft = _this$asProps.addonLeft,
|
|
139
|
-
addonRight = _this$asProps.addonRight
|
|
145
|
+
addonRight = _this$asProps.addonRight,
|
|
146
|
+
ariaLabel = _this$asProps['aria-label'];
|
|
140
147
|
var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
|
|
148
|
+
var isTextInside = (0, _reactToText["default"])((0, _getOriginChildren["default"])(Children));
|
|
149
|
+
|
|
150
|
+
_logger["default"].warn(!isTextInside && !ariaLabel, 'aria-label is required', this.asProps['data-ui-name'] || Button.displayName);
|
|
151
|
+
|
|
141
152
|
return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SButton, _ref4.cn("SButton", _objectSpread({}, (0, _core.assignProps)({
|
|
142
153
|
"type": "button",
|
|
143
154
|
"tag": "button",
|
|
144
155
|
"disabled": disabled,
|
|
145
|
-
"use:theme": useTheme
|
|
156
|
+
"use:theme": useTheme,
|
|
157
|
+
"role": "button"
|
|
146
158
|
}, _ref))), /*#__PURE__*/_react["default"].createElement(SInner, _ref4.cn("SInner", {
|
|
147
159
|
"tag": "span",
|
|
148
160
|
"loading": loading
|
package/lib/cjs/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["MAP_USE_DEFAULT_THEME","primary","secondary","tertiary","RootButton","size","asProps","SButton","Box","SInner","SSpin","Children","styles","use","theme","loading","disabled","addonLeft","addonRight","useTheme","
|
|
1
|
+
{"version":3,"file":"Button.js","names":["MAP_USE_DEFAULT_THEME","primary","secondary","tertiary","RootButton","size","asProps","SButton","Box","SInner","SSpin","Children","styles","use","theme","loading","disabled","addonLeft","addonRight","ariaLabel","useTheme","isTextInside","reactToText","getOriginChildren","logger","warn","Button","displayName","sstyled","addonTextChildren","Text","Addon","Component","keyboardFocusEnhance","neighborLocationEnhance","style","props","SText","SAddon","createComponent"],"sources":["../../src/Button.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { neighborLocationEnhance } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport logger from '@semcore/utils/lib/logger';\nimport reactToText from '@semcore/utils/lib/reactToText';\nimport getOriginChildren from '@semcore/utils/lib/getOriginChildren';\nimport SpinButton from './SpinButton';\n\nimport style from './style/button.shadow.css';\n\nexport const MAP_USE_DEFAULT_THEME = {\n primary: 'info',\n secondary: 'muted',\n tertiary: 'info',\n};\n\nclass RootButton extends Component {\n static displayName = 'Button';\n static enhance = [keyboardFocusEnhance(), neighborLocationEnhance()];\n static style = style;\n static defaultProps = {\n use: 'secondary',\n size: 'm',\n };\n\n getTextProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n getAddonProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n render() {\n const SButton = Root;\n const SInner = Box;\n const SSpin = Box;\n const {\n Children,\n styles,\n use,\n theme = typeof use === 'string' && MAP_USE_DEFAULT_THEME[use],\n loading,\n disabled = loading,\n size,\n addonLeft,\n addonRight,\n 'aria-label': ariaLabel,\n } = this.asProps;\n const useTheme = use && theme ? `${use}-${theme}` : false;\n const isTextInside = reactToText(getOriginChildren(Children));\n\n logger.warn(\n !isTextInside && !ariaLabel,\n 'aria-label is required',\n this.asProps['data-ui-name'] || Button.displayName,\n );\n\n return sstyled(styles)(\n <SButton\n render={Box}\n type=\"button\"\n tag=\"button\"\n disabled={disabled}\n use:theme={useTheme}\n role=\"button\"\n >\n <SInner tag=\"span\" loading={loading}>\n {addonLeft ? <Button.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Button.Text, Button.Addon)}\n {addonRight ? <Button.Addon tag={addonRight} /> : null}\n </SInner>\n {loading && (\n <SSpin tag=\"span\">\n <SpinButton centered size={size} theme={useTheme} />\n </SSpin>\n )}\n </SButton>,\n );\n }\n}\n\nfunction Text(props) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst Button = createComponent(RootButton, {\n Text,\n Addon,\n});\n\nexport default Button;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,qBAAqB,GAAG;EACnCC,OAAO,EAAE,MAD0B;EAEnCC,SAAS,EAAE,OAFwB;EAGnCC,QAAQ,EAAE;AAHyB,CA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EAA4B;EACzC0B,IAAI,EAAJA,IADyC;EAEzCC,KAAK,EAALA;AAFyC,CAA5B,CAAf;eAKeL,M"}
|
package/lib/es6/Button.js
CHANGED
|
@@ -23,6 +23,9 @@ import { Box } from '@semcore/flex-box';
|
|
|
23
23
|
import { neighborLocationEnhance } from '@semcore/neighbor-location';
|
|
24
24
|
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
25
25
|
import addonTextChildren from '@semcore/utils/lib/addonTextChildren';
|
|
26
|
+
import logger from '@semcore/utils/lib/logger';
|
|
27
|
+
import reactToText from '@semcore/utils/lib/reactToText';
|
|
28
|
+
import getOriginChildren from '@semcore/utils/lib/getOriginChildren';
|
|
26
29
|
import SpinButton from './SpinButton';
|
|
27
30
|
|
|
28
31
|
/*__reshadow-styles__:"./style/button.shadow.css"*/
|
|
@@ -30,36 +33,36 @@ var style = (
|
|
|
30
33
|
/*__reshadow_css_start__*/
|
|
31
34
|
_sstyled.insert(
|
|
32
35
|
/*__inner_css_start__*/
|
|
33
|
-
".
|
|
36
|
+
".___SButton_5h4zz_gg_{position:relative;display:inline-block;align-items:center;justify-content:center;padding:0;margin:0;white-space:nowrap;font-family:Inter,sans-serif;line-height:normal;text-decoration:none;text-align:center;vertical-align:middle;border:1px solid transparent;outline:0;box-shadow:none;cursor:pointer;box-sizing:border-box;overflow:visible;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;font-weight:500;color:#6c6e79}.___SButton_5h4zz_gg_::-moz-focus-inner{padding:0;border:none}.___SButton_5h4zz_gg_:active,.___SButton_5h4zz_gg_:focus,.___SButton_5h4zz_gg_:hover{outline:0;text-decoration:none}.___SButton_5h4zz_gg_.__disabled_5h4zz_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SButton_5h4zz_gg_.__keyboardFocused_5h4zz_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2);z-index:1}.___SButton_5h4zz_gg_._size_m_5h4zz_gg_{height:28px;min-width:28px;border-radius:6px;font-size:14px}.___SButton_5h4zz_gg_._size_l_5h4zz_gg_{height:40px;min-width:40px;border-radius:6px;font-size:16px}.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_{color:#ffffff;background-color:#008ff8}.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_:hover{background-color:#006dca}.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-info_5h4zz_gg_.__active_5h4zz_gg_{background-color:#044792}.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_{color:#ffffff;background-color:#009f81}.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_:hover{background-color:#007c65}.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-success_5h4zz_gg_.__active_5h4zz_gg_{background-color:#055345}.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_{background-color:#ff642d;color:#ffffff}.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_:hover{background-color:#c33909}.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-warning_5h4zz_gg_.__active_5h4zz_gg_{background-color:#8b1500}.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_{background-color:#ff4953;color:#ffffff}.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_:hover{background-color:#d1002f}.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-danger_5h4zz_gg_.__active_5h4zz_gg_{background-color:#8e0016}.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_{background-color:#fff;color:#191b23}.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_:hover{background-color:#f4f5f9}.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_primary-invert_5h4zz_gg_.__active_5h4zz_gg_{background-color:#e0e1e9}.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_{color:#6c6e79;border-color:#c4c7cf;background-color:rgba(138,142,155,.1)}.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_secondary-muted_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_{background-color:rgba(0,143,248,.05);color:#008ff8;border-color:#008ff8}.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_:hover{background-color:rgba(0,109,202,.2)}.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_secondary-info_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(0,109,202,.3)}.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_{background-color:hsla(0,0%,100%,.05);color:#fff;border-color:#fff}.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_secondary-invert_5h4zz_gg_.__active_5h4zz_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_{color:#006dca;background-color:transparent}.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_:hover{background-color:rgba(0,143,248,.2)}.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_tertiary-info_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(0,143,248,.3)}.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_{color:#6c6e79;background-color:transparent}.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_tertiary-muted_5h4zz_gg_.__active_5h4zz_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_{color:#fff;background-color:transparent}.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_:active,.___SButton_5h4zz_gg_._theme_tertiary-invert_5h4zz_gg_.__active_5h4zz_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_5h4zz_gg_._neighborLocation_right_5h4zz_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_{border-radius:0;margin-left:-1px}.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-danger_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-info_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-success_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-warning_5h4zz_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_5h4zz_gg_._neighborLocation_both_5h4zz_gg_._theme_primary-invert_5h4zz_gg_{border-left-color:rgba(0,0,0,.5)}.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-danger_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-info_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-success_5h4zz_gg_,.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-warning_5h4zz_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_5h4zz_gg_._neighborLocation_left_5h4zz_gg_._theme_primary-invert_5h4zz_gg_{border-left-color:rgba(0,0,0,.5)}.___SSpin_5h4zz_gg_{position:absolute;top:0;left:0;width:100%;height:100%;display:flex}.___SInner_5h4zz_gg_{display:inline-flex;align-items:center;justify-content:center;height:100%;width:100%}.___SInner_5h4zz_gg_.__loading_5h4zz_gg_{visibility:hidden}.___SText_5h4zz_gg_{display:inline-flex}.___SText_5h4zz_gg_._size_m_5h4zz_gg_{margin-left:8px;margin-right:8px;line-height:1.42}.___SText_5h4zz_gg_._size_l_5h4zz_gg_{margin-left:12px;margin-right:12px;line-height:1.5}.___SAddon_5h4zz_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_5h4zz_gg_._size_m_5h4zz_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_5h4zz_gg_._size_m_5h4zz_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_5h4zz_gg_._size_m_5h4zz_gg_:only-child{margin-left:-4px;margin-right:-4px}.___SAddon_5h4zz_gg_._size_l_5h4zz_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_5h4zz_gg_._size_l_5h4zz_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_5h4zz_gg_._size_l_5h4zz_gg_:only-child{margin-left:-4px;margin-right:-4px}"
|
|
34
37
|
/*__inner_css_end__*/
|
|
35
|
-
, "
|
|
38
|
+
, "5h4zz_gg_")
|
|
36
39
|
/*__reshadow_css_end__*/
|
|
37
40
|
, {
|
|
38
|
-
"__SButton": "
|
|
39
|
-
"_disabled": "
|
|
40
|
-
"_keyboardFocused": "
|
|
41
|
-
"_size_m": "
|
|
42
|
-
"_size_l": "
|
|
43
|
-
"_theme_primary-info": "_theme_primary-
|
|
44
|
-
"_active": "
|
|
45
|
-
"_theme_primary-success": "_theme_primary-
|
|
46
|
-
"_theme_primary-warning": "_theme_primary-
|
|
47
|
-
"_theme_primary-danger": "_theme_primary-
|
|
48
|
-
"_theme_primary-invert": "_theme_primary-
|
|
49
|
-
"_theme_secondary-muted": "_theme_secondary-
|
|
50
|
-
"_theme_secondary-info": "_theme_secondary-
|
|
51
|
-
"_theme_secondary-invert": "_theme_secondary-
|
|
52
|
-
"_theme_tertiary-info": "_theme_tertiary-
|
|
53
|
-
"_theme_tertiary-muted": "_theme_tertiary-
|
|
54
|
-
"_theme_tertiary-invert": "_theme_tertiary-
|
|
55
|
-
"_neighborLocation_right": "
|
|
56
|
-
"_neighborLocation_both": "
|
|
57
|
-
"_neighborLocation_left": "
|
|
58
|
-
"__SSpin": "
|
|
59
|
-
"__SInner": "
|
|
60
|
-
"_loading": "
|
|
61
|
-
"__SText": "
|
|
62
|
-
"__SAddon": "
|
|
41
|
+
"__SButton": "___SButton_5h4zz_gg_",
|
|
42
|
+
"_disabled": "__disabled_5h4zz_gg_",
|
|
43
|
+
"_keyboardFocused": "__keyboardFocused_5h4zz_gg_",
|
|
44
|
+
"_size_m": "_size_m_5h4zz_gg_",
|
|
45
|
+
"_size_l": "_size_l_5h4zz_gg_",
|
|
46
|
+
"_theme_primary-info": "_theme_primary-info_5h4zz_gg_",
|
|
47
|
+
"_active": "__active_5h4zz_gg_",
|
|
48
|
+
"_theme_primary-success": "_theme_primary-success_5h4zz_gg_",
|
|
49
|
+
"_theme_primary-warning": "_theme_primary-warning_5h4zz_gg_",
|
|
50
|
+
"_theme_primary-danger": "_theme_primary-danger_5h4zz_gg_",
|
|
51
|
+
"_theme_primary-invert": "_theme_primary-invert_5h4zz_gg_",
|
|
52
|
+
"_theme_secondary-muted": "_theme_secondary-muted_5h4zz_gg_",
|
|
53
|
+
"_theme_secondary-info": "_theme_secondary-info_5h4zz_gg_",
|
|
54
|
+
"_theme_secondary-invert": "_theme_secondary-invert_5h4zz_gg_",
|
|
55
|
+
"_theme_tertiary-info": "_theme_tertiary-info_5h4zz_gg_",
|
|
56
|
+
"_theme_tertiary-muted": "_theme_tertiary-muted_5h4zz_gg_",
|
|
57
|
+
"_theme_tertiary-invert": "_theme_tertiary-invert_5h4zz_gg_",
|
|
58
|
+
"_neighborLocation_right": "_neighborLocation_right_5h4zz_gg_",
|
|
59
|
+
"_neighborLocation_both": "_neighborLocation_both_5h4zz_gg_",
|
|
60
|
+
"_neighborLocation_left": "_neighborLocation_left_5h4zz_gg_",
|
|
61
|
+
"__SSpin": "___SSpin_5h4zz_gg_",
|
|
62
|
+
"__SInner": "___SInner_5h4zz_gg_",
|
|
63
|
+
"_loading": "__loading_5h4zz_gg_",
|
|
64
|
+
"__SText": "___SText_5h4zz_gg_",
|
|
65
|
+
"__SAddon": "___SAddon_5h4zz_gg_"
|
|
63
66
|
});
|
|
64
67
|
export var MAP_USE_DEFAULT_THEME = {
|
|
65
68
|
primary: 'info',
|
|
@@ -114,13 +117,17 @@ var RootButton = /*#__PURE__*/function (_Component) {
|
|
|
114
117
|
disabled = _this$asProps$disable === void 0 ? loading : _this$asProps$disable,
|
|
115
118
|
size = _this$asProps.size,
|
|
116
119
|
addonLeft = _this$asProps.addonLeft,
|
|
117
|
-
addonRight = _this$asProps.addonRight
|
|
120
|
+
addonRight = _this$asProps.addonRight,
|
|
121
|
+
ariaLabel = _this$asProps['aria-label'];
|
|
118
122
|
var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
|
|
123
|
+
var isTextInside = reactToText(getOriginChildren(Children));
|
|
124
|
+
logger.warn(!isTextInside && !ariaLabel, 'aria-label is required', this.asProps['data-ui-name'] || Button.displayName);
|
|
119
125
|
return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SButton, _ref4.cn("SButton", _objectSpread({}, _assignProps({
|
|
120
126
|
"type": "button",
|
|
121
127
|
"tag": "button",
|
|
122
128
|
"disabled": disabled,
|
|
123
|
-
"use:theme": useTheme
|
|
129
|
+
"use:theme": useTheme,
|
|
130
|
+
"role": "button"
|
|
124
131
|
}, _ref))), /*#__PURE__*/React.createElement(SInner, _ref4.cn("SInner", {
|
|
125
132
|
"tag": "span",
|
|
126
133
|
"loading": loading
|
package/lib/es6/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["React","createComponent","Component","sstyled","Root","Box","neighborLocationEnhance","keyboardFocusEnhance","addonTextChildren","SpinButton","MAP_USE_DEFAULT_THEME","primary","secondary","tertiary","RootButton","size","asProps","SButton","SInner","SSpin","Children","styles","use","theme","loading","disabled","addonLeft","addonRight","useTheme","Button","Text","Addon","style","props","SText","SAddon"],"sources":["../../src/Button.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { neighborLocationEnhance } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport SpinButton from './SpinButton';\n\nimport style from './style/button.shadow.css';\n\nexport const MAP_USE_DEFAULT_THEME = {\n primary: 'info',\n secondary: 'muted',\n tertiary: 'info',\n};\n\nclass RootButton extends Component {\n static displayName = 'Button';\n static enhance = [keyboardFocusEnhance(), neighborLocationEnhance()];\n static style = style;\n static defaultProps = {\n use: 'secondary',\n size: 'm',\n };\n\n getTextProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n getAddonProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n render() {\n const SButton = Root;\n const SInner = Box;\n const SSpin = Box;\n const {\n Children,\n styles,\n use,\n theme = typeof use === 'string' && MAP_USE_DEFAULT_THEME[use],\n loading,\n disabled = loading,\n size,\n addonLeft,\n addonRight,\n } = this.asProps;\n
|
|
1
|
+
{"version":3,"file":"Button.js","names":["React","createComponent","Component","sstyled","Root","Box","neighborLocationEnhance","keyboardFocusEnhance","addonTextChildren","logger","reactToText","getOriginChildren","SpinButton","MAP_USE_DEFAULT_THEME","primary","secondary","tertiary","RootButton","size","asProps","SButton","SInner","SSpin","Children","styles","use","theme","loading","disabled","addonLeft","addonRight","ariaLabel","useTheme","isTextInside","warn","Button","displayName","Text","Addon","style","props","SText","SAddon"],"sources":["../../src/Button.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { neighborLocationEnhance } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport logger from '@semcore/utils/lib/logger';\nimport reactToText from '@semcore/utils/lib/reactToText';\nimport getOriginChildren from '@semcore/utils/lib/getOriginChildren';\nimport SpinButton from './SpinButton';\n\nimport style from './style/button.shadow.css';\n\nexport const MAP_USE_DEFAULT_THEME = {\n primary: 'info',\n secondary: 'muted',\n tertiary: 'info',\n};\n\nclass RootButton extends Component {\n static displayName = 'Button';\n static enhance = [keyboardFocusEnhance(), neighborLocationEnhance()];\n static style = style;\n static defaultProps = {\n use: 'secondary',\n size: 'm',\n };\n\n getTextProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n getAddonProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n render() {\n const SButton = Root;\n const SInner = Box;\n const SSpin = Box;\n const {\n Children,\n styles,\n use,\n theme = typeof use === 'string' && MAP_USE_DEFAULT_THEME[use],\n loading,\n disabled = loading,\n size,\n addonLeft,\n addonRight,\n 'aria-label': ariaLabel,\n } = this.asProps;\n const useTheme = use && theme ? `${use}-${theme}` : false;\n const isTextInside = reactToText(getOriginChildren(Children));\n\n logger.warn(\n !isTextInside && !ariaLabel,\n 'aria-label is required',\n this.asProps['data-ui-name'] || Button.displayName,\n );\n\n return sstyled(styles)(\n <SButton\n render={Box}\n type=\"button\"\n tag=\"button\"\n disabled={disabled}\n use:theme={useTheme}\n role=\"button\"\n >\n <SInner tag=\"span\" loading={loading}>\n {addonLeft ? <Button.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Button.Text, Button.Addon)}\n {addonRight ? <Button.Addon tag={addonRight} /> : null}\n </SInner>\n {loading && (\n <SSpin tag=\"span\">\n <SpinButton centered size={size} theme={useTheme} />\n </SSpin>\n )}\n </SButton>,\n );\n }\n}\n\nfunction Text(props) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst Button = createComponent(RootButton, {\n Text,\n Addon,\n});\n\nexport default Button;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,SAASC,uBAAT,QAAwC,4BAAxC;AACA,OAAOC,oBAAP,MAAiC,kDAAjC;AACA,OAAOC,iBAAP,MAA8B,sCAA9B;AACA,OAAOC,MAAP,MAAmB,2BAAnB;AACA,OAAOC,WAAP,MAAwB,gCAAxB;AACA,OAAOC,iBAAP,MAA8B,sCAA9B;AACA,OAAOC,UAAP,MAAuB,cAAvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,OAAO,IAAMC,qBAAqB,GAAG;EACnCC,OAAO,EAAE,MAD0B;EAEnCC,SAAS,EAAE,OAFwB;EAGnCC,QAAQ,EAAE;AAHyB,CAA9B;;IAMDC,U;;;;;;;;;;;;;WASJ,wBAAe;MACb,IAAQC,IAAR,GAAiB,KAAKC,OAAtB,CAAQD,IAAR;MACA,OAAO;QACLA,IAAI,EAAJA;MADK,CAAP;IAGD;;;WAED,yBAAgB;MACd,IAAQA,IAAR,GAAiB,KAAKC,OAAtB,CAAQD,IAAR;MACA,OAAO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e,QAAD,EAAWY,MAAM,CAACE,IAAlB,EAAwBF,MAAM,CAACG,KAA/B,CAFpB,EAGGR,UAAU,gBAAG,oBAAC,MAAD,CAAQ,KAAR;QAAc,GAAG,EAAEA;MAAnB,EAAH,GAAuC,IAHpD,CARF,EAaGH,OAAO,iBACN,oBAAC,KAAD;QAAA,OAAW;MAAX,iBACE,oBAAC,UAAD;QAAA;QAAA,QAA2BT,IAA3B;QAAA,SAAwCc;MAAxC,GADF,CAdJ,CADF;IAqBD;;;;EArEsB9B,S;;gBAAnBe,U,iBACiB,Q;;gBADjBA,U,aAEa,CAACV,oBAAoB,EAArB,EAAyBD,uBAAuB,EAAhD,C;;gBAFbW,U,WAGWsB,K;;gBAHXtB,U,kBAIkB;EACpBQ,GAAG,EAAE,WADe;EAEpBP,IAAI,EAAE;AAFc,C;;AAoExB,SAASmB,IAAT,CAAcG,KAAd,EAAqB;EAAA;EAAA;;EACnB,IAAMC,KAAK,GACiCpC,GAD5C;EACA,eAAOF,OAAO,CAACqC,KAAK,CAAChB,MAAP,CAAd,eAA6B,oBAAC,KAAD;IAAA,OAAwB;EAAxB,YAA7B;AACD;;AAED,SAASc,KAAT,CAAeE,KAAf,EAAsB;EAAA;EAAA;;EACpB,IAAME,MAAM,GACiCrC,GAD7C;EACA,eAAOF,OAAO,CAACqC,KAAK,CAAChB,MAAP,CAAd,eAA6B,oBAAC,MAAD;IAAA,OAAyB;EAAzB,YAA7B;AACD;;AAED,IAAMW,MAAM,GAAGlC,eAAe,CAACgB,UAAD,EAAa;EACzCoB,IAAI,EAAJA,IADyC;EAEzCC,KAAK,EAALA;AAFyC,CAAb,CAA9B;AAKA,eAAeH,MAAf"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/button",
|
|
3
3
|
"description": "Semrush Button Component",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.15",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"test": "jest"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@semcore/utils": "^3.
|
|
16
|
+
"@semcore/utils": "^3.37",
|
|
17
17
|
"@semcore/spin": "^4",
|
|
18
18
|
"@semcore/neighbor-location": "^2",
|
|
19
19
|
"@semcore/flex-box": "^4"
|
package/src/Button.jsx
CHANGED
|
@@ -4,6 +4,9 @@ import { Box } from '@semcore/flex-box';
|
|
|
4
4
|
import { neighborLocationEnhance } from '@semcore/neighbor-location';
|
|
5
5
|
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
6
6
|
import addonTextChildren from '@semcore/utils/lib/addonTextChildren';
|
|
7
|
+
import logger from '@semcore/utils/lib/logger';
|
|
8
|
+
import reactToText from '@semcore/utils/lib/reactToText';
|
|
9
|
+
import getOriginChildren from '@semcore/utils/lib/getOriginChildren';
|
|
7
10
|
import SpinButton from './SpinButton';
|
|
8
11
|
|
|
9
12
|
import style from './style/button.shadow.css';
|
|
@@ -51,11 +54,26 @@ class RootButton extends Component {
|
|
|
51
54
|
size,
|
|
52
55
|
addonLeft,
|
|
53
56
|
addonRight,
|
|
57
|
+
'aria-label': ariaLabel,
|
|
54
58
|
} = this.asProps;
|
|
55
|
-
|
|
56
59
|
const useTheme = use && theme ? `${use}-${theme}` : false;
|
|
60
|
+
const isTextInside = reactToText(getOriginChildren(Children));
|
|
61
|
+
|
|
62
|
+
logger.warn(
|
|
63
|
+
!isTextInside && !ariaLabel,
|
|
64
|
+
'aria-label is required',
|
|
65
|
+
this.asProps['data-ui-name'] || Button.displayName,
|
|
66
|
+
);
|
|
67
|
+
|
|
57
68
|
return sstyled(styles)(
|
|
58
|
-
<SButton
|
|
69
|
+
<SButton
|
|
70
|
+
render={Box}
|
|
71
|
+
type="button"
|
|
72
|
+
tag="button"
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
use:theme={useTheme}
|
|
75
|
+
role="button"
|
|
76
|
+
>
|
|
59
77
|
<SInner tag="span" loading={loading}>
|
|
60
78
|
{addonLeft ? <Button.Addon tag={addonLeft} /> : null}
|
|
61
79
|
{addonTextChildren(Children, Button.Text, Button.Addon)}
|