@semcore/button 4.0.12 → 4.0.13
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 +6 -0
- package/lib/cjs/Button.js +39 -29
- package/lib/cjs/Button.js.map +1 -1
- package/lib/es6/Button.js +35 -29
- package/lib/es6/Button.js.map +1 -1
- package/package.json +1 -1
- package/src/Button.jsx +20 -1
package/CHANGELOG.md
CHANGED
package/lib/cjs/Button.js
CHANGED
|
@@ -33,6 +33,10 @@ 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
|
+
|
|
36
40
|
var _SpinButton = _interopRequireDefault(require("./SpinButton"));
|
|
37
41
|
|
|
38
42
|
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 +56,36 @@ var style = (
|
|
|
52
56
|
/*__reshadow_css_start__*/
|
|
53
57
|
_core.sstyled.insert(
|
|
54
58
|
/*__inner_css_start__*/
|
|
55
|
-
".
|
|
59
|
+
".___SButton_15cgj_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_15cgj_gg_::-moz-focus-inner{padding:0;border:none}.___SButton_15cgj_gg_:active,.___SButton_15cgj_gg_:focus,.___SButton_15cgj_gg_:hover{outline:0;text-decoration:none}.___SButton_15cgj_gg_.__disabled_15cgj_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SButton_15cgj_gg_.__keyboardFocused_15cgj_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2);z-index:1}.___SButton_15cgj_gg_._size_m_15cgj_gg_{height:28px;min-width:28px;border-radius:6px;font-size:14px}.___SButton_15cgj_gg_._size_l_15cgj_gg_{height:40px;min-width:40px;border-radius:6px;font-size:16px}.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_{color:#ffffff;background-color:#008ff8}.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_:hover{background-color:#006dca}.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_.__active_15cgj_gg_{background-color:#044792}.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_{color:#ffffff;background-color:#009f81}.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_:hover{background-color:#007c65}.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_.__active_15cgj_gg_{background-color:#055345}.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_{background-color:#ff642d;color:#ffffff}.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_:hover{background-color:#c33909}.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_.__active_15cgj_gg_{background-color:#8b1500}.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_{background-color:#ff4953;color:#ffffff}.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_:hover{background-color:#d1002f}.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_.__active_15cgj_gg_{background-color:#8e0016}.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_{background-color:#fff;color:#191b23}.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_:hover{background-color:#f4f5f9}.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_.__active_15cgj_gg_{background-color:#e0e1e9}.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_{color:#6c6e79;border-color:#c4c7cf;background-color:rgba(138,142,155,.1)}.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_{background-color:rgba(0,143,248,.05);color:#008ff8;border-color:#008ff8}.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_:hover{background-color:rgba(0,109,202,.2)}.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(0,109,202,.3)}.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_{background-color:hsla(0,0%,100%,.05);color:#fff;border-color:#fff}.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_.__active_15cgj_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_{color:#006dca;background-color:transparent}.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_:hover{background-color:rgba(0,143,248,.2)}.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(0,143,248,.3)}.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_{color:#6c6e79;background-color:transparent}.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_{color:#fff;background-color:transparent}.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_.__active_15cgj_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_15cgj_gg_._neighborLocation_right_15cgj_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_{border-radius:0;margin-left:-1px}.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-danger_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-info_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-success_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-warning_15cgj_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-invert_15cgj_gg_{border-left-color:rgba(0,0,0,.5)}.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-danger_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-info_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-success_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-warning_15cgj_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-invert_15cgj_gg_{border-left-color:rgba(0,0,0,.5)}.___SSpin_15cgj_gg_{position:absolute;top:0;left:0;width:100%;height:100%;display:flex}.___SInner_15cgj_gg_{display:inline-flex;align-items:center;justify-content:center;height:100%;width:100%}.___SInner_15cgj_gg_.__loading_15cgj_gg_{visibility:hidden}.___SText_15cgj_gg_{display:inline-flex}.___SText_15cgj_gg_._size_m_15cgj_gg_{margin-left:8px;margin-right:8px;line-height:1.42}.___SText_15cgj_gg_._size_l_15cgj_gg_{margin-left:12px;margin-right:12px;line-height:1.5}.___SAddon_15cgj_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_15cgj_gg_._size_m_15cgj_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_15cgj_gg_._size_m_15cgj_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_15cgj_gg_._size_m_15cgj_gg_:only-child{margin-left:-4px;margin-right:-4px}.___SAddon_15cgj_gg_._size_l_15cgj_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_15cgj_gg_._size_l_15cgj_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_15cgj_gg_._size_l_15cgj_gg_:only-child{margin-left:-4px;margin-right:-4px}"
|
|
56
60
|
/*__inner_css_end__*/
|
|
57
|
-
, "
|
|
61
|
+
, "15cgj_gg_")
|
|
58
62
|
/*__reshadow_css_end__*/
|
|
59
63
|
, {
|
|
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": "
|
|
64
|
+
"__SButton": "___SButton_15cgj_gg_",
|
|
65
|
+
"_disabled": "__disabled_15cgj_gg_",
|
|
66
|
+
"_keyboardFocused": "__keyboardFocused_15cgj_gg_",
|
|
67
|
+
"_size_m": "_size_m_15cgj_gg_",
|
|
68
|
+
"_size_l": "_size_l_15cgj_gg_",
|
|
69
|
+
"_theme_primary-info": "_theme_primary-info_15cgj_gg_",
|
|
70
|
+
"_active": "__active_15cgj_gg_",
|
|
71
|
+
"_theme_primary-success": "_theme_primary-success_15cgj_gg_",
|
|
72
|
+
"_theme_primary-warning": "_theme_primary-warning_15cgj_gg_",
|
|
73
|
+
"_theme_primary-danger": "_theme_primary-danger_15cgj_gg_",
|
|
74
|
+
"_theme_primary-invert": "_theme_primary-invert_15cgj_gg_",
|
|
75
|
+
"_theme_secondary-muted": "_theme_secondary-muted_15cgj_gg_",
|
|
76
|
+
"_theme_secondary-info": "_theme_secondary-info_15cgj_gg_",
|
|
77
|
+
"_theme_secondary-invert": "_theme_secondary-invert_15cgj_gg_",
|
|
78
|
+
"_theme_tertiary-info": "_theme_tertiary-info_15cgj_gg_",
|
|
79
|
+
"_theme_tertiary-muted": "_theme_tertiary-muted_15cgj_gg_",
|
|
80
|
+
"_theme_tertiary-invert": "_theme_tertiary-invert_15cgj_gg_",
|
|
81
|
+
"_neighborLocation_right": "_neighborLocation_right_15cgj_gg_",
|
|
82
|
+
"_neighborLocation_both": "_neighborLocation_both_15cgj_gg_",
|
|
83
|
+
"_neighborLocation_left": "_neighborLocation_left_15cgj_gg_",
|
|
84
|
+
"__SSpin": "___SSpin_15cgj_gg_",
|
|
85
|
+
"__SInner": "___SInner_15cgj_gg_",
|
|
86
|
+
"_loading": "__loading_15cgj_gg_",
|
|
87
|
+
"__SText": "___SText_15cgj_gg_",
|
|
88
|
+
"__SAddon": "___SAddon_15cgj_gg_"
|
|
85
89
|
});
|
|
86
90
|
var MAP_USE_DEFAULT_THEME = {
|
|
87
91
|
primary: 'info',
|
|
@@ -136,13 +140,19 @@ var RootButton = /*#__PURE__*/function (_Component) {
|
|
|
136
140
|
disabled = _this$asProps$disable === void 0 ? loading : _this$asProps$disable,
|
|
137
141
|
size = _this$asProps.size,
|
|
138
142
|
addonLeft = _this$asProps.addonLeft,
|
|
139
|
-
addonRight = _this$asProps.addonRight
|
|
143
|
+
addonRight = _this$asProps.addonRight,
|
|
144
|
+
ariaLabel = _this$asProps['aria-label'];
|
|
140
145
|
var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
|
|
146
|
+
var isTextInside = (0, _reactToText["default"])(Children);
|
|
147
|
+
|
|
148
|
+
_logger["default"].warn(!isTextInside && !ariaLabel, 'aria-label is required', this.asProps['data-ui-name'] || Button.displayName);
|
|
149
|
+
|
|
141
150
|
return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SButton, _ref4.cn("SButton", _objectSpread({}, (0, _core.assignProps)({
|
|
142
151
|
"type": "button",
|
|
143
152
|
"tag": "button",
|
|
144
153
|
"disabled": disabled,
|
|
145
|
-
"use:theme": useTheme
|
|
154
|
+
"use:theme": useTheme,
|
|
155
|
+
"role": "button"
|
|
146
156
|
}, _ref))), /*#__PURE__*/_react["default"].createElement(SInner, _ref4.cn("SInner", {
|
|
147
157
|
"tag": "span",
|
|
148
158
|
"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","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 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\n const useTheme = use && theme ? `${use}-${theme}` : false;\n\n const isTextInside = reactToText(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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,qBAAqB,GAAG;EACnCC,OAAO,EAAE,MAD0B;EAEnCC,SAAS,EAAE,OAFwB;EAGnCC,QAAQ,EAAE;AAHyB,CAA9B;;;IAMDC,U;;;;;;;;;;;;WAS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C,CAA5B,CAAf;eAKeL,M"}
|
package/lib/es6/Button.js
CHANGED
|
@@ -23,6 +23,8 @@ 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';
|
|
26
28
|
import SpinButton from './SpinButton';
|
|
27
29
|
|
|
28
30
|
/*__reshadow-styles__:"./style/button.shadow.css"*/
|
|
@@ -30,36 +32,36 @@ var style = (
|
|
|
30
32
|
/*__reshadow_css_start__*/
|
|
31
33
|
_sstyled.insert(
|
|
32
34
|
/*__inner_css_start__*/
|
|
33
|
-
".
|
|
35
|
+
".___SButton_15cgj_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_15cgj_gg_::-moz-focus-inner{padding:0;border:none}.___SButton_15cgj_gg_:active,.___SButton_15cgj_gg_:focus,.___SButton_15cgj_gg_:hover{outline:0;text-decoration:none}.___SButton_15cgj_gg_.__disabled_15cgj_gg_{opacity:0.3;cursor:default;pointer-events:none}.___SButton_15cgj_gg_.__keyboardFocused_15cgj_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2);z-index:1}.___SButton_15cgj_gg_._size_m_15cgj_gg_{height:28px;min-width:28px;border-radius:6px;font-size:14px}.___SButton_15cgj_gg_._size_l_15cgj_gg_{height:40px;min-width:40px;border-radius:6px;font-size:16px}.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_{color:#ffffff;background-color:#008ff8}.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_:hover{background-color:#006dca}.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-info_15cgj_gg_.__active_15cgj_gg_{background-color:#044792}.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_{color:#ffffff;background-color:#009f81}.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_:hover{background-color:#007c65}.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-success_15cgj_gg_.__active_15cgj_gg_{background-color:#055345}.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_{background-color:#ff642d;color:#ffffff}.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_:hover{background-color:#c33909}.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-warning_15cgj_gg_.__active_15cgj_gg_{background-color:#8b1500}.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_{background-color:#ff4953;color:#ffffff}.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_:hover{background-color:#d1002f}.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-danger_15cgj_gg_.__active_15cgj_gg_{background-color:#8e0016}.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_{background-color:#fff;color:#191b23}.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_:hover{background-color:#f4f5f9}.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_primary-invert_15cgj_gg_.__active_15cgj_gg_{background-color:#e0e1e9}.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_{color:#6c6e79;border-color:#c4c7cf;background-color:rgba(138,142,155,.1)}.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_secondary-muted_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_{background-color:rgba(0,143,248,.05);color:#008ff8;border-color:#008ff8}.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_:hover{background-color:rgba(0,109,202,.2)}.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_secondary-info_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(0,109,202,.3)}.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_{background-color:hsla(0,0%,100%,.05);color:#fff;border-color:#fff}.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_secondary-invert_15cgj_gg_.__active_15cgj_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_{color:#006dca;background-color:transparent}.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_:hover{background-color:rgba(0,143,248,.2)}.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_tertiary-info_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(0,143,248,.3)}.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_{color:#6c6e79;background-color:transparent}.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_:hover{background-color:rgba(138,142,155,.2);color:#191b23}.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_tertiary-muted_15cgj_gg_.__active_15cgj_gg_{background-color:rgba(138,142,155,.3);color:#191b23}.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_{color:#fff;background-color:transparent}.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_:hover{background-color:hsla(0,0%,100%,.1)}.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_:active,.___SButton_15cgj_gg_._theme_tertiary-invert_15cgj_gg_.__active_15cgj_gg_{background-color:hsla(0,0%,100%,.3)}.___SButton_15cgj_gg_._neighborLocation_right_15cgj_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_{border-radius:0;margin-left:-1px}.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-danger_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-info_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-success_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-warning_15cgj_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_15cgj_gg_._neighborLocation_both_15cgj_gg_._theme_primary-invert_15cgj_gg_{border-left-color:rgba(0,0,0,.5)}.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-danger_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-info_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-success_15cgj_gg_,.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-warning_15cgj_gg_{border-left-color:hsla(0,0%,100%,.5)}.___SButton_15cgj_gg_._neighborLocation_left_15cgj_gg_._theme_primary-invert_15cgj_gg_{border-left-color:rgba(0,0,0,.5)}.___SSpin_15cgj_gg_{position:absolute;top:0;left:0;width:100%;height:100%;display:flex}.___SInner_15cgj_gg_{display:inline-flex;align-items:center;justify-content:center;height:100%;width:100%}.___SInner_15cgj_gg_.__loading_15cgj_gg_{visibility:hidden}.___SText_15cgj_gg_{display:inline-flex}.___SText_15cgj_gg_._size_m_15cgj_gg_{margin-left:8px;margin-right:8px;line-height:1.42}.___SText_15cgj_gg_._size_l_15cgj_gg_{margin-left:12px;margin-right:12px;line-height:1.5}.___SAddon_15cgj_gg_{display:inline-flex;align-items:center;justify-content:center}.___SAddon_15cgj_gg_._size_m_15cgj_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_15cgj_gg_._size_m_15cgj_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_15cgj_gg_._size_m_15cgj_gg_:only-child{margin-left:-4px;margin-right:-4px}.___SAddon_15cgj_gg_._size_l_15cgj_gg_:not(:only-child):first-child{margin-left:8px}.___SAddon_15cgj_gg_._size_l_15cgj_gg_:not(:only-child):last-child{margin-right:8px}.___SAddon_15cgj_gg_._size_l_15cgj_gg_:only-child{margin-left:-4px;margin-right:-4px}"
|
|
34
36
|
/*__inner_css_end__*/
|
|
35
|
-
, "
|
|
37
|
+
, "15cgj_gg_")
|
|
36
38
|
/*__reshadow_css_end__*/
|
|
37
39
|
, {
|
|
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": "
|
|
40
|
+
"__SButton": "___SButton_15cgj_gg_",
|
|
41
|
+
"_disabled": "__disabled_15cgj_gg_",
|
|
42
|
+
"_keyboardFocused": "__keyboardFocused_15cgj_gg_",
|
|
43
|
+
"_size_m": "_size_m_15cgj_gg_",
|
|
44
|
+
"_size_l": "_size_l_15cgj_gg_",
|
|
45
|
+
"_theme_primary-info": "_theme_primary-info_15cgj_gg_",
|
|
46
|
+
"_active": "__active_15cgj_gg_",
|
|
47
|
+
"_theme_primary-success": "_theme_primary-success_15cgj_gg_",
|
|
48
|
+
"_theme_primary-warning": "_theme_primary-warning_15cgj_gg_",
|
|
49
|
+
"_theme_primary-danger": "_theme_primary-danger_15cgj_gg_",
|
|
50
|
+
"_theme_primary-invert": "_theme_primary-invert_15cgj_gg_",
|
|
51
|
+
"_theme_secondary-muted": "_theme_secondary-muted_15cgj_gg_",
|
|
52
|
+
"_theme_secondary-info": "_theme_secondary-info_15cgj_gg_",
|
|
53
|
+
"_theme_secondary-invert": "_theme_secondary-invert_15cgj_gg_",
|
|
54
|
+
"_theme_tertiary-info": "_theme_tertiary-info_15cgj_gg_",
|
|
55
|
+
"_theme_tertiary-muted": "_theme_tertiary-muted_15cgj_gg_",
|
|
56
|
+
"_theme_tertiary-invert": "_theme_tertiary-invert_15cgj_gg_",
|
|
57
|
+
"_neighborLocation_right": "_neighborLocation_right_15cgj_gg_",
|
|
58
|
+
"_neighborLocation_both": "_neighborLocation_both_15cgj_gg_",
|
|
59
|
+
"_neighborLocation_left": "_neighborLocation_left_15cgj_gg_",
|
|
60
|
+
"__SSpin": "___SSpin_15cgj_gg_",
|
|
61
|
+
"__SInner": "___SInner_15cgj_gg_",
|
|
62
|
+
"_loading": "__loading_15cgj_gg_",
|
|
63
|
+
"__SText": "___SText_15cgj_gg_",
|
|
64
|
+
"__SAddon": "___SAddon_15cgj_gg_"
|
|
63
65
|
});
|
|
64
66
|
export var MAP_USE_DEFAULT_THEME = {
|
|
65
67
|
primary: 'info',
|
|
@@ -114,13 +116,17 @@ var RootButton = /*#__PURE__*/function (_Component) {
|
|
|
114
116
|
disabled = _this$asProps$disable === void 0 ? loading : _this$asProps$disable,
|
|
115
117
|
size = _this$asProps.size,
|
|
116
118
|
addonLeft = _this$asProps.addonLeft,
|
|
117
|
-
addonRight = _this$asProps.addonRight
|
|
119
|
+
addonRight = _this$asProps.addonRight,
|
|
120
|
+
ariaLabel = _this$asProps['aria-label'];
|
|
118
121
|
var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
|
|
122
|
+
var isTextInside = reactToText(Children);
|
|
123
|
+
logger.warn(!isTextInside && !ariaLabel, 'aria-label is required', this.asProps['data-ui-name'] || Button.displayName);
|
|
119
124
|
return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SButton, _ref4.cn("SButton", _objectSpread({}, _assignProps({
|
|
120
125
|
"type": "button",
|
|
121
126
|
"tag": "button",
|
|
122
127
|
"disabled": disabled,
|
|
123
|
-
"use:theme": useTheme
|
|
128
|
+
"use:theme": useTheme,
|
|
129
|
+
"role": "button"
|
|
124
130
|
}, _ref))), /*#__PURE__*/React.createElement(SInner, _ref4.cn("SInner", {
|
|
125
131
|
"tag": "span",
|
|
126
132
|
"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\n const useTheme = use && theme ? `${use}-${theme}` : false;\n return sstyled(styles)(\n <SButton
|
|
1
|
+
{"version":3,"file":"Button.js","names":["React","createComponent","Component","sstyled","Root","Box","neighborLocationEnhance","keyboardFocusEnhance","addonTextChildren","logger","reactToText","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 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\n const useTheme = use && theme ? `${use}-${theme}` : false;\n\n const isTextInside = reactToText(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,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;QACLA,IAAI,EAAJA;MADK,CAAP;IAGD;;;WAED,kBAAS;MAAA;MAAA;;MACP,IAAME,OAAO,GA4BDd,GA5BZ;MACA,IAAMe,MAAM,GAAGf,GAAf;MACA,IAAMgB,KAAK,GAAGhB,GAAd;MACA,oBAWI,KAAKa,OAXT;MAAA,IACEI,QADF,iBACEA,QADF;MAAA,IAEEC,MAFF,iBAEEA,MAFF;MAAA,IAGEC,GAHF,iBAGEA,GAHF;MAAA,wCAIEC,KAJF;MAAA,IAIEA,KAJF,oCAIU,OAAOD,GAAP,KAAe,QAAf,IAA2BZ,qBAAqB,CAACY,GAAD,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AhD,C;;gBAFbU,U,WAGWsB,K;;gBAHXtB,U,kBAIkB;EACpBQ,GAAG,EAAE,WADe;EAEpBP,IAAI,EAAE;AAFc,C;;AAsExB,SAASmB,IAAT,CAAcG,KAAd,EAAqB;EAAA;EAAA;;EACnB,IAAMC,KAAK,GACiCnC,GAD5C;EACA,eAAOF,OAAO,CAACoC,KAAK,CAAChB,MAAP,CAAd,eAA6B,oBAAC,KAAD;IAAA,OAAwB;EAAxB,YAA7B;AACD;;AAED,SAASc,KAAT,CAAeE,KAAf,EAAsB;EAAA;EAAA;;EACpB,IAAME,MAAM,GACiCpC,GAD7C;EACA,eAAOF,OAAO,CAACoC,KAAK,CAAChB,MAAP,CAAd,eAA6B,oBAAC,MAAD;IAAA,OAAyB;EAAzB,YAA7B;AACD;;AAED,IAAMW,MAAM,GAAGjC,eAAe,CAACe,UAAD,EAAa;EACzCoB,IAAI,EAAJA,IADyC;EAEzCC,KAAK,EAALA;AAFyC,CAAb,CAA9B;AAKA,eAAeH,MAAf"}
|
package/package.json
CHANGED
package/src/Button.jsx
CHANGED
|
@@ -4,6 +4,8 @@ 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';
|
|
7
9
|
import SpinButton from './SpinButton';
|
|
8
10
|
|
|
9
11
|
import style from './style/button.shadow.css';
|
|
@@ -51,11 +53,28 @@ class RootButton extends Component {
|
|
|
51
53
|
size,
|
|
52
54
|
addonLeft,
|
|
53
55
|
addonRight,
|
|
56
|
+
'aria-label': ariaLabel,
|
|
54
57
|
} = this.asProps;
|
|
55
58
|
|
|
56
59
|
const useTheme = use && theme ? `${use}-${theme}` : false;
|
|
60
|
+
|
|
61
|
+
const isTextInside = reactToText(Children);
|
|
62
|
+
|
|
63
|
+
logger.warn(
|
|
64
|
+
!isTextInside && !ariaLabel,
|
|
65
|
+
'aria-label is required',
|
|
66
|
+
this.asProps['data-ui-name'] || Button.displayName,
|
|
67
|
+
);
|
|
68
|
+
|
|
57
69
|
return sstyled(styles)(
|
|
58
|
-
<SButton
|
|
70
|
+
<SButton
|
|
71
|
+
render={Box}
|
|
72
|
+
type="button"
|
|
73
|
+
tag="button"
|
|
74
|
+
disabled={disabled}
|
|
75
|
+
use:theme={useTheme}
|
|
76
|
+
role="button"
|
|
77
|
+
>
|
|
59
78
|
<SInner tag="span" loading={loading}>
|
|
60
79
|
{addonLeft ? <Button.Addon tag={addonLeft} /> : null}
|
|
61
80
|
{addonTextChildren(Children, Button.Text, Button.Addon)}
|