@akinon/ui-button 1.2.0 → 1.2.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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,gBAAiB,YAAY,sBA0J/C,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
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,gBAAiB,YAAY,sBA2J/C,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -22,14 +22,14 @@ const Button = (buttonProps) => {
22
22
  const { getPrefixCls, theme } = react_1.default.useContext(antd_1.ConfigProvider.ConfigContext);
23
23
  const { token, hashId } = (0, ui_theme_1.useToken)();
24
24
  const buttonToken = token.Button;
25
- const customTokens = theme.CustomTokens || {};
25
+ const customTokens = (0, ui_theme_1.getSafeCustomTokens)(theme);
26
26
  const useStyle = (0, cssinjs_1.useStyleRegister)({
27
27
  token: token,
28
28
  path: ['Button'],
29
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
30
  theme: theme
31
31
  }, () => {
32
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
33
33
  const prefixCls = `:where(.${hashId}).${getPrefixCls()}-btn`;
34
34
  const iconPrefixCls = `.${getPrefixCls()}-btn`;
35
35
  // MARK: - Disabled
@@ -62,7 +62,7 @@ const Button = (buttonProps) => {
62
62
  borderColor: customTokens.others.colorTransparent,
63
63
  '&:hover': {
64
64
  backgroundColor: buttonToken.defaultBgSmHover,
65
- borderColor: customTokens.others.colorTransparent,
65
+ borderColor: (_d = (_c = customTokens.others) === null || _c === void 0 ? void 0 : _c.colorTransparent) !== null && _d !== void 0 ? _d : 'transparent',
66
66
  color: buttonToken.colorTextHover
67
67
  },
68
68
  [`&${prefixCls}-dangerous`]: {
@@ -79,14 +79,14 @@ const Button = (buttonProps) => {
79
79
  },
80
80
  // END: Default SM
81
81
  // MARK: - Success
82
- [`${prefixCls}-success`]: Object.assign({ backgroundColor: (_c = buttonToken.colorSuccessBg) !== null && _c !== void 0 ? _c : token.colorSuccessBg, '&:hover:not(:disabled)': {
83
- backgroundColor: (_d = buttonToken.colorSuccessHover) !== null && _d !== void 0 ? _d : token.colorSuccessHover
82
+ [`${prefixCls}-success`]: Object.assign({ backgroundColor: (_e = buttonToken.colorSuccessBg) !== null && _e !== void 0 ? _e : token.colorSuccessBg, '&:hover:not(:disabled)': {
83
+ backgroundColor: (_f = buttonToken.colorSuccessHover) !== null && _f !== void 0 ? _f : token.colorSuccessHover
84
84
  } }, disabledStyles),
85
85
  // END: Success
86
86
  // MARK: - Warning
87
- [`${prefixCls}-warning`]: Object.assign({ backgroundColor: (_e = buttonToken.colorWarningBg) !== null && _e !== void 0 ? _e : token.colorWarningBg, color: (_f = buttonToken.colorWarningText) !== null && _f !== void 0 ? _f : token.colorWarningText, '&:hover:not(:disabled)': {
88
- backgroundColor: (_g = buttonToken.colorWarningHover) !== null && _g !== void 0 ? _g : token.colorWarningHover,
89
- borderColor: (_h = buttonToken.colorWarningBorder) !== null && _h !== void 0 ? _h : token.colorWarningBorder
87
+ [`${prefixCls}-warning`]: Object.assign({ backgroundColor: (_g = buttonToken.colorWarningBg) !== null && _g !== void 0 ? _g : token.colorWarningBg, color: (_h = buttonToken.colorWarningText) !== null && _h !== void 0 ? _h : token.colorWarningText, '&:hover:not(:disabled)': {
88
+ backgroundColor: (_j = buttonToken.colorWarningHover) !== null && _j !== void 0 ? _j : token.colorWarningHover,
89
+ borderColor: (_k = buttonToken.colorWarningBorder) !== null && _k !== void 0 ? _k : token.colorWarningBorder
90
90
  } }, disabledStyles),
91
91
  // END: Warning
92
92
  // MARK: Icon
@@ -94,10 +94,10 @@ const Button = (buttonProps) => {
94
94
  ['> *']: {
95
95
  backgroundColor: customTokens.others.colorTransparent,
96
96
  // Since this button is transparent, we are using success bg color for the icon.
97
- color: (_j = buttonToken.colorSuccessBg) !== null && _j !== void 0 ? _j : token.colorSuccessBg,
97
+ color: (_l = buttonToken.colorSuccessBg) !== null && _l !== void 0 ? _l : token.colorSuccessBg,
98
98
  verticalAlign: customTokens.others.verticalAlignMiddle,
99
99
  '&:hover:not(:disabled)': {
100
- color: (_k = buttonToken.colorSuccessBg) !== null && _k !== void 0 ? _k : token.colorSuccessBg
100
+ color: (_m = buttonToken.colorSuccessBg) !== null && _m !== void 0 ? _m : token.colorSuccessBg
101
101
  },
102
102
  '&:active': {
103
103
  boxShadow: customTokens.layout.displayNone
@@ -109,7 +109,7 @@ const Button = (buttonProps) => {
109
109
  [`&${iconPrefixCls}-dangerous > *`]: {
110
110
  color: 'red',
111
111
  '&:hover:not(:disabled)': {
112
- color: (_l = buttonToken.colorErrorHover) !== null && _l !== void 0 ? _l : token.colorErrorHover
112
+ color: (_o = buttonToken.colorErrorHover) !== null && _o !== void 0 ? _o : token.colorErrorHover
113
113
  }
114
114
  }
115
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,gBAAiB,YAAY,sBA0J/C,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
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,gBAAiB,YAAY,sBA2J/C,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Icon } from '@akinon/icons';
2
- import { useToken } from '@akinon/ui-theme';
2
+ import { getSafeCustomTokens, useToken } from '@akinon/ui-theme';
3
3
  import { Tooltip } from '@akinon/ui-tooltip';
4
4
  import { useStyleRegister } from '@ant-design/cssinjs';
5
5
  import { Button as AntButton, ConfigProvider } from 'antd';
@@ -19,14 +19,14 @@ export const Button = (buttonProps) => {
19
19
  const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
20
20
  const { token, hashId } = useToken();
21
21
  const buttonToken = token.Button;
22
- const customTokens = theme.CustomTokens || {};
22
+ const customTokens = getSafeCustomTokens(theme);
23
23
  const useStyle = useStyleRegister({
24
24
  token: token,
25
25
  path: ['Button'],
26
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
27
  theme: theme
28
28
  }, () => {
29
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
29
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
30
30
  const prefixCls = `:where(.${hashId}).${getPrefixCls()}-btn`;
31
31
  const iconPrefixCls = `.${getPrefixCls()}-btn`;
32
32
  // MARK: - Disabled
@@ -59,7 +59,7 @@ export const Button = (buttonProps) => {
59
59
  borderColor: customTokens.others.colorTransparent,
60
60
  '&:hover': {
61
61
  backgroundColor: buttonToken.defaultBgSmHover,
62
- borderColor: customTokens.others.colorTransparent,
62
+ borderColor: (_d = (_c = customTokens.others) === null || _c === void 0 ? void 0 : _c.colorTransparent) !== null && _d !== void 0 ? _d : 'transparent',
63
63
  color: buttonToken.colorTextHover
64
64
  },
65
65
  [`&${prefixCls}-dangerous`]: {
@@ -76,14 +76,14 @@ export const Button = (buttonProps) => {
76
76
  },
77
77
  // END: Default SM
78
78
  // MARK: - Success
79
- [`${prefixCls}-success`]: Object.assign({ backgroundColor: (_c = buttonToken.colorSuccessBg) !== null && _c !== void 0 ? _c : token.colorSuccessBg, '&:hover:not(:disabled)': {
80
- backgroundColor: (_d = buttonToken.colorSuccessHover) !== null && _d !== void 0 ? _d : token.colorSuccessHover
79
+ [`${prefixCls}-success`]: Object.assign({ backgroundColor: (_e = buttonToken.colorSuccessBg) !== null && _e !== void 0 ? _e : token.colorSuccessBg, '&:hover:not(:disabled)': {
80
+ backgroundColor: (_f = buttonToken.colorSuccessHover) !== null && _f !== void 0 ? _f : token.colorSuccessHover
81
81
  } }, disabledStyles),
82
82
  // END: Success
83
83
  // MARK: - Warning
84
- [`${prefixCls}-warning`]: Object.assign({ backgroundColor: (_e = buttonToken.colorWarningBg) !== null && _e !== void 0 ? _e : token.colorWarningBg, color: (_f = buttonToken.colorWarningText) !== null && _f !== void 0 ? _f : token.colorWarningText, '&:hover:not(:disabled)': {
85
- backgroundColor: (_g = buttonToken.colorWarningHover) !== null && _g !== void 0 ? _g : token.colorWarningHover,
86
- borderColor: (_h = buttonToken.colorWarningBorder) !== null && _h !== void 0 ? _h : token.colorWarningBorder
84
+ [`${prefixCls}-warning`]: Object.assign({ backgroundColor: (_g = buttonToken.colorWarningBg) !== null && _g !== void 0 ? _g : token.colorWarningBg, color: (_h = buttonToken.colorWarningText) !== null && _h !== void 0 ? _h : token.colorWarningText, '&:hover:not(:disabled)': {
85
+ backgroundColor: (_j = buttonToken.colorWarningHover) !== null && _j !== void 0 ? _j : token.colorWarningHover,
86
+ borderColor: (_k = buttonToken.colorWarningBorder) !== null && _k !== void 0 ? _k : token.colorWarningBorder
87
87
  } }, disabledStyles),
88
88
  // END: Warning
89
89
  // MARK: Icon
@@ -91,10 +91,10 @@ export const Button = (buttonProps) => {
91
91
  ['> *']: {
92
92
  backgroundColor: customTokens.others.colorTransparent,
93
93
  // Since this button is transparent, we are using success bg color for the icon.
94
- color: (_j = buttonToken.colorSuccessBg) !== null && _j !== void 0 ? _j : token.colorSuccessBg,
94
+ color: (_l = buttonToken.colorSuccessBg) !== null && _l !== void 0 ? _l : token.colorSuccessBg,
95
95
  verticalAlign: customTokens.others.verticalAlignMiddle,
96
96
  '&:hover:not(:disabled)': {
97
- color: (_k = buttonToken.colorSuccessBg) !== null && _k !== void 0 ? _k : token.colorSuccessBg
97
+ color: (_m = buttonToken.colorSuccessBg) !== null && _m !== void 0 ? _m : token.colorSuccessBg
98
98
  },
99
99
  '&:active': {
100
100
  boxShadow: customTokens.layout.displayNone
@@ -106,7 +106,7 @@ export const Button = (buttonProps) => {
106
106
  [`&${iconPrefixCls}-dangerous > *`]: {
107
107
  color: 'red',
108
108
  '&:hover:not(:disabled)': {
109
- color: (_l = buttonToken.colorErrorHover) !== null && _l !== void 0 ? _l : token.colorErrorHover
109
+ color: (_o = buttonToken.colorErrorHover) !== null && _o !== void 0 ? _o : token.colorErrorHover
110
110
  }
111
111
  }
112
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-button",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "private": false,
5
5
  "description": "A basic button react component.",
6
6
  "type": "module",
@@ -11,9 +11,9 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "antd": "5.22.6",
14
- "@akinon/ui-theme": "1.0.1",
15
14
  "@akinon/icons": "1.0.1",
16
- "@akinon/ui-tooltip": "1.2.0"
15
+ "@akinon/ui-tooltip": "1.2.1",
16
+ "@akinon/ui-theme": "1.0.2"
17
17
  },
18
18
  "devDependencies": {
19
19
  "clean-package": "2.2.0",