@akinon/ui-button 1.2.1 → 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.
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +20 -10
- package/dist/cjs/types.d.ts +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +20 -10
- package/dist/esm/types.d.ts +1 -0
- package/package.json +11 -10
package/dist/cjs/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ import type { IButtonProps } from './types';
|
|
|
11
11
|
* and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes" target="_blank" rel="noopener noreferrer">HTMLAnchorElement</a>,
|
|
12
12
|
* allowing for flexible usage as both a button and a link.
|
|
13
13
|
*/
|
|
14
|
-
export declare const Button: (buttonProps: IButtonProps) => React.JSX.Element;
|
|
14
|
+
export declare const Button: ({ iconSize, ...buttonProps }: IButtonProps) => React.JSX.Element;
|
|
15
15
|
export type * from './types';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,GAAI,8BAA8B,YAAY,sBA6JhE,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.Button = void 0;
|
|
4
15
|
const icons_1 = require("@akinon/icons");
|
|
@@ -18,7 +29,8 @@ const react_1 = require("react");
|
|
|
18
29
|
* and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes" target="_blank" rel="noopener noreferrer">HTMLAnchorElement</a>,
|
|
19
30
|
* allowing for flexible usage as both a button and a link.
|
|
20
31
|
*/
|
|
21
|
-
const Button = (
|
|
32
|
+
const Button = (_a) => {
|
|
33
|
+
var { iconSize } = _a, buttonProps = __rest(_a, ["iconSize"]);
|
|
22
34
|
const { getPrefixCls, theme } = react_1.default.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
23
35
|
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
24
36
|
const buttonToken = token.Button;
|
|
@@ -29,7 +41,7 @@ const Button = (buttonProps) => {
|
|
|
29
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
42
|
theme: theme
|
|
31
43
|
}, () => {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
33
45
|
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-btn`;
|
|
34
46
|
const iconPrefixCls = `.${getPrefixCls()}-btn`;
|
|
35
47
|
// MARK: - Disabled
|
|
@@ -91,13 +103,14 @@ const Button = (buttonProps) => {
|
|
|
91
103
|
// END: Warning
|
|
92
104
|
// MARK: Icon
|
|
93
105
|
[`${prefixCls}-icon`]: {
|
|
106
|
+
lineHeight: 1,
|
|
94
107
|
['> *']: {
|
|
95
108
|
backgroundColor: customTokens.others.colorTransparent,
|
|
96
|
-
// Since this button is transparent, we are using
|
|
97
|
-
color:
|
|
109
|
+
// Since this button is transparent, we are using current color for the icon.
|
|
110
|
+
color: 'currentcolor',
|
|
98
111
|
verticalAlign: customTokens.others.verticalAlignMiddle,
|
|
99
112
|
'&:hover:not(:disabled)': {
|
|
100
|
-
color:
|
|
113
|
+
color: 'currentcolor'
|
|
101
114
|
},
|
|
102
115
|
'&:active': {
|
|
103
116
|
boxShadow: customTokens.layout.displayNone
|
|
@@ -109,17 +122,14 @@ const Button = (buttonProps) => {
|
|
|
109
122
|
[`&${iconPrefixCls}-dangerous > *`]: {
|
|
110
123
|
color: 'red',
|
|
111
124
|
'&:hover:not(:disabled)': {
|
|
112
|
-
color: (
|
|
125
|
+
color: (_l = buttonToken.colorErrorHover) !== null && _l !== void 0 ? _l : token.colorErrorHover
|
|
113
126
|
}
|
|
114
127
|
}
|
|
115
128
|
}
|
|
116
129
|
// END: Icon
|
|
117
130
|
};
|
|
118
131
|
});
|
|
119
|
-
const renderButton = () => {
|
|
120
|
-
var _a;
|
|
121
|
-
return (react_1.default.createElement(antd_1.Button, Object.assign({}, buttonProps, { icon: buttonProps.icon ? (react_1.default.createElement(icons_1.Icon, { icon: buttonProps.icon, size: (_a = buttonProps.iconSize) !== null && _a !== void 0 ? _a : 12, style: { lineHeight: 0 } })) : undefined }), buttonProps.children));
|
|
122
|
-
};
|
|
132
|
+
const renderButton = () => (react_1.default.createElement(antd_1.Button, Object.assign({}, buttonProps, { icon: buttonProps.icon ? (react_1.default.createElement(icons_1.Icon, { icon: buttonProps.icon, size: iconSize !== null && iconSize !== void 0 ? iconSize : 12, style: { lineHeight: 0 } })) : undefined }), buttonProps.children));
|
|
123
133
|
// If tooltip prop is provided, wrap the button with Tooltip
|
|
124
134
|
if (buttonProps.tooltip) {
|
|
125
135
|
const tooltipProps = typeof buttonProps.tooltip === 'string'
|
package/dist/cjs/types.d.ts
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ import type { IButtonProps } from './types';
|
|
|
11
11
|
* and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes" target="_blank" rel="noopener noreferrer">HTMLAnchorElement</a>,
|
|
12
12
|
* allowing for flexible usage as both a button and a link.
|
|
13
13
|
*/
|
|
14
|
-
export declare const Button: (buttonProps: IButtonProps) => React.JSX.Element;
|
|
14
|
+
export declare const Button: ({ iconSize, ...buttonProps }: IButtonProps) => React.JSX.Element;
|
|
15
15
|
export type * from './types';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,GAAI,8BAA8B,YAAY,sBA6JhE,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { Icon } from '@akinon/icons';
|
|
2
13
|
import { getSafeCustomTokens, useToken } from '@akinon/ui-theme';
|
|
3
14
|
import { Tooltip } from '@akinon/ui-tooltip';
|
|
@@ -15,7 +26,8 @@ import React from 'react';
|
|
|
15
26
|
* and <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes" target="_blank" rel="noopener noreferrer">HTMLAnchorElement</a>,
|
|
16
27
|
* allowing for flexible usage as both a button and a link.
|
|
17
28
|
*/
|
|
18
|
-
export const Button = (
|
|
29
|
+
export const Button = (_a) => {
|
|
30
|
+
var { iconSize } = _a, buttonProps = __rest(_a, ["iconSize"]);
|
|
19
31
|
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
20
32
|
const { token, hashId } = useToken();
|
|
21
33
|
const buttonToken = token.Button;
|
|
@@ -26,7 +38,7 @@ export const Button = (buttonProps) => {
|
|
|
26
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
39
|
theme: theme
|
|
28
40
|
}, () => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
30
42
|
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-btn`;
|
|
31
43
|
const iconPrefixCls = `.${getPrefixCls()}-btn`;
|
|
32
44
|
// MARK: - Disabled
|
|
@@ -88,13 +100,14 @@ export const Button = (buttonProps) => {
|
|
|
88
100
|
// END: Warning
|
|
89
101
|
// MARK: Icon
|
|
90
102
|
[`${prefixCls}-icon`]: {
|
|
103
|
+
lineHeight: 1,
|
|
91
104
|
['> *']: {
|
|
92
105
|
backgroundColor: customTokens.others.colorTransparent,
|
|
93
|
-
// Since this button is transparent, we are using
|
|
94
|
-
color:
|
|
106
|
+
// Since this button is transparent, we are using current color for the icon.
|
|
107
|
+
color: 'currentcolor',
|
|
95
108
|
verticalAlign: customTokens.others.verticalAlignMiddle,
|
|
96
109
|
'&:hover:not(:disabled)': {
|
|
97
|
-
color:
|
|
110
|
+
color: 'currentcolor'
|
|
98
111
|
},
|
|
99
112
|
'&:active': {
|
|
100
113
|
boxShadow: customTokens.layout.displayNone
|
|
@@ -106,17 +119,14 @@ export const Button = (buttonProps) => {
|
|
|
106
119
|
[`&${iconPrefixCls}-dangerous > *`]: {
|
|
107
120
|
color: 'red',
|
|
108
121
|
'&:hover:not(:disabled)': {
|
|
109
|
-
color: (
|
|
122
|
+
color: (_l = buttonToken.colorErrorHover) !== null && _l !== void 0 ? _l : token.colorErrorHover
|
|
110
123
|
}
|
|
111
124
|
}
|
|
112
125
|
}
|
|
113
126
|
// END: Icon
|
|
114
127
|
};
|
|
115
128
|
});
|
|
116
|
-
const renderButton = () => {
|
|
117
|
-
var _a;
|
|
118
|
-
return (React.createElement(AntButton, Object.assign({}, buttonProps, { icon: buttonProps.icon ? (React.createElement(Icon, { icon: buttonProps.icon, size: (_a = buttonProps.iconSize) !== null && _a !== void 0 ? _a : 12, style: { lineHeight: 0 } })) : undefined }), buttonProps.children));
|
|
119
|
-
};
|
|
129
|
+
const renderButton = () => (React.createElement(AntButton, Object.assign({}, buttonProps, { icon: buttonProps.icon ? (React.createElement(Icon, { icon: buttonProps.icon, size: iconSize !== null && iconSize !== void 0 ? iconSize : 12, style: { lineHeight: 0 } })) : undefined }), buttonProps.children));
|
|
120
130
|
// If tooltip prop is provided, wrap the button with Tooltip
|
|
121
131
|
if (buttonProps.tooltip) {
|
|
122
132
|
const tooltipProps = typeof buttonProps.tooltip === 'string'
|
package/dist/esm/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-button",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A basic button react component.",
|
|
6
6
|
"type": "module",
|
|
@@ -10,21 +10,22 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"@akinon/
|
|
16
|
-
"@akinon/ui-theme": "1.
|
|
13
|
+
"@ant-design/cssinjs": "^1.24.0",
|
|
14
|
+
"antd": "^5.27.0",
|
|
15
|
+
"@akinon/icons": "1.1.0",
|
|
16
|
+
"@akinon/ui-theme": "1.1.1",
|
|
17
|
+
"@akinon/ui-tooltip": "1.3.1"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"clean-package": "2.2.0",
|
|
20
21
|
"copyfiles": "^2.4.1",
|
|
21
22
|
"rimraf": "^5.0.5",
|
|
22
23
|
"typescript": "*",
|
|
23
|
-
"@akinon/typescript-config": "1.0
|
|
24
|
+
"@akinon/typescript-config": "1.1.0"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
|
-
"react": "
|
|
27
|
-
"react-dom": "
|
|
27
|
+
"react": "^18 || ^19",
|
|
28
|
+
"react-dom": "^18 || ^19"
|
|
28
29
|
},
|
|
29
30
|
"clean-package": "../../../clean-package.config.json",
|
|
30
31
|
"types": "dist/esm/index.d.ts",
|
|
@@ -38,10 +39,10 @@
|
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
41
|
-
"build:esm": "tsc --outDir dist/esm",
|
|
42
42
|
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
43
|
-
"
|
|
43
|
+
"build:esm": "tsc --outDir dist/esm",
|
|
44
44
|
"clean": "rimraf dist/",
|
|
45
|
+
"copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
|
|
45
46
|
"typecheck": "tsc --noEmit"
|
|
46
47
|
}
|
|
47
48
|
}
|