Skip to content

Commit d8d0330

Browse files
feat: refactor
1 parent 7f8338b commit d8d0330

25 files changed

+109
-105
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"eslint": "npm:[email protected]",
2222
"eslint-ts-patch": "9.4.0-0",
2323
"prettier": "^3.3.3",
24-
"turbo": "latest",
24+
"turbo": "^2.1.1",
2525
"typescript": "^5.5.4"
2626
}
2727
}

packages/vue-primitives/src/accordion/AccordionTrigger.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { shallowRef } from 'vue'
33
import { useCollapsibleContext } from '../collapsible/index.ts'
4-
import { ITEM_DATA_ATTR } from '../collection/index.ts'
4+
import { DATA_COLLECTION_ITEM } from '../collection/index.ts'
55
import { useForwardElement } from '../hooks/index.ts'
66
import { Primitive } from '../primitive/index.ts'
77
import { composeEventHandlers } from '../utils/vue.ts'
@@ -39,7 +39,7 @@ const onClick = composeEventHandlers<MouseEvent>((event) => {
3939
:as="as"
4040
:aria-disabled="(itemContext.open.value && !accordionContext.collapsible) || undefined"
4141
:data-orientation="accordionContext.orientation"
42-
:[ITEM_DATA_ATTR]="true"
42+
:[DATA_COLLECTION_ITEM]="true"
4343

4444
type="button"
4545
:aria-controls="context.contentId"

packages/vue-primitives/src/collection/Collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createContext, type MutableRefObject } from '../hooks/index.ts'
22

3-
export const ITEM_DATA_ATTR = 'data-radix-collection-item'
3+
export const DATA_COLLECTION_ITEM = 'data-radix-collection-item'
44

55
type ItemElementWithData<E extends HTMLElement, D> = E & {
66
$$rcid: D
@@ -42,7 +42,7 @@ export function createCollection<ItemElement extends HTMLElement, ItemData = obj
4242
if (!collectionNode)
4343
return []
4444

45-
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`))
45+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${DATA_COLLECTION_ITEM}]`))
4646

4747
return orderedNodes as CollectionItem[]
4848
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { type CollectionContext, createCollection, ITEM_DATA_ATTR } from './Collection.ts'
1+
export { type CollectionContext, createCollection, DATA_COLLECTION_ITEM } from './Collection.ts'

packages/vue-primitives/src/dialog/DialogContentModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ const dismissableLayer = useDismissableLayer($el, {
111111
:id="context.contentId"
112112
:ref="forwardElement"
113113

114+
tabindex="-1"
115+
114116
data-dismissable-layer
115117

116118
:style="{ pointerEvents: dismissableLayer.pointerEvents() }"
@@ -119,13 +121,11 @@ const dismissableLayer = useDismissableLayer($el, {
119121
:aria-labelledby="context.titleId"
120122
:data-state="getState(context.open.value)"
121123

122-
tabindex="-1"
124+
@keydown="focusScope.onKeydown"
123125

124126
@focus.capture="dismissableLayer.onFocusCapture"
125127
@blur.capture="dismissableLayer.onBlurCapture"
126128
@pointerdown.capture="dismissableLayer.onPointerdownCapture"
127-
128-
@keydown="focusScope.onKeydown"
129129
>
130130
<slot />
131131
</Primitive>

packages/vue-primitives/src/dialog/DialogContentNonModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const dismissableLayer = useDismissableLayer($el, {
121121
:id="context.contentId"
122122
:ref="forwardElement"
123123

124+
tabindex="-1"
125+
124126
data-dismissable-layer
125127

126128
:style="{ pointerEvents: dismissableLayer.pointerEvents() }"
@@ -129,13 +131,11 @@ const dismissableLayer = useDismissableLayer($el, {
129131
:aria-labelledby="context.titleId"
130132
:data-state="getState(context.open.value)"
131133

132-
tabindex="-1"
134+
@keydown="focusScope.onKeydown"
133135

134136
@focus.capture="dismissableLayer.onFocusCapture"
135137
@blur.capture="dismissableLayer.onBlurCapture"
136138
@pointerdown.capture="dismissableLayer.onPointerdownCapture"
137-
138-
@keydown="focusScope.onKeydown"
139139
>
140140
<slot />
141141
</Primitive>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ export function useControllableState<P extends object, K extends keyof P, V = Ex
5757
}
5858

5959
export function useControllableStateV2<T, V = Exclude<T, undefined>>(
60-
prop: () => T,
60+
prop?: () => T,
6161
onChange?: (value: V) => void,
6262
defaultValue?: V | undefined,
6363
): Ref<V> {
6464
const getValue = (): V => {
65-
return (isDef(prop())
66-
? prop()
65+
return (isDef(prop?.())
66+
? prop?.()
6767
: defaultValue) as V
6868
}
6969

70-
if (isDef(prop())) {
70+
if (isDef(prop?.())) {
7171
return computed<V>({
7272
get() {
7373
return getValue()

packages/vue-primitives/src/popover/PopoverContentModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ const dismissableLayer = useDismissableLayer($el, {
114114
:id="context.contentId"
115115
:ref="forwardElement"
116116

117+
tabindex="-1"
118+
117119
data-dismissable-layer
118120

119121
:data-state="getState(context.open.value)"
@@ -127,13 +129,11 @@ const dismissableLayer = useDismissableLayer($el, {
127129
'--radix-popover-trigger-height': 'var(--radix-popper-anchor-height)',
128130
}"
129131

130-
tabindex="-1"
132+
@keydown="focusScope.onKeydown"
131133

132134
@focus.capture="dismissableLayer.onFocusCapture"
133135
@blur.capture="dismissableLayer.onBlurCapture"
134136
@pointerdown.capture="dismissableLayer.onPointerdownCapture"
135-
136-
@keydown="focusScope.onKeydown"
137137
>
138138
<slot />
139139
</PopperContent>

packages/vue-primitives/src/popover/PopoverContentNonModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const dismissableLayer = useDismissableLayer($el, {
121121
:id="context.contentId"
122122
:ref="forwardElement"
123123

124+
tabindex="-1"
125+
124126
data-dismissable-layer
125127

126128
:data-state="getState(context.open.value)"
@@ -134,13 +136,11 @@ const dismissableLayer = useDismissableLayer($el, {
134136
'--radix-popover-trigger-height': 'var(--radix-popper-anchor-height)',
135137
}"
136138

137-
tabindex="-1"
139+
@keydown="focusScope.onKeydown"
138140

139141
@focus.capture="dismissableLayer.onFocusCapture"
140142
@blur.capture="dismissableLayer.onBlurCapture"
141143
@pointerdown.capture="dismissableLayer.onPointerdownCapture"
142-
143-
@keydown="focusScope.onKeydown"
144144
>
145145
<slot />
146146
</PopperContent>

packages/vue-primitives/src/radio-group/RadioGroupItem.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { computed, onBeforeUnmount, onMounted, shallowRef } from 'vue'
3-
import { ITEM_DATA_ATTR } from '../collection/index.ts'
3+
import { DATA_COLLECTION_ITEM } from '../collection/index.ts'
44
import { useComposedElements } from '../hooks/index.ts'
55
import { Primitive } from '../primitive/index.ts'
66
import { useRovingFocusGroupItem } from '../roving-focus/index.ts'
@@ -132,7 +132,11 @@ defineExpose({
132132
<Primitive
133133
:ref="forwardElement"
134134
:as="as"
135-
:[ITEM_DATA_ATTR]="true"
135+
:[DATA_COLLECTION_ITEM]="true"
136+
137+
:tabindex="rovingFocusGroupItem.tabindex()"
138+
:data-orientation="rovingFocusGroupItem.orientation()"
139+
136140
type="button"
137141
role="radio"
138142
:aria-checked="checked"
@@ -142,14 +146,11 @@ defineExpose({
142146
:value="value"
143147
v-bind="$attrs"
144148

145-
:tabindex="rovingFocusGroupItem.tabindex()"
146-
:data-orientation="rovingFocusGroupItem.orientation()"
147-
148-
@click="onClick"
149-
150149
@mousedown="rovingFocusGroupItem.onMousedown"
151150
@focus="rovingFocusGroupItem.onFocus"
152151
@keydown="rovingFocusGroupItem.onKeydown"
152+
153+
@click="onClick"
153154
>
154155
<slot />
155156
</Primitive>

0 commit comments

Comments
 (0)