Skip to content

Commit b0990b7

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat-v4
2 parents 5376014 + c36b69d commit b0990b7

File tree

22 files changed

+128
-63
lines changed

22 files changed

+128
-63
lines changed

components/button/__tests__/index.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { nextTick } from 'vue';
55
import { asyncExpect, sleep } from '../../../tests/utils';
66
import mountTest from '../../../tests/shared/mountTest';
77
import { resetWarned } from '../../_util/warning';
8+
import focusTest from '../../../tests/shared/focusTest';
89

910
describe('Button', () => {
1011
mountTest(Button);
1112
mountTest(Button.Group);
13+
focusTest(Button);
1214
it('renders correctly', () => {
1315
const wrapper = mount({
1416
render() {

components/button/button.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default defineComponent({
3838
props: initDefaultProps(buttonProps(), { type: 'default' }),
3939
slots: ['icon'],
4040
// emits: ['click', 'mousedown'],
41-
setup(props, { slots, attrs, emit }) {
41+
setup(props, { slots, attrs, emit, expose }) {
4242
const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject('btn', props);
4343
const [wrapSSR, hashId] = useStyle(prefixCls);
4444
const groupSizeContext = GroupSizeContext.useInject();
@@ -157,6 +157,17 @@ export default defineComponent({
157157
delayTimeoutRef.value && clearTimeout(delayTimeoutRef.value);
158158
});
159159

160+
const focus = () => {
161+
buttonNodeRef.value?.focus();
162+
};
163+
const blur = () => {
164+
buttonNodeRef.value?.blur();
165+
};
166+
expose({
167+
focus,
168+
blur,
169+
});
170+
160171
return () => {
161172
const { icon = slots.icon?.() } = props;
162173
const children = flattenChildren(slots.default?.());

components/button/index.en-US.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ It accepts all props which native buttons support.
5656

5757
## FAQ
5858

59+
### Methods
60+
61+
#### Checkbox
62+
63+
| Name | Description | Version |
64+
| ------- | ------------ | ------- |
65+
| blur() | remove focus | |
66+
| focus() | get focus | |
67+
5968
### How to remove space between 2 chinese characters
6069

6170
Following the Ant Design specification, we will add one space between if Button (exclude Text button and Link button) contains two Chinese characters only. If you don't need that, you can use [ConfigProvider](/components/config-provider/#api) to set `autoInsertSpaceInButton` as `false`.

components/button/index.zh-CN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*Lp1kTYmSsgoAAA
5757

5858
支持原生 button 的其他所有属性。
5959

60+
### 方法
61+
62+
#### Button
63+
64+
| 名称 | 描述 | 版本 |
65+
| ------- | -------- | ---- |
66+
| blur() | 移除焦点 | |
67+
| focus() | 获取焦点 | |
68+
6069
## FAQ
6170

6271
### 如何移除 2 个汉字之间的空格

components/date-picker/index.en-US.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,20 @@ Please refer [replace date](/docs/vue/replace-date)
211211
### Why config dayjs.locale globally not work?
212212

213213
DatePicker default set `locale` as `en` in v4. You can config DatePicker `locale` prop or [ConfigProvider `locale`](/components/config-provider) prop instead.
214+
215+
### How to modify start day of week?
216+
217+
Please use correct [language](/docs/vue/i18n) ([#5605](https://github.com/ant-design/ant-design/issues/5605)), or update dayjs `locale` config:
218+
219+
- Example: <https://codesandbox.io/s/dayjs-day-of-week-x9tuj2?file=/demo.tsx>
220+
221+
```js
222+
import dayjs from 'dayjs';
223+
import updateLocale from 'dayjs/plugin/updateLocale';
224+
import 'dayjs/locale/zh-cn';
225+
226+
dayjs.extend(updateLocale);
227+
dayjs.updateLocale('zh-cn', {
228+
weekStart: 0,
229+
});
230+
```

components/date-picker/index.zh-CN.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,18 @@ export type FormatType = Generic | GenericFn | Array<Generic | GenericFn>;
212212
### 为何全局修改 dayjs.locale 不生效?
213213

214214
DatePicker 默认 `locale``en`。你可以通过 DatePicker 的 `locale` 属性来单独设置,也可以通过 [ConfigProvider `locale`](/components/config-provider-cn) 属性来配置。
215+
216+
### 如何修改周的起始日?
217+
218+
请使用正确的[语言包](/docs/vue/i18n-cn)[#5605](https://github.com/ant-design/ant-design/issues/5605)),或者修改 dayjs 的 `locale` 配置:<https://codesandbox.io/s/dayjs-day-of-week-x9tuj2?file=/demo.tsx>
219+
220+
```js
221+
import dayjs from 'dayjs';
222+
import updateLocale from 'dayjs/plugin/updateLocale';
223+
import 'dayjs/locale/zh-cn';
224+
225+
dayjs.extend(updateLocale);
226+
dayjs.updateLocale('zh-cn', {
227+
weekStart: 0,
228+
});
229+
```

components/form/FormItem.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import { warning } from '../vc-util/warning';
3434
import find from 'lodash-es/find';
3535
import { tuple } from '../_util/type';
3636
import type {
37+
FormLabelAlign,
3738
InternalNamePath,
3839
Rule,
3940
RuleError,
4041
RuleObject,
4142
ValidateOptions,
42-
FormLabelAlign,
4343
} from './interface';
4444
import useConfigInject from '../config-provider/hooks/useConfigInject';
4545
import { useInjectForm } from './context';
@@ -113,10 +113,7 @@ export const formItemProps = () => ({
113113
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
114114
hasFeedback: { type: Boolean, default: false },
115115
colon: { type: Boolean, default: undefined },
116-
labelAlign: {
117-
...PropTypes.oneOf(tuple('left', 'right')),
118-
type: String as PropType<FormLabelAlign>,
119-
},
116+
labelAlign: String as PropType<FormLabelAlign>,
120117
prop: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
121118
name: { type: [String, Number, Array] as PropType<string | number | Array<string | number>> },
122119
rules: [Array, Object] as PropType<Rule[] | Rule>,
@@ -237,7 +234,7 @@ export default defineComponent({
237234
if (typeof props.label === 'string') {
238235
variables.label = props.label;
239236
} else if (props.name) {
240-
variables.label = String(name);
237+
variables.label = String(props.name);
241238
}
242239
if (props.messageVariables) {
243240
variables = { ...variables, ...props.messageVariables };

components/mentions/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { App, PropType, ExtractPropTypes } from 'vue';
22
import { computed, watch, shallowRef, defineComponent } from 'vue';
33
import classNames from '../_util/classNames';
44
import PropTypes from '../_util/vue-types';
5-
import VcMentions, { Option } from '../vc-mentions';
5+
import VcMentions from '../vc-mentions';
66
import { mentionsProps as baseMentionsProps } from '../vc-mentions/src/mentionsProps';
77
import useConfigInject from '../config-provider/hooks/useConfigInject';
88
import { flattenChildren, getOptionProps } from '../_util/props-util';
99
import { FormItemInputContext, useInjectFormItemContext } from '../form/FormItemContext';
1010
import omit from '../_util/omit';
11-
import { optionProps } from '../vc-mentions/src/Option';
11+
import { optionProps, optionOptions } from '../vc-mentions/src/Option';
1212
import type { KeyboardEventHandler } from '../_util/EventInterface';
1313
import type { InputStatus } from '../_util/statusUtils';
1414
import { getStatusClassNames, getMergedStatus } from '../_util/statusUtils';
@@ -279,7 +279,7 @@ const Mentions = defineComponent({
279279
/* istanbul ignore next */
280280
export const MentionsOption = defineComponent({
281281
compatConfig: { MODE: 3 },
282-
...(Option as any),
282+
...optionOptions,
283283
name: 'AMentionsOption',
284284
props: optionProps,
285285
});

components/table/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Table, { tableProps } from './Table';
22
import Column from './Column';
33
import ColumnGroup from './ColumnGroup';
44
import type { TableProps, TablePaginationConfig } from './Table';
5-
import { defineComponent } from 'vue';
65
import type { App } from 'vue';
76
import { EXPAND_COLUMN, Summary, SummaryCell, SummaryRow } from '../vc-table';
87
import {
@@ -16,8 +15,8 @@ export type { ColumnProps } from './Column';
1615
export type { ColumnsType, ColumnType, ColumnGroupType } from './interface';
1716
export type { TableProps, TablePaginationConfig };
1817

19-
const TableSummaryRow = defineComponent({ ...(SummaryRow as any), name: 'ATableSummaryRow' });
20-
const TableSummaryCell = defineComponent({ ...(SummaryCell as any), name: 'ATableSummaryCell' });
18+
const TableSummaryRow = SummaryRow;
19+
const TableSummaryCell = SummaryCell;
2120

2221
const TableSummary = Object.assign(Summary, {
2322
Cell: TableSummaryCell,

components/transfer/demo/tree-transfer.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,12 @@ function isChecked(selectedKeys: (string | number)[], eventKey: string | number)
7878
return selectedKeys.indexOf(eventKey) !== -1;
7979
}
8080
81-
function handleTreeData(data: TransferProps['dataSource'], targetKeys: string[] = []) {
82-
data.forEach(item => {
83-
item['disabled'] = targetKeys.includes(item.key as any);
84-
if (item.children) {
85-
handleTreeData(item.children, targetKeys);
86-
}
87-
});
88-
return data as TreeProps['treeData'];
81+
function handleTreeData(treeNodes: TransferProps['dataSource'], targetKeys: string[] = []) {
82+
return treeNodes.map(({ children, ...props }) => ({
83+
...props,
84+
disabled: targetKeys.includes(props.key as string),
85+
children: handleTreeData(children ?? [], targetKeys),
86+
}));
8987
}
9088
9189
export default defineComponent({

0 commit comments

Comments
 (0)