@oceanbase/design 1.0.0-alpha.3 → 1.0.0-alpha.5

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 (74) hide show
  1. package/dist/design.min.js +1 -1
  2. package/es/alert/index.d.ts +2 -2
  3. package/es/alert/index.js +16 -4
  4. package/es/alert/style/index.js +155 -60
  5. package/es/badge/index.js +2 -3
  6. package/es/badge/style/index.js +1 -3
  7. package/es/card/index.d.ts +4 -0
  8. package/es/card/index.js +64 -7
  9. package/es/card/style/index.js +36 -10
  10. package/es/checkbox/style/index.js +4 -2
  11. package/es/config-provider/index.d.ts +2 -2
  12. package/es/config-provider/index.js +26 -2
  13. package/es/descriptions/hooks/useItems.d.ts +6 -6
  14. package/es/descriptions/style/index.js +3 -2
  15. package/es/drawer/style/index.js +28 -8
  16. package/es/empty/style/index.js +6 -4
  17. package/es/form/FormItem.d.ts +1 -0
  18. package/es/form/FormItem.js +14 -4
  19. package/es/form/style/index.js +15 -3
  20. package/es/input-number/index.d.ts +2 -1
  21. package/es/locale/ja-JP.d.ts +3 -0
  22. package/es/locale/ja-JP.js +28 -0
  23. package/es/modal/Modal.js +20 -6
  24. package/es/modal/style/index.js +64 -20
  25. package/es/radio/style/index.js +4 -2
  26. package/es/slider/style/index.js +7 -5
  27. package/es/spin/style/index.js +14 -11
  28. package/es/static-function/index.js +13 -4
  29. package/es/table/style/index.js +19 -19
  30. package/es/tabs/style/index.js +4 -2
  31. package/es/tag/index.d.ts +1 -0
  32. package/es/tag/index.js +3 -2
  33. package/es/tag/style/index.js +8 -2
  34. package/es/theme/default.js +9 -3
  35. package/es/theme/style/compact.less +7 -7
  36. package/es/theme/style/default.less +7 -7
  37. package/es/typography/style/index.js +25 -20
  38. package/lib/alert/index.d.ts +2 -2
  39. package/lib/alert/index.js +13 -3
  40. package/lib/alert/style/index.js +171 -72
  41. package/lib/badge/index.js +2 -2
  42. package/lib/badge/style/index.js +1 -3
  43. package/lib/card/index.d.ts +4 -0
  44. package/lib/card/index.js +61 -4
  45. package/lib/card/style/index.js +58 -11
  46. package/lib/checkbox/style/index.js +3 -2
  47. package/lib/config-provider/index.d.ts +2 -2
  48. package/lib/config-provider/index.js +35 -2
  49. package/lib/descriptions/hooks/useItems.d.ts +6 -6
  50. package/lib/descriptions/style/index.js +2 -2
  51. package/lib/drawer/style/index.js +28 -6
  52. package/lib/empty/style/index.js +5 -4
  53. package/lib/form/FormItem.d.ts +1 -0
  54. package/lib/form/FormItem.js +10 -2
  55. package/lib/form/style/index.js +20 -1
  56. package/lib/input-number/index.d.ts +2 -1
  57. package/lib/locale/ja-JP.d.ts +3 -0
  58. package/lib/locale/ja-JP.js +60 -0
  59. package/lib/modal/Modal.js +26 -6
  60. package/lib/modal/style/index.js +78 -18
  61. package/lib/radio/style/index.js +3 -2
  62. package/lib/slider/style/index.js +6 -5
  63. package/lib/spin/style/index.js +12 -11
  64. package/lib/static-function/index.js +7 -1
  65. package/lib/table/style/index.js +19 -19
  66. package/lib/tabs/style/index.js +5 -0
  67. package/lib/tag/index.d.ts +1 -0
  68. package/lib/tag/index.js +3 -1
  69. package/lib/tag/style/index.js +8 -0
  70. package/lib/theme/default.js +9 -3
  71. package/lib/theme/style/compact.less +7 -7
  72. package/lib/theme/style/default.less +7 -7
  73. package/lib/typography/style/index.js +24 -20
  74. package/package.json +5 -6
@@ -3,10 +3,10 @@ import type { AlertProps as AntAlertProps } from 'antd/es/alert';
3
3
  export * from 'antd/es/alert';
4
4
  export interface AlertProps extends AntAlertProps {
5
5
  ghost?: boolean;
6
- colored?: boolean;
6
+ mini?: boolean;
7
7
  }
8
8
  declare const Alert: {
9
- ({ type, ghost, colored, prefixCls: customizePrefixCls, className, ...restProps }: AlertProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
9
+ ({ type: typeProp, showIcon, closable, ghost, mini, banner, prefixCls: customizePrefixCls, className, ...restProps }: AlertProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
10
10
  ErrorBoundary: typeof import("antd/es/alert/ErrorBoundary").default;
11
11
  displayName: string;
12
12
  };
package/es/alert/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["type", "ghost", "colored", "prefixCls", "className"];
2
+ var _excluded = ["type", "showIcon", "closable", "ghost", "mini", "banner", "prefixCls", "className"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -13,6 +13,7 @@ import { CheckCircleOutlined, CloseCircleOutlined, ExclamationCircleOutlined, In
13
13
  import classNames from 'classnames';
14
14
  import ConfigProvider from "../config-provider";
15
15
  import useStyle from "./style";
16
+ import theme from "../theme";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  export * from 'antd/es/alert';
18
19
  var iconMapOutlined = {
@@ -22,20 +23,31 @@ var iconMapOutlined = {
22
23
  warning: /*#__PURE__*/_jsx(ExclamationCircleOutlined, {})
23
24
  };
24
25
  var Alert = function Alert(_ref) {
25
- var type = _ref.type,
26
+ var typeProp = _ref.type,
27
+ _ref$showIcon = _ref.showIcon,
28
+ showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
29
+ closable = _ref.closable,
26
30
  ghost = _ref.ghost,
27
- colored = _ref.colored,
31
+ mini = _ref.mini,
32
+ banner = _ref.banner,
28
33
  customizePrefixCls = _ref.prefixCls,
29
34
  className = _ref.className,
30
35
  restProps = _objectWithoutProperties(_ref, _excluded);
36
+ var _theme$useToken = theme.useToken(),
37
+ token = _theme$useToken.token;
38
+ // banner exists and type is empty, use warning type by default for correct icon
39
+ var type = banner && !typeProp ? 'warning' : typeProp;
31
40
  var _useContext = useContext(ConfigProvider.ConfigContext),
32
41
  getPrefixCls = _useContext.getPrefixCls;
33
42
  var prefixCls = getPrefixCls('alert', customizePrefixCls);
34
43
  var _useStyle = useStyle(prefixCls),
35
44
  wrapSSR = _useStyle.wrapSSR;
36
- var alertCls = classNames(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-ghost"), ghost), "".concat(prefixCls, "-colored"), colored), className);
45
+ var alertCls = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-closable"), closable), "".concat(prefixCls, "-ghost"), ghost), "".concat(prefixCls, "-mini"), mini), className);
37
46
  return wrapSSR( /*#__PURE__*/_jsx(AntAlert, _objectSpread({
38
47
  type: type,
48
+ showIcon: showIcon,
49
+ closable: closable,
50
+ banner: banner,
39
51
  icon: iconMapOutlined[type],
40
52
  prefixCls: customizePrefixCls,
41
53
  className: alertCls
@@ -3,91 +3,186 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  import { genComponentStyleHook } from "../../_util/genComponentStyleHook";
6
- var genTypeStyle = function genTypeStyle(color, token) {
7
- // 左侧颜色条宽度设置为 8px,但还需要绕 Y 轴旋转 60deg,因此最后的投影宽度实际为 4px
8
- var borderWidth = 8;
9
- return {
10
- content: '""',
11
- width: borderWidth,
12
- // Y 轴旋转 60deg 是为了让圆角有一定的视觉拉伸,以与原先的边框贴合更加紧密
13
- transform: 'rotateY(60deg)',
14
- backgroundColor: color,
15
- position: 'absolute',
16
- height: "calc(100% - ".concat(token.lineWidth, "px)"),
17
- left: -token.lineWidth - borderWidth / 2 / 2,
18
- top: token.lineWidth / 2,
19
- borderTopLeftRadius: token.borderRadiusLG,
20
- borderBottomLeftRadius: token.borderRadiusLG
6
+ import { upperFirst } from 'lodash';
7
+ var genAlertTypeStyle = function genAlertTypeStyle(type, token) {
8
+ var componentCls = token.componentCls;
9
+ var textColor = token["color".concat(upperFirst(type), "Text")];
10
+ var hoverColor = token["color".concat(upperFirst(type), "TextHover")];
11
+ var activeColor = token["color".concat(upperFirst(type), "TextActive")];
12
+ var linkStyle = {
13
+ color: textColor,
14
+ textDecoration: 'underline',
15
+ '&:hover': {
16
+ color: hoverColor
17
+ },
18
+ '&:active': {
19
+ color: activeColor
20
+ }
21
21
  };
22
- };
23
- var genColoredStyle = function genColoredStyle(color, colorHover, token) {
24
- var componentCls = token.componentCls,
25
- iconCls = token.iconCls;
26
22
  return _defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls, "-message"), {
27
- color: color
23
+ color: textColor,
24
+ a: linkStyle
28
25
  }), "".concat(componentCls, "-description"), {
29
- color: color
30
- }), "".concat(componentCls, "-close-icon"), _defineProperty(_defineProperty({}, "".concat(iconCls), {
31
- color: color,
32
- '&:hover': {
33
- color: colorHover
34
- }
35
- }), "".concat(componentCls, "-close-text"), {
36
- color: color,
37
- '&:hover': {
38
- color: colorHover
39
- }
40
- }));
26
+ a: linkStyle
27
+ }), "".concat(componentCls, "-icon"), {
28
+ color: textColor
29
+ });
41
30
  };
42
31
  export var genAlertStyle = function genAlertStyle(token) {
43
32
  var componentCls = token.componentCls,
44
- colorSuccess = token.colorSuccess,
45
- colorSuccessHover = token.colorSuccessHover,
46
- colorInfo = token.colorInfo,
47
- colorInfoHover = token.colorInfoHover,
48
- colorWarning = token.colorWarning,
49
- colorWarningHover = token.colorWarningHover,
50
- colorError = token.colorError,
51
- colorErrorHover = token.colorErrorHover,
52
33
  colorIcon = token.colorIcon,
53
34
  colorIconHover = token.colorIconHover,
54
- motionDurationMid = token.motionDurationMid;
35
+ motionDurationMid = token.motionDurationMid,
36
+ calc = token.calc;
55
37
  // height = fontSize * lineHeight
56
- var height = token.fontSize * token.lineHeight;
57
- return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls), _defineProperty(_defineProperty({
38
+ var height = calc(token.fontSize).mul(token.lineHeight).equal();
39
+ // icon width = fontSizeLG (icon size)
40
+ var iconWidth = token.fontSizeLG;
41
+ // content and action start position = icon width + icon margin
42
+ var contentStartOffset = calc(iconWidth).add(token.marginXS).equal();
43
+ // close icon width (approximate)
44
+ var closeIconWidth = height;
45
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
58
46
  // vertical align to flex-start
59
47
  alignItems: 'flex-start !important',
60
- paddingRight: token.padding
48
+ paddingInline: token.padding,
49
+ position: 'relative'
61
50
  }, "".concat(componentCls, "-icon"), {
62
- height: height
51
+ height: height,
52
+ fontSize: token.fontSizeLG,
53
+ marginInlineEnd: token.marginXS,
54
+ flexShrink: 0
63
55
  }), "".concat(componentCls, "-close-icon"), {
56
+ position: 'absolute',
57
+ top: token.paddingXS,
58
+ insetInlineEnd: token.padding,
64
59
  height: height,
65
60
  color: colorIcon,
66
61
  transition: "color ".concat(motionDurationMid),
62
+ flexShrink: 0,
63
+ display: 'flex',
64
+ alignItems: 'center',
67
65
  '&:hover': {
68
66
  color: colorIconHover
69
67
  }
70
- })), "".concat(componentCls, ":not(").concat(componentCls, "-with-description)"), {
71
- paddingLeft: token.padding
72
- }), "".concat(componentCls).concat(componentCls, "-with-description"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({
73
- paddingBlock: token.padding
68
+ }), "".concat(componentCls, "-message"), {
69
+ a: {
70
+ textDecoration: 'underline'
71
+ }
72
+ }), "".concat(componentCls, "-description"), {
73
+ a: {
74
+ textDecoration: 'underline'
75
+ }
76
+ }), "&".concat(componentCls, "-success"), genAlertTypeStyle('success', token)), "&".concat(componentCls, "-info"), genAlertTypeStyle('info', token)), "&".concat(componentCls, "-warning"), genAlertTypeStyle('warning', token)), "&".concat(componentCls, "-error"), genAlertTypeStyle('error', token))), "".concat(componentCls, ":not(").concat(componentCls, "-with-description)"), _defineProperty(_defineProperty({
77
+ flexWrap: 'wrap'
78
+ }, "".concat(componentCls, "-content"), {
79
+ flex: "1 1 ".concat(calc('100%').sub(contentStartOffset).sub(closeIconWidth).sub(token.padding).equal()),
80
+ minWidth: 0,
81
+ maxWidth: calc('100%').sub(contentStartOffset).sub(closeIconWidth).sub(token.padding).equal(),
82
+ wordBreak: 'break-word'
83
+ }), "".concat(componentCls, "-action"), {
84
+ width: calc('100%').sub(contentStartOffset).sub(token.padding).equal(),
85
+ marginInlineStart: contentStartOffset,
86
+ marginTop: token.marginXS
87
+ })), "".concat(componentCls).concat(componentCls, "-with-description"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
88
+ paddingBlock: token.paddingSM,
89
+ flexWrap: 'wrap'
74
90
  }, "".concat(componentCls, "-message"), {
75
- fontWeight: 500,
76
- marginBottom: token.marginXXS
91
+ fontSize: token.fontSize,
92
+ fontWeight: token.fontWeightStrong,
93
+ marginBottom: token.marginXXS,
94
+ wordBreak: 'break-word'
77
95
  }), "".concat(componentCls, "-description"), {
78
- color: token.colorTextSecondary
79
- }), "".concat(componentCls, "-icon"), {
80
- fontSize: token.fontSizeHeading4,
81
- height: token.fontSizeHeading3,
82
- marginInlineEnd: token.margin
96
+ wordBreak: 'break-word'
97
+ }), "".concat(componentCls, "-content"), {
98
+ flex: "1 1 ".concat(calc('100%').sub(contentStartOffset).sub(closeIconWidth).sub(token.padding).equal()),
99
+ minWidth: 0,
100
+ maxWidth: calc('100%').sub(contentStartOffset).sub(closeIconWidth).sub(token.padding).equal(),
101
+ wordBreak: 'break-word'
83
102
  }), "".concat(componentCls, "-action"), {
84
- marginInlineStart: token.marginXS
85
- })), "".concat(componentCls, ":not(").concat(componentCls, "-banner):not(").concat(componentCls, "-ghost)"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "&".concat(componentCls, "-success::before"), genTypeStyle(colorSuccess, token)), "&".concat(componentCls, "-info::before"), genTypeStyle(colorInfo, token)), "&".concat(componentCls, "-warning::before"), genTypeStyle(colorWarning, token)), "&".concat(componentCls, "-error::before"), genTypeStyle(colorError, token))), "".concat(componentCls).concat(componentCls, "-ghost"), {
103
+ width: calc('100%').sub(contentStartOffset).sub(token.padding).equal(),
104
+ marginInlineStart: contentStartOffset,
105
+ marginTop: token.marginSM
106
+ }), "".concat(componentCls, "-close-icon"), {
107
+ top: token.paddingSM
108
+ })), "".concat(componentCls).concat(componentCls, "-ghost"), {
86
109
  backgroundColor: 'transparent',
87
110
  border: 'none',
88
- padding: 0,
111
+ padding: '0px !important',
89
112
  borderRadius: 0
90
- }), "".concat(componentCls, "-colored"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "&".concat(componentCls, "-success"), genColoredStyle(colorSuccess, colorSuccessHover, token)), "&".concat(componentCls, "-info"), genColoredStyle(colorInfo, colorInfoHover, token)), "&".concat(componentCls, "-warning"), genColoredStyle(colorWarning, colorWarningHover, token)), "&".concat(componentCls, "-error"), genColoredStyle(colorError, colorErrorHover, token)));
113
+ }), "".concat(componentCls).concat(componentCls, "-mini"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
114
+ paddingBlock: token.paddingXXS,
115
+ paddingInline: token.paddingXS,
116
+ border: 'none',
117
+ width: 'fit-content',
118
+ display: 'inline-flex',
119
+ alignItems: 'center',
120
+ flexWrap: 'nowrap'
121
+ }, "".concat(componentCls, "-icon"), {
122
+ marginInlineEnd: token.paddingXS,
123
+ flexShrink: 0,
124
+ display: 'flex',
125
+ alignItems: 'center',
126
+ justifyContent: 'center',
127
+ lineHeight: 1
128
+ }), "".concat(componentCls, "-message"), {
129
+ whiteSpace: 'nowrap',
130
+ wordBreak: 'normal',
131
+ overflow: 'visible',
132
+ lineHeight: token.lineHeight,
133
+ display: 'flex',
134
+ alignItems: 'center'
135
+ }), "".concat(componentCls, "-content"), {
136
+ display: 'flex',
137
+ alignItems: 'center',
138
+ flex: '0 1 auto',
139
+ whiteSpace: 'nowrap',
140
+ minWidth: 0,
141
+ lineHeight: token.lineHeight
142
+ }), "".concat(componentCls, "-close-icon"), {
143
+ position: 'relative',
144
+ top: token.paddingXXS,
145
+ insetInlineEnd: 'auto',
146
+ height: 'auto',
147
+ flexShrink: 0,
148
+ marginInlineStart: 0
149
+ }), "&".concat(componentCls, "-closable"), _defineProperty({}, "".concat(componentCls, "-content"), {
150
+ paddingInlineEnd: token.paddingXS
151
+ })), "&:not(".concat(componentCls, "-with-description)"), _defineProperty({
152
+ flexWrap: 'nowrap'
153
+ }, "".concat(componentCls, "-content"), {
154
+ flex: '0 1 auto',
155
+ minWidth: 0,
156
+ maxWidth: 'none',
157
+ wordBreak: 'normal'
158
+ })), "&".concat(componentCls, "-with-description"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
159
+ paddingBlock: token.paddingXXS,
160
+ flexDirection: 'row',
161
+ alignItems: 'flex-start',
162
+ position: 'relative',
163
+ flexWrap: 'nowrap'
164
+ }, "".concat(componentCls, "-icon"), {
165
+ alignSelf: 'flex-start',
166
+ marginTop: 0
167
+ }), "".concat(componentCls, "-content"), {
168
+ flexDirection: 'column',
169
+ alignItems: 'flex-start',
170
+ flex: '0 1 auto',
171
+ minWidth: 0,
172
+ maxWidth: 'none',
173
+ wordBreak: 'normal'
174
+ }), "".concat(componentCls, "-message"), {
175
+ marginBottom: token.marginXXS,
176
+ whiteSpace: 'nowrap',
177
+ wordBreak: 'normal'
178
+ }), "".concat(componentCls, "-description"), {
179
+ whiteSpace: 'nowrap',
180
+ wordBreak: 'normal'
181
+ }), "".concat(componentCls, "-close-icon"), {
182
+ position: 'absolute',
183
+ top: token.paddingXXS,
184
+ insetInlineEnd: token.paddingXS
185
+ })));
91
186
  };
92
187
  export default (function (prefixCls) {
93
188
  var useStyle = genComponentStyleHook('Alert', function (token) {
package/es/badge/index.js CHANGED
@@ -25,8 +25,7 @@ var Badge = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
25
25
  icon = _ref.icon,
26
26
  restProps = _objectWithoutProperties(_ref, _excluded);
27
27
  var _useContext = useContext(ConfigProvider.ConfigContext),
28
- getPrefixCls = _useContext.getPrefixCls,
29
- iconPrefixCls = _useContext.iconPrefixCls;
28
+ getPrefixCls = _useContext.getPrefixCls;
30
29
  var prefixCls = getPrefixCls('badge', customizePrefixCls);
31
30
  var _useStyle = useStyle(prefixCls),
32
31
  wrapSSR = _useStyle.wrapSSR,
@@ -39,7 +38,7 @@ var Badge = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
38
  style: {
40
39
  display: 'inline-block'
41
40
  },
42
- className: "".concat(iconPrefixCls, "-spin")
41
+ spin: true
43
42
  }),
44
43
  success: /*#__PURE__*/_jsx(CheckCircleFilled, {}),
45
44
  error: /*#__PURE__*/_jsx(CloseCircleFilled, {}),
@@ -9,9 +9,7 @@ export var genBadgeStyle = function genBadgeStyle(token) {
9
9
  // make status text inherit parent style
10
10
  color: 'inherit',
11
11
  fontSize: 'inherit'
12
- }), "".concat(componentCls).concat(componentCls, "-status"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls, "-status-dot"), _defineProperty({}, "&".concat(componentCls, "-status-default"), {
13
- backgroundColor: token.colorFill
14
- })), "".concat(componentCls, "-status-icon"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
12
+ }), "".concat(componentCls).concat(componentCls, "-status"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls, "-status-dot"), _defineProperty({}, "&".concat(componentCls, "-status-default"), {})), "".concat(componentCls, "-status-icon"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
15
13
  // remove dot style
16
14
  backgroundColor: 'transparent'
17
15
  }, '&::after', {
@@ -8,6 +8,10 @@ export interface CardTabListType extends AntCardTabListType {
8
8
  export interface CardProps extends AntCardProps {
9
9
  divided?: boolean;
10
10
  tabList?: CardTabListType[];
11
+ collapsible?: boolean;
12
+ defaultCollapsed?: boolean;
13
+ collapsed?: boolean;
14
+ onCollapse?: (collapsed: boolean) => void;
11
15
  }
12
16
  declare const _default: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>> & {
13
17
  Grid: React.FC<import("antd/es/card").CardGridProps>;
package/es/card/index.js CHANGED
@@ -1,18 +1,26 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["children", "size", "title", "tabList", "tabProps", "divided", "prefixCls", "bodyStyle", "styles", "className"];
2
+ var _excluded = ["children", "size", "title", "tabList", "tabProps", "divided", "prefixCls", "bodyStyle", "styles", "className", "collapsible", "defaultCollapsed", "collapsed", "onCollapse", "extra"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
15
  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; }
10
16
  import { isNullValue } from '@oceanbase/util';
11
17
  import { Card as AntCard, Space, Tag } from 'antd';
12
18
  import classNames from 'classnames';
13
- import React, { useContext } from 'react';
19
+ import React, { useContext, useState, useMemo, useCallback } from 'react';
20
+ import { CaretRightFilled } from '@oceanbase/icons';
14
21
  import ConfigProvider from "../config-provider";
15
22
  import { isHorizontalPaddingZero } from "../_util";
23
+ import theme from "../theme";
16
24
  import useStyle, { genTableStyle } from "./style";
17
25
  import { jsx as _jsx } from "react/jsx-runtime";
18
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -30,19 +38,67 @@ var Card = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
30
38
  bodyStyle = _ref.bodyStyle,
31
39
  styles = _ref.styles,
32
40
  className = _ref.className,
41
+ collapsible = _ref.collapsible,
42
+ defaultCollapsed = _ref.defaultCollapsed,
43
+ outerCollapsed = _ref.collapsed,
44
+ onCollapse = _ref.onCollapse,
45
+ extra = _ref.extra,
33
46
  restProps = _objectWithoutProperties(_ref, _excluded);
34
47
  var _useContext = useContext(ConfigProvider.ConfigContext),
35
48
  getPrefixCls = _useContext.getPrefixCls,
36
- contextCard = _useContext.card;
49
+ contextCard = _useContext.card,
50
+ iconPrefixCls = _useContext.iconPrefixCls;
51
+ var _theme$useToken = theme.useToken(),
52
+ token = _theme$useToken.token;
37
53
  var divided = (_ref2 = outerDivided !== null && outerDivided !== void 0 ? outerDivided : contextCard === null || contextCard === void 0 ? void 0 : contextCard.divided) !== null && _ref2 !== void 0 ? _ref2 : true;
38
54
  var prefixCls = getPrefixCls('card', customizePrefixCls);
39
55
  var tabsPrefixCls = getPrefixCls('tabs', customizePrefixCls);
40
56
  var _useStyle = useStyle(prefixCls, tabsPrefixCls),
41
57
  wrapSSR = _useStyle.wrapSSR;
58
+ var _useState = useState(defaultCollapsed !== null && defaultCollapsed !== void 0 ? defaultCollapsed : false),
59
+ _useState2 = _slicedToArray(_useState, 2),
60
+ internalCollapsed = _useState2[0],
61
+ setInternalCollapsed = _useState2[1];
62
+ var collapsed = outerCollapsed !== undefined ? outerCollapsed : internalCollapsed;
63
+ var handleCollapse = useCallback(function () {
64
+ var newCollapsed = !collapsed;
65
+ if (outerCollapsed === undefined) {
66
+ setInternalCollapsed(newCollapsed);
67
+ }
68
+ onCollapse === null || onCollapse === void 0 || onCollapse(newCollapsed);
69
+ }, [collapsed, outerCollapsed, onCollapse]);
70
+ var cardTitle = useMemo(function () {
71
+ if (!collapsible) {
72
+ return title;
73
+ }
74
+ if (!title) {
75
+ return null;
76
+ }
77
+ return /*#__PURE__*/_jsxs("div", {
78
+ className: "".concat(prefixCls, "-title-wrapper"),
79
+ onClick: handleCollapse,
80
+ style: {
81
+ cursor: 'pointer',
82
+ display: 'flex',
83
+ alignItems: 'center'
84
+ },
85
+ children: [/*#__PURE__*/_jsx(CaretRightFilled, {
86
+ className: "".concat(prefixCls, "-collapsible-icon"),
87
+ style: {
88
+ transition: "transform ".concat(token.motionDurationMid),
89
+ transform: collapsed ? undefined : 'rotate(90deg)',
90
+ color: token.colorIcon,
91
+ marginRight: token.marginXS
92
+ }
93
+ }), /*#__PURE__*/_jsx("span", {
94
+ children: title
95
+ })]
96
+ });
97
+ }, [collapsible, title, collapsed, prefixCls, token, handleCollapse]);
42
98
 
43
99
  // card body no horizontal padding
44
100
  var noBodyHorizontalPadding = isHorizontalPaddingZero(bodyStyle === null || bodyStyle === void 0 ? void 0 : bodyStyle.padding) || isHorizontalPaddingZero(styles === null || styles === void 0 || (_styles$body = styles.body) === null || _styles$body === void 0 ? void 0 : _styles$body.padding);
45
- var cardCls = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-has-title"), !!title), "".concat(prefixCls, "-no-divider"), !divided), "".concat(prefixCls, "-no-body-horizontal-padding"), noBodyHorizontalPadding), className);
101
+ var cardCls = classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-has-title"), !!title), "".concat(prefixCls, "-no-divider"), !divided), "".concat(prefixCls, "-no-body-horizontal-padding"), noBodyHorizontalPadding), "".concat(prefixCls, "-collapsible"), collapsible), "".concat(prefixCls, "-collapsed"), collapsed), className);
46
102
  var newTabList = tabList === null || tabList === void 0 ? void 0 : tabList.map(function (item) {
47
103
  if (!isNullValue(item.tag)) {
48
104
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -61,15 +117,16 @@ var Card = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
61
117
  return wrapSSR( /*#__PURE__*/_jsx(AntCard, _objectSpread(_objectSpread({
62
118
  ref: ref,
63
119
  size: size,
64
- title: title,
120
+ title: cardTitle,
65
121
  tabList: newTabList,
66
122
  tabProps: _objectSpread({
67
123
  size: 'middle'
68
124
  }, tabProps),
69
125
  prefixCls: customizePrefixCls,
70
- bodyStyle: bodyStyle,
126
+ bodyStyle: _objectSpread({}, bodyStyle),
71
127
  styles: styles,
72
- className: cardCls
128
+ className: cardCls,
129
+ extra: extra
73
130
  }, restProps), {}, {
74
131
  children: children
75
132
  })));
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { unit } from '@ant-design/cssinjs';
7
8
  import { genTabsStyle } from "../../tabs/style";
8
9
  import { genComponentStyleHook } from "../../_util/genComponentStyleHook";
9
10
  export var genTableStyle = function genTableStyle(padding, token) {
@@ -26,39 +27,64 @@ export var genCardStyle = function genCardStyle(token) {
26
27
  tabsComponentCls = token.tabsComponentCls,
27
28
  tabsPrefixCls = token.tabsPrefixCls,
28
29
  paddingSM = token.paddingSM,
29
- paddingLG = token.paddingLG;
30
+ paddingLG = token.paddingLG,
31
+ calc = token.calc;
30
32
  var tableComponentCls = "".concat(antCls, "-table");
31
- return _ref2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref2, "".concat(componentCls), _defineProperty(_defineProperty({}, "".concat(componentCls, ":not(").concat(componentCls, "-bordered):not(").concat(componentCls, "-type-inner)"), {
33
+ return _ref2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref2, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls, "-body"), {
34
+ paddingTop: token.padding
35
+ }), "".concat(componentCls, ":not(").concat(componentCls, "-bordered):not(").concat(componentCls, "-type-inner)"), {
32
36
  boxShadow: 'none'
33
37
  }), "".concat(componentCls).concat(componentCls, "-bordered"), _defineProperty({
34
- borderRadius: token.borderRadiusLG - 2
38
+ borderRadius: calc(token.borderRadiusLG).sub(2).equal()
35
39
  }, "".concat(componentCls).concat(componentCls, "-bordered"), _defineProperty({
36
40
  borderRadius: token.borderRadius
37
41
  }, "".concat(componentCls).concat(componentCls, "-bordered"), {
38
42
  borderRadius: token.borderRadiusSM
39
43
  })))), "".concat(componentCls).concat(componentCls, "-no-divider"), _defineProperty({}, "".concat(componentCls, "-head"), _defineProperty({
40
44
  // should not remove border-bottom to avoid tabs inkbar display correctly
41
- borderBottomColor: 'transparent'
45
+ borderBottomColor: 'transparent',
46
+ paddingTop: token.paddingLG,
47
+ paddingBottom: token.padding
42
48
  }, tabsComponentCls, _defineProperty({}, "&".concat(tabsComponentCls, "-top, &").concat(tabsComponentCls, "-bottom"), _defineProperty({}, "".concat(tabsComponentCls, "-nav::before"), {
43
49
  border: 'none'
44
50
  }))))), "".concat(componentCls).concat(componentCls, "-no-divider:not(").concat(componentCls, "-contain-tabs)"), _defineProperty({}, "".concat(componentCls, "-body"), {
45
- padding: "0 ".concat(paddingLG, "px ").concat(paddingLG, "px ").concat(paddingLG, "px")
51
+ padding: "0 ".concat(unit(paddingLG), " ").concat(unit(paddingLG), " ").concat(unit(paddingLG))
52
+ })), "".concat(componentCls, "-small"), _defineProperty({}, "".concat(componentCls, "-body"), {
53
+ paddingTop: token.paddingXS
46
54
  })), "".concat(componentCls, "-small").concat(componentCls, "-no-divider:not(").concat(componentCls, "-contain-tabs)"), _defineProperty({}, "".concat(componentCls, "-body"), {
47
- padding: "0 ".concat(paddingSM, "px ").concat(paddingSM, "px ").concat(paddingSM, "px")
55
+ padding: "0 ".concat(unit(paddingSM), " ").concat(unit(paddingSM), " ").concat(unit(paddingSM))
48
56
  })), "".concat(componentCls, "-small").concat(componentCls, "-contain-tabs >").concat(componentCls, "-head"), _defineProperty({}, "".concat(componentCls, "-head-title, ").concat(componentCls, "-head-extra"), {
49
57
  paddingTop: token.paddingXS
50
- })), "".concat(componentCls).concat(componentCls, "-contain-tabs"), _defineProperty({}, "".concat(componentCls, "-head"), genTabsStyle(_objectSpread(_objectSpread({}, token), {}, {
58
+ })), "".concat(componentCls).concat(componentCls, "-contain-tabs"), _defineProperty({}, "".concat(componentCls, "-head"), _objectSpread(_objectSpread({}, genTabsStyle(_objectSpread(_objectSpread({}, token), {}, {
51
59
  componentCls: tabsComponentCls,
52
60
  prefixCls: tabsPrefixCls
53
- })))), "".concat(componentCls).concat(componentCls, "-contain-grid"), _defineProperty({}, "".concat(componentCls, "-head"), {
61
+ }))), {}, _defineProperty({}, tabsComponentCls, _defineProperty({}, "&".concat(tabsComponentCls, "-top, &").concat(tabsComponentCls, "-bottom"), _defineProperty({}, "".concat(tabsComponentCls, "-tab"), {
62
+ paddingBlock: token.padding
63
+ })))))), "".concat(componentCls).concat(componentCls, "-contain-grid"), _defineProperty({}, "".concat(componentCls, "-head"), {
54
64
  // work for Card containing Card.Grid
55
65
  marginBottom: -1
56
66
  })), "".concat(componentCls, ":not(").concat(componentCls, "-contain-grid)"), _defineProperty({}, "".concat(componentCls, "-head"), {
57
67
  // work for Card not containing Card.Grid
58
68
  marginBottom: 0
59
69
  })), "&".concat(componentCls, "-has-title").concat(componentCls, "-no-divider:not(").concat(componentCls, "-contain-tabs)"), _defineProperty({}, "".concat(componentCls, "-body"), _defineProperty({}, "& > ".concat(tableComponentCls, "-wrapper ").concat(tableComponentCls, ":not(").concat(tableComponentCls, "-bordered):first-child"), {
60
- marginTop: -token.marginSM
61
- }))), "".concat(componentCls).concat(componentCls, "-no-body-horizontal-padding"), genTableStyle(paddingLG, token)), _defineProperty(_ref2, "".concat(componentCls).concat(componentCls, "-no-body-horizontal-padding").concat(componentCls, "-small"), genTableStyle(paddingSM, token));
70
+ marginTop: calc(token.marginSM).mul(-1).equal()
71
+ }))), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref2, "".concat(componentCls).concat(componentCls, "-no-body-horizontal-padding"), genTableStyle(paddingLG, token)), "".concat(componentCls).concat(componentCls, "-no-body-horizontal-padding").concat(componentCls, "-small"), genTableStyle(paddingSM, token)), "".concat(componentCls).concat(componentCls, "-collapsible"), _defineProperty(_defineProperty({}, "".concat(componentCls, "-title-wrapper"), _defineProperty({
72
+ userSelect: 'none'
73
+ }, "".concat(componentCls, "-collapsible-icon"), {
74
+ fontSize: token.fontSizeLG
75
+ })), "".concat(componentCls, "-body"), {
76
+ overflow: 'hidden'
77
+ })), "".concat(componentCls).concat(componentCls, "-collapsible").concat(componentCls, "-collapsed"), _defineProperty(_defineProperty({}, "".concat(componentCls, "-body"), {
78
+ maxHeight: 0,
79
+ paddingTop: 0,
80
+ paddingBottom: 0,
81
+ opacity: 0,
82
+ overflow: 'hidden',
83
+ border: 'none',
84
+ margin: 0
85
+ }), "".concat(componentCls, "-head"), {
86
+ borderBottom: 'none'
87
+ }));
62
88
  };
63
89
  export default (function (prefixCls, tabsPrefixCls) {
64
90
  var useStyle = genComponentStyleHook('Card', function (token) {
@@ -7,11 +7,13 @@ export var genCheckboxStyle = function genCheckboxStyle(token) {
7
7
  var componentCls = token.componentCls,
8
8
  fontSize = token.fontSize,
9
9
  fontSizeLG = token.fontSizeLG,
10
- lineHeight = token.lineHeight;
10
+ lineHeight = token.lineHeight,
11
+ calc = token.calc;
12
+ var translateY = calc(calc(fontSize).mul(lineHeight).equal()).sub(fontSizeLG).div(2).equal();
11
13
  return _defineProperty({}, "".concat(componentCls, "-wrapper"), _defineProperty({}, "".concat(componentCls), _defineProperty({
12
14
  alignSelf: 'baseline'
13
15
  }, "".concat(componentCls, "-inner"), {
14
- transform: "translate(0px, ".concat((fontSize * lineHeight - fontSizeLG) / 2, "px)")
16
+ transform: "translate(0px, ".concat(translateY, ")")
15
17
  })));
16
18
  };
17
19
  export default (function (prefixCls) {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ConfigProvider as AntConfigProvider } from 'antd';
3
3
  import type { ConfigProviderProps as AntConfigProviderProps, ConfigConsumerProps as AntConfigConsumerProps, ThemeConfig as AntThemeConfig } from 'antd/es/config-provider';
4
- import type { ComponentStyleConfig, CardConfig as AntCardConfig } from 'antd/es/config-provider/context';
4
+ import type { ComponentStyleConfig, CardConfig as AntCardConfig, TableConfig as AntTableConfig } from 'antd/es/config-provider/context';
5
5
  import type { AppProps } from 'antd/es/app';
6
6
  import type { PaginationConfig } from 'antd/es/pagination';
7
7
  import type { SpinIndicator } from 'antd/es/spin';
@@ -23,7 +23,7 @@ export type CardConfig = AntCardConfig & {
23
23
  export type SpinConfig = ComponentStyleConfig & {
24
24
  indicator?: SpinIndicator;
25
25
  };
26
- export type TableConfig = ComponentStyleConfig & {
26
+ export type TableConfig = AntTableConfig & {
27
27
  selectionColumnWidth?: number;
28
28
  };
29
29
  export interface ConfigConsumerProps extends AntConfigConsumerProps {