@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.
Files changed (48) hide show
  1. package/lib/cjs/component/Button/Button.js +160 -50
  2. package/lib/cjs/component/Button/Button.js.map +1 -1
  3. package/lib/cjs/component/Button/Button.type.js.map +1 -1
  4. package/lib/cjs/component/Button/SpinButton.js.map +1 -0
  5. package/lib/cjs/component/ButtonLink/ButtonLink.js +29 -54
  6. package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
  7. package/lib/cjs/component/ButtonLink/ButtonLink.type.js.map +1 -1
  8. package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +10 -140
  9. package/lib/cjs/index.js +3 -4
  10. package/lib/cjs/index.js.map +1 -1
  11. package/lib/es6/component/Button/Button.js +160 -49
  12. package/lib/es6/component/Button/Button.js.map +1 -1
  13. package/lib/es6/component/Button/Button.type.js.map +1 -1
  14. package/lib/es6/component/Button/SpinButton.js.map +1 -0
  15. package/lib/es6/component/ButtonLink/ButtonLink.js +30 -56
  16. package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
  17. package/lib/es6/component/ButtonLink/ButtonLink.type.js.map +1 -1
  18. package/lib/es6/component/ButtonLink/buttonLink.shadow.css +10 -140
  19. package/lib/es6/index.js +1 -2
  20. package/lib/es6/index.js.map +1 -1
  21. package/lib/esm/component/Button/Button.mjs +140 -48
  22. package/lib/esm/component/Button/Button.type.mjs +1 -0
  23. package/lib/esm/component/{AbstractButton → Button}/SpinButton.mjs +1 -2
  24. package/lib/esm/component/ButtonLink/ButtonLink.mjs +30 -52
  25. package/lib/esm/component/ButtonLink/ButtonLink.type.mjs +1 -0
  26. package/lib/esm/component/ButtonLink/buttonLink.shadow.css +10 -140
  27. package/lib/esm/index.mjs +3 -2
  28. package/lib/types/component/Button/Button.d.ts +28 -1
  29. package/lib/types/component/Button/Button.type.d.ts +40 -39
  30. package/lib/types/component/ButtonLink/ButtonLink.type.d.ts +14 -19
  31. package/lib/types/index.d.ts +1 -2
  32. package/package.json +9 -9
  33. package/lib/cjs/component/AbstractButton/AbstractButton.js +0 -189
  34. package/lib/cjs/component/AbstractButton/AbstractButton.js.map +0 -1
  35. package/lib/cjs/component/AbstractButton/AbstractButton.type.js +0 -2
  36. package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +0 -1
  37. package/lib/cjs/component/AbstractButton/SpinButton.js.map +0 -1
  38. package/lib/es6/component/AbstractButton/AbstractButton.js +0 -184
  39. package/lib/es6/component/AbstractButton/AbstractButton.js.map +0 -1
  40. package/lib/es6/component/AbstractButton/AbstractButton.type.js +0 -2
  41. package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +0 -1
  42. package/lib/es6/component/AbstractButton/SpinButton.js.map +0 -1
  43. package/lib/esm/component/AbstractButton/AbstractButton.mjs +0 -157
  44. package/lib/types/component/AbstractButton/AbstractButton.d.ts +0 -24
  45. package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +0 -38
  46. /package/lib/cjs/component/{AbstractButton → Button}/SpinButton.js +0 -0
  47. /package/lib/es6/component/{AbstractButton → Button}/SpinButton.js +0 -0
  48. /package/lib/types/component/{AbstractButton → Button}/SpinButton.d.ts +0 -0
@@ -1,3 +1,30 @@
1
- import type { ButtonComponent } from './Button.type';
1
+ import { Component } from '@semcore/core';
2
+ import React from 'react';
3
+ import type { ButtonProps, ButtonComponent } from './Button.type';
4
+ export declare const MAP_USE_DEFAULT_THEME: Record<string, string>;
5
+ type State = {
6
+ ariaLabelledByContent: null | string;
7
+ };
8
+ export declare class RootButton extends Component<ButtonProps, [], never, {}, State> {
9
+ static displayName: string;
10
+ static style: {
11
+ [key: string]: string;
12
+ };
13
+ static defaultProps: {
14
+ use: string;
15
+ size: string;
16
+ };
17
+ containerRef: React.RefObject<HTMLButtonElement>;
18
+ state: State;
19
+ getTextProps(): {
20
+ size: "l" | "m" | undefined;
21
+ 'hint:triggerRef': React.RefObject<HTMLButtonElement>;
22
+ };
23
+ getAddonProps(): {
24
+ size: "l" | "m" | undefined;
25
+ };
26
+ componentDidMount(): void;
27
+ render(): React.JSX.Element;
28
+ }
2
29
  declare const Button: ButtonComponent;
3
30
  export default Button;
@@ -1,43 +1,44 @@
1
- import type { UnknownProperties, Intergalactic } from '@semcore/core';
2
- import type { AbstractButtonAddonProps, AbstractButtonContext, AbstractButtonTextProps, AbstractButtonProps } from '../AbstractButton/AbstractButton.type';
3
- /**
4
- * Button size
5
- * @default m
6
- */
7
- export type ButtonSize = 'l' | 'm';
8
- /**
9
- * Button type
10
- * @default secondary
11
- */
12
- type Use = 'primary' | 'secondary' | 'tertiary';
13
- /**
14
- * @deprecated don't use it. use `danger` for incorrect or danger behavior and `brand` for the orange one.
15
- */
16
- type DeprecatedTheme = 'warning';
17
- /** Button theme */
18
- type Theme = 'info' | 'success' | 'brand' | 'danger' | 'muted' | 'invert';
19
- /** @deprecated */
20
- export interface IButtonProps extends ButtonProps, UnknownProperties {
21
- }
22
- export type ButtonProps = AbstractButtonProps<ButtonSize, Use, Theme | DeprecatedTheme>;
23
- /** @deprecated */
24
- export interface IButtonTextProps extends ButtonTextProps, UnknownProperties {
25
- }
26
- export type ButtonTextProps = AbstractButtonTextProps<ButtonSize>;
27
- /** @deprecated */
28
- export interface IButtonAddonProps extends ButtonAddonProps, UnknownProperties {
29
- }
30
- export type ButtonAddonProps = AbstractButtonAddonProps<ButtonSize>;
31
- /** @deprecated */
32
- export interface IButtonContext extends ButtonContext, UnknownProperties {
33
- }
34
- export type ButtonContext = AbstractButtonContext;
35
- export type ButtonChildren = {
36
- Text: Intergalactic.Component<'span', ButtonTextProps>;
37
- Addon: Intergalactic.Component<'span', ButtonAddonProps>;
1
+ import type { BoxProps, NeighborItemProps, SimpleHintPopperProps } from '@semcore/base-components';
2
+ import type { Intergalactic, PropGetterFn } from '@semcore/core';
3
+ import type { NSText } from '@semcore/typography';
4
+ import type React from 'react';
5
+ export type ButtonProps = BoxProps & NeighborItemProps & {
6
+ /** Button activity state */
7
+ active?: boolean;
8
+ /** Disabled button state */
9
+ disabled?: boolean;
10
+ /** Loading button state */
11
+ loading?: boolean;
12
+ /** Tag for the left Addon */
13
+ addonLeft?: React.ElementType;
14
+ /** Tag for the right Addon */
15
+ addonRight?: React.ElementType;
16
+ /**
17
+ * Placement for hint
18
+ * @default top
19
+ */
20
+ hintPlacement?: SimpleHintPopperProps['placement'];
21
+ /** Button size.
22
+ * @default `m`
23
+ */
24
+ size?: 'l' | 'm';
25
+ /** Button usage.
26
+ * @default `primary`
27
+ */
28
+ use?: 'primary' | 'secondary' | 'tertiary';
29
+ /** Button theme.
30
+ * @default undefined
31
+ */
32
+ theme?: 'info' | 'success' | 'brand' | 'danger' | 'muted' | 'invert';
38
33
  };
39
- export type ButtonComponent = Intergalactic.Component<'button', ButtonProps, ButtonContext> & {
34
+ export type ButtonTextProps = NSText.Props;
35
+ export type ButtonAddonProps = BoxProps;
36
+ export type ButtonContext = {
37
+ getTextProps: PropGetterFn;
38
+ getAddonProps: PropGetterFn;
39
+ };
40
+ export type ButtonChildren = {
40
41
  Text: Intergalactic.Component<'span', ButtonTextProps>;
41
42
  Addon: Intergalactic.Component<'span', ButtonAddonProps>;
42
43
  };
43
- export {};
44
+ export type ButtonComponent = Intergalactic.Component<'button', ButtonProps, ButtonContext> & ButtonChildren;
@@ -1,24 +1,19 @@
1
+ import type { BoxProps } from '@semcore/base-components';
1
2
  import type { Intergalactic } from '@semcore/core';
2
- import type { AbstractButtonAddonProps, AbstractButtonContext, AbstractButtonTextProps, AbstractButtonProps } from '../AbstractButton/AbstractButton.type';
3
- /**
4
- * Button link size
5
- */
6
- export type ButtonLinkSize = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800;
7
- /**
8
- * Button link type
9
- * @default primary
10
- */
11
- type Use = 'primary' | 'secondary';
12
- export type ButtonLinkProps = AbstractButtonProps<ButtonLinkSize, Use, never>;
13
- export type ButtonLinkTextProps = AbstractButtonTextProps<ButtonLinkSize>;
14
- export type ButtonLinkAddonProps = AbstractButtonAddonProps<ButtonLinkSize>;
15
- export type ButtonLinkContext = AbstractButtonContext;
16
- export type ButtonLinkChildren = {
17
- Text: Intergalactic.Component<'span', ButtonLinkTextProps>;
18
- Addon: Intergalactic.Component<'span', ButtonLinkAddonProps>;
3
+ import type { LinkProps } from '@semcore/link';
4
+ import type { NSText } from '@semcore/typography';
5
+ import type { ButtonContext } from '../Button/Button.type';
6
+ export type ButtonLinkProps = Intergalactic.InternalTypings.EfficientOmit<LinkProps, 'enableVisited'> & {
7
+ /**
8
+ * Button link type
9
+ * @default primary
10
+ */
11
+ use?: 'primary' | 'secondary';
19
12
  };
20
- export type ButtonLinkComponent = Intergalactic.Component<'button', ButtonLinkProps, ButtonLinkContext> & {
13
+ export type ButtonLinkTextProps = NSText.Props;
14
+ export type ButtonLinkAddonProps = BoxProps;
15
+ export type ButtonLinkChildren = {
21
16
  Text: Intergalactic.Component<'span', ButtonLinkTextProps>;
22
17
  Addon: Intergalactic.Component<'span', ButtonLinkAddonProps>;
23
18
  };
24
- export {};
19
+ export type ButtonLinkComponent = Intergalactic.Component<'button', ButtonLinkProps, ButtonContext> & ButtonLinkChildren;
@@ -1,5 +1,4 @@
1
- export { default } from './component/Button/Button';
1
+ export { default, MAP_USE_DEFAULT_THEME } from './component/Button/Button';
2
2
  export * from './component/Button/Button.type';
3
3
  export * from './component/ButtonLink/ButtonLink';
4
4
  export * from './component/ButtonLink/ButtonLink.type';
5
- export { MAP_USE_DEFAULT_THEME } from './component/AbstractButton/AbstractButton';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/button",
3
3
  "description": "Semrush Button Component",
4
- "version": "16.1.0-prerelease.1",
4
+ "version": "16.1.0",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,13 +14,13 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/flex-box": "16.1.0-prerelease.1",
18
- "@semcore/neighbor-location": "16.1.0-prerelease.1",
19
- "@semcore/spin": "16.1.0-prerelease.1",
20
- "@semcore/tooltip": "16.1.0-prerelease.1"
17
+ "@semcore/flex-box": "16.1.0",
18
+ "@semcore/neighbor-location": "16.1.0",
19
+ "@semcore/spin": "16.1.0",
20
+ "@semcore/tooltip": "16.1.0"
21
21
  },
22
22
  "peerDependencies": {
23
- "@semcore/base-components": "^16.6.0-prerelease.1"
23
+ "@semcore/base-components": "^16.6.0"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
@@ -28,10 +28,10 @@
28
28
  "directory": "semcore/button"
29
29
  },
30
30
  "devDependencies": {
31
- "@semcore/core": "16.6.0-prerelease.1",
31
+ "@semcore/core": "16.6.0",
32
+ "@semcore/icon": "16.8.0",
32
33
  "@semcore/testing-utils": "1.0.0",
33
- "@semcore/base-components": "16.6.0-prerelease.1",
34
- "@semcore/icon": "16.8.0-prerelease.1"
34
+ "@semcore/base-components": "16.6.0"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "pnpm semcore-builder && pnpm vite build"
@@ -1,189 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.MAP_USE_DEFAULT_THEME = exports.AbstractButton = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _core = require("@semcore/core");
15
- var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils/addonTextChildren"));
16
- var _hasLabels = _interopRequireDefault(require("@semcore/core/lib/utils/hasLabels"));
17
- var _logger = _interopRequireDefault(require("@semcore/core/lib/utils/logger"));
18
- var _flexBox = require("@semcore/flex-box");
19
- var _neighborLocation = _interopRequireDefault(require("@semcore/neighbor-location"));
20
- var _tooltip = require("@semcore/tooltip");
21
- var _react = _interopRequireDefault(require("react"));
22
- var _SpinButton = _interopRequireDefault(require("./SpinButton"));
23
- var MAP_USE_DEFAULT_THEME = exports.MAP_USE_DEFAULT_THEME = {
24
- primary: 'info',
25
- secondary: 'muted',
26
- tertiary: 'info'
27
- };
28
- var AbstractButton = exports.AbstractButton = /*#__PURE__*/function (_Component) {
29
- function AbstractButton() {
30
- var _this;
31
- (0, _classCallCheck2["default"])(this, AbstractButton);
32
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
- args[_key] = arguments[_key];
34
- }
35
- _this = (0, _callSuper2["default"])(this, AbstractButton, [].concat(args));
36
- (0, _defineProperty2["default"])(_this, "containerRef", /*#__PURE__*/_react["default"].createRef());
37
- (0, _defineProperty2["default"])(_this, "state", {
38
- ariaLabelledByContent: null
39
- });
40
- return _this;
41
- }
42
- (0, _inherits2["default"])(AbstractButton, _Component);
43
- return (0, _createClass2["default"])(AbstractButton, [{
44
- key: "getTextProps",
45
- value: function getTextProps() {
46
- var size = this.asProps.size;
47
- return {
48
- size: size
49
- };
50
- }
51
- }, {
52
- key: "getAddonProps",
53
- value: function getAddonProps() {
54
- var size = this.asProps.size;
55
- return {
56
- size: size
57
- };
58
- }
59
- }, {
60
- key: "componentDidMount",
61
- value: function componentDidMount() {
62
- var _this2 = this;
63
- if (process.env.NODE_ENV !== 'production') {
64
- _logger["default"].warn(this.containerRef.current && !(0, _hasLabels["default"])(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);
65
- _logger["default"].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);
66
- }
67
- var ariaLabelledby = this.asProps['aria-labelledby'];
68
- if (ariaLabelledby) {
69
- setTimeout(function () {
70
- var _document$getElementB, _document$getElementB2;
71
- _this2.setState({
72
- 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 : ''
73
- });
74
- }, 0);
75
- }
76
- }
77
- }, {
78
- key: "renderButton",
79
- value: function renderButton(_ref6) {
80
- var _ref = this.asProps,
81
- _ref3;
82
- var buttonProps = _ref6.buttonProps,
83
- children = _ref6.children;
84
- var _this$asProps = this.asProps,
85
- styles = _this$asProps.styles,
86
- theme = _this$asProps.theme;
87
- var SButton = _flexBox.Box;
88
- return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SButton, _ref3.cn("SButton", (0, _objectSpread2["default"])({}, (0, _core.assignProps)((0, _objectSpread2["default"])({
89
- "invertOutline": theme === 'invert'
90
- }, buttonProps), _ref))), children);
91
- }
92
- }, {
93
- key: "renderButtonWithHint",
94
- value: function renderButtonWithHint(_ref7) {
95
- var _ref2 = this.asProps,
96
- _ref4;
97
- var buttonProps = _ref7.buttonProps,
98
- children = _ref7.children,
99
- hintProps = _ref7.hintProps;
100
- var _this$asProps2 = this.asProps,
101
- styles = _this$asProps2.styles,
102
- theme = _this$asProps2.theme;
103
- var SButton = _tooltip.Hint;
104
- return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SButton, _ref4.cn("SButton", (0, _objectSpread2["default"])({}, (0, _core.assignProps)((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
105
- "invertOutline": theme === 'invert'
106
- }, buttonProps), hintProps), {}, {
107
- "ignorePortalsStacking": true
108
- }), _ref2))), children);
109
- }
110
- }, {
111
- key: "render",
112
- value: function render() {
113
- var _ref8,
114
- _ref9,
115
- _this3 = this;
116
- var _this$asProps3 = this.asProps,
117
- styles = _this$asProps3.styles,
118
- use = _this$asProps3.use,
119
- _this$asProps3$theme = _this$asProps3.theme,
120
- theme = _this$asProps3$theme === void 0 ? typeof use === 'string' && MAP_USE_DEFAULT_THEME[use] : _this$asProps3$theme,
121
- loading = _this$asProps3.loading,
122
- _this$asProps3$disabl = _this$asProps3.disabled,
123
- disabled = _this$asProps3$disabl === void 0 ? loading : _this$asProps3$disabl,
124
- size = _this$asProps3.size,
125
- neighborLocation = _this$asProps3.neighborLocation,
126
- hasChildren = _this$asProps3.children,
127
- title = _this$asProps3.title,
128
- ariaLabel = _this$asProps3['aria-label'],
129
- Children = _this$asProps3.Children,
130
- AddonLeft = _this$asProps3.addonLeft,
131
- AddonRight = _this$asProps3.addonRight,
132
- hintPlacement = _this$asProps3.hintPlacement;
133
- // @ts-ignore
134
- var Button = this[_core.CORE_INSTANCE];
135
- var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
136
- var SInner = _flexBox.Box;
137
- var SSpin = _flexBox.Box;
138
- var buttonAriaLabel = (_ref8 = (_ref9 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref9 !== void 0 ? _ref9 : this.state.ariaLabelledByContent) !== null && _ref8 !== void 0 ? _ref8 : '';
139
- var buttonProps = {
140
- 'type': 'button',
141
- 'tag': 'button',
142
- disabled: disabled,
143
- 'use:theme': useTheme,
144
- 'ref': this.containerRef,
145
- 'text-color': this.getTextColor(),
146
- 'aria-busy': loading,
147
- '__excludeProps': ['title'],
148
- 'tabIndex': 0
149
- };
150
- var hintProps = {
151
- title: buttonAriaLabel,
152
- timeout: [250, 50],
153
- placement: hintPlacement,
154
- theme: theme === 'invert' ? 'invert' : undefined,
155
- __excludeProps: []
156
- };
157
- return /*#__PURE__*/_react["default"].createElement(_neighborLocation["default"].Detect, {
158
- neighborLocation: neighborLocation
159
- }, function (neighborLocation) {
160
- var _ref5;
161
- var children = (_ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(SInner, _ref5.cn("SInner", {
162
- "tag": 'span',
163
- "loading": loading,
164
- "data-ui-name": "".concat(_this3.asProps['data-ui-name'], ".InnerWrapper")
165
- }), AddonLeft ? /*#__PURE__*/_react["default"].createElement(Button.Addon, null, /*#__PURE__*/_react["default"].createElement(AddonLeft, _ref5.cn("AddonLeft", {}))) : null, (0, _addonTextChildren["default"])(Children, Button.Text, Button.Addon), AddonRight ? /*#__PURE__*/_react["default"].createElement(Button.Addon, null, /*#__PURE__*/_react["default"].createElement(AddonRight, _ref5.cn("AddonRight", {}))) : null), loading && /*#__PURE__*/_react["default"].createElement(SSpin, _ref5.cn("SSpin", {
166
- "tag": 'span'
167
- }), /*#__PURE__*/_react["default"].createElement(_SpinButton["default"], _ref5.cn("SpinButton", {
168
- "centered": true,
169
- "size": size,
170
- "theme": useTheme
171
- })))));
172
- buttonProps.neighborLocation = neighborLocation;
173
- if (hasChildren === undefined || title) {
174
- return _this3.renderButtonWithHint({
175
- buttonProps: buttonProps,
176
- hintProps: hintProps,
177
- children: children
178
- });
179
- }
180
- return _this3.renderButton({
181
- buttonProps: buttonProps,
182
- children: children
183
- });
184
- });
185
- }
186
- }]);
187
- }(_core.Component);
188
- (0, _defineProperty2["default"])(AbstractButton, "displayName", 'AbstractButton');
189
- //# sourceMappingURL=AbstractButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractButton.js","names":["_core","require","_addonTextChildren","_interopRequireDefault","_hasLabels","_logger","_flexBox","_neighborLocation","_tooltip","_react","_SpinButton","MAP_USE_DEFAULT_THEME","exports","primary","secondary","tertiary","AbstractButton","_Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","React","createRef","ariaLabelledByContent","_inherits2","_createClass2","key","value","getTextProps","size","asProps","getAddonProps","componentDidMount","_this2","process","env","NODE_ENV","logger","warn","containerRef","current","hasLabels","title","displayName","theme","ariaLabelledby","setTimeout","_document$getElementB","_document$getElementB2","setState","document","getElementById","textContent","renderButton","_ref6","_ref","_ref3","buttonProps","children","_this$asProps","styles","SButton","Box","sstyled","createElement","cn","_objectSpread2","assignProps","renderButtonWithHint","_ref7","_ref2","_ref4","hintProps","_this$asProps2","Hint","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","CORE_INSTANCE","useTheme","SInner","SSpin","buttonAriaLabel","state","getTextColor","timeout","placement","undefined","__excludeProps","Detect","_ref5","Fragment","Addon","addonTextChildren","Text","Component"],"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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAN,sBAAA,CAAAF,OAAA;AAGA,IAAAS,WAAA,GAAAP,sBAAA,CAAAF,OAAA;AAEO,IAAMU,qBAA6C,GAAAC,OAAA,CAAAD,qBAAA,GAAG;EAC3DE,OAAO,EAAE,MAAM;EACfC,SAAS,EAAE,OAAO;EAClBC,QAAQ,EAAE;AACZ,CAAC;AAAC,IAIoBC,cAAc,GAA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AA+D,aAAA,CAACkC,KAAK,EAAAS,KAAA,CAAA1C,EAAA;UAAA,OAAK;QAAM,iBACfhE,MAAA,YAAA+D,aAAA,CAAC9D,WAAA,WAAU,EAAAyG,KAAA,CAAA1C,EAAA;UAAA;UAAA,QAAgBpC,IAAI;UAAA,SAASmE;QAAQ,EAAG,CAC9C,CAET,CAAC,CACJ;QACDvC,WAAW,CAAC4B,gBAAgB,GAAGA,gBAAgB;QAE/C,IAAIC,WAAW,KAAKkB,SAAS,IAAI9D,KAAK,EAAE;UACtC,OAAOoC,MAAI,CAACV,oBAAoB,CAAC;YAAEX,WAAW,EAAXA,WAAW;YAAEe,SAAS,EAATA,SAAS;YAAEd,QAAQ,EAARA;UAAS,CAAC,CAAC;QACxE;QAEA,OAAOoB,MAAI,CAACzB,YAAY,CAAC;UAAEI,WAAW,EAAXA,WAAW;UAAEC,QAAQ,EAARA;QAAS,CAAC,CAAC;MACrD,CACuB,CAAC;IAE9B;EAAC;AAAA,EA9J0CsD,eAAS;AAAA,IAAA5F,gBAAA,aAAhCZ,cAAc,iBACb,gBAAgB","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
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 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","_interopRequireDefault","require","_react","_excluded","SPIN_SIZE_MAP","exports","xl","l","m","s","SpinButton","_ref","theme","size","others","_objectWithoutProperties2","createElement","_extends2"],"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,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA0B,IAAAE,SAAA;AAEnB,IAAMC,aAAqC,GAAAC,OAAA,CAAAD,aAAA,GAAG;EACnDE,EAAE,EAAE,GAAG;EACPC,CAAC,EAAE,GAAG;EACNC,CAAC,EAAE,IAAI;EACPC,CAAC,EAAE;AACL,CAAC;AAEc,SAASC,UAAUA,CAAAC,IAAA,EAAkC;EAAA,IAA/BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAKC,MAAM,OAAAC,yBAAA,aAAAJ,IAAA,EAAAR,SAAA;EACzD,oBACED,MAAA,YAAAc,aAAA,CAACjB,KAAA,WAAI,MAAAkB,SAAA;IACHJ,IAAI,EAAE,OAAOA,IAAI,KAAK,QAAQ,GAAGT,aAAa,CAACS,IAAI,CAAC,GAAGA,IAAK;IAC5DD,KAAK,EAAC;EAAc,GAChBE,MAAM,CACX,CAAC;AAEN","ignoreList":[]}
@@ -1,184 +0,0 @@
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
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- import { assignProps as _assignProps2 } from "@semcore/core";
8
- import { assignProps as _assignProps } from "@semcore/core";
9
- import { Component, CORE_INSTANCE, Root, sstyled } from '@semcore/core';
10
- import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
11
- import hasLabels from '@semcore/core/lib/utils/hasLabels';
12
- import logger from '@semcore/core/lib/utils/logger';
13
- import { Box } from '@semcore/flex-box';
14
- import NeighborLocation from '@semcore/neighbor-location';
15
- import { Hint } from '@semcore/tooltip';
16
- import React from 'react';
17
- import SpinButton from './SpinButton';
18
- export var MAP_USE_DEFAULT_THEME = {
19
- primary: 'info',
20
- secondary: 'muted',
21
- tertiary: 'info'
22
- };
23
- export var AbstractButton = /*#__PURE__*/function (_Component) {
24
- function AbstractButton() {
25
- var _this;
26
- _classCallCheck(this, AbstractButton);
27
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
- args[_key] = arguments[_key];
29
- }
30
- _this = _callSuper(this, AbstractButton, [].concat(args));
31
- _defineProperty(_this, "containerRef", /*#__PURE__*/React.createRef());
32
- _defineProperty(_this, "state", {
33
- ariaLabelledByContent: null
34
- });
35
- return _this;
36
- }
37
- _inherits(AbstractButton, _Component);
38
- return _createClass(AbstractButton, [{
39
- key: "getTextProps",
40
- value: function getTextProps() {
41
- var size = this.asProps.size;
42
- return {
43
- size: size
44
- };
45
- }
46
- }, {
47
- key: "getAddonProps",
48
- value: function getAddonProps() {
49
- var size = this.asProps.size;
50
- return {
51
- size: 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'] || AbstractButton.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'] || AbstractButton.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,
76
- _ref3;
77
- var buttonProps = _ref6.buttonProps,
78
- children = _ref6.children;
79
- var _this$asProps = this.asProps,
80
- styles = _this$asProps.styles,
81
- theme = _this$asProps.theme;
82
- var SButton = Box;
83
- return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(SButton, _ref3.cn("SButton", _objectSpread({}, _assignProps(_objectSpread({
84
- "invertOutline": theme === 'invert'
85
- }, buttonProps), _ref))), children);
86
- }
87
- }, {
88
- key: "renderButtonWithHint",
89
- value: function renderButtonWithHint(_ref7) {
90
- var _ref2 = this.asProps,
91
- _ref4;
92
- var buttonProps = _ref7.buttonProps,
93
- children = _ref7.children,
94
- hintProps = _ref7.hintProps;
95
- var _this$asProps2 = this.asProps,
96
- styles = _this$asProps2.styles,
97
- theme = _this$asProps2.theme;
98
- var SButton = Hint;
99
- return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SButton, _ref4.cn("SButton", _objectSpread({}, _assignProps2(_objectSpread(_objectSpread(_objectSpread({
100
- "invertOutline": theme === 'invert'
101
- }, buttonProps), hintProps), {}, {
102
- "ignorePortalsStacking": true
103
- }), _ref2))), children);
104
- }
105
- }, {
106
- key: "render",
107
- value: function render() {
108
- var _ref8,
109
- _ref9,
110
- _this3 = this;
111
- var _this$asProps3 = this.asProps,
112
- styles = _this$asProps3.styles,
113
- use = _this$asProps3.use,
114
- _this$asProps3$theme = _this$asProps3.theme,
115
- theme = _this$asProps3$theme === void 0 ? typeof use === 'string' && MAP_USE_DEFAULT_THEME[use] : _this$asProps3$theme,
116
- loading = _this$asProps3.loading,
117
- _this$asProps3$disabl = _this$asProps3.disabled,
118
- disabled = _this$asProps3$disabl === void 0 ? loading : _this$asProps3$disabl,
119
- size = _this$asProps3.size,
120
- neighborLocation = _this$asProps3.neighborLocation,
121
- hasChildren = _this$asProps3.children,
122
- title = _this$asProps3.title,
123
- ariaLabel = _this$asProps3['aria-label'],
124
- Children = _this$asProps3.Children,
125
- AddonLeft = _this$asProps3.addonLeft,
126
- AddonRight = _this$asProps3.addonRight,
127
- hintPlacement = _this$asProps3.hintPlacement;
128
- // @ts-ignore
129
- var Button = this[CORE_INSTANCE];
130
- var useTheme = use && theme ? "".concat(use, "-").concat(theme) : false;
131
- var SInner = Box;
132
- var SSpin = Box;
133
- var buttonAriaLabel = (_ref8 = (_ref9 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref9 !== void 0 ? _ref9 : this.state.ariaLabelledByContent) !== null && _ref8 !== void 0 ? _ref8 : '';
134
- var buttonProps = {
135
- 'type': 'button',
136
- 'tag': 'button',
137
- disabled: disabled,
138
- 'use:theme': useTheme,
139
- 'ref': this.containerRef,
140
- 'text-color': this.getTextColor(),
141
- 'aria-busy': loading,
142
- '__excludeProps': ['title'],
143
- 'tabIndex': 0
144
- };
145
- var hintProps = {
146
- title: buttonAriaLabel,
147
- timeout: [250, 50],
148
- placement: hintPlacement,
149
- theme: theme === 'invert' ? 'invert' : undefined,
150
- __excludeProps: []
151
- };
152
- return /*#__PURE__*/React.createElement(NeighborLocation.Detect, {
153
- neighborLocation: neighborLocation
154
- }, function (neighborLocation) {
155
- var _ref5;
156
- var children = (_ref5 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SInner, _ref5.cn("SInner", {
157
- "tag": 'span',
158
- "loading": loading,
159
- "data-ui-name": "".concat(_this3.asProps['data-ui-name'], ".InnerWrapper")
160
- }), 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", {
161
- "tag": 'span'
162
- }), /*#__PURE__*/React.createElement(SpinButton, _ref5.cn("SpinButton", {
163
- "centered": true,
164
- "size": size,
165
- "theme": useTheme
166
- })))));
167
- buttonProps.neighborLocation = neighborLocation;
168
- if (hasChildren === undefined || title) {
169
- return _this3.renderButtonWithHint({
170
- buttonProps: buttonProps,
171
- hintProps: hintProps,
172
- children: children
173
- });
174
- }
175
- return _this3.renderButton({
176
- buttonProps: buttonProps,
177
- children: children
178
- });
179
- });
180
- }
181
- }]);
182
- }(Component);
183
- _defineProperty(AbstractButton, "displayName", 'AbstractButton');
184
- //# sourceMappingURL=AbstractButton.js.map