@semcore/button 16.1.0 → 16.1.1

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 (49) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/lib/cjs/component/AbstractButton/AbstractButton.js +189 -0
  3. package/lib/cjs/component/AbstractButton/AbstractButton.js.map +1 -0
  4. package/lib/cjs/component/AbstractButton/AbstractButton.type.js +2 -0
  5. package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +1 -0
  6. package/lib/cjs/component/AbstractButton/SpinButton.js.map +1 -0
  7. package/lib/cjs/component/Button/Button.js +50 -160
  8. package/lib/cjs/component/Button/Button.js.map +1 -1
  9. package/lib/cjs/component/Button/Button.type.js.map +1 -1
  10. package/lib/cjs/component/ButtonLink/ButtonLink.js +54 -29
  11. package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
  12. package/lib/cjs/component/ButtonLink/ButtonLink.type.js.map +1 -1
  13. package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +140 -10
  14. package/lib/cjs/index.js +4 -3
  15. package/lib/cjs/index.js.map +1 -1
  16. package/lib/es6/component/AbstractButton/AbstractButton.js +184 -0
  17. package/lib/es6/component/AbstractButton/AbstractButton.js.map +1 -0
  18. package/lib/es6/component/AbstractButton/AbstractButton.type.js +2 -0
  19. package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +1 -0
  20. package/lib/es6/component/AbstractButton/SpinButton.js.map +1 -0
  21. package/lib/es6/component/Button/Button.js +49 -160
  22. package/lib/es6/component/Button/Button.js.map +1 -1
  23. package/lib/es6/component/Button/Button.type.js.map +1 -1
  24. package/lib/es6/component/ButtonLink/ButtonLink.js +56 -30
  25. package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
  26. package/lib/es6/component/ButtonLink/ButtonLink.type.js.map +1 -1
  27. package/lib/es6/component/ButtonLink/buttonLink.shadow.css +140 -10
  28. package/lib/es6/index.js +2 -1
  29. package/lib/es6/index.js.map +1 -1
  30. package/lib/esm/component/AbstractButton/AbstractButton.mjs +157 -0
  31. package/lib/esm/component/{Button → AbstractButton}/SpinButton.mjs +2 -1
  32. package/lib/esm/component/Button/Button.mjs +48 -140
  33. package/lib/esm/component/ButtonLink/ButtonLink.mjs +52 -30
  34. package/lib/esm/component/ButtonLink/buttonLink.shadow.css +140 -10
  35. package/lib/esm/index.mjs +2 -3
  36. package/lib/types/component/AbstractButton/AbstractButton.d.ts +24 -0
  37. package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +38 -0
  38. package/lib/types/component/Button/Button.d.ts +1 -28
  39. package/lib/types/component/Button/Button.type.d.ts +39 -40
  40. package/lib/types/component/ButtonLink/ButtonLink.type.d.ts +19 -14
  41. package/lib/types/index.d.ts +2 -1
  42. package/package.json +7 -7
  43. package/lib/cjs/component/Button/SpinButton.js.map +0 -1
  44. package/lib/es6/component/Button/SpinButton.js.map +0 -1
  45. package/lib/esm/component/Button/Button.type.mjs +0 -1
  46. package/lib/esm/component/ButtonLink/ButtonLink.type.mjs +0 -1
  47. /package/lib/cjs/component/{Button → AbstractButton}/SpinButton.js +0 -0
  48. /package/lib/es6/component/{Button → AbstractButton}/SpinButton.js +0 -0
  49. /package/lib/types/component/{Button → AbstractButton}/SpinButton.d.ts +0 -0
@@ -1,19 +1,61 @@
1
- SButtonLink {
2
- border: none;
1
+ SButton {
2
+ display: inline-flex;
3
3
  font-family: inherit;
4
- }
5
-
6
- SButtonLink[use='primary']:not([color]) {
4
+ font-size: var(--intergalactic-fs-200, 14px);
7
5
  color: var(--intergalactic-text-link, oklch(0.53 0.21 263));
6
+ line-height: normal;
7
+ position: relative;
8
+ cursor: pointer;
9
+ text-decoration: none;
10
+ border: none;
11
+ padding: 0;
12
+ margin: 0;
13
+ box-shadow: none;
14
+ -webkit-tap-highlight-color: transparent;
15
+ background: none;
16
+ transition: color 0.15s ease-in-out;
8
17
 
9
- &[active],
10
18
  &:active,
11
19
  &:hover {
20
+ text-decoration: none;
21
+ }
22
+
23
+ &::-moz-focus-inner {
24
+ border: none;
25
+ padding: 0;
26
+ }
27
+
28
+ &[active],
29
+ &:hover,
30
+ &:active {
12
31
  color: var(--intergalactic-text-link-hover-active, oklch(0.51 0.202 263));
32
+
33
+ & SText {
34
+ border-color: currentColor;
35
+ }
36
+ }
37
+
38
+ &[enableVisited]:visited,
39
+ &[enableVisited]:visited:hover {
40
+ color: var(--intergalactic-text-link-visited, oklch(0.53 0.26 296));
13
41
  }
42
+
43
+ SText {
44
+ border-bottom-width: 1px;
45
+ border-bottom-style: solid;
46
+ border-color: transparent;
47
+ transition: border-bottom-color 0.15s ease-in-out;
48
+ }
49
+ }
50
+
51
+ SButton[disabled] {
52
+ opacity: var(--intergalactic-disabled-opacity, 0.4);
53
+ cursor: default;
54
+ /* Disable link interactions */
55
+ pointer-events: none;
14
56
  }
15
57
 
16
- SButtonLink[use='secondary']:not([color]) {
58
+ SButton[use='secondary'] {
17
59
  color: var(--intergalactic-text-hint, oklch(0.088 0.026 147.7 / 0.583));
18
60
 
19
61
  &[active],
@@ -21,9 +63,97 @@ SButtonLink[use='secondary']:not([color]) {
21
63
  &:hover {
22
64
  color: var(--intergalactic-text-hint-hover-active, oklch(0.086 0.026 145.8 / 0.605));
23
65
  }
66
+
67
+ SText {
68
+ border-bottom-width: 1px;
69
+ border-bottom-style: dashed;
70
+ border-color: currentColor;
71
+ }
72
+ }
73
+
74
+ SInner {
75
+ display: inline-flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ height: 100%;
79
+ width: 100%;
80
+ }
81
+
82
+ SAddon {
83
+ display: inline-flex;
84
+ justify-content: center;
85
+ align-items: center;
86
+ vertical-align: middle;
87
+ pointer-events: none;
88
+ }
89
+
90
+ SButton SAddon {
91
+ &:not(:only-child):first-child {
92
+ margin-right: var(--intergalactic-spacing-1x, 4px);
93
+ }
94
+
95
+ &:not(:only-child):last-child {
96
+ margin-left: var(--intergalactic-spacing-1x, 4px);
97
+ }
98
+ }
99
+
100
+ SButton[text-color] {
101
+ color: var(--text-color);
102
+
103
+ &[active],
104
+ &:hover,
105
+ &:active {
106
+ color: var(--text-color);
107
+ filter: brightness(0.8);
108
+ }
109
+ }
110
+
111
+ SButton[size='100'] {
112
+ font-size: var(--intergalactic-fs-100, 12px);
113
+ line-height: var(--intergalactic-lh-100, 133%);
114
+ }
115
+
116
+ SButton[size='200'] {
117
+ font-size: var(--intergalactic-fs-200, 14px);
118
+ line-height: var(--intergalactic-lh-200, 142%);
119
+ }
120
+
121
+ SButton[size='300'] {
122
+ font-size: var(--intergalactic-fs-300, 16px);
123
+ line-height: var(--intergalactic-lh-300, 150%);
24
124
  }
25
125
 
26
- SButtonLink[use='secondary'] SText {
27
- text-decoration-style: dashed;
28
- text-decoration-color: currentColor;
126
+ SButton[size='400'] {
127
+ font-size: var(--intergalactic-fs-400, 20px);
128
+ line-height: var(--intergalactic-lh-400, 120%);
129
+ }
130
+
131
+ SButton[size='500'] {
132
+ font-size: var(--intergalactic-fs-500, 24px);
133
+ line-height: var(--intergalactic-lh-500, 117%);
134
+ }
135
+
136
+ SButton[size='600'] {
137
+ font-size: var(--intergalactic-fs-600, 32px);
138
+ line-height: var(--intergalactic-lh-600, 125%);
139
+ }
140
+
141
+ SButton[size='700'] {
142
+ font-size: var(--intergalactic-fs-700, 36px);
143
+ line-height: var(--intergalactic-lh-700, 110%);
144
+ }
145
+
146
+ SButton[size='800'] {
147
+ font-size: var(--intergalactic-fs-800, 48px);
148
+ line-height: var(--intergalactic-lh-800, 117%);
149
+ }
150
+
151
+ @media (prefers-reduced-motion) {
152
+ SButton {
153
+ transition: none;
154
+ }
155
+
156
+ SText {
157
+ transition: none;
158
+ }
29
159
  }
package/lib/es6/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export { default, MAP_USE_DEFAULT_THEME } from './component/Button/Button';
1
+ export { default } 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';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","MAP_USE_DEFAULT_THEME"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, MAP_USE_DEFAULT_THEME } from './component/Button/Button';\nexport * from './component/Button/Button.type';\nexport * from './component/ButtonLink/ButtonLink';\nexport * from './component/ButtonLink/ButtonLink.type';\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,qBAAqB,QAAQ,2BAA2B;AAC1E,cAAc,gCAAgC;AAC9C,cAAc,mCAAmC;AACjD,cAAc,wCAAwC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","MAP_USE_DEFAULT_THEME"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './component/Button/Button';\nexport * from './component/Button/Button.type';\nexport * from './component/ButtonLink/ButtonLink';\nexport * from './component/ButtonLink/ButtonLink.type';\nexport { MAP_USE_DEFAULT_THEME } from './component/AbstractButton/AbstractButton';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,2BAA2B;AACnD,cAAc,gCAAgC;AAC9C,cAAc,mCAAmC;AACjD,cAAc,wCAAwC;AACtD,SAASC,qBAAqB,QAAQ,2CAA2C","ignoreList":[]}
@@ -0,0 +1,157 @@
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
+ };
@@ -10,7 +10,8 @@ var SPIN_SIZE_MAP = {
10
10
  s: "xxs"
11
11
  };
12
12
  function SpinButton(_ref) {
13
- var theme = _ref.theme, size = _ref.size, others = _objectWithoutProperties(_ref, _excluded);
13
+ _ref.theme;
14
+ var size = _ref.size, others = _objectWithoutProperties(_ref, _excluded);
14
15
  return /* @__PURE__ */ React.createElement(Spin, _extends({
15
16
  size: typeof size === "string" ? SPIN_SIZE_MAP[size] : size,
16
17
  theme: "currentColor"