Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vue emit types #712

Merged
merged 4 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixes

- Only add `type=button` to real buttons ([#709](https://github.com/tailwindlabs/headlessui/pull/709))
- Add Vue emit types ([#679](https://github.com/tailwindlabs/headlessui/pull/679), [#712](https://github.com/tailwindlabs/headlessui/pull/712))

## [@headlessui/react@v1.4.0] - 2021-07-29

Expand Down
2 changes: 1 addition & 1 deletion packages/@headlessui-vue/src/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export let Dialog = defineComponent({
open: { type: [Boolean, String], default: Missing },
initialFocus: { type: Object as PropType<HTMLElement | null>, default: null },
},
emits: ['close'],
emits: { close: (_close: boolean) => true },
render() {
let propsWeControl = {
// Manually passthrough the attributes, because Vue can't automatically pass
Expand Down
2 changes: 1 addition & 1 deletion packages/@headlessui-vue/src/components/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function useListboxContext(component: string) {

export let Listbox = defineComponent({
name: 'Listbox',
emits: ['update:modelValue'],
emits: { 'update:modelValue': (_value: any) => true },
props: {
as: { type: [Object, String], default: 'template' },
disabled: { type: [Boolean], default: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function useRadioGroupContext(component: string) {

export let RadioGroup = defineComponent({
name: 'RadioGroup',
emits: ['update:modelValue'],
emits: { 'update:modelValue': (_value: any) => true },
props: {
as: { type: [Object, String], default: 'div' },
disabled: { type: [Boolean], default: false },
Expand Down
2 changes: 1 addition & 1 deletion packages/@headlessui-vue/src/components/switch/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export let SwitchGroup = defineComponent({

export let Switch = defineComponent({
name: 'Switch',
emits: ['update:modelValue'],
emits: { 'update:modelValue': (_value: boolean) => true },
props: {
as: { type: [Object, String], default: 'button' },
modelValue: { type: Boolean, default: false },
Expand Down
4 changes: 3 additions & 1 deletion packages/@headlessui-vue/src/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function useTabsContext(component: string) {

export let TabGroup = defineComponent({
name: 'TabGroup',
emits: ['change'],
emits: {
change: (_index: number) => true,
},
props: {
as: { type: [Object, String], default: 'template' },
defaultIndex: { type: [Number], default: 0 },
Expand Down
14 changes: 12 additions & 2 deletions packages/@headlessui-vue/src/components/transitions/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ export let TransitionChild = defineComponent({
leaveFrom: { type: [String], default: '' },
leaveTo: { type: [String], default: '' },
},
emits: ['beforeEnter', 'afterEnter', 'beforeLeave', 'afterLeave'],
emits: {
beforeEnter: () => true,
afterEnter: () => true,
beforeLeave: () => true,
afterLeave: () => true,
},
render() {
if (this.renderAsRoot) {
return h(
Expand Down Expand Up @@ -357,7 +362,12 @@ export let TransitionRoot = defineComponent({
leaveFrom: { type: [String], default: '' },
leaveTo: { type: [String], default: '' },
},
emits: ['beforeEnter', 'afterEnter', 'beforeLeave', 'afterLeave'],
emits: {
beforeEnter: () => true,
afterEnter: () => true,
beforeLeave: () => true,
afterLeave: () => true,
},
render() {
let { show, appear, unmount, ...passThroughProps } = this.$props
let sharedProps = { unmount }
Expand Down