From a00f4bc43e09799d558758b5f94ba5a047ec427f Mon Sep 17 00:00:00 2001 From: Shyrro Date: Fri, 12 May 2023 15:01:53 +0200 Subject: [PATCH] chore: export right types Signed-off-by: Shyrro --- packages/vue/src/accordion/accordion.tsx | 27 +++---- packages/vue/src/checkbox/checkbox.tsx | 49 ++++++++----- .../vue/src/color-picker/color-picker.tsx | 22 +++--- .../vue/src/color-picker/use-color-picker.ts | 2 + packages/vue/src/combobox/combobox.tsx | 70 ++++++++++--------- packages/vue/src/dialog/dialog.tsx | 39 ++++++----- packages/vue/src/dialog/use-dialog.ts | 2 + packages/vue/src/editable/editable.tsx | 49 +++++++------ packages/vue/src/editable/use-editable.ts | 2 + packages/vue/src/hover-card/hover-card.tsx | 25 ++++--- packages/vue/src/hover-card/use-hover-card.ts | 2 + packages/vue/src/menu/menu.tsx | 31 ++++---- .../vue/src/number-input/number-input.tsx | 64 +++++++++-------- .../vue/src/number-input/use-number-input.tsx | 2 + .../pagination/pagination-page-trigger.tsx | 2 +- .../vue/src/pagination/pagination.stories.vue | 3 +- packages/vue/src/pagination/pagination.tsx | 28 ++++---- packages/vue/src/pagination/use-pagination.ts | 2 + packages/vue/src/pin-input/pin-input.tsx | 46 ++++++------ packages/vue/src/pin-input/use-pin-input.ts | 2 + packages/vue/src/popover/popover.tsx | 37 +++++----- packages/vue/src/popover/use-popover.ts | 2 + packages/vue/src/pressable/pressable.tsx | 22 +++--- packages/vue/src/pressable/use-pressable.tsx | 2 + packages/vue/src/radio-group/radio-group.tsx | 32 +++++---- .../vue/src/range-slider/range-slider.tsx | 50 ++++++------- .../vue/src/rating-group/rating-group.tsx | 38 +++++----- packages/vue/src/select/select.tsx | 43 ++++++------ packages/vue/src/slider/slider.tsx | 52 +++++++------- packages/vue/src/splitter/splitter.tsx | 20 +++--- packages/vue/src/tabs/tabs.tsx | 28 ++++---- packages/vue/src/tags-input/index.ts | 2 +- packages/vue/src/tags-input/tags-input.tsx | 53 +++++++------- packages/vue/src/tooltip/tooltip.tsx | 33 +++++---- 34 files changed, 480 insertions(+), 403 deletions(-) diff --git a/packages/vue/src/accordion/accordion.tsx b/packages/vue/src/accordion/accordion.tsx index 29885be61e..9708456448 100644 --- a/packages/vue/src/accordion/accordion.tsx +++ b/packages/vue/src/accordion/accordion.tsx @@ -1,45 +1,46 @@ import { type Context } from '@zag-js/accordion' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { AccordionProvider } from './accordion-context' import { useAccordion } from './use-accordion' export type AccordionContext = Context & { modelValue?: AccordionContext['value'] } -export type AccordionProps = Assign, AccordionContext> -const VueAccordionProps = createVueProps({ +export type UseAccordionProps = Assign, AccordionContext> + +const VueAccordionProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, modelValue: { - type: [String, Object] as PropType, + type: [String, Object] as PropType, }, collapsible: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, multiple: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, ids: { - type: Object as PropType, + type: Object as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, orientation: { - type: String as PropType, + type: String as PropType, }, }) -export const Accordion: ComponentWithProps> = defineComponent({ +export const Accordion: ComponentWithProps> = defineComponent({ name: 'Accordion', emits: ['change', 'update:modelValue'], props: VueAccordionProps, @@ -55,3 +56,5 @@ export const Accordion: ComponentWithProps> = defineComp ) }, }) + +export type AccordionProps = Optional diff --git a/packages/vue/src/checkbox/checkbox.tsx b/packages/vue/src/checkbox/checkbox.tsx index 3906eb712e..bc91622426 100644 --- a/packages/vue/src/checkbox/checkbox.tsx +++ b/packages/vue/src/checkbox/checkbox.tsx @@ -1,7 +1,7 @@ import { type Context } from '@zag-js/checkbox' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { CheckboxProvider } from './checkbox-context' import { useCheckbox } from './use-checkbox' @@ -9,59 +9,68 @@ import { useCheckbox } from './use-checkbox' export type CheckboxContext = Context & { modelValue?: Context['checked'] } -export type CheckboxProps = Assign, CheckboxContext> +export type UseCheckboxProps = Assign, CheckboxContext> -export const VueCheckboxProps = createVueProps({ +export const VueCheckboxProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, 'aria-describedby': { - type: String as PropType, + type: String as PropType, }, 'aria-label': { - type: String as PropType, + type: String as PropType, }, 'aria-labelledby': { - type: String as PropType, + type: String as PropType, }, checked: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, + }, + focusable: { + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, + }, + indeterminate: { + type: Boolean as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, modelValue: { - type: [Boolean, String] as PropType, + type: [Boolean, String] as PropType, default: undefined, }, name: { - type: String as PropType, + type: String as PropType, + }, + readOnly: { + type: Boolean as PropType, }, required: { - type: Boolean as PropType, + type: Boolean as PropType, }, value: { - type: String as PropType, + type: String as PropType, }, }) -export const Checkbox: ComponentWithProps> = defineComponent({ +export const Checkbox: ComponentWithProps> = defineComponent({ name: 'Checkbox', emits: ['change', 'update:modelValue'], props: VueCheckboxProps, @@ -77,3 +86,5 @@ export const Checkbox: ComponentWithProps> = defineCompon ) }, }) + +export type CheckboxProps = Optional diff --git a/packages/vue/src/color-picker/color-picker.tsx b/packages/vue/src/color-picker/color-picker.tsx index c76698245b..3777347338 100644 --- a/packages/vue/src/color-picker/color-picker.tsx +++ b/packages/vue/src/color-picker/color-picker.tsx @@ -1,7 +1,7 @@ import { type Context } from '@zag-js/color-picker' import { defineComponent, type PropType } from 'vue' import type { HTMLArkProps } from '../factory' -import type { Assign } from '../types' +import type { Assign, Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { ColorPickerProvider } from './color-picker-context' import { useColorPicker } from './use-color-picker' @@ -9,29 +9,29 @@ import { useColorPicker } from './use-color-picker' export type ColorPickerContext = Context & { modelValue?: Context['value'] } -export type ColorPickerProps = Assign, ColorPickerContext> +export type UseColorPickerProps = Assign, ColorPickerContext> -const VueColorPickerProps = createVueProps({ +const VueColorPickerProps = createVueProps({ dir: { - type: String as PropType, + type: String as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, modelValue: { - type: String as PropType, + type: String as PropType, }, value: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, }) @@ -47,3 +47,5 @@ export const ColorPicker: ComponentWithProps> = defi return () => slots.default?.(api.value) }, }) + +export type ColorPickerProps = Optional diff --git a/packages/vue/src/color-picker/use-color-picker.ts b/packages/vue/src/color-picker/use-color-picker.ts index 2076ea20c7..94825eb426 100644 --- a/packages/vue/src/color-picker/use-color-picker.ts +++ b/packages/vue/src/color-picker/use-color-picker.ts @@ -27,3 +27,5 @@ export const useColorPicker = >( return computed(() => colorPicker.connect(state.value, send, normalizeProps)) } + +export type UseColorPickerReturn = ReturnType diff --git a/packages/vue/src/combobox/combobox.tsx b/packages/vue/src/combobox/combobox.tsx index 2d3f1e00c2..1786c3a37f 100644 --- a/packages/vue/src/combobox/combobox.tsx +++ b/packages/vue/src/combobox/combobox.tsx @@ -1,7 +1,7 @@ import { type Context } from '@zag-js/combobox' import { defineComponent, type PropType } from 'vue' -import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { ark } from '../factory' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { ComboboxProvider } from './combobox-context' import { useCombobox } from './use-combobox' @@ -9,98 +9,98 @@ import { useCombobox } from './use-combobox' export type ComboboxContext = Context & { modelValue?: ComboboxContext['inputValue'] } -export type ComboboxProps = Assign, ComboboxContext> +export type UseComboboxProps = ComboboxContext -const VueComboboxProps = createVueProps({ +const VueComboboxProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, modelValue: { - type: String as PropType, + type: String as PropType, }, allowCustomValue: { - type: Boolean as PropType, + type: Boolean as PropType, }, ariaHidden: { - type: Boolean as PropType, + type: Boolean as PropType, }, autoFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, blurOnSelect: { - type: Boolean as PropType, + type: Boolean as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, focusOnClear: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, inputBehavior: { - type: String as PropType, + type: String as PropType, }, inputValue: { - type: String as PropType, + type: String as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, isCustomValue: { - type: Function as PropType, + type: Function as PropType, }, loop: { - type: Boolean as PropType, + type: Boolean as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, openOnClick: { - type: Boolean as PropType, + type: Boolean as PropType, }, placeholder: { - type: String as PropType, + type: String as PropType, }, positioning: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, - selectInputOnfocus: { - type: Boolean as PropType, + selectInputOnFocus: { + type: Boolean as PropType, }, selectOnTab: { - type: Boolean as PropType, + type: Boolean as PropType, }, selectionBehavior: { - type: String as PropType, + type: String as PropType, }, selectionData: { - type: Object as PropType, + type: Object as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, }) -export const Combobox: ComponentWithProps> = defineComponent({ +export const Combobox: ComponentWithProps> = defineComponent({ name: 'Combobox', props: VueComboboxProps, emits: ['close', 'open', 'highlight', 'input-change', 'update:modelValue', 'select'], setup(props, { slots, attrs, emit }) { - const api = useCombobox(emit, props) + const api = useCombobox(emit, props as UseComboboxProps) ComboboxProvider(api) @@ -111,3 +111,5 @@ export const Combobox: ComponentWithProps> = defineCompon ) }, }) + +export type ComboboxProps = Optional diff --git a/packages/vue/src/dialog/dialog.tsx b/packages/vue/src/dialog/dialog.tsx index 503548f4fe..93fcb4960b 100644 --- a/packages/vue/src/dialog/dialog.tsx +++ b/packages/vue/src/dialog/dialog.tsx @@ -1,65 +1,66 @@ import { type Context as DialogContext } from '@zag-js/dialog' import { defineComponent, type PropType } from 'vue' -import { type HTMLArkProps } from '../factory' -import type { Assign } from '../types' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { DialogProvider } from './dialog-context' import { useDialog } from './use-dialog' -export type DialogProps = Assign, DialogContext> +export type UseDialogProps = DialogContext -const VueDialogProps = createVueProps({ +const VueDialogProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, trapFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, preventScroll: { - type: Boolean as PropType, + type: Boolean as PropType, }, modal: { - type: Boolean as PropType, + type: Boolean as PropType, }, initialFocusEl: { - type: Object as PropType, + type: Object as PropType, }, finalFocusEl: { - type: Object as PropType, + type: Object as PropType, }, restoreFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, closeOnOutsideClick: { - type: Boolean as PropType, + type: Boolean as PropType, default: true, }, closeOnEsc: { - type: Boolean as PropType, + type: Boolean as PropType, }, 'aria-label': { - type: String as PropType, + type: String as PropType, }, role: { - type: String as PropType, + type: String as PropType, }, open: { - type: Boolean as PropType, + type: Boolean as PropType, }, }) -export const Dialog: ComponentWithProps> = defineComponent({ +export const Dialog: ComponentWithProps> = defineComponent({ name: 'Dialog', props: VueDialogProps, emits: ['close', 'outside-click', 'esc'], setup(props, { slots, emit }) { - const api = useDialog(emit, props) + const api = useDialog(emit, props as UseDialogProps) DialogProvider(api) return () => slots?.default?.(api.value) }, }) + +export type DialogProps = Optional diff --git a/packages/vue/src/dialog/use-dialog.ts b/packages/vue/src/dialog/use-dialog.ts index a46497fbb5..42264f0f57 100644 --- a/packages/vue/src/dialog/use-dialog.ts +++ b/packages/vue/src/dialog/use-dialog.ts @@ -43,3 +43,5 @@ export const useDialog = >( return api } + +export type UseDialogReturn = ReturnType diff --git a/packages/vue/src/editable/editable.tsx b/packages/vue/src/editable/editable.tsx index cc0fdd7ae7..b67128dc40 100644 --- a/packages/vue/src/editable/editable.tsx +++ b/packages/vue/src/editable/editable.tsx @@ -1,78 +1,79 @@ import { type Context } from '@zag-js/editable' import { defineComponent, type PropType } from 'vue' import { ark } from '../factory' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { EditableProvider } from './editable-context' import { useEditable } from './use-editable' -export type EditableProps = Context & { modelValue?: Context['value'] } +export type UseEditableProps = Context & { modelValue?: Context['value'] } -const VueEditableProps = createVueProps({ +const VueEditableProps = createVueProps({ activationMode: { - type: String as PropType, + type: String as PropType, }, autoResize: { - type: Boolean as PropType, + type: Boolean as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, maxLength: { - type: Number as PropType, + type: Number as PropType, }, modelValue: { - type: String as PropType, + type: String as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, placeholder: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, selectOnFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, startWithEditView: { - type: Boolean as PropType, + type: Boolean as PropType, }, submitMode: { - type: String as PropType, + type: String as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, value: { - type: String as PropType, + type: String as PropType, }, }) -export const Editable: ComponentWithProps> = defineComponent({ +export const Editable: ComponentWithProps> = defineComponent({ name: 'Editable', props: VueEditableProps, emits: ['cancel', 'change', 'update:modelValue', 'edit', 'submit'], setup(props, { slots, attrs, emit }) { - const api = useEditable(emit, props as EditableProps) + const api = useEditable(emit, props as UseEditableProps) EditableProvider(api) @@ -83,3 +84,5 @@ export const Editable: ComponentWithProps> = defineCompon ) }, }) + +export type EditableProps = Optional diff --git a/packages/vue/src/editable/use-editable.ts b/packages/vue/src/editable/use-editable.ts index a2d560b75e..92a8ad9c81 100644 --- a/packages/vue/src/editable/use-editable.ts +++ b/packages/vue/src/editable/use-editable.ts @@ -33,3 +33,5 @@ export const useEditable = >( return computed(() => connect(state.value, send, normalizeProps)) } + +export type UseEditableReturn = ReturnType diff --git a/packages/vue/src/hover-card/hover-card.tsx b/packages/vue/src/hover-card/hover-card.tsx index d6e03cfdb3..51373a5ea5 100644 --- a/packages/vue/src/hover-card/hover-card.tsx +++ b/packages/vue/src/hover-card/hover-card.tsx @@ -1,40 +1,41 @@ import { type Context as HoverCardContext } from '@zag-js/hover-card' import { defineComponent, type PropType } from 'vue' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { HoverCardProvider } from './hover-card-context' import { useHoverCard } from './use-hover-card' -export type HoverCardProps = HoverCardContext +export type UseHoverCardProps = HoverCardContext -const VueHoverCardProps = createVueProps({ +const VueHoverCardProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, openDelay: { - type: Number as PropType, + type: Number as PropType, }, closeDelay: { - type: Number as PropType, + type: Number as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, open: { - type: Boolean as PropType, + type: Boolean as PropType, }, positioning: { - type: Object as PropType, + type: Object as PropType, }, }) -export const HoverCard: ComponentWithProps> = defineComponent({ +export const HoverCard: ComponentWithProps> = defineComponent({ name: 'HoverCard', props: VueHoverCardProps, emits: ['open', 'close'], @@ -46,3 +47,5 @@ export const HoverCard: ComponentWithProps> = defineComp return () => slots?.default?.(api.value) }, }) + +export type HoverCardProps = Optional diff --git a/packages/vue/src/hover-card/use-hover-card.ts b/packages/vue/src/hover-card/use-hover-card.ts index 06223e15fa..7830135d8a 100644 --- a/packages/vue/src/hover-card/use-hover-card.ts +++ b/packages/vue/src/hover-card/use-hover-card.ts @@ -25,3 +25,5 @@ export const useHoverCard = >( return computed(() => connect(state.value, send, normalizeProps)) } + +export type UseHoverCardReturn = ReturnType diff --git a/packages/vue/src/menu/menu.tsx b/packages/vue/src/menu/menu.tsx index f6d6f5f6e4..a68a4a2425 100644 --- a/packages/vue/src/menu/menu.tsx +++ b/packages/vue/src/menu/menu.tsx @@ -1,5 +1,6 @@ import type { Context } from '@zag-js/menu' import { computed, defineComponent, onMounted, type PropType } from 'vue' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { MenuMachineProvider, @@ -15,47 +16,47 @@ export type MenuState = { onClose: () => void } -export type MenuProps = Context & { isOpen?: boolean } +export type UseMenuProps = Context & { isOpen?: boolean } -const VueProps = createVueProps({ +const VueProps = createVueProps({ anchorPoint: { - type: Object as PropType, + type: Object as PropType, }, 'aria-label': { - type: String as PropType, + type: String as PropType, }, closeOnSelect: { - type: Boolean as PropType, + type: Boolean as PropType, default: true, }, dir: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, isOpen: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, loop: { - type: Boolean as PropType, + type: Boolean as PropType, }, positioning: { - type: Object as PropType, + type: Object as PropType, }, value: { - type: Object as PropType, + type: Object as PropType, }, }) -export const Menu: ComponentWithProps> = defineComponent({ +export const Menu: ComponentWithProps> = defineComponent({ name: 'Menu', props: VueProps, emits: ['close', 'open', 'select', 'value-change'], @@ -95,3 +96,5 @@ export const Menu: ComponentWithProps> = defineComponent({ return () => slots.default?.({ isOpen: api.value.isOpen, close: api.value.close }) }, }) + +export type MenuProps = Optional diff --git a/packages/vue/src/number-input/number-input.tsx b/packages/vue/src/number-input/number-input.tsx index 9e9ef1f9db..c7b384ff91 100644 --- a/packages/vue/src/number-input/number-input.tsx +++ b/packages/vue/src/number-input/number-input.tsx @@ -1,100 +1,100 @@ import type { Context } from '@zag-js/number-input' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { NumberInputProvider } from './number-input-context' import { useNumberInput } from './use-number-input' export type NumberInputContext = Context & { modelValue?: Context['value'] } -export type NumberInputProps = Assign, NumberInputContext> +export type UseNumberInputProps = Assign, NumberInputContext> -const VueNumberInputProps = createVueProps({ +const VueNumberInputProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, allowMouseWheel: { - type: Boolean as PropType, + type: Boolean as PropType, }, allowOverflow: { - type: Boolean as PropType, + type: Boolean as PropType, }, clampValueOnBlur: { - type: Boolean as PropType, + type: Boolean as PropType, default: true, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, focusInputOnChange: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, format: { - type: Function as PropType, + type: Function as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, inputMode: { - type: String as PropType, + type: String as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, max: { - type: Number as PropType, + type: Number as PropType, }, maxFractionDigits: { - type: Number as PropType, + type: Number as PropType, }, min: { - type: Number as PropType, + type: Number as PropType, }, minFractionDigits: { - type: Number as PropType, + type: Number as PropType, }, modelValue: { - type: String as PropType, + type: String as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, parse: { - type: Function as PropType, + type: Function as PropType, }, pattern: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, spinOnPress: { - type: Boolean as PropType, + type: Boolean as PropType, }, step: { - type: Number as PropType, + type: Number as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, validateCharacter: { - type: Function as PropType, + type: Function as PropType, }, value: { - type: String as PropType, + type: String as PropType, }, }) -export const NumberInput: ComponentWithProps> = defineComponent({ +export const NumberInput: ComponentWithProps> = defineComponent({ name: 'NumberInput', emits: ['change', 'focus', 'invalid', 'blur', 'update:modelValue'], props: VueNumberInputProps, @@ -106,3 +106,5 @@ export const NumberInput: ComponentWithProps> = define return () => {() => slots?.default?.(api.value)} }, }) + +export type NumberInputProps = Optional diff --git a/packages/vue/src/number-input/use-number-input.tsx b/packages/vue/src/number-input/use-number-input.tsx index ded4e8cf66..cdd0470aa7 100644 --- a/packages/vue/src/number-input/use-number-input.tsx +++ b/packages/vue/src/number-input/use-number-input.tsx @@ -33,3 +33,5 @@ export const useNumberInput = >( return computed(() => connect(state.value, send, normalizeProps)) } + +export type UseNumberInputReturn = ReturnType diff --git a/packages/vue/src/pagination/pagination-page-trigger.tsx b/packages/vue/src/pagination/pagination-page-trigger.tsx index a28c7f51ff..f27f3b4fd5 100644 --- a/packages/vue/src/pagination/pagination-page-trigger.tsx +++ b/packages/vue/src/pagination/pagination-page-trigger.tsx @@ -6,7 +6,7 @@ import { usePaginationContext } from './pagination-context' export type PaginationPageTriggerProps = HTMLArkProps<'li'> & PageTriggerProps -export const PaginationPageTrigger: ComponentWithProps = +export const PaginationPageTrigger: ComponentWithProps> = defineComponent({ name: 'PaginationPageTrigger', props: { diff --git a/packages/vue/src/pagination/pagination.stories.vue b/packages/vue/src/pagination/pagination.stories.vue index 5f7d5c45da..e3d070450b 100644 --- a/packages/vue/src/pagination/pagination.stories.vue +++ b/packages/vue/src/pagination/pagination.stories.vue @@ -8,6 +8,7 @@ import { PaginationPageTrigger, PaginationPrevPageTrigger, } from './' + import './pagination.css' diff --git a/packages/vue/src/pagination/pagination.tsx b/packages/vue/src/pagination/pagination.tsx index 3628e57465..44ab0c2855 100644 --- a/packages/vue/src/pagination/pagination.tsx +++ b/packages/vue/src/pagination/pagination.tsx @@ -1,45 +1,45 @@ import type { Context as PaginationContext } from '@zag-js/pagination' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { PaginationProvider } from './pagination-context' import { usePagination } from './use-pagination' -export type PaginationProps = Assign, PaginationContext> +export type UsePaginationProps = Assign, PaginationContext> -const VueProps = createVueProps({ +const VueProps = createVueProps({ count: { - type: Number as PropType, + type: Number as PropType, required: true, }, dir: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, page: { - type: Number as PropType, + type: Number as PropType, }, pageSize: { - type: Number as PropType, + type: Number as PropType, }, siblingCount: { - type: Number as PropType, + type: Number as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, }) -export const Pagination: ComponentWithProps> = defineComponent({ +export const Pagination: ComponentWithProps> = defineComponent({ name: 'Pagination', props: VueProps, emits: ['change'], @@ -55,3 +55,5 @@ export const Pagination: ComponentWithProps> = defineCo ) }, }) + +export type PaginationProps = Optional diff --git a/packages/vue/src/pagination/use-pagination.ts b/packages/vue/src/pagination/use-pagination.ts index f09a3cbd00..f3a04e1153 100644 --- a/packages/vue/src/pagination/use-pagination.ts +++ b/packages/vue/src/pagination/use-pagination.ts @@ -22,3 +22,5 @@ export const usePagination = >( return computed(() => connect(state.value, send, normalizeProps)) } + +export type UsePaginationReturn = ReturnType diff --git a/packages/vue/src/pin-input/pin-input.tsx b/packages/vue/src/pin-input/pin-input.tsx index 903ff8c934..52a3e811d4 100644 --- a/packages/vue/src/pin-input/pin-input.tsx +++ b/packages/vue/src/pin-input/pin-input.tsx @@ -1,7 +1,7 @@ import { type Context } from '@zag-js/pin-input' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { PinInputProvider } from './pin-input-context' import { usePinInput } from './use-pin-input' @@ -9,66 +9,66 @@ import { usePinInput } from './use-pin-input' export type PinInputContext = Context & { modelValue?: PinInputContext['value'] } -export type PinInputProps = Assign, PinInputContext> +export type UsePinInputProps = Assign, PinInputContext> -const VuePinInputProps = createVueProps({ +const VuePinInputProps = createVueProps({ autoFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, blurOnComplete: { - type: Boolean as PropType, + type: Boolean as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, mask: { - type: Boolean as PropType, + type: Boolean as PropType, }, modelValue: { - type: Array as PropType, + type: Array as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, otp: { - type: Boolean as PropType, + type: Boolean as PropType, }, pattern: { - type: String as PropType, + type: String as PropType, }, placeholder: { - type: String as PropType, + type: String as PropType, }, selectOnFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, type: { - type: String as PropType, + type: String as PropType, }, value: { - type: Array as PropType, + type: Array as PropType, }, }) -export const PinInput: ComponentWithProps> = defineComponent({ +export const PinInput: ComponentWithProps> = defineComponent({ name: 'PinInput', props: VuePinInputProps, emits: ['change', 'update:modelValue', 'invalid', 'complete'], @@ -84,3 +84,5 @@ export const PinInput: ComponentWithProps> = defineCompon ) }, }) + +export type PinInputProps = Optional diff --git a/packages/vue/src/pin-input/use-pin-input.ts b/packages/vue/src/pin-input/use-pin-input.ts index 6d139c740d..88d1637a83 100644 --- a/packages/vue/src/pin-input/use-pin-input.ts +++ b/packages/vue/src/pin-input/use-pin-input.ts @@ -32,3 +32,5 @@ export const usePinInput = >( return api } + +export type UsePinInputReturn = ReturnType diff --git a/packages/vue/src/popover/popover.tsx b/packages/vue/src/popover/popover.tsx index 2c45a22bff..05bb25f856 100644 --- a/packages/vue/src/popover/popover.tsx +++ b/packages/vue/src/popover/popover.tsx @@ -1,6 +1,7 @@ import type { Context } from '@zag-js/popover' import { defineComponent, type PropType } from 'vue' -import { createVueProps } from '../utils' +import type { Optional } from '../types' +import { createVueProps, type ComponentWithProps } from '../utils' import { PopoverProvider } from './popover-context' import { usePopover } from './use-popover' @@ -12,49 +13,49 @@ export type PopoverContext = Context & { */ isOpen?: boolean } -export type PopoverProps = PopoverContext +export type UsePopoverProps = PopoverContext -const VuePopoverProps = createVueProps({ +const VuePopoverProps = createVueProps>({ autoFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, closeOnEsc: { - type: Boolean as PropType, + type: Boolean as PropType, }, closeOnInteractOutside: { - type: Boolean as PropType, + type: Boolean as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, initialFocusEl: { - type: [Object, Function] as PropType, + type: [Object, Function] as PropType, }, isOpen: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, modal: { - type: Boolean as PropType, + type: Boolean as PropType, }, portalled: { - type: Boolean as PropType, + type: Boolean as PropType, }, open: { - type: Boolean as PropType, + type: Boolean as PropType, }, positioning: { - type: Object as PropType, + type: Object as PropType, }, }) -export const Popover = defineComponent({ +export const Popover: ComponentWithProps> = defineComponent({ name: 'Popover', props: VuePopoverProps, emits: [ @@ -66,10 +67,12 @@ export const Popover = defineComponent({ 'pointer-down-outside', ], setup(props, { slots, emit }) { - const api = usePopover(emit, props) + const api = usePopover(emit, props as Partial) PopoverProvider(api) return () => slots.default?.(api.value) }, }) + +export type PopoverProps = Optional diff --git a/packages/vue/src/popover/use-popover.ts b/packages/vue/src/popover/use-popover.ts index 4163a5b7e0..2fb8a8d0b7 100644 --- a/packages/vue/src/popover/use-popover.ts +++ b/packages/vue/src/popover/use-popover.ts @@ -55,3 +55,5 @@ export const usePopover = >( return api } + +export type UsePopoverReturn = ReturnType diff --git a/packages/vue/src/pressable/pressable.tsx b/packages/vue/src/pressable/pressable.tsx index 630a344e17..75db5e29c0 100644 --- a/packages/vue/src/pressable/pressable.tsx +++ b/packages/vue/src/pressable/pressable.tsx @@ -1,34 +1,34 @@ import type { Context as PressableContext } from '@zag-js/pressable' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { usePressable } from './use-pressable' -export type PressableProps = Assign, PressableContext> +export type UsePressableProps = Assign, PressableContext> -const VueProps = createVueProps({ +const VueProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, cancelOnPointerExit: { - type: Boolean as PropType, + type: Boolean as PropType, }, preventFocusOnPress: { - type: Boolean as PropType, + type: Boolean as PropType, }, allowTextSelectionOnPress: { - type: Boolean as PropType, + type: Boolean as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, }) -export const Pressable: ComponentWithProps> = defineComponent({ +export const Pressable: ComponentWithProps> = defineComponent({ name: 'Pressable', props: VueProps, emits: ['press', 'long-press', 'press-end', 'press-up', 'press-start'], @@ -41,3 +41,5 @@ export const Pressable: ComponentWithProps> = defineComp ) }, }) + +export type PressableProps = Optional diff --git a/packages/vue/src/pressable/use-pressable.tsx b/packages/vue/src/pressable/use-pressable.tsx index 703f9d402c..65fe77b965 100644 --- a/packages/vue/src/pressable/use-pressable.tsx +++ b/packages/vue/src/pressable/use-pressable.tsx @@ -3,6 +3,8 @@ import { normalizeProps, useMachine } from '@zag-js/vue' import { computed, reactive, type ExtractPropTypes } from 'vue' import { useId } from '../utils' +export type UsePressableContext = PressableContext + export const usePressable = >( emit: CallableFunction, context: T, diff --git a/packages/vue/src/radio-group/radio-group.tsx b/packages/vue/src/radio-group/radio-group.tsx index 7d422b603c..0a6f62134c 100644 --- a/packages/vue/src/radio-group/radio-group.tsx +++ b/packages/vue/src/radio-group/radio-group.tsx @@ -1,7 +1,7 @@ import type { Context } from '@zag-js/radio-group' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { RadioGroupProvider } from './radio-context' import { useRadioGroup } from './use-radio-group' @@ -9,45 +9,45 @@ import { useRadioGroup } from './use-radio-group' export type RadioGroupContext = Context & { modelValue?: Context['value'] } -export type RadioGroupProps = Assign, RadioGroupContext> +export type UseRadioGroupProps = Assign, RadioGroupContext> -const VueProps = createVueProps({ +const VueProps = createVueProps({ dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, modelValue: { - type: String as PropType, + type: String as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, orientation: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, value: { - type: String as PropType, + type: String as PropType, }, }) -export const RadioGroup: ComponentWithProps> = defineComponent({ +export const RadioGroup: ComponentWithProps> = defineComponent({ name: 'RadioGroup', props: VueProps, emits: ['change', 'update:modelValue'], @@ -63,3 +63,5 @@ export const RadioGroup: ComponentWithProps> = defineCo ) }, }) + +export type RadioGroupProps = Optional diff --git a/packages/vue/src/range-slider/range-slider.tsx b/packages/vue/src/range-slider/range-slider.tsx index f3051fcf0e..383fb9d18e 100644 --- a/packages/vue/src/range-slider/range-slider.tsx +++ b/packages/vue/src/range-slider/range-slider.tsx @@ -1,7 +1,7 @@ import type { Context } from '@zag-js/range-slider' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { RangeSliderProvider } from './range-slider-context' import { useRangeSlider } from './use-range-slider' @@ -10,72 +10,72 @@ export type RangeSliderContext = Context & { modelValue?: Context['value'] } -export type RangeSliderProps = Assign, RangeSliderContext> +export type UseRangeSliderProps = Assign, RangeSliderContext> -const VueProps = createVueProps({ +const VueProps = createVueProps({ 'aria-label': { - type: Object as PropType, + type: Object as PropType, }, 'aria-labelledby': { - type: Object as PropType, + type: Object as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getAriaValueText: { - type: Function as PropType, + type: Function as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, max: { - type: Number as PropType, + type: Number as PropType, }, min: { - type: Number as PropType, + type: Number as PropType, }, minStepsBetweenThumbs: { - type: Number as PropType, + type: Number as PropType, }, modelValue: { - type: Object as PropType, + type: Object as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, orientation: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, step: { - type: Number as PropType, + type: Number as PropType, }, thumbAlignment: { - type: String as PropType, + type: String as PropType, }, value: { - type: Object as PropType, + type: Object as PropType, }, }) -export const RangeSlider: ComponentWithProps> = defineComponent({ +export const RangeSlider: ComponentWithProps> = defineComponent({ name: 'RangeSlider', props: VueProps, emits: ['change', 'update:modelValue', 'change-start', 'change-end'], @@ -95,3 +95,5 @@ export const RangeSlider: ComponentWithProps> = define ) }, }) + +export type RangeSliderProps = Optional diff --git a/packages/vue/src/rating-group/rating-group.tsx b/packages/vue/src/rating-group/rating-group.tsx index 69399716a1..4181bb8717 100644 --- a/packages/vue/src/rating-group/rating-group.tsx +++ b/packages/vue/src/rating-group/rating-group.tsx @@ -1,7 +1,7 @@ import type { Context } from '@zag-js/rating-group' import { defineComponent, Fragment, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import type { Assign } from '../types' +import type { Assign, Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { RatingGroupProvider } from './rating-group-context' import { useRatingGroup } from './use-rating-group' @@ -10,54 +10,54 @@ export type RatingGroupContext = Context & { modelValue?: RatingGroupContext['value'] } -export type RatingGroupProps = Assign, RatingGroupContext> +export type UseRatingGroupProps = Assign, RatingGroupContext> -const vueRatingGroupProps = createVueProps({ +const vueRatingGroupProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, allowHalf: { - type: Boolean as PropType, + type: Boolean as PropType, }, autoFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, max: { - type: Number as PropType, + type: Number as PropType, }, modelValue: { - type: Number as PropType, + type: Number as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, value: { - type: Number as PropType, + type: Number as PropType, }, }) -export const RatingGroup: ComponentWithProps> = defineComponent({ +export const RatingGroup: ComponentWithProps> = defineComponent({ name: 'RatingGroup', props: vueRatingGroupProps, emits: ['change', 'update:modelValue', 'hover'], @@ -76,3 +76,5 @@ export const RatingGroup: ComponentWithProps> = define ) }, }) + +export type RatingGroupProps = Optional diff --git a/packages/vue/src/select/select.tsx b/packages/vue/src/select/select.tsx index 075f16084b..e415402059 100644 --- a/packages/vue/src/select/select.tsx +++ b/packages/vue/src/select/select.tsx @@ -1,5 +1,6 @@ import type { Context } from '@zag-js/select' import { defineComponent, type PropType } from 'vue' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { SelectProvider } from './select-context' import { useSelect } from './use-select' @@ -8,72 +9,74 @@ export type SelectContext = Context & { modelValue?: Context['selectedOption'] } -export type SelectProps = SelectContext +export type UseSelectProps = SelectContext -const VueSelectProps = createVueProps({ +const VueSelectProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, modelValue: { - type: [Object, null] as PropType, + type: [Object, null] as PropType, }, loop: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, closeOnSelect: { - type: Boolean as PropType, + type: Boolean as PropType, default: true, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, default: false, }, name: { - type: String as PropType, + type: String as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, positioning: { - type: Object as PropType, + type: Object as PropType, }, highlightedOption: { - type: Object as PropType, + type: Object as PropType, }, selectOnTab: { - type: Boolean as PropType, + type: Boolean as PropType, }, selectedOption: { - type: Object as PropType, + type: Object as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, }) -export const Select: ComponentWithProps> = defineComponent({ +export const Select: ComponentWithProps> = defineComponent({ name: 'Select', emits: ['change', 'highlight', 'open', 'close', 'update:modelValue'], props: VueSelectProps, setup(props, { slots, emit }) { - const api = useSelect(emit, props as SelectProps) + const api = useSelect(emit, props as UseSelectProps) SelectProvider(api) return () => slots?.default?.(api.value) }, }) + +export type SelectProps = Optional diff --git a/packages/vue/src/slider/slider.tsx b/packages/vue/src/slider/slider.tsx index d7691aff22..6f6692140b 100644 --- a/packages/vue/src/slider/slider.tsx +++ b/packages/vue/src/slider/slider.tsx @@ -1,7 +1,7 @@ import type { Context } from '@zag-js/slider' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, getValidChildren, type ComponentWithProps } from '../utils' import { SliderProvider } from './slider-context' import { useSlider } from './use-slider' @@ -10,75 +10,75 @@ export type SliderContext = Context & { modelValue?: Context['value'] } -export type SliderProps = Assign, SliderContext> +export type UseSliderProps = Assign, SliderContext> -const VueProps = createVueProps({ +const VueProps = createVueProps({ 'aria-label': { - type: String as PropType, + type: String as PropType, }, 'aria-labelledby': { - type: String as PropType, + type: String as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, focusThumbOnChange: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getAriaValueText: { - type: Function as PropType, + type: Function as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, max: { - type: Number as PropType, + type: Number as PropType, }, min: { - type: Number as PropType, + type: Number as PropType, }, modelValue: { - type: Number as PropType, + type: Number as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, orientation: { - type: String as PropType, + type: String as PropType, }, origin: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, step: { - type: Number as PropType, + type: Number as PropType, }, thumbAlignment: { - type: String as PropType, + type: String as PropType, }, value: { - type: Number as PropType, + type: Number as PropType, }, }) -export const Slider: ComponentWithProps> = defineComponent({ +export const Slider: ComponentWithProps> = defineComponent({ name: 'Slider', props: VueProps, setup(props, { slots, attrs, emit, expose }) { @@ -97,3 +97,5 @@ export const Slider: ComponentWithProps> = defineComponent( ) }, }) + +export type SliderProps = Optional diff --git a/packages/vue/src/splitter/splitter.tsx b/packages/vue/src/splitter/splitter.tsx index a923d6d808..1753481f76 100644 --- a/packages/vue/src/splitter/splitter.tsx +++ b/packages/vue/src/splitter/splitter.tsx @@ -1,31 +1,31 @@ import type { Context as SplitterContext } from '@zag-js/splitter' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, getValidChildren, type ComponentWithProps } from '../utils' import { SplitterProvider } from './splitter-context' import { useSplitter } from './use-splitter' -export type SplitterProps = Assign, SplitterContext> -const VueProps = createVueProps({ +export type UseSplitterProps = Assign, SplitterContext> +const VueProps = createVueProps({ dir: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, orientation: { - type: String as PropType, + type: String as PropType, }, size: { - type: Object as PropType, + type: Object as PropType, }, }) -export const Splitter: ComponentWithProps> = defineComponent({ +export const Splitter: ComponentWithProps> = defineComponent({ name: 'Splitter', props: VueProps, emits: ['resize', 'resize-end', 'resize-start'], @@ -41,3 +41,5 @@ export const Splitter: ComponentWithProps> = defineCompon ) }, }) + +export type SplitterProps = Optional diff --git a/packages/vue/src/tabs/tabs.tsx b/packages/vue/src/tabs/tabs.tsx index 777c6b6992..92915ca362 100644 --- a/packages/vue/src/tabs/tabs.tsx +++ b/packages/vue/src/tabs/tabs.tsx @@ -1,7 +1,7 @@ import type { Context } from '@zag-js/tabs' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import { type Assign } from '../types' +import { type Assign, type Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { TabsProvider } from './tabs-context' import { useTabs } from './use-tabs' @@ -9,39 +9,39 @@ import { useTabs } from './use-tabs' export type TabsContext = Context & { defaultValue?: Context['value'] } -export type TabsProps = Assign, TabsContext> +export type UseTabsProps = Assign, TabsContext> -const VueTabsProps = createVueProps({ +const VueTabsProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, defaultValue: { - type: String as PropType, + type: String as PropType, }, orientation: { - type: String as PropType, + type: String as PropType, }, activationMode: { - type: String as PropType, + type: String as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, loop: { - type: Boolean as PropType, + type: Boolean as PropType, }, translation: { - type: Object as PropType, + type: Object as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, }) -export const Tabs: ComponentWithProps> = defineComponent({ +export const Tabs: ComponentWithProps> = defineComponent({ name: 'Tabs', emits: ['change', 'focus', 'delete'], props: VueTabsProps, @@ -60,3 +60,5 @@ export const Tabs: ComponentWithProps> = defineComponent({ ) }, }) + +export type TabsProps = Optional diff --git a/packages/vue/src/tags-input/index.ts b/packages/vue/src/tags-input/index.ts index d2d5ceeda9..b11da4fc41 100644 --- a/packages/vue/src/tags-input/index.ts +++ b/packages/vue/src/tags-input/index.ts @@ -8,4 +8,4 @@ export { TagsInputControl, type TagsInputControlProps } from './tags-input-contr export { TagsInputField, type TagsInputFieldProps } from './tags-input-field' export { TagsInputLabel, type TagsInputLabelProps } from './tags-input-label' export { tagsInputAnatomy } from './tags-input.anatomy' -export { useTagsInput, type UseTagsInputProps, type UseTagsInputReturn } from './use-tags-input' +export { useTagsInput, type UseTagsInputReturn } from './use-tags-input' diff --git a/packages/vue/src/tags-input/tags-input.tsx b/packages/vue/src/tags-input/tags-input.tsx index ccdfbe5d27..30c25ac159 100644 --- a/packages/vue/src/tags-input/tags-input.tsx +++ b/packages/vue/src/tags-input/tags-input.tsx @@ -1,9 +1,8 @@ import type { Context } from '@zag-js/tags-input' import { defineComponent, type PropType } from 'vue' import { ark, type HTMLArkProps } from '../factory' -import type { Assign } from '../types' +import type { Assign, Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' -import type { TagInputProps } from './tag-input' import { TagsInputProvider } from './tags-input-context' import { useTagsInput } from './use-tags-input' @@ -11,76 +10,76 @@ export type TagsInputContext = Context & { modelValue?: Context['value'] } -export type TagsInputProps = Assign, TagsInputContext> +export type UseTagsInputProps = Assign, TagsInputContext> -const VueTagsInputProps = createVueProps({ +const VueTagsInputProps = createVueProps({ addOnPaste: { - type: Boolean as PropType, + type: Boolean as PropType, }, allowEditTag: { - type: Boolean as PropType, + type: Boolean as PropType, default: true, }, allowOverflow: { - type: Boolean as PropType, + type: Boolean as PropType, }, autoFocus: { - type: Boolean as PropType, + type: Boolean as PropType, }, blurBehavior: { - type: String as PropType, + type: String as PropType, }, dir: { - type: String as PropType, + type: String as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, form: { - type: String as PropType, + type: String as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: String as PropType, + type: String as PropType, }, inputValue: { - type: String as PropType, + type: String as PropType, }, invalid: { - type: Boolean as PropType, + type: Boolean as PropType, }, max: { - type: Number as PropType, + type: Number as PropType, }, maxLength: { - type: Number as PropType, + type: Number as PropType, }, modelValue: { - type: Object as PropType, + type: Object as PropType, }, name: { - type: String as PropType, + type: String as PropType, }, readOnly: { - type: Boolean as PropType, + type: Boolean as PropType, }, translations: { - type: Object as PropType, + type: Object as PropType, }, validate: { - type: Function as PropType, + type: Function as PropType, }, value: { - type: Object as PropType, + type: Object as PropType, }, }) -export const TagsInput: ComponentWithProps> = defineComponent({ +export const TagsInput: ComponentWithProps> = defineComponent({ name: 'TagsInput', props: VueTagsInputProps, emits: ['change', 'update:modelValue', 'highlight', 'invalid', 'tag-update'], @@ -100,3 +99,5 @@ export const TagsInput: ComponentWithProps> = defineCompo ) }, }) + +export type TagsInputProps = Optional diff --git a/packages/vue/src/tooltip/tooltip.tsx b/packages/vue/src/tooltip/tooltip.tsx index 03426189ab..739ae1c42e 100644 --- a/packages/vue/src/tooltip/tooltip.tsx +++ b/packages/vue/src/tooltip/tooltip.tsx @@ -1,57 +1,60 @@ import type { Context } from '@zag-js/tooltip' import { defineComponent, type PropType } from 'vue' +import type { Optional } from '../types' import { createVueProps, type ComponentWithProps } from '../utils' import { TooltipProvider } from './tooltip-context' import { useTooltip } from './use-tooltip' -export type TooltipProps = Context +export type UseTooltipProps = Context -const VueTooltipProps = createVueProps({ +const VueTooltipProps = createVueProps({ id: { - type: String as PropType, + type: String as PropType, }, ids: { - type: Object as PropType, + type: Object as PropType, }, openDelay: { - type: Number as PropType, + type: Number as PropType, }, closeDelay: { - type: Number as PropType, + type: Number as PropType, }, closeOnPointerDown: { - type: Boolean as PropType, + type: Boolean as PropType, }, closeOnEsc: { - type: Boolean as PropType, + type: Boolean as PropType, default: true, }, interactive: { - type: Boolean as PropType, + type: Boolean as PropType, }, 'aria-label': { - type: String as PropType, + type: String as PropType, }, positioning: { - type: Object as PropType, + type: Object as PropType, }, disabled: { - type: Boolean as PropType, + type: Boolean as PropType, }, getRootNode: { - type: Function as PropType, + type: Function as PropType, }, }) -export const Tooltip: ComponentWithProps> = defineComponent({ +export const Tooltip: ComponentWithProps> = defineComponent({ name: 'Tooltip', props: VueTooltipProps, emits: ['open', 'close'], setup(props, { slots, emit }) { - const api = useTooltip(emit, props as TooltipProps) + const api = useTooltip(emit, props as UseTooltipProps) TooltipProvider(api) return () => slots?.default?.() }, }) + +export type TooltipProps = Optional