@semcore/button 5.43.3 → 5.44.0-prerelease.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/component/Button/Button.js +166 -64
  3. package/lib/cjs/component/Button/Button.js.map +1 -1
  4. package/lib/cjs/component/Button/Button.type.js.map +1 -1
  5. package/lib/cjs/component/{AbstractButton → Button}/SpinButton.js +3 -4
  6. package/lib/cjs/component/Button/SpinButton.js.map +1 -0
  7. package/lib/cjs/component/Button/button.shadow.css +80 -88
  8. package/lib/cjs/component/ButtonLink/ButtonLink.js +35 -68
  9. package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
  10. package/lib/cjs/component/ButtonLink/ButtonLink.type.js.map +1 -1
  11. package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +13 -152
  12. package/lib/cjs/index.js +3 -4
  13. package/lib/cjs/index.js.map +1 -1
  14. package/lib/es6/component/Button/Button.js +163 -57
  15. package/lib/es6/component/Button/Button.js.map +1 -1
  16. package/lib/es6/component/Button/Button.type.js.map +1 -1
  17. package/lib/es6/component/{AbstractButton → Button}/SpinButton.js +1 -1
  18. package/lib/es6/component/Button/SpinButton.js.map +1 -0
  19. package/lib/es6/component/Button/button.shadow.css +80 -88
  20. package/lib/es6/component/ButtonLink/ButtonLink.js +34 -65
  21. package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
  22. package/lib/es6/component/ButtonLink/ButtonLink.type.js.map +1 -1
  23. package/lib/es6/component/ButtonLink/buttonLink.shadow.css +13 -152
  24. package/lib/es6/index.js +1 -2
  25. package/lib/es6/index.js.map +1 -1
  26. package/lib/esm/component/Button/Button.mjs +142 -56
  27. package/lib/esm/component/Button/Button.type.mjs +1 -0
  28. package/lib/esm/component/{AbstractButton → Button}/SpinButton.mjs +2 -3
  29. package/lib/esm/component/Button/button.shadow.css +80 -88
  30. package/lib/esm/component/ButtonLink/ButtonLink.mjs +33 -61
  31. package/lib/esm/component/ButtonLink/ButtonLink.type.mjs +1 -0
  32. package/lib/esm/component/ButtonLink/buttonLink.shadow.css +13 -152
  33. package/lib/esm/index.mjs +3 -2
  34. package/lib/types/component/Button/Button.d.ts +28 -1
  35. package/lib/types/component/Button/Button.type.d.ts +40 -39
  36. package/lib/types/component/{AbstractButton → Button}/SpinButton.d.ts +2 -2
  37. package/lib/types/component/ButtonLink/ButtonLink.d.ts +1 -1
  38. package/lib/types/component/ButtonLink/ButtonLink.type.d.ts +15 -21
  39. package/lib/types/index.d.ts +1 -2
  40. package/package.json +7 -7
  41. package/lib/cjs/component/AbstractButton/AbstractButton.js +0 -182
  42. package/lib/cjs/component/AbstractButton/AbstractButton.js.map +0 -1
  43. package/lib/cjs/component/AbstractButton/AbstractButton.type.js +0 -2
  44. package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +0 -1
  45. package/lib/cjs/component/AbstractButton/SpinButton.js.map +0 -1
  46. package/lib/es6/component/AbstractButton/AbstractButton.js +0 -175
  47. package/lib/es6/component/AbstractButton/AbstractButton.js.map +0 -1
  48. package/lib/es6/component/AbstractButton/AbstractButton.type.js +0 -2
  49. package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +0 -1
  50. package/lib/es6/component/AbstractButton/SpinButton.js.map +0 -1
  51. package/lib/esm/component/AbstractButton/AbstractButton.mjs +0 -152
  52. package/lib/types/component/AbstractButton/AbstractButton.d.ts +0 -24
  53. package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +0 -39
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractButton.js","names":["React","Box","Hint","NeighborLocation","addonTextChildren","logger","SpinButton","hasLabels","Component","CORE_INSTANCE","Root","sstyled","MAP_USE_DEFAULT_THEME","primary","secondary","tertiary","AbstractButton","_Component","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","createRef","ariaLabelledByContent","_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","styles","SButton","createElement","cn","_objectSpread","_assignProps","renderButtonWithHint","_ref7","_ref2","_ref4","hintProps","_assignProps2","render","_ref8","_ref9","_this3","_this$asProps","use","_this$asProps$theme","loading","_this$asProps$disable","disabled","neighborLocation","hasChildren","ariaLabel","Children","AddonLeft","addonLeft","AddonRight","addonRight","hintPlacement","Button","useTheme","SInner","SSpin","buttonAriaLabel","state","type","tag","ref","getTextColor","__excludeProps","timeout","placement","undefined","Detect","_ref5","Fragment","Addon","Text"],"sources":["../../../../src/component/AbstractButton/AbstractButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '@semcore/flex-box';\nimport { Hint } from '@semcore/tooltip';\nimport NeighborLocation from '@semcore/neighbor-location';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport logger from '@semcore/utils/lib/logger';\nimport SpinButton from './SpinButton';\nimport hasLabels from '@semcore/utils/lib/hasLabels';\nimport { AbstractButtonProps } from './AbstractButton.type';\nimport { Component, CORE_INSTANCE, Root, sstyled } from '@semcore/core';\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 } = this.asProps;\n const SButton = Root;\n\n return sstyled(styles)(\n <SButton render={Box} {...buttonProps}>\n {children}\n </SButton>,\n );\n }\n\n renderButtonWithHint({ buttonProps, children, hintProps }: any) {\n const { styles } = this.asProps;\n const SButton = Root;\n\n return sstyled(styles)(\n <SButton render={Hint} {...buttonProps} {...hintProps}>\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 };\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}>\n {AddonLeft ? (\n <Button.Addon>\n <AddonLeft />\n </Button.Addon>\n ) : null}\n {addonTextChildren(Children, Button.Text, Button.Addon)}\n {AddonRight ? (\n <Button.Addon>\n <AddonRight />\n </Button.Addon>\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,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,GAAG,QAAQ,mBAAmB;AACvC,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,MAAM,MAAM,2BAA2B;AAC9C,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,SAAS,MAAM,8BAA8B;AAEpD,SAASC,SAAS,EAAEC,aAAa,EAAEC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAEvE,OAAO,IAAMC,qBAA6C,GAAG;EAC3DC,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,OAAO;EAClBC,QAAQ,EAAE;AACZ,CAAC;AAID,WAAsBC,cAAc,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,cAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,cAAA;EAAA,SAAAA,eAAA;IAAA,IAAAK,KAAA;IAAAC,eAAA,OAAAN,cAAA;IAAA,SAAAO,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAA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@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=AbstractButton.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractButton.type.js","names":[],"sources":["../../../../src/component/AbstractButton/AbstractButton.type.ts"],"sourcesContent":["import React from 'react';\nimport { PropGetterFn } from '@semcore/core';\nimport { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport { BoxProps } from '@semcore/flex-box';\nimport { NeighborItemProps } from '@semcore/neighbor-location';\nimport { TooltipHintProps } from '@semcore/tooltip';\n\nexport type AbstractButtonProps<S, U, T> = BoxProps &\n NeighborItemProps &\n KeyboardFocusProps & {\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 type. 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":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpinButton.js","names":["React","Spin","SPIN_SIZE_MAP","xl","l","m","s","SpinButton","_ref","theme","size","others","_objectWithoutProperties","_excluded","createElement","_extends"],"sources":["../../../../src/component/AbstractButton/SpinButton.tsx"],"sourcesContent":["import React from 'react';\nimport Spin from '@semcore/spin';\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,KAAK,MAAM,OAAO;AACzB,OAAOC,IAAI,MAAM,eAAe;AAEhC,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,oBACEb,KAAA,CAAAc,aAAA,CAACb,IAAI,EAAAc,QAAA;IACHL,IAAI,EAAE,OAAOA,IAAI,KAAK,QAAQ,GAAGR,aAAa,CAACQ,IAAI,CAAC,GAAGA,IAAK;IAC5DD,KAAK,EAAC;EAAc,GAChBE,MAAM,EACV;AAEN"}
@@ -1,152 +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 _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
7
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
- import { sstyled, assignProps, CORE_INSTANCE, Component } from "@semcore/core";
9
- import React from "react";
10
- import { Box } from "@semcore/flex-box";
11
- import { Hint } from "@semcore/tooltip";
12
- import NeighborLocation from "@semcore/neighbor-location";
13
- import addonTextChildren from "@semcore/utils/lib/addonTextChildren";
14
- import logger from "@semcore/utils/lib/logger";
15
- import SpinButton from "./SpinButton.mjs";
16
- import hasLabels from "@semcore/utils/lib/hasLabels";
17
- var MAP_USE_DEFAULT_THEME = {
18
- primary: "info",
19
- secondary: "muted",
20
- tertiary: "info"
21
- };
22
- var AbstractButton = /* @__PURE__ */ function(_Component) {
23
- _inherits(AbstractButton2, _Component);
24
- var _super = _createSuper(AbstractButton2);
25
- function AbstractButton2() {
26
- var _this;
27
- _classCallCheck(this, AbstractButton2);
28
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
- args[_key] = arguments[_key];
30
- }
31
- _this = _super.call.apply(_super, [this].concat(args));
32
- _defineProperty(_assertThisInitialized(_this), "containerRef", /* @__PURE__ */ React.createRef());
33
- _defineProperty(_assertThisInitialized(_this), "state", {
34
- ariaLabelledByContent: null
35
- });
36
- return _this;
37
- }
38
- _createClass(AbstractButton2, [{
39
- key: "getTextProps",
40
- value: function getTextProps() {
41
- var size = this.asProps.size;
42
- return {
43
- size
44
- };
45
- }
46
- }, {
47
- key: "getAddonProps",
48
- value: function getAddonProps() {
49
- var size = this.asProps.size;
50
- return {
51
- size
52
- };
53
- }
54
- }, {
55
- key: "componentDidMount",
56
- value: function componentDidMount() {
57
- var _this2 = this;
58
- if (process.env.NODE_ENV !== "production") {
59
- 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);
60
- 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);
61
- }
62
- var ariaLabelledby = this.asProps["aria-labelledby"];
63
- if (ariaLabelledby) {
64
- setTimeout(function() {
65
- var _document$getElementB, _document$getElementB2;
66
- _this2.setState({
67
- 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 : ""
68
- });
69
- }, 0);
70
- }
71
- }
72
- }, {
73
- key: "renderButton",
74
- value: function renderButton(_ref6) {
75
- var _ref = this.asProps, _ref3;
76
- var buttonProps = _ref6.buttonProps, children = _ref6.children;
77
- var styles = this.asProps.styles;
78
- var SButton = Box;
79
- return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SButton, _ref3.cn("SButton", _objectSpread({}, assignProps(_objectSpread({}, 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 styles = this.asProps.styles;
87
- var SButton = Hint;
88
- return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SButton, _ref4.cn("SButton", _objectSpread({}, assignProps(_objectSpread(_objectSpread({}, buttonProps), hintProps), _ref2))), children);
89
- }
90
- }, {
91
- key: "render",
92
- value: function render() {
93
- var _ref8, _ref9, _this3 = this;
94
- var _this$asProps = this.asProps, styles = _this$asProps.styles, use = _this$asProps.use, _this$asProps$theme = _this$asProps.theme, theme = _this$asProps$theme === void 0 ? typeof use === "string" && MAP_USE_DEFAULT_THEME[use] : _this$asProps$theme, loading = _this$asProps.loading, _this$asProps$disable = _this$asProps.disabled, disabled = _this$asProps$disable === void 0 ? loading : _this$asProps$disable, size = _this$asProps.size, neighborLocation = _this$asProps.neighborLocation, hasChildren = _this$asProps.children, title = _this$asProps.title, ariaLabel = _this$asProps["aria-label"], Children = _this$asProps.Children, AddonLeft = _this$asProps.addonLeft, AddonRight = _this$asProps.addonRight, hintPlacement = _this$asProps.hintPlacement;
95
- var Button = this[CORE_INSTANCE];
96
- var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
97
- var SInner = Box;
98
- var SSpin = Box;
99
- var buttonAriaLabel = (_ref8 = (_ref9 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref9 !== void 0 ? _ref9 : this.state.ariaLabelledByContent) !== null && _ref8 !== void 0 ? _ref8 : "";
100
- var buttonProps = {
101
- type: "button",
102
- tag: "button",
103
- disabled,
104
- "use:theme": useTheme,
105
- ref: this.containerRef,
106
- "text-color": this.getTextColor(),
107
- "aria-busy": loading,
108
- __excludeProps: ["title"]
109
- };
110
- var hintProps = {
111
- title: buttonAriaLabel,
112
- timeout: [250, 50],
113
- placement: hintPlacement,
114
- theme: theme === "invert" ? "invert" : void 0,
115
- __excludeProps: []
116
- };
117
- return /* @__PURE__ */ React.createElement(NeighborLocation.Detect, {
118
- neighborLocation
119
- }, function(neighborLocation2) {
120
- var _ref5;
121
- var children = (_ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SInner, _ref5.cn("SInner", {
122
- "tag": "span",
123
- "loading": loading
124
- }), 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", {
125
- "tag": "span"
126
- }), /* @__PURE__ */ React.createElement(SpinButton, _ref5.cn("SpinButton", {
127
- "centered": true,
128
- "size": size,
129
- "theme": useTheme
130
- })))));
131
- buttonProps.neighborLocation = neighborLocation2;
132
- if (hasChildren === void 0 || title) {
133
- return _this3.renderButtonWithHint({
134
- buttonProps,
135
- hintProps,
136
- children
137
- });
138
- }
139
- return _this3.renderButton({
140
- buttonProps,
141
- children
142
- });
143
- });
144
- }
145
- }]);
146
- return AbstractButton2;
147
- }(Component);
148
- _defineProperty(AbstractButton, "displayName", "AbstractButton");
149
- export {
150
- AbstractButton,
151
- MAP_USE_DEFAULT_THEME
152
- };
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { AbstractButtonProps } from './AbstractButton.type';
3
- import { Component } from '@semcore/core';
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(): JSX.Element;
23
- }
24
- export {};
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import { PropGetterFn } from '@semcore/core';
3
- import { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
4
- import { BoxProps } from '@semcore/flex-box';
5
- import { NeighborItemProps } from '@semcore/neighbor-location';
6
- import { TooltipHintProps } from '@semcore/tooltip';
7
- export type AbstractButtonProps<S, U, T> = BoxProps & NeighborItemProps & KeyboardFocusProps & {
8
- /** Button activity state */
9
- active?: boolean;
10
- /** Disabled button state */
11
- disabled?: boolean;
12
- /** Loading button state */
13
- loading?: boolean;
14
- /** Tag for the left Addon */
15
- addonLeft?: React.ElementType;
16
- /** Tag for the right Addon */
17
- addonRight?: React.ElementType;
18
- /**
19
- * Placement for hint
20
- * @default top
21
- */
22
- hintPlacement?: TooltipHintProps['placement'];
23
- /** Button type. Defined in Button.type or ButtonLink.type */
24
- size?: S;
25
- /** Button usage. Defined in Button.type or ButtonLink.type */
26
- use?: U;
27
- /** Button theme. Defined in Button.type or ButtonLink.type */
28
- theme?: T;
29
- };
30
- export type AbstractButtonAddonProps<S> = BoxProps & {
31
- size?: S;
32
- };
33
- export type AbstractButtonTextProps<S> = BoxProps & {
34
- size?: S;
35
- };
36
- export type AbstractButtonContext = {
37
- getTextProps: PropGetterFn;
38
- getAddonProps: PropGetterFn;
39
- };