Skip to content

Commit

Permalink
chore: bump radix-vue deps (#941)
Browse files Browse the repository at this point in the history
* chore: update radix-vue deps

* fix: ts build error

---------

Co-authored-by: zernonia <zernonia@gmail.com>
  • Loading branch information
sadeghbarati and zernonia authored May 21, 2024
1 parent d0e1819 commit 0d1109e
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 47 deletions.
10 changes: 5 additions & 5 deletions packages/radix-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@
"vue": ">= 3.2.0"
},
"dependencies": {
"@floating-ui/dom": "^1.5.4",
"@floating-ui/vue": "^1.0.4",
"@internationalized/date": "^3.5.2",
"@internationalized/number": "^3.5.2",
"@tanstack/vue-virtual": "^3.1.3",
"@floating-ui/dom": "^1.6.5",
"@floating-ui/vue": "^1.0.6",
"@internationalized/date": "^3.5.4",
"@internationalized/number": "^3.5.3",
"@tanstack/vue-virtual": "^3.5.0",
"@vueuse/core": "^10.5.0",
"@vueuse/shared": "^10.5.0",
"aria-hidden": "^1.2.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/radix-vue/src/Collection/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const [injectCollectionContext, provideCollectionContext]
export function createCollection<ItemData = {}>(attrName = ITEM_DATA_ATTR) {
const itemMap = ref<Map<HTMLElement, { ref: HTMLElement } & ItemData>>(new Map())
const collectionRef = ref<HTMLElement>()

// @ts-expect-error Type instantiation is excessively deep and possibly infinite.
const context = provideCollectionContext({
collectionRef,
itemMap,
Expand Down
16 changes: 8 additions & 8 deletions packages/radix-vue/src/shared/useForwardProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type MaybeRefOrGetter, type UnwrapRef, camelize, computed, getCurrentInstance, toRef } from 'vue'
import { type MaybeRefOrGetter, camelize, computed, getCurrentInstance, toRef } from 'vue'

interface PropOptions {
type?: any
Expand All @@ -13,30 +13,30 @@ interface PropOptions {
* component.
* @returns computed value that combines the default props, preserved props, and assigned props.
*/
export function useForwardProps<T extends MaybeRefOrGetter<Record<string, any>>, U extends UnwrapRef<T>>(props: T) {
export function useForwardProps<T extends Record<string, any>>(props: MaybeRefOrGetter<T>) {
const vm = getCurrentInstance()
// Default value for declared props
const defaultProps = Object.keys(vm?.type.props ?? {}).reduce((prev, curr) => {
const defaultValue = (vm?.type.props[curr] as PropOptions).default
if (defaultValue !== undefined)
prev[curr as keyof U] = defaultValue
prev[curr as keyof T] = defaultValue
return prev
}, {} as U)
}, {} as T)

const refProps = toRef(props)
return computed(() => {
const preservedProps = {} as U
const preservedProps = {} as T
const assignedProps = vm?.vnode.props ?? {}

Object.keys(assignedProps).forEach((key) => {
preservedProps[camelize(key) as keyof U] = assignedProps[key]
preservedProps[camelize(key) as keyof T] = assignedProps[key]
})

// Only return value from the props parameter
return Object.keys({ ...defaultProps, ...preservedProps }).reduce((prev, curr) => {
if (refProps.value[curr] !== undefined)
prev[curr as keyof U] = refProps.value[curr]
prev[curr as keyof T] = refProps.value[curr]
return prev
}, {} as U)
}, {} as T)
})
}
2 changes: 1 addition & 1 deletion packages/radix-vue/src/shared/useForwardPropsEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useForwardProps } from './useForwardProps'
* @returns a computed property that combines the parsed
* props and emits as props.
*/
export function useForwardPropsEmits<T extends Parameters<typeof useForwardProps>[0], Name extends string>(props: T, emit?: (name: Name, ...args: any[]) => void) {
export function useForwardPropsEmits<T extends Record<string, any>, Name extends string>(props: T, emit?: (name: Name, ...args: any[]) => void) {
const parsedProps = useForwardProps(props)
const emitsAsProps = emit ? useEmitAsProps(emit) : {}

Expand Down
99 changes: 66 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d1109e

Please sign in to comment.