@semcore/button 16.1.0-prerelease.1 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/component/Button/Button.js +160 -50
- 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/Button/SpinButton.js.map +1 -0
- package/lib/cjs/component/ButtonLink/ButtonLink.js +29 -54
- package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
- package/lib/cjs/component/ButtonLink/ButtonLink.type.js.map +1 -1
- package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +10 -140
- package/lib/cjs/index.js +3 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/component/Button/Button.js +160 -49
- 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/Button/SpinButton.js.map +1 -0
- package/lib/es6/component/ButtonLink/ButtonLink.js +30 -56
- package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
- package/lib/es6/component/ButtonLink/ButtonLink.type.js.map +1 -1
- package/lib/es6/component/ButtonLink/buttonLink.shadow.css +10 -140
- package/lib/es6/index.js +1 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/esm/component/Button/Button.mjs +140 -48
- package/lib/esm/component/Button/Button.type.mjs +1 -0
- package/lib/esm/component/{AbstractButton → Button}/SpinButton.mjs +1 -2
- package/lib/esm/component/ButtonLink/ButtonLink.mjs +30 -52
- package/lib/esm/component/ButtonLink/ButtonLink.type.mjs +1 -0
- package/lib/esm/component/ButtonLink/buttonLink.shadow.css +10 -140
- package/lib/esm/index.mjs +3 -2
- package/lib/types/component/Button/Button.d.ts +28 -1
- package/lib/types/component/Button/Button.type.d.ts +40 -39
- package/lib/types/component/ButtonLink/ButtonLink.type.d.ts +14 -19
- package/lib/types/index.d.ts +1 -2
- package/package.json +9 -9
- package/lib/cjs/component/AbstractButton/AbstractButton.js +0 -189
- package/lib/cjs/component/AbstractButton/AbstractButton.js.map +0 -1
- package/lib/cjs/component/AbstractButton/AbstractButton.type.js +0 -2
- package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +0 -1
- package/lib/cjs/component/AbstractButton/SpinButton.js.map +0 -1
- package/lib/es6/component/AbstractButton/AbstractButton.js +0 -184
- package/lib/es6/component/AbstractButton/AbstractButton.js.map +0 -1
- package/lib/es6/component/AbstractButton/AbstractButton.type.js +0 -2
- package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +0 -1
- package/lib/es6/component/AbstractButton/SpinButton.js.map +0 -1
- package/lib/esm/component/AbstractButton/AbstractButton.mjs +0 -157
- package/lib/types/component/AbstractButton/AbstractButton.d.ts +0 -24
- package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +0 -38
- /package/lib/cjs/component/{AbstractButton → Button}/SpinButton.js +0 -0
- /package/lib/es6/component/{AbstractButton → Button}/SpinButton.js +0 -0
- /package/lib/types/component/{AbstractButton → Button}/SpinButton.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractButton.js","names":["Component","CORE_INSTANCE","Root","sstyled","addonTextChildren","hasLabels","logger","Box","NeighborLocation","Hint","React","SpinButton","MAP_USE_DEFAULT_THEME","primary","secondary","tertiary","AbstractButton","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","createRef","ariaLabelledByContent","_inherits","_createClass","key","value","getTextProps","size","asProps","getAddonProps","componentDidMount","_this2","process","env","NODE_ENV","warn","containerRef","current","title","displayName","theme","ariaLabelledby","setTimeout","_document$getElementB","_document$getElementB2","setState","document","getElementById","textContent","renderButton","_ref6","_ref","_ref3","buttonProps","children","_this$asProps","styles","SButton","createElement","cn","_objectSpread","_assignProps","renderButtonWithHint","_ref7","_ref2","_ref4","hintProps","_this$asProps2","_assignProps2","render","_ref8","_ref9","_this3","_this$asProps3","use","_this$asProps3$theme","loading","_this$asProps3$disabl","disabled","neighborLocation","hasChildren","ariaLabel","Children","AddonLeft","addonLeft","AddonRight","addonRight","hintPlacement","Button","useTheme","SInner","SSpin","buttonAriaLabel","state","getTextColor","timeout","placement","undefined","__excludeProps","Detect","_ref5","Fragment","Addon","Text"],"sources":["../../../../src/component/AbstractButton/AbstractButton.tsx"],"sourcesContent":["import { Component, CORE_INSTANCE, Root, sstyled } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport hasLabels from '@semcore/core/lib/utils/hasLabels';\nimport logger from '@semcore/core/lib/utils/logger';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation from '@semcore/neighbor-location';\nimport { Hint } from '@semcore/tooltip';\nimport React from 'react';\n\nimport type { AbstractButtonProps } from './AbstractButton.type';\nimport SpinButton from './SpinButton';\n\nexport const MAP_USE_DEFAULT_THEME: Record<string, string> = {\n primary: 'info',\n secondary: 'muted',\n tertiary: 'info',\n};\n\ntype Props = AbstractButtonProps<any, any, any>;\n\nexport abstract class AbstractButton extends Component<Props, {}, {}> {\n static displayName = 'AbstractButton';\n\n containerRef = React.createRef<HTMLButtonElement>();\n\n state = {\n ariaLabelledByContent: null,\n };\n\n protected abstract getTextColor(): string | undefined;\n\n getTextProps() {\n const { size } = this.asProps;\n\n return {\n size,\n };\n }\n\n getAddonProps() {\n const { size } = this.asProps;\n return {\n size,\n };\n }\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current) && !this.asProps.title,\n `'title' or 'aria-label' or 'aria-labelledby' are required props for buttons without text content`,\n this.asProps['data-ui-name'] || AbstractButton.displayName,\n );\n\n logger.warn(\n this.asProps.theme === 'warning',\n 'Warning theme is deprecated and will be removed in the next major release.',\n this.asProps['data-ui-name'] || AbstractButton.displayName,\n );\n }\n\n const ariaLabelledby = this.asProps['aria-labelledby'];\n\n if (ariaLabelledby) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent: document.getElementById(ariaLabelledby)?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n renderButton({ buttonProps, children }: any) {\n const { styles, theme } = this.asProps;\n const SButton = Root;\n\n return sstyled(styles)(\n <SButton render={Box} invertOutline={theme === 'invert'} {...buttonProps}>\n {children}\n </SButton>,\n );\n }\n\n renderButtonWithHint({ buttonProps, children, hintProps }: any) {\n const { styles, theme } = this.asProps;\n const SButton = Root;\n\n return sstyled(styles)(\n <SButton render={Hint} invertOutline={theme === 'invert'} {...buttonProps} {...hintProps} ignorePortalsStacking>\n {children}\n </SButton>,\n );\n }\n\n render() {\n const {\n styles,\n use,\n theme = typeof use === 'string' && MAP_USE_DEFAULT_THEME[use],\n loading,\n disabled = loading,\n size,\n neighborLocation,\n children: hasChildren,\n title,\n ['aria-label']: ariaLabel,\n Children,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n hintPlacement,\n } = this.asProps;\n // @ts-ignore\n const Button = this[CORE_INSTANCE];\n const useTheme = use && theme ? `${use}-${theme}` : false;\n const SInner = Box;\n const SSpin = Box;\n const buttonAriaLabel = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n\n const buttonProps: Record<string, any> = {\n 'type': 'button',\n 'tag': 'button',\n disabled,\n 'use:theme': useTheme,\n 'ref': this.containerRef,\n 'text-color': this.getTextColor(),\n 'aria-busy': loading,\n '__excludeProps': ['title'],\n 'tabIndex': 0,\n };\n\n const hintProps = {\n title: buttonAriaLabel,\n timeout: [250, 50],\n placement: hintPlacement,\n theme: theme === 'invert' ? 'invert' : undefined,\n __excludeProps: [],\n };\n\n return (\n <NeighborLocation.Detect neighborLocation={neighborLocation}>\n {(neighborLocation) => {\n const children = sstyled(styles)(\n <>\n {/* @ts-ignore */}\n <SInner tag='span' loading={loading} data-ui-name={`${this.asProps['data-ui-name']}.InnerWrapper`}>\n {AddonLeft\n ? (\n <Button.Addon>\n <AddonLeft />\n </Button.Addon>\n )\n : null}\n {addonTextChildren(Children, Button.Text, Button.Addon)}\n {AddonRight\n ? (\n <Button.Addon>\n <AddonRight />\n </Button.Addon>\n )\n : null}\n </SInner>\n {loading && (\n <SSpin tag='span'>\n <SpinButton centered size={size} theme={useTheme} />\n </SSpin>\n )}\n </>,\n );\n buttonProps.neighborLocation = neighborLocation;\n\n if (hasChildren === undefined || title) {\n return this.renderButtonWithHint({ buttonProps, hintProps, children });\n }\n\n return this.renderButton({ buttonProps, children });\n }}\n </NeighborLocation.Detect>\n );\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAASA,SAAS,EAAEC,aAAa,EAAEC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AACvE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,SAAS,MAAM,mCAAmC;AACzD,OAAOC,MAAM,MAAM,gCAAgC;AACnD,SAASC,GAAG,QAAQ,mBAAmB;AACvC,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,KAAK,MAAM,OAAO;AAGzB,OAAOC,UAAU,MAAM,cAAc;AAErC,OAAO,IAAMC,qBAA6C,GAAG;EAC3DC,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,OAAO;EAClBC,QAAQ,EAAE;AACZ,CAAC;AAID,WAAsBC,cAAc,0BAAAC,UAAA;EAAA,SAAAD,eAAA;IAAA,IAAAE,KAAA;IAAAC,eAAA,OAAAH,cAAA;IAAA,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAAF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAAP,KAAA,GAAAQ,UAAA,OAAAV,cAAA,KAAAW,MAAA,CAAAJ,IAAA;IAAAK,eAAA,CAAAV,KAAA,+BAGnBR,KAAK,CAACmB,SAAS,CAAoB,CAAC;IAAAD,eAAA,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AS,CAAC,CAAC;MACrD,CACuB,CAAC;IAE9B;EAAC;AAAA,EA9J0C/D,SAAS;AA+JrD4B,eAAA,CA/JqBZ,cAAc,iBACb,gBAAgB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractButton.type.js","names":[],"sources":["../../../../src/component/AbstractButton/AbstractButton.type.ts"],"sourcesContent":["import type { PropGetterFn } from '@semcore/core';\nimport type { BoxProps } from '@semcore/flex-box';\nimport type { NeighborItemProps } from '@semcore/neighbor-location';\nimport type { TooltipHintProps } from '@semcore/tooltip';\nimport type React from 'react';\n\nexport type AbstractButtonProps<S, U, T> = BoxProps &\n NeighborItemProps & {\n /** Button activity state */\n active?: boolean;\n /** Disabled button state */\n disabled?: boolean;\n /** Loading button state */\n loading?: boolean;\n /** Tag for the left Addon */\n addonLeft?: React.ElementType;\n /** Tag for the right Addon */\n addonRight?: React.ElementType;\n /**\n * Placement for hint\n * @default top\n */\n hintPlacement?: TooltipHintProps['placement'];\n\n /** Button size. Defined in Button.type or ButtonLink.type */\n size?: S;\n /** Button usage. Defined in Button.type or ButtonLink.type */\n use?: U;\n /** Button theme. Defined in Button.type or ButtonLink.type */\n theme?: T;\n };\n\nexport type AbstractButtonAddonProps<S> = BoxProps & {\n size?: S;\n};\n\nexport type AbstractButtonTextProps<S> = BoxProps & {\n size?: S;\n};\n\nexport type AbstractButtonContext = {\n getTextProps: PropGetterFn;\n getAddonProps: PropGetterFn;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SpinButton.js","names":["Spin","React","SPIN_SIZE_MAP","xl","l","m","s","SpinButton","_ref","theme","size","others","_objectWithoutProperties","_excluded","createElement","_extends"],"sources":["../../../../src/component/AbstractButton/SpinButton.tsx"],"sourcesContent":["import Spin from '@semcore/spin';\nimport React from 'react';\n\nexport const SPIN_SIZE_MAP: Record<string, string> = {\n xl: 'm',\n l: 's',\n m: 'xs',\n s: 'xxs',\n};\n\nexport default function SpinButton({ theme, size, ...others }: any) {\n return (\n <Spin\n size={typeof size === 'string' ? SPIN_SIZE_MAP[size] : size}\n theme='currentColor'\n {...others}\n />\n );\n}\n"],"mappings":";;;AAAA,OAAOA,IAAI,MAAM,eAAe;AAChC,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAO,IAAMC,aAAqC,GAAG;EACnDC,EAAE,EAAE,GAAG;EACPC,CAAC,EAAE,GAAG;EACNC,CAAC,EAAE,IAAI;EACPC,CAAC,EAAE;AACL,CAAC;AAED,eAAe,SAASC,UAAUA,CAAAC,IAAA,EAAkC;EAAA,IAA/BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAKC,MAAM,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EACzD,oBACEZ,KAAA,CAAAa,aAAA,CAACd,IAAI,EAAAe,QAAA;IACHL,IAAI,EAAE,OAAOA,IAAI,KAAK,QAAQ,GAAGR,aAAa,CAACQ,IAAI,CAAC,GAAGA,IAAK;IAC5DD,KAAK,EAAC;EAAc,GAChBE,MAAM,CACX,CAAC;AAEN","ignoreList":[]}
|
|
@@ -1,157 +0,0 @@
|
|
|
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
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import { sstyled, assignProps, CORE_INSTANCE, Component } from "@semcore/core";
|
|
8
|
-
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
9
|
-
import hasLabels from "@semcore/core/lib/utils/hasLabels";
|
|
10
|
-
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
|
-
import React from "react";
|
|
15
|
-
import SpinButton from "./SpinButton.mjs";
|
|
16
|
-
var MAP_USE_DEFAULT_THEME = {
|
|
17
|
-
primary: "info",
|
|
18
|
-
secondary: "muted",
|
|
19
|
-
tertiary: "info"
|
|
20
|
-
};
|
|
21
|
-
var AbstractButton = /* @__PURE__ */ (function(_Component) {
|
|
22
|
-
function AbstractButton2() {
|
|
23
|
-
var _this;
|
|
24
|
-
_classCallCheck(this, AbstractButton2);
|
|
25
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
-
args[_key] = arguments[_key];
|
|
27
|
-
}
|
|
28
|
-
_this = _callSuper(this, AbstractButton2, [].concat(args));
|
|
29
|
-
_defineProperty(_this, "containerRef", /* @__PURE__ */ React.createRef());
|
|
30
|
-
_defineProperty(_this, "state", {
|
|
31
|
-
ariaLabelledByContent: null
|
|
32
|
-
});
|
|
33
|
-
return _this;
|
|
34
|
-
}
|
|
35
|
-
_inherits(AbstractButton2, _Component);
|
|
36
|
-
return _createClass(AbstractButton2, [{
|
|
37
|
-
key: "getTextProps",
|
|
38
|
-
value: function getTextProps() {
|
|
39
|
-
var size = this.asProps.size;
|
|
40
|
-
return {
|
|
41
|
-
size
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: "getAddonProps",
|
|
46
|
-
value: function getAddonProps() {
|
|
47
|
-
var size = this.asProps.size;
|
|
48
|
-
return {
|
|
49
|
-
size
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "componentDidMount",
|
|
54
|
-
value: function componentDidMount() {
|
|
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);
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
key: "render",
|
|
96
|
-
value: function render() {
|
|
97
|
-
var _ref8, _ref9, _this3 = this;
|
|
98
|
-
var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, use = _this$asProps3.use, _this$asProps3$theme = _this$asProps3.theme, theme = _this$asProps3$theme === void 0 ? typeof use === "string" && MAP_USE_DEFAULT_THEME[use] : _this$asProps3$theme, loading = _this$asProps3.loading, _this$asProps3$disabl = _this$asProps3.disabled, disabled = _this$asProps3$disabl === void 0 ? loading : _this$asProps3$disabl, size = _this$asProps3.size, neighborLocation = _this$asProps3.neighborLocation, hasChildren = _this$asProps3.children, title = _this$asProps3.title, ariaLabel = _this$asProps3["aria-label"], Children = _this$asProps3.Children, AddonLeft = _this$asProps3.addonLeft, AddonRight = _this$asProps3.addonRight, hintPlacement = _this$asProps3.hintPlacement;
|
|
99
|
-
var Button = this[CORE_INSTANCE];
|
|
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
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}]);
|
|
152
|
-
})(Component);
|
|
153
|
-
_defineProperty(AbstractButton, "displayName", "AbstractButton");
|
|
154
|
-
export {
|
|
155
|
-
AbstractButton,
|
|
156
|
-
MAP_USE_DEFAULT_THEME
|
|
157
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Component } from '@semcore/core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { AbstractButtonProps } from './AbstractButton.type';
|
|
4
|
-
export declare const MAP_USE_DEFAULT_THEME: Record<string, string>;
|
|
5
|
-
type Props = AbstractButtonProps<any, any, any>;
|
|
6
|
-
export declare abstract class AbstractButton extends Component<Props, {}, {}> {
|
|
7
|
-
static displayName: string;
|
|
8
|
-
containerRef: React.RefObject<HTMLButtonElement>;
|
|
9
|
-
state: {
|
|
10
|
-
ariaLabelledByContent: null;
|
|
11
|
-
};
|
|
12
|
-
protected abstract getTextColor(): string | undefined;
|
|
13
|
-
getTextProps(): {
|
|
14
|
-
size: any;
|
|
15
|
-
};
|
|
16
|
-
getAddonProps(): {
|
|
17
|
-
size: any;
|
|
18
|
-
};
|
|
19
|
-
componentDidMount(): void;
|
|
20
|
-
renderButton({ buttonProps, children }: any): React.ReactNode;
|
|
21
|
-
renderButtonWithHint({ buttonProps, children, hintProps }: any): React.ReactNode;
|
|
22
|
-
render(): React.JSX.Element;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { PropGetterFn } from '@semcore/core';
|
|
2
|
-
import type { BoxProps } from '@semcore/flex-box';
|
|
3
|
-
import type { NeighborItemProps } from '@semcore/neighbor-location';
|
|
4
|
-
import type { TooltipHintProps } from '@semcore/tooltip';
|
|
5
|
-
import type React from 'react';
|
|
6
|
-
export type AbstractButtonProps<S, U, T> = BoxProps & NeighborItemProps & {
|
|
7
|
-
/** Button activity state */
|
|
8
|
-
active?: boolean;
|
|
9
|
-
/** Disabled button state */
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
/** Loading button state */
|
|
12
|
-
loading?: boolean;
|
|
13
|
-
/** Tag for the left Addon */
|
|
14
|
-
addonLeft?: React.ElementType;
|
|
15
|
-
/** Tag for the right Addon */
|
|
16
|
-
addonRight?: React.ElementType;
|
|
17
|
-
/**
|
|
18
|
-
* Placement for hint
|
|
19
|
-
* @default top
|
|
20
|
-
*/
|
|
21
|
-
hintPlacement?: TooltipHintProps['placement'];
|
|
22
|
-
/** Button size. Defined in Button.type or ButtonLink.type */
|
|
23
|
-
size?: S;
|
|
24
|
-
/** Button usage. Defined in Button.type or ButtonLink.type */
|
|
25
|
-
use?: U;
|
|
26
|
-
/** Button theme. Defined in Button.type or ButtonLink.type */
|
|
27
|
-
theme?: T;
|
|
28
|
-
};
|
|
29
|
-
export type AbstractButtonAddonProps<S> = BoxProps & {
|
|
30
|
-
size?: S;
|
|
31
|
-
};
|
|
32
|
-
export type AbstractButtonTextProps<S> = BoxProps & {
|
|
33
|
-
size?: S;
|
|
34
|
-
};
|
|
35
|
-
export type AbstractButtonContext = {
|
|
36
|
-
getTextProps: PropGetterFn;
|
|
37
|
-
getAddonProps: PropGetterFn;
|
|
38
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|