xmirror-components 1.0.26-alpha.0 → 1.0.26-alpha.2

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.
@@ -52,5 +52,5 @@ export interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
52
52
  */
53
53
  [key: string]: any;
54
54
  }
55
- export declare const IconButton: (props: IconButtonProps) => React.JSX.Element;
55
+ export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
56
56
  export default IconButton;
@@ -31,7 +31,10 @@ import classNames from 'classnames';
31
31
  import IconFont from '../IconFont';
32
32
  import { ConfigContext } from '../ConfigProvider';
33
33
  import styled from '@emotion/styled';
34
- var StyledButton = styled(Button)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"], ["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"])));
34
+ // 1. 先用 forwardRef 包裹 antd Button,确保 ref 类型
35
+ var BaseButton = React.forwardRef(function (props, ref) { return (React.createElement(Button, __assign({ ref: ref }, props))); });
36
+ // 2. 用 styled/emotion 包裹 BaseButton
37
+ var StyledButton = styled(BaseButton)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"], ["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"])));
35
38
  var ButtonTooltip = function (_a) {
36
39
  var children = _a.children, tooltipDisabled = _a.tooltipDisabled, disabled = _a.disabled, disabledReason = _a.disabledReason, title = _a.title, attrs = __rest(_a, ["children", "tooltipDisabled", "disabled", "disabledReason", "title"]);
37
40
  if (tooltipDisabled) {
@@ -41,9 +44,9 @@ var ButtonTooltip = function (_a) {
41
44
  return (React.createElement(Tooltip, __assign({ title: disabled ? disabledReason || title : title }, attrs), children));
42
45
  }
43
46
  };
44
- export var IconButton = function (props) {
47
+ export var IconButton = React.forwardRef(function (props, ref) {
45
48
  var iconButton = useContext(ConfigContext).iconButton;
46
- var Icon = props.icon, _a = props.tooltipDisabled, tooltipDisabled = _a === void 0 ? false : _a, title = props.title, _b = props.hide, hide = _b === void 0 ? false : _b, disabledReason = props.disabledReason, _c = props.onClick, onClick = _c === void 0 ? noop : _c, disabled = props.disabled, _d = props.size, size = _d === void 0 ? iconButton.size : _d, _e = props.style, style = _e === void 0 ? {} : _e, className = props.className, _f = props.loading, loading = _f === void 0 ? false : _f, attrs = __rest(props, ["icon", "tooltipDisabled", "title", "hide", "disabledReason", "onClick", "disabled", "size", "style", "className", "loading"]);
49
+ var Icon = props.icon, _a = props.tooltipDisabled, tooltipDisabled = _a === void 0 ? false : _a, title = props.title, _b = props.hide, hide = _b === void 0 ? false : _b, disabledReason = props.disabledReason, _c = props.onClick, onClick = _c === void 0 ? noop : _c, disabled = props.disabled, _d = props.size, size = _d === void 0 ? iconButton.size || 'small' : _d, _e = props.style, style = _e === void 0 ? {} : _e, className = props.className, _f = props.loading, loading = _f === void 0 ? false : _f, attrs = __rest(props, ["icon", "tooltipDisabled", "title", "hide", "disabledReason", "onClick", "disabled", "size", "style", "className", "loading"]);
47
50
  var createIcon = function () {
48
51
  if (isString(Icon)) {
49
52
  return React.createElement(IconFont, { type: Icon });
@@ -58,7 +61,7 @@ export var IconButton = function (props) {
58
61
  }
59
62
  return (React.createElement(IconButtonRender, __assign({}, props),
60
63
  React.createElement(ButtonTooltip, __assign({ tooltipDisabled: tooltipDisabled, hide: hide, disabled: disabled, disabledReason: disabledReason, title: title }, attrs),
61
- React.createElement(StyledButton, { icon: createIcon(), size: size, className: classNames([iconButton.className, className]), disabled: disabled, style: __assign(__assign({}, iconButton.style), style), loading: loading, onClick: onClick }))));
62
- };
64
+ React.createElement(StyledButton, { ref: ref, icon: createIcon(), size: size, className: classNames([iconButton.className, className]), disabled: disabled, style: __assign(__assign({}, iconButton.style), style), loading: loading, onClick: onClick }))));
65
+ });
63
66
  export default IconButton;
64
67
  var templateObject_1;
@@ -52,5 +52,5 @@ export interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
52
52
  */
53
53
  [key: string]: any;
54
54
  }
55
- export declare const IconButton: (props: IconButtonProps) => React.JSX.Element;
55
+ export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
56
56
  export default IconButton;
@@ -70,7 +70,10 @@ var classnames_1 = __importDefault(require("classnames"));
70
70
  var IconFont_1 = __importDefault(require("../IconFont"));
71
71
  var ConfigProvider_1 = require("../ConfigProvider");
72
72
  var styled_1 = __importDefault(require("@emotion/styled"));
73
- var StyledButton = (0, styled_1.default)(antd_1.Button)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"], ["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"])));
73
+ // 1. 先用 forwardRef 包裹 antd Button,确保 ref 类型
74
+ var BaseButton = react_1.default.forwardRef(function (props, ref) { return (react_1.default.createElement(antd_1.Button, __assign({ ref: ref }, props))); });
75
+ // 2. 用 styled/emotion 包裹 BaseButton
76
+ var StyledButton = (0, styled_1.default)(BaseButton)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"], ["\n font-size: 18px;\n color: var(--color-primary);\n background-color: transparent;\n border: none;\n box-shadow: initial;\n transition: background-color 0.2s;\n\n &[disabled], &[aria-disabled='true'] {\n color: #9da2a6 !important;\n cursor: not-allowed;\n background-color: transparent;\n }\n\n &:hover, &:active, &:focus {\n background: #F4F0F5;\n }\n\n span {\n font-size: 18px;\n }\n"])));
74
77
  var ButtonTooltip = function (_a) {
75
78
  var children = _a.children, tooltipDisabled = _a.tooltipDisabled, disabled = _a.disabled, disabledReason = _a.disabledReason, title = _a.title, attrs = __rest(_a, ["children", "tooltipDisabled", "disabled", "disabledReason", "title"]);
76
79
  if (tooltipDisabled) {
@@ -80,9 +83,9 @@ var ButtonTooltip = function (_a) {
80
83
  return (react_1.default.createElement(antd_1.Tooltip, __assign({ title: disabled ? disabledReason || title : title }, attrs), children));
81
84
  }
82
85
  };
83
- var IconButton = function (props) {
86
+ exports.IconButton = react_1.default.forwardRef(function (props, ref) {
84
87
  var iconButton = (0, react_1.useContext)(ConfigProvider_1.ConfigContext).iconButton;
85
- var Icon = props.icon, _a = props.tooltipDisabled, tooltipDisabled = _a === void 0 ? false : _a, title = props.title, _b = props.hide, hide = _b === void 0 ? false : _b, disabledReason = props.disabledReason, _c = props.onClick, onClick = _c === void 0 ? lodash_es_1.noop : _c, disabled = props.disabled, _d = props.size, size = _d === void 0 ? iconButton.size : _d, _e = props.style, style = _e === void 0 ? {} : _e, className = props.className, _f = props.loading, loading = _f === void 0 ? false : _f, attrs = __rest(props, ["icon", "tooltipDisabled", "title", "hide", "disabledReason", "onClick", "disabled", "size", "style", "className", "loading"]);
88
+ var Icon = props.icon, _a = props.tooltipDisabled, tooltipDisabled = _a === void 0 ? false : _a, title = props.title, _b = props.hide, hide = _b === void 0 ? false : _b, disabledReason = props.disabledReason, _c = props.onClick, onClick = _c === void 0 ? lodash_es_1.noop : _c, disabled = props.disabled, _d = props.size, size = _d === void 0 ? iconButton.size || 'small' : _d, _e = props.style, style = _e === void 0 ? {} : _e, className = props.className, _f = props.loading, loading = _f === void 0 ? false : _f, attrs = __rest(props, ["icon", "tooltipDisabled", "title", "hide", "disabledReason", "onClick", "disabled", "size", "style", "className", "loading"]);
86
89
  var createIcon = function () {
87
90
  if ((0, lodash_es_1.isString)(Icon)) {
88
91
  return react_1.default.createElement(IconFont_1.default, { type: Icon });
@@ -97,8 +100,7 @@ var IconButton = function (props) {
97
100
  }
98
101
  return (react_1.default.createElement(IconButtonRender, __assign({}, props),
99
102
  react_1.default.createElement(ButtonTooltip, __assign({ tooltipDisabled: tooltipDisabled, hide: hide, disabled: disabled, disabledReason: disabledReason, title: title }, attrs),
100
- react_1.default.createElement(StyledButton, { icon: createIcon(), size: size, className: (0, classnames_1.default)([iconButton.className, className]), disabled: disabled, style: __assign(__assign({}, iconButton.style), style), loading: loading, onClick: onClick }))));
101
- };
102
- exports.IconButton = IconButton;
103
+ react_1.default.createElement(StyledButton, { ref: ref, icon: createIcon(), size: size, className: (0, classnames_1.default)([iconButton.className, className]), disabled: disabled, style: __assign(__assign({}, iconButton.style), style), loading: loading, onClick: onClick }))));
104
+ });
103
105
  exports.default = exports.IconButton;
104
106
  var templateObject_1;
@@ -95,7 +95,7 @@ declare interface ConfigProviderProps {
95
95
 
96
96
  export declare function GlobalLoading(): React_2.JSX.Element;
97
97
 
98
- export declare const IconButton: (props: IconButtonProps) => React_2.JSX.Element;
98
+ export declare const IconButton: React_2.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React_2.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
99
99
 
100
100
  declare type IconButtonConfig = Pick<IconButtonProps, 'size' | 'className' | 'style'> & {
101
101
  render: (props: IconButtonProps & {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmirror-components",
3
- "version": "1.0.26-alpha.0",
3
+ "version": "1.0.26-alpha.2",
4
4
  "type": "module",
5
5
  "main": "build/lib/index.js",
6
6
  "module": "build/es/index.js",
@@ -52,5 +52,5 @@ export interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
52
52
  */
53
53
  [key: string]: any;
54
54
  }
55
- export declare const IconButton: (props: IconButtonProps) => React.JSX.Element;
55
+ export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
56
56
  export default IconButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmirror-components",
3
- "version": "1.0.26-alpha.0",
3
+ "version": "1.0.26-alpha.2",
4
4
  "type": "module",
5
5
  "main": "build/lib/index.js",
6
6
  "module": "build/es/index.js",