File tree Expand file tree Collapse file tree 7 files changed +119
-1
lines changed
packages/ui/src/components Expand file tree Collapse file tree 7 files changed +119
-1
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
- <button :class =" classes" @click =" $emit('click', $event)" >
2
+ <button class = " ant-btn " :class =" classes" @click =" $emit('click', $event)" >
3
3
<slot ></slot >
4
4
</button >
5
5
</template >
Original file line number Diff line number Diff line change 1
1
import { App , Plugin } from 'vue'
2
2
import Button from './Button.vue'
3
+ import './style/index.css'
4
+
5
+ // 导出组件
6
+ export { default as Button } from './Button.vue'
7
+ export * from './meta'
3
8
4
9
/* istanbul ignore next */
5
10
Button . install = function ( app : App ) {
Original file line number Diff line number Diff line change 1
1
export { default as Button } from './button'
2
+ export { default as Input } from './input'
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <input
3
+ class =" ant-input"
4
+ :class =" classes"
5
+ :value =" modelValue"
6
+ @input =" $emit('update:modelValue', ($event.target as HTMLInputElement).value)"
7
+ @focus =" $emit('focus', $event)"
8
+ @blur =" $emit('blur', $event)"
9
+ />
10
+ </template >
11
+
12
+ <script setup lang="ts">
13
+ import { computed } from ' vue'
14
+ import { inputProps , inputEmits , InputSlots } from ' ./meta'
15
+
16
+ const props = defineProps (inputProps )
17
+
18
+ defineEmits (inputEmits )
19
+ defineSlots <InputSlots >()
20
+
21
+ const classes = computed (() => {
22
+ return [
23
+ ' w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent' ,
24
+ {
25
+ ' border-red-500' : props .status === ' error' ,
26
+ ' border-yellow-500' : props .status === ' warning' ,
27
+ },
28
+ ]
29
+ })
30
+ </script >
Original file line number Diff line number Diff line change
1
+ import { App , Plugin } from 'vue'
2
+ import Input from './Input.vue'
3
+ import './style/index.css'
4
+
5
+ // 导出组件
6
+ export { default as Input } from './Input.vue'
7
+ export * from './meta'
8
+
9
+ /* istanbul ignore next */
10
+ Input . install = function ( app : App ) {
11
+ app . component ( 'AInput' , Input )
12
+ return app
13
+ }
14
+
15
+ export default Input as typeof Input & Plugin
Original file line number Diff line number Diff line change
1
+ import { PropType , ExtractPublicPropTypes } from 'vue'
2
+
3
+ // Input Props
4
+ export const inputProps = {
5
+ /**
6
+ * The input value
7
+ */
8
+ modelValue : {
9
+ type : String ,
10
+ default : '' ,
11
+ } ,
12
+ /**
13
+ * The status of the input
14
+ */
15
+ status : {
16
+ type : String as PropType < 'error' | 'warning' > ,
17
+ default : undefined ,
18
+ } ,
19
+ /**
20
+ * The placeholder text
21
+ */
22
+ placeholder : {
23
+ type : String ,
24
+ default : '' ,
25
+ } ,
26
+ /**
27
+ * Whether the input is disabled
28
+ */
29
+ disabled : {
30
+ type : Boolean ,
31
+ default : false ,
32
+ } ,
33
+ } as const
34
+
35
+ export type InputProps = ExtractPublicPropTypes < typeof inputProps >
36
+
37
+ // Input Emits
38
+ export const inputEmits = {
39
+ /**
40
+ * Triggered when the input value changes
41
+ */
42
+ 'update:modelValue' : ( value : string ) => typeof value === 'string' ,
43
+ /**
44
+ * Triggered when the input receives focus
45
+ */
46
+ focus : ( e : FocusEvent ) => e instanceof FocusEvent ,
47
+ /**
48
+ * Triggered when the input loses focus
49
+ */
50
+ blur : ( e : FocusEvent ) => e instanceof FocusEvent ,
51
+ } as const
52
+
53
+ export type InputEmits = typeof inputEmits
54
+
55
+ // Input Slots
56
+ export const inputSlots = { } as const
57
+
58
+ export type InputSlots = typeof inputSlots
Original file line number Diff line number Diff line change
1
+ /* Input component styles */
2
+ .ant-input {
3
+ transition : all 0.2s ease-in-out;
4
+ }
5
+
6
+ .ant-input : disabled {
7
+ opacity : 0.6 ;
8
+ cursor : not-allowed;
9
+ }
You can’t perform that action at this time.
0 commit comments