@algolia/satellite 1.0.0-beta.156 → 1.0.0-beta.158
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/cjs/Avatars/UserAvatar.d.ts +7 -3
- package/cjs/Avatars/UserAvatar.js +28 -28
- package/cjs/Badge/Badge.d.ts +2 -2
- package/cjs/Badge/Badge.js +7 -6
- package/cjs/Banners/Alert/Alert.js +1 -1
- package/cjs/Button/Button.d.ts +3 -5
- package/cjs/Button/Button.js +8 -51
- package/cjs/Button/Button.tailwind.js +0 -2
- package/cjs/Button/IconButton.d.ts +3 -15
- package/cjs/Button/IconButton.js +8 -62
- package/cjs/Button/PolymorphicButton.d.ts +11 -0
- package/cjs/Button/PolymorphicButton.js +76 -0
- package/cjs/Button/PolymorphicIconButton.d.ts +24 -0
- package/cjs/Button/PolymorphicIconButton.js +84 -0
- package/cjs/Button/index.d.ts +1 -1
- package/cjs/Button/index.js +16 -12
- package/cjs/Button/types.d.ts +11 -6
- package/cjs/Button/types.js +3 -1
- package/cjs/Dropdown/DropdownButton.d.ts +3 -3
- package/cjs/Dropdown/DropdownButton.js +5 -2
- package/cjs/FlexGrid/FlexGrid.js +1 -1
- package/cjs/Link/ButtonLink.d.ts +5 -3
- package/cjs/Link/ButtonLink.js +9 -6
- package/cjs/Link/IconButtonLink.d.ts +5 -4
- package/cjs/Link/IconButtonLink.js +8 -5
- package/cjs/Medallion/Medallion.js +1 -1
- package/cjs/Modal/Modal.d.ts +35 -11
- package/cjs/Modal/Modal.js +131 -95
- package/cjs/Modal/Modal.tailwind.js +7 -0
- package/cjs/RangeSlider/RangeSlider.js +1 -1
- package/cjs/Satellite/Satellite.d.ts +2 -1
- package/cjs/Satellite/Satellite.js +26 -2
- package/cjs/Satellite/locale.d.ts +2 -0
- package/cjs/Tables/DataTable/DataTable.js +12 -12
- package/cjs/Tag/Tag.d.ts +26 -6
- package/cjs/Tag/Tag.js +51 -19
- package/cjs/Tag/Tag.tailwind.js +17 -1
- package/cjs/Tooltip/Tooltip.tailwind.js +2 -1
- package/cjs/styles/colors.d.ts +18 -0
- package/cjs/styles/colors.js +33 -15
- package/cjs/types.d.ts +9 -0
- package/cjs/utils/isCssPropertySupported.d.ts +1 -1
- package/esm/Avatars/UserAvatar.d.ts +7 -3
- package/esm/Avatars/UserAvatar.js +28 -28
- package/esm/Badge/Badge.d.ts +2 -2
- package/esm/Badge/Badge.js +7 -6
- package/esm/Banners/Alert/Alert.js +1 -1
- package/esm/Button/Button.d.ts +3 -5
- package/esm/Button/Button.js +8 -52
- package/esm/Button/Button.tailwind.js +0 -2
- package/esm/Button/IconButton.d.ts +3 -15
- package/esm/Button/IconButton.js +8 -64
- package/esm/Button/PolymorphicButton.d.ts +11 -0
- package/esm/Button/PolymorphicButton.js +66 -0
- package/esm/Button/PolymorphicIconButton.d.ts +24 -0
- package/esm/Button/PolymorphicIconButton.js +78 -0
- package/esm/Button/index.d.ts +1 -1
- package/esm/Button/index.js +1 -1
- package/esm/Button/types.d.ts +11 -6
- package/esm/Button/types.js +3 -1
- package/esm/Dropdown/DropdownButton.d.ts +3 -3
- package/esm/Dropdown/DropdownButton.js +5 -2
- package/esm/Link/ButtonLink.d.ts +5 -3
- package/esm/Link/ButtonLink.js +9 -6
- package/esm/Link/IconButtonLink.d.ts +5 -4
- package/esm/Link/IconButtonLink.js +8 -5
- package/esm/Medallion/Medallion.js +1 -1
- package/esm/Modal/Modal.d.ts +35 -11
- package/esm/Modal/Modal.js +129 -96
- package/esm/Modal/Modal.tailwind.js +7 -0
- package/esm/RangeSlider/RangeSlider.js +2 -0
- package/esm/Satellite/Satellite.d.ts +2 -1
- package/esm/Satellite/Satellite.js +24 -1
- package/esm/Satellite/locale.d.ts +2 -0
- package/esm/Tables/DataTable/DataTable.js +12 -12
- package/esm/Tag/Tag.d.ts +26 -6
- package/esm/Tag/Tag.js +52 -20
- package/esm/Tag/Tag.tailwind.js +17 -1
- package/esm/Tooltip/Tooltip.tailwind.js +2 -1
- package/esm/styles/colors.d.ts +18 -0
- package/esm/styles/colors.js +33 -15
- package/esm/types.d.ts +9 -0
- package/esm/utils/isCssPropertySupported.d.ts +1 -1
- package/package.json +8 -4
- package/satellite.min.css +1 -1
- package/scss/colors.scss +27 -10
@@ -1,6 +1,9 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import type { MinimalUser } from "./types";
|
3
|
-
export declare type
|
3
|
+
export declare type UserAvatarLocale = {
|
4
|
+
fallbackText?: string;
|
5
|
+
};
|
6
|
+
export interface UserAvatarProps {
|
4
7
|
/** A minimal user object containing `name`, `email` and `avatar`. */
|
5
8
|
user: MinimalUser;
|
6
9
|
/**
|
@@ -10,7 +13,8 @@ export declare type UserAvatarProps = {
|
|
10
13
|
size?: number;
|
11
14
|
/** @ignore */
|
12
15
|
className?: string;
|
13
|
-
|
16
|
+
locale?: UserAvatarLocale;
|
17
|
+
}
|
14
18
|
/** The `UserAvatar` is used as a visual representation of a user. */
|
15
|
-
export declare const UserAvatar: ({ className, user, size }: UserAvatarProps) => JSX.Element;
|
19
|
+
export declare const UserAvatar: ({ className, user, size, locale: propsLocale }: UserAvatarProps) => JSX.Element;
|
16
20
|
export default UserAvatar;
|
@@ -1,48 +1,48 @@
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
2
|
-
import
|
3
|
-
var _templateObject, _templateObject2, _templateObject3;
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
|
+
import { AvatarFallback, Image as AvatarImage, Root as AvatarRoot } from "@radix-ui/react-avatar";
|
4
7
|
import cx from "clsx";
|
5
|
-
import {
|
8
|
+
import { useLocale } from "../Satellite";
|
6
9
|
import stl from "../styles/helpers/satellitePrefixer";
|
7
10
|
import { getUserBackgroundClassName, getUserInitials } from "./utils";
|
8
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
var DEFAULT_LOCALE = {
|
14
|
+
fallbackText: "User's avatar"
|
15
|
+
};
|
10
16
|
/** The `UserAvatar` is used as a visual representation of a user. */
|
11
17
|
export var UserAvatar = function UserAvatar(_ref) {
|
12
18
|
var _user$email;
|
13
19
|
var className = _ref.className,
|
14
20
|
user = _ref.user,
|
15
21
|
_ref$size = _ref.size,
|
16
|
-
size = _ref$size === void 0 ? 32 : _ref$size
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
return setImageLoaded(false);
|
24
|
-
}, [user.avatar]);
|
25
|
-
return /*#__PURE__*/_jsxs("div", {
|
26
|
-
role: "img",
|
27
|
-
"aria-label": imageLoaded ? (user === null || user === void 0 ? void 0 : user.name) || "User's avatar" : "User's avatar",
|
28
|
-
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["relative overflow-hidden flex justify-center items-center rounded-full uppercase transition-colors"]))), imageLoaded ? stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["bg-white"]))) : getUserBackgroundClassName((_user$email = user.email) !== null && _user$email !== void 0 ? _user$email : "no-email"), className),
|
22
|
+
size = _ref$size === void 0 ? 32 : _ref$size,
|
23
|
+
propsLocale = _ref.locale;
|
24
|
+
var contextLocale = useLocale("userAvatar");
|
25
|
+
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_LOCALE), contextLocale), propsLocale);
|
26
|
+
var fallbackName = user.name || user.email || locale.fallbackText;
|
27
|
+
return /*#__PURE__*/_jsxs(AvatarRoot, {
|
28
|
+
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["overflow-hidden flex justify-center items-center rounded-full"]))), getUserBackgroundClassName((_user$email = user.email) !== null && _user$email !== void 0 ? _user$email : "no-email"), className),
|
29
29
|
style: {
|
30
30
|
width: size,
|
31
31
|
height: size
|
32
32
|
},
|
33
|
-
children: [
|
34
|
-
|
35
|
-
}), /*#__PURE__*/_jsx("img", {
|
36
|
-
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n w-full absolute top-0 left-0\n transition-opacity ", "\n "])), imageLoaded ? "opacity-100" : "opacity-0"),
|
33
|
+
children: [/*#__PURE__*/_jsx(AvatarImage, {
|
34
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["h-full w-full object-cover"]))),
|
37
35
|
src: user.avatar,
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
36
|
+
alt: fallbackName
|
37
|
+
}), /*#__PURE__*/_jsxs(AvatarFallback, {
|
38
|
+
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["flex h-full w-full items-center justify-center uppercase"]))),
|
39
|
+
children: [/*#__PURE__*/_jsx("span", {
|
40
|
+
"aria-hidden": true,
|
41
|
+
children: getUserInitials(user)
|
42
|
+
}), /*#__PURE__*/_jsx("span", {
|
43
|
+
className: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["sr-only"]))),
|
44
|
+
children: fallbackName
|
45
|
+
})]
|
46
46
|
})]
|
47
47
|
});
|
48
48
|
};
|
package/esm/Badge/Badge.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { FunctionComponent, HTMLAttributes, ReactNode } from "react";
|
2
2
|
import type { AtLeastOne, ColorVariant, IconComponentType } from "../types";
|
3
|
-
export declare type BadgeSizes = "
|
3
|
+
export declare type BadgeSizes = "small" | "medium" | "large";
|
4
4
|
export declare type BadgeVariants = ColorVariant | "pink";
|
5
5
|
interface BaseBadgeProps extends HTMLAttributes<HTMLDivElement> {
|
6
6
|
/** @default "grey" */
|
@@ -21,7 +21,7 @@ export declare type BadgeProps = BaseBadgeProps & AtLeastOne<BadgeContentProps>;
|
|
21
21
|
*
|
22
22
|
* - Stay consistent with badge content (text), don't vary your vocabulary
|
23
23
|
* - Bages usually come after a textual information or explanation
|
24
|
-
* - Don't use badges where traditional error messages
|
24
|
+
* - Don't use badges where traditional error messages (such as form validation) can be used instead
|
25
25
|
* - Don't use badges with combination of buttons
|
26
26
|
* - Badges are not interactive
|
27
27
|
*
|
package/esm/Badge/Badge.js
CHANGED
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
4
|
var _excluded = ["children", "value", "icon", "variant", "size", "className"];
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
6
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
8
|
import cx from "clsx";
|
@@ -21,8 +21,9 @@ var VARIANT_CLASSNAMES = {
|
|
21
21
|
pink: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["bg-pink-100 border-pink-200 text-pink-700"])))
|
22
22
|
};
|
23
23
|
var SIZE_CLASSNAMES = {
|
24
|
-
|
25
|
-
|
24
|
+
small: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["h-4 display-caption px-1 space-x-1"]))),
|
25
|
+
medium: stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["h-5 display-body px-2 space-x-2"]))),
|
26
|
+
large: stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["h-6 display-body px-2 space-x-2"])))
|
26
27
|
};
|
27
28
|
|
28
29
|
/**
|
@@ -30,7 +31,7 @@ var SIZE_CLASSNAMES = {
|
|
30
31
|
*
|
31
32
|
* - Stay consistent with badge content (text), don't vary your vocabulary
|
32
33
|
* - Bages usually come after a textual information or explanation
|
33
|
-
* - Don't use badges where traditional error messages
|
34
|
+
* - Don't use badges where traditional error messages (such as form validation) can be used instead
|
34
35
|
* - Don't use badges with combination of buttons
|
35
36
|
* - Badges are not interactive
|
36
37
|
*
|
@@ -47,7 +48,7 @@ export var Badge = function Badge(_ref) {
|
|
47
48
|
_ref$variant = _ref.variant,
|
48
49
|
variant = _ref$variant === void 0 ? "grey" : _ref$variant,
|
49
50
|
_ref$size = _ref.size,
|
50
|
-
size = _ref$size === void 0 ? "
|
51
|
+
size = _ref$size === void 0 ? "large" : _ref$size,
|
51
52
|
className = _ref.className,
|
52
53
|
props = _objectWithoutProperties(_ref, _excluded);
|
53
54
|
var badgeClassName = cx(BASE_CLASSNAMES, VARIANT_CLASSNAMES[variant], SIZE_CLASSNAMES[size], className);
|
@@ -58,7 +59,7 @@ export var Badge = function Badge(_ref) {
|
|
58
59
|
size: ".8em"
|
59
60
|
})
|
60
61
|
}), isRenderedChild(children) && /*#__PURE__*/_jsx("span", {
|
61
|
-
className: stl(
|
62
|
+
className: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["truncate"]))),
|
62
63
|
children: children
|
63
64
|
}), isRenderedChild(value) && /*#__PURE__*/_jsx("span", {
|
64
65
|
children: value
|
@@ -31,7 +31,7 @@ var ICON_VARIANTS = {
|
|
31
31
|
var ICON_CLASSNAME_VARIANTS = {
|
32
32
|
grey: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["text-grey-600"]))),
|
33
33
|
accent: stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["text-accent-600"]))),
|
34
|
-
green: stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["text-green-
|
34
|
+
green: stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["text-green-600"]))),
|
35
35
|
orange: stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["text-orange-600"]))),
|
36
36
|
red: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["text-red-600"])))
|
37
37
|
};
|
package/esm/Button/Button.d.ts
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import {
|
3
|
-
export declare type ButtonProps
|
4
|
-
as?: T;
|
5
|
-
};
|
2
|
+
import { type PolymorphicButtonProps } from "./PolymorphicButton";
|
3
|
+
export declare type ButtonProps = Omit<PolymorphicButtonProps<"button">, "as" | "ref">;
|
6
4
|
/**
|
7
5
|
* Buttons are used to trigger user actions (like "Add", "Close" or "Save") or navigate users elsewhere through the links. Buttons can contain a combination of a clear label and an icon while links are always text.
|
8
6
|
*
|
@@ -17,5 +15,5 @@ export declare type ButtonProps<T extends AcceptableButtonType = "button"> = But
|
|
17
15
|
* - Use icon-only button for an action that is less critical and doesn't have to drag too much of user attention
|
18
16
|
* - Buttons can take the full width to fill the parent container
|
19
17
|
*/
|
20
|
-
export declare const Button: <
|
18
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
21
19
|
export default Button;
|
package/esm/Button/Button.js
CHANGED
@@ -1,19 +1,9 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
-
var _excluded = ["as", "className", "variant", "size", "startIcon", "endIcon", "loading", "children"];
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
6
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import stl from "../styles/helpers/satellitePrefixer";
|
11
|
-
import { BUTTON_LOADER_ICON_SIZES, BUTTON_SIZE_CLASSNAMES, BUTTON_VARIANT_CLASSNAMES, getIconColorClassName } from "./styles";
|
12
|
-
import { isButtonType } from "./types";
|
4
|
+
import { forwardRef } from "react";
|
5
|
+
import { PolymorphicButton } from "./PolymorphicButton";
|
13
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
15
|
-
var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex justify-center items-center px-4 typo-display-body"])));
|
16
|
-
|
17
7
|
/**
|
18
8
|
* Buttons are used to trigger user actions (like "Add", "Close" or "Save") or navigate users elsewhere through the links. Buttons can contain a combination of a clear label and an icon while links are always text.
|
19
9
|
*
|
@@ -28,45 +18,11 @@ var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateL
|
|
28
18
|
* - Use icon-only button for an action that is less critical and doesn't have to drag too much of user attention
|
29
19
|
* - Buttons can take the full width to fill the parent container
|
30
20
|
*/
|
31
|
-
export var Button = function
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
_props$variant = props.variant,
|
36
|
-
variant = _props$variant === void 0 ? "neutral" : _props$variant,
|
37
|
-
_props$size = props.size,
|
38
|
-
size = _props$size === void 0 ? "medium" : _props$size,
|
39
|
-
StartIcon = props.startIcon,
|
40
|
-
EndIcon = props.endIcon,
|
41
|
-
_props$loading = props.loading,
|
42
|
-
loading = _props$loading === void 0 ? false : _props$loading,
|
43
|
-
children = props.children,
|
44
|
-
cleanedProps = _objectWithoutProperties(props, _excluded);
|
45
|
-
if (loading) {
|
46
|
-
cleanedProps.disabled = true;
|
47
|
-
}
|
48
|
-
var buttonClassName = cx(BASE_CLASSNAMES, BUTTON_SIZE_CLASSNAMES[size], BUTTON_VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["btn-disabled"]))), className);
|
49
|
-
var loaderClassNames = stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
|
50
|
-
var iconClassNames = cx(getIconColorClassName(props), loading && stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["invisible"]))));
|
51
|
-
var textClassNames = cx(loading && stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["invisible"]))));
|
52
|
-
if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
|
53
|
-
// @ts-ignore
|
54
|
-
cleanedProps.type = "button";
|
55
|
-
}
|
56
|
-
return /*#__PURE__*/_jsxs(Component, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
57
|
-
className: buttonClassName,
|
58
|
-
children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
|
59
|
-
className: loaderClassNames,
|
60
|
-
size: BUTTON_LOADER_ICON_SIZES[size],
|
61
|
-
thickness: 1
|
62
|
-
}), StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
63
|
-
className: cx(stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["shrink-0 pr-2"]))), iconClassNames)
|
64
|
-
}), /*#__PURE__*/_jsx("span", {
|
65
|
-
className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["truncate text-center"]))), textClassNames),
|
66
|
-
children: children
|
67
|
-
}), EndIcon && /*#__PURE__*/_jsx(EndIcon, {
|
68
|
-
className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["shrink-0 pl-2"]))), iconClassNames)
|
69
|
-
})]
|
21
|
+
export var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
22
|
+
return /*#__PURE__*/_jsx(PolymorphicButton, _objectSpread(_objectSpread({}, props), {}, {
|
23
|
+
as: "button",
|
24
|
+
ref: ref
|
70
25
|
}));
|
71
|
-
};
|
26
|
+
});
|
27
|
+
Button.displayName = "Button";
|
72
28
|
export default Button;
|
@@ -60,7 +60,6 @@ var buttonPlugin = plugin(function (_ref) {
|
|
60
60
|
},
|
61
61
|
"&:active, &.btn-active": {
|
62
62
|
borderColor: theme("colors.grey.200"),
|
63
|
-
backgroundImage: theme("color.grey.100"),
|
64
63
|
boxShadow: "\n inset 0 1px 4px 0 ".concat(rgba(theme("colors.grey.500"), 0.4), ",\n inset 0 1px 1px 0 ").concat(rgba(theme("colors.grey.500"), 0.4), ",\n 0 1px 0 0 ").concat(theme("colors.shadow.5"), "\n ")
|
65
64
|
},
|
66
65
|
"&:disabled, &.btn-disabled": {
|
@@ -115,7 +114,6 @@ var buttonPlugin = plugin(function (_ref) {
|
|
115
114
|
boxShadow: "\n inset 0 1px 0 0 ".concat(rgba(theme("colors.white"), 0.06), ",\n 0 0 0 1px ").concat(theme("colors.red.800"), ",\n 0 2px 0 1px ").concat(theme("colors.shadow.10"), "\n ")
|
116
115
|
},
|
117
116
|
"&:active, &.btn-active": {
|
118
|
-
backgroundImage: theme("colors.red.700"),
|
119
117
|
borderColor: theme("colors.red.800"),
|
120
118
|
boxShadow: "\n inset 0 1px 4px 0 ".concat(rgba(theme("colors.red.900"), 0.4), ",\n inset 0 1px 1px 0 ").concat(rgba(theme("colors.red.900"), 0.6), ",\n 0 1px 0 0 ").concat(theme("colors.shadow.5"), "\n ")
|
121
119
|
},
|
@@ -1,17 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import type
|
3
|
-
|
4
|
-
export
|
5
|
-
variant?: ButtonVariant;
|
6
|
-
size?: ButtonSize;
|
7
|
-
disabled?: boolean;
|
8
|
-
icon: IconComponentType;
|
9
|
-
title: string;
|
10
|
-
showTooltip?: boolean;
|
11
|
-
loading?: boolean;
|
12
|
-
}
|
13
|
-
export declare type IconButtonProps<T extends AcceptableButtonType> = IconButtonBaseProps & ExtractProps<T> & {
|
14
|
-
as?: T;
|
15
|
-
};
|
16
|
-
export declare const IconButton: <T extends AcceptableButtonType = "button">(props: IconButtonProps<T>) => JSX.Element;
|
2
|
+
import { type PolymorphicIconButtonProps } from "./PolymorphicIconButton";
|
3
|
+
export declare type IconButtonProps = Omit<PolymorphicIconButtonProps<"button">, "as" | "ref">;
|
4
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
17
5
|
export default IconButton;
|
package/esm/Button/IconButton.js
CHANGED
@@ -1,70 +1,14 @@
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
-
var _excluded = ["as", "className", "variant", "size", "icon", "title", "showTooltip", "loading"];
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
6
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import stl from "../styles/helpers/satellitePrefixer";
|
11
|
-
import { TooltipWrapper } from "../Tooltip";
|
12
|
-
import { BUTTON_LOADER_ICON_SIZES, BUTTON_VARIANT_CLASSNAMES } from "./styles";
|
13
|
-
import { isButtonType } from "./types";
|
4
|
+
import { forwardRef } from "react";
|
5
|
+
import { PolymorphicIconButton } from "./PolymorphicIconButton";
|
14
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
medium: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["h-8 w-8 text-md"]))),
|
21
|
-
large: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["h-10 w-10 text-lg"])))
|
22
|
-
};
|
23
|
-
var VARIANT_CLASSNAMES = _objectSpread(_objectSpread({}, BUTTON_VARIANT_CLASSNAMES), {}, {
|
24
|
-
neutral: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["btn-neutral text-grey-600"])))
|
7
|
+
export var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
8
|
+
return /*#__PURE__*/_jsx(PolymorphicIconButton, _objectSpread(_objectSpread({}, props), {}, {
|
9
|
+
as: "button",
|
10
|
+
ref: ref
|
11
|
+
}));
|
25
12
|
});
|
26
|
-
|
27
|
-
var _props$as = props.as,
|
28
|
-
Tag = _props$as === void 0 ? "button" : _props$as,
|
29
|
-
className = props.className,
|
30
|
-
_props$variant = props.variant,
|
31
|
-
variant = _props$variant === void 0 ? "neutral" : _props$variant,
|
32
|
-
_props$size = props.size,
|
33
|
-
size = _props$size === void 0 ? "medium" : _props$size,
|
34
|
-
Icon = props.icon,
|
35
|
-
title = props.title,
|
36
|
-
showTooltip = props.showTooltip,
|
37
|
-
_props$loading = props.loading,
|
38
|
-
loading = _props$loading === void 0 ? false : _props$loading,
|
39
|
-
cleanedProps = _objectWithoutProperties(props, _excluded);
|
40
|
-
if (loading) {
|
41
|
-
cleanedProps.disabled = true;
|
42
|
-
}
|
43
|
-
var iconButtonClassName = cx(BASE_CLASSNAMES, SIZE_CLASSNAMES[size], VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["btn-disabled"]))), className);
|
44
|
-
var loaderClassNames = stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
|
45
|
-
if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
|
46
|
-
// @ts-ignore
|
47
|
-
cleanedProps.type = "button";
|
48
|
-
}
|
49
|
-
return /*#__PURE__*/_jsx(TooltipWrapper, {
|
50
|
-
delay: 500,
|
51
|
-
show: showTooltip,
|
52
|
-
placement: "top",
|
53
|
-
content: title,
|
54
|
-
children: /*#__PURE__*/_jsx(Tag, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
55
|
-
className: iconButtonClassName,
|
56
|
-
"aria-label": title,
|
57
|
-
children: /*#__PURE__*/_jsxs(_Fragment, {
|
58
|
-
children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
|
59
|
-
className: loaderClassNames,
|
60
|
-
size: BUTTON_LOADER_ICON_SIZES[size],
|
61
|
-
thickness: 1
|
62
|
-
}), /*#__PURE__*/_jsx(Icon, {
|
63
|
-
className: cx(loading && stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["invisible"])))),
|
64
|
-
size: "1em"
|
65
|
-
})]
|
66
|
-
})
|
67
|
-
}))
|
68
|
-
});
|
69
|
-
};
|
13
|
+
IconButton.displayName = "IconButton";
|
70
14
|
export default IconButton;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { ButtonBaseProps, PolymorphicComponentPropWithRef } from "./types";
|
3
|
+
export declare type PolymorphicButtonProps<C extends React.ElementType> = PolymorphicComponentPropWithRef<C, ButtonBaseProps>;
|
4
|
+
declare type PolymorphicButtonComponent = (<C extends React.ElementType = "button">(props: PolymorphicButtonProps<C>) => React.ReactElement | null) & {
|
5
|
+
displayName?: string;
|
6
|
+
};
|
7
|
+
/**
|
8
|
+
* `PolymorphicButton` is intended for internal use
|
9
|
+
*/
|
10
|
+
export declare const PolymorphicButton: PolymorphicButtonComponent;
|
11
|
+
export {};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
+
var _excluded = ["as", "className", "variant", "size", "startIcon", "endIcon", "loading", "children"];
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
+
import cx from "clsx";
|
9
|
+
import React, { forwardRef } from "react";
|
10
|
+
import ProgressSpinner from "../ProgressSpinner";
|
11
|
+
import stl from "../styles/helpers/satellitePrefixer";
|
12
|
+
import { BUTTON_LOADER_ICON_SIZES, BUTTON_SIZE_CLASSNAMES, BUTTON_VARIANT_CLASSNAMES, getIconColorClassName } from "./styles";
|
13
|
+
import { isButtonType } from "./types";
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
16
|
+
var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex justify-center items-center px-3 typo-display-body"])));
|
17
|
+
var ICON_SIZE = 16;
|
18
|
+
/**
|
19
|
+
* `PolymorphicButton` is intended for internal use
|
20
|
+
*/
|
21
|
+
export var PolymorphicButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
22
|
+
var _props$as = props.as,
|
23
|
+
Component = _props$as === void 0 ? "button" : _props$as,
|
24
|
+
className = props.className,
|
25
|
+
_props$variant = props.variant,
|
26
|
+
variant = _props$variant === void 0 ? "neutral" : _props$variant,
|
27
|
+
_props$size = props.size,
|
28
|
+
size = _props$size === void 0 ? "medium" : _props$size,
|
29
|
+
StartIcon = props.startIcon,
|
30
|
+
EndIcon = props.endIcon,
|
31
|
+
_props$loading = props.loading,
|
32
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
33
|
+
children = props.children,
|
34
|
+
cleanedProps = _objectWithoutProperties(props, _excluded);
|
35
|
+
if (loading) {
|
36
|
+
// @ts-expect-error
|
37
|
+
cleanedProps.disabled = true;
|
38
|
+
}
|
39
|
+
var buttonClassName = cx(BASE_CLASSNAMES, BUTTON_SIZE_CLASSNAMES[size], BUTTON_VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["btn-disabled"]))), className);
|
40
|
+
var loaderClassNames = stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
|
41
|
+
var iconClassNames = cx(getIconColorClassName(props), loading && stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["invisible"]))));
|
42
|
+
var textClassNames = cx(loading && stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["invisible"]))));
|
43
|
+
if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
|
44
|
+
// @ts-expect-error
|
45
|
+
cleanedProps.type = "button";
|
46
|
+
}
|
47
|
+
return /*#__PURE__*/_jsxs(Component, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
48
|
+
className: buttonClassName,
|
49
|
+
ref: ref,
|
50
|
+
children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
|
51
|
+
className: loaderClassNames,
|
52
|
+
size: BUTTON_LOADER_ICON_SIZES[size],
|
53
|
+
thickness: 1
|
54
|
+
}), StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
55
|
+
size: ICON_SIZE,
|
56
|
+
className: cx(stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["shrink-0"]))), iconClassNames)
|
57
|
+
}), /*#__PURE__*/_jsx("span", {
|
58
|
+
className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["truncate text-center px-1"]))), textClassNames),
|
59
|
+
children: children
|
60
|
+
}), EndIcon && /*#__PURE__*/_jsx(EndIcon, {
|
61
|
+
size: ICON_SIZE,
|
62
|
+
className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["shrink-0"]))), iconClassNames)
|
63
|
+
})]
|
64
|
+
}));
|
65
|
+
});
|
66
|
+
PolymorphicButton.displayName = "PolymorphicButton";
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import type { TooltipWrapperBaseProps } from "../Tooltip/types";
|
3
|
+
import type { IconComponentType } from "../types";
|
4
|
+
import { ButtonSize, ButtonVariant, PolymorphicComponentPropWithRef } from "./types";
|
5
|
+
export interface IconButtonBaseProps {
|
6
|
+
variant?: ButtonVariant;
|
7
|
+
size?: ButtonSize;
|
8
|
+
disabled?: boolean;
|
9
|
+
icon: IconComponentType;
|
10
|
+
title: string;
|
11
|
+
showTooltip?: boolean;
|
12
|
+
/** @default "top" */
|
13
|
+
tooltipPlacement?: TooltipWrapperBaseProps["placement"];
|
14
|
+
loading?: boolean;
|
15
|
+
}
|
16
|
+
export declare type PolymorphicIconButtonProps<C extends React.ElementType> = PolymorphicComponentPropWithRef<C, IconButtonBaseProps>;
|
17
|
+
declare type PolymorphicIconButtonComponent = (<C extends React.ElementType = "button">(props: PolymorphicIconButtonProps<C>) => React.ReactElement | null) & {
|
18
|
+
displayName?: string;
|
19
|
+
};
|
20
|
+
/**
|
21
|
+
* `PolymorphicIconButton` is intended for internal use
|
22
|
+
*/
|
23
|
+
export declare const PolymorphicIconButton: PolymorphicIconButtonComponent;
|
24
|
+
export {};
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
+
var _excluded = ["as", "className", "variant", "size", "icon", "title", "showTooltip", "tooltipPlacement", "loading"];
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
+
import cx from "clsx";
|
9
|
+
import { forwardRef } from "react";
|
10
|
+
import ProgressSpinner from "../ProgressSpinner";
|
11
|
+
import stl from "../styles/helpers/satellitePrefixer";
|
12
|
+
import { TooltipWrapper } from "../Tooltip";
|
13
|
+
import { BUTTON_LOADER_ICON_SIZES, BUTTON_VARIANT_CLASSNAMES } from "./styles";
|
14
|
+
import { isButtonType } from "./types";
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
16
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
18
|
+
var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex items-center justify-center"])));
|
19
|
+
var SIZE_CLASSNAMES = {
|
20
|
+
small: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["h-6 w-6 text-mobile md:text-sm"]))),
|
21
|
+
medium: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["h-8 w-8 text-md"]))),
|
22
|
+
large: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["h-10 w-10 text-lg"])))
|
23
|
+
};
|
24
|
+
var VARIANT_CLASSNAMES = _objectSpread(_objectSpread({}, BUTTON_VARIANT_CLASSNAMES), {}, {
|
25
|
+
neutral: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["btn-neutral text-grey-600"])))
|
26
|
+
});
|
27
|
+
/**
|
28
|
+
* `PolymorphicIconButton` is intended for internal use
|
29
|
+
*/
|
30
|
+
export var PolymorphicIconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
31
|
+
var _props$as = props.as,
|
32
|
+
Tag = _props$as === void 0 ? "button" : _props$as,
|
33
|
+
className = props.className,
|
34
|
+
_props$variant = props.variant,
|
35
|
+
variant = _props$variant === void 0 ? "neutral" : _props$variant,
|
36
|
+
_props$size = props.size,
|
37
|
+
size = _props$size === void 0 ? "medium" : _props$size,
|
38
|
+
Icon = props.icon,
|
39
|
+
title = props.title,
|
40
|
+
showTooltip = props.showTooltip,
|
41
|
+
_props$tooltipPlaceme = props.tooltipPlacement,
|
42
|
+
tooltipPlacement = _props$tooltipPlaceme === void 0 ? "top" : _props$tooltipPlaceme,
|
43
|
+
_props$loading = props.loading,
|
44
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
45
|
+
cleanedProps = _objectWithoutProperties(props, _excluded);
|
46
|
+
if (loading) {
|
47
|
+
// @ts-expect-error
|
48
|
+
cleanedProps.disabled = true;
|
49
|
+
}
|
50
|
+
var iconButtonClassName = cx(BASE_CLASSNAMES, SIZE_CLASSNAMES[size], VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["btn-disabled"]))), className);
|
51
|
+
var loaderClassNames = stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
|
52
|
+
if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
|
53
|
+
// @ts-ignore
|
54
|
+
cleanedProps.type = "button";
|
55
|
+
}
|
56
|
+
return /*#__PURE__*/_jsx(TooltipWrapper, {
|
57
|
+
delay: 500,
|
58
|
+
show: showTooltip,
|
59
|
+
placement: tooltipPlacement,
|
60
|
+
content: title,
|
61
|
+
children: /*#__PURE__*/_jsx(Tag, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
62
|
+
className: iconButtonClassName,
|
63
|
+
"aria-label": title,
|
64
|
+
ref: ref,
|
65
|
+
children: /*#__PURE__*/_jsxs(_Fragment, {
|
66
|
+
children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
|
67
|
+
className: loaderClassNames,
|
68
|
+
size: BUTTON_LOADER_ICON_SIZES[size],
|
69
|
+
thickness: 1
|
70
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
71
|
+
className: cx(loading && stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["invisible"])))),
|
72
|
+
size: "1em"
|
73
|
+
})]
|
74
|
+
})
|
75
|
+
}))
|
76
|
+
});
|
77
|
+
});
|
78
|
+
PolymorphicIconButton.displayName = "PolymorphicIconButton";
|
package/esm/Button/index.d.ts
CHANGED
package/esm/Button/index.js
CHANGED
package/esm/Button/types.d.ts
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ReactNode } from "react";
|
2
2
|
import type { IconComponentType } from "../types";
|
3
3
|
export declare type ButtonVariant = "subtle" | "neutral" | "primary" | "destructive";
|
4
4
|
export declare type ButtonSize = "small" | "medium" | "large";
|
5
|
-
export declare type MinimalButtonProps = {
|
6
|
-
className?: string;
|
7
|
-
};
|
8
|
-
export declare type AcceptableButtonType = "a" | "button" | ComponentType<MinimalButtonProps>;
|
9
|
-
export declare type ExtractProps<T> = T extends "a" | "button" ? JSX.IntrinsicElements[T] : T extends ComponentType<infer P> ? P : never;
|
10
5
|
export interface ButtonBaseProps {
|
11
6
|
/** @default "neutral" */
|
12
7
|
variant?: ButtonVariant;
|
@@ -25,3 +20,13 @@ export interface ButtonBaseProps {
|
|
25
20
|
className?: string;
|
26
21
|
}
|
27
22
|
export declare function isButtonType(props: any): props is JSX.IntrinsicElements["button"];
|
23
|
+
declare type AsProp<C extends React.ElementType> = {
|
24
|
+
as?: C;
|
25
|
+
};
|
26
|
+
declare type PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);
|
27
|
+
declare type PolymorphicComponentProp<C extends React.ElementType, Props = {}> = React.PropsWithChildren<Props & AsProp<C>> & Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;
|
28
|
+
export declare type PolymorphicComponentPropWithRef<C extends React.ElementType, Props = {}> = PolymorphicComponentProp<C, Props> & {
|
29
|
+
ref?: PolymorphicRef<C>;
|
30
|
+
};
|
31
|
+
export declare type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>["ref"];
|
32
|
+
export {};
|