UNPKG

@vuesax-alpha/nightly

Version:
1 lines 6.62 kB
{"version":3,"file":"input.mjs","sources":["../../../../../../packages/components/input/src/input.ts"],"sourcesContent":["import { isNil } from 'lodash-unified'\nimport { UPDATE_MODEL_EVENT } from '@vuesax-alpha/constants'\nimport { useColorProp } from '@vuesax-alpha/hooks'\nimport {\n buildProps,\n definePropType,\n isNumber,\n isString,\n} from '@vuesax-alpha/utils'\n\nimport type { ExtractPropTypes, StyleValue } from 'vue'\nimport type { EmitFn } from '@vuesax-alpha/utils'\nimport type Input from './input.vue'\n\nexport type InputValue = string | number | null | undefined\n\nexport const inputProps = buildProps({\n /**\n * @description native input readonly\n */\n clearable: {\n type: Boolean,\n default: false,\n },\n\n /**\n * @description Component color - Accept Vuesax's color, Hex, rgb\n */\n color: useColorProp,\n\n /**\n * @description whether Input is disabled\n */\n disabled: { type: Boolean },\n\n /**\n * @description put the icon to the back of the input\n */\n iconAfter: { type: Boolean },\n\n /**\n * @description input id\n */\n id: {\n type: String,\n default: null,\n },\n\n /**\n * @description input style\n * @enum `border` | `shadow` | `transparent`\n */\n inputStyle: {\n type: String,\n values: ['border', 'shadow', 'transparent'] as const,\n default: null,\n },\n\n /**\n * @description label is placeholder when input empty\n */\n labelFloat: {\n type: Boolean,\n default: false,\n },\n\n /**\n * @description a label above the component.\n */\n label: {\n type: String,\n default: null,\n },\n\n /**\n * @description Add a loading animation to the input.\n */\n loading: { type: Boolean },\n\n /**\n * @description binding value\n */\n modelValue: {\n type: definePropType<InputValue>([String, Number]),\n default: '',\n },\n\n /**\n * @description input placeholder\n */\n placeholder: {\n type: String,\n default: null,\n },\n\n /**\n * @description progress bar starting in red and ending in green.\n */\n progress: { type: Number },\n\n /**\n * @description input shape\n * @enum `rounded` | `square`\n */\n shape: {\n type: String,\n values: ['rounded', 'square'] as const,\n default: 'rounded',\n },\n\n /**\n * @description add toggleable password icon\n */\n showPassword: {\n type: Boolean,\n default: false,\n },\n\n /**\n * @description Change the background color of the component by changing its status.\n */\n state: useColorProp,\n\n /**\n * @description set text input to white color\n */\n textWhite: { type: Boolean },\n\n /**\n * @description type of input, native input type.\n */\n type: {\n type: String,\n default: 'text',\n },\n /** @description input wrapper classes */\n wrapClasses: {\n type: String,\n },\n /** @description input wrapper styles */\n wrapStyles: {\n type: definePropType<StyleValue>([String, Object, Array]),\n },\n\n /**\n * @description set input width 100%\n */\n block: { type: Boolean },\n\n /** @deprecated */\n border: Boolean,\n /** @deprecated */\n labelPlaceholder: String,\n /** @deprecated */\n shadow: Boolean,\n /** @deprecated */\n square: Boolean,\n /** @deprecated */\n transparent: Boolean,\n} as const)\n\nexport const inputEmits = {\n [UPDATE_MODEL_EVENT]: (text: InputValue) =>\n isString(text) || isNumber(text) || isNil(text),\n /**\n * @description triggers when clicking the icon\n */\n clickIcon: (evt: Event) => evt instanceof Event,\n /**\n * @description triggers when the Input is cleared by clicking the clear button\n */\n mouseleave: (evt: MouseEvent) => evt instanceof MouseEvent,\n mouseenter: (evt: MouseEvent) => evt instanceof MouseEvent,\n clear: () => true,\n input: (value: string) => !isNil(value),\n change: (value: string) => isString(value),\n focus: (evt: FocusEvent) => evt instanceof FocusEvent,\n blur: (evt: FocusEvent) => evt instanceof FocusEvent,\n\n // NOTE: when autofill by browser, the keydown event is instanceof Event, not KeyboardEvent\n keydown: (evt: KeyboardEvent | Event) => evt instanceof Event,\n}\n\nexport type InputEmits = typeof inputEmits\nexport type InputEmitsFn = EmitFn<InputEmits>\nexport type InputProps = ExtractPropTypes<typeof inputProps>\nexport type InputInstance = InstanceType<typeof Input>\n"],"names":[],"mappings":";;;;;;;;;;AAgBO,MAAM,aAAa,UAAW,CAAA;AAAA,EAInC,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAKA,KAAO,EAAA,YAAA;AAAA,EAKP,QAAA,EAAU,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,EAK1B,SAAA,EAAW,EAAE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