@semcore/button 16.0.12-prerelease.1 → 16.0.13-prerelease.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -4
- package/lib/cjs/component/AbstractButton/AbstractButton.js +100 -165
- package/lib/cjs/component/AbstractButton/AbstractButton.js.map +1 -1
- package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +1 -1
- package/lib/cjs/component/AbstractButton/SpinButton.js +9 -10
- package/lib/cjs/component/AbstractButton/SpinButton.js.map +1 -1
- package/lib/cjs/component/Button/Button.js +54 -63
- package/lib/cjs/component/Button/Button.js.map +1 -1
- package/lib/cjs/component/Button/Button.type.js.map +1 -1
- package/lib/cjs/component/ButtonLink/ButtonLink.js +51 -59
- package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
- package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +7 -7
- package/lib/cjs/index.js +7 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/component/AbstractButton/AbstractButton.js +97 -164
- package/lib/es6/component/AbstractButton/AbstractButton.js.map +1 -1
- package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +1 -1
- package/lib/es6/component/AbstractButton/SpinButton.js +6 -7
- package/lib/es6/component/AbstractButton/SpinButton.js.map +1 -1
- package/lib/es6/component/Button/Button.js +47 -56
- package/lib/es6/component/Button/Button.js.map +1 -1
- package/lib/es6/component/Button/Button.type.js.map +1 -1
- package/lib/es6/component/ButtonLink/ButtonLink.js +44 -52
- package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
- package/lib/es6/component/ButtonLink/buttonLink.shadow.css +7 -7
- package/lib/esm/component/AbstractButton/AbstractButton.mjs +98 -136
- package/lib/esm/component/AbstractButton/SpinButton.mjs +6 -6
- package/lib/esm/component/Button/Button.mjs +47 -56
- package/lib/esm/component/ButtonLink/ButtonLink.mjs +44 -50
- package/lib/esm/component/ButtonLink/buttonLink.shadow.css +7 -7
- package/lib/types/component/AbstractButton/AbstractButton.d.ts +5 -6
- package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +2 -4
- package/lib/types/component/Button/Button.type.d.ts +2 -18
- package/package.json +6 -9
- package/src/component/AbstractButton/AbstractButton.tsx +58 -77
- package/src/component/AbstractButton/AbstractButton.type.ts +2 -4
- package/src/component/Button/Button.tsx +1 -1
- package/src/component/Button/Button.type.ts +1 -14
- package/src/component/ButtonLink/ButtonLink.tsx +1 -1
- package/src/component/ButtonLink/buttonLink.shadow.css +7 -7
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { NeighborLocation, Box, Hint } from '@semcore/base-components';
|
|
1
2
|
import { Component, CORE_INSTANCE, Root, sstyled } from '@semcore/core';
|
|
2
3
|
import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
3
4
|
import hasLabels from '@semcore/core/lib/utils/hasLabels';
|
|
4
5
|
import logger from '@semcore/core/lib/utils/logger';
|
|
5
|
-
import { Box } from '@semcore/flex-box';
|
|
6
|
-
import NeighborLocation from '@semcore/neighbor-location';
|
|
7
|
-
import { Hint } from '@semcore/tooltip';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
8
|
import type { AbstractButtonProps } from './AbstractButton.type';
|
|
@@ -18,12 +16,16 @@ export const MAP_USE_DEFAULT_THEME: Record<string, string> = {
|
|
|
18
16
|
|
|
19
17
|
type Props = AbstractButtonProps<any, any, any>;
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
type State = {
|
|
20
|
+
ariaLabelledByContent: null | string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export abstract class AbstractButton extends Component<Props, [], never, {}, State> {
|
|
22
24
|
static displayName = 'AbstractButton';
|
|
23
25
|
|
|
24
26
|
containerRef = React.createRef<HTMLButtonElement>();
|
|
25
27
|
|
|
26
|
-
state = {
|
|
28
|
+
state: State = {
|
|
27
29
|
ariaLabelledByContent: null,
|
|
28
30
|
};
|
|
29
31
|
|
|
@@ -70,28 +72,6 @@ export abstract class AbstractButton extends Component<Props, {}, {}> {
|
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
renderButton({ buttonProps, children }: any) {
|
|
74
|
-
const { styles, theme } = this.asProps;
|
|
75
|
-
const SButton = Root;
|
|
76
|
-
|
|
77
|
-
return sstyled(styles)(
|
|
78
|
-
<SButton render={Box} invertOutline={theme === 'invert'} {...buttonProps}>
|
|
79
|
-
{children}
|
|
80
|
-
</SButton>,
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
renderButtonWithHint({ buttonProps, children, hintProps }: any) {
|
|
85
|
-
const { styles, theme } = this.asProps;
|
|
86
|
-
const SButton = Root;
|
|
87
|
-
|
|
88
|
-
return sstyled(styles)(
|
|
89
|
-
<SButton render={Hint} invertOutline={theme === 'invert'} {...buttonProps} {...hintProps} ignorePortalsStacking>
|
|
90
|
-
{children}
|
|
91
|
-
</SButton>,
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
75
|
render() {
|
|
96
76
|
const {
|
|
97
77
|
styles,
|
|
@@ -101,7 +81,7 @@ export abstract class AbstractButton extends Component<Props, {}, {}> {
|
|
|
101
81
|
disabled = loading,
|
|
102
82
|
size,
|
|
103
83
|
neighborLocation,
|
|
104
|
-
children
|
|
84
|
+
children,
|
|
105
85
|
title,
|
|
106
86
|
['aria-label']: ariaLabel,
|
|
107
87
|
Children,
|
|
@@ -109,6 +89,7 @@ export abstract class AbstractButton extends Component<Props, {}, {}> {
|
|
|
109
89
|
addonRight: AddonRight,
|
|
110
90
|
hintPlacement,
|
|
111
91
|
} = this.asProps;
|
|
92
|
+
const SButton = Root;
|
|
112
93
|
// @ts-ignore
|
|
113
94
|
const Button = this[CORE_INSTANCE];
|
|
114
95
|
const useTheme = use && theme ? `${use}-${theme}` : false;
|
|
@@ -116,63 +97,63 @@ export abstract class AbstractButton extends Component<Props, {}, {}> {
|
|
|
116
97
|
const SSpin = Box;
|
|
117
98
|
const buttonAriaLabel = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';
|
|
118
99
|
|
|
119
|
-
const
|
|
120
|
-
'type': 'button',
|
|
121
|
-
'tag': 'button',
|
|
122
|
-
disabled,
|
|
123
|
-
'use:theme': useTheme,
|
|
124
|
-
'ref': this.containerRef,
|
|
125
|
-
'text-color': this.getTextColor(),
|
|
126
|
-
'aria-busy': loading,
|
|
127
|
-
'__excludeProps': ['title'],
|
|
128
|
-
'tabIndex': 0,
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const hintProps = {
|
|
132
|
-
title: buttonAriaLabel,
|
|
133
|
-
timeout: [250, 50],
|
|
134
|
-
placement: hintPlacement,
|
|
135
|
-
theme: theme === 'invert' ? 'invert' : undefined,
|
|
136
|
-
__excludeProps: [],
|
|
137
|
-
};
|
|
100
|
+
const showHint = (children === undefined || title);
|
|
138
101
|
|
|
139
102
|
return (
|
|
140
103
|
<NeighborLocation.Detect neighborLocation={neighborLocation}>
|
|
141
104
|
{(neighborLocation) => {
|
|
142
|
-
|
|
105
|
+
return sstyled(styles)(
|
|
143
106
|
<>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
{
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
107
|
+
<SButton
|
|
108
|
+
render={Box}
|
|
109
|
+
invertOutline={theme === 'invert'}
|
|
110
|
+
type='button'
|
|
111
|
+
tag='button'
|
|
112
|
+
tabIndex={0}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
use:theme={useTheme}
|
|
115
|
+
ref={this.containerRef}
|
|
116
|
+
text-color={this.getTextColor()}
|
|
117
|
+
aria-busy={loading}
|
|
118
|
+
__excludeProps={['title']}
|
|
119
|
+
aria-label={showHint ? buttonAriaLabel : undefined}
|
|
120
|
+
neighborLocation={neighborLocation}
|
|
121
|
+
>
|
|
122
|
+
{/* @ts-ignore */}
|
|
123
|
+
<SInner tag='span' loading={loading} data-ui-name={`${this.asProps['data-ui-name']}.InnerWrapper`}>
|
|
124
|
+
{AddonLeft
|
|
125
|
+
? (
|
|
126
|
+
<Button.Addon>
|
|
127
|
+
<AddonLeft />
|
|
128
|
+
</Button.Addon>
|
|
129
|
+
)
|
|
130
|
+
: null}
|
|
131
|
+
{addonTextChildren(Children, Button.Text, Button.Addon)}
|
|
132
|
+
{AddonRight
|
|
133
|
+
? (
|
|
134
|
+
<Button.Addon>
|
|
135
|
+
<AddonRight />
|
|
136
|
+
</Button.Addon>
|
|
137
|
+
)
|
|
138
|
+
: null}
|
|
139
|
+
</SInner>
|
|
140
|
+
{loading && (
|
|
141
|
+
<SSpin tag='span'>
|
|
142
|
+
<SpinButton centered size={size} theme={useTheme} />
|
|
143
|
+
</SSpin>
|
|
144
|
+
)}
|
|
145
|
+
</SButton>
|
|
146
|
+
{showHint && (
|
|
147
|
+
<Hint
|
|
148
|
+
triggerRef={this.containerRef}
|
|
149
|
+
timeout={[250, 50]}
|
|
150
|
+
placement={hintPlacement}
|
|
151
|
+
>
|
|
152
|
+
{buttonAriaLabel}
|
|
153
|
+
</Hint>
|
|
166
154
|
)}
|
|
167
155
|
</>,
|
|
168
156
|
);
|
|
169
|
-
buttonProps.neighborLocation = neighborLocation;
|
|
170
|
-
|
|
171
|
-
if (hasChildren === undefined || title) {
|
|
172
|
-
return this.renderButtonWithHint({ buttonProps, hintProps, children });
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return this.renderButton({ buttonProps, children });
|
|
176
157
|
}}
|
|
177
158
|
</NeighborLocation.Detect>
|
|
178
159
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
import type { BoxProps, NeighborItemProps, SimpleHintPopperProps } from '@semcore/base-components';
|
|
1
2
|
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
3
|
import type React from 'react';
|
|
6
4
|
|
|
7
5
|
export type AbstractButtonProps<S, U, T> = BoxProps &
|
|
@@ -20,7 +18,7 @@ export type AbstractButtonProps<S, U, T> = BoxProps &
|
|
|
20
18
|
* Placement for hint
|
|
21
19
|
* @default top
|
|
22
20
|
*/
|
|
23
|
-
hintPlacement?:
|
|
21
|
+
hintPlacement?: SimpleHintPopperProps['placement'];
|
|
24
22
|
|
|
25
23
|
/** Button size. Defined in Button.type or ButtonLink.type */
|
|
26
24
|
size?: S;
|
|
@@ -18,28 +18,15 @@ export type ButtonSize = 'l' | 'm';
|
|
|
18
18
|
*/
|
|
19
19
|
type Use = 'primary' | 'secondary' | 'tertiary';
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated don't use it. use `danger` for incorrect or danger behavior and `brand` for the orange one.
|
|
23
|
-
*/
|
|
24
|
-
type DeprecatedTheme = 'warning';
|
|
25
|
-
|
|
26
21
|
/** Button theme */
|
|
27
22
|
type Theme = 'info' | 'success' | 'brand' | 'danger' | 'muted' | 'invert';
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
export interface IButtonProps extends ButtonProps, UnknownProperties {}
|
|
31
|
-
export type ButtonProps = AbstractButtonProps<ButtonSize, Use, Theme | DeprecatedTheme>;
|
|
24
|
+
export type ButtonProps = AbstractButtonProps<ButtonSize, Use, Theme>;
|
|
32
25
|
|
|
33
|
-
/** @deprecated */
|
|
34
|
-
export interface IButtonTextProps extends ButtonTextProps, UnknownProperties {}
|
|
35
26
|
export type ButtonTextProps = AbstractButtonTextProps<ButtonSize>;
|
|
36
27
|
|
|
37
|
-
/** @deprecated */
|
|
38
|
-
export interface IButtonAddonProps extends ButtonAddonProps, UnknownProperties {}
|
|
39
28
|
export type ButtonAddonProps = AbstractButtonAddonProps<ButtonSize>;
|
|
40
29
|
|
|
41
|
-
/** @deprecated */
|
|
42
|
-
export interface IButtonContext extends ButtonContext, UnknownProperties {}
|
|
43
30
|
export type ButtonContext = AbstractButtonContext;
|
|
44
31
|
|
|
45
32
|
export type ButtonChildren = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Box } from '@semcore/base-components';
|
|
1
2
|
import { createComponent, sstyled, Root } from '@semcore/core';
|
|
2
3
|
import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
|
|
3
|
-
import { Box } from '@semcore/flex-box';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
6
|
import style from './buttonLink.shadow.css';
|
|
@@ -31,7 +31,7 @@ SButton {
|
|
|
31
31
|
color: var(--intergalactic-text-link-hover-active, #044792);
|
|
32
32
|
|
|
33
33
|
& SText {
|
|
34
|
-
|
|
34
|
+
box-shadow: 0 1px 0 0 currentColor;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -41,10 +41,8 @@ SButton {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
SText {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
border-color: transparent;
|
|
47
|
-
transition: border-bottom-color 0.15s ease-in-out;
|
|
44
|
+
box-shadow: 0 1px 0 0 transparent;
|
|
45
|
+
transition: box-shadow 0.15s ease-in-out;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -65,6 +63,7 @@ SButton[use='secondary'] {
|
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
SText {
|
|
66
|
+
box-shadow: none;
|
|
68
67
|
border-bottom-width: 1px;
|
|
69
68
|
border-bottom-style: dashed;
|
|
70
69
|
border-color: currentColor;
|
|
@@ -73,7 +72,7 @@ SButton[use='secondary'] {
|
|
|
73
72
|
|
|
74
73
|
SInner {
|
|
75
74
|
display: inline-flex;
|
|
76
|
-
align-items:
|
|
75
|
+
align-items: baseline;
|
|
77
76
|
justify-content: center;
|
|
78
77
|
height: 100%;
|
|
79
78
|
width: 100%;
|
|
@@ -82,9 +81,10 @@ SInner {
|
|
|
82
81
|
SAddon {
|
|
83
82
|
display: inline-flex;
|
|
84
83
|
justify-content: center;
|
|
85
|
-
align-items:
|
|
84
|
+
align-items: baseline;
|
|
86
85
|
vertical-align: middle;
|
|
87
86
|
pointer-events: none;
|
|
87
|
+
align-self: center;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
SButton SAddon {
|