Skip to content

Commit ee6c7dc

Browse files
committed
fix: add missing events
1 parent 50934be commit ee6c7dc

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

src/components/form/CFormInput.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ const CFormInput = defineComponent({
6363
required: false,
6464
},
6565
},
66-
setup(props, { attrs, slots }) {
66+
emits: ['change', 'input'],
67+
setup(props, { attrs, emit, slots }) {
68+
const handleInput = (event: Event) => {
69+
const target = event.target as HTMLInputElement
70+
emit('input', target.value)
71+
}
72+
73+
const handleChange = (event: Event) => {
74+
const target = event.target as HTMLInputElement
75+
emit('change', target.value)
76+
}
6777
return () =>
6878
h(
6979
'input',
@@ -79,6 +89,8 @@ const CFormInput = defineComponent({
7989
'is-valid': props.valid,
8090
},
8191
],
92+
onChange: handleChange,
93+
onInput: handleInput,
8294
},
8395
slots.default && slots.default(),
8496
)

src/components/form/CFormSelect.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ const CFormSelect = defineComponent({
3939
required: false,
4040
},
4141
},
42-
setup(props, { attrs, slots }) {
42+
emits: ['change'],
43+
setup(props, { attrs, emit, slots }) {
44+
const handleChange = (event: Event) => {
45+
const target = event.target as HTMLSelectElement
46+
emit('change', Number(target.value))
47+
}
4348
return () =>
4449
h(
4550
'select',
@@ -52,6 +57,7 @@ const CFormSelect = defineComponent({
5257
},
5358
],
5459
size: props.htmlSize,
60+
onChange: handleChange,
5561
},
5662
slots.default && slots.default(),
5763
)

src/components/pagination/CPaginationItem.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ const CPaginationItem = defineComponent({
3636
required: false,
3737
},
3838
},
39-
setup(props, { slots }) {
39+
emits: ['click'],
40+
setup(props, { emit, slots }) {
41+
const handleClick = () => {
42+
emit('click')
43+
}
4044
return () => {
4145
const component = props.component ? props.component : props.active ? 'span' : 'a'
4246
return h(
@@ -58,6 +62,7 @@ const CPaginationItem = defineComponent({
5862
class: ['page-link'],
5963
component: component,
6064
href: props.href,
65+
onClick: handleClick,
6166
},
6267
{
6368
default: () => slots.default && slots.default(),

src/components/table/CTableRow.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ const CTableRow = defineComponent({
3232
*/
3333
color: Color,
3434
},
35-
setup(props, { slots }) {
35+
emits: ['click'],
36+
setup(props, { emit, slots }) {
37+
const handleClick = () => {
38+
emit('click')
39+
}
3640
return () =>
3741
h(
3842
'tr',
@@ -44,6 +48,7 @@ const CTableRow = defineComponent({
4448
[`table-${props.color}`]: props.color,
4549
},
4650
],
51+
onClick: handleClick,
4752
},
4853
slots.default && slots.default(),
4954
)

0 commit comments

Comments
 (0)