@aloudata/aloudata-design 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IDropdownProps } from '../Dropdown';
|
|
3
3
|
import { TSize } from '../Input';
|
|
4
|
+
import { ITooltipProps } from '../Tooltip';
|
|
4
5
|
interface IIconButtonProps {
|
|
5
6
|
icon: React.ReactNode;
|
|
6
|
-
onClick?: React.
|
|
7
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
size?: TSize;
|
|
9
10
|
className?: string;
|
|
10
11
|
keepFocus?: boolean;
|
|
12
|
+
tooltip?: ITooltipProps;
|
|
13
|
+
id?: string;
|
|
14
|
+
mode?: 'light' | 'dark';
|
|
11
15
|
}
|
|
12
|
-
declare const DropdownButton: React.ForwardRefExoticComponent<IIconButtonProps & IDropdownProps &
|
|
16
|
+
declare const DropdownButton: React.ForwardRefExoticComponent<IIconButtonProps & IDropdownProps & {
|
|
17
|
+
showArrow?: boolean | undefined;
|
|
18
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
13
19
|
declare const IconButton: React.ForwardRefExoticComponent<IIconButtonProps & React.RefAttributes<HTMLButtonElement>> & {
|
|
14
20
|
dropdown: typeof DropdownButton;
|
|
21
|
+
__ANT_BUTTON: boolean;
|
|
15
22
|
};
|
|
16
23
|
export default IconButton;
|
package/dist/IconButton/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
var _excluded = ["icon", "onClick", "disabled", "size", "menu", "className", "onOpenChange"];
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1
|
+
var _excluded = ["icon", "onClick", "disabled", "size", "menu", "className", "onOpenChange", "tooltip", "id", "overlay", "showArrow", "mode"];
|
|
4
2
|
|
|
5
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
4
|
|
|
@@ -18,11 +16,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
18
16
|
|
|
19
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
18
|
|
|
19
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
20
|
+
|
|
21
21
|
import { FoldDownFill } from '@aloudata/icons-react';
|
|
22
22
|
import classnames from 'classnames';
|
|
23
|
-
import React, { forwardRef } from 'react';
|
|
23
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
24
24
|
import Dropdown from "../Dropdown";
|
|
25
25
|
import { getSizeType } from "../Input/components/Input";
|
|
26
|
+
import Tooltip from "../Tooltip";
|
|
26
27
|
var InternalIconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
27
28
|
var icon = props.icon,
|
|
28
29
|
_props$onClick = props.onClick,
|
|
@@ -31,7 +32,11 @@ var InternalIconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
31
32
|
_props$size = props.size,
|
|
32
33
|
size = _props$size === void 0 ? 'middle' : _props$size,
|
|
33
34
|
keepFocus = props.keepFocus,
|
|
34
|
-
className = props.className
|
|
35
|
+
className = props.className,
|
|
36
|
+
tooltip = props.tooltip,
|
|
37
|
+
id = props.id,
|
|
38
|
+
_props$mode = props.mode,
|
|
39
|
+
mode = _props$mode === void 0 ? 'light' : _props$mode;
|
|
35
40
|
|
|
36
41
|
var onButtonClick = function onButtonClick(e) {
|
|
37
42
|
if (disabled) {
|
|
@@ -43,18 +48,22 @@ var InternalIconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
43
48
|
onClick(e);
|
|
44
49
|
};
|
|
45
50
|
|
|
46
|
-
return /*#__PURE__*/React.createElement(
|
|
51
|
+
return /*#__PURE__*/React.createElement(Tooltip, _extends({}, tooltip, {
|
|
52
|
+
title: tooltip === null || tooltip === void 0 ? void 0 : tooltip.title
|
|
53
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
54
|
+
id: id,
|
|
47
55
|
className: classnames(className, 'ald-icon-button', "ald-icon-button-".concat(getSizeType(size)), {
|
|
48
56
|
'ald-icon-button-disabled': disabled,
|
|
49
|
-
'ald-icon-button-focus': keepFocus
|
|
57
|
+
'ald-icon-button-focus': keepFocus,
|
|
58
|
+
'ald-icon-button-dark': mode === 'dark'
|
|
50
59
|
}),
|
|
51
60
|
type: "button",
|
|
52
61
|
ref: ref,
|
|
53
|
-
onClick: onButtonClick
|
|
54
|
-
|
|
62
|
+
onClick: onButtonClick // disabled={disabled}
|
|
63
|
+
|
|
55
64
|
}, /*#__PURE__*/React.createElement("div", {
|
|
56
65
|
className: "ald-icon-button-wrap"
|
|
57
|
-
}, icon));
|
|
66
|
+
}, icon)));
|
|
58
67
|
});
|
|
59
68
|
var DropdownButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
60
69
|
var icon = props.icon,
|
|
@@ -66,6 +75,13 @@ var DropdownButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
66
75
|
menu = props.menu,
|
|
67
76
|
className = props.className,
|
|
68
77
|
onOpenChange = props.onOpenChange,
|
|
78
|
+
tooltip = props.tooltip,
|
|
79
|
+
id = props.id,
|
|
80
|
+
overlay = props.overlay,
|
|
81
|
+
_props$showArrow = props.showArrow,
|
|
82
|
+
showArrow = _props$showArrow === void 0 ? true : _props$showArrow,
|
|
83
|
+
_props$mode2 = props.mode,
|
|
84
|
+
mode = _props$mode2 === void 0 ? 'light' : _props$mode2,
|
|
69
85
|
restDropdownProps = _objectWithoutProperties(props, _excluded);
|
|
70
86
|
|
|
71
87
|
var sizeMemo = React.useMemo(function () {
|
|
@@ -95,25 +111,52 @@ var DropdownButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
95
111
|
}
|
|
96
112
|
};
|
|
97
113
|
|
|
98
|
-
|
|
114
|
+
var canDropdown = useMemo(function () {
|
|
115
|
+
var hasMenu = menu && menu.items && menu.items.length > 0;
|
|
116
|
+
return (hasMenu || overlay) && !disabled;
|
|
117
|
+
}, [menu, overlay, disabled]);
|
|
118
|
+
|
|
119
|
+
if (!canDropdown) {
|
|
120
|
+
return /*#__PURE__*/React.createElement(Tooltip, _extends({}, tooltip, {
|
|
121
|
+
title: tooltip === null || tooltip === void 0 ? void 0 : tooltip.title
|
|
122
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
123
|
+
id: id,
|
|
124
|
+
className: classnames(className, 'ald-icon-button-dropdown', "ald-icon-button-".concat(getSizeType(size)), {
|
|
125
|
+
'ald-icon-button-disabled': disabled,
|
|
126
|
+
'ald-icon-button-dropdown-open': dropdownOpen,
|
|
127
|
+
'ald-icon-button-dark': mode === 'dark'
|
|
128
|
+
}),
|
|
129
|
+
type: "button",
|
|
130
|
+
ref: ref,
|
|
131
|
+
onClick: onButtonClick
|
|
132
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
className: "ald-icon-button-wrap"
|
|
134
|
+
}, icon), showArrow && /*#__PURE__*/React.createElement(FoldDownFill, {
|
|
135
|
+
size: sizeMemo === 'large' ? 20 : 16
|
|
136
|
+
})));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return /*#__PURE__*/React.createElement(Tooltip, _extends({}, tooltip, {
|
|
140
|
+
title: tooltip === null || tooltip === void 0 ? void 0 : tooltip.title
|
|
141
|
+
}), /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
99
142
|
menu: menu,
|
|
100
143
|
onOpenChange: onDropdownOpenChange
|
|
101
144
|
}, restDropdownProps), /*#__PURE__*/React.createElement("button", {
|
|
145
|
+
id: id,
|
|
102
146
|
className: classnames(className, 'ald-icon-button-dropdown', "ald-icon-button-".concat(getSizeType(size)), {
|
|
103
147
|
'ald-icon-button-disabled': disabled,
|
|
104
148
|
'ald-icon-button-dropdown-open': dropdownOpen
|
|
105
149
|
}),
|
|
106
150
|
type: "button",
|
|
107
151
|
ref: ref,
|
|
108
|
-
onClick: onButtonClick
|
|
109
|
-
disabled: disabled
|
|
152
|
+
onClick: onButtonClick
|
|
110
153
|
}, /*#__PURE__*/React.createElement("div", {
|
|
111
154
|
className: "ald-icon-button-wrap"
|
|
112
|
-
}, icon), /*#__PURE__*/React.createElement(FoldDownFill, {
|
|
113
|
-
size: sizeMemo === 'large' ? 20 : 16
|
|
114
|
-
|
|
115
|
-
})));
|
|
155
|
+
}, icon), showArrow && /*#__PURE__*/React.createElement(FoldDownFill, {
|
|
156
|
+
size: sizeMemo === 'large' ? 20 : 16
|
|
157
|
+
}))));
|
|
116
158
|
});
|
|
117
159
|
var IconButton = InternalIconButton;
|
|
118
160
|
IconButton.dropdown = DropdownButton;
|
|
161
|
+
IconButton.__ANT_BUTTON = true;
|
|
119
162
|
export default IconButton;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@import '../../style/index.less';
|
|
2
2
|
@import '../../Dropdown/style/index.less';
|
|
3
3
|
@import '../../Menu/style/index.less';
|
|
4
|
-
|
|
4
|
+
@import '../../Tooltip/style/index.less';
|
|
5
5
|
@icon-button-size-large: 28px;
|
|
6
6
|
@icon-button-size-middle: 24px;
|
|
7
7
|
@icon-button-size-small: 20px;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
padding: 0;
|
|
25
25
|
outline: 0;
|
|
26
26
|
font-size: inherit;
|
|
27
|
-
color:
|
|
27
|
+
color: #171717;
|
|
28
28
|
-webkit-tap-highlight-color: transparent;
|
|
29
29
|
appearance: none;
|
|
30
30
|
box-sizing: border-box;
|
|
@@ -60,10 +60,26 @@
|
|
|
60
60
|
background: var(--colors-gray-98, #f4f4f4);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
&.
|
|
63
|
+
&.ald-icon-button-dropdown {
|
|
64
64
|
width: fit-content;
|
|
65
65
|
word-spacing: 0;
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
&.ald-icon-button-dark {
|
|
69
|
+
color: #d5d5d5;
|
|
70
|
+
|
|
71
|
+
&:hover {
|
|
72
|
+
background: fade(#f4f4f4, 10%);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:active {
|
|
76
|
+
background: fade(#ededed, 20%);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:not(.ald-icon-button-dark) {
|
|
81
|
+
mix-blend-mode: multiply;
|
|
82
|
+
}
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
.ald-icon-button-wrap-content(@size) {
|