Skip to content

Commit a991db7

Browse files
fix: vars name
1 parent e1786e8 commit a991db7

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

packages/vue-primitives/src/collection/stories/DynamicInsertion.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { shallowRef } from 'vue'
3-
import { ITEM_DATA_ATTR } from '../index.ts'
3+
import { DATA_COLLECTION_ITEM } from '../index.ts'
44
import Item from './item.vue'
55
import List from './List.vue'
66
import LogItems from './LogItems.vue'
@@ -13,7 +13,7 @@ function setHasTomato(value: boolean) {
1313
}
1414
1515
function log() {
16-
console.warn('Items:', Array.from(document.querySelectorAll(`[${ITEM_DATA_ATTR}]`)))
16+
console.warn('Items:', Array.from(document.querySelectorAll(`[${DATA_COLLECTION_ITEM}]`)))
1717
}
1818
</script>
1919

packages/vue-primitives/src/collection/stories/item.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { useAttrs } from 'vue'
33
import { useComposedElements } from '../../hooks/useComposedElements.ts'
44
import { isPropFalsy } from '../../utils/is.ts'
5-
import { ITEM_DATA_ATTR } from '../Collection.ts'
5+
import { DATA_COLLECTION_ITEM } from '../Collection.ts'
66
import { Collection, type ItemData } from './utils.ts'
77
88
const attrs = useAttrs()
@@ -19,7 +19,7 @@ const composedElements = useComposedElements((v) => {
1919
:style="{
2020
opacity: !isPropFalsy($attrs.disabled) ? 0.3 : undefined,
2121
}"
22-
:[ITEM_DATA_ATTR]="true"
22+
:[DATA_COLLECTION_ITEM]="true"
2323
>
2424
<slot />
2525
</li>

packages/vue-primitives/src/hooks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export { useControllableState } from './useControllableState.ts'
44
export { useEscapeKeydown } from './useEscapeKeydown.ts'
55
export { useForwardElement } from './useForwardElement.ts'
66
export { useId } from './useId.ts'
7-
export { type MutableRefObject, useRef } from './useRef.ts'
7+
export { type MutableRefObject, type RefObject, useRef } from './useRef.ts'
88
export { useSize } from './useSize.ts'
99
export { useStateMachine } from './useStateMachine.ts'

packages/vue-primitives/src/hooks/useControllableState.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,23 @@ export function useControllableStateV2<T, V = Exclude<T, undefined>>(
8181
const proxy = shallowRef<V>(getValue())
8282
let isUpdating = false
8383

84-
watch(
85-
prop,
86-
(v) => {
87-
if (!isUpdating) {
88-
isUpdating = true
89-
; (proxy as any).value = v
90-
nextTick(() => isUpdating = false)
91-
}
92-
},
93-
)
84+
if (prop) {
85+
watch(
86+
prop,
87+
(v) => {
88+
if (!isUpdating) {
89+
isUpdating = true
90+
; (proxy as any).value = v
91+
nextTick(() => isUpdating = false)
92+
}
93+
},
94+
)
95+
}
9496

9597
watch(
9698
proxy,
9799
(v) => {
98-
if (!isUpdating && (v !== prop()))
100+
if (!isUpdating && (v !== prop?.()))
99101
onChange?.(v)
100102
},
101103
)

packages/vue-primitives/src/hooks/useRef.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import type { IfAny } from '@vue/shared'
22
import type { Ref } from 'vue'
33

4-
export interface MutableRefObject<T> { current: T }
4+
export interface MutableRefObject<T> {
5+
current: T
6+
}
7+
8+
export interface RefObject<T> {
9+
readonly current: T | null
10+
}
511

612
export function useRef<T>(value: T): Ref extends T
713
? T extends Ref

0 commit comments

Comments
 (0)