mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2025-07-03 02:23:12 +08:00
feat: add button
This commit is contained in:
8
components/_util/hooks/disabled.ts
Normal file
8
components/_util/hooks/disabled.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import type { ComputedRef } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import { useProviderConfigState } from '../../config-provider/context'
|
||||
|
||||
export const useDisabled = (props: Record<string, any>) => {
|
||||
const { componentDisabled } = useProviderConfigState()
|
||||
return computed(() => props.disabled || componentDisabled.value) as ComputedRef<boolean>
|
||||
}
|
9
components/_util/hooks/size.ts
Normal file
9
components/_util/hooks/size.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { ComputedRef } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import type { SizeType } from '../../config-provider/context'
|
||||
import { useProviderConfigState } from '../../config-provider/context'
|
||||
|
||||
export const useSize = (props: Record<string, any>) => {
|
||||
const { componentSize } = useProviderConfigState()
|
||||
return computed(() => props.size || componentSize.value) as ComputedRef<SizeType>
|
||||
}
|
21
components/_util/warning.ts
Normal file
21
components/_util/warning.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { warning as rcWarning, resetWarned } from '@v-c/utils'
|
||||
|
||||
export { resetWarned }
|
||||
export function noop() {}
|
||||
|
||||
type Warning = (valid: boolean, component: string, message?: string) => void
|
||||
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
let warning: Warning = noop
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning = (valid, component, message) => {
|
||||
rcWarning(valid, `[antd: ${component}] ${message}`)
|
||||
|
||||
// StrictMode will inject console which will not throw warning in React 17.
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
resetWarned()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default warning
|
Reference in New Issue
Block a user