style: format file

pull/3131/head^2
tangjinzhou 2020-11-07 15:37:17 +08:00
parent bd1f42a5ef
commit a13dd20f58
46 changed files with 302 additions and 304 deletions

View File

@ -10,7 +10,7 @@
"parserOptions": {
"parser": "babel-eslint"
},
"extends": ["plugin:vue/recommended", "prettier"],
"extends": ["plugin:vue/vue3-recommended", "prettier"],
"plugins": ["markdown"],
"overrides": [
{

View File

@ -29,9 +29,6 @@ export default defineComponent({
openCount = visible ? openCount + 1 : openCount;
return {};
},
updated() {
this.setWrapperClassName();
},
watch: {
visible(val) {
openCount = val ? openCount + 1 : openCount - 1;
@ -48,6 +45,9 @@ export default defineComponent({
}
},
},
updated() {
this.setWrapperClassName();
},
beforeUnmount() {
const { visible } = this.$props;
// 离开时不会 render 导到离开时数值不变,改用 func 。。

View File

@ -23,6 +23,12 @@ function isNotGrey(color) {
export default defineComponent({
name: 'Wave',
props: ['insertExtraNode'],
setup() {
const configProvider = inject('configProvider', defaultConfigProvider);
return {
configProvider,
};
},
mounted() {
nextTick(() => {
const node = findDOMNode(this);
@ -32,12 +38,6 @@ export default defineComponent({
this.instance = this.bindAnimationEvent(node);
});
},
setup() {
const configProvider = inject('configProvider', defaultConfigProvider);
return {
configProvider,
};
},
beforeUnmount() {
if (this.instance) {
this.instance.cancel();

View File

@ -50,14 +50,14 @@ const AffixProps = {
};
const Affix = defineComponent({
name: 'AAffix',
props: AffixProps,
mixins: [BaseMixin],
props: AffixProps,
emits: ['change', 'testUpdatePosition'],
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
emits: ['change', 'testUpdatePosition'],
data() {
return {
affixStyle: undefined,
@ -68,25 +68,6 @@ const Affix = defineComponent({
timeout: null,
};
},
beforeMount() {
this.updatePosition = throttleByAnimationFrame(this.updatePosition);
this.lazyUpdatePosition = throttleByAnimationFrame(this.lazyUpdatePosition);
},
mounted() {
const { target } = this;
if (target) {
// [Legacy] Wait for parent component ref has its value.
// We should use target as directly element instead of function which makes element check hard.
this.timeout = setTimeout(() => {
addObserveTarget(target(), this);
// Mock Event object.
this.updatePosition();
});
}
},
updated() {
this.measure();
},
watch: {
target(val) {
let newTarget = null;
@ -110,6 +91,25 @@ const Affix = defineComponent({
this.updatePosition();
},
},
beforeMount() {
this.updatePosition = throttleByAnimationFrame(this.updatePosition);
this.lazyUpdatePosition = throttleByAnimationFrame(this.lazyUpdatePosition);
},
mounted() {
const { target } = this;
if (target) {
// [Legacy] Wait for parent component ref has its value.
// We should use target as directly element instead of function which makes element check hard.
this.timeout = setTimeout(() => {
addObserveTarget(target(), this);
// Mock Event object.
this.updatePosition();
});
}
},
updated() {
this.measure();
},
beforeUnmount() {
clearTimeout(this.timeout);
removeObserveTarget(this);

View File

@ -59,9 +59,9 @@ export const AlertProps = {
const Alert = defineComponent({
name: 'AAlert',
mixins: [BaseMixin],
inheritAttrs: false,
props: AlertProps,
mixins: [BaseMixin],
emits: ['close'],
setup() {
return {

View File

@ -81,6 +81,11 @@ export default defineComponent({
inheritAttrs: false,
props: AnchorProps,
emits: ['change', 'click'],
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
data() {
// this.links = [];
// this.sPrefixCls = '';
@ -111,11 +116,6 @@ export default defineComponent({
} as AntAnchor);
provide('antAnchorContext', this);
},
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
mounted() {
nextTick(() => {
const { getContainer } = this;

View File

@ -18,8 +18,8 @@ const props = backTopTypes();
const BackTop = defineComponent({
name: 'ABackTop',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
emits: ['click'],
props: {
...props,

View File

@ -51,8 +51,8 @@ export const CalendarProps = {
const Calendar = defineComponent({
name: 'ACalendar',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
props: CalendarProps,
setup() {
return {

View File

@ -201,17 +201,10 @@ function flattenTree(
const defaultDisplayRender = ({ labels }) => labels.join(' / ');
const Cascader = defineComponent({
inheritAttrs: false,
name: 'ACascader',
mixins: [BaseMixin],
inheritAttrs: false,
props: CascaderProps,
// model: {
// prop: 'value',
// event: 'change',
// },
created() {
provide('savePopupRef', this.savePopupRef);
},
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
@ -244,6 +237,13 @@ const Cascader = defineComponent({
}
},
},
// model: {
// prop: 'value',
// event: 'change',
// },
created() {
provide('savePopupRef', this.savePopupRef);
},
methods: {
savePopupRef(ref: any) {
this.popupRef = ref;

View File

@ -25,6 +25,11 @@ export default defineComponent({
disabled: PropTypes.looseBool,
onChange: PropTypes.func,
},
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
data() {
const { value, defaultValue } = this;
@ -38,11 +43,6 @@ export default defineComponent({
this.sValue = val || [];
},
},
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
created() {
provide('checkboxGroupContext', this);
},

View File

@ -31,8 +31,8 @@ export default function createPicker<P>(
name: string,
): DefineComponent<any> {
return defineComponent({
inheritAttrs: false,
name,
inheritAttrs: false,
props: {
...props,
allowClear: PropTypes.looseBool.def(true),

View File

@ -66,6 +66,11 @@ export default function wrapPicker<P>(
popupRef: undefined,
};
},
watch: {
value(val) {
checkValidate('DatePicker', val, 'value', this.valueFormat);
},
},
created() {
provide('savePopupRef', this.savePopupRef);
},
@ -79,11 +84,6 @@ export default function wrapPicker<P>(
});
}
},
watch: {
value(val) {
checkValidate('DatePicker', val, 'value', this.valueFormat);
},
},
methods: {
savePicker(node: any) {
this.picker = node;

View File

@ -41,11 +41,6 @@ const Drawer = defineComponent({
'onUpdate:visible': PropTypes.func,
},
mixins: [BaseMixin],
data() {
return {
sPush: false,
};
},
setup(props) {
const configProvider = inject('configProvider', defaultConfigProvider);
return {
@ -55,6 +50,11 @@ const Drawer = defineComponent({
parentDrawer: inject('parentDrawer', null),
};
},
data() {
return {
sPush: false,
};
},
beforeCreate() {
provide('parentDrawer', this);
},

View File

@ -76,9 +76,6 @@ const Form = defineComponent({
colon: true,
}),
Item: FormItem,
created() {
provide('FormContext', this);
},
setup(props) {
return {
configProvider: inject('configProvider', defaultConfigProvider),
@ -95,6 +92,9 @@ const Form = defineComponent({
}
},
},
created() {
provide('FormContext', this);
},
methods: {
addField(field: any) {
if (field) {

View File

@ -30,22 +30,9 @@ const TextAreaProps = {
const ResizableTextArea = defineComponent({
name: 'ResizableTextArea',
mixins: [BaseMixin],
inheritAttrs: false,
props: TextAreaProps,
data() {
return {
textareaStyles: {},
resizeStatus: RESIZE_STATUS_NONE,
};
},
mixins: [BaseMixin],
mounted() {
this.resizeTextarea();
},
beforeUnmount() {
raf.cancel(this.nextFrameActionId);
raf.cancel(this.resizeFrameId);
},
setup() {
return {
nextFrameActionId: undefined,
@ -53,6 +40,12 @@ const ResizableTextArea = defineComponent({
resizeFrameId: undefined,
};
},
data() {
return {
textareaStyles: {},
resizeStatus: RESIZE_STATUS_NONE,
};
},
watch: {
value() {
nextTick(() => {
@ -60,6 +53,13 @@ const ResizableTextArea = defineComponent({
});
},
},
mounted() {
this.resizeTextarea();
},
beforeUnmount() {
raf.cancel(this.nextFrameActionId);
raf.cancel(this.resizeFrameId);
},
methods: {
saveTextArea(textArea: any) {
this.textArea = textArea;

View File

@ -71,6 +71,12 @@ export default defineComponent({
collapsedWidth: 80,
}),
emits: ['breakpoint', 'update:collapsed', 'collapse'],
setup() {
return {
siderHook: inject<SiderHookProvider>('siderHook', {}),
configProvider: inject('configProvider', defaultConfigProvider),
};
},
data() {
const uniqueId = generateId('ant-sider-');
let matchMedia: typeof window.matchMedia;
@ -106,12 +112,6 @@ export default defineComponent({
created() {
provide('layoutSiderContext', this); // menu组件中使用
},
setup() {
return {
siderHook: inject<SiderHookProvider>('siderHook', {}),
configProvider: inject('configProvider', defaultConfigProvider),
};
},
mounted() {
nextTick(() => {

View File

@ -55,9 +55,9 @@ export const ListProps = () => ({
});
const List = defineComponent({
name: 'AList',
inheritAttrs: false,
Item,
name: 'AList',
props: initDefaultProps(ListProps(), {
dataSource: [],
bordered: false,
@ -65,23 +65,6 @@ const List = defineComponent({
loading: false,
pagination: false,
}),
created() {
provide('listContext', this);
this.defaultPaginationProps = {
current: 1,
pageSize: 10,
onChange: (page: number, pageSize: number) => {
const { pagination } = this;
this.paginationCurrent = page;
if (pagination && (pagination as any).onChange) {
(pagination as any).onChange(page, pageSize);
}
},
total: 0,
};
this.onPaginationChange = this.triggerPaginationEvent('onChange');
this.onPaginationShowSizeChange = this.triggerPaginationEvent('onShowSizeChange');
},
setup() {
return {
keys: [],
@ -101,6 +84,23 @@ const List = defineComponent({
paginationSize: paginationObj.defaultPageSize || 10,
};
},
created() {
provide('listContext', this);
this.defaultPaginationProps = {
current: 1,
pageSize: 10,
onChange: (page: number, pageSize: number) => {
const { pagination } = this;
this.paginationCurrent = page;
if (pagination && (pagination as any).onChange) {
(pagination as any).onChange(page, pageSize);
}
},
total: 0,
};
this.onPaginationChange = this.triggerPaginationEvent('onChange');
this.onPaginationShowSizeChange = this.triggerPaginationEvent('onShowSizeChange');
},
methods: {
triggerPaginationEvent(eventName) {
return (page, pageSize) => {

View File

@ -51,13 +51,13 @@ export type MenuProps = Partial<ExtractPropTypes<typeof menuProps>>;
const Menu = defineComponent({
name: 'AMenu',
mixins: [BaseMixin],
inheritAttrs: false,
props: menuProps,
Divider: { ...Divider, name: 'AMenuDivider' },
Item: { ...Item, name: 'AMenuItem' },
SubMenu: { ...SubMenu, name: 'ASubMenu' },
ItemGroup: { ...ItemGroup, name: 'AMenuItemGroup' },
mixins: [BaseMixin],
emits: [
'update:selectedKeys',
'update:openKeys',
@ -68,10 +68,6 @@ const Menu = defineComponent({
'select',
'deselect',
],
created() {
provide('getInlineCollapsed', this.getInlineCollapsed);
provide('menuPropsContext', this.$props);
},
setup() {
const layoutSiderContext = inject<SiderContextProps>('layoutSiderContext', {});
const layoutSiderCollapsed = toRef(layoutSiderContext, 'sCollapsed');
@ -85,8 +81,23 @@ const Menu = defineComponent({
inlineOpenKeys: [],
};
},
updated() {
this.propsUpdating = false;
data() {
const props: MenuProps = getOptionProps(this);
warning(
!('inlineCollapsed' in props && props.mode !== 'inline'),
'Menu',
"`inlineCollapsed` should only be used when Menu's `mode` is inline.",
);
let sOpenKeys;
if ('openKeys' in props) {
sOpenKeys = props.openKeys;
} else if ('defaultOpenKeys' in props) {
sOpenKeys = props.defaultOpenKeys;
}
return {
sOpenKeys,
};
},
// beforeUnmount() {
// raf.cancel(this.mountRafId);
@ -107,23 +118,12 @@ const Menu = defineComponent({
this.collapsedChange(val);
},
},
data() {
const props: MenuProps = getOptionProps(this);
warning(
!('inlineCollapsed' in props && props.mode !== 'inline'),
'Menu',
"`inlineCollapsed` should only be used when Menu's `mode` is inline.",
);
let sOpenKeys;
if ('openKeys' in props) {
sOpenKeys = props.openKeys;
} else if ('defaultOpenKeys' in props) {
sOpenKeys = props.defaultOpenKeys;
}
return {
sOpenKeys,
};
created() {
provide('getInlineCollapsed', this.getInlineCollapsed);
provide('menuPropsContext', this.$props);
},
updated() {
this.propsUpdating = false;
},
methods: {
collapsedChange(val) {

View File

@ -19,16 +19,16 @@ export type IActionButtonProps = ExtractPropTypes<typeof ActionButtonProps>;
export default defineComponent({
mixins: [BaseMixin],
props: ActionButtonProps,
data() {
return {
loading: false,
};
},
setup() {
return {
timeoutId: undefined,
};
},
data() {
return {
loading: false,
};
},
mounted() {
if (this.autofocus) {
this.timeoutId = setTimeout(() => findDOMNode(this).focus());

View File

@ -159,6 +159,11 @@ export default defineComponent({
visible: false,
okType: 'primary',
}),
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
data() {
return {
sVisible: !!this.visible,
@ -169,11 +174,6 @@ export default defineComponent({
this.sVisible = val;
},
},
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
};
},
methods: {
handleCancel(e: MouseEvent) {
this.$emit('update:visible', false);

View File

@ -38,11 +38,6 @@ const Popconfirm = defineComponent({
},
mixins: [BaseMixin],
emits: ['update:visible', 'confirm', 'cancel', 'visibleChange'],
watch: {
visible(val) {
this.sVisible = val;
},
},
setup() {
return {
configProvider: inject('configProvider', defaultConfigProvider),
@ -59,6 +54,11 @@ const Popconfirm = defineComponent({
}
return state;
},
watch: {
visible(val) {
this.sVisible = val;
},
},
methods: {
onConfirmHandle(e) {
this.setVisible(false, e);

View File

@ -21,12 +21,6 @@ export default defineComponent({
onChange: PropTypes.func,
},
emits: ['update:value', 'change'],
data() {
const { value, defaultValue } = this;
return {
stateValue: value === undefined ? defaultValue : value,
};
},
setup() {
return {
updatingValue: false,
@ -34,6 +28,18 @@ export default defineComponent({
radioGroupContext: null,
};
},
data() {
const { value, defaultValue } = this;
return {
stateValue: value === undefined ? defaultValue : value,
};
},
watch: {
value(val) {
this.updatingValue = false;
this.stateValue = val;
},
},
// computed: {
// radioOptions() {
// const { disabled } = this;
@ -47,12 +53,6 @@ export default defineComponent({
created() {
this.radioGroupContext = provide('radioGroupContext', this);
},
watch: {
value(val) {
this.updatingValue = false;
this.stateValue = val;
},
},
methods: {
onRadioChange(ev: RadioChangeEvent) {
const lastValue = this.stateValue;

View File

@ -53,9 +53,9 @@ const defaultTipFormatter = (value: number) => value.toString();
const Slider = defineComponent({
name: 'ASlider',
mixins: [BaseMixin],
inheritAttrs: false,
emits: ['update:value', 'change'],
mixins: [BaseMixin],
setup() {
return {
vcSlider: null,

View File

@ -46,10 +46,6 @@ export default defineComponent({
configProvider: inject('configProvider', defaultConfigProvider),
};
},
created() {
this.originalUpdateSpinning = this.updateSpinning;
this.debouncifyUpdateSpinning(this.$props);
},
data() {
const { spinning, delay } = this;
const shouldBeDelayed = shouldDelay(spinning, delay);
@ -57,6 +53,10 @@ export default defineComponent({
sSpinning: spinning && !shouldBeDelayed,
};
},
created() {
this.originalUpdateSpinning = this.updateSpinning;
this.debouncifyUpdateSpinning(this.$props);
},
mounted() {
this.updateSpinning();
},

View File

@ -31,6 +31,13 @@ const Switch = defineComponent({
configProvider: inject('configProvider', defaultConfigProvider),
};
},
created() {
warning(
hasProp(this, 'checked') || !('value' in this.$attrs),
'Switch',
'`value` is not validate prop, do you mean `checked`?',
);
},
methods: {
focus() {
this.refSwitchNode?.focus();
@ -42,13 +49,6 @@ const Switch = defineComponent({
this.refSwitchNode = c;
},
},
created() {
warning(
hasProp(this, 'checked') || !('value' in this.$attrs),
'Switch',
'`value` is not validate prop, do you mean `checked`?',
);
},
render() {
const { prefixCls: customizePrefixCls, size, loading, disabled, ...restProps } = getOptionProps(

View File

@ -10,17 +10,17 @@ export default defineComponent({
mixins: [BaseMixin],
inheritAttrs: false,
props: SelectionBoxProps,
data() {
return {
checked: false,
};
},
setup() {
return {
unsubscribe: null,
};
},
data() {
return {
checked: false,
};
},
created() {
this.checked = this.getCheckState(this.$props);

View File

@ -93,6 +93,13 @@ export default defineComponent({
mixins: [BaseMixin],
inheritAttrs: false,
props: SelectionCheckboxAllProps,
setup() {
return {
defaultSelections: [],
unsubscribe: null,
};
},
data() {
const { $props: props } = this;
@ -102,11 +109,12 @@ export default defineComponent({
};
},
setup() {
return {
defaultSelections: [],
unsubscribe: null,
};
watch: {
propsSymbol: {
handler() {
this.setCheckState(this.$props);
},
},
},
created() {
@ -125,14 +133,6 @@ export default defineComponent({
];
},
watch: {
propsSymbol: {
handler() {
this.setCheckState(this.$props);
},
},
},
mounted() {
this.subscribe();
},

View File

@ -170,13 +170,6 @@ export default defineComponent({
filterDataCnt: 0,
};
},
created() {
const props = getOptionProps(this);
this.store = createStore({
selectedRowKeys: getRowSelection(props).selectedRowKeys || [],
selectionDirty: false,
});
},
watch: {
pagination: {
handler(val) {
@ -242,6 +235,13 @@ export default defineComponent({
deep: true,
},
},
created() {
const props = getOptionProps(this);
this.store = createStore({
selectedRowKeys: getRowSelection(props).selectedRowKeys || [],
selectionDirty: false,
});
},
updated() {
const { columns, sSortColumn: sortColumn, sSortOrder: sortOrder } = this;
if (this.getSortOrderColumns(columns).length > 0) {

View File

@ -15,6 +15,11 @@ export default function createBodyRow(Component = 'tr') {
name: 'BodyRow',
inheritAttrs: false,
props: BodyRowProps,
setup() {
return {
unsubscribe: null,
};
},
data() {
const { selectedRowKeys } = this.store.getState();
@ -22,11 +27,6 @@ export default function createBodyRow(Component = 'tr') {
selected: selectedRowKeys.indexOf(this.rowKey) >= 0,
};
},
setup() {
return {
unsubscribe: null,
};
},
mounted() {
this.subscribe();
},

View File

@ -8,8 +8,8 @@ const Table = defineComponent({
name: 'ATable',
Column: T.Column,
ColumnGroup: T.ColumnGroup,
props: defaultTableProps,
inheritAttrs: false,
props: defaultTableProps,
methods: {
normalize(elements = []) {
const columns = [];

View File

@ -76,8 +76,8 @@ export const TimePickerProps = () => ({
const TimePicker = defineComponent({
name: 'ATimePicker',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
emits: ['update:value', 'update:open', 'change', 'openChange', 'focus', 'blur', 'keydown'],
props: initDefaultProps(TimePickerProps(), {
align: {
@ -93,9 +93,6 @@ const TimePicker = defineComponent({
focusOnOpen: true,
allowClear: true,
}),
created() {
provide('savePopupRef', this.savePopupRef);
},
setup() {
return {
popupRef: null,
@ -124,6 +121,9 @@ const TimePicker = defineComponent({
this.setState({ sValue: stringToMoment(val, this.valueFormat) });
},
},
created() {
provide('savePopupRef', this.savePopupRef);
},
methods: {
getDefaultFormat() {
const { format, use12Hours } = this;

View File

@ -57,8 +57,8 @@ export interface TransferLocale {
const Transfer = defineComponent({
name: 'ATransfer',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
props: initDefaultProps(TransferProps, {
dataSource: [],
locale: {},
@ -86,9 +86,6 @@ const Transfer = defineComponent({
targetSelectedKeys: selectedKeys.filter(key => targetKeys.indexOf(key) > -1),
};
},
mounted() {
// this.currentProps = { ...this.$props }
},
watch: {
targetKeys() {
this.updateState();
@ -113,6 +110,9 @@ const Transfer = defineComponent({
}
},
},
mounted() {
// this.currentProps = { ...this.$props }
},
methods: {
getSelectedKeysName(direction) {
return direction === 'left' ? 'sourceSelectedKeys' : 'targetSelectedKeys';

View File

@ -21,8 +21,8 @@ const TreeSelect = defineComponent({
SHOW_ALL,
SHOW_PARENT,
SHOW_CHILD,
inheritAttrs: false,
name: 'ATreeSelect',
inheritAttrs: false,
props: initDefaultProps(TreeSelectProps(), {
transitionName: 'slide-up',
choiceTransitionName: '',

View File

@ -88,9 +88,6 @@ export default defineComponent({
...state,
};
},
created() {
this.onDebounceExpand = debounce(this.expandFolderNode, 200, { leading: true });
},
watch: {
expandedKeys(val) {
this.setState({ _expandedKeys: val });
@ -99,6 +96,9 @@ export default defineComponent({
this.setState({ _selectedKeys: val });
},
},
created() {
this.onDebounceExpand = debounce(this.expandFolderNode, 200, { leading: true });
},
methods: {
handleExpand(expandedKeys, info) {
this.setUncontrolledState({ _expandedKeys: expandedKeys });

View File

@ -64,32 +64,6 @@ const Drawer = defineComponent({
container: undefined,
};
},
mounted() {
nextTick(() => {
if (!windowIsUndefined) {
let passiveSupported = false;
window.addEventListener(
'test',
null,
Object.defineProperty({}, 'passive', {
get: () => {
passiveSupported = true;
return null;
},
}),
);
this.passive = passiveSupported ? { passive: false } : false;
}
const open = this.getOpen();
if (this.handler || open || this.sFirstEnter) {
this.getDefault(this.$props);
if (open) {
this.isOpenChange = true;
}
this.$forceUpdate();
}
});
},
watch: {
open(val) {
if (val !== undefined && val !== this.preProps.open) {
@ -118,6 +92,32 @@ const Drawer = defineComponent({
this.preProps.level = val;
},
},
mounted() {
nextTick(() => {
if (!windowIsUndefined) {
let passiveSupported = false;
window.addEventListener(
'test',
null,
Object.defineProperty({}, 'passive', {
get: () => {
passiveSupported = true;
return null;
},
}),
);
this.passive = passiveSupported ? { passive: false } : false;
}
const open = this.getOpen();
if (this.handler || open || this.sFirstEnter) {
this.getDefault(this.$props);
if (open) {
this.isOpenChange = true;
}
this.$forceUpdate();
}
});
},
updated() {
nextTick(() => {
// dom 没渲染时,重走一遍。

View File

@ -12,46 +12,14 @@ export default defineComponent({
props: {
...defaultProps,
},
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
data() {
this._responsiveMediaHandlers = [];
return {
breakpoint: null,
};
},
methods: {
innerSliderRefHandler(ref) {
this.innerSlider = ref;
},
media(query, handler) {
// javascript handler for css media query
const mql = window.matchMedia(query);
const listener = ({ matches }) => {
if (matches) {
handler();
}
};
mql.addListener(listener);
listener(mql);
this._responsiveMediaHandlers.push({ mql, query, listener });
},
slickPrev() {
this.innerSlider.slickPrev();
},
slickNext() {
this.innerSlider.slickNext();
},
slickGoTo(slide, dontAnimate = false) {
this.innerSlider.slickGoTo(slide, dontAnimate);
},
slickPause() {
this.innerSlider.pause('paused');
},
slickPlay() {
this.innerSlider.handleAutoPlay('play');
},
},
// handles responsive breakpoints
beforeMount() {
if (this.responsive) {
@ -92,6 +60,38 @@ export default defineComponent({
obj.mql.removeListener(obj.listener);
});
},
methods: {
innerSliderRefHandler(ref) {
this.innerSlider = ref;
},
media(query, handler) {
// javascript handler for css media query
const mql = window.matchMedia(query);
const listener = ({ matches }) => {
if (matches) {
handler();
}
};
mql.addListener(listener);
listener(mql);
this._responsiveMediaHandlers.push({ mql, query, listener });
},
slickPrev() {
this.innerSlider.slickPrev();
},
slickNext() {
this.innerSlider.slickNext();
},
slickGoTo(slide, dontAnimate = false) {
this.innerSlider.slickGoTo(slide, dontAnimate);
},
slickPause() {
this.innerSlider.pause('paused');
},
slickPlay() {
this.innerSlider.handleAutoPlay('play');
},
},
render() {
let settings;

View File

@ -8,8 +8,8 @@ import { defineComponent } from 'vue';
const Slider = defineComponent({
name: 'Slider',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
props: {
defaultValue: PropTypes.number,
value: PropTypes.number,

View File

@ -36,9 +36,9 @@ export default function createSlider(Component) {
autofocus: PropTypes.looseBool,
};
return defineComponent({
name: 'createSlider',
inheritAttrs: false,
name: 'CreateSlider',
mixins: [BaseMixin, Component],
inheritAttrs: false,
// model: {
// prop: 'value',
// event: 'change',

View File

@ -34,8 +34,8 @@ function toNearestValidTime(time, hourOptions, minuteOptions, secondOptions) {
const Panel = defineComponent({
name: 'Panel',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
props: {
clearText: PropTypes.string,
prefixCls: PropTypes.string.def('rc-time-picker-panel'),

View File

@ -68,8 +68,8 @@ function getWatch(keys = []) {
}
const Select = defineComponent({
name: 'Select',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
props: initDefaultProps(
{
prefixCls: PropTypes.string,

View File

@ -43,8 +43,8 @@ function getWatch(keys = []) {
const Tree = defineComponent({
name: 'Tree',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
props: initDefaultProps(
{
prefixCls: PropTypes.string,

View File

@ -14,8 +14,8 @@ const defaultTitle = '---';
const TreeNode = defineComponent({
name: 'TreeNode',
inheritAttrs: false,
mixins: [BaseMixin],
inheritAttrs: false,
__ANT_TREE_NODE: true,
props: initDefaultProps(
{
@ -52,6 +52,12 @@ const TreeNode = defineComponent({
},
{},
),
setup() {
return {
vcTree: inject('vcTree', {}),
vcTreeNode: inject('vcTreeNode', {}),
};
},
data() {
this.children = null;
@ -59,12 +65,6 @@ const TreeNode = defineComponent({
dragNodeHighlight: false,
};
},
setup() {
return {
vcTree: inject('vcTree', {}),
vcTreeNode: inject('vcTreeNode', {}),
};
},
created() {
provide('vcTreeNode', this);
},

View File

@ -76,6 +76,13 @@ export default defineComponent({
stretch: PropTypes.string,
alignPoint: PropTypes.looseBool, // Maybe we can support user pass position in the future
},
setup() {
return {
vcTriggerContext: inject('vcTriggerContext', {}),
savePopupRef: inject('savePopupRef', noop),
dialogContext: inject('dialogContext', null),
};
},
data() {
const props = this.$props;
let popupVisible;
@ -112,13 +119,6 @@ export default defineComponent({
created() {
provide('vcTriggerContext', this);
},
setup() {
return {
vcTriggerContext: inject('vcTriggerContext', {}),
savePopupRef: inject('savePopupRef', noop),
dialogContext: inject('dialogContext', null),
};
},
deactivated() {
this.setPopupVisible(false);
},

View File

@ -59,8 +59,8 @@ export interface ListState<T = object> {
}
const List = defineComponent({
inheritAttrs: false,
name: 'List',
inheritAttrs: false,
props: {
prefixCls: PropTypes.string,
data: PropTypes.array,

View File

@ -123,7 +123,7 @@
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-markdown": "^2.0.0-alpha.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-vue": "^6.2.2",
"eslint-plugin-vue": "^7.1.0",
"fetch-jsonp": "^1.1.3",
"fs-extra": "^8.0.0",
"glob": "^7.1.2",

View File

@ -2,8 +2,8 @@ import glob from 'glob';
import { mount } from '@vue/test-utils';
import MockDate from 'mockdate';
import moment from 'moment';
import { nextTick } from 'vue';
import antd from 'ant-design-vue';
import { sleep } from '../utils';
export default function demoTest(component, options = {}) {
const suffix = options.suffix || 'md';
@ -14,22 +14,20 @@ export default function demoTest(component, options = {}) {
if (Array.isArray(options.skip) && options.skip.some(c => file.includes(c))) {
testMethod = test.skip;
}
testMethod(`renders ${file} correctly`, done => {
testMethod(`renders ${file} correctly`, async () => {
MockDate.set(moment('2016-11-22'));
const demo = require(`../.${file}`).default || require(`../.${file}`);
document.body.innerHTML = '';
const wrapper = mount(demo, { global: { plugins: [antd] }, attachTo: document.body });
nextTick(() => {
// should get dom from element
// snap files copy from antd does not need to change
// or just change a little
const dom = options.getDomFromElement ? wrapper.element : wrapper.html();
expect(dom).toMatchSnapshot();
MockDate.reset();
// wrapper.unmount();
document.body.innerHTML = '';
done();
});
await sleep();
// should get dom from element
// snap files copy from antd does not need to change
// or just change a little
const dom = options.getDomFromElement ? wrapper.element : wrapper.html();
expect(dom).toMatchSnapshot();
MockDate.reset();
// wrapper.unmount();
document.body.innerHTML = '';
});
});
}