@semcore/button 16.0.12 → 16.0.13-prerelease.9
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/README.md +4 -4
- package/lib/cjs/component/AbstractButton/AbstractButton.js +100 -165
- package/lib/cjs/component/AbstractButton/AbstractButton.js.map +1 -1
- package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +1 -1
- package/lib/cjs/component/AbstractButton/SpinButton.js +9 -10
- package/lib/cjs/component/AbstractButton/SpinButton.js.map +1 -1
- package/lib/cjs/component/Button/Button.js +54 -63
- package/lib/cjs/component/Button/Button.js.map +1 -1
- package/lib/cjs/component/Button/Button.type.js.map +1 -1
- package/lib/cjs/component/ButtonLink/ButtonLink.js +51 -59
- package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
- package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +7 -7
- package/lib/cjs/index.js +7 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/component/AbstractButton/AbstractButton.js +97 -164
- package/lib/es6/component/AbstractButton/AbstractButton.js.map +1 -1
- package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +1 -1
- package/lib/es6/component/AbstractButton/SpinButton.js +6 -7
- package/lib/es6/component/AbstractButton/SpinButton.js.map +1 -1
- package/lib/es6/component/Button/Button.js +47 -56
- package/lib/es6/component/Button/Button.js.map +1 -1
- package/lib/es6/component/Button/Button.type.js.map +1 -1
- package/lib/es6/component/ButtonLink/ButtonLink.js +44 -52
- package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
- package/lib/es6/component/ButtonLink/buttonLink.shadow.css +7 -7
- package/lib/esm/component/AbstractButton/AbstractButton.mjs +98 -136
- package/lib/esm/component/AbstractButton/SpinButton.mjs +6 -6
- package/lib/esm/component/Button/Button.mjs +47 -56
- package/lib/esm/component/ButtonLink/ButtonLink.mjs +44 -50
- package/lib/esm/component/ButtonLink/buttonLink.shadow.css +7 -7
- package/lib/types/component/AbstractButton/AbstractButton.d.ts +5 -6
- package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +2 -4
- package/lib/types/component/Button/Button.type.d.ts +2 -18
- package/package.json +5 -8
- package/src/component/AbstractButton/AbstractButton.tsx +58 -77
- package/src/component/AbstractButton/AbstractButton.type.ts +2 -4
- package/src/component/Button/Button.tsx +1 -1
- package/src/component/Button/Button.type.ts +1 -14
- package/src/component/ButtonLink/ButtonLink.tsx +1 -1
- package/src/component/ButtonLink/buttonLink.shadow.css +7 -7
|
@@ -1,59 +1,47 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
2
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
8
3
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
9
4
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
5
|
+
import { Box } from '@semcore/base-components';
|
|
10
6
|
import { createComponent, sstyled, Root } from '@semcore/core';
|
|
11
7
|
import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
|
|
12
|
-
import { Box } from '@semcore/flex-box';
|
|
13
8
|
import React from 'react';
|
|
14
9
|
/*!__reshadow-styles__:"./buttonLink.shadow.css"*/
|
|
15
|
-
|
|
10
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SButton_o1yge_gg_{display:inline-flex;font-family:inherit;font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-link, #006dca);line-height:normal;position:relative;cursor:pointer;border:0;padding:0;margin:0;box-shadow:none;-webkit-tap-highlight-color:transparent;background:0 0;transition:color .15s ease-in-out}.___SButton_o1yge_gg_,.___SButton_o1yge_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SButton_o1yge_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___SButton_o1yge_gg_::-moz-focus-inner{border:0;padding:0}.___SButton_o1yge_gg_.__active_o1yge_gg_,.___SButton_o1yge_gg_:active{color:var(--intergalactic-text-link-hover-active, #044792)}@media (hover:hover){.___SButton_o1yge_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___SButton_o1yge_gg_.__active_o1yge_gg_ .___SText_o1yge_gg_,.___SButton_o1yge_gg_:active .___SText_o1yge_gg_{box-shadow:0 1px 0 0 currentColor}@media (hover:hover){.___SButton_o1yge_gg_:hover .___SText_o1yge_gg_{box-shadow:0 1px 0 0 currentColor}}.___SButton_o1yge_gg_.__enableVisited_o1yge_gg_:visited{color:var(--intergalactic-text-link-visited, #8649e1)}@media (hover:hover){.___SButton_o1yge_gg_.__enableVisited_o1yge_gg_:visited:hover{color:var(--intergalactic-text-link-visited, #8649e1)}}.___SButton_o1yge_gg_ .___SText_o1yge_gg_{box-shadow:0 1px 0 0 transparent;transition:box-shadow .15s ease-in-out}.___SButton_o1yge_gg_.__disabled_o1yge_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SButton_o1yge_gg_._use_secondary_o1yge_gg_{color:var(--intergalactic-text-hint, #6c6e79)}.___SButton_o1yge_gg_._use_secondary_o1yge_gg_.__active_o1yge_gg_,.___SButton_o1yge_gg_._use_secondary_o1yge_gg_:active{color:var(--intergalactic-text-hint-hover-active, #484a54)}@media (hover:hover){.___SButton_o1yge_gg_._use_secondary_o1yge_gg_:hover{color:var(--intergalactic-text-hint-hover-active, #484a54)}}.___SButton_o1yge_gg_._use_secondary_o1yge_gg_ .___SText_o1yge_gg_{box-shadow:none;border-bottom-width:1px;border-bottom-style:dashed;border-color:currentColor}.___SAddon_o1yge_gg_,.___SInner_o1yge_gg_{display:inline-flex;justify-content:center;align-items:baseline}.___SInner_o1yge_gg_{height:100%;width:100%}.___SAddon_o1yge_gg_{vertical-align:middle;pointer-events:none;align-self:center}.___SButton_o1yge_gg_ .___SAddon_o1yge_gg_:not(:only-child):first-child{margin-right:var(--intergalactic-spacing-1x, 4px)}.___SButton_o1yge_gg_ .___SAddon_o1yge_gg_:not(:only-child):last-child{margin-left:var(--intergalactic-spacing-1x, 4px)}.___SButton_o1yge_gg_.__text-color_o1yge_gg_{color:var(--text-color_o1yge)}.___SButton_o1yge_gg_.__text-color_o1yge_gg_.__active_o1yge_gg_,.___SButton_o1yge_gg_.__text-color_o1yge_gg_:active{color:var(--text-color_o1yge);filter:brightness(.8)}@media (hover:hover){.___SButton_o1yge_gg_.__text-color_o1yge_gg_:hover{color:var(--text-color_o1yge);filter:brightness(.8)}}.___SButton_o1yge_gg_._size_100_o1yge_gg_{font-size:var(--intergalactic-fs-100, 12px);line-height:var(--intergalactic-lh-100, 133%)}.___SButton_o1yge_gg_._size_200_o1yge_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SButton_o1yge_gg_._size_300_o1yge_gg_{font-size:var(--intergalactic-fs-300, 16px);line-height:var(--intergalactic-lh-300, 150%)}.___SButton_o1yge_gg_._size_400_o1yge_gg_{font-size:var(--intergalactic-fs-400, 20px);line-height:var(--intergalactic-lh-400, 120%)}.___SButton_o1yge_gg_._size_500_o1yge_gg_{font-size:var(--intergalactic-fs-500, 24px);line-height:var(--intergalactic-lh-500, 117%)}.___SButton_o1yge_gg_._size_600_o1yge_gg_{font-size:var(--intergalactic-fs-600, 32px);line-height:var(--intergalactic-lh-600, 125%)}.___SButton_o1yge_gg_._size_700_o1yge_gg_{font-size:var(--intergalactic-fs-700, 36px);line-height:var(--intergalactic-lh-700, 110%)}.___SButton_o1yge_gg_._size_800_o1yge_gg_{font-size:var(--intergalactic-fs-800, 48px);line-height:var(--intergalactic-lh-800, 117%)}@media (prefers-reduced-motion){.___SButton_o1yge_gg_,.___SText_o1yge_gg_{transition:none}}", /*__inner_css_end__*/"o1yge_gg_"),
|
|
16
11
|
/*__reshadow_css_end__*/
|
|
17
12
|
{
|
|
18
|
-
"__SButton": "
|
|
19
|
-
"_disabled": "
|
|
20
|
-
"__SInner": "
|
|
21
|
-
"__SAddon": "
|
|
22
|
-
"_size_100": "
|
|
23
|
-
"_size_200": "
|
|
24
|
-
"_size_300": "
|
|
25
|
-
"_size_400": "
|
|
26
|
-
"_size_500": "
|
|
27
|
-
"_size_600": "
|
|
28
|
-
"_size_700": "
|
|
29
|
-
"_size_800": "
|
|
30
|
-
"__SText": "
|
|
31
|
-
"_active": "
|
|
32
|
-
"_enableVisited": "
|
|
33
|
-
"_use_secondary": "
|
|
34
|
-
"_text-color": "__text-
|
|
35
|
-
"--text-color": "--text-
|
|
13
|
+
"__SButton": "___SButton_o1yge_gg_",
|
|
14
|
+
"_disabled": "__disabled_o1yge_gg_",
|
|
15
|
+
"__SInner": "___SInner_o1yge_gg_",
|
|
16
|
+
"__SAddon": "___SAddon_o1yge_gg_",
|
|
17
|
+
"_size_100": "_size_100_o1yge_gg_",
|
|
18
|
+
"_size_200": "_size_200_o1yge_gg_",
|
|
19
|
+
"_size_300": "_size_300_o1yge_gg_",
|
|
20
|
+
"_size_400": "_size_400_o1yge_gg_",
|
|
21
|
+
"_size_500": "_size_500_o1yge_gg_",
|
|
22
|
+
"_size_600": "_size_600_o1yge_gg_",
|
|
23
|
+
"_size_700": "_size_700_o1yge_gg_",
|
|
24
|
+
"_size_800": "_size_800_o1yge_gg_",
|
|
25
|
+
"__SText": "___SText_o1yge_gg_",
|
|
26
|
+
"_active": "__active_o1yge_gg_",
|
|
27
|
+
"_enableVisited": "__enableVisited_o1yge_gg_",
|
|
28
|
+
"_use_secondary": "_use_secondary_o1yge_gg_",
|
|
29
|
+
"_text-color": "__text-color_o1yge_gg_",
|
|
30
|
+
"--text-color": "--text-color_o1yge"
|
|
36
31
|
});
|
|
37
32
|
import { AbstractButton } from '../AbstractButton/AbstractButton';
|
|
38
|
-
|
|
33
|
+
const enhance = {
|
|
39
34
|
resolveColor: resolveColorEnhance()
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
class RootButtonLink extends AbstractButton {
|
|
37
|
+
getTextColor() {
|
|
38
|
+
const {
|
|
39
|
+
color,
|
|
40
|
+
resolveColor
|
|
41
|
+
} = this.asProps;
|
|
42
|
+
return resolveColor(color);
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
return _createClass(RootButtonLink, [{
|
|
48
|
-
key: "getTextColor",
|
|
49
|
-
value: function getTextColor() {
|
|
50
|
-
var _ref5 = this.asProps,
|
|
51
|
-
color = _ref5.color,
|
|
52
|
-
resolveColor = _ref5.resolveColor;
|
|
53
|
-
return resolveColor(color);
|
|
54
|
-
}
|
|
55
|
-
}]);
|
|
56
|
-
}(AbstractButton);
|
|
44
|
+
}
|
|
57
45
|
_defineProperty(RootButtonLink, "displayName", 'ButtonLink');
|
|
58
46
|
_defineProperty(RootButtonLink, "enhance", Object.values(enhance));
|
|
59
47
|
_defineProperty(RootButtonLink, "style", style);
|
|
@@ -63,21 +51,25 @@ _defineProperty(RootButtonLink, "defaultProps", {
|
|
|
63
51
|
function Text(props) {
|
|
64
52
|
var _ref = arguments[0],
|
|
65
53
|
_ref3;
|
|
66
|
-
|
|
67
|
-
return _ref3 = sstyled(props.styles), /*#__PURE__*/React.createElement(SText, _ref3.cn("SText",
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
const SText = Box;
|
|
55
|
+
return _ref3 = sstyled(props.styles), /*#__PURE__*/React.createElement(SText, _ref3.cn("SText", {
|
|
56
|
+
..._assignProps({
|
|
57
|
+
"tag": 'span'
|
|
58
|
+
}, _ref)
|
|
59
|
+
}));
|
|
70
60
|
}
|
|
71
61
|
function Addon(props) {
|
|
72
62
|
var _ref2 = arguments[0],
|
|
73
63
|
_ref4;
|
|
74
|
-
|
|
75
|
-
return _ref4 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref4.cn("SAddon",
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
const SAddon = Box;
|
|
65
|
+
return _ref4 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref4.cn("SAddon", {
|
|
66
|
+
..._assignProps2({
|
|
67
|
+
"tag": 'span'
|
|
68
|
+
}, _ref2)
|
|
69
|
+
}));
|
|
78
70
|
}
|
|
79
|
-
export
|
|
80
|
-
Text
|
|
81
|
-
Addon
|
|
71
|
+
export const ButtonLink = createComponent(RootButtonLink, {
|
|
72
|
+
Text,
|
|
73
|
+
Addon
|
|
82
74
|
});
|
|
83
75
|
//# sourceMappingURL=ButtonLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonLink.js","names":["createComponent","sstyled","Root","resolveColorEnhance","
|
|
1
|
+
{"version":3,"file":"ButtonLink.js","names":["Box","createComponent","sstyled","Root","resolveColorEnhance","React","style","_sstyled","insert","AbstractButton","enhance","resolveColor","RootButtonLink","getTextColor","color","asProps","_defineProperty","Object","values","use","Text","props","_ref","arguments[0]","_ref3","SText","styles","createElement","cn","_assignProps","Addon","_ref2","_ref4","SAddon","_assignProps2","ButtonLink"],"sources":["../../../../src/component/ButtonLink/ButtonLink.tsx"],"sourcesContent":["import { Box } from '@semcore/base-components';\nimport { createComponent, sstyled, Root } from '@semcore/core';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport React from 'react';\n\nimport style from './buttonLink.shadow.css';\nimport type { ButtonLinkAddonProps, ButtonLinkComponent, ButtonLinkTextProps } from './ButtonLink.type';\nimport { AbstractButton } from '../AbstractButton/AbstractButton';\n\nconst enhance = {\n resolveColor: resolveColorEnhance(),\n};\n\nclass RootButtonLink extends AbstractButton {\n static displayName = 'ButtonLink';\n static enhance = Object.values(enhance);\n static style = style;\n static defaultProps = {\n use: 'primary',\n };\n\n protected getTextColor(): string | undefined {\n const { color, resolveColor } = this.asProps as any;\n return resolveColor(color);\n }\n}\n\nfunction Text(props: ButtonLinkTextProps) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: ButtonLinkAddonProps) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const ButtonLink = createComponent(RootButtonLink, {\n Text,\n Addon,\n}) as ButtonLinkComponent;\n"],"mappings":";;;;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,eAAe,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAC9D,OAAOC,mBAAmB,MAAM,sDAAsD;AACtF,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI1B,SAASC,cAAc,QAAQ,kCAAkC;AAEjE,MAAMC,OAAO,GAAG;EACdC,YAAY,EAAEP,mBAAmB,CAAC;AACpC,CAAC;AAED,MAAMQ,cAAc,SAASH,cAAc,CAAC;EAQhCI,YAAYA,CAAA,EAAuB;IAC3C,MAAM;MAAEC,KAAK;MAAEH;IAAa,CAAC,GAAG,IAAI,CAACI,OAAc;IACnD,OAAOJ,YAAY,CAACG,KAAK,CAAC;EAC5B;AACF;AAACE,eAAA,CAZKJ,cAAc,iBACG,YAAY;AAAAI,eAAA,CAD7BJ,cAAc,aAEDK,MAAM,CAACC,MAAM,CAACR,OAAO,CAAC;AAAAM,eAAA,CAFnCJ,cAAc,WAGHN,KAAK;AAAAU,eAAA,CAHhBJ,cAAc,kBAII;EACpBO,GAAG,EAAE;AACP,CAAC;AAQH,SAASC,IAAIA,CAACC,KAA0B,EAAE;EAAA,IAAAC,IAAA,GAAAC,YAAA;IAAAC,KAAA;EACxC,MAAMC,KAAK,GACiCzB,GAAG;EAA/C,OAAAwB,KAAA,GAAOtB,OAAO,CAACmB,KAAK,CAACK,MAAM,CAAC,eAACrB,KAAA,CAAAsB,aAAA,CAACF,KAAK,EAAAD,KAAA,CAAAI,EAAA;IAAA,GAAAC,YAAA;MAAA,OAAkB;IAAM,GAAAP,IAAA;EAAA,EAAE,CAAC;AAChE;AAEA,SAASQ,KAAKA,CAACT,KAA2B,EAAE;EAAA,IAAAU,KAAA,GAAAR,YAAA;IAAAS,KAAA;EAC1C,MAAMC,MAAM,GACiCjC,GAAG;EAAhD,OAAAgC,KAAA,GAAO9B,OAAO,CAACmB,KAAK,CAACK,MAAM,CAAC,eAACrB,KAAA,CAAAsB,aAAA,CAACM,MAAM,EAAAD,KAAA,CAAAJ,EAAA;IAAA,GAAAM,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AACjE;AAEA,OAAO,MAAMI,UAAU,GAAGlC,eAAe,CAACW,cAAc,EAAE;EACxDQ,IAAI;EACJU;AACF,CAAC,CAAwB","ignoreList":[]}
|
|
@@ -31,7 +31,7 @@ SButton {
|
|
|
31
31
|
color: var(--intergalactic-text-link-hover-active, #044792);
|
|
32
32
|
|
|
33
33
|
& SText {
|
|
34
|
-
|
|
34
|
+
box-shadow: 0 1px 0 0 currentColor;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -41,10 +41,8 @@ SButton {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
SText {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
border-color: transparent;
|
|
47
|
-
transition: border-bottom-color 0.15s ease-in-out;
|
|
44
|
+
box-shadow: 0 1px 0 0 transparent;
|
|
45
|
+
transition: box-shadow 0.15s ease-in-out;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -65,6 +63,7 @@ SButton[use='secondary'] {
|
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
SText {
|
|
66
|
+
box-shadow: none;
|
|
68
67
|
border-bottom-width: 1px;
|
|
69
68
|
border-bottom-style: dashed;
|
|
70
69
|
border-color: currentColor;
|
|
@@ -73,7 +72,7 @@ SButton[use='secondary'] {
|
|
|
73
72
|
|
|
74
73
|
SInner {
|
|
75
74
|
display: inline-flex;
|
|
76
|
-
align-items:
|
|
75
|
+
align-items: baseline;
|
|
77
76
|
justify-content: center;
|
|
78
77
|
height: 100%;
|
|
79
78
|
width: 100%;
|
|
@@ -82,9 +81,10 @@ SInner {
|
|
|
82
81
|
SAddon {
|
|
83
82
|
display: inline-flex;
|
|
84
83
|
justify-content: center;
|
|
85
|
-
align-items:
|
|
84
|
+
align-items: baseline;
|
|
86
85
|
vertical-align: middle;
|
|
87
86
|
pointer-events: none;
|
|
87
|
+
align-self: center;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
SButton SAddon {
|
|
@@ -1,155 +1,117 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import {
|
|
2
|
+
import { Component, CORE_INSTANCE, sstyled, assignProps } from "@semcore/core";
|
|
3
|
+
import { NeighborLocation, Box, Hint } from "@semcore/base-components";
|
|
8
4
|
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
9
5
|
import hasLabels from "@semcore/core/lib/utils/hasLabels";
|
|
10
6
|
import logger from "@semcore/core/lib/utils/logger";
|
|
11
|
-
import { Box } from "@semcore/flex-box";
|
|
12
|
-
import NeighborLocation from "@semcore/neighbor-location";
|
|
13
|
-
import { Hint } from "@semcore/tooltip";
|
|
14
7
|
import React from "react";
|
|
15
8
|
import SpinButton from "./SpinButton.mjs";
|
|
16
|
-
|
|
9
|
+
const MAP_USE_DEFAULT_THEME = {
|
|
17
10
|
primary: "info",
|
|
18
11
|
secondary: "muted",
|
|
19
12
|
tertiary: "info"
|
|
20
13
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
args[_key] = arguments[_key];
|
|
27
|
-
}
|
|
28
|
-
_this = _callSuper(this, AbstractButton2, [].concat(args));
|
|
29
|
-
_defineProperty(_this, "containerRef", /* @__PURE__ */ React.createRef());
|
|
30
|
-
_defineProperty(_this, "state", {
|
|
14
|
+
class AbstractButton extends Component {
|
|
15
|
+
constructor(...args) {
|
|
16
|
+
super(...args);
|
|
17
|
+
_defineProperty(this, "containerRef", /* @__PURE__ */ React.createRef());
|
|
18
|
+
_defineProperty(this, "state", {
|
|
31
19
|
ariaLabelledByContent: null
|
|
32
20
|
});
|
|
33
|
-
return _this;
|
|
34
21
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _this2 = this;
|
|
56
|
-
if (process.env.NODE_ENV !== "production") {
|
|
57
|
-
logger.warn(this.containerRef.current && !hasLabels(this.containerRef.current) && !this.asProps.title, "'title' or 'aria-label' or 'aria-labelledby' are required props for buttons without text content", this.asProps["data-ui-name"] || AbstractButton2.displayName);
|
|
58
|
-
logger.warn(this.asProps.theme === "warning", "Warning theme is deprecated and will be removed in the next major release.", this.asProps["data-ui-name"] || AbstractButton2.displayName);
|
|
59
|
-
}
|
|
60
|
-
var ariaLabelledby = this.asProps["aria-labelledby"];
|
|
61
|
-
if (ariaLabelledby) {
|
|
62
|
-
setTimeout(function() {
|
|
63
|
-
var _document$getElementB, _document$getElementB2;
|
|
64
|
-
_this2.setState({
|
|
65
|
-
ariaLabelledByContent: (_document$getElementB = (_document$getElementB2 = document.getElementById(ariaLabelledby)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.textContent) !== null && _document$getElementB !== void 0 ? _document$getElementB : ""
|
|
66
|
-
});
|
|
67
|
-
}, 0);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "renderButton",
|
|
72
|
-
value: function renderButton(_ref6) {
|
|
73
|
-
var _ref = this.asProps, _ref3;
|
|
74
|
-
var buttonProps = _ref6.buttonProps, children = _ref6.children;
|
|
75
|
-
var _this$asProps = this.asProps, styles = _this$asProps.styles, theme = _this$asProps.theme;
|
|
76
|
-
var SButton = Box;
|
|
77
|
-
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SButton, _ref3.cn("SButton", _objectSpread({}, assignProps(_objectSpread({
|
|
78
|
-
"invertOutline": theme === "invert"
|
|
79
|
-
}, buttonProps), _ref))), children);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "renderButtonWithHint",
|
|
83
|
-
value: function renderButtonWithHint(_ref7) {
|
|
84
|
-
var _ref2 = this.asProps, _ref4;
|
|
85
|
-
var buttonProps = _ref7.buttonProps, children = _ref7.children, hintProps = _ref7.hintProps;
|
|
86
|
-
var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, theme = _this$asProps2.theme;
|
|
87
|
-
var SButton = Hint;
|
|
88
|
-
return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SButton, _ref4.cn("SButton", _objectSpread({}, assignProps(_objectSpread(_objectSpread(_objectSpread({
|
|
89
|
-
"invertOutline": theme === "invert"
|
|
90
|
-
}, buttonProps), hintProps), {}, {
|
|
91
|
-
"ignorePortalsStacking": true
|
|
92
|
-
}), _ref2))), children);
|
|
22
|
+
getTextProps() {
|
|
23
|
+
const {
|
|
24
|
+
size
|
|
25
|
+
} = this.asProps;
|
|
26
|
+
return {
|
|
27
|
+
size
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
getAddonProps() {
|
|
31
|
+
const {
|
|
32
|
+
size
|
|
33
|
+
} = this.asProps;
|
|
34
|
+
return {
|
|
35
|
+
size
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
componentDidMount() {
|
|
39
|
+
if (process.env.NODE_ENV !== "production") {
|
|
40
|
+
logger.warn(this.containerRef.current && !hasLabels(this.containerRef.current) && !this.asProps.title, `'title' or 'aria-label' or 'aria-labelledby' are required props for buttons without text content`, this.asProps["data-ui-name"] || AbstractButton.displayName);
|
|
41
|
+
logger.warn(this.asProps.theme === "warning", "Warning theme is deprecated and will be removed in the next major release.", this.asProps["data-ui-name"] || AbstractButton.displayName);
|
|
93
42
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
|
|
101
|
-
var SInner = Box;
|
|
102
|
-
var SSpin = Box;
|
|
103
|
-
var buttonAriaLabel = (_ref8 = (_ref9 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref9 !== void 0 ? _ref9 : this.state.ariaLabelledByContent) !== null && _ref8 !== void 0 ? _ref8 : "";
|
|
104
|
-
var buttonProps = {
|
|
105
|
-
"type": "button",
|
|
106
|
-
"tag": "button",
|
|
107
|
-
disabled,
|
|
108
|
-
"use:theme": useTheme,
|
|
109
|
-
"ref": this.containerRef,
|
|
110
|
-
"text-color": this.getTextColor(),
|
|
111
|
-
"aria-busy": loading,
|
|
112
|
-
"__excludeProps": ["title"],
|
|
113
|
-
"tabIndex": 0
|
|
114
|
-
};
|
|
115
|
-
var hintProps = {
|
|
116
|
-
title: buttonAriaLabel,
|
|
117
|
-
timeout: [250, 50],
|
|
118
|
-
placement: hintPlacement,
|
|
119
|
-
theme: theme === "invert" ? "invert" : void 0,
|
|
120
|
-
__excludeProps: []
|
|
121
|
-
};
|
|
122
|
-
return /* @__PURE__ */ React.createElement(NeighborLocation.Detect, {
|
|
123
|
-
neighborLocation
|
|
124
|
-
}, function(neighborLocation2) {
|
|
125
|
-
var _ref5;
|
|
126
|
-
var children = (_ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SInner, _ref5.cn("SInner", {
|
|
127
|
-
"tag": "span",
|
|
128
|
-
"loading": loading,
|
|
129
|
-
"data-ui-name": "".concat(_this3.asProps["data-ui-name"], ".InnerWrapper")
|
|
130
|
-
}), AddonLeft ? /* @__PURE__ */ React.createElement(Button.Addon, null, /* @__PURE__ */ React.createElement(AddonLeft, _ref5.cn("AddonLeft", {}))) : null, addonTextChildren(Children, Button.Text, Button.Addon), AddonRight ? /* @__PURE__ */ React.createElement(Button.Addon, null, /* @__PURE__ */ React.createElement(AddonRight, _ref5.cn("AddonRight", {}))) : null), loading && /* @__PURE__ */ React.createElement(SSpin, _ref5.cn("SSpin", {
|
|
131
|
-
"tag": "span"
|
|
132
|
-
}), /* @__PURE__ */ React.createElement(SpinButton, _ref5.cn("SpinButton", {
|
|
133
|
-
"centered": true,
|
|
134
|
-
"size": size,
|
|
135
|
-
"theme": useTheme
|
|
136
|
-
})))));
|
|
137
|
-
buttonProps.neighborLocation = neighborLocation2;
|
|
138
|
-
if (hasChildren === void 0 || title) {
|
|
139
|
-
return _this3.renderButtonWithHint({
|
|
140
|
-
buttonProps,
|
|
141
|
-
hintProps,
|
|
142
|
-
children
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
return _this3.renderButton({
|
|
146
|
-
buttonProps,
|
|
147
|
-
children
|
|
43
|
+
const ariaLabelledby = this.asProps["aria-labelledby"];
|
|
44
|
+
if (ariaLabelledby) {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
this.setState({
|
|
48
|
+
ariaLabelledByContent: ((_a = document.getElementById(ariaLabelledby)) == null ? void 0 : _a.textContent) ?? ""
|
|
148
49
|
});
|
|
149
|
-
});
|
|
50
|
+
}, 0);
|
|
150
51
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
var _ref = this.asProps;
|
|
55
|
+
const {
|
|
56
|
+
styles,
|
|
57
|
+
use,
|
|
58
|
+
theme = typeof use === "string" && MAP_USE_DEFAULT_THEME[use],
|
|
59
|
+
loading,
|
|
60
|
+
disabled = loading,
|
|
61
|
+
size,
|
|
62
|
+
neighborLocation,
|
|
63
|
+
children,
|
|
64
|
+
title,
|
|
65
|
+
["aria-label"]: ariaLabel,
|
|
66
|
+
Children,
|
|
67
|
+
addonLeft: AddonLeft,
|
|
68
|
+
addonRight: AddonRight,
|
|
69
|
+
hintPlacement
|
|
70
|
+
} = this.asProps;
|
|
71
|
+
const SButton = Box;
|
|
72
|
+
const Button = this[CORE_INSTANCE];
|
|
73
|
+
const useTheme = use && theme ? `${use}-${theme}` : false;
|
|
74
|
+
const SInner = Box;
|
|
75
|
+
const SSpin = Box;
|
|
76
|
+
const buttonAriaLabel = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? "";
|
|
77
|
+
const showHint = children === void 0 || title;
|
|
78
|
+
return /* @__PURE__ */ React.createElement(NeighborLocation.Detect, {
|
|
79
|
+
neighborLocation
|
|
80
|
+
}, (neighborLocation2) => {
|
|
81
|
+
var _ref2;
|
|
82
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SButton, _ref2.cn("SButton", {
|
|
83
|
+
...assignProps({
|
|
84
|
+
"invertOutline": theme === "invert",
|
|
85
|
+
"type": "button",
|
|
86
|
+
"tag": "button",
|
|
87
|
+
"tabIndex": 0,
|
|
88
|
+
"disabled": disabled,
|
|
89
|
+
"use:theme": useTheme,
|
|
90
|
+
"ref": this.containerRef,
|
|
91
|
+
"text-color": this.getTextColor(),
|
|
92
|
+
"aria-busy": loading,
|
|
93
|
+
"__excludeProps": ["title"],
|
|
94
|
+
"aria-label": showHint ? buttonAriaLabel : void 0,
|
|
95
|
+
"neighborLocation": neighborLocation2
|
|
96
|
+
}, _ref)
|
|
97
|
+
}), /* @__PURE__ */ React.createElement(SInner, _ref2.cn("SInner", {
|
|
98
|
+
"tag": "span",
|
|
99
|
+
"loading": loading,
|
|
100
|
+
"data-ui-name": `${this.asProps["data-ui-name"]}.InnerWrapper`
|
|
101
|
+
}), AddonLeft ? /* @__PURE__ */ React.createElement(Button.Addon, null, /* @__PURE__ */ React.createElement(AddonLeft, _ref2.cn("AddonLeft", {}))) : null, addonTextChildren(Children, Button.Text, Button.Addon), AddonRight ? /* @__PURE__ */ React.createElement(Button.Addon, null, /* @__PURE__ */ React.createElement(AddonRight, _ref2.cn("AddonRight", {}))) : null), loading && /* @__PURE__ */ React.createElement(SSpin, _ref2.cn("SSpin", {
|
|
102
|
+
"tag": "span"
|
|
103
|
+
}), /* @__PURE__ */ React.createElement(SpinButton, _ref2.cn("SpinButton", {
|
|
104
|
+
"centered": true,
|
|
105
|
+
"size": size,
|
|
106
|
+
"theme": useTheme
|
|
107
|
+
})))), showHint && /* @__PURE__ */ React.createElement(Hint, _ref2.cn("Hint", {
|
|
108
|
+
"triggerRef": this.containerRef,
|
|
109
|
+
"timeout": [250, 50],
|
|
110
|
+
"placement": hintPlacement
|
|
111
|
+
}), buttonAriaLabel));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
153
115
|
_defineProperty(AbstractButton, "displayName", "AbstractButton");
|
|
154
116
|
export {
|
|
155
117
|
AbstractButton,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
2
|
import Spin from "@semcore/spin";
|
|
4
3
|
import React from "react";
|
|
5
|
-
|
|
6
|
-
var SPIN_SIZE_MAP = {
|
|
4
|
+
const SPIN_SIZE_MAP = {
|
|
7
5
|
xl: "m",
|
|
8
6
|
l: "s",
|
|
9
7
|
m: "xs",
|
|
10
8
|
s: "xxs"
|
|
11
9
|
};
|
|
12
|
-
function SpinButton(
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function SpinButton({
|
|
11
|
+
theme,
|
|
12
|
+
size,
|
|
13
|
+
...others
|
|
14
|
+
}) {
|
|
15
15
|
return /* @__PURE__ */ React.createElement(Spin, _extends({
|
|
16
16
|
size: typeof size === "string" ? SPIN_SIZE_MAP[size] : size,
|
|
17
17
|
theme: "currentColor"
|