Skip to content

Commit

Permalink
Merge branch 'main' into refactor/useEventListener
Browse files Browse the repository at this point in the history
  • Loading branch information
sadeghbarati authored Oct 5, 2024
2 parents 06f4674 + d6d0c71 commit fe3f7f0
Show file tree
Hide file tree
Showing 89 changed files with 8,006 additions and 5,559 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pkg.pr.new.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Publish Approved PR
name: Publish Merged PR
on:
pull_request_review:
types: [submitted]
pull_request:
types: [closed]
paths:
- 'packages/**'

jobs:
approved:
if: github.event.review.state == 'APPROVED'
after_merge:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
Expand Down
4 changes: 2 additions & 2 deletions .histoire/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"vue": "^3.4.31"
},
"devDependencies": {
"@antfu/eslint-config": "^2.24.1",
"@antfu/eslint-config": "^2.27.3",
"@floating-ui/dom": "^1.6.7",
"@floating-ui/vue": "^1.1.0",
"@histoire/plugin-vue": "^0.17.17",
"@iconify/vue": "^4.1.2",
"@radix-ui/colors": "^3.0.0",
"@rollup/plugin-alias": "^5.1.0",
"autoprefixer": "^10.4.19",
"eslint": "^9.8.0",
"eslint": "^9.10.0",
"histoire": "^0.17.17",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.4",
Expand Down
4 changes: 4 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export default defineConfig({
editLink: {
pattern: 'https://github.com/radix-vue/radix-vue/edit/main/docs/content/:path',
},
carbonAds: {
code: 'CW7DV27J',
placement: 'wwwradix-vuecom',
},
},
srcDir: 'content',
appearance: 'dark',
Expand Down
1 change: 1 addition & 0 deletions docs/components/demo/Accordion/css/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const accordionItems = [
<Icon
icon="radix-icons:chevron-down"
class="AccordionChevron"
aria-label="Expand/Collapse"
/>
</AccordionTrigger>
</AccordionHeader>
Expand Down
1 change: 1 addition & 0 deletions docs/components/demo/Accordion/tailwind/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const accordionItems = [
<Icon
icon="radix-icons:chevron-down"
class="text-green10 ease-[cubic-bezier(0.87,_0,_0.13,_1)] transition-transform duration-300 group-data-[state=open]:rotate-180"
aria-label="Expand/Collapse"
/>
</AccordionTrigger>
</AccordionHeader>
Expand Down
10 changes: 5 additions & 5 deletions docs/components/demo/Pagination/tailwind/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import { PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, Pa
v-slot="{ items }"
class="flex items-center gap-1 text-white"
>
<PaginationFirst class="w-9 h-9 flex items-center justify-center disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<PaginationFirst class="w-9 h-9 flex items-center justify-center disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<Icon icon="radix-icons:double-arrow-left" />
</PaginationFirst>
<PaginationPrev class="w-9 h-9 flex items-center justify-center mr-4 disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<PaginationPrev class="w-9 h-9 flex items-center justify-center mr-4 disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<Icon icon="radix-icons:chevron-left" />
</PaginationPrev>
<template v-for="(page, index) in items">
<PaginationListItem
v-if="page.type === 'page'"
:key="index"
class="w-9 h-9 border rounded data-[selected]:bg-white data-[selected]:text-blackA11 hover:bg-white/10 transition focus-within:outline focus-within:outline-1 focus-within:outline-offset-1"
class="w-9 h-9 border rounded data-[selected]:bg-white data-[selected]:text-blackA11 hover:bg-white/10 transition focus-within:outline focus-within:outline-1 focus-within:outline-offset-1"
:value="page.value"
>
{{ page.value }}
Expand All @@ -38,10 +38,10 @@ import { PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, Pa
&#8230;
</PaginationEllipsis>
</template>
<PaginationNext class="w-9 h-9 flex items-center justify-center ml-4 disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<PaginationNext class="w-9 h-9 flex items-center justify-center ml-4 disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<Icon icon="radix-icons:chevron-right" />
</PaginationNext>
<PaginationLast class="w-9 h-9 flex items-center justify-center disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<PaginationLast class="w-9 h-9 flex items-center justify-center disabled:opacity-50 focus-within:outline focus-within:outline-1 focus-within:outline-offset-1 rounded">
<Icon icon="radix-icons:double-arrow-right" />
</PaginationLast>
</PaginationList>
Expand Down
6 changes: 6 additions & 0 deletions docs/content/components/combobox.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ The button that clears the search term.

<!-- @include: @/meta/ComboboxCancel.md -->

### Empty

Shown when none of the items match the query.

<!-- @include: @/meta/ComboboxEmpty.md -->

### Portal

When used, portals the content part into the `body`.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/components/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ If you want to hide the title, wrap it inside our Visually Hidden utility like t

An optional accessible description to be announced when the dialog is opened.

If you want to hide the description, wrap it inside our Visually Hidden utility like this `<VisuallyHidden asChild>`. If you want to remove the description entirely, remove this part and pass `aria-describedby="undefined"` to `DialogContent`.
If you want to hide the description, wrap it inside our Visually Hidden utility like this `<VisuallyHidden asChild>`. If you want to remove the description entirely, remove this part and pass `:aria-describedby="undefined"` to `DialogContent`.

<!-- @include: @/meta/DialogDescription.md -->

Expand Down
4 changes: 2 additions & 2 deletions docs/content/components/popover.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title: Popover
description: Displays rich content in a portal, triggered by a button.
name: popover
aria: https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal
aria: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
---

# Popover
Expand Down Expand Up @@ -322,7 +322,7 @@ import { PopoverAnchor, PopoverArrow, PopoverClose, PopoverContent, PopoverPorta

## Accessibility

Adheres to the [Dialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal).
Adheres to the [Dialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).

### Keyboard Interactions

Expand Down
10 changes: 10 additions & 0 deletions docs/content/meta/StepperRoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,15 @@
'name': 'goToStep',
'description': '<p>Go to a specific step</p>\n',
'type': ''
},
{
'name': 'nextStep',
'description': '<p>Go to the next step</p>\n',
'type': ''
},
{
'name': 'prevStep',
'description': '<p>Go to the previous step</p>\n',
'type': ''
}
]" />
2 changes: 1 addition & 1 deletion docs/content/utilities/use-date-formatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ More information on the DateFormatter [here](https://react-spectrum.adobe.com/in
```vue
<script setup lang="ts">
import { type Ref, ref } from 'vue'
import { CalendarDate, type DateValue } from '@internationalized/date'
import { CalendarDate, getLocalTimeZone, type DateValue } from '@internationalized/date'
import { toDate, useDateFormatter } from 'radix-vue'
const value = ref(new CalendarDate(1995, 8, 18)) as Ref<DateValue>
Expand Down
4 changes: 4 additions & 0 deletions docs/content/utilities/use-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ description: Generate random id

# useId

::: warning Deprecated
[Vue 3.5](https://blog.vuejs.org/posts/vue-3-5#useid) released an official client-server stable solution for `useId`.
:::

<Description>
Generate random id
</Description>
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docs",
"type": "module",
"version": "1.9.3",
"version": "1.9.6",
"scripts": {
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default antfu(
'no-console': 'warn',
'import/first': 'off',
'import/order': 'off',
'max-statements-per-line': ['error', { max: 2 }],
'style/max-statements-per-line': ['error', { max: 2 }],
'vue/one-component-per-file': 'off',
'unicorn/prefer-dom-node-text-content': 'off',
'unicorn/prefer-number-properties': 'off',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radix-vue",
"version": "1.9.3",
"version": "1.9.6",
"private": true,
"packageManager": "pnpm@9.4.0",
"license": "MIT",
Expand All @@ -25,12 +25,12 @@
"pub:release": "cd packages/radix-vue && pnpm pub:release"
},
"devDependencies": {
"@antfu/eslint-config": "^2.24.1",
"@antfu/eslint-config": "^2.27.3",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"bumpp": "^9.4.1",
"eslint": "^9.8.0",
"lint-staged": "^15.2.8",
"eslint": "^9.10.0",
"lint-staged": "^15.2.10",
"pnpm": "^9.4.0",
"rimraf": "^6.0.1",
"simple-git-hooks": "^2.11.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plugins",
"type": "module",
"version": "1.9.3",
"version": "1.9.6",
"description": "Nuxt module for Radix Vue",
"license": "MIT",
"keywords": [
Expand Down
18 changes: 9 additions & 9 deletions packages/radix-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "radix-vue",
"type": "module",
"version": "1.9.3",
"version": "1.9.6",
"description": "Vue port for Radix UI Primitives.",
"author": "Radix Vue Contributors (https://github.com/radix-vue)",
"license": "MIT",
Expand Down Expand Up @@ -108,20 +108,20 @@
"devDependencies": {
"@iconify/vue": "^4.1.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/user-event": "^14.5.2",
"@testing-library/vue": "^8.1.0",
"@tsconfig/node18": "^18.2.4",
"@types/node": "^20.14.9",
"@vitejs/plugin-vue": "^5.1.2",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"@vitest/coverage-istanbul": "^1.6.0",
"@vitejs/plugin-vue": "^5.1.4",
"@vitejs/plugin-vue-jsx": "^4.0.1",
"@vitest/coverage-istanbul": "^2.1.1",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.5.1",
"jsdom": "^24.1.1",
"vite": "^5.3.5",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.6.0",
"jsdom": "^25.0.1",
"vite": "^5.4.8",
"vite-plugin-dts": "^4.2.3",
"vitest": "^2.1.1",
"vitest-axe": "0.1.0",
"vitest-canvas-mock": "^0.3.3",
"vue": "3.4.31",
Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Checkbox/CheckboxRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ provideCheckboxRootContext({
v-if="isFormControl"
type="checkbox"
tabindex="-1"
aria-hidden
aria-hidden="true"
:value="value"
:checked="!!checked"
:name="props.name"
Expand Down
28 changes: 28 additions & 0 deletions packages/radix-vue/src/Combobox/Combobox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,19 @@ describe('given combobox in a form', async () => {
props: { handleSubmit },
})

const valueBox = wrapper.find('input')

let enterEventBubbledToForm = false

beforeEach(() => {
enterEventBubbledToForm = false
wrapper.find('form').element.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
enterEventBubbledToForm = true
}
})
})

it('should have hidden input field', async () => {
expect(wrapper.find('[type="hidden"]').exists()).toBe(true)
})
Expand Down Expand Up @@ -327,6 +340,21 @@ describe('given combobox in a form', async () => {
expect(handleSubmit.mock.results[1].value).toStrictEqual({ test: 'Pineapple' })
})
})

describe('after selecting an option via keyboard', () => {
beforeEach(async () => {
await valueBox.setValue('B')
await valueBox.trigger('keydown', { key: 'Enter' })
})

it('should show value correctly', () => {
expect((valueBox.element).value).toBe('Banana')
})

it('should bubble up the Enter keydown event to the form', () => {
expect(enterEventBubbledToForm).toBe(false)
})
})
})

describe('given a Combobox with 1,000 options', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Combobox/ComboboxContentImpl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const rootContext = injectComboboxRootContext()
useBodyScrollLock(props.bodyLock)
const { forwardRef, currentElement } = useForwardExpose()
useHideOthers(currentElement)
useHideOthers(rootContext.parentElement)
const pickedProps = computed(() => {
if (props.position === 'popper')
Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Combobox/ComboboxItemIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const itemContext = injectComboboxItemContext()
<template>
<Primitive
v-if="itemContext.isSelected.value"
aria-hidden
aria-hidden="true"
v-bind="props"
>
<slot />
Expand Down
18 changes: 14 additions & 4 deletions packages/radix-vue/src/Combobox/ComboboxRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ComboboxRootContext<T> = {
inputElement: Ref<HTMLInputElement | undefined>
onInputElementChange: (el: HTMLInputElement) => void
onInputNavigation: (dir: 'up' | 'down' | 'home' | 'end') => void
onInputEnter: () => void
onInputEnter: (event: InputEvent) => void
selectedValue: Ref<T | undefined>
selectedElement: ComputedRef<HTMLElement | undefined>
onSelectedValueChange: (val: T) => void
Expand Down Expand Up @@ -137,6 +137,9 @@ async function onOpenChange(val: boolean) {
else
selectedValue.value = modelValue.value as T
}
// selectedElement is a computed value and is not yet fully resolved.
// We need to wait for it to finish processing at this point.
await nextTick()
inputElement.value?.focus()
scrollSelectedValueIntoView()
}
Expand Down Expand Up @@ -233,7 +236,7 @@ function scrollSelectedValueIntoView() {
// Find the highlighted element and scroll into view
// We can put this in Item, but we avoid having too many watcher
if (selectedElement.value instanceof Element)
selectedElement.value.scrollIntoView({ block: 'nearest' })
selectedElement.value?.scrollIntoView({ block: 'nearest' })
}
function focusOnSelectedElement() {
Expand Down Expand Up @@ -273,14 +276,21 @@ provideComboboxRootContext({
else
selectedValue.value = filteredOptions.value[val === 'up' ? index - 1 : index + 1]
await nextTick()
// selectedElement is a computed value and is not yet fully resolved.
// We need to wait for it to finish processing at this point.
scrollSelectedValueIntoView()
focusOnSelectedElement()
nextTick(() => inputElement.value?.focus({ preventScroll: true }))
},
onInputEnter: async () => {
if (filteredOptions.value.length && selectedValue.value && selectedElement.value instanceof Element)
onInputEnter: async (event) => {
if (filteredOptions.value.length && selectedValue.value && selectedElement.value instanceof Element) {
event.preventDefault()
event.stopPropagation()
selectedElement.value?.click()
}
},
selectedValue,
onSelectedValueChange: val => selectedValue.value = val as T,
Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Combobox/ComboboxSeparator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ useForwardExpose()
<template>
<Primitive
v-bind="props"
aria-hidden
aria-hidden="true"
>
<slot />
</Primitive>
Expand Down
Loading

0 comments on commit fe3f7f0

Please sign in to comment.