@teamix/pro 1.2.0 → 1.2.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.
- package/dist/212.js +1 -1
- package/dist/pro.css +1 -1
- package/dist/pro.js +1072 -507
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-component.js +2 -1
- package/es/actions/dialog-form.js +2 -1
- package/es/actions/dialog.js +2 -1
- package/es/actions/index.js +1 -1
- package/es/actions/utils.d.ts +1 -0
- package/es/actions/utils.js +27 -0
- package/es/card/card-container.d.ts +18 -0
- package/es/card/card-container.js +24 -0
- package/es/card/divider.d.ts +6 -0
- package/es/card/divider.js +16 -0
- package/es/card/index.d.ts +59 -32
- package/es/card/index.js +191 -107
- package/es/card/index.scss +124 -9
- package/es/card/utils.d.ts +9 -0
- package/es/card/utils.js +30 -0
- package/es/form/Components/ProField/index.js +2 -6
- package/es/form/ProForm/index.js +43 -17
- package/es/form/ProForm/index.scss +0 -1
- package/es/form/ProForm/useAutoSubmit.d.ts +1 -1
- package/es/form/ProForm/useAutoSubmit.js +3 -3
- package/es/form/ProForm/useInitialRequest.d.ts +1 -1
- package/es/form/ProForm/useInitialRequest.js +2 -2
- package/es/form/SchemaForm/initializeDataSource.js +1 -1
- package/es/form/SchemaForm/initializeFormButton.js +3 -2
- package/es/form/SchemaForm/initializeRequest.js +6 -3
- package/es/form/SchemaForm/initializeRules.js +1 -1
- package/es/form/SchemaForm/reactions.d.ts +5 -4
- package/es/form/SchemaForm/reactions.js +20 -11
- package/es/form/locales/validate.d.ts +159 -0
- package/es/form/locales/validate.js +158 -0
- package/es/form/typing.d.ts +4 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/InfoGroup/index.js +5 -2
- package/es/info/components/InfoValueItem/index.js +5 -7
- package/es/info/components/baseInfo/index.js +4 -2
- package/es/info/index.js +25 -11
- package/es/info/typing.d.ts +6 -0
- package/es/nocode/configurators/Card.js +8 -4
- package/es/table/components/Layout/index.js +1 -1
- package/es/table/components/ToolBar/FilterColumnIcon.js +2 -24
- package/es/table/components/ToolBar/index.scss +0 -3
- package/es/table/index.js +15 -7
- package/es/table/typing.d.ts +4 -4
- package/lib/actions/dialog-component.js +3 -1
- package/lib/actions/dialog-form.js +3 -1
- package/lib/actions/dialog.js +3 -1
- package/lib/actions/index.js +1 -1
- package/lib/actions/utils.d.ts +1 -0
- package/lib/actions/utils.js +33 -0
- package/lib/card/card-container.d.ts +18 -0
- package/lib/card/card-container.js +37 -0
- package/lib/card/divider.d.ts +6 -0
- package/lib/card/divider.js +26 -0
- package/lib/card/index.d.ts +59 -32
- package/lib/card/index.js +211 -110
- package/lib/card/index.scss +124 -9
- package/lib/card/utils.d.ts +9 -0
- package/lib/card/utils.js +41 -0
- package/lib/form/Components/ProField/index.js +1 -5
- package/lib/form/ProForm/index.js +41 -14
- package/lib/form/ProForm/index.scss +0 -1
- package/lib/form/ProForm/useAutoSubmit.d.ts +1 -1
- package/lib/form/ProForm/useAutoSubmit.js +3 -3
- package/lib/form/ProForm/useInitialRequest.d.ts +1 -1
- package/lib/form/ProForm/useInitialRequest.js +2 -2
- package/lib/form/SchemaForm/initializeDataSource.js +1 -1
- package/lib/form/SchemaForm/initializeFormButton.js +5 -2
- package/lib/form/SchemaForm/initializeRequest.js +5 -2
- package/lib/form/SchemaForm/initializeRules.js +1 -1
- package/lib/form/SchemaForm/reactions.d.ts +5 -4
- package/lib/form/SchemaForm/reactions.js +23 -12
- package/lib/form/locales/validate.d.ts +159 -0
- package/lib/form/locales/validate.js +165 -0
- package/lib/form/typing.d.ts +4 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/InfoGroup/index.js +5 -2
- package/lib/info/components/InfoValueItem/index.js +5 -7
- package/lib/info/components/baseInfo/index.js +4 -2
- package/lib/info/index.js +24 -10
- package/lib/info/typing.d.ts +6 -0
- package/lib/nocode/configurators/Card.js +8 -4
- package/lib/table/components/Layout/index.js +1 -1
- package/lib/table/components/ToolBar/FilterColumnIcon.js +2 -24
- package/lib/table/components/ToolBar/index.scss +0 -3
- package/lib/table/index.js +16 -7
- package/lib/table/typing.d.ts +4 -4
- package/package.json +5 -4
@@ -12,13 +12,14 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
12
12
|
|
13
13
|
import React from 'react';
|
14
14
|
import useDialogAction from './dialog';
|
15
|
+
import { addContext } from './utils';
|
15
16
|
export function useDialogComponentAction(action, context) {
|
16
17
|
var schema = action.schema,
|
17
18
|
Component = action.component,
|
18
19
|
others = _objectWithoutProperties(action, _excluded);
|
19
20
|
|
20
21
|
return useDialogAction(Object.assign({
|
21
|
-
content: /*#__PURE__*/React.createElement(Component, _objectSpread({}, schema)),
|
22
|
+
content: /*#__PURE__*/React.createElement(Component, _objectSpread({}, addContext(schema, context))),
|
22
23
|
closeable: true
|
23
24
|
}, others), context);
|
24
25
|
}
|
@@ -30,6 +30,7 @@ import ProForm, { createForm } from '../form';
|
|
30
30
|
import { getTargetValue } from '@teamix/utils';
|
31
31
|
import { doRequest } from './request';
|
32
32
|
import useDialogAction from './dialog';
|
33
|
+
import { addContext } from './utils';
|
33
34
|
|
34
35
|
function getDefaultFormPropsByDialogSize(size) {
|
35
36
|
if (size === 'small') {
|
@@ -119,7 +120,7 @@ var DialogForm = function DialogForm(props) {
|
|
119
120
|
}, /*#__PURE__*/React.createElement(ProForm, _objectSpread(_objectSpread({
|
120
121
|
form: form,
|
121
122
|
schema: getTargetValue(formSchema, context)
|
122
|
-
}, getDefaultFormPropsByDialogSize(size)), getTargetValue(others, context))));
|
123
|
+
}, getDefaultFormPropsByDialogSize(size)), addContext(getTargetValue(others, context), context))));
|
123
124
|
};
|
124
125
|
|
125
126
|
export function useDialogFormAction(action, context) {
|
package/es/actions/dialog.js
CHANGED
@@ -37,6 +37,7 @@ import ProForm, { createForm } from '../form';
|
|
37
37
|
import { renderProMessage } from '../utils/message';
|
38
38
|
import { eventHandler } from './base';
|
39
39
|
import { doRequest } from './request';
|
40
|
+
import { addContext } from './utils';
|
40
41
|
|
41
42
|
function addContextForReactNode(content, context) {
|
42
43
|
if (typeof content === 'function' && context) {
|
@@ -223,7 +224,7 @@ export function useDialogAction(action, context) {
|
|
223
224
|
});
|
224
225
|
var dialogContent = Component ? /*#__PURE__*/React.createElement(Component, _objectSpread({
|
225
226
|
key: uuid()
|
226
|
-
}, componentProps)) : addContextForReactNode(content, dialogContext);
|
227
|
+
}, addContext(componentProps, dialogContext))) : addContextForReactNode(content, dialogContext);
|
227
228
|
|
228
229
|
var quickShowProps = _objectSpread(_objectSpread({
|
229
230
|
// @ts-ignore
|
package/es/actions/index.js
CHANGED
@@ -228,7 +228,7 @@ export var ProActionMenuButton = function ProActionMenuButton(props) {
|
|
228
228
|
triggerType: 'hover'
|
229
229
|
},
|
230
230
|
popupProps: {
|
231
|
-
|
231
|
+
v2: true
|
232
232
|
},
|
233
233
|
type: type,
|
234
234
|
label: buttonContent(label || children, icon, iconSize, context)
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function addContext(props?: any, context?: any): any;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
var _excluded = ["context"];
|
2
|
+
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
4
|
+
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
6
|
+
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
+
|
9
|
+
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; }
|
10
|
+
|
11
|
+
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; }
|
12
|
+
|
13
|
+
export function addContext(props, context) {
|
14
|
+
if (!props) {
|
15
|
+
return {
|
16
|
+
context: context
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
var propsContext = props.context,
|
21
|
+
others = _objectWithoutProperties(props, _excluded);
|
22
|
+
|
23
|
+
var mergedContext = Object.assign({}, propsContext, context);
|
24
|
+
return _objectSpread({
|
25
|
+
context: mergedContext
|
26
|
+
}, others);
|
27
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ProCardProps } from './index';
|
3
|
+
/**
|
4
|
+
* @deprecated 建议使用 ProCardProps 代替
|
5
|
+
*/
|
6
|
+
export declare type ProCardContainerProps = ProCardProps;
|
7
|
+
/**
|
8
|
+
* @deprecated 建议使用 ProCard 代替
|
9
|
+
*/
|
10
|
+
export declare const ProCardContainer: React.FC<ProCardContainerProps>;
|
11
|
+
/**
|
12
|
+
* @deprecated 建议使用 ProCardContainer 代替
|
13
|
+
*/
|
14
|
+
export declare const CardContainer: React.FC<ProCardProps>;
|
15
|
+
/**
|
16
|
+
* @deprecated 建议使用 ProCardContainerProps 代替
|
17
|
+
*/
|
18
|
+
export declare type CardContainerProps = ProCardContainerProps;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
2
|
+
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
4
|
+
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
+
|
7
|
+
import React from 'react';
|
8
|
+
import { ProCard } from './index';
|
9
|
+
/**
|
10
|
+
* @deprecated 建议使用 ProCard 代替
|
11
|
+
*/
|
12
|
+
|
13
|
+
export var ProCardContainer = function ProCardContainer(props) {
|
14
|
+
return /*#__PURE__*/React.createElement(ProCard, _objectSpread({}, props));
|
15
|
+
};
|
16
|
+
ProCardContainer.defaultProps = {
|
17
|
+
compacted: true,
|
18
|
+
direction: 'column'
|
19
|
+
};
|
20
|
+
/**
|
21
|
+
* @deprecated 建议使用 ProCardContainer 代替
|
22
|
+
*/
|
23
|
+
|
24
|
+
export var CardContainer = ProCardContainer;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
2
|
+
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
4
|
+
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
+
|
7
|
+
import React from 'react';
|
8
|
+
|
9
|
+
var ProCardDivider = function ProCardDivider(props) {
|
10
|
+
return /*#__PURE__*/React.createElement("div", _objectSpread({
|
11
|
+
className: "teamix-pro-card-divider"
|
12
|
+
}, props));
|
13
|
+
};
|
14
|
+
|
15
|
+
ProCardDivider.isProCardDivider = true;
|
16
|
+
export default ProCardDivider;
|
package/es/card/index.d.ts
CHANGED
@@ -1,59 +1,86 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import { ProActionGroupProps } from '../actions';
|
3
3
|
import './index.scss';
|
4
|
-
export
|
5
|
-
|
6
|
-
spacing?: [number, number] | number;
|
7
|
-
wrap?: boolean;
|
8
|
-
} & React.HTMLAttributes<HTMLElement>;
|
9
|
-
export declare const ProCardContainer: React.FC<ProCardContainerProps>;
|
10
|
-
export interface ProCardProps {
|
4
|
+
export * from './card-container';
|
5
|
+
export interface ProCardProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
11
6
|
/** 内容部分 */
|
12
7
|
children?: React.ReactNode;
|
13
8
|
/**卡片标题 */
|
14
9
|
title?: React.ReactNode;
|
15
10
|
/**卡片副标题 */
|
16
11
|
subTitle?: React.ReactNode;
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
/** 标题右侧图标 hover 提示信息 */
|
13
|
+
tooltip?: React.ReactNode;
|
14
|
+
/** 标题右侧图标 */
|
15
|
+
tooltipIcon?: React.ReactNode;
|
16
|
+
/** 标题右侧描述 */
|
17
|
+
description?: React.ReactNode;
|
18
|
+
/** 额外信息区域,位于卡片右上角,可以配置一些常用轻量操作 */
|
19
|
+
extra?: React.ReactNode | ProActionGroupProps;
|
20
|
+
/** 卡片操作区域,位于卡片最下方,可以配置一些常用轻量操作 */
|
21
|
+
actions?: React.ReactNode | ProActionGroupProps;
|
22
|
+
/** 卡片背景图 */
|
20
23
|
image?: string;
|
21
|
-
|
24
|
+
/** 卡片标题下方是否有分割线 */
|
22
25
|
divider?: boolean;
|
23
|
-
|
26
|
+
/** 卡片是否有边框 */
|
24
27
|
bordered?: boolean;
|
25
|
-
|
28
|
+
/**
|
29
|
+
* @deprecated 已经没有这个效果了,将在下一个 minor 版本移除
|
30
|
+
*/
|
26
31
|
hoveredShadow?: boolean;
|
27
|
-
|
32
|
+
/** 卡片是否为紧凑模式,紧凑模式下卡片没有内边距和边框 */
|
28
33
|
compacted?: boolean;
|
29
|
-
|
34
|
+
/** 卡片内容是否居中展示 */
|
30
35
|
centered?: boolean;
|
31
|
-
|
36
|
+
/** 加载中状态 */
|
32
37
|
loading?: boolean;
|
33
|
-
|
38
|
+
/** 背景色 */
|
34
39
|
backgroundColor?: 'blue' | 'green' | 'red' | 'orange' | 'yellow' | 'grey' | 'transparent';
|
35
|
-
|
40
|
+
/** 内容区栅格排列 flex 方向,仅仅在卡片嵌套模式下生效 */
|
41
|
+
direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
42
|
+
/** 内容区栅格的间距,仅仅在卡片嵌套模式下生效 */
|
43
|
+
spacing?: [number, number] | number;
|
44
|
+
/** 内容区栅格超出部分是否换行展示,仅仅在卡片嵌套模式下生效 */
|
45
|
+
wrap?: boolean;
|
46
|
+
/** 卡片嵌套使用的模式下,子卡片分隔 */
|
47
|
+
split?: 'horizontal' | 'vertical';
|
48
|
+
/** 卡片嵌套使用的模式下,卡片占父卡片内容区域的栅格数量 */
|
36
49
|
col?: number | string;
|
37
|
-
|
50
|
+
/** 卡片是否可折叠 */
|
51
|
+
collapsible?: boolean;
|
52
|
+
/** 默认是否折叠,用于非受控模式 */
|
53
|
+
defaultCollapsed?: boolean;
|
54
|
+
/** 是否折叠,受控模式 */
|
55
|
+
collapsed?: boolean;
|
56
|
+
/** 折叠状态改变的回调函数 */
|
57
|
+
onCollapse?: (collapsed: boolean) => void;
|
58
|
+
/** 卡片 class */
|
38
59
|
className?: string;
|
39
|
-
|
60
|
+
/** 卡片样式 */
|
40
61
|
style?: React.CSSProperties;
|
41
|
-
|
62
|
+
/** 卡片内容 class */
|
42
63
|
contentClassName?: string;
|
43
|
-
|
64
|
+
/** 卡片内容样式 */
|
44
65
|
contentStyle?: React.CSSProperties;
|
66
|
+
/** 上下文 */
|
67
|
+
context?: any;
|
45
68
|
}
|
46
|
-
declare const ProCard:
|
69
|
+
export declare const ProCard: {
|
70
|
+
(props: ProCardProps): JSX.Element;
|
71
|
+
defaultProps: {
|
72
|
+
bordered: boolean;
|
73
|
+
spacing: number;
|
74
|
+
direction: string;
|
75
|
+
};
|
76
|
+
Divider: {
|
77
|
+
(props: React.HTMLAttributes<HTMLElement>): JSX.Element;
|
78
|
+
isProCardDivider: boolean;
|
79
|
+
};
|
80
|
+
isProCard: boolean;
|
81
|
+
};
|
47
82
|
export default ProCard;
|
48
|
-
/**
|
49
|
-
* @deprecated 建议使用 ProCardContainer 代替
|
50
|
-
*/
|
51
|
-
export declare const CardContainer: React.FC<ProCardContainerProps>;
|
52
83
|
/**
|
53
84
|
* @deprecated 建议使用 ProCardProps 代替
|
54
85
|
*/
|
55
86
|
export declare type CardProps = ProCardProps;
|
56
|
-
/**
|
57
|
-
* @deprecated 建议使用 ProCardContainerProps 代替
|
58
|
-
*/
|
59
|
-
export declare type CardContainerProps = ProCardContainerProps;
|
package/es/card/index.js
CHANGED
@@ -1,65 +1,152 @@
|
|
1
|
+
var _excluded = ["context"],
|
2
|
+
_excluded2 = ["children", "title", "subTitle", "tooltip", "tooltipIcon", "description", "extra", "actions", "style", "className", "image", "divider", "bordered", "compacted", "centered", "loading", "backgroundColor", "contentClassName", "contentStyle", "direction", "wrap", "spacing", "split", "collapsible", "defaultCollapsed", "collapsed", "onCollapse", "context"];
|
3
|
+
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
5
|
+
|
6
|
+
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."); }
|
7
|
+
|
8
|
+
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); }
|
9
|
+
|
10
|
+
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; }
|
11
|
+
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
13
|
+
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
15
|
+
|
1
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
2
17
|
|
3
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
4
19
|
|
5
20
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
21
|
|
22
|
+
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; }
|
23
|
+
|
24
|
+
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; }
|
25
|
+
|
7
26
|
import React from 'react';
|
8
27
|
import classnames from 'classnames';
|
9
|
-
import { Card as BasicCard } from '@alicloudfe/components';
|
28
|
+
import { Card as BasicCard, Balloon } from '@alicloudfe/components';
|
29
|
+
import TeamixIcon from '@teamix/icon';
|
10
30
|
import { baseClass } from '@teamix/utils';
|
11
31
|
import { ProSkeletonRaw } from '../skeleton';
|
12
32
|
import { ProActionGroup } from '../actions';
|
33
|
+
import { formatSpacing, getColClassAndStyle } from './utils';
|
34
|
+
import ProCardDivider from './divider';
|
13
35
|
import './index.scss';
|
36
|
+
export * from './card-container';
|
14
37
|
var cls = baseClass('teamix-pro-card');
|
15
38
|
|
16
|
-
function
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
39
|
+
var renderActionGroup = function renderActionGroup(extra, context) {
|
40
|
+
if (!extra) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
|
44
|
+
if (extra.actions instanceof Array) {
|
45
|
+
var userContext = extra.context,
|
46
|
+
others = _objectWithoutProperties(extra, _excluded);
|
47
|
+
|
48
|
+
var mergedContext = _objectSpread(_objectSpread({}, context), userContext);
|
23
49
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
};
|
50
|
+
return /*#__PURE__*/React.createElement(ProActionGroup, _objectSpread(_objectSpread({
|
51
|
+
context: mergedContext
|
52
|
+
}, others), {}, {
|
53
|
+
type: "text"
|
54
|
+
}));
|
29
55
|
}
|
30
56
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
57
|
+
return extra;
|
58
|
+
};
|
59
|
+
|
60
|
+
var getFlexDirectionClassName = function getFlexDirectionClassName(direction, split) {
|
61
|
+
if (split) {
|
62
|
+
return "flex-direction-".concat(split === 'horizontal' ? 'row' : 'column');
|
36
63
|
}
|
37
64
|
|
38
|
-
return
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
};
|
44
|
-
}
|
65
|
+
return "flex-direction-".concat(direction);
|
66
|
+
};
|
67
|
+
|
68
|
+
export var ProCard = function ProCard(props) {
|
69
|
+
var _classnames;
|
45
70
|
|
46
|
-
export var ProCardContainer = function ProCardContainer(props) {
|
47
71
|
var children = props.children,
|
72
|
+
title = props.title,
|
73
|
+
subTitle = props.subTitle,
|
74
|
+
tooltip = props.tooltip,
|
75
|
+
tooltipIcon = props.tooltipIcon,
|
76
|
+
description = props.description,
|
77
|
+
extra = props.extra,
|
78
|
+
actions = props.actions,
|
48
79
|
style = props.style,
|
49
80
|
className = props.className,
|
50
|
-
|
81
|
+
image = props.image,
|
82
|
+
divider = props.divider,
|
83
|
+
bordered = props.bordered,
|
84
|
+
compacted = props.compacted,
|
85
|
+
centered = props.centered,
|
86
|
+
loading = props.loading,
|
87
|
+
backgroundColor = props.backgroundColor,
|
88
|
+
contentClassName = props.contentClassName,
|
89
|
+
contentStyle = props.contentStyle,
|
51
90
|
direction = props.direction,
|
52
|
-
wrap = props.wrap
|
91
|
+
wrap = props.wrap,
|
92
|
+
spacing = props.spacing,
|
93
|
+
split = props.split,
|
94
|
+
collapsible = props.collapsible,
|
95
|
+
defaultCollapsed = props.defaultCollapsed,
|
96
|
+
collapsed = props.collapsed,
|
97
|
+
onCollapse = props.onCollapse,
|
98
|
+
context = props.context,
|
99
|
+
others = _objectWithoutProperties(props, _excluded2);
|
100
|
+
|
101
|
+
var _React$useState = React.useState(defaultCollapsed !== undefined ? defaultCollapsed : false),
|
102
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
103
|
+
innerCollapseState = _React$useState2[0],
|
104
|
+
setInnerCollapseState = _React$useState2[1];
|
53
105
|
|
54
106
|
var _formatSpacing = formatSpacing(spacing),
|
55
107
|
horizonal = _formatSpacing.horizonal,
|
56
|
-
vertical = _formatSpacing.vertical;
|
108
|
+
vertical = _formatSpacing.vertical;
|
109
|
+
|
110
|
+
var hasDivider = (divider || !!split) && (title || extra);
|
111
|
+
var hasCollapse = collapsible === true || defaultCollapsed !== undefined || collapsed !== undefined;
|
112
|
+
var collapseState = collapsed !== undefined ? collapsed : innerCollapseState;
|
113
|
+
var showContent = hasCollapse ? !collapseState : true;
|
57
114
|
|
115
|
+
var onCollapseChanged = function onCollapseChanged() {
|
116
|
+
onCollapse && onCollapse(!collapseState);
|
117
|
+
|
118
|
+
if (collapsed !== undefined) {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
setInnerCollapseState(!collapseState);
|
123
|
+
};
|
124
|
+
|
125
|
+
var childCardStyle = split ? {} : {
|
126
|
+
paddingRight: horizonal,
|
127
|
+
paddingLeft: horizonal,
|
128
|
+
paddingTop: vertical,
|
129
|
+
paddingBottom: vertical
|
130
|
+
};
|
131
|
+
var dividerStyle = direction === 'row' || direction === 'row-reverse' ? {
|
132
|
+
marginTop: vertical,
|
133
|
+
marginBottom: vertical,
|
134
|
+
marginLeft: 20 - horizonal,
|
135
|
+
marginRight: 20 - horizonal
|
136
|
+
} : {
|
137
|
+
marginTop: 20 - vertical,
|
138
|
+
marginBottom: 20 - vertical,
|
139
|
+
marginLeft: horizonal,
|
140
|
+
marginRight: horizonal
|
141
|
+
}; // 判断是否套了卡片,如果套了的话,为自身卡片内容区设置负间距,以适配栅格系统
|
142
|
+
|
143
|
+
var containProCard = false; // 如果嵌套了 ProCard,为其添加一层栅格化的 col 和 padding
|
58
144
|
|
59
145
|
var childrenModified = React.Children.map(children, function (element, index) {
|
60
|
-
var _element$type;
|
146
|
+
var _element$type, _element$type2;
|
61
147
|
|
62
148
|
if (element === null || element === void 0 ? void 0 : (_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.isProCard) {
|
149
|
+
containProCard = true;
|
63
150
|
var col = element.props.col;
|
64
151
|
|
65
152
|
var _getColClassAndStyle = getColClassAndStyle(col),
|
@@ -67,97 +154,94 @@ export var ProCardContainer = function ProCardContainer(props) {
|
|
67
154
|
colStyle = _getColClassAndStyle.style;
|
68
155
|
|
69
156
|
return /*#__PURE__*/React.createElement("div", {
|
70
|
-
style: _objectSpread({
|
71
|
-
paddingRight: horizonal,
|
72
|
-
paddingLeft: horizonal,
|
73
|
-
paddingTop: vertical,
|
74
|
-
paddingBottom: vertical
|
75
|
-
}, colStyle),
|
157
|
+
style: _objectSpread(_objectSpread({}, childCardStyle), colStyle),
|
76
158
|
className: classnames(cls('col'), colClassName),
|
77
159
|
key: "pro-card-col-".concat(index)
|
78
160
|
}, /*#__PURE__*/React.cloneElement(element));
|
79
161
|
}
|
80
162
|
|
163
|
+
if (element === null || element === void 0 ? void 0 : (_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.isProCardDivider) {
|
164
|
+
console.log('isProCardDivider');
|
165
|
+
return /*#__PURE__*/React.cloneElement(element, {
|
166
|
+
style: dividerStyle
|
167
|
+
});
|
168
|
+
}
|
169
|
+
|
81
170
|
return element;
|
82
171
|
});
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
}
|
172
|
+
var cardClassName = classnames(cls(), className, backgroundColor, {
|
173
|
+
noBorder: !bordered,
|
174
|
+
compacted: compacted
|
175
|
+
});
|
176
|
+
var cardContentClassName = classnames(cls('content'), contentClassName, getFlexDirectionClassName(direction, split), (_classnames = {
|
177
|
+
'contain-pro-card': containProCard
|
178
|
+
}, _defineProperty(_classnames, "split-".concat(split), split), _defineProperty(_classnames, 'flex-wrap', wrap), _defineProperty(_classnames, "centered", centered), _classnames));
|
179
|
+
var cardContentMargin = containProCard && !split ? {
|
180
|
+
marginRight: -horizonal,
|
181
|
+
marginLeft: -horizonal,
|
182
|
+
marginTop: -vertical,
|
183
|
+
marginBottom: -vertical
|
184
|
+
} : {};
|
185
|
+
|
186
|
+
var cardContentStyle = _objectSpread(_objectSpread({}, cardContentMargin), contentStyle);
|
187
|
+
|
188
|
+
var renderTitle = function renderTitle() {
|
189
|
+
var icon = tooltipIcon || 'info-circle-line';
|
190
|
+
var tooltipTrigger = typeof icon === 'string' ? /*#__PURE__*/React.createElement(TeamixIcon, {
|
191
|
+
size: "small",
|
192
|
+
type: icon
|
193
|
+
}) : icon;
|
194
|
+
return /*#__PURE__*/React.createElement("div", {
|
195
|
+
className: cls('title')
|
196
|
+
}, hasCollapse && /*#__PURE__*/React.createElement("div", {
|
197
|
+
className: classnames(cls('title-collapse'), {
|
198
|
+
collapsed: collapseState
|
199
|
+
}),
|
200
|
+
onClick: onCollapseChanged
|
201
|
+
}, /*#__PURE__*/React.createElement(TeamixIcon, {
|
202
|
+
size: "small",
|
203
|
+
type: "down-fill"
|
204
|
+
}), /*#__PURE__*/React.createElement("div", {
|
205
|
+
className: cls('title-name')
|
206
|
+
}, title)), !hasCollapse && /*#__PURE__*/React.createElement("div", {
|
207
|
+
className: cls('title-name')
|
208
|
+
}, title), tooltip && /*#__PURE__*/React.createElement("div", {
|
209
|
+
className: cls('title-tooltip')
|
210
|
+
}, /*#__PURE__*/React.createElement(Balloon.Tooltip, {
|
211
|
+
align: "t",
|
212
|
+
trigger: tooltipTrigger
|
213
|
+
}, tooltip)), description && /*#__PURE__*/React.createElement("div", {
|
214
|
+
className: cls('title-description')
|
215
|
+
}, description));
|
216
|
+
};
|
111
217
|
|
112
|
-
|
113
|
-
var children = props.children,
|
114
|
-
title = props.title,
|
115
|
-
subTitle = props.subTitle,
|
116
|
-
extra = props.extra,
|
117
|
-
style = props.style,
|
118
|
-
className = props.className,
|
119
|
-
image = props.image,
|
120
|
-
divider = props.divider,
|
121
|
-
bordered = props.bordered,
|
122
|
-
hoveredShadow = props.hoveredShadow,
|
123
|
-
compacted = props.compacted,
|
124
|
-
centered = props.centered,
|
125
|
-
loading = props.loading,
|
126
|
-
backgroundColor = props.backgroundColor,
|
127
|
-
contentClassName = props.contentClassName,
|
128
|
-
contentStyle = props.contentStyle;
|
129
|
-
return /*#__PURE__*/React.createElement(BasicCard, {
|
218
|
+
return /*#__PURE__*/React.createElement(BasicCard, _objectSpread({
|
130
219
|
free: true,
|
131
|
-
className:
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
}),
|
136
|
-
style: style
|
137
|
-
}, !loading && image && /*#__PURE__*/React.createElement(BasicCard.Media, {
|
220
|
+
className: cardClassName,
|
221
|
+
style: style,
|
222
|
+
actions: renderActionGroup(actions, context)
|
223
|
+
}, others), !loading && image && /*#__PURE__*/React.createElement(BasicCard.Media, {
|
138
224
|
component: "img",
|
139
225
|
src: image
|
140
226
|
}), (title || extra) && /*#__PURE__*/React.createElement(BasicCard.Header, {
|
141
|
-
title: loading ? /*#__PURE__*/React.createElement(ProSkeletonRaw.Card.Title, null) :
|
227
|
+
title: loading ? /*#__PURE__*/React.createElement(ProSkeletonRaw.Card.Title, null) : renderTitle(),
|
142
228
|
subTitle: !loading && subTitle,
|
143
|
-
extra: !loading &&
|
144
|
-
}),
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
}, loading && /*#__PURE__*/React.createElement(ProSkeletonRaw.Card.Content, null), !loading &&
|
229
|
+
extra: !loading && renderActionGroup(extra, context)
|
230
|
+
}), hasDivider && /*#__PURE__*/React.createElement(BasicCard.Divider, null), showContent && /*#__PURE__*/React.createElement(BasicCard.Content, {
|
231
|
+
style: split ? {
|
232
|
+
padding: 0,
|
233
|
+
margin: 0
|
234
|
+
} : {}
|
235
|
+
}, loading && /*#__PURE__*/React.createElement(ProSkeletonRaw.Card.Content, null), !loading && /*#__PURE__*/React.createElement("div", {
|
236
|
+
className: cardContentClassName,
|
237
|
+
style: cardContentStyle
|
238
|
+
}, childrenModified)));
|
150
239
|
};
|
151
|
-
|
152
240
|
ProCard.defaultProps = {
|
153
241
|
bordered: true,
|
154
|
-
|
155
|
-
|
156
|
-
|
242
|
+
spacing: 16,
|
243
|
+
direction: 'row'
|
244
|
+
};
|
245
|
+
ProCard.Divider = ProCardDivider;
|
157
246
|
ProCard.isProCard = true;
|
158
|
-
export default ProCard;
|
159
|
-
/**
|
160
|
-
* @deprecated 建议使用 ProCardContainer 代替
|
161
|
-
*/
|
162
|
-
|
163
|
-
export var CardContainer = ProCardContainer;
|
247
|
+
export default ProCard;
|