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

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 (60) 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 +13 -4
  4. package/es/alert/style/index.js +152 -58
  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 +29 -5
  10. package/es/config-provider/index.d.ts +2 -2
  11. package/es/config-provider/index.js +26 -2
  12. package/es/descriptions/hooks/useItems.d.ts +6 -6
  13. package/es/drawer/style/index.js +24 -6
  14. package/es/form/FormItem.d.ts +1 -0
  15. package/es/form/FormItem.js +14 -4
  16. package/es/form/style/index.js +13 -2
  17. package/es/input-number/index.d.ts +2 -1
  18. package/es/locale/ja-JP.d.ts +3 -0
  19. package/es/locale/ja-JP.js +28 -0
  20. package/es/modal/Modal.js +20 -6
  21. package/es/modal/style/index.js +62 -19
  22. package/es/static-function/index.js +13 -4
  23. package/es/table/style/index.js +3 -4
  24. package/es/tabs/style/index.js +4 -2
  25. package/es/tag/index.d.ts +1 -0
  26. package/es/tag/index.js +3 -2
  27. package/es/tag/style/index.js +8 -2
  28. package/es/theme/default.js +9 -3
  29. package/es/theme/style/compact.less +7 -7
  30. package/es/theme/style/default.less +7 -7
  31. package/lib/alert/index.d.ts +2 -2
  32. package/lib/alert/index.js +11 -3
  33. package/lib/alert/style/index.js +170 -71
  34. package/lib/badge/index.js +2 -2
  35. package/lib/badge/style/index.js +1 -3
  36. package/lib/card/index.d.ts +4 -0
  37. package/lib/card/index.js +61 -4
  38. package/lib/card/style/index.js +52 -6
  39. package/lib/config-provider/index.d.ts +2 -2
  40. package/lib/config-provider/index.js +35 -2
  41. package/lib/descriptions/hooks/useItems.d.ts +6 -6
  42. package/lib/drawer/style/index.js +25 -4
  43. package/lib/form/FormItem.d.ts +1 -0
  44. package/lib/form/FormItem.js +10 -2
  45. package/lib/form/style/index.js +19 -0
  46. package/lib/input-number/index.d.ts +2 -1
  47. package/lib/locale/ja-JP.d.ts +3 -0
  48. package/lib/locale/ja-JP.js +60 -0
  49. package/lib/modal/Modal.js +26 -6
  50. package/lib/modal/style/index.js +76 -17
  51. package/lib/static-function/index.js +7 -1
  52. package/lib/table/style/index.js +3 -4
  53. package/lib/tabs/style/index.js +5 -0
  54. package/lib/tag/index.d.ts +1 -0
  55. package/lib/tag/index.js +3 -1
  56. package/lib/tag/style/index.js +8 -0
  57. package/lib/theme/default.js +9 -3
  58. package/lib/theme/style/compact.less +7 -7
  59. package/lib/theme/style/default.less +7 -7
  60. package/package.json +5 -5
@@ -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; }
@@ -22,20 +22,29 @@ var iconMapOutlined = {
22
22
  warning: /*#__PURE__*/_jsx(ExclamationCircleOutlined, {})
23
23
  };
24
24
  var Alert = function Alert(_ref) {
25
- var type = _ref.type,
25
+ var typeProp = _ref.type,
26
+ _ref$showIcon = _ref.showIcon,
27
+ showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
28
+ closable = _ref.closable,
26
29
  ghost = _ref.ghost,
27
- colored = _ref.colored,
30
+ mini = _ref.mini,
31
+ banner = _ref.banner,
28
32
  customizePrefixCls = _ref.prefixCls,
29
33
  className = _ref.className,
30
34
  restProps = _objectWithoutProperties(_ref, _excluded);
35
+ // banner exists and type is empty, use warning type by default for correct icon
36
+ var type = banner && !typeProp ? 'warning' : typeProp;
31
37
  var _useContext = useContext(ConfigProvider.ConfigContext),
32
38
  getPrefixCls = _useContext.getPrefixCls;
33
39
  var prefixCls = getPrefixCls('alert', customizePrefixCls);
34
40
  var _useStyle = useStyle(prefixCls),
35
41
  wrapSSR = _useStyle.wrapSSR;
36
- var alertCls = classNames(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-ghost"), ghost), "".concat(prefixCls, "-colored"), colored), className);
42
+ var alertCls = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-closable"), closable), "".concat(prefixCls, "-ghost"), ghost), "".concat(prefixCls, "-mini"), mini), className);
37
43
  return wrapSSR( /*#__PURE__*/_jsx(AntAlert, _objectSpread({
38
44
  type: type,
45
+ showIcon: showIcon,
46
+ closable: closable,
47
+ banner: banner,
39
48
  icon: iconMapOutlined[type],
40
49
  prefixCls: customizePrefixCls,
41
50
  className: alertCls
@@ -3,91 +3,185 @@ 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
35
  motionDurationMid = token.motionDurationMid;
55
36
  // height = fontSize * lineHeight
56
37
  var height = token.fontSize * token.lineHeight;
57
- return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls), _defineProperty(_defineProperty({
38
+ // icon width = fontSizeLG (icon size)
39
+ var iconWidth = token.fontSizeLG;
40
+ // content and action start position = icon width + icon margin
41
+ var contentStartOffset = iconWidth + token.marginXS;
42
+ // close icon width (approximate)
43
+ var closeIconWidth = height;
44
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
58
45
  // vertical align to flex-start
59
46
  alignItems: 'flex-start !important',
60
- paddingRight: token.padding
47
+ paddingInline: token.padding,
48
+ position: 'relative'
61
49
  }, "".concat(componentCls, "-icon"), {
62
- height: height
50
+ height: height,
51
+ fontSize: token.fontSizeLG,
52
+ marginInlineEnd: token.marginXS,
53
+ flexShrink: 0
63
54
  }), "".concat(componentCls, "-close-icon"), {
55
+ position: 'absolute',
56
+ top: token.paddingXS,
57
+ insetInlineEnd: token.padding,
64
58
  height: height,
65
59
  color: colorIcon,
66
60
  transition: "color ".concat(motionDurationMid),
61
+ flexShrink: 0,
62
+ display: 'flex',
63
+ alignItems: 'center',
67
64
  '&:hover': {
68
65
  color: colorIconHover
69
66
  }
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
67
+ }), "".concat(componentCls, "-message"), {
68
+ a: {
69
+ textDecoration: 'underline'
70
+ }
71
+ }), "".concat(componentCls, "-description"), {
72
+ a: {
73
+ textDecoration: 'underline'
74
+ }
75
+ }), "&".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({
76
+ flexWrap: 'wrap'
77
+ }, "".concat(componentCls, "-content"), {
78
+ flex: "1 1 calc(100% - ".concat(contentStartOffset + closeIconWidth + token.padding, "px)"),
79
+ minWidth: 0,
80
+ maxWidth: "calc(100% - ".concat(contentStartOffset + closeIconWidth + token.padding, "px)"),
81
+ wordBreak: 'break-word'
82
+ }), "".concat(componentCls, "-action"), {
83
+ width: "calc(100% - ".concat(contentStartOffset + token.padding, "px)"),
84
+ marginInlineStart: contentStartOffset,
85
+ marginTop: token.marginXS
86
+ })), "".concat(componentCls).concat(componentCls, "-with-description"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
87
+ paddingBlock: token.paddingSM,
88
+ flexWrap: 'wrap'
74
89
  }, "".concat(componentCls, "-message"), {
75
- fontWeight: 500,
76
- marginBottom: token.marginXXS
90
+ fontSize: token.fontSize,
91
+ fontWeight: token.fontWeightStrong,
92
+ marginBottom: token.marginXXS,
93
+ wordBreak: 'break-word'
77
94
  }), "".concat(componentCls, "-description"), {
78
- color: token.colorTextSecondary
79
- }), "".concat(componentCls, "-icon"), {
80
- fontSize: token.fontSizeHeading4,
81
- height: token.fontSizeHeading3,
82
- marginInlineEnd: token.margin
95
+ wordBreak: 'break-word'
96
+ }), "".concat(componentCls, "-content"), {
97
+ flex: "1 1 calc(100% - ".concat(contentStartOffset + closeIconWidth + token.padding, "px)"),
98
+ minWidth: 0,
99
+ maxWidth: "calc(100% - ".concat(contentStartOffset + closeIconWidth + token.padding, "px)"),
100
+ wordBreak: 'break-word'
83
101
  }), "".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"), {
102
+ width: "calc(100% - ".concat(contentStartOffset + token.padding, "px)"),
103
+ marginInlineStart: contentStartOffset,
104
+ marginTop: token.marginSM
105
+ }), "".concat(componentCls, "-close-icon"), {
106
+ top: token.paddingSM
107
+ })), "".concat(componentCls).concat(componentCls, "-ghost"), {
86
108
  backgroundColor: 'transparent',
87
109
  border: 'none',
88
- padding: 0,
110
+ padding: '0px !important',
89
111
  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)));
112
+ }), "".concat(componentCls).concat(componentCls, "-mini"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
113
+ paddingBlock: token.paddingXXS,
114
+ paddingInline: token.paddingXS,
115
+ border: 'none',
116
+ width: 'fit-content',
117
+ display: 'inline-flex',
118
+ alignItems: 'center',
119
+ flexWrap: 'nowrap'
120
+ }, "".concat(componentCls, "-icon"), {
121
+ marginInlineEnd: token.paddingXS,
122
+ flexShrink: 0,
123
+ display: 'flex',
124
+ alignItems: 'center',
125
+ justifyContent: 'center',
126
+ lineHeight: 1
127
+ }), "".concat(componentCls, "-message"), {
128
+ whiteSpace: 'nowrap',
129
+ wordBreak: 'normal',
130
+ overflow: 'visible',
131
+ lineHeight: token.lineHeight,
132
+ display: 'flex',
133
+ alignItems: 'center'
134
+ }), "".concat(componentCls, "-content"), {
135
+ display: 'flex',
136
+ alignItems: 'center',
137
+ flex: '0 1 auto',
138
+ whiteSpace: 'nowrap',
139
+ minWidth: 0,
140
+ lineHeight: token.lineHeight
141
+ }), "".concat(componentCls, "-close-icon"), {
142
+ position: 'relative',
143
+ top: token.paddingXXS,
144
+ insetInlineEnd: 'auto',
145
+ height: 'auto',
146
+ flexShrink: 0,
147
+ marginInlineStart: 0
148
+ }), "&".concat(componentCls, "-closable"), _defineProperty({}, "".concat(componentCls, "-content"), {
149
+ paddingInlineEnd: token.paddingXS
150
+ })), "&:not(".concat(componentCls, "-with-description)"), _defineProperty({
151
+ flexWrap: 'nowrap'
152
+ }, "".concat(componentCls, "-content"), {
153
+ flex: '0 1 auto',
154
+ minWidth: 0,
155
+ maxWidth: 'none',
156
+ wordBreak: 'normal'
157
+ })), "&".concat(componentCls, "-with-description"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
158
+ paddingBlock: token.paddingXXS,
159
+ flexDirection: 'row',
160
+ alignItems: 'flex-start',
161
+ position: 'relative',
162
+ flexWrap: 'nowrap'
163
+ }, "".concat(componentCls, "-icon"), {
164
+ alignSelf: 'flex-start',
165
+ marginTop: 0
166
+ }), "".concat(componentCls, "-content"), {
167
+ flexDirection: 'column',
168
+ alignItems: 'flex-start',
169
+ flex: '0 1 auto',
170
+ minWidth: 0,
171
+ maxWidth: 'none',
172
+ wordBreak: 'normal'
173
+ }), "".concat(componentCls, "-message"), {
174
+ marginBottom: token.marginXXS,
175
+ whiteSpace: 'nowrap',
176
+ wordBreak: 'normal'
177
+ }), "".concat(componentCls, "-description"), {
178
+ whiteSpace: 'nowrap',
179
+ wordBreak: 'normal'
180
+ }), "".concat(componentCls, "-close-icon"), {
181
+ position: 'absolute',
182
+ top: token.paddingXXS,
183
+ insetInlineEnd: token.paddingXS
184
+ })));
91
185
  };
92
186
  export default (function (prefixCls) {
93
187
  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
  })));
@@ -28,7 +28,9 @@ export var genCardStyle = function genCardStyle(token) {
28
28
  paddingSM = token.paddingSM,
29
29
  paddingLG = token.paddingLG;
30
30
  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)"), {
31
+ return _ref2 = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref2, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls, "-body"), {
32
+ paddingTop: token.padding
33
+ }), "".concat(componentCls, ":not(").concat(componentCls, "-bordered):not(").concat(componentCls, "-type-inner)"), {
32
34
  boxShadow: 'none'
33
35
  }), "".concat(componentCls).concat(componentCls, "-bordered"), _defineProperty({
34
36
  borderRadius: token.borderRadiusLG - 2
@@ -38,19 +40,25 @@ export var genCardStyle = function genCardStyle(token) {
38
40
  borderRadius: token.borderRadiusSM
39
41
  })))), "".concat(componentCls).concat(componentCls, "-no-divider"), _defineProperty({}, "".concat(componentCls, "-head"), _defineProperty({
40
42
  // should not remove border-bottom to avoid tabs inkbar display correctly
41
- borderBottomColor: 'transparent'
43
+ borderBottomColor: 'transparent',
44
+ paddingTop: token.paddingLG,
45
+ paddingBottom: token.padding
42
46
  }, tabsComponentCls, _defineProperty({}, "&".concat(tabsComponentCls, "-top, &").concat(tabsComponentCls, "-bottom"), _defineProperty({}, "".concat(tabsComponentCls, "-nav::before"), {
43
47
  border: 'none'
44
48
  }))))), "".concat(componentCls).concat(componentCls, "-no-divider:not(").concat(componentCls, "-contain-tabs)"), _defineProperty({}, "".concat(componentCls, "-body"), {
45
49
  padding: "0 ".concat(paddingLG, "px ").concat(paddingLG, "px ").concat(paddingLG, "px")
50
+ })), "".concat(componentCls, "-small"), _defineProperty({}, "".concat(componentCls, "-body"), {
51
+ paddingTop: token.paddingXS
46
52
  })), "".concat(componentCls, "-small").concat(componentCls, "-no-divider:not(").concat(componentCls, "-contain-tabs)"), _defineProperty({}, "".concat(componentCls, "-body"), {
47
53
  padding: "0 ".concat(paddingSM, "px ").concat(paddingSM, "px ").concat(paddingSM, "px")
48
54
  })), "".concat(componentCls, "-small").concat(componentCls, "-contain-tabs >").concat(componentCls, "-head"), _defineProperty({}, "".concat(componentCls, "-head-title, ").concat(componentCls, "-head-extra"), {
49
55
  paddingTop: token.paddingXS
50
- })), "".concat(componentCls).concat(componentCls, "-contain-tabs"), _defineProperty({}, "".concat(componentCls, "-head"), genTabsStyle(_objectSpread(_objectSpread({}, token), {}, {
56
+ })), "".concat(componentCls).concat(componentCls, "-contain-tabs"), _defineProperty({}, "".concat(componentCls, "-head"), _objectSpread(_objectSpread({}, genTabsStyle(_objectSpread(_objectSpread({}, token), {}, {
51
57
  componentCls: tabsComponentCls,
52
58
  prefixCls: tabsPrefixCls
53
- })))), "".concat(componentCls).concat(componentCls, "-contain-grid"), _defineProperty({}, "".concat(componentCls, "-head"), {
59
+ }))), {}, _defineProperty({}, tabsComponentCls, _defineProperty({}, "&".concat(tabsComponentCls, "-top, &").concat(tabsComponentCls, "-bottom"), _defineProperty({}, "".concat(tabsComponentCls, "-tab"), {
60
+ paddingBlock: token.padding
61
+ })))))), "".concat(componentCls).concat(componentCls, "-contain-grid"), _defineProperty({}, "".concat(componentCls, "-head"), {
54
62
  // work for Card containing Card.Grid
55
63
  marginBottom: -1
56
64
  })), "".concat(componentCls, ":not(").concat(componentCls, "-contain-grid)"), _defineProperty({}, "".concat(componentCls, "-head"), {
@@ -58,7 +66,23 @@ export var genCardStyle = function genCardStyle(token) {
58
66
  marginBottom: 0
59
67
  })), "&".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
68
  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));
69
+ }))), _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({
70
+ userSelect: 'none'
71
+ }, "".concat(componentCls, "-collapsible-icon"), {
72
+ fontSize: token.fontSizeLG
73
+ })), "".concat(componentCls, "-body"), {
74
+ overflow: 'hidden'
75
+ })), "".concat(componentCls).concat(componentCls, "-collapsible").concat(componentCls, "-collapsed"), _defineProperty(_defineProperty({}, "".concat(componentCls, "-body"), {
76
+ maxHeight: 0,
77
+ paddingTop: 0,
78
+ paddingBottom: 0,
79
+ opacity: 0,
80
+ overflow: 'hidden',
81
+ border: 'none',
82
+ margin: 0
83
+ }), "".concat(componentCls, "-head"), {
84
+ borderBottom: 'none'
85
+ }));
62
86
  };
63
87
  export default (function (prefixCls, tabsPrefixCls) {
64
88
  var useStyle = genComponentStyleHook('Card', function (token) {
@@ -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 {
@@ -75,9 +75,13 @@ var ConfigProvider = function ConfigProvider(_ref3) {
75
75
  card: merge({}, parentContext.card, card),
76
76
  collapse: merge({}, {
77
77
  expandIcon: function expandIcon(_ref4) {
78
+ var _mergedTheme$token4, _mergedTheme$token5;
78
79
  var isActive = _ref4.isActive;
79
80
  return /*#__PURE__*/_jsx(CaretRightOutlined, {
80
- rotate: isActive ? 90 : 0
81
+ rotate: isActive ? 90 : 0,
82
+ style: {
83
+ color: ((_mergedTheme$token4 = mergedTheme.token) === null || _mergedTheme$token4 === void 0 ? void 0 : _mergedTheme$token4.colorIcon) || ((_mergedTheme$token5 = mergedTheme.token) === null || _mergedTheme$token5 === void 0 ? void 0 : _mergedTheme$token5.colorTextSecondary)
84
+ }
81
85
  });
82
86
  }
83
87
  }, parentContext.collapse, collapse),
@@ -85,7 +89,27 @@ var ConfigProvider = function ConfigProvider(_ref3) {
85
89
  requiredMark: 'optional'
86
90
  }, parentContext.form, form),
87
91
  spin: merge({}, parentContext.spin, spin),
88
- table: merge({}, parentContext.table, table),
92
+ table: merge({}, {
93
+ expandable: {
94
+ expandIcon: function expandIcon(_ref5) {
95
+ var _mergedTheme$token6, _mergedTheme$token7;
96
+ var expandable = _ref5.expandable,
97
+ expanded = _ref5.expanded,
98
+ onExpand = _ref5.onExpand,
99
+ record = _ref5.record;
100
+ return expandable && /*#__PURE__*/_jsx(CaretRightOutlined, {
101
+ onClick: function onClick(e) {
102
+ return onExpand(record, e);
103
+ },
104
+ style: {
105
+ transition: "transform 0.2s",
106
+ transform: expanded ? 'rotate(90deg)' : undefined,
107
+ color: ((_mergedTheme$token6 = mergedTheme.token) === null || _mergedTheme$token6 === void 0 ? void 0 : _mergedTheme$token6.colorIcon) || ((_mergedTheme$token7 = mergedTheme.token) === null || _mergedTheme$token7 === void 0 ? void 0 : _mergedTheme$token7.colorTextSecondary)
108
+ }
109
+ });
110
+ }
111
+ }
112
+ }, parentContext.table, table),
89
113
  tabs: merge({}, parentContext.tabs, tabs),
90
114
  theme: merge({}, mergedTheme, {
91
115
  token: _objectSpread(_objectSpread(_objectSpread({}, getLocaleTokenValue(mergedLocale, 'fontFamily', fontFamily, fontFamilyEn)), getLocaleTokenValue(mergedLocale, 'fontWeight', fontWeight, fontWeightEn)), getLocaleTokenValue(mergedLocale, 'fontWeightStrong', fontWeightStrong, fontWeightStrongEn))
@@ -5,17 +5,17 @@ export default function useItems(items?: DescriptionsItemType[], children?: Reac
5
5
  key?: React.Key;
6
6
  label?: React.ReactNode;
7
7
  span?: number | "filled" | {
8
- xs?: number;
9
- sm?: number;
10
- md?: number;
11
- lg?: number;
12
- xl?: number;
13
8
  xxl?: number;
9
+ xl?: number;
10
+ lg?: number;
11
+ md?: number;
12
+ sm?: number;
13
+ xs?: number;
14
14
  };
15
15
  style?: React.CSSProperties;
16
+ className?: string;
16
17
  classNames?: Partial<Record<"label" | "content", string>>;
17
18
  styles?: Partial<Record<"label" | "content", React.CSSProperties>>;
18
- className?: string;
19
19
  labelStyle?: React.CSSProperties;
20
20
  contentStyle?: React.CSSProperties;
21
21
  }[];