mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-29 18:48:32 +08:00
feat(config-provider ): wave config (#7036)
This commit is contained in:
parent
82f407d396
commit
6c39bec277
@ -26,7 +26,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const instance = getCurrentInstance();
|
const instance = getCurrentInstance();
|
||||||
const { prefixCls } = useConfigInject('wave', props);
|
const { prefixCls, wave } = useConfigInject('wave', props);
|
||||||
|
|
||||||
// ============================== Style ===============================
|
// ============================== Style ===============================
|
||||||
const [, hashId] = useStyle(prefixCls);
|
const [, hashId] = useStyle(prefixCls);
|
||||||
@ -35,6 +35,7 @@ export default defineComponent({
|
|||||||
const showWave = useWave(
|
const showWave = useWave(
|
||||||
instance,
|
instance,
|
||||||
computed(() => classNames(prefixCls.value, hashId.value)),
|
computed(() => classNames(prefixCls.value, hashId.value)),
|
||||||
|
wave,
|
||||||
);
|
);
|
||||||
let onClick: (e: MouseEvent) => void;
|
let onClick: (e: MouseEvent) => void;
|
||||||
const clear = () => {
|
const clear = () => {
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
import type { ComponentInternalInstance, Ref } from 'vue';
|
import type { ComponentInternalInstance, ComputedRef, Ref } from 'vue';
|
||||||
import { findDOMNode } from '../props-util';
|
import { findDOMNode } from '../props-util';
|
||||||
import showWaveEffect from './WaveEffect';
|
import showWaveEffect from './WaveEffect';
|
||||||
|
|
||||||
export default function useWave(
|
export default function useWave(
|
||||||
instance: ComponentInternalInstance | null,
|
instance: ComponentInternalInstance | null,
|
||||||
className: Ref<string>,
|
className: Ref<string>,
|
||||||
|
wave: ComputedRef<{ disabled?: boolean }>,
|
||||||
): VoidFunction {
|
): VoidFunction {
|
||||||
function showWave() {
|
function showWave() {
|
||||||
const node = findDOMNode(instance);
|
const node = findDOMNode(instance);
|
||||||
|
|
||||||
|
if (wave.value?.disabled || !node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showWaveEffect(node, className.value);
|
showWaveEffect(node, className.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,9 @@ export const configProviderProps = () => ({
|
|||||||
select: objectType<{
|
select: objectType<{
|
||||||
showSearch?: boolean;
|
showSearch?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
|
wave: objectType<{
|
||||||
|
disabled?: boolean;
|
||||||
|
}>(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ConfigProviderProps = Partial<ExtractPropTypes<ReturnType<typeof configProviderProps>>>;
|
export type ConfigProviderProps = Partial<ExtractPropTypes<ReturnType<typeof configProviderProps>>>;
|
||||||
@ -145,6 +148,9 @@ export interface ConfigProviderInnerProps {
|
|||||||
componentSize?: ComputedRef<SizeType>;
|
componentSize?: ComputedRef<SizeType>;
|
||||||
componentDisabled?: ComputedRef<boolean>;
|
componentDisabled?: ComputedRef<boolean>;
|
||||||
transformCellText?: ComputedRef<(tableProps: TransformCellTextProps) => any>;
|
transformCellText?: ComputedRef<(tableProps: TransformCellTextProps) => any>;
|
||||||
|
wave?: ComputedRef<{
|
||||||
|
disabled?: boolean;
|
||||||
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const configProviderKey: InjectionKey<ConfigProviderInnerProps> = Symbol('configProvider');
|
export const configProviderKey: InjectionKey<ConfigProviderInnerProps> = Symbol('configProvider');
|
||||||
|
@ -42,6 +42,10 @@ export default (name: string, props: Record<any, any>) => {
|
|||||||
);
|
);
|
||||||
const disabled = computed<boolean>(() => props.disabled ?? disabledContext.value);
|
const disabled = computed<boolean>(() => props.disabled ?? disabledContext.value);
|
||||||
const csp = computed(() => props.csp ?? configProvider.csp);
|
const csp = computed(() => props.csp ?? configProvider.csp);
|
||||||
|
const wave = computed<{
|
||||||
|
disabled?: boolean;
|
||||||
|
}>(() => props.wave ?? configProvider.wave.value);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configProvider,
|
configProvider,
|
||||||
prefixCls,
|
prefixCls,
|
||||||
@ -63,5 +67,6 @@ export default (name: string, props: Record<any, any>) => {
|
|||||||
iconPrefixCls,
|
iconPrefixCls,
|
||||||
disabled,
|
disabled,
|
||||||
select: configProvider.select,
|
select: configProvider.select,
|
||||||
|
wave,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -197,6 +197,7 @@ const ConfigProvider = defineComponent({
|
|||||||
);
|
);
|
||||||
const componentSize = computed(() => props.componentSize);
|
const componentSize = computed(() => props.componentSize);
|
||||||
const componentDisabled = computed(() => props.componentDisabled);
|
const componentDisabled = computed(() => props.componentDisabled);
|
||||||
|
const wave = computed(() => props.wave ?? parentContext.wave?.value);
|
||||||
const configProvider: ConfigProviderInnerProps = {
|
const configProvider: ConfigProviderInnerProps = {
|
||||||
csp,
|
csp,
|
||||||
autoInsertSpaceInButton,
|
autoInsertSpaceInButton,
|
||||||
@ -221,6 +222,7 @@ const ConfigProvider = defineComponent({
|
|||||||
componentSize,
|
componentSize,
|
||||||
componentDisabled,
|
componentDisabled,
|
||||||
transformCellText: computed(() => props.transformCellText),
|
transformCellText: computed(() => props.transformCellText),
|
||||||
|
wave,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ================================ Dynamic theme ================================
|
// ================================ Dynamic theme ================================
|
||||||
|
Loading…
Reference in New Issue
Block a user