xmirror-components 1.0.25 → 1.0.26-alpha.0

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.
Files changed (34) hide show
  1. package/build/dist/index.cjs +24 -20
  2. package/build/dist/index.mjs +1405 -1302
  3. package/build/es/components/AntdApp/index.d.ts +4 -1
  4. package/build/es/components/AntdApp/index.js +6 -4
  5. package/build/es/components/ConfigProvider/index.d.ts +9 -0
  6. package/build/es/components/ConfigProvider/index.js +53 -0
  7. package/build/es/components/ConfigProvider/types.d.ts +15 -0
  8. package/build/es/components/ConfigProvider/types.js +1 -0
  9. package/build/es/components/IconButton/index.d.ts +1 -1
  10. package/build/es/components/IconButton/index.js +9 -4
  11. package/build/es/components/IconFont/index.d.ts +8 -2
  12. package/build/es/components/IconFont/index.js +17 -4
  13. package/build/es/index.d.ts +1 -0
  14. package/build/es/index.js +1 -0
  15. package/build/lib/components/AntdApp/index.d.ts +4 -1
  16. package/build/lib/components/AntdApp/index.js +6 -4
  17. package/build/lib/components/ConfigProvider/index.d.ts +9 -0
  18. package/build/lib/components/ConfigProvider/index.js +60 -0
  19. package/build/lib/components/ConfigProvider/types.d.ts +15 -0
  20. package/build/lib/components/ConfigProvider/types.js +2 -0
  21. package/build/lib/components/IconButton/index.d.ts +1 -1
  22. package/build/lib/components/IconButton/index.js +42 -4
  23. package/build/lib/components/IconFont/index.d.ts +8 -2
  24. package/build/lib/components/IconFont/index.js +19 -3
  25. package/build/lib/index.d.ts +37 -4
  26. package/build/lib/index.js +4 -1
  27. package/build/package.json +3 -2
  28. package/build/types/components/AntdApp/index.d.ts +4 -1
  29. package/build/types/components/ConfigProvider/index.d.ts +9 -0
  30. package/build/types/components/ConfigProvider/types.d.ts +15 -0
  31. package/build/types/components/IconButton/index.d.ts +1 -1
  32. package/build/types/components/IconFont/index.d.ts +8 -2
  33. package/build/types/index.d.ts +1 -0
  34. package/package.json +3 -2
@@ -3,9 +3,12 @@ import { type AppProps } from 'antd';
3
3
  import { type MessageInstance } from 'antd/es/message/interface';
4
4
  import { type NotificationInstance } from 'antd/es/notification/interface';
5
5
  import { type ModalStaticFunctions } from 'antd/es/modal/confirm';
6
+ import { type ConfigProviderConfigProps } from './../ConfigProvider';
6
7
  declare let message: MessageInstance;
7
8
  declare let notification: NotificationInstance;
8
9
  declare let modal: Omit<ModalStaticFunctions, 'warn'>;
9
- declare function Index({ children, ...props }: AppProps): React.JSX.Element;
10
+ declare function Index({ children, config, ...props }: AppProps & {
11
+ config?: ConfigProviderConfigProps;
12
+ }): React.JSX.Element;
10
13
  export { message, notification, modal };
11
14
  export default Index;
@@ -23,6 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import React from 'react';
24
24
  import { App, message as AntdMessage, notification as AntdNotification, Modal as AntdModal } from 'antd';
25
25
  import GlobalLoading from './../GlobalLoading';
26
+ import ConfigProvider from './../ConfigProvider';
26
27
  var message = AntdMessage;
27
28
  var notification = AntdNotification;
28
29
  var modal = AntdModal;
@@ -35,10 +36,11 @@ function InitApp(_a) {
35
36
  return children || '';
36
37
  }
37
38
  function Index(_a) {
38
- var children = _a.children, props = __rest(_a, ["children"]);
39
- return (React.createElement(App, __assign({}, props),
40
- React.createElement(GlobalLoading, null),
41
- React.createElement(InitApp, null, children)));
39
+ var children = _a.children, config = _a.config, props = __rest(_a, ["children", "config"]);
40
+ return (React.createElement(ConfigProvider, { config: config || {} },
41
+ React.createElement(App, __assign({}, props),
42
+ React.createElement(GlobalLoading, null),
43
+ React.createElement(InitApp, null, children))));
42
44
  }
43
45
  export { message, notification, modal };
44
46
  export default Index;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { ConfigContextProps, ConfigProviderConfigProps } from './types';
3
+ export type { ConfigProviderConfigProps, ConfigContextProps } from './types';
4
+ export declare const ConfigContext: React.Context<ConfigContextProps>;
5
+ interface ConfigProviderProps {
6
+ children: React.ReactNode;
7
+ config: ConfigProviderConfigProps;
8
+ }
9
+ export default function ConfigProvider({ children, config }: ConfigProviderProps): React.JSX.Element;
@@ -0,0 +1,53 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import React from 'react';
24
+ // 递归合并函数
25
+ function deepMerge(target, source) {
26
+ var result = __assign({}, target);
27
+ for (var key in source) {
28
+ if (source[key] !== undefined) {
29
+ if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
30
+ result[key] = deepMerge(target[key] || {}, source[key]);
31
+ }
32
+ else {
33
+ result[key] = source[key];
34
+ }
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ var baseConfig = {
40
+ iconButton: {
41
+ size: 'small',
42
+ render: function (_a) {
43
+ var children = _a.children, params = __rest(_a, ["children"]);
44
+ return children;
45
+ }
46
+ },
47
+ iconFont: {}
48
+ };
49
+ export var ConfigContext = React.createContext(baseConfig);
50
+ export default function ConfigProvider(_a) {
51
+ var children = _a.children, config = _a.config;
52
+ return (React.createElement(ConfigContext.Provider, { value: deepMerge(baseConfig, config) }, children));
53
+ }
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { IconButtonProps } from "../IconButton";
3
+ import { IconFontProps } from "../IconFont";
4
+ type IconButtonConfig = Pick<IconButtonProps, 'size' | 'className' | 'style'> & {
5
+ render: (props: IconButtonProps & {
6
+ children: React.ReactNode;
7
+ }) => React.ReactNode;
8
+ };
9
+ type IconFontConfig = Pick<IconFontProps, 'className' | 'style'>;
10
+ export interface ConfigContextProps {
11
+ iconButton: IconButtonConfig;
12
+ iconFont: IconFontConfig;
13
+ }
14
+ export type ConfigProviderConfigProps = Partial<ConfigContextProps>;
15
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -22,7 +22,7 @@ interface ButtonTooltipProps {
22
22
  disabled?: boolean;
23
23
  children?: React.ReactNode;
24
24
  }
25
- interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
25
+ export interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
26
26
  /**
27
27
  * 图标
28
28
  */
@@ -24,10 +24,12 @@ var __rest = (this && this.__rest) || function (s, e) {
24
24
  }
25
25
  return t;
26
26
  };
27
- import React from 'react';
27
+ import React, { useContext } from 'react';
28
28
  import { Tooltip, Button } from 'antd';
29
29
  import { noop, isString } from 'lodash-es';
30
+ import classNames from 'classnames';
30
31
  import IconFont from '../IconFont';
32
+ import { ConfigContext } from '../ConfigProvider';
31
33
  import styled from '@emotion/styled';
32
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"])));
33
35
  var ButtonTooltip = function (_a) {
@@ -40,7 +42,8 @@ var ButtonTooltip = function (_a) {
40
42
  }
41
43
  };
42
44
  export var IconButton = function (props) {
43
- 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 ? '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"]);
45
+ 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"]);
44
47
  var createIcon = function () {
45
48
  if (isString(Icon)) {
46
49
  return React.createElement(IconFont, { type: Icon });
@@ -49,11 +52,13 @@ export var IconButton = function (props) {
49
52
  return Icon;
50
53
  }
51
54
  };
55
+ var IconButtonRender = iconButton.render;
52
56
  if (!Icon) {
53
57
  console.warn('Icon props not found');
54
58
  }
55
- return (React.createElement(ButtonTooltip, __assign({ tooltipDisabled: tooltipDisabled, hide: hide, disabled: disabled, disabledReason: disabledReason, title: title }, attrs),
56
- React.createElement(StyledButton, { icon: createIcon(), size: size, className: className, disabled: disabled, style: style, loading: loading, onClick: onClick })));
59
+ return (React.createElement(IconButtonRender, __assign({}, props),
60
+ 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 }))));
57
62
  };
58
63
  export default IconButton;
59
64
  var templateObject_1;
@@ -12,10 +12,16 @@ interface IconFontCommonProps {
12
12
  * 是否使用 symbol 模式
13
13
  */
14
14
  symbol?: boolean;
15
+ [attrs: string]: any;
15
16
  }
16
- declare const IconFont: React.ForwardRefExoticComponent<((IconFontCommonProps & React.HTMLAttributes<HTMLElement> & {
17
+ export type IconFontProps = (IconFontCommonProps & React.SVGProps<SVGSVGElement> & {
18
+ symbol: true;
19
+ }) | (IconFontCommonProps & React.HTMLAttributes<HTMLElement> & {
17
20
  symbol?: false;
18
- }) | Omit<IconFontCommonProps & React.SVGProps<SVGSVGElement> & {
21
+ });
22
+ declare const IconFont: React.ForwardRefExoticComponent<(Omit<IconFontCommonProps & React.SVGProps<SVGSVGElement> & {
19
23
  symbol: true;
24
+ }, "ref"> | Omit<IconFontCommonProps & React.HTMLAttributes<HTMLElement> & {
25
+ symbol?: false;
20
26
  }, "ref">) & React.RefAttributes<HTMLElement | SVGSVGElement>>;
21
27
  export default IconFont;
@@ -20,13 +20,26 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React, { forwardRef } from 'react';
23
+ import React, { forwardRef, useContext } from 'react';
24
+ import classNames from 'classnames';
25
+ import { ConfigContext } from '../ConfigProvider';
24
26
  var IconFont = forwardRef(function (_a, ref) {
25
- var _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.symbol, symbol = _d === void 0 ? false : _d, attrs = __rest(_a, ["type", "className", "symbol"]);
27
+ var _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.symbol, symbol = _d === void 0 ? false : _d, style = _a.style, attrs = __rest(_a, ["type", "className", "symbol", "style"]);
28
+ var iconFont = useContext(ConfigContext).iconFont;
26
29
  if (symbol) {
27
- return (React.createElement("svg", __assign({ className: "iconfont-symbol ".concat(type, " ").concat(className), "aria-hidden": "true", ref: ref }, attrs),
30
+ return (React.createElement("svg", __assign({ className: classNames([
31
+ 'iconfont-symbol',
32
+ iconFont.className || '',
33
+ type,
34
+ className,
35
+ ]), "aria-hidden": "true", ref: ref, style: __assign(__assign({}, iconFont.style), (style || {})) }, attrs),
28
36
  React.createElement("use", { xlinkHref: "#".concat(type) })));
29
37
  }
30
- return (React.createElement("i", __assign({ className: "iconfont ".concat(type, " ").concat(className), ref: ref }, attrs)));
38
+ return (React.createElement("i", __assign({ className: classNames([
39
+ 'iconfont',
40
+ iconFont.className || '',
41
+ type,
42
+ className,
43
+ ]), ref: ref, style: __assign(__assign({}, iconFont.style), (style || {})) }, attrs)));
31
44
  });
32
45
  export default IconFont;
@@ -4,4 +4,5 @@ export { default as CheckboxValue } from './components/CheckboxValue';
4
4
  export { default as SwitchValue } from './components/SwitchValue';
5
5
  export { default as IconButton } from './components/IconButton';
6
6
  export { default as GlobalLoading, setGlobalLoading } from './components/GlobalLoading';
7
+ export { default as ConfigProvider, ConfigContext } from './components/ConfigProvider';
7
8
  export { default as useRequest } from './hooks/useRequest';
package/build/es/index.js CHANGED
@@ -4,4 +4,5 @@ export { default as CheckboxValue } from './components/CheckboxValue';
4
4
  export { default as SwitchValue } from './components/SwitchValue';
5
5
  export { default as IconButton } from './components/IconButton';
6
6
  export { default as GlobalLoading, setGlobalLoading } from './components/GlobalLoading';
7
+ export { default as ConfigProvider, ConfigContext } from './components/ConfigProvider';
7
8
  export { default as useRequest } from './hooks/useRequest';
@@ -3,9 +3,12 @@ import { type AppProps } from 'antd';
3
3
  import { type MessageInstance } from 'antd/es/message/interface';
4
4
  import { type NotificationInstance } from 'antd/es/notification/interface';
5
5
  import { type ModalStaticFunctions } from 'antd/es/modal/confirm';
6
+ import { type ConfigProviderConfigProps } from './../ConfigProvider';
6
7
  declare let message: MessageInstance;
7
8
  declare let notification: NotificationInstance;
8
9
  declare let modal: Omit<ModalStaticFunctions, 'warn'>;
9
- declare function Index({ children, ...props }: AppProps): React.JSX.Element;
10
+ declare function Index({ children, config, ...props }: AppProps & {
11
+ config?: ConfigProviderConfigProps;
12
+ }): React.JSX.Element;
10
13
  export { message, notification, modal };
11
14
  export default Index;
@@ -29,6 +29,7 @@ exports.modal = exports.notification = exports.message = void 0;
29
29
  var react_1 = __importDefault(require("react"));
30
30
  var antd_1 = require("antd");
31
31
  var GlobalLoading_1 = __importDefault(require("./../GlobalLoading"));
32
+ var ConfigProvider_1 = __importDefault(require("./../ConfigProvider"));
32
33
  var message = antd_1.message;
33
34
  exports.message = message;
34
35
  var notification = antd_1.notification;
@@ -44,9 +45,10 @@ function InitApp(_a) {
44
45
  return children || '';
45
46
  }
46
47
  function Index(_a) {
47
- var children = _a.children, props = __rest(_a, ["children"]);
48
- return (react_1.default.createElement(antd_1.App, __assign({}, props),
49
- react_1.default.createElement(GlobalLoading_1.default, null),
50
- react_1.default.createElement(InitApp, null, children)));
48
+ var children = _a.children, config = _a.config, props = __rest(_a, ["children", "config"]);
49
+ return (react_1.default.createElement(ConfigProvider_1.default, { config: config || {} },
50
+ react_1.default.createElement(antd_1.App, __assign({}, props),
51
+ react_1.default.createElement(GlobalLoading_1.default, null),
52
+ react_1.default.createElement(InitApp, null, children))));
51
53
  }
52
54
  exports.default = Index;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { ConfigContextProps, ConfigProviderConfigProps } from './types';
3
+ export type { ConfigProviderConfigProps, ConfigContextProps } from './types';
4
+ export declare const ConfigContext: React.Context<ConfigContextProps>;
5
+ interface ConfigProviderProps {
6
+ children: React.ReactNode;
7
+ config: ConfigProviderConfigProps;
8
+ }
9
+ export default function ConfigProvider({ children, config }: ConfigProviderProps): React.JSX.Element;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.ConfigContext = void 0;
29
+ exports.default = ConfigProvider;
30
+ var react_1 = __importDefault(require("react"));
31
+ // 递归合并函数
32
+ function deepMerge(target, source) {
33
+ var result = __assign({}, target);
34
+ for (var key in source) {
35
+ if (source[key] !== undefined) {
36
+ if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
37
+ result[key] = deepMerge(target[key] || {}, source[key]);
38
+ }
39
+ else {
40
+ result[key] = source[key];
41
+ }
42
+ }
43
+ }
44
+ return result;
45
+ }
46
+ var baseConfig = {
47
+ iconButton: {
48
+ size: 'small',
49
+ render: function (_a) {
50
+ var children = _a.children, params = __rest(_a, ["children"]);
51
+ return children;
52
+ }
53
+ },
54
+ iconFont: {}
55
+ };
56
+ exports.ConfigContext = react_1.default.createContext(baseConfig);
57
+ function ConfigProvider(_a) {
58
+ var children = _a.children, config = _a.config;
59
+ return (react_1.default.createElement(exports.ConfigContext.Provider, { value: deepMerge(baseConfig, config) }, children));
60
+ }
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { IconButtonProps } from "../IconButton";
3
+ import { IconFontProps } from "../IconFont";
4
+ type IconButtonConfig = Pick<IconButtonProps, 'size' | 'className' | 'style'> & {
5
+ render: (props: IconButtonProps & {
6
+ children: React.ReactNode;
7
+ }) => React.ReactNode;
8
+ };
9
+ type IconFontConfig = Pick<IconFontProps, 'className' | 'style'>;
10
+ export interface ConfigContextProps {
11
+ iconButton: IconButtonConfig;
12
+ iconFont: IconFontConfig;
13
+ }
14
+ export type ConfigProviderConfigProps = Partial<ConfigContextProps>;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -22,7 +22,7 @@ interface ButtonTooltipProps {
22
22
  disabled?: boolean;
23
23
  children?: React.ReactNode;
24
24
  }
25
- interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
25
+ export interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
26
26
  /**
27
27
  * 图标
28
28
  */
@@ -14,6 +14,39 @@ var __assign = (this && this.__assign) || function () {
14
14
  };
15
15
  return __assign.apply(this, arguments);
16
16
  };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
17
50
  var __rest = (this && this.__rest) || function (s, e) {
18
51
  var t = {};
19
52
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -30,10 +63,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
63
  };
31
64
  Object.defineProperty(exports, "__esModule", { value: true });
32
65
  exports.IconButton = void 0;
33
- var react_1 = __importDefault(require("react"));
66
+ var react_1 = __importStar(require("react"));
34
67
  var antd_1 = require("antd");
35
68
  var lodash_es_1 = require("lodash-es");
69
+ var classnames_1 = __importDefault(require("classnames"));
36
70
  var IconFont_1 = __importDefault(require("../IconFont"));
71
+ var ConfigProvider_1 = require("../ConfigProvider");
37
72
  var styled_1 = __importDefault(require("@emotion/styled"));
38
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"])));
39
74
  var ButtonTooltip = function (_a) {
@@ -46,7 +81,8 @@ var ButtonTooltip = function (_a) {
46
81
  }
47
82
  };
48
83
  var IconButton = function (props) {
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 ? lodash_es_1.noop : _c, disabled = props.disabled, _d = props.size, size = _d === void 0 ? '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"]);
84
+ 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"]);
50
86
  var createIcon = function () {
51
87
  if ((0, lodash_es_1.isString)(Icon)) {
52
88
  return react_1.default.createElement(IconFont_1.default, { type: Icon });
@@ -55,11 +91,13 @@ var IconButton = function (props) {
55
91
  return Icon;
56
92
  }
57
93
  };
94
+ var IconButtonRender = iconButton.render;
58
95
  if (!Icon) {
59
96
  console.warn('Icon props not found');
60
97
  }
61
- return (react_1.default.createElement(ButtonTooltip, __assign({ tooltipDisabled: tooltipDisabled, hide: hide, disabled: disabled, disabledReason: disabledReason, title: title }, attrs),
62
- react_1.default.createElement(StyledButton, { icon: createIcon(), size: size, className: className, disabled: disabled, style: style, loading: loading, onClick: onClick })));
98
+ return (react_1.default.createElement(IconButtonRender, __assign({}, props),
99
+ 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 }))));
63
101
  };
64
102
  exports.IconButton = IconButton;
65
103
  exports.default = exports.IconButton;
@@ -12,10 +12,16 @@ interface IconFontCommonProps {
12
12
  * 是否使用 symbol 模式
13
13
  */
14
14
  symbol?: boolean;
15
+ [attrs: string]: any;
15
16
  }
16
- declare const IconFont: React.ForwardRefExoticComponent<((IconFontCommonProps & React.HTMLAttributes<HTMLElement> & {
17
+ export type IconFontProps = (IconFontCommonProps & React.SVGProps<SVGSVGElement> & {
18
+ symbol: true;
19
+ }) | (IconFontCommonProps & React.HTMLAttributes<HTMLElement> & {
17
20
  symbol?: false;
18
- }) | Omit<IconFontCommonProps & React.SVGProps<SVGSVGElement> & {
21
+ });
22
+ declare const IconFont: React.ForwardRefExoticComponent<(Omit<IconFontCommonProps & React.SVGProps<SVGSVGElement> & {
19
23
  symbol: true;
24
+ }, "ref"> | Omit<IconFontCommonProps & React.HTMLAttributes<HTMLElement> & {
25
+ symbol?: false;
20
26
  }, "ref">) & React.RefAttributes<HTMLElement | SVGSVGElement>>;
21
27
  export default IconFont;
@@ -54,14 +54,30 @@ var __rest = (this && this.__rest) || function (s, e) {
54
54
  }
55
55
  return t;
56
56
  };
57
+ var __importDefault = (this && this.__importDefault) || function (mod) {
58
+ return (mod && mod.__esModule) ? mod : { "default": mod };
59
+ };
57
60
  Object.defineProperty(exports, "__esModule", { value: true });
58
61
  var react_1 = __importStar(require("react"));
62
+ var classnames_1 = __importDefault(require("classnames"));
63
+ var ConfigProvider_1 = require("../ConfigProvider");
59
64
  var IconFont = (0, react_1.forwardRef)(function (_a, ref) {
60
- var _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.symbol, symbol = _d === void 0 ? false : _d, attrs = __rest(_a, ["type", "className", "symbol"]);
65
+ var _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.symbol, symbol = _d === void 0 ? false : _d, style = _a.style, attrs = __rest(_a, ["type", "className", "symbol", "style"]);
66
+ var iconFont = (0, react_1.useContext)(ConfigProvider_1.ConfigContext).iconFont;
61
67
  if (symbol) {
62
- return (react_1.default.createElement("svg", __assign({ className: "iconfont-symbol ".concat(type, " ").concat(className), "aria-hidden": "true", ref: ref }, attrs),
68
+ return (react_1.default.createElement("svg", __assign({ className: (0, classnames_1.default)([
69
+ 'iconfont-symbol',
70
+ iconFont.className || '',
71
+ type,
72
+ className,
73
+ ]), "aria-hidden": "true", ref: ref, style: __assign(__assign({}, iconFont.style), (style || {})) }, attrs),
63
74
  react_1.default.createElement("use", { xlinkHref: "#".concat(type) })));
64
75
  }
65
- return (react_1.default.createElement("i", __assign({ className: "iconfont ".concat(type, " ").concat(className), ref: ref }, attrs)));
76
+ return (react_1.default.createElement("i", __assign({ className: (0, classnames_1.default)([
77
+ 'iconfont',
78
+ iconFont.className || '',
79
+ type,
80
+ className,
81
+ ]), ref: ref, style: __assign(__assign({}, iconFont.style), (style || {})) }, attrs)));
66
82
  });
67
83
  exports.default = IconFont;
@@ -11,7 +11,9 @@ import type { Result } from 'ahooks/lib/useRequest/src/types';
11
11
  import type { Service } from 'ahooks/lib/useRequest/src/types';
12
12
  import { SwitchProps } from 'antd/es/switch';
13
13
 
14
- export declare function App({ children, ...props }: AppProps): React_2.JSX.Element;
14
+ export declare function App({ children, config, ...props }: AppProps & {
15
+ config?: ConfigProviderConfigProps;
16
+ }): React_2.JSX.Element;
15
17
 
16
18
  declare interface ButtonTooltipProps {
17
19
  /**
@@ -75,10 +77,32 @@ declare interface CheckboxValueProps<T = any, F = any> extends Omit<React_2.Comp
75
77
  children?: React_2.ReactNode;
76
78
  }
77
79
 
80
+ export declare const ConfigContext: React_2.Context<ConfigContextProps>;
81
+
82
+ declare interface ConfigContextProps {
83
+ iconButton: IconButtonConfig;
84
+ iconFont: IconFontConfig;
85
+ }
86
+
87
+ export declare function ConfigProvider({ children, config }: ConfigProviderProps): React_2.JSX.Element;
88
+
89
+ declare type ConfigProviderConfigProps = Partial<ConfigContextProps>;
90
+
91
+ declare interface ConfigProviderProps {
92
+ children: React_2.ReactNode;
93
+ config: ConfigProviderConfigProps;
94
+ }
95
+
78
96
  export declare function GlobalLoading(): React_2.JSX.Element;
79
97
 
80
98
  export declare const IconButton: (props: IconButtonProps) => React_2.JSX.Element;
81
99
 
100
+ declare type IconButtonConfig = Pick<IconButtonProps, 'size' | 'className' | 'style'> & {
101
+ render: (props: IconButtonProps & {
102
+ children: React_2.ReactNode;
103
+ }) => React_2.ReactNode;
104
+ };
105
+
82
106
  declare interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
83
107
  /**
84
108
  * 图标
@@ -110,10 +134,10 @@ declare interface IconButtonProps extends Omit<ButtonTooltipProps, 'children'> {
110
134
  [key: string]: any;
111
135
  }
112
136
 
113
- export declare const IconFont: React_2.ForwardRefExoticComponent<((IconFontCommonProps & React_2.HTMLAttributes<HTMLElement> & {
114
- symbol?: false;
115
- }) | Omit<IconFontCommonProps & React_2.SVGProps<SVGSVGElement> & {
137
+ export declare const IconFont: React_2.ForwardRefExoticComponent<(Omit<IconFontCommonProps & React_2.SVGProps<SVGSVGElement> & {
116
138
  symbol: true;
139
+ }, "ref"> | Omit<IconFontCommonProps & React_2.HTMLAttributes<HTMLElement> & {
140
+ symbol?: false;
117
141
  }, "ref">) & React_2.RefAttributes<HTMLElement | SVGSVGElement>>;
118
142
 
119
143
  declare interface IconFontCommonProps {
@@ -129,8 +153,17 @@ declare interface IconFontCommonProps {
129
153
  * 是否使用 symbol 模式
130
154
  */
131
155
  symbol?: boolean;
156
+ [attrs: string]: any;
132
157
  }
133
158
 
159
+ declare type IconFontConfig = Pick<IconFontProps, 'className' | 'style'>;
160
+
161
+ declare type IconFontProps = (IconFontCommonProps & React_2.SVGProps<SVGSVGElement> & {
162
+ symbol: true;
163
+ }) | (IconFontCommonProps & React_2.HTMLAttributes<HTMLElement> & {
164
+ symbol?: false;
165
+ });
166
+
134
167
  export declare let message: MessageInstance;
135
168
 
136
169
  export declare let modal: Omit<ModalStaticFunctions, 'warn'>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useRequest = exports.setGlobalLoading = exports.GlobalLoading = exports.IconButton = exports.SwitchValue = exports.CheckboxValue = exports.IconFont = exports.modal = exports.notification = exports.message = exports.App = void 0;
6
+ exports.useRequest = exports.ConfigContext = exports.ConfigProvider = exports.setGlobalLoading = exports.GlobalLoading = exports.IconButton = exports.SwitchValue = exports.CheckboxValue = exports.IconFont = exports.modal = exports.notification = exports.message = exports.App = void 0;
7
7
  var AntdApp_1 = require("./components/AntdApp");
8
8
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return __importDefault(AntdApp_1).default; } });
9
9
  Object.defineProperty(exports, "message", { enumerable: true, get: function () { return AntdApp_1.message; } });
@@ -20,5 +20,8 @@ Object.defineProperty(exports, "IconButton", { enumerable: true, get: function (
20
20
  var GlobalLoading_1 = require("./components/GlobalLoading");
21
21
  Object.defineProperty(exports, "GlobalLoading", { enumerable: true, get: function () { return __importDefault(GlobalLoading_1).default; } });
22
22
  Object.defineProperty(exports, "setGlobalLoading", { enumerable: true, get: function () { return GlobalLoading_1.setGlobalLoading; } });
23
+ var ConfigProvider_1 = require("./components/ConfigProvider");
24
+ Object.defineProperty(exports, "ConfigProvider", { enumerable: true, get: function () { return __importDefault(ConfigProvider_1).default; } });
25
+ Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return ConfigProvider_1.ConfigContext; } });
23
26
  var useRequest_1 = require("./hooks/useRequest");
24
27
  Object.defineProperty(exports, "useRequest", { enumerable: true, get: function () { return __importDefault(useRequest_1).default; } });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmirror-components",
3
- "version": "1.0.25",
3
+ "version": "1.0.26-alpha.0",
4
4
  "type": "module",
5
5
  "main": "build/lib/index.js",
6
6
  "module": "build/es/index.js",
@@ -19,7 +19,8 @@
19
19
  "lint": "eslint .",
20
20
  "preview": "vite preview",
21
21
  "prepublishOnly": "npm run build",
22
- "publish:npm": "npm publish --access public"
22
+ "publish:npm": "npm publish --access public",
23
+ "publish:dev": "npm publish --access public --tag dev"
23
24
  },
24
25
  "peerDependencies": {
25
26
  "antd": ">=5.0.0",