@cyber-harbour/ui 1.0.62 → 1.0.63
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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +113 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Button/Button.tsx +16 -5
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { CSSProperties } from 'styled-components';
|
|
3
3
|
import {
|
|
4
4
|
ButtonVariant,
|
|
5
5
|
ButtonSize,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
generatePropertySpaceStyle,
|
|
12
12
|
createStyledComponent,
|
|
13
13
|
StyledFabricComponent,
|
|
14
|
+
pxToRem,
|
|
14
15
|
} from '../../Theme';
|
|
15
16
|
|
|
16
17
|
type BaseButtonProps = {
|
|
@@ -24,6 +25,8 @@ type BaseButtonProps = {
|
|
|
24
25
|
icon?: any;
|
|
25
26
|
iconPosition?: 'left' | 'right';
|
|
26
27
|
iconVariant?: 'filled' | 'empty';
|
|
28
|
+
minWidth?: number;
|
|
29
|
+
whiteSpace?: CSSProperties['whiteSpace'];
|
|
27
30
|
};
|
|
28
31
|
export type ButtonProps = (
|
|
29
32
|
| Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children' | 'media'>
|
|
@@ -47,12 +50,14 @@ const getIconStyles = (styles: ButtonElementStyle) =>
|
|
|
47
50
|
: '';
|
|
48
51
|
|
|
49
52
|
// Створюємо стилізований компонент, що використовує уніфіковану палітру
|
|
50
|
-
const ButtonTextContainer = styled.div
|
|
53
|
+
const ButtonTextContainer = styled.div<{ $whiteSpace: CSSProperties['whiteSpace'] }>(
|
|
54
|
+
({ $whiteSpace }) => `
|
|
51
55
|
text-overflow: ellipsis;
|
|
52
56
|
overflow: hidden;
|
|
53
|
-
white-space:
|
|
57
|
+
white-space: ${$whiteSpace};
|
|
54
58
|
user-select: text;
|
|
55
|
-
|
|
59
|
+
`
|
|
60
|
+
);
|
|
56
61
|
|
|
57
62
|
const StyledIconWrapper = styled.span`
|
|
58
63
|
display: inline-flex;
|
|
@@ -68,6 +73,7 @@ type StyledButtonProps = {
|
|
|
68
73
|
$fullWidth: boolean;
|
|
69
74
|
$iconPosition: 'left' | 'right';
|
|
70
75
|
$iconVariant: 'filled' | 'empty';
|
|
76
|
+
$minWidth?: number;
|
|
71
77
|
};
|
|
72
78
|
|
|
73
79
|
const StyledButton = createStyledComponent(
|
|
@@ -80,6 +86,7 @@ const StyledButton = createStyledComponent(
|
|
|
80
86
|
$fullWidth,
|
|
81
87
|
$iconPosition,
|
|
82
88
|
$iconVariant,
|
|
89
|
+
$minWidth,
|
|
83
90
|
theme,
|
|
84
91
|
px = $variant !== 'empty' ? theme.button.sizes[$size].paddingInline : 0,
|
|
85
92
|
py = $variant !== 'empty' ? theme.button.sizes[$size].paddingBlock : 0,
|
|
@@ -105,6 +112,7 @@ const StyledButton = createStyledComponent(
|
|
|
105
112
|
transition: all 0.2s ease;
|
|
106
113
|
outline: none;
|
|
107
114
|
user-select: text;
|
|
115
|
+
${typeof $minWidth === 'number' ? `min-width: ${pxToRem($minWidth, theme.baseSize)};` : ''}
|
|
108
116
|
|
|
109
117
|
${$iconPosition === 'right' ? 'flex-direction: row-reverse;' : ''}
|
|
110
118
|
|
|
@@ -172,6 +180,8 @@ export const Button = createComponent<ButtonProps>(
|
|
|
172
180
|
icon,
|
|
173
181
|
iconPosition = 'left',
|
|
174
182
|
iconVariant = 'empty',
|
|
183
|
+
whiteSpace = 'nowrap',
|
|
184
|
+
minWidth,
|
|
175
185
|
...props
|
|
176
186
|
}) => {
|
|
177
187
|
return (
|
|
@@ -185,12 +195,13 @@ export const Button = createComponent<ButtonProps>(
|
|
|
185
195
|
$fullWidth={fullWidth}
|
|
186
196
|
$iconPosition={iconPosition}
|
|
187
197
|
$iconVariant={iconVariant}
|
|
198
|
+
$minWidth={minWidth}
|
|
188
199
|
disabled={disabled}
|
|
189
200
|
className={className}
|
|
190
201
|
{...props}
|
|
191
202
|
>
|
|
192
203
|
{!!icon && <StyledIconWrapper>{icon}</StyledIconWrapper>}
|
|
193
|
-
{!!children && <ButtonTextContainer>{children}</ButtonTextContainer>}
|
|
204
|
+
{!!children && <ButtonTextContainer $whiteSpace={whiteSpace}>{children}</ButtonTextContainer>}
|
|
194
205
|
</StyledButton>
|
|
195
206
|
);
|
|
196
207
|
}
|