Skip to content

Commit 6f8a139

Browse files
authored
refactor: datePicker & calendar & trigger (#4522)
1 parent 75724dc commit 6f8a139

File tree

691 files changed

+18007
-13889
lines changed

Some content is hidden

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

691 files changed

+18007
-13889
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,5 @@ site/dev.js
7373

7474
# IDE 语法提示临时文件
7575
vetur/
76+
77+
report.html

CHANGELOG.en-US.md

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010

1111
---
1212

13+
## 2.2.6
14+
15+
`2021-08-12`
16+
17+
- 🐞 Fix `Table` expanded list rendering problem [#4507](https://github.com/vueComponent/ant-design-vue/issues/4507)
18+
- 🐞 Fix `Rate` custom `character` slot not taking effect [#4509](https://github.com/vueComponent/ant-design-vue/issues/4509)
19+
- 🐞 Add resize-observer-polyfill to fix the problem of reporting errors in low versions of Chrome [#4508](https://github.com/vueComponent/ant-design-vue/issues/4508)
20+
21+
## 2.2.5
22+
23+
`2021-08-11`
24+
25+
- 🌟 `Select` supports customizing nodes through option slots [68c1f4](https://github.com/vueComponent/ant-design-vue/commit/68c1f4550108a3a6bbe4f1b2c5c168523fd6c84a)
26+
- 🐞 Fix the problem that the pop-up window component in the development environment does not display in the lower version of chrome, and avoid the pop-up window flashing [#4409](https://github.com/vueComponent/ant-design-vue/issues/4409)
27+
- 🐞 Fix the problem of not scrolling to the active position when `Select` is opened [ccb240](https://github.com/vueComponent/ant-design-vue/commit/ccb24016c07632f49550646c971060c402586c67)
28+
29+
## 2.2.4
30+
31+
`2021-08-10`
32+
33+
- 🌟 Support [email protected] [#4490](https://github.com/vueComponent/ant-design-vue/issues/4490)
34+
- 🌟 Automatically hide the horizontal scroll bar of `Table` [#4484](https://github.com/vueComponent/ant-design-vue/issues/4484)
35+
- 🐞 Fix the issue of `Progress` trailColor not taking effect [#4483](https://github.com/vueComponent/ant-design-vue/issues/4483)
36+
1337
## 2.2.3
1438

1539
`2021-08-07`

CHANGELOG.zh-CN.md

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010

1111
---
1212

13+
## 2.2.6
14+
15+
`2021-08-12`
16+
17+
- 🐞 修复 `Table` 展开列表渲染错位问题 [#4507](https://github.com/vueComponent/ant-design-vue/issues/4507)
18+
- 🐞 修复 `Rate` 自定义 `character` 插槽未生效问题 [#4509](https://github.com/vueComponent/ant-design-vue/issues/4509)
19+
- 🐞 添加 resize-observer-polyfill, 修复在低版本 Chrome 下报错问题 [#4508](https://github.com/vueComponent/ant-design-vue/issues/4508)
20+
21+
## 2.2.5
22+
23+
`2021-08-11`
24+
25+
- 🌟 `Select` 支持通过 option 插槽定制化节点 [68c1f4](https://github.com/vueComponent/ant-design-vue/commit/68c1f4550108a3a6bbe4f1b2c5c168523fd6c84a)
26+
- 🐞 修复开发环境下弹窗类组件在低版本 chrome 下,不显示问题,并避免弹窗闪动 [#4409](https://github.com/vueComponent/ant-design-vue/issues/4409)
27+
- 🐞 修复 `Select` 打开时没有滚动到激活位置问题 [ccb240](https://github.com/vueComponent/ant-design-vue/commit/ccb24016c07632f49550646c971060c402586c67)
28+
29+
## 2.2.4
30+
31+
`2021-08-10`
32+
33+
- 🌟 支持 [email protected] [#4490](https://github.com/vueComponent/ant-design-vue/issues/4490)
34+
- 🌟 自动隐藏 `Table` 横向滚动条 [#4484](https://github.com/vueComponent/ant-design-vue/issues/4484)
35+
- 🐞 修复 `Progress` trailColor 不生效问题 [#4483](https://github.com/vueComponent/ant-design-vue/issues/4483)
36+
1337
## 2.2.3
1438

1539
`2021-08-07`

antd-tools/getWebpackConfig.js

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ function getWebpackConfig(modules) {
8080
},
8181

8282
module: {
83-
noParse: [/moment.js/],
8483
rules: [
8584
{
8685
test: /\.vue$/,

components/_util/EventInterface.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export type FocusEventHandler = (e: FocusEvent) => void;
2+
export type MouseEventHandler = (e: MouseEvent) => void;
3+
export type KeyboardEventHandler = (e: KeyboardEvent) => void;
4+
export type ChangeEvent = Event & {
5+
target: {
6+
value?: string | undefined;
7+
};
8+
};

components/_util/Portal.js

+25-35
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,38 @@
11
import PropTypes from './vue-types';
2-
import { defineComponent, nextTick, Teleport } from 'vue';
2+
import {
3+
defineComponent,
4+
nextTick,
5+
onBeforeUnmount,
6+
onMounted,
7+
onUpdated,
8+
ref,
9+
Teleport,
10+
} from 'vue';
311

412
export default defineComponent({
513
name: 'Portal',
14+
inheritAttrs: false,
615
props: {
716
getContainer: PropTypes.func.isRequired,
8-
children: PropTypes.any.isRequired,
917
didUpdate: PropTypes.func,
1018
},
11-
data() {
12-
this._container = null;
13-
return {};
14-
},
15-
mounted() {
16-
this.createContainer();
17-
},
18-
updated() {
19-
const { didUpdate } = this.$props;
20-
if (didUpdate) {
19+
setup(props, { slots }) {
20+
const container = ref();
21+
onMounted(() => {
22+
container.value = props.getContainer();
23+
});
24+
onUpdated(() => {
2125
nextTick(() => {
22-
didUpdate(this.$props);
26+
props.nextTick?.(props);
2327
});
24-
}
25-
},
26-
27-
beforeUnmount() {
28-
this.removeContainer();
29-
},
30-
methods: {
31-
createContainer() {
32-
this._container = this.$props.getContainer();
33-
this.$forceUpdate();
34-
},
35-
removeContainer() {
36-
if (this._container && this._container.parentNode) {
37-
this._container.parentNode.removeChild(this._container);
28+
});
29+
onBeforeUnmount(() => {
30+
if (container.value && container.value.parentNode) {
31+
container.value.parentNode.removeChild(container.value);
3832
}
39-
},
40-
},
41-
42-
render() {
43-
if (this._container) {
44-
return <Teleport to={this._container}>{this.$props.children}</Teleport>;
45-
}
46-
return null;
33+
});
34+
return () => {
35+
return container.value ? <Teleport to={container.value}>{slots.default?.()}</Teleport> : null;
36+
};
4737
},
4838
});

components/_util/PortalWrapper.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default defineComponent({
2020
wrapperClassName: PropTypes.string,
2121
forceRender: PropTypes.looseBool,
2222
getContainer: PropTypes.any,
23-
children: PropTypes.func,
2423
visible: PropTypes.looseBool,
2524
},
2625
data() {
@@ -130,7 +129,7 @@ export default defineComponent({
130129
},
131130

132131
render() {
133-
const { children, forceRender, visible } = this.$props;
132+
const { forceRender, visible } = this.$props;
134133
let portal = null;
135134
const childProps = {
136135
getOpenCount: () => openCount,
@@ -141,8 +140,8 @@ export default defineComponent({
141140
portal = (
142141
<Portal
143142
getContainer={this.getDomContainer}
144-
children={children(childProps)}
145143
ref={this.savePortal}
144+
v-slots={{ default: () => this.$slots.default?.(childProps) }}
146145
></Portal>
147146
);
148147
}

components/_util/hooks/useConfigInject.ts

+6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ export default (
1010
): {
1111
configProvider: UnwrapRef<ConfigProviderProps>;
1212
prefixCls: ComputedRef<string>;
13+
rootPrefixCls: ComputedRef<string>;
1314
direction: ComputedRef<Direction>;
1415
size: ComputedRef<SizeType>;
1516
getTargetContainer: ComputedRef<() => HTMLElement>;
17+
getPopupContainer: ComputedRef<() => HTMLElement>;
1618
space: ComputedRef<{ size: SizeType | number }>;
1719
pageHeader: ComputedRef<{ ghost: boolean }>;
1820
form?: ComputedRef<{
@@ -26,6 +28,7 @@ export default (
2628
defaultConfigProvider,
2729
);
2830
const prefixCls = computed(() => configProvider.getPrefixCls(name, props.prefixCls));
31+
const rootPrefixCls = computed(() => configProvider.getPrefixCls());
2932
const direction = computed(() => configProvider.direction);
3033
const autoInsertSpaceInButton = computed(() => configProvider.autoInsertSpaceInButton);
3134
const renderEmpty = computed(() => configProvider.renderEmpty);
@@ -34,16 +37,19 @@ export default (
3437
const form = computed(() => configProvider.form);
3538
const size = computed(() => props.size || configProvider.componentSize);
3639
const getTargetContainer = computed(() => props.getTargetContainer);
40+
const getPopupContainer = computed(() => props.getPopupContainer);
3741
return {
3842
configProvider,
3943
prefixCls,
4044
direction,
4145
size,
4246
getTargetContainer,
47+
getPopupContainer,
4348
space,
4449
pageHeader,
4550
form,
4651
autoInsertSpaceInButton,
4752
renderEmpty,
53+
rootPrefixCls,
4854
};
4955
};

components/_util/hooks/useMemo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { Ref } from 'vue';
1+
import type { Ref, WatchSource } from 'vue';
22
import { ref, watch } from 'vue';
33

44
export default function useMemo<T>(
55
getValue: () => T,
6-
condition: any[],
6+
condition: (WatchSource<unknown> | object)[],
77
shouldUpdate?: (prev: any[], next: any[]) => boolean,
88
) {
99
const cacheRef: Ref<T> = ref(getValue() as any);
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { Ref, UnwrapRef } from 'vue';
2+
import { toRaw } from 'vue';
3+
import { watchEffect } from 'vue';
4+
import { unref } from 'vue';
5+
import { watch } from 'vue';
6+
import { ref } from 'vue';
7+
8+
export default function useMergedState<T, R = Ref<T>>(
9+
defaultStateValue: T | (() => T),
10+
option?: {
11+
defaultValue?: T | (() => T);
12+
value?: Ref<T> | Ref<UnwrapRef<T>>;
13+
onChange?: (val: T, prevValue: T) => void;
14+
postState?: (val: T) => T;
15+
},
16+
): [R, (val: T) => void] {
17+
const { defaultValue, value = ref() } = option || {};
18+
let initValue: T =
19+
typeof defaultStateValue === 'function' ? (defaultStateValue as any)() : defaultStateValue;
20+
if (value.value !== undefined) {
21+
initValue = unref(value as any) as T;
22+
}
23+
if (defaultValue !== undefined) {
24+
initValue = typeof defaultValue === 'function' ? (defaultValue as any)() : defaultValue;
25+
}
26+
27+
const innerValue = ref(initValue) as Ref<T>;
28+
const mergedValue = ref(initValue) as Ref<T>;
29+
watchEffect(() => {
30+
let val = value.value !== undefined ? value.value : innerValue.value;
31+
if (option.postState) {
32+
val = option.postState(val as T);
33+
}
34+
mergedValue.value = val as T;
35+
});
36+
37+
function triggerChange(newValue: T) {
38+
const preVal = mergedValue.value;
39+
innerValue.value = newValue;
40+
if (toRaw(mergedValue.value) !== newValue && option.onChange) {
41+
option.onChange(newValue, preVal);
42+
}
43+
}
44+
45+
// Effect of reset value to `undefined`
46+
watch(value, () => {
47+
innerValue.value = value.value as T;
48+
});
49+
50+
return [mergedValue as unknown as R, triggerChange];
51+
}

components/_util/hooks/useState.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Ref } from 'vue';
2+
import { ref } from 'vue';
3+
4+
export default function useState<T, R = Ref<T>>(
5+
defaultStateValue: T | (() => T),
6+
): [R, (val: T) => void] {
7+
const initValue: T =
8+
typeof defaultStateValue === 'function' ? (defaultStateValue as any)() : defaultStateValue;
9+
10+
const innerValue = ref(initValue) as Ref<T>;
11+
12+
function triggerChange(newValue: T) {
13+
innerValue.value = newValue;
14+
}
15+
16+
return [innerValue as unknown as R, triggerChange];
17+
}

components/_util/interopDefault.js

-4
This file was deleted.

components/_util/moment-util.js

-75
This file was deleted.

0 commit comments

Comments
 (0)