style: some code
parent
8f20fd514a
commit
adbc39bfbd
|
@ -1,15 +1,18 @@
|
||||||
import type { Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import { onMounted, onUnmounted, ref } from 'vue';
|
import { getCurrentInstance, onMounted, onUnmounted, ref } from 'vue';
|
||||||
import type { ScreenMap } from '../../_util/responsiveObserve';
|
import type { ScreenMap } from '../../_util/responsiveObserve';
|
||||||
import ResponsiveObserve from '../../_util/responsiveObserve';
|
import ResponsiveObserve from '../../_util/responsiveObserve';
|
||||||
|
|
||||||
function useBreakpoint(): Ref<ScreenMap> {
|
function useBreakpoint(refreshOnChange = ref(true)): Ref<ScreenMap> {
|
||||||
const screens = ref<ScreenMap>({});
|
const screens = ref<ScreenMap>({});
|
||||||
let token = null;
|
let token = null;
|
||||||
|
const instance = getCurrentInstance();
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
token = ResponsiveObserve.subscribe(supportScreens => {
|
token = ResponsiveObserve.subscribe(supportScreens => {
|
||||||
screens.value = supportScreens;
|
screens.value = supportScreens;
|
||||||
|
if (refreshOnChange?.value) {
|
||||||
|
instance.update();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,15 @@ const Avatar = defineComponent({
|
||||||
const { prefixCls } = useConfigInject('avatar', props);
|
const { prefixCls } = useConfigInject('avatar', props);
|
||||||
|
|
||||||
const groupSize = useInjectSize();
|
const groupSize = useInjectSize();
|
||||||
|
const size = computed(() => {
|
||||||
const screens = useBreakpoint();
|
return props.size === 'default' ? groupSize.value : props.size;
|
||||||
|
});
|
||||||
|
const needResponsive = computed(() =>
|
||||||
|
Object.keys(typeof size.value === 'object' ? size.value || {} : {}).some(key =>
|
||||||
|
['xs', 'sm', 'md', 'lg', 'xl', 'xxl'].includes(key),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const screens = useBreakpoint(needResponsive);
|
||||||
const responsiveSize = computed(() => {
|
const responsiveSize = computed(() => {
|
||||||
if (typeof props.size !== 'object') {
|
if (typeof props.size !== 'object') {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -126,27 +133,26 @@ const Avatar = defineComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { shape, size: customSize, src, alt, srcset, draggable, crossOrigin } = props;
|
const { shape, src, alt, srcset, draggable, crossOrigin } = props;
|
||||||
const icon = getPropsSlot(slots, props, 'icon');
|
const icon = getPropsSlot(slots, props, 'icon');
|
||||||
const pre = prefixCls.value;
|
const pre = prefixCls.value;
|
||||||
const size = customSize === 'default' ? groupSize.value : customSize;
|
|
||||||
const classString = {
|
const classString = {
|
||||||
[`${attrs.class}`]: !!attrs.class,
|
[`${attrs.class}`]: !!attrs.class,
|
||||||
[pre]: true,
|
[pre]: true,
|
||||||
[`${pre}-lg`]: size === 'large',
|
[`${pre}-lg`]: size.value === 'large',
|
||||||
[`${pre}-sm`]: size === 'small',
|
[`${pre}-sm`]: size.value === 'small',
|
||||||
[`${pre}-${shape}`]: shape,
|
[`${pre}-${shape}`]: shape,
|
||||||
[`${pre}-image`]: src && isImgExist.value,
|
[`${pre}-image`]: src && isImgExist.value,
|
||||||
[`${pre}-icon`]: icon,
|
[`${pre}-icon`]: icon,
|
||||||
};
|
};
|
||||||
|
|
||||||
const sizeStyle: CSSProperties =
|
const sizeStyle: CSSProperties =
|
||||||
typeof size === 'number'
|
typeof size.value === 'number'
|
||||||
? {
|
? {
|
||||||
width: `${size}px`,
|
width: `${size.value}px`,
|
||||||
height: `${size}px`,
|
height: `${size.value}px`,
|
||||||
lineHeight: `${size}px`,
|
lineHeight: `${size.value}px`,
|
||||||
fontSize: icon ? `${size / 2}px` : '18px',
|
fontSize: icon ? `${size.value / 2}px` : '18px',
|
||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
@ -173,9 +179,9 @@ const Avatar = defineComponent({
|
||||||
transform: transformString,
|
transform: transformString,
|
||||||
};
|
};
|
||||||
const sizeChildrenStyle =
|
const sizeChildrenStyle =
|
||||||
typeof size === 'number'
|
typeof size.value === 'number'
|
||||||
? {
|
? {
|
||||||
lineHeight: `${size}px`,
|
lineHeight: `${size.value}px`,
|
||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
childrenToRender = (
|
childrenToRender = (
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
import Wave from '../_util/wave';
|
import Wave from '../_util/wave';
|
||||||
import buttonTypes from './buttonTypes';
|
import buttonTypes from './buttonTypes';
|
||||||
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
|
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
|
||||||
import { flattenChildren, getPropsSlot } from '../_util/props-util';
|
import { flattenChildren, getPropsSlot, initDefaultProps } from '../_util/props-util';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import devWarning from '../vc-util/devWarning';
|
import devWarning from '../vc-util/devWarning';
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export default defineComponent({
|
||||||
name: 'AButton',
|
name: 'AButton',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
__ANT_BUTTON: true,
|
__ANT_BUTTON: true,
|
||||||
props: buttonTypes(),
|
props: initDefaultProps(buttonTypes(), { type: 'default' }),
|
||||||
slots: ['icon'],
|
slots: ['icon'],
|
||||||
emits: ['click', 'mousedown'],
|
emits: ['click', 'mousedown'],
|
||||||
setup(props, { slots, attrs, emit }) {
|
setup(props, { slots, attrs, emit }) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ Select multiple options
|
||||||
<template>
|
<template>
|
||||||
<a-cascader
|
<a-cascader
|
||||||
v-model:value="value"
|
v-model:value="value"
|
||||||
style="width: 233px"
|
style="width: 100%"
|
||||||
multiple
|
multiple
|
||||||
max-tag-count="responsive"
|
max-tag-count="responsive"
|
||||||
:options="options"
|
:options="options"
|
||||||
|
|
|
@ -76,6 +76,10 @@ interface Option {
|
||||||
label?: VNode;
|
label?: VNode;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
children?: Option[];
|
children?: Option[];
|
||||||
|
// Determines if this is a leaf node(effective when `loadData` is specified).
|
||||||
|
// `false` will force trade TreeNode as a parent node.
|
||||||
|
// Show expand icon even if the current node has no children.
|
||||||
|
isLeaf?: boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { ShowSearchType, FieldNames, BaseOptionType, DefaultOptionType } from '../vc-cascader';
|
import type { ShowSearchType, FieldNames, BaseOptionType, DefaultOptionType } from '../vc-cascader';
|
||||||
import VcCascader, { cascaderProps as vcCascaderProps } from '../vc-cascader';
|
import VcCascader, { cascaderProps as vcCascaderProps } from '../vc-cascader';
|
||||||
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
|
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
|
||||||
import RedoOutlined from '@ant-design/icons-vue/RedoOutlined';
|
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
|
||||||
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
|
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
|
||||||
import getIcons from '../select/utils/iconUtil';
|
import getIcons from '../select/utils/iconUtil';
|
||||||
import type { VueNode } from '../_util/type';
|
import type { VueNode } from '../_util/type';
|
||||||
|
@ -215,7 +215,7 @@ const Cascader = defineComponent({
|
||||||
|
|
||||||
const loadingIcon = (
|
const loadingIcon = (
|
||||||
<span class={`${prefixCls.value}-menu-item-loading-icon`}>
|
<span class={`${prefixCls.value}-menu-item-loading-icon`}>
|
||||||
<RedoOutlined spin />
|
<LoadingOutlined spin />
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,9 @@ interface Option {
|
||||||
label?: any;
|
label?: any;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
children?: Option[];
|
children?: Option[];
|
||||||
|
// 标记是否为叶子节点,设置了 `loadData` 时有效
|
||||||
|
// 设为 `false` 时会强制标记为父节点,即使当前节点没有 children,也会显示展开图标
|
||||||
|
isLeaf?: boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { TinyColor } from '@ctrl/tinycolor';
|
||||||
import { generate } from '@ant-design/colors';
|
import { generate } from '@ant-design/colors';
|
||||||
import type { Theme } from './context';
|
import type { Theme } from './context';
|
||||||
import { updateCSS } from '../vc-util/Dom/dynamicCSS';
|
import { updateCSS } from '../vc-util/Dom/dynamicCSS';
|
||||||
|
import canUseDom from '../_util/canUseDom';
|
||||||
|
import devWarning from '../vc-util/devWarning';
|
||||||
|
|
||||||
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
|
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
|
||||||
|
|
||||||
|
@ -86,12 +88,16 @@ export function registerTheme(globalPrefixCls: string, theme: Theme) {
|
||||||
key => `--${globalPrefixCls}-${key}: ${variables[key]};`,
|
key => `--${globalPrefixCls}-${key}: ${variables[key]};`,
|
||||||
);
|
);
|
||||||
|
|
||||||
updateCSS(
|
if (canUseDom()) {
|
||||||
`
|
updateCSS(
|
||||||
|
`
|
||||||
:root {
|
:root {
|
||||||
${cssList.join('\n')}
|
${cssList.join('\n')}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
`${dynamicStyleMark}-dynamic-theme`,
|
`${dynamicStyleMark}-dynamic-theme`,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
devWarning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,9 +152,7 @@ const ConfigProvider = defineComponent({
|
||||||
}
|
}
|
||||||
const validateMessagesRef = computed(() => {
|
const validateMessagesRef = computed(() => {
|
||||||
// Additional Form provider
|
// Additional Form provider
|
||||||
let validateMessages: ValidateMessages = {
|
let validateMessages: ValidateMessages = {};
|
||||||
...defaultLocale.Form?.defaultValidateMessages,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (props.locale) {
|
if (props.locale) {
|
||||||
validateMessages =
|
validateMessages =
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import Row from './Row';
|
import Row from './Row';
|
||||||
import Col from './Col';
|
import Col from './Col';
|
||||||
import useBreakpoint from '../_util/hooks/useBreakpoint';
|
import useInternalBreakpoint from '../_util/hooks/useBreakpoint';
|
||||||
|
|
||||||
|
// Do not export params
|
||||||
|
function useBreakpoint() {
|
||||||
|
return useInternalBreakpoint();
|
||||||
|
}
|
||||||
export type { RowProps } from './Row';
|
export type { RowProps } from './Row';
|
||||||
|
|
||||||
export type { ColProps, ColSize } from './Col';
|
export type { ColProps, ColSize } from './Col';
|
||||||
|
|
Loading…
Reference in New Issue