UNPKG

ano-ui

Version:

<p align="center"> <img src="https://github.com/ano-ui/ano-ui/raw/main/public/logo.svg" style="width:100px;" /> <h1 align="center">Ano-UI (WIP)</h1> <p align="center">An UniApp UI components with UnoCSS.</p> </p> <p align="center"> <a href="https://www.np

51 lines (42 loc) 1 kB
/** * prop type helpers * help us to write less code and reduce bundle size * copy from https://github.com/youzan/vant/blob/main/packages/vant/src/utils/props.ts */ import type { PropType } from 'vue' export const unknownProp = null as unknown as PropType<unknown> export const numericProp = [Number, String] export const truthProp = { type: Boolean, default: true as const, } export function makeRequiredProp<T>(type: T) { return { type, required: true as const, } } export function makeArrayProp<T>(defaultVal: T[] = []) { return { type: Array as PropType<T[]>, default: () => defaultVal, } } export function makeNumberProp<T>(defaultVal: T) { return { type: Number, default: defaultVal, } } export function makeNumericProp<T>(defaultVal: T) { return { type: numericProp, default: defaultVal, } } export function makeStringProp<T>(defaultVal: T) { return { type: String as unknown as PropType<T>, default: defaultVal, } }