Skip to content

Commit 6f3fca4

Browse files
committed
feat: support [email protected]
1 parent 4135161 commit 6f3fca4

File tree

19 files changed

+151
-114
lines changed

19 files changed

+151
-114
lines changed

components/_util/transition.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { BaseTransitionProps, CSSProperties, Ref } from 'vue';
2-
import { getCurrentInstance, onUpdated } from 'vue';
1+
import { BaseTransitionProps, CSSProperties, onBeforeUpdate, Ref } from 'vue';
2+
import { getCurrentInstance } from 'vue';
33
import { defineComponent, nextTick, Transition as T, TransitionGroup as TG } from 'vue';
44

55
export const getTransitionProps = (transitionName: string, opt: object = {}) => {
@@ -51,7 +51,7 @@ if (process.env.NODE_ENV === 'test') {
5151
inheritAttrs: false,
5252
setup(_props, { slots, attrs }) {
5353
const instance = getCurrentInstance();
54-
onUpdated(() => {
54+
onBeforeUpdate(() => {
5555
const child = instance.subTree.children[0];
5656
if (child && child.dirs && child.dirs[0]) {
5757
const value = child.dirs[0].value;

components/auto-complete/InputElement.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

components/auto-complete/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { App, Plugin, VNode, ExtractPropTypes } from 'vue';
22
import { defineComponent, inject, provide } from 'vue';
33
import Select, { SelectProps } from '../select';
44
import Input from '../input';
5-
import InputElement from './InputElement';
65
import PropTypes from '../_util/vue-types';
76
import { defaultConfigProvider } from '../config-provider';
87
import { getComponent, getOptionProps, isValidElement, getSlot } from '../_util/props-util';
@@ -72,7 +71,7 @@ const AutoComplete = defineComponent({
7271
getInputElement() {
7372
const children = getSlot(this);
7473
const element = children.length ? children[0] : <Input lazy={false} />;
75-
return <InputElement {...element.props}>{element}</InputElement>;
74+
return element;
7675
},
7776

7877
focus() {

components/cascader/__tests__/__snapshots__/index.test.js.snap

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,33 @@ exports[`Cascader popup correctly with defaultValue 1`] = `
113113
</div>
114114
`;
115115

116-
exports[`Cascader support controlled mode 1`] = `<!----><span class="ant-cascader-picker" tabindex="0"><span class="ant-cascader-picker-label">Zhejiang / Hangzhou / West Lake</span><input type="text" readonly="" autocomplete="off" class="ant-input ant-cascader-input "><span tabindex="-1" role="img" aria-label="close-circle" class="anticon anticon-close-circle ant-cascader-picker-clear"><svg focusable="false" class="" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path></svg></span><span role="img" aria-label="down" class="anticon anticon-down ant-cascader-picker-arrow"><svg focusable="false" class="" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></span></span>`;
116+
exports[`Cascader popup correctly with defaultValue 2`] = `
117+
<div>
118+
<!---->
119+
<div class="ant-cascader-menus ant-cascader-menus-placement-bottomLeft">
120+
<div>
121+
<ul class="ant-cascader-menu">
122+
<li class="ant-cascader-menu-item ant-cascader-menu-item-expand ant-cascader-menu-item-active" title="Zhejiang" role="menuitem">Zhejiang<span class="ant-cascader-menu-item-expand-icon"><span role="img" aria-label="right" class="anticon anticon-right"><svg focusable="false" class="" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></span>
123+
<!---->
124+
</li>
125+
<li class="ant-cascader-menu-item ant-cascader-menu-item-expand" title="Jiangsu" role="menuitem">Jiangsu<span class="ant-cascader-menu-item-expand-icon"><span role="img" aria-label="right" class="anticon anticon-right"><svg focusable="false" class="" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></span>
126+
<!---->
127+
</li>
128+
</ul>
129+
<ul class="ant-cascader-menu">
130+
<li class="ant-cascader-menu-item ant-cascader-menu-item-expand ant-cascader-menu-item-active" title="Hangzhou" role="menuitem">Hangzhou<span class="ant-cascader-menu-item-expand-icon"><span role="img" aria-label="right" class="anticon anticon-right"><svg focusable="false" class="" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg></span></span>
131+
<!---->
132+
</li>
133+
</ul>
134+
<ul class="ant-cascader-menu">
135+
<li class="ant-cascader-menu-item" title="West Lake" role="menuitem">West Lake
136+
<!---->
137+
<!---->
138+
</li>
139+
</ul>
140+
</div>
141+
</div>
142+
</div>
143+
`;
144+
145+
exports[`Cascader support controlled mode 1`] = `<!----><span class="ant-cascader-picker" tabindex="0"><span class="ant-cascader-picker-label">Zhejiang / Hangzhou / West Lake</span><input type="text" readonly="" autocomplete="off" class="ant-input ant-cascader-input"><span tabindex="-1" role="img" aria-label="close-circle" class="anticon anticon-close-circle ant-cascader-picker-clear"><svg focusable="false" class="" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path></svg></span><span role="img" aria-label="down" class="anticon anticon-down ant-cascader-picker-arrow"><svg focusable="false" class="" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></span></span>`;

components/drawer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const Drawer = defineComponent({
123123
}
124124
if (!this.visible) {
125125
this.destroyClose = true;
126-
this.$forceUpdate();
126+
(this as any).$forceUpdate();
127127
}
128128
},
129129

components/input/Input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export default defineComponent({
128128
if (!hasProp(this, 'value')) {
129129
this.stateValue = value;
130130
} else {
131-
this.$forceUpdate();
131+
(this as any).$forceUpdate();
132132
}
133133
nextTick(() => {
134134
callback && callback();

components/input/TextArea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default defineComponent({
5555
if (!hasProp(this, 'value')) {
5656
this.stateValue = value;
5757
} else {
58-
this.$forceUpdate();
58+
(this as any).$forceUpdate();
5959
}
6060
nextTick(() => {
6161
callback && callback();

components/menu/src/MenuItem.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { MenuInfo } from './interface';
1010
import KeyCode from '../../_util/KeyCode';
1111
import useDirectionStyle from './hooks/useDirectionStyle';
1212
import Overflow from '../../vc-overflow';
13+
import devWarning from '../../vc-util/devWarning';
1314

1415
let indexGuid = 0;
1516
const menuItemProps = {
@@ -30,7 +31,15 @@ export default defineComponent({
3031
slots: ['icon', 'title'],
3132
setup(props, { slots, emit, attrs }) {
3233
const instance = getCurrentInstance();
33-
const key = instance.vnode.key;
34+
35+
const key =
36+
typeof instance.vnode.key === 'symbol' ? String(instance.vnode.key) : instance.vnode.key;
37+
devWarning(
38+
typeof instance.vnode.key !== 'symbol',
39+
'MenuItem',
40+
`MenuItem \`:key="${String(key)}"\` not support Symbol type`,
41+
);
42+
3443
const eventKey = `menu_item_${++indexGuid}_$$_${key}`;
3544
const { parentEventKeys, parentKeys } = useInjectKeyPath();
3645
const {

components/menu/src/SubMenu.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import InlineSubMenuList from './InlineSubMenuList';
1212
import Transition, { getTransitionProps } from '../../_util/transition';
1313
import { cloneElement } from '../../_util/vnode';
1414
import Overflow from '../../vc-overflow';
15+
import devWarning from '../../vc-util/devWarning';
16+
import isValid from '../../_util/isValid';
1517

1618
let indexGuid = 0;
1719

@@ -39,14 +41,17 @@ export default defineComponent({
3941
useProvideFirstLevel(false);
4042

4143
const instance = getCurrentInstance();
42-
const key =
43-
instance.vnode.key !== null ? instance.vnode.key : `sub_menu_${++indexGuid}_$$_not_set_key`;
44-
44+
const vnodeKey =
45+
typeof instance.vnode.key === 'symbol' ? String(instance.vnode.key) : instance.vnode.key;
46+
devWarning(
47+
typeof instance.vnode.key !== 'symbol',
48+
'SubMenu',
49+
`SubMenu \`:key="${String(vnodeKey)}"\` not support Symbol type`,
50+
);
51+
const key = isValid(vnodeKey) ? vnodeKey : `sub_menu_${++indexGuid}_$$_not_set_key`;
4552
const eventKey =
4653
props.eventKey ??
47-
(instance.vnode.key !== null
48-
? `sub_menu_${++indexGuid}_$$_${instance.vnode.key}`
49-
: (key as string));
54+
(isValid(vnodeKey) ? `sub_menu_${++indexGuid}_$$_${vnodeKey}` : (key as string));
5055
const { parentEventKeys, parentInfo, parentKeys } = useInjectKeyPath();
5156
const keysPath = computed(() => [...parentKeys.value, key]);
5257
const eventKeysPath = computed(() => [...parentEventKeys.value, eventKey]);

components/table/filterDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default defineComponent({
9898
this.setVisible(false);
9999
// Call `setSelectedKeys` & `confirm` in the same time will make filter data not up to date
100100
// https://github.com/ant-design/ant-design/issues/12284
101-
this.$forceUpdate();
101+
(this as any).$forceUpdate();
102102
nextTick(this.confirmFilter2);
103103
},
104104

0 commit comments

Comments
 (0)