Skip to content

Commit 8202d8c

Browse files
committed
merge feat-v4
2 parents 7f64e15 + 4ccb1c3 commit 8202d8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1504
-1311
lines changed

components/_util/transKeys.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const groupKeysMap = (keys: string[]) => {
2+
const map = new Map<string, number>();
3+
keys.forEach((key, index) => {
4+
map.set(key, index);
5+
});
6+
return map;
7+
};
8+
9+
export const groupDisabledKeysMap = <RecordType extends any[]>(dataSource: RecordType) => {
10+
const map = new Map<string, number>();
11+
dataSource.forEach(({ disabled, key }, index) => {
12+
if (disabled) {
13+
map.set(key, index);
14+
}
15+
});
16+
return map;
17+
};

components/card/Card.tsx

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { VNodeTypes, PropType, VNode, ExtractPropTypes, CSSProperties } from 'vue';
22
import { isVNode, defineComponent, renderSlot } from 'vue';
33
import Tabs from '../tabs';
4-
import Row from '../row';
5-
import Col from '../col';
64
import PropTypes from '../_util/vue-types';
75
import { flattenChildren, isEmptyElement, filterEmptyWithUndefined } from '../_util/props-util';
86
import type { SizeType } from '../config-provider';
97
import isPlainObject from 'lodash-es/isPlainObject';
108
import useConfigInject from '../config-provider/hooks/useConfigInject';
119
import devWarning from '../vc-util/devWarning';
10+
import useStyle from './style';
11+
import Skeleton from '../skeleton';
1212
export interface CardTabListType {
1313
key: string;
1414
tab: any;
@@ -51,10 +51,12 @@ export type CardProps = Partial<ExtractPropTypes<ReturnType<typeof cardProps>>>;
5151
const Card = defineComponent({
5252
compatConfig: { MODE: 3 },
5353
name: 'ACard',
54+
inheritAttrs: false,
5455
props: cardProps(),
5556
slots: ['title', 'extra', 'tabBarExtraContent', 'actions', 'cover', 'customTab'],
56-
setup(props, { slots }) {
57+
setup(props, { slots, attrs }) {
5758
const { prefixCls, direction, size } = useConfigInject('card', props);
59+
const [wrapSSR, hashId] = useStyle(prefixCls);
5860
const getAction = (actions: VNodeTypes[]) => {
5961
const actionList = actions.map((action, index) =>
6062
(isVNode(action) && !isEmptyElement(action)) || !isVNode(action) ? (
@@ -99,6 +101,7 @@ const Card = defineComponent({
99101
const pre = prefixCls.value;
100102
const classString = {
101103
[`${pre}`]: true,
104+
[hashId.value]: true,
102105
[`${pre}-loading`]: loading,
103106
[`${pre}-bordered`]: bordered,
104107
[`${pre}-hoverable`]: !!hoverable,
@@ -108,34 +111,10 @@ const Card = defineComponent({
108111
[`${pre}-type-${type}`]: !!type,
109112
[`${pre}-rtl`]: direction.value === 'rtl',
110113
};
111-
112-
const loadingBlockStyle =
113-
bodyStyle.padding === 0 || bodyStyle.padding === '0px' ? { padding: '24px' } : undefined;
114-
115-
const block = <div class={`${pre}-loading-block`} />;
116114
const loadingBlock = (
117-
<div class={`${pre}-loading-content`} style={loadingBlockStyle}>
118-
<Row gutter={8}>
119-
<Col span={22}>{block}</Col>
120-
</Row>
121-
<Row gutter={8}>
122-
<Col span={8}>{block}</Col>
123-
<Col span={15}>{block}</Col>
124-
</Row>
125-
<Row gutter={8}>
126-
<Col span={6}>{block}</Col>
127-
<Col span={18}>{block}</Col>
128-
</Row>
129-
<Row gutter={8}>
130-
<Col span={13}>{block}</Col>
131-
<Col span={9}>{block}</Col>
132-
</Row>
133-
<Row gutter={8}>
134-
<Col span={4}>{block}</Col>
135-
<Col span={3}>{block}</Col>
136-
<Col span={16}>{block}</Col>
137-
</Row>
138-
</div>
115+
<Skeleton loading active paragraph={{ rows: 4 }} title={false}>
116+
{children}
117+
</Skeleton>
139118
);
140119

141120
const hasActiveTabKey = activeTabKey !== undefined;
@@ -190,13 +169,13 @@ const Card = defineComponent({
190169
const actionDom =
191170
actions && actions.length ? <ul class={`${pre}-actions`}>{getAction(actions)}</ul> : null;
192171

193-
return (
194-
<div class={classString} ref="cardContainerRef">
172+
return wrapSSR(
173+
<div ref="cardContainerRef" {...attrs} class={[classString, attrs.class]}>
195174
{head}
196175
{coverDom}
197176
{children && children.length ? body : null}
198177
{actionDom}
199-
</div>
178+
</div>,
200179
);
201180
};
202181
},

components/card/Meta.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { ExtractPropTypes } from 'vue';
22
import { defineComponent } from 'vue';
3-
import PropTypes from '../_util/vue-types';
43
import { getPropsSlot } from '../_util/props-util';
54
import useConfigInject from '../config-provider/hooks/useConfigInject';
5+
import { vNodeType } from '../_util/type';
66

77
export const cardMetaProps = () => ({
88
prefixCls: String,
9-
title: PropTypes.any,
10-
description: PropTypes.any,
11-
avatar: PropTypes.any,
9+
title: vNodeType(),
10+
description: vNodeType(),
11+
avatar: vNodeType(),
1212
});
1313
export type CardGridProps = Partial<ExtractPropTypes<ReturnType<typeof cardMetaProps>>>;
1414
export default defineComponent({

components/card/index.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
category: Components
33
type: Data Display
44
title: Card
5-
cover: https://gw.alipayobjects.com/zos/antfincdn/NqXt8DJhky/Card.svg
5+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*VXtCTp93KPAAAAAAAAAAAAAADrJ8AQ/original
66
---
77

88
Simple rectangular container.

components/card/index.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
type: 数据展示
44
title: Card
55
subtitle: 卡片
6-
cover: https://gw.alipayobjects.com/zos/antfincdn/NqXt8DJhky/Card.svg
6+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*VXtCTp93KPAAAAAAAAAAAAAADrJ8AQ/original
77
---
88

99
通用卡片容器

0 commit comments

Comments
 (0)