@synerise/ds-button 1.5.26 → 1.5.27
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 +4 -0
- package/README.md +1 -1
- package/dist/BaseButton.d.ts +22 -0
- package/dist/BaseButton.js +89 -0
- package/dist/BaseButton.styles.d.ts +1 -0
- package/dist/BaseButton.styles.js +11 -0
- package/dist/BaseButton.types.d.ts +29 -0
- package/dist/BaseButton.types.js +1 -0
- package/dist/Button.d.ts +5 -11
- package/dist/Button.js +34 -28
- package/dist/Button.styles.d.ts +29 -15
- package/dist/Button.styles.js +9 -31
- package/dist/Button.types.d.ts +18 -20
- package/dist/Button.types.js +7 -8
- package/dist/Button.variants.d.ts +16 -0
- package/dist/Button.variants.js +48 -0
- package/dist/ButtonToggle/ButtonToggle.styles.js +1 -1
- package/dist/Checkbox/Checkbox.styles.js +1 -1
- package/dist/Creator/Creator.styles.d.ts +13 -21
- package/dist/Creator/Creator.styles.js +11 -15
- package/dist/Expander/Expander.js +1 -1
- package/dist/Expander/Expander.styles.d.ts +19 -6
- package/dist/Expander/Expander.styles.js +5 -9
- package/dist/Expander/Expander.types.d.ts +3 -5
- package/dist/Expander/Expander.types.js +4 -5
- package/dist/Star/Star.styles.js +1 -1
- package/dist/Star/Star.types.d.ts +2 -2
- package/dist/index.d.ts +5 -12
- package/package.json +3 -7
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/style/index.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.5.27](https://github.com/synerise/synerise-design/compare/@synerise/ds-button@1.5.26...@synerise/ds-button@1.5.27) (2026-05-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-button
|
|
9
|
+
|
|
6
10
|
## [1.5.26](https://github.com/synerise/synerise-design/compare/@synerise/ds-button@1.5.25...@synerise/ds-button@1.5.26) (2026-05-04)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ import { version } from './package.json';
|
|
|
15
15
|
|
|
16
16
|
Buttons allow users to take actions, and make choices, with a single tap. Buttons communicate actions that users can take. They are typically placed throughout your UI, in places such as dialogs, modal windows, forms, cards, and toolbars.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Standalone button component for the Synerise Design System.
|
|
19
19
|
|
|
20
20
|
## When to use it
|
|
21
21
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Base button component.
|
|
4
|
+
*
|
|
5
|
+
* Produces CSS class names:
|
|
6
|
+
* ant-btn ant-btn-{type} [ant-btn-lg] [ant-btn-sm] [ant-btn-block] [ant-btn-loading]
|
|
7
|
+
*/
|
|
8
|
+
declare const BaseButton: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onClick"> & {
|
|
9
|
+
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
10
|
+
type?: string;
|
|
11
|
+
size?: import('./BaseButton.types').ButtonSize;
|
|
12
|
+
loading?: boolean | {
|
|
13
|
+
delay?: number;
|
|
14
|
+
};
|
|
15
|
+
block?: boolean;
|
|
16
|
+
htmlType?: import('./BaseButton.types').ButtonHTMLType;
|
|
17
|
+
href?: string;
|
|
18
|
+
target?: string;
|
|
19
|
+
download?: string | boolean;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
} & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
22
|
+
export default BaseButton;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { forwardRef, useState, useEffect } from "react";
|
|
3
|
+
import { Button } from "./BaseButton.styles.js";
|
|
4
|
+
const sizeClassMap = {
|
|
5
|
+
large: "ant-btn-lg",
|
|
6
|
+
small: "ant-btn-sm"
|
|
7
|
+
};
|
|
8
|
+
function isFragment(child) {
|
|
9
|
+
return React.isValidElement(child) && child.type === React.Fragment;
|
|
10
|
+
}
|
|
11
|
+
function wrapChildren(children) {
|
|
12
|
+
return React.Children.map(children, (child) => {
|
|
13
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
14
|
+
return /* @__PURE__ */ jsx("span", { children: child });
|
|
15
|
+
}
|
|
16
|
+
if (isFragment(child)) {
|
|
17
|
+
return /* @__PURE__ */ jsx("span", { children: child });
|
|
18
|
+
}
|
|
19
|
+
return child;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const BaseButton = forwardRef(({
|
|
23
|
+
type = "default",
|
|
24
|
+
size,
|
|
25
|
+
loading = false,
|
|
26
|
+
block = false,
|
|
27
|
+
htmlType = "button",
|
|
28
|
+
href,
|
|
29
|
+
target,
|
|
30
|
+
download,
|
|
31
|
+
className,
|
|
32
|
+
children,
|
|
33
|
+
disabled,
|
|
34
|
+
onClick,
|
|
35
|
+
...rest
|
|
36
|
+
}, ref) => {
|
|
37
|
+
const [innerLoading, setInnerLoading] = useState(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
let delayTimer = null;
|
|
40
|
+
if (typeof loading === "object" && loading.delay) {
|
|
41
|
+
delayTimer = setTimeout(() => {
|
|
42
|
+
delayTimer = null;
|
|
43
|
+
setInnerLoading(true);
|
|
44
|
+
}, loading.delay);
|
|
45
|
+
} else {
|
|
46
|
+
setInnerLoading(!!loading);
|
|
47
|
+
}
|
|
48
|
+
return () => {
|
|
49
|
+
if (delayTimer) {
|
|
50
|
+
clearTimeout(delayTimer);
|
|
51
|
+
delayTimer = null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [loading]);
|
|
55
|
+
const handleClick = (e) => {
|
|
56
|
+
if (innerLoading || disabled) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
onClick?.(e);
|
|
61
|
+
};
|
|
62
|
+
const classes = ["ant-btn", type && `ant-btn-${type}`, size && sizeClassMap[size], block && "ant-btn-block", innerLoading && "ant-btn-loading", className].filter(Boolean).join(" ");
|
|
63
|
+
const sharedProps = {
|
|
64
|
+
className: classes,
|
|
65
|
+
"aria-disabled": innerLoading || disabled || void 0,
|
|
66
|
+
tabIndex: innerLoading ? -1 : void 0,
|
|
67
|
+
onClick: handleClick,
|
|
68
|
+
...rest
|
|
69
|
+
};
|
|
70
|
+
if (href) {
|
|
71
|
+
const anchorProps = {
|
|
72
|
+
...sharedProps,
|
|
73
|
+
as: "a",
|
|
74
|
+
ref,
|
|
75
|
+
href: disabled ? void 0 : href,
|
|
76
|
+
target,
|
|
77
|
+
download
|
|
78
|
+
};
|
|
79
|
+
return (
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
/* @__PURE__ */ jsx(Button, { ...anchorProps, children: wrapChildren(children) })
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ jsx(Button, { ref, type: htmlType, disabled, ...sharedProps, children: wrapChildren(children) });
|
|
85
|
+
});
|
|
86
|
+
BaseButton.displayName = "BaseButton";
|
|
87
|
+
export {
|
|
88
|
+
BaseButton as default
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Button: import('styled-components').StyledComponent<"button", any, {}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const dsProps = /* @__PURE__ */ new Set(["mode", "justifyContent", "groupVariant", "customColor", "pressed", "iconColor", "error", "readOnly", "expanderSize", "expanded", "htmlType", "loading"]);
|
|
3
|
+
const Button = /* @__PURE__ */ styled.button.withConfig({
|
|
4
|
+
shouldForwardProp: (prop) => !dsProps.has(prop)
|
|
5
|
+
}).withConfig({
|
|
6
|
+
displayName: "BaseButtonstyles__Button",
|
|
7
|
+
componentId: "sc-tbau7c-0"
|
|
8
|
+
})(["&{position:relative;font-weight:500;white-space:nowrap;text-align:center;background-image:none;border:0 solid transparent;box-shadow:none;text-shadow:none;cursor:pointer;transition:all 0.3s cubic-bezier(0.645,0.045,0.355,1);user-select:none;touch-action:manipulation;height:32px;font-size:13px;border-radius:3px;outline:0;text-decoration:none;&:not([disabled]):hover{text-decoration:none;}&:not([disabled]):active{outline:0;}&[disabled]{cursor:not-allowed;}> span{display:contents;}&.ant-btn-lg{height:48px;font-size:14px;}&.ant-btn-sm{height:28px;padding:0 12px;font-size:13px;}&.ant-btn-block{width:100%;}&.ant-btn-loading{cursor:default;pointer-events:none;}}"]);
|
|
9
|
+
export {
|
|
10
|
+
Button
|
|
11
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export type ButtonSize = 'small' | 'middle' | 'large';
|
|
3
|
+
export type ButtonHTMLType = 'submit' | 'button' | 'reset';
|
|
4
|
+
export type BaseButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onClick'> & {
|
|
5
|
+
/** Click handler — typed with HTMLElement to support both button and anchor rendering */
|
|
6
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
7
|
+
/** Any string — becomes `ant-btn-{type}` CSS class */
|
|
8
|
+
type?: string;
|
|
9
|
+
/** Button size — affects height and padding */
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
/** Shows a spinning overlay. Pass `{ delay: ms }` to debounce short loading states */
|
|
12
|
+
loading?: boolean | {
|
|
13
|
+
delay?: number;
|
|
14
|
+
};
|
|
15
|
+
/** Stretches the button to full width of its container */
|
|
16
|
+
block?: boolean;
|
|
17
|
+
/** HTML type attribute for the underlying button element
|
|
18
|
+
* @default button
|
|
19
|
+
*/
|
|
20
|
+
htmlType?: ButtonHTMLType;
|
|
21
|
+
/** When provided, renders as an `<a>` element instead of `<button>` */
|
|
22
|
+
href?: string;
|
|
23
|
+
/** Link target — only used when `href` is set */
|
|
24
|
+
target?: string;
|
|
25
|
+
/** Download filename — only used when `href` is set */
|
|
26
|
+
download?: string | boolean;
|
|
27
|
+
/** Button content — text label, icons, or any ReactNode */
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/Button.d.ts
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { default as React, MouseEvent } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} & import('antd/lib/button/button').BaseButtonProps & Omit<React.AnchorHTMLAttributes<any>, "type" | "onClick"> & {
|
|
7
|
-
htmlType?: import('antd/lib/button/button').ButtonHTMLType;
|
|
8
|
-
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
9
|
-
} & Omit<React.ButtonHTMLAttributes<any>, "type" | "onClick">>, "ghost" | "type"> & {
|
|
10
|
-
type?: import('@synerise/ds-utils').LiteralStringUnion<import('./Button.types').ButtonType>;
|
|
11
|
-
mode?: import('@synerise/ds-utils').LiteralStringUnion<"single-icon" | "split" | "two-icons" | "label-icon" | "icon-label">;
|
|
2
|
+
import { ButtonMode } from './Button.types';
|
|
3
|
+
declare const Button: React.ForwardRefExoticComponent<Omit<import('./BaseButton.types').BaseButtonProps, "type"> & {
|
|
4
|
+
type?: import('./Button.types').ButtonType;
|
|
5
|
+
mode?: import('@synerise/ds-utils').LiteralStringUnion<ButtonMode>;
|
|
12
6
|
color?: import('@synerise/ds-utils').LiteralStringUnion<"blue" | "grey" | "red" | "green" | "yellow" | "pink" | "mars" | "orange" | "fern" | "cyan" | "purple" | "violet">;
|
|
13
7
|
groupVariant?: import('@synerise/ds-utils').LiteralStringUnion<"left-rounded" | "squared" | "right-rounded">;
|
|
14
|
-
justifyContent?: import('csstype').JustifyContentProperty;
|
|
15
8
|
loading?: boolean | {
|
|
16
9
|
delay?: number;
|
|
17
10
|
};
|
|
11
|
+
icon?: React.ReactNode;
|
|
18
12
|
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
19
13
|
iconColor?: import('@synerise/ds-utils').LiteralStringUnion<"blue" | "grey" | "red" | "green" | "yellow" | "pink" | "mars" | "orange" | "fern" | "cyan" | "purple" | "violet">;
|
|
20
14
|
error?: boolean;
|
package/dist/Button.js
CHANGED
|
@@ -3,28 +3,28 @@ import { forwardRef, useRef, useState, useEffect, useMemo } from "react";
|
|
|
3
3
|
import Icon, { SpinnerM } from "@synerise/ds-icon";
|
|
4
4
|
import { TagShape } from "@synerise/ds-tag";
|
|
5
5
|
import Tooltip from "@synerise/ds-tooltip";
|
|
6
|
-
import { RIPPLE_ANIMATION_TIME, ButtonLabel, Tag,
|
|
6
|
+
import { RIPPLE_ANIMATION_TIME, ButtonLabel, Tag, StyledButton, RippleEffect, Spinner, ButtonFocus, ACTIVE_DELAY } from "./Button.styles.js";
|
|
7
7
|
import { ButtonMode } from "./Button.types.js";
|
|
8
|
-
import "./style/index.css";
|
|
9
8
|
const RIPPLE_ANIMATION_OFFSET = 50;
|
|
10
9
|
const Button = forwardRef(({
|
|
11
10
|
type = "secondary",
|
|
12
11
|
mode,
|
|
13
|
-
justifyContent = "center",
|
|
14
12
|
groupVariant,
|
|
15
13
|
loading = false,
|
|
16
14
|
onClick,
|
|
17
15
|
className,
|
|
18
16
|
color = "red",
|
|
19
17
|
error,
|
|
18
|
+
icon,
|
|
20
19
|
tagProps,
|
|
21
20
|
children,
|
|
22
21
|
tooltipProps,
|
|
23
|
-
...
|
|
22
|
+
...restProps
|
|
24
23
|
}, forwardedRef) => {
|
|
25
24
|
const rippleRef = useRef(null);
|
|
26
25
|
const [rippleClassName, setRippleClassName] = useState("");
|
|
27
26
|
const [pressed, setPressed] = useState(false);
|
|
27
|
+
const activeTimerRef = useRef(null);
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
let rippleAnimation;
|
|
30
30
|
if (rippleClassName !== "") {
|
|
@@ -36,7 +36,14 @@ const Button = forwardRef(({
|
|
|
36
36
|
rippleAnimation && clearTimeout(rippleAnimation);
|
|
37
37
|
};
|
|
38
38
|
}, [rippleClassName]);
|
|
39
|
-
const
|
|
39
|
+
const clearActiveTimer = () => {
|
|
40
|
+
if (activeTimerRef.current) {
|
|
41
|
+
clearTimeout(activeTimerRef.current);
|
|
42
|
+
activeTimerRef.current = null;
|
|
43
|
+
}
|
|
44
|
+
setPressed(false);
|
|
45
|
+
};
|
|
46
|
+
const handleMouseDown = (event) => {
|
|
40
47
|
const button = event.currentTarget.closest(".ant-btn");
|
|
41
48
|
if (button) {
|
|
42
49
|
const buttonBoundingRect = button.getBoundingClientRect();
|
|
@@ -46,36 +53,35 @@ const Button = forwardRef(({
|
|
|
46
53
|
rippleRef.current.style.cssText = `top: ${y}px; left: ${x}px`;
|
|
47
54
|
}
|
|
48
55
|
setRippleClassName("animate");
|
|
49
|
-
onClick && onClick(event);
|
|
50
56
|
}
|
|
57
|
+
clearActiveTimer();
|
|
58
|
+
activeTimerRef.current = setTimeout(() => {
|
|
59
|
+
setPressed(true);
|
|
60
|
+
}, ACTIVE_DELAY);
|
|
61
|
+
};
|
|
62
|
+
const handleClick = (event) => {
|
|
63
|
+
onClick && onClick(event);
|
|
51
64
|
};
|
|
52
65
|
const classNameString = useMemo(() => {
|
|
53
66
|
const modeStringifed = mode || "";
|
|
54
|
-
const readOnlyStringifed =
|
|
67
|
+
const readOnlyStringifed = restProps.readOnly ? "read-only" : "";
|
|
55
68
|
const classNameStringifed = className || "";
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
const pressedStringified = pressed ? "pressed" : "";
|
|
70
|
+
return `ds-button ${modeStringifed} ${classNameStringifed} ${readOnlyStringifed} ${pressedStringified}`;
|
|
71
|
+
}, [mode, className, restProps.readOnly, pressed]);
|
|
72
|
+
const iconBefore = icon && mode !== ButtonMode.LABEL_ICON ? icon : null;
|
|
73
|
+
const iconAfter = icon && mode === ButtonMode.LABEL_ICON ? icon : null;
|
|
58
74
|
const buttonLabel = useMemo(() => {
|
|
59
|
-
const label = /* @__PURE__ */ jsxs(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
children: [
|
|
66
|
-
children,
|
|
67
|
-
tagProps && mode !== ButtonMode.SINGLE_ICON && /* @__PURE__ */ jsx(Tag, { ...tagProps, shape: TagShape.MEDIUM_ROUND, asPill: true })
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
);
|
|
75
|
+
const label = /* @__PURE__ */ jsxs(ButtonLabel, { withTooltip: !!tooltipProps, "data-testid": "ds-button-label", className: "ds-button-label", children: [
|
|
76
|
+
iconBefore,
|
|
77
|
+
children,
|
|
78
|
+
iconAfter,
|
|
79
|
+
tagProps && mode !== ButtonMode.SINGLE_ICON && /* @__PURE__ */ jsx(Tag, { ...tagProps, shape: TagShape.MEDIUM_ROUND, asPill: true })
|
|
80
|
+
] });
|
|
71
81
|
return tooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...tooltipProps, children: label }) : label;
|
|
72
|
-
}, [children, tagProps, mode, tooltipProps]);
|
|
73
|
-
return /* @__PURE__ */ jsxs(
|
|
74
|
-
|
|
75
|
-
}, onMouseUp: () => {
|
|
76
|
-
setPressed(false);
|
|
77
|
-
}, pressed, className: classNameString, customColor: color, ...antdProps, children: [
|
|
78
|
-
!antdProps.readOnly && /* @__PURE__ */ jsx(RippleEffect, { ref: rippleRef, className: `btn-ripple ${rippleClassName}` }),
|
|
82
|
+
}, [children, tagProps, mode, tooltipProps, iconBefore, iconAfter]);
|
|
83
|
+
return /* @__PURE__ */ jsxs(StyledButton, { ref: forwardedRef, type: type || "secondary", mode, error, groupVariant, loading, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: clearActiveTimer, onMouseLeave: clearActiveTimer, className: classNameString, customColor: color, ...restProps, children: [
|
|
84
|
+
!restProps.readOnly && /* @__PURE__ */ jsx(RippleEffect, { ref: rippleRef, className: `btn-ripple ${rippleClassName}` }),
|
|
79
85
|
buttonLabel,
|
|
80
86
|
loading && /* @__PURE__ */ jsx(Spinner, { className: "btn-spinner", "data-testid": "button-spinner", children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SpinnerM, {}) }) }),
|
|
81
87
|
/* @__PURE__ */ jsx(ButtonFocus, { className: "btn-focus" })
|
package/dist/Button.styles.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { ButtonProps } from './Button.types';
|
|
3
1
|
export declare const RIPPLE_ANIMATION_TIME = 500;
|
|
2
|
+
export declare const ACTIVE_DELAY = 200;
|
|
4
3
|
export declare const Spinner: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
5
4
|
export declare const RippleEffect: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
6
5
|
export declare const ButtonFocus: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
7
|
-
export declare const Tag: import('styled-components').StyledComponent<
|
|
6
|
+
export declare const Tag: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<{
|
|
8
7
|
id?: string | number;
|
|
9
8
|
name?: string;
|
|
10
9
|
textColor?: string;
|
|
@@ -22,20 +21,35 @@ export declare const Tag: import('styled-components').StyledComponent<React.Forw
|
|
|
22
21
|
asPill?: boolean;
|
|
23
22
|
dashed?: boolean;
|
|
24
23
|
tooltipProps?: import('@synerise/ds-tooltip').TooltipProps;
|
|
25
|
-
} & Omit<
|
|
24
|
+
} & Omit<import('react').HTMLAttributes<HTMLDivElement>, "image" | "name" | "className" | "color" | "id" | "onClick" | "shape" | "disabled" | "textColor" | "removable" | "onRemove" | "prefixel" | "suffixel" | "texts" | "asPill" | "dashed" | "tooltipProps"> & import('@synerise/ds-utils').DataAttributes & import('react').RefAttributes<HTMLDivElement>>, any, {}, never>;
|
|
26
25
|
export declare const ButtonLabel: import('styled-components').StyledComponent<"div", any, {
|
|
27
26
|
withTooltip?: boolean;
|
|
28
27
|
}, never>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
36
|
-
} & Omit<React.ButtonHTMLAttributes<any>, "type" | "onClick">>, "type"> & Pick<ButtonProps, "mode" | "justifyContent" | "groupVariant" | "iconColor" | "error"> & {
|
|
37
|
-
pressed: boolean;
|
|
38
|
-
customColor: string;
|
|
28
|
+
type StyledButtonProps = {
|
|
29
|
+
mode?: string;
|
|
30
|
+
groupVariant?: string;
|
|
31
|
+
iconColor?: string;
|
|
32
|
+
error?: boolean;
|
|
33
|
+
customColor?: string;
|
|
39
34
|
readOnly?: boolean;
|
|
40
35
|
type: string;
|
|
41
|
-
|
|
36
|
+
size?: string;
|
|
37
|
+
loading?: boolean | {
|
|
38
|
+
delay?: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare const StyledButton: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<Omit<import('react').ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onClick"> & {
|
|
42
|
+
onClick?: (event: import('react').MouseEvent<HTMLElement>) => void;
|
|
43
|
+
type?: string;
|
|
44
|
+
size?: import('./BaseButton.types').ButtonSize;
|
|
45
|
+
loading?: boolean | {
|
|
46
|
+
delay?: number;
|
|
47
|
+
};
|
|
48
|
+
block?: boolean;
|
|
49
|
+
htmlType?: import('./BaseButton.types').ButtonHTMLType;
|
|
50
|
+
href?: string;
|
|
51
|
+
target?: string;
|
|
52
|
+
download?: string | boolean;
|
|
53
|
+
children?: import('react').ReactNode;
|
|
54
|
+
} & import('react').RefAttributes<HTMLAnchorElement | HTMLButtonElement>>, any, StyledButtonProps, never>;
|
|
55
|
+
export {};
|
package/dist/Button.styles.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from "antd";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
1
|
import styled, { css, keyframes } from "styled-components";
|
|
5
2
|
import { IconContainer } from "@synerise/ds-icon";
|
|
6
3
|
import DSTag from "@synerise/ds-tag";
|
|
4
|
+
import BaseButton from "./BaseButton.js";
|
|
5
|
+
import { getVariantStyles } from "./Button.variants.js";
|
|
7
6
|
const RIPPLE_ANIMATION_TIME = 500;
|
|
7
|
+
const ACTIVE_DELAY = 200;
|
|
8
8
|
const leftIcon = "0 4px 0 8px";
|
|
9
9
|
const rightIcon = "0 8px 0 4px";
|
|
10
10
|
const rippleInitialSize = 20;
|
|
11
|
-
const buttonTypes = ["secondary", "tertiary", "ghost"];
|
|
12
11
|
const splitTypes = ["secondary", "tertiary"];
|
|
13
12
|
const pressedStyles = (props) => css(["color:", ";background:", ";&.ant-btn .btn-focus{box-shadow:inset 0 0 0 1px ", ";}", " > .ds-icon:before{background-color:", ";}"], props.theme.palette["blue-600"], props.theme.palette["blue-100"], props.theme.palette["blue-300"], ButtonLabel, props.theme.palette["blue-200"]);
|
|
14
13
|
const spinnerAnimation = /* @__PURE__ */ keyframes(["from{transform:rotateZ(0deg);}to{transform:rotateZ(360deg);}"]);
|
|
@@ -32,42 +31,21 @@ const Tag = /* @__PURE__ */ styled(DSTag).withConfig({
|
|
|
32
31
|
const ButtonLabel = /* @__PURE__ */ styled.div.withConfig({
|
|
33
32
|
displayName: "Buttonstyles__ButtonLabel",
|
|
34
33
|
componentId: "sc-3lgta1-4"
|
|
35
|
-
})(["display:flex;align-items:center;flex-grow:1;min-width:0;justify-content:center;", ""], (props) => props.withTooltip && `
|
|
34
|
+
})(["display:flex;align-items:center;flex-grow:1;min-width:0;z-index:1;position:relative;justify-content:center;", ""], (props) => props.withTooltip && `
|
|
36
35
|
&& {
|
|
37
36
|
pointer-events: all;
|
|
38
37
|
}`);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
type,
|
|
42
|
-
loading,
|
|
43
|
-
justifyContent,
|
|
44
|
-
groupVariant,
|
|
45
|
-
customColor,
|
|
46
|
-
pressed,
|
|
47
|
-
size,
|
|
48
|
-
iconColor,
|
|
49
|
-
error,
|
|
50
|
-
...rest
|
|
51
|
-
}, ref) => {
|
|
52
|
-
return /* @__PURE__ */ jsx(
|
|
53
|
-
Button,
|
|
54
|
-
{
|
|
55
|
-
ref,
|
|
56
|
-
type: type === "custom-color-ghost" ? "ghost-primary" : type,
|
|
57
|
-
size,
|
|
58
|
-
...rest
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
})).withConfig({
|
|
62
|
-
displayName: "Buttonstyles__AntdButton",
|
|
38
|
+
const StyledButton = /* @__PURE__ */ styled(BaseButton).withConfig({
|
|
39
|
+
displayName: "Buttonstyles__StyledButton",
|
|
63
40
|
componentId: "sc-3lgta1-5"
|
|
64
|
-
})([" &&{-webkit-mask-image:-webkit-radial-gradient(white,black);display:inline-flex;align-items:center;padding:0 12px;position:relative;overflow:hidden;justify-content:", ";", ";&:not(:disabled):not(:focus){", " span{color:inherit;}}", " > *:not(.btn-focus){position:relative;}", " > .ds-icon,> .ds-icon{display:flex;align-items:center;justify-content:center;margin:0;width:24px;height:24px;svg{transition:all .3s cubic-bezier(.645,.045,.355,1);}}", " &&.ant-btn-default:not(.ds-expander):not(.ds-button-creator):not(.read-only):not([disabled]),&&.ant-btn-secondary:not(.ds-expander):not(.ds-button-creator):not(.read-only):not([disabled]){&:active{", "}&:focus:not(:active){color:", ";svg{fill:currentColor;}background:", ";}&:hover:not(:disabled):not(:focus){background-color:", ";&.ant-btn .btn-focus{box-shadow:inset 0 0 0 1px ", ";}", " > .ds-icon:before{background-color:", ";}}&:active{color:", ";svg{fill:", ";!important;}}}", " ", ";", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " &:hover:not(:disabled):not(:focus){", " span{color:", ";cursor:inherit;}}}"], (props) => props.justifyContent, (props) => props.shape && props.shape === "circle" && css(["border-radius:50%;"]), ButtonLabel, ButtonLabel, ButtonLabel, (props) => props.mode !== "single-icon" && css(["&.ant-btn:not(.ds-expander):not(.ds-button-creator):not( .btn-search ):not(.btn-search-open){min-width:54px;}"]), (props) => pressedStyles(props), (props) => props.error ? props.theme.palette["red-600"] : props.theme.palette["grey-600"], (props) => props.theme.palette["grey-050"], (props) => props.theme.palette["blue-050"], (props) => props.theme.palette["blue-300"], ButtonLabel, (props) => props.theme.palette["blue-200"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"], (props) => props.readOnly && props.type !== "custom-color-ghost" && css(["&&.ant-btn{cursor:default;transition:none;}&&.ant-btn-secondary{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 1px ", ";}", ",svg{color:", ";}svg{fill:", " !important;}}}&&.ant-btn-primary{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 1px ", ";}", ",svg{color:", ";}svg{fill:", " !important;}}}&&.ant-btn-tertiary{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 0 ", ";}", ",svg{color:", ";}svg{fill:", " !important;}}}&&.ant-btn-tertiary-white{&:hover,&:focus{background:rgba(219,224,227,0.15);.btn-focus{box-shadow:inset 0 0 0 0 rgba(219,224,227,0.15);}", ",svg{color:", ";}svg{fill:", " !important;}}}&&.ant-btn-ghost-primary{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 0 ", ";}", ",svg{color:", ";}svg{fill:", " !important;}}}&&.ant-btn-ghost{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 0 ", ";}", ",svg{color:", ";}svg{fill:", " !important;}}}&&.ant-btn-ghost-white{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 0 ", ";}", ",svg{color:", ";}svg{fill:", " !important;}}}"], props.theme.palette["grey-050"], props.theme.palette["grey-300"], ButtonLabel, props.theme.palette["grey-700"], props.theme.palette["grey-700"], props.theme.palette["blue-600"], props.theme.palette["blue-600"], ButtonLabel, props.theme.palette["grey-050"], props.theme.palette["grey-050"], props.theme.palette["grey-100"], props.theme.palette["grey-100"], ButtonLabel, props.theme.palette["grey-700"], props.theme.palette["grey-700"], ButtonLabel, props.theme.palette["grey-050"], props.theme.palette["grey-050"], props.theme.palette.white, props.theme.palette.white, ButtonLabel, props.theme.palette["blue-600"], props.theme.palette["blue-600"], props.theme.palette.white, props.theme.palette.white, ButtonLabel, props.theme.palette["grey-600"], props.theme.palette["grey-600"], props.theme.palette["grey-600"], props.theme.palette["grey-600"], ButtonLabel, props.theme.palette["grey-050"], props.theme.palette["grey-050"]), (props) => props.loading && css(["> *:not(.btn-focus){opacity:0;visibility:hidden;}", "{opacity:1;visibility:visible;}"], Spinner), (props) => buttonTypes.includes(props.type) && !props.error && css(["&.ant-btn{&:not(:disabled){svg{fill:", ";}&:hover{svg{fill:currentColor;}}}}"], props.iconColor ? props.theme.palette[`${props.iconColor}-600`] : "currentColor"), (props) => props.mode === "split" && css(["&.ant-btn{padding-right:0;transition:0s;", "{position:relative;}", " > .ds-icon{margin:0 4px 0 15px;position:relative;&:before{content:'';background-color:", ";top:", ";height:", ";width:1px;left:-4px;position:absolute;transition:all 0.3s ease;}}}"], ButtonLabel, ButtonLabel, !splitTypes.includes(props.type) ? `rgba(255, 255, 255, 0.15);` : props.theme.palette["grey-300"], props.size === "large" ? "-12px" : "-4px", props.size === "large" ? "48px" : "32px"), (props) => props.mode === "two-icons" && css(["&.ant-btn{padding:0;transition:0s;", " > ", ":first-of-type,", " > .ds-icon:first-of-type,& > ", ":first-of-type,& > .ds-icon:first-of-type{margin:", ";}", " > ", ":nth-of-type(2),", " > .ds-icon:nth-of-type(2),& > ", ":nth-of-type(2),& > .ds-icon:nth-of-type(2){margin:", ";}}", "{margin:0 12px 0 0;}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer, leftIcon, ButtonLabel, IconContainer, ButtonLabel, IconContainer, rightIcon, Tag), (props) => props.mode === "label-icon" && css(["&.ant-btn{padding-right:0;transition:0s;", " > ", ",", " > .ds-icon,& > ", ",& > .ds-icon{margin:", ";}}", "{margin:0 12px 0 0;}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer, rightIcon, Tag), (props) => props.mode === "icon-label" && css(["&.ant-btn{padding-left:0;transition:0s;", " > ", ",", " > .ds-icon,& > ", ",& > .ds-icon{margin:", ";}}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer, leftIcon), (props) => props.mode === "single-icon" && css(["&.ant-btn:not(.ds-expander){display:flex;align-items:center;justify-content:center;padding:0;transition:0s;width:32px;", " > ", ",", " > .ds-icon,& > ", ",& > .ds-icon{margin:0 4px 0 4px;}}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer), (props) => props.mode === "single-icon" && props.size === "large" && css(["&.ant-btn{width:48px;}"]), (props) => props.groupVariant === "squared" && css(["&.ant-btn{border-radius:0;}"]), (props) => props.groupVariant === "left-rounded" && css(["&.ant-btn{border-radius:3px 0 0 3px;}"]), (props) => props.groupVariant === "right-rounded" && css(["&.ant-btn{border-radius:0 3px 3px 0;}"]), (props) => props.error && css(["&.ant-btn{background-color:", ";box-shadow:inset 0 0 0 1px ", ";", "{color:", ";}svg{fill:", ";}.btn-focus{box-shadow:none;}&&&:hover:not(:disabled):not(:focus){background-color:", ";box-shadow:inset 0 0 0 1px ", ";", "{color:", ";}svg{fill:", " !important;}}&:active{background-color:", ";box-shadow:none;", "{color:", ";}svg{fill:", ";}}&&&:focus:not(:active){border:none !important;background-color:", ";", "{color:", ";}.btn-focus{box-shadow:inset 0 0 0 2px ", ";}}svg{fill:", ";}}", "{background-color:", ";}"], props.theme.palette[`red-100`], props.theme.palette["red-600"], ButtonLabel, props.theme.palette[`red-600`], props.theme.palette[`red-600`], props.theme.palette[`red-200`], props.theme.palette["red-600"], ButtonLabel, props.theme.palette[`red-600`], props.theme.palette[`red-600`], props.theme.palette[`red-700`], ButtonLabel, props.theme.palette.white, props.theme.palette.white, props.theme.palette[`red-100`], ButtonLabel, props.theme.palette[`red-600`], props.theme.palette["blue-600"], props.theme.palette[`red-600`], RippleEffect, props.theme.palette[`red-700`]), (props) => props.error && props.type === "secondary" && css(["&&&.ant-btn{", "{color:", ";}svg{fill:", ";}.btn-focus{box-shadow:none;}&&&:hover{background-color:", ";.btn-focus{box-shadow:none;}}&&&:focus:not(:active){.btn-focus{box-shadow:inset 0 0 0 2px ", ";}}&&&:active{background-color:", ";", "{color:", ";}svg{fill:", ";}}", "{background-color:", ";}}"], ButtonLabel, props.theme.palette[`red-600`], props.theme.palette[`red-600`], props.theme.palette[`red-200`], props.theme.palette["blue-600"], props.theme.palette[`red-700`], ButtonLabel, props.theme.palette.white, props.theme.palette.white, RippleEffect, props.theme.palette[`red-700`]), (props) => props.type === "custom-color" && !props.error && css(["&.ant-btn{background-color:", ";border:0 solid transparent;color:", ";", "{color:", ";}svg{color:", ";fill:", ";}", "{box-shadow:inset 0 0 0 0px transparent;}", "{background-color:", ";}&:focus:not(.read-only){", "{box-shadow:inset 0 0 0 2px ", ";}}&:hover:not(:disabled):not(:focus){background-color:", ";", "{color:", ";}svg{color:", " !important;fill:", " !important;}}&:disabled{opacity:0.4;background-color:", ";", "{color:", ";}svg{color:", " !important;fill:", " !important;}}}"], props.theme.palette[`${props.customColor}-600`], props.theme.palette.white, ButtonLabel, props.theme.palette.white, props.theme.palette.white, props.theme.palette.white, ButtonFocus, RippleEffect, props.theme.palette[`${props.customColor}-700`], ButtonFocus, props.theme.palette["blue-600"], props.theme.palette[props.readOnly ? `${props.customColor}-600` : `${props.customColor}-500`], ButtonLabel, props.theme.palette.white, props.theme.palette.white, props.theme.palette.white, props.theme.palette[`${props.customColor}-600`], ButtonLabel, props.theme.palette.white, props.theme.palette.white, props.theme.palette.white), (props) => props.type === "custom-color-ghost" && !props.error && css(["&&&{color:", ";.ds-icon > svg{fill:", ";}&:disabled{opacity:0.4;color:", ";.ds-icon > svg{fill:", " !important;}}}"], props.theme.palette[`${props.customColor}-600`], props.theme.palette[`${props.customColor}-600`], props.theme.palette[`${props.customColor}-600`], props.theme.palette[`${props.customColor}-600`]), (props) => props.readOnly && props.type === "custom-color-ghost" && css(["&&.ant-btn{cursor:default;transition:none;}&&.ant-btn-ghost-primary{&:hover,&:focus{background:", ";.btn-focus{box-shadow:inset 0 0 0 0 ", ";}", ",svg{color:", ";}svg{fill:", ";!important;}}}"], props.theme.palette.white, props.theme.palette.white, ButtonLabel, props.theme.palette[`${props.customColor}-600`], props.theme.palette[`${props.customColor}-600`]), Tag, (props) => props.theme.palette.white);
|
|
41
|
+
})(["&&{", " -webkit-mask-image:-webkit-radial-gradient(white,black);display:inline-flex;align-items:center;padding:0 12px;position:relative;overflow:hidden;&:not(:disabled):not(:focus-visible){", " span{color:inherit;}}", " > *:not(.btn-focus){position:relative;z-index:1;}", " > .ds-icon,> .ds-icon{display:flex;align-items:center;justify-content:center;margin:0;width:24px;height:24px;}", " &&.ant-btn-default:not(.ds-expander):not(.ds-button-creator):not(.read-only):not([disabled]),&&.ant-btn-secondary:not(.ds-expander):not(.ds-button-creator):not(.read-only):not([disabled]){.btn-ripple{background-color:", ";}&.pressed{", " color:", ";}&:focus-visible:not(.pressed){color:", ";background:", ";}&:hover:not(:disabled):not(:focus-visible):not(.pressed){background-color:", ";&.ant-btn .btn-focus{box-shadow:inset 0 0 0 1px ", ";}", " > .ds-icon:before{background-color:", ";}}}", " ", ";", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " &:hover:not(:disabled):not(:focus-visible):not(.pressed){", " span{color:", ";cursor:inherit;}}}"], (props) => getVariantStyles(props.type, props.theme.palette), ButtonLabel, ButtonLabel, ButtonLabel, (props) => props.mode !== "single-icon" && css(["&.ant-btn:not(.ds-expander):not(.ds-button-creator):not( .btn-search ):not(.btn-search-open){min-width:54px;}"]), (props) => props.theme.palette["blue-100"], (props) => pressedStyles(props), (props) => props.theme.palette["blue-600"], (props) => props.error ? props.theme.palette["red-600"] : props.theme.palette["grey-600"], (props) => props.theme.palette["grey-050"], (props) => props.theme.palette["blue-050"], (props) => props.theme.palette["blue-300"], ButtonLabel, (props) => props.theme.palette["blue-200"], (props) => props.readOnly && props.type !== "custom-color-ghost" && css(["&&.ant-btn{cursor:default;transition:none;}&&.ant-btn-secondary{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:inset 0 0 0 1px ", ";}color:", ";}}&&.ant-btn-primary{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:inset 0 0 0 1px ", ";}color:", ";}}&&.ant-btn-tertiary{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-tertiary-white{&:hover,&:focus-visible{background:rgba(219,224,227,0.15);.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-ghost-primary{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-ghost{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-ghost-white{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-danger{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-success{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}&&.ant-btn-warning{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:none;}color:", ";}}"], props.theme.palette["grey-050"], props.theme.palette["grey-300"], props.theme.palette["grey-700"], props.theme.palette["blue-600"], props.theme.palette["blue-600"], props.theme.palette["grey-050"], props.theme.palette["grey-100"], props.theme.palette["grey-700"], props.theme.palette["grey-050"], props.theme.palette.white, props.theme.palette["blue-600"], props.theme.palette.white, props.theme.palette["grey-600"], props.theme.palette["grey-600"], props.theme.palette["grey-050"], props.theme.palette["red-600"], props.theme.palette.white, props.theme.palette["green-600"], props.theme.palette.white, props.theme.palette["yellow-600"], props.theme.palette.white), (props) => props.loading && css(["> *:not(.btn-focus){opacity:0;visibility:hidden;}", "{opacity:1;visibility:visible;}"], Spinner), (props) => props.iconColor && css(["&.ant-btn:not(:disabled){color:", ";&:hover{color:inherit;}}"], props.theme.palette[`${props.iconColor}-600`]), (props) => props.mode === "split" && css(["&.ant-btn{padding-right:0;transition:0s;", "{position:relative;}", " > .ds-icon{margin:0 4px 0 15px;position:relative;&:before{content:'';background-color:", ";top:", ";height:", ";width:1px;left:-4px;position:absolute;transition:all 0.3s ease;}}}"], ButtonLabel, ButtonLabel, !splitTypes.includes(props.type) ? `rgba(255, 255, 255, 0.15);` : props.theme.palette["grey-300"], props.size === "large" ? "-12px" : "-4px", props.size === "large" ? "48px" : "32px"), (props) => props.mode === "two-icons" && css(["&.ant-btn{padding:0;transition:0s;", " > ", ":first-of-type,", " > .ds-icon:first-of-type,& > ", ":first-of-type,& > .ds-icon:first-of-type{margin:", ";}", " > ", ":nth-of-type(2),", " > .ds-icon:nth-of-type(2),& > ", ":nth-of-type(2),& > .ds-icon:nth-of-type(2){margin:", ";}}", "{margin:0 12px 0 0;}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer, leftIcon, ButtonLabel, IconContainer, ButtonLabel, IconContainer, rightIcon, Tag), (props) => props.mode === "label-icon" && css(["&.ant-btn{padding-right:0;transition:0s;", " > ", ",", " > .ds-icon,& > ", ",& > .ds-icon{margin:", ";}}", "{margin:0 12px 0 0;}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer, rightIcon, Tag), (props) => props.mode === "icon-label" && css(["&.ant-btn{padding-left:0;transition:0s;", " > ", ",", " > .ds-icon,& > ", ",& > .ds-icon{margin:", ";}}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer, leftIcon), (props) => props.mode === "single-icon" && css(["&.ant-btn:not(.ds-expander){display:flex;align-items:center;justify-content:center;padding:0;transition:0s;width:32px;", " > ", ",", " > .ds-icon,& > ", ",& > .ds-icon{margin:0 4px 0 4px;}}"], ButtonLabel, IconContainer, ButtonLabel, IconContainer), (props) => props.mode === "single-icon" && props.size === "large" && css(["&.ant-btn{width:48px;}"]), (props) => props.groupVariant === "squared" && css(["&.ant-btn{border-radius:0;}"]), (props) => props.groupVariant === "left-rounded" && css(["&.ant-btn{border-radius:3px 0 0 3px;}"]), (props) => props.groupVariant === "right-rounded" && css(["&.ant-btn{border-radius:0 3px 3px 0;}"]), (props) => props.error && css(["&.ant-btn{background-color:", ";box-shadow:inset 0 0 0 1px ", ";color:", ";.btn-focus{box-shadow:none;}&&:hover:not(:disabled):not(:focus-visible):not(.pressed){background-color:", ";box-shadow:inset 0 0 0 1px ", ";color:", ";}&.pressed{background-color:", ";box-shadow:none;color:", ";}&&:focus-visible:not(.pressed){border:none !important;background-color:", ";color:", ";.btn-focus{box-shadow:inset 0 0 0 2px ", ";}}}", "{background-color:", ";}"], props.theme.palette[`red-100`], props.theme.palette["red-600"], props.theme.palette[`red-600`], props.theme.palette[`red-200`], props.theme.palette["red-600"], props.theme.palette[`red-600`], props.theme.palette[`red-700`], props.theme.palette.white, props.theme.palette[`red-100`], props.theme.palette[`red-600`], props.theme.palette["blue-600"], RippleEffect, props.theme.palette[`red-700`]), (props) => props.error && props.type === "secondary" && css(["&&.ant-btn{color:", ";.btn-focus{box-shadow:none;}&&:hover{background-color:", ";.btn-focus{box-shadow:none;}}&&:focus-visible:not(.pressed){.btn-focus{box-shadow:inset 0 0 0 2px ", ";}}&&.pressed{background-color:", ";color:", ";}", "{background-color:", ";}}"], props.theme.palette[`red-600`], props.theme.palette[`red-200`], props.theme.palette["blue-600"], props.theme.palette[`red-700`], props.theme.palette.white, RippleEffect, props.theme.palette[`red-700`]), (props) => props.type === "custom-color" && !props.error && css(["&.ant-btn{background-color:", ";border:0 solid transparent;color:", ";", "{box-shadow:inset 0 0 0 0px transparent;}", "{background-color:", ";}&:focus-visible:not(.read-only){", "{box-shadow:inset 0 0 0 2px ", ";}}&:hover:not(:disabled):not(:focus-visible):not(.pressed){background-color:", ";color:", ";}&.pressed{background-color:", ";color:", ";}&:disabled{opacity:0.4;background-color:", ";color:", ";}}"], props.theme.palette[`${props.customColor}-600`], props.theme.palette.white, ButtonFocus, RippleEffect, props.theme.palette[`${props.customColor}-700`], ButtonFocus, props.theme.palette["blue-600"], props.theme.palette[props.readOnly ? `${props.customColor}-600` : `${props.customColor}-500`], props.theme.palette.white, props.theme.palette[`${props.customColor}-700`], props.theme.palette.white, props.theme.palette[`${props.customColor}-600`], props.theme.palette.white), (props) => props.type === "custom-color-ghost" && !props.error && css(["&&{color:", ";&:hover:not(:disabled){color:", ";}&:disabled{opacity:0.4;color:", ";}}"], props.theme.palette[`${props.customColor}-600`], props.theme.palette[`${props.customColor}-600`], props.theme.palette[`${props.customColor}-600`]), (props) => props.readOnly && props.type === "custom-color-ghost" && css(["&&.ant-btn{cursor:default;transition:none;}&&.ant-btn-custom-color-ghost{&:hover,&:focus-visible{background:", ";.btn-focus{box-shadow:inset 0 0 0 0 ", ";}color:", ";}}"], props.theme.palette.white, props.theme.palette.white, props.theme.palette[`${props.customColor}-600`]), Tag, (props) => props.theme.palette.white);
|
|
65
42
|
export {
|
|
66
|
-
|
|
43
|
+
ACTIVE_DELAY,
|
|
67
44
|
ButtonFocus,
|
|
68
45
|
ButtonLabel,
|
|
69
46
|
RIPPLE_ANIMATION_TIME,
|
|
70
47
|
RippleEffect,
|
|
71
48
|
Spinner,
|
|
49
|
+
StyledButton,
|
|
72
50
|
Tag
|
|
73
51
|
};
|
package/dist/Button.types.d.ts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JustifyContentProperty } from 'csstype';
|
|
3
|
-
import { ForwardRefExoticComponent, MouseEvent, RefAttributes } from 'react';
|
|
1
|
+
import { ForwardRefExoticComponent, MouseEvent, ReactNode, RefAttributes } from 'react';
|
|
4
2
|
import { StyledComponent } from 'styled-components';
|
|
5
3
|
import { TagProps } from '@synerise/ds-tag';
|
|
6
4
|
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
7
5
|
import { LiteralStringUnion } from '@synerise/ds-utils';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ICON_LABEL = "icon-label"
|
|
14
|
-
}
|
|
15
|
-
type ButtonModes = `${ButtonMode}`;
|
|
16
|
-
export type ButtonType = 'primary' | 'secondary' | 'tertiary' | 'tertiary-white' | 'ghost-primary' | 'ghost' | 'ghost-white' | 'custom-color' | 'custom-color-ghost';
|
|
17
|
-
export type ButtonProps = Omit<AntdButtonProps, 'type' | 'ghost'> & {
|
|
6
|
+
import { BaseButtonProps } from './BaseButton.types';
|
|
7
|
+
export declare const ButtonMode: Record<string, ButtonMode>;
|
|
8
|
+
export type ButtonMode = 'single-icon' | 'split' | 'two-icons' | 'label-icon' | 'icon-label';
|
|
9
|
+
export type ButtonType = LiteralStringUnion<'primary' | 'secondary' | 'tertiary' | 'tertiary-white' | 'ghost-primary' | 'ghost' | 'ghost-white' | 'custom-color' | 'custom-color-ghost' | 'danger' | 'success' | 'warning'>;
|
|
10
|
+
export type ButtonProps = Omit<BaseButtonProps, 'type'> & {
|
|
18
11
|
/**
|
|
19
12
|
* Defines the type of the button. It affects the button color
|
|
20
13
|
*
|
|
21
14
|
* @default secondary
|
|
22
15
|
*/
|
|
23
|
-
type?:
|
|
16
|
+
type?: ButtonType;
|
|
24
17
|
/**
|
|
25
18
|
* Defines the type of the button content. It affects content inside the button
|
|
26
19
|
*
|
|
27
20
|
* @default simple
|
|
28
21
|
*/
|
|
29
|
-
mode?: LiteralStringUnion<
|
|
22
|
+
mode?: LiteralStringUnion<ButtonMode>;
|
|
30
23
|
/**
|
|
31
24
|
* Defines color of `custom-color` button.
|
|
32
25
|
*
|
|
@@ -37,10 +30,6 @@ export type ButtonProps = Omit<AntdButtonProps, 'type' | 'ghost'> & {
|
|
|
37
30
|
* Defines shape of the button.
|
|
38
31
|
*/
|
|
39
32
|
groupVariant?: LiteralStringUnion<'left-rounded' | 'squared' | 'right-rounded'>;
|
|
40
|
-
/**
|
|
41
|
-
* Defines justify of content in button.
|
|
42
|
-
*/
|
|
43
|
-
justifyContent?: JustifyContentProperty;
|
|
44
33
|
/**
|
|
45
34
|
* Set the loading status of button
|
|
46
35
|
* @default false
|
|
@@ -48,17 +37,26 @@ export type ButtonProps = Omit<AntdButtonProps, 'type' | 'ghost'> & {
|
|
|
48
37
|
loading?: boolean | {
|
|
49
38
|
delay?: number;
|
|
50
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Icon element rendered inside the button label.
|
|
42
|
+
* Placed before text in `icon-label` / `single-icon` modes, after text in `label-icon` mode.
|
|
43
|
+
*/
|
|
44
|
+
icon?: ReactNode;
|
|
51
45
|
/**
|
|
52
46
|
* Sets the handler to handle `click` event
|
|
53
47
|
*/
|
|
54
48
|
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
49
|
+
/** Overrides the icon color on secondary, tertiary, and ghost variants */
|
|
55
50
|
iconColor?: LiteralStringUnion<'blue' | 'grey' | 'red' | 'green' | 'yellow' | 'pink' | 'mars' | 'orange' | 'fern' | 'cyan' | 'purple' | 'violet'>;
|
|
51
|
+
/** Applies red error styling to the button */
|
|
56
52
|
error?: boolean;
|
|
53
|
+
/** Disables hover and focus visual changes while keeping the button visually enabled */
|
|
57
54
|
readOnly?: boolean;
|
|
55
|
+
/** Renders a pill tag after the button label */
|
|
58
56
|
tagProps?: TagProps;
|
|
57
|
+
/** Wraps the button label in a tooltip */
|
|
59
58
|
tooltipProps?: TooltipProps;
|
|
60
59
|
};
|
|
61
60
|
/** @deprecated - use ButtonProps instead */
|
|
62
61
|
export type Props = ButtonProps;
|
|
63
62
|
export type StyledButton<CustomProps extends object = object> = StyledComponent<ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>, object, CustomProps, never>;
|
|
64
|
-
export {};
|
package/dist/Button.types.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})(ButtonMode || {});
|
|
1
|
+
const ButtonMode = {
|
|
2
|
+
SINGLE_ICON: "single-icon",
|
|
3
|
+
SPLIT: "split",
|
|
4
|
+
TWO_ICONS: "two-icons",
|
|
5
|
+
LABEL_ICON: "label-icon",
|
|
6
|
+
ICON_LABEL: "icon-label"
|
|
7
|
+
};
|
|
9
8
|
export {
|
|
10
9
|
ButtonMode
|
|
11
10
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FlattenSimpleInterpolation } from 'styled-components';
|
|
2
|
+
/**
|
|
3
|
+
* Button variant styles — direct port of button.mixin.less to styled-components.
|
|
4
|
+
*
|
|
5
|
+
* Icons use currentColor for fill/stroke and inherit the button's color property,
|
|
6
|
+
* so we only set `color` on the button — no direct svg fill/color overrides needed.
|
|
7
|
+
*/
|
|
8
|
+
type Palette = {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Returns the variant-specific CSS for a given button type.
|
|
13
|
+
* Falls back to the default/secondary variant for unknown types.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getVariantStyles: (type: string | undefined, palette: Palette) => FlattenSimpleInterpolation;
|
|
16
|
+
export {};
|