mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2024-11-10 09:39:15 +08:00
chore: change info
This commit is contained in:
parent
7ae7f3a878
commit
7cead859d1
@ -58,8 +58,8 @@ const Button = defineComponent({
|
||||
small: 'sm',
|
||||
middle: undefined
|
||||
}
|
||||
const sizeFullname = compactSize?.value || size.value
|
||||
return sizeClassNameMap[sizeFullname]
|
||||
const sizeFullName = compactSize?.value || size.value
|
||||
return sizeClassNameMap[sizeFullName]
|
||||
})
|
||||
const disabled = useDisabled(props)
|
||||
const buttonRef = shallowRef<HTMLButtonElement | null>(null)
|
||||
@ -73,6 +73,30 @@ const Button = defineComponent({
|
||||
)
|
||||
const [hasTwoCNChar, setHasTwoCNChar] = useState(false)
|
||||
|
||||
const isNeedInserted = (children: any) => {
|
||||
return (
|
||||
children.length === 1 &&
|
||||
!slots.icon &&
|
||||
isUnBorderedButtonType(props.type)
|
||||
)
|
||||
}
|
||||
|
||||
const fixTwoCNChar = (children: any) => {
|
||||
// console.log(buttonRef)
|
||||
// FIXME: for HOC usage like <FormatMessage />
|
||||
if (!buttonRef.value || autoInsertSpaceInButton.value === false) {
|
||||
return
|
||||
}
|
||||
const buttonText = buttonRef.value.textContent
|
||||
if (isNeedInserted(children) && isTwoCNChar(buttonText as string)) {
|
||||
if (!hasTwoCNChar) {
|
||||
setHasTwoCNChar(true)
|
||||
}
|
||||
} else if (hasTwoCNChar) {
|
||||
setHasTwoCNChar(false)
|
||||
}
|
||||
}
|
||||
|
||||
let delayTimer: number | null = null
|
||||
|
||||
onMounted(() => {
|
||||
@ -84,7 +108,6 @@ const Button = defineComponent({
|
||||
} else {
|
||||
setLoading(loadingOrDelay.value.loading)
|
||||
}
|
||||
// fixTwoCNChar()
|
||||
})
|
||||
|
||||
function cleanupTimer() {
|
||||
@ -128,29 +151,8 @@ const Button = defineComponent({
|
||||
const { shape, rootClassName, ghost, type, block, danger } = props
|
||||
const icon = getSlotsProps(slots, props, 'icon')
|
||||
const children = filterEmpty(slots.default?.())
|
||||
const isNeedInserted = () => {
|
||||
return (
|
||||
children.length === 1 &&
|
||||
!slots.icon &&
|
||||
isUnBorderedButtonType(props.type)
|
||||
)
|
||||
}
|
||||
|
||||
const fixTwoCNChar = () => {
|
||||
// FIXME: for HOC usage like <FormatMessage />
|
||||
if (!buttonRef.value || autoInsertSpaceInButton.value === false) {
|
||||
return
|
||||
}
|
||||
const buttonText = buttonRef.value.textContent
|
||||
if (isNeedInserted() && isTwoCNChar(buttonText as string)) {
|
||||
if (!hasTwoCNChar) {
|
||||
setHasTwoCNChar(true)
|
||||
}
|
||||
} else if (hasTwoCNChar) {
|
||||
setHasTwoCNChar(false)
|
||||
}
|
||||
}
|
||||
fixTwoCNChar()
|
||||
fixTwoCNChar(children)
|
||||
showError()
|
||||
const iconType = innerLoading.value ? 'loading' : icon
|
||||
|
||||
@ -198,7 +200,12 @@ const Button = defineComponent({
|
||||
)
|
||||
}
|
||||
let buttonNode = (
|
||||
<button {...attrs} onClick={handleClick} class={classes}>
|
||||
<button
|
||||
{...attrs}
|
||||
onClick={handleClick}
|
||||
class={classes}
|
||||
ref={buttonRef}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
|
@ -1,8 +1,20 @@
|
||||
import { booleanType, createInjectionState, functionType, objectType, someType, stringType } from '@v-c/utils'
|
||||
import {
|
||||
booleanType,
|
||||
createInjectionState,
|
||||
functionType,
|
||||
objectType,
|
||||
someType,
|
||||
stringType
|
||||
} from '@v-c/utils'
|
||||
import type { ExtractPropTypes } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import type { DerivativeFunc } from '@antd-tiny-vue/cssinjs'
|
||||
import type { AliasToken, MapToken, OverrideToken, SeedToken } from '../theme/interface'
|
||||
import type {
|
||||
AliasToken,
|
||||
MapToken,
|
||||
OverrideToken,
|
||||
SeedToken
|
||||
} from '../theme/interface'
|
||||
import type { RenderEmptyHandler } from './default-render-empty'
|
||||
import type { ConfigProviderProps } from './index'
|
||||
|
||||
@ -34,7 +46,10 @@ export interface ThemeConfig {
|
||||
}
|
||||
export const defaultIconPrefixCls = 'anticon'
|
||||
|
||||
const defaultGetPrefixCls = (suffixCls?: string, customizePrefixCls?: string) => {
|
||||
const defaultGetPrefixCls = (
|
||||
suffixCls?: string,
|
||||
customizePrefixCls?: string
|
||||
) => {
|
||||
if (customizePrefixCls) return customizePrefixCls
|
||||
|
||||
return suffixCls ? `ant-${suffixCls}` : 'ant'
|
||||
@ -82,11 +97,16 @@ const configState = (props: ConfigProviderProps) => {
|
||||
const getPrefixCls = (suffixCls?: string, customizePrefixCls?: string) => {
|
||||
const { prefixCls, getPrefixCls } = props
|
||||
if (customizePrefixCls) return customizePrefixCls
|
||||
const mergedPrefixCls = prefixCls || getPrefixCls?.('') || defaultGetPrefixCls('')
|
||||
const mergedPrefixCls =
|
||||
prefixCls || getPrefixCls?.('') || defaultGetPrefixCls('')
|
||||
return suffixCls ? `${mergedPrefixCls}-${suffixCls}` : mergedPrefixCls
|
||||
}
|
||||
const iconPrefixCls = computed(() => props?.iconPrefixCls ?? defaultIconPrefixCls)
|
||||
const shouldWrapSSR = computed(() => iconPrefixCls.value !== defaultIconPrefixCls)
|
||||
const iconPrefixCls = computed(
|
||||
() => props?.iconPrefixCls ?? defaultIconPrefixCls
|
||||
)
|
||||
const shouldWrapSSR = computed(
|
||||
() => iconPrefixCls.value !== defaultIconPrefixCls
|
||||
)
|
||||
const csp = computed(() => props?.csp)
|
||||
const componentSize = computed(() => props?.componentSize)
|
||||
const componentDisabled = computed(() => props?.componentDisabled)
|
||||
@ -103,7 +123,8 @@ const configState = (props: ConfigProviderProps) => {
|
||||
direction
|
||||
}
|
||||
}
|
||||
const [useProviderConfigProvide, useProviderConfigInject] = createInjectionState(configState)
|
||||
const [useProviderConfigProvide, useProviderConfigInject] =
|
||||
createInjectionState(configState)
|
||||
|
||||
export { useProviderConfigProvide }
|
||||
export const useProviderConfigState = (): ReturnType<typeof configState> => {
|
||||
@ -115,7 +136,7 @@ export const useProviderConfigState = (): ReturnType<typeof configState> => {
|
||||
componentSize: computed(() => undefined),
|
||||
componentDisabled: computed(() => false),
|
||||
direction: computed(() => undefined),
|
||||
autoInsertSpaceInButton: computed(() => undefined)
|
||||
autoInsertSpaceInButton: computed(() => true)
|
||||
} as any)
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user