Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Vendor in Reakit functions (#1653)

Olga Bulatfd5f187109f8
diff --git a/package.json b/package.json
index e3eae23c5..e5506d30b 100644
--- a/package.json
+++ b/package.json
@@ -91,7 +91,6 @@
"pinia": "^2.0.13",
"postcss-focus-visible": "^6.0.4",
"prom-client": "^14.0.1",
- "reakit-utils": "^0.15.2",
"rfdc": "^1.3.0",
"seeded-rand": "^2.0.1",
"throttle-debounce": "^4.0.1",
@@ -159,7 +158,7 @@
"vue-i18n-extract": "^2.0.7",
"vue-jest": "^3.0.7",
"vue-template-compiler": "^2.6.14",
- "vue-tsc": "^0.34.7",
+ "vue-tsc": "^0.39.5",
"webpack": "^4.46.0"
},
"pnpm": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d406f5006..5c6c42c2b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -83,7 +83,6 @@ specifiers:
prettier: ^2.2.1
prettier-plugin-tailwindcss: ^0.1.12
prom-client: ^14.0.1
- reakit-utils: ^0.15.2
rfdc: ^1.3.0
rimraf: ^3.0.2
seeded-rand: ^2.0.1
@@ -100,7 +99,7 @@ specifiers:
vue-i18n-extract: ^2.0.7
vue-jest: ^3.0.7
vue-template-compiler: ^2.6.14
- vue-tsc: ^0.34.7
+ vue-tsc: ^0.39.5
webpack: ^4.46.0
dependencies:
@@ -138,7 +137,6 @@ dependencies:
pinia: 2.0.13_k3kegkzgmpj55t3l5d75ppieg4
postcss-focus-visible: [email protected]
prom-client: 14.0.1
- reakit-utils: 0.15.2
rfdc: 1.3.0
seeded-rand: 2.0.1
throttle-debounce: 4.0.1
@@ -205,7 +203,7 @@ devDependencies:
vue-i18n-extract: 2.0.7
vue-jest: 3.0.7_emdz5kfrc5cn55r4a24jgpa35q
vue-template-compiler: 2.6.14
webpack: 4.46.0
packages:
@@ -2774,7 +2772,7 @@ packages:
deprecated: this version had an improper engines field added, update to 1.1.1
dependencies:
'@gar/promisify': 1.1.2
- semver: 7.3.5
+ semver: 7.3.7
/@npmcli/move-file/1.1.2:
resolution: {integrity: sha512-1SUf/Cg2GzGDyaf15aR9St9TWlb+XvbZXWpDx8YKs7MLzMH/BCeopv+y9vzrzgkfykCGuWOlSu3mZhj2+FQcrg==}
@@ -2911,7 +2909,7 @@ packages:
minimist: 1.2.5
opener: 1.5.2
pretty-bytes: 5.6.0
- semver: 7.3.5
+ semver: 7.3.7
serve-static: 1.14.2
std-env: 2.3.1
upath: 2.0.1
@@ -3147,7 +3145,7 @@ packages:
jiti: 1.13.0
lodash: 4.17.21
proper-lockfile: 4.1.2
- semver: 7.3.5
+ semver: 7.3.7
serialize-javascript: 5.0.1
signal-exit: 3.0.6
ua-parser-js: 0.7.31
@@ -3218,7 +3216,7 @@ packages:
postcss-loader: 3.0.0
postcss-preset-env: 6.7.0
postcss-url: 8.0.0
- semver: 7.3.5
+ semver: 7.3.7
std-env: 2.3.1
style-resources-loader: [email protected]
terser-webpack-plugin: [email protected]
@@ -6383,34 +6381,48 @@ packages:
eslint-visitor-keys: 3.3.0
dev: true
- /@volar/code-gen/0.34.12:
- resolution: {integrity: sha512-5GAPsSjScnfMmMoh9qLW7CWQjjnT0fTUsPWnDMMjKIOqQF9J5mOyo7rprt1VzX63zwayqFfx7V8W3EVNhUCE3w==}
+ /@volar/code-gen/0.39.5:
+ resolution: {integrity: sha512-vQr5VoCH8T2NHmqLc/AA1/4F8l41WB+24+I+VjxBaev/Hmwjye9K0GlmMHAOl84WB3hWGOqpHaPX6JkqzRNjJg==}
dependencies:
- '@volar/source-map': 0.34.12
+ '@volar/source-map': 0.39.5
dev: true
- /@volar/source-map/0.34.12:
- resolution: {integrity: sha512-07imKws1cz9g3eo0VWXdioNfc1eCjqwK7GsxVuYSc7OCzKASt9PywUW+F39QGB9g2Kewof+PjCVIPeGqGRECTA==}
+ /@volar/source-map/0.39.5:
+ resolution: {integrity: sha512-IVOX+v++Sr5Kok4/cLbDJp2vf1ia1rChpV7adgcnMle6uORBuGFEur234UzamK0iHRCcfFFRz7z+hSPf2CO23Q==}
dev: true
- /@volar/vue-code-gen/0.34.12:
- resolution: {integrity: sha512-PFcft62eIvQvcB6H2Z88fouTu2JmYwimORziFGr3LlGriQUEVmyDtqddtb+E+j2wGChtLkh6hf1py94C5VpI/Q==}
+ /@volar/typescript-faster/0.39.5:
+ resolution: {integrity: sha512-IzLqlxefmKkjNKXC/8aFiqPcTqnj6RG31D2f9cIWxmW9pvUYJxLED+y9phnOxNxq0OmeRtQ3Pfmvu85tUBoZsQ==}
dependencies:
- '@volar/code-gen': 0.34.12
- '@volar/source-map': 0.34.12
- '@vue/compiler-core': 3.2.31
- '@vue/compiler-dom': 3.2.31
- '@vue/shared': 3.2.31
+ semver: 7.3.7
dev: true
- /@volar/vue-typescript/0.34.12:
- resolution: {integrity: sha512-mY5cZ2OFOKt1HcCuoX1ViEsccltX3mdACk/FAjrSZTrilTdVHI1zkmQlrpCSnjmE1qowd8I6YoVt7THCaVrHdg==}
+ /@volar/vue-code-gen/0.39.5:
+ resolution: {integrity: sha512-y+QUV9MuuasiIuRoGKQl+gMhDaAX6XNhckAyJCvD1FZ8f2eJuPY2VtoFxmu/Z2bGWBdtUW/g98jaeKJ+j3wwOw==}
dependencies:
- '@volar/code-gen': 0.34.12
- '@volar/source-map': 0.34.12
- '@volar/vue-code-gen': 0.34.12
- '@vue/compiler-sfc': 3.2.31
- '@vue/reactivity': 3.2.31
+ '@volar/code-gen': 0.39.5
+ '@volar/source-map': 0.39.5
+ '@vue/compiler-core': 3.2.37
+ '@vue/compiler-dom': 3.2.37
+ '@vue/shared': 3.2.37
+ dev: true
+
+ /@volar/vue-language-core/0.39.5:
+ resolution: {integrity: sha512-m+e1tYuL/WRPhSeC7hZ0NuSwHsfnnGJVxCBHLaP7jR0f6xcC0DAegP3QF+gfu9ZJFPGznpZYFKadngMjuhQS9Q==}
+ dependencies:
+ '@volar/code-gen': 0.39.5
+ '@volar/source-map': 0.39.5
+ '@volar/vue-code-gen': 0.39.5
+ '@vue/compiler-sfc': 3.2.37
+ '@vue/reactivity': 3.2.37
+ dev: true
+
+ /@volar/vue-typescript/0.39.5:
+ resolution: {integrity: sha512-ckhWD1xOi0OMr702XVkv/Npsb9FKAp5gvhxyLv0QqWekPdSo04t4KrZfwosJLGERIEcyr50SuB7HqBp8ndQmzA==}
+ dependencies:
+ '@volar/code-gen': 0.39.5
+ '@volar/typescript-faster': 0.39.5
+ '@volar/vue-language-core': 0.39.5
dev: true
/@vue/babel-helper-vue-jsx-merge-props/1.2.1:
@@ -6515,33 +6527,51 @@ packages:
'@vue/shared': 3.2.31
estree-walker: 2.0.2
source-map: 0.6.1
+ dev: false
+
+ /@vue/compiler-core/3.2.37:
+ resolution: {integrity: sha512-81KhEjo7YAOh0vQJoSmAD68wLfYqJvoiD4ulyedzF+OEk/bk6/hx3fTNVfuzugIIaTrOx4PGx6pAiBRe5e9Zmg==}
+ dependencies:
+ '@babel/parser': 7.17.10
+ '@vue/shared': 3.2.37
+ estree-walker: 2.0.2
+ source-map: 0.6.1
+ dev: true
/@vue/compiler-dom/3.2.31:
resolution: {integrity: sha512-60zIlFfzIDf3u91cqfqy9KhCKIJgPeqxgveH2L+87RcGU/alT6BRrk5JtUso0OibH3O7NXuNOQ0cDc9beT0wrg==}
dependencies:
'@vue/compiler-core': 3.2.31
'@vue/shared': 3.2.31
+ dev: false
+
+ /@vue/compiler-dom/3.2.37:
+ resolution: {integrity: sha512-yxJLH167fucHKxaqXpYk7x8z7mMEnXOw3G2q62FTkmsvNxu4FQSu5+3UMb+L7fjKa26DEzhrmCxAgFLLIzVfqQ==}
+ dependencies:
+ '@vue/compiler-core': 3.2.37
+ '@vue/shared': 3.2.37
+ dev: true
- /@vue/compiler-sfc/3.2.31:
- resolution: {integrity: sha512-748adc9msSPGzXgibHiO6T7RWgfnDcVQD+VVwYgSsyyY8Ans64tALHZANrKtOzvkwznV/F4H7OAod/jIlp/dkQ==}
+ /@vue/compiler-sfc/3.2.37:
+ resolution: {integrity: sha512-+7i/2+9LYlpqDv+KTtWhOZH+pa8/HnX/905MdVmAcI/mPQOBwkHHIzrsEsucyOIZQYMkXUiTkmZq5am/NyXKkg==}
dependencies:
'@babel/parser': 7.17.10
- '@vue/compiler-core': 3.2.31
- '@vue/compiler-dom': 3.2.31
- '@vue/compiler-ssr': 3.2.31
- '@vue/reactivity-transform': 3.2.31
- '@vue/shared': 3.2.31
+ '@vue/compiler-core': 3.2.37
+ '@vue/compiler-dom': 3.2.37
+ '@vue/compiler-ssr': 3.2.37
+ '@vue/reactivity-transform': 3.2.37
+ '@vue/shared': 3.2.37
estree-walker: 2.0.2
magic-string: 0.25.9
postcss: 8.4.12
source-map: 0.6.1
dev: true
- /@vue/compiler-ssr/3.2.31:
- resolution: {integrity: sha512-mjN0rqig+A8TVDnsGPYJM5dpbjlXeHUm2oZHZwGyMYiGT/F4fhJf/cXy8QpjnLQK4Y9Et4GWzHn9PS8AHUnSkw==}
+ /@vue/compiler-ssr/3.2.37:
+ resolution: {integrity: sha512-7mQJD7HdXxQjktmsWp/J67lThEIcxLemz1Vb5I6rYJHR5vI+lON3nPGOH3ubmbvYGt8xEUaAr1j7/tIFWiEOqw==}
dependencies:
- '@vue/compiler-dom': 3.2.31
- '@vue/shared': 3.2.31
+ '@vue/compiler-dom': 3.2.37
+ '@vue/shared': 3.2.37
dev: true
/@vue/component-compiler-utils/[email protected]:
@@ -6701,12 +6731,29 @@ packages:
'@vue/shared': 3.2.31
estree-walker: 2.0.2
magic-string: 0.25.9
+ dev: false
+
+ /@vue/reactivity-transform/3.2.37:
+ resolution: {integrity: sha512-IWopkKEb+8qpu/1eMKVeXrK0NLw9HicGviJzhJDEyfxTR9e1WtpnnbYkJWurX6WwoFP0sz10xQg8yL8lgskAZg==}
+ dependencies:
+ '@babel/parser': 7.17.10
+ '@vue/compiler-core': 3.2.37
+ '@vue/shared': 3.2.37
+ estree-walker: 2.0.2
+ magic-string: 0.25.9
+ dev: true
/@vue/reactivity/3.2.31:
resolution: {integrity: sha512-HVr0l211gbhpEKYr2hYe7hRsV91uIVGFYNHj73njbARVGHQvIojkImKMaZNDdoDZOIkMsBc9a1sMqR+WZwfSCw==}
dependencies:
'@vue/shared': 3.2.31
+ /@vue/reactivity/3.2.37:
+ resolution: {integrity: sha512-/7WRafBOshOc6m3F7plwzPeCu/RCVv9uMpOwa/5PiY1Zz+WLVRWiy0MYKwmg19KBdGtFWsmZ4cD+LOdVPcs52A==}
+ dependencies:
+ '@vue/shared': 3.2.37
+ dev: true
+
/@vue/runtime-core/3.2.31:
resolution: {integrity: sha512-Kcog5XmSY7VHFEMuk4+Gap8gUssYMZ2+w+cmGI6OpZWYOEIcbE0TPzzPHi+8XTzAgx1w/ZxDFcXhZeXN5eKWsA==}
dependencies:
@@ -6723,6 +6770,9 @@ packages:
/@vue/shared/3.2.31:
resolution: {integrity: sha512-ymN2pj6zEjiKJZbrf98UM2pfDd6F2H7ksKw7NDt/ZZ1fh5Ei39X5tABugtT03ZRlWd9imccoK0hE8hpjpU7irQ==}
+ /@vue/shared/3.2.37:
+ resolution: {integrity: sha512-4rSJemR2NQIo9Klm1vabqWjD8rs/ZaJSzMxkMNeJS6lHiUjjUeYFbooN19NgFjztubEKh3WlZUeOLVdbbUWHsw==}
+
/@vue/test-utils/1.1.3_sbs6or2oam5i4s4vmfp4rzwdnq:
resolution: {integrity: sha512-BAY1Cwe9JpkJseimC295EW3YlAmgIJI9OPkg2FSP62+PHZooB0B+wceDi9TYyU57oqzL0yLbcP73JKFpKiLc9A==}
peerDependencies:
@@ -9197,7 +9247,7 @@ packages:
postcss-modules-values: 3.0.0
postcss-value-parser: 4.2.0
schema-utils: 2.7.1
- semver: 7.3.5
+ semver: 7.3.7
webpack: 4.46.0
dev: false
@@ -12886,7 +12936,7 @@ packages:
jest-resolve: 26.6.2
natural-compare: 1.4.0
pretty-format: 26.6.2
- semver: 7.3.5
+ semver: 7.3.7
transitivePeerDependencies:
- supports-color
dev: true
@@ -14175,7 +14225,7 @@ packages:
dependencies:
growly: 1.3.0
is-wsl: 2.2.0
- semver: 7.3.5
+ semver: 7.3.7
shellwords: 0.1.1
uuid: 8.3.2
which: 2.0.2
@@ -15347,7 +15397,7 @@ packages:
loader-utils: 2.0.2
postcss: 7.0.39
schema-utils: 3.1.1
- semver: 7.3.5
+ semver: 7.3.7
webpack: 4.46.0
dev: true
@@ -15363,7 +15413,7 @@ packages:
loader-utils: 2.0.2
postcss: 8.4.12
schema-utils: 3.1.1
- semver: 7.3.5
+ semver: 7.3.7
webpack: 4.46.0
/postcss-logical/3.0.0:
@@ -16761,18 +16811,6 @@ packages:
dependencies:
picomatch: 2.3.1
- /reakit-utils/0.15.2:
- resolution: {integrity: sha512-i/RYkq+W6hvfFmXw5QW7zvfJJT/K8a4qZ0hjA79T61JAFPGt23DsfxwyBbyK91GZrJ9HMrXFVXWMovsKBc1qEQ==}
- peerDependencies:
- react: ^16.8.0 || ^17.0.0
- react-dom: ^16.8.0 || ^17.0.0
- peerDependenciesMeta:
- react:
- optional: true
- react-dom:
- optional: true
- dev: false
-
/recast/0.18.10:
resolution: {integrity: sha512-XNvYvkfdAN9QewbrxeTOjgINkdY/odTgTS56ZNEWL9Ml0weT4T3sFtvnTuF+Gxyu46ANcRm1ntrF6F5LAJPAaQ==}
engines: {node: '>= 4'}
@@ -17308,6 +17346,13 @@ packages:
dependencies:
lru-cache: 6.0.0
+ /semver/7.3.7:
+ resolution: {integrity: sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==}
+ engines: {node: '>=10'}
+ hasBin: true
+ dependencies:
+ lru-cache: 6.0.0
+
/send/0.17.2:
resolution: {integrity: sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==}
engines: {node: '>= 0.8.0'}
@@ -18812,7 +18857,7 @@ packages:
'@vue/composition-api': [email protected]
'@vue/reactivity-transform': 3.2.31
'@vue/runtime-dom': 3.2.31
- '@vue/shared': 3.2.31
+ '@vue/shared': 3.2.37
defu: 5.0.1
htmlparser2: 5.0.1
magic-string: 0.25.9
@@ -19124,8 +19169,8 @@ packages:
dependencies:
'@babel/parser': 7.17.10
'@babel/types': 7.17.10
- '@vue/compiler-dom': 3.2.31
- '@vue/compiler-sfc': 3.2.31
+ '@vue/compiler-dom': 3.2.37
+ '@vue/compiler-sfc': 3.2.37
ast-types: 0.14.2
hash-sum: 1.0.2
lru-cache: 4.1.5
@@ -19437,13 +19482,14 @@ packages:
/vue-template-es2015-compiler/1.9.1:
resolution: {integrity: sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==}
- /vue-tsc/[email protected]:
- resolution: {integrity: sha512-CmuqLXHEW5UvS8UpT2RYom5MzOWBD142PLXxDX0ARdZ/u1oLobA3od4XY2XZACQYCFCzjTvfD1H5wrWwiGwoUA==}
+ /vue-tsc/[email protected]:
+ resolution: {integrity: sha512-jhTsrKhZkafpIeN4Cbhr1K53hNfa/oesSrlh7hUaeHyCk55VhZT6oJkwJbtqN4MYkWZIwPrm3/xTwsELuf2ocg==}
hasBin: true
peerDependencies:
typescript: '*'
dependencies:
- '@volar/vue-typescript': 0.34.12
+ '@volar/vue-language-core': 0.39.5
+ '@volar/vue-typescript': 0.39.5
typescript: 4.6.2
dev: true
@@ -19889,7 +19935,7 @@ packages:
dev: true
/yallist/2.1.2:
- resolution: {integrity: sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=}
+ resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==}
/yallist/3.1.1:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
diff --git a/src/components/VItemGroup/VItemGroup.vue b/src/components/VItemGroup/VItemGroup.vue
index d4bd0f036..c3a1890e0 100644
--- a/src/components/VItemGroup/VItemGroup.vue
+++ b/src/components/VItemGroup/VItemGroup.vue
@@ -26,11 +26,11 @@ import {
ref,
readonly,
} from '@nuxtjs/composition-api'
-import { ensureFocus } from 'reakit-utils/ensureFocus'
import { useI18n } from '~/composables/use-i18n'
import { keycodes } from '~/constants/key-codes'
+import { ensureFocus } from '~/utils/reakit-utils/focus'
/**
* @typedef VItemGroupContext
diff --git a/src/components/VSkipToContentContainer.vue b/src/components/VSkipToContentContainer.vue
index 3499832a1..3d49b4739 100644
--- a/src/components/VSkipToContentContainer.vue
+++ b/src/components/VSkipToContentContainer.vue
@@ -15,8 +15,7 @@
<script>
import { defineComponent, ref } from '@nuxtjs/composition-api'
-import { getFirstTabbableIn } from 'reakit-utils/tabbable'
-import { ensureFocus } from 'reakit-utils/ensureFocus'
+import { ensureFocus, getFirstTabbableIn } from '~/utils/reakit-utils/focus'
import VTeleport from '~/components/VTeleport/VTeleport.vue'
import VButton from '~/components/VButton.vue'
diff --git a/src/composables/use-body-scroll-lock.ts b/src/composables/use-body-scroll-lock.ts
index 9abb4f914..75cb01c5a 100644
--- a/src/composables/use-body-scroll-lock.ts
+++ b/src/composables/use-body-scroll-lock.ts
@@ -1,6 +1,6 @@
import { Ref, ref } from '@nuxtjs/composition-api'
-import { getDocument } from '~/utils/dom/get-document'
+import { getDocument } from '~/utils/reakit-utils/dom'
/**
* Creates a utility for locking body scrolling for a particular node.
diff --git a/src/composables/use-event-listener-outside.js b/src/composables/use-event-listener-outside.js
index ec0a62127..aa026f5ed 100644
--- a/src/composables/use-event-listener-outside.js
+++ b/src/composables/use-event-listener-outside.js
@@ -1,7 +1,6 @@
import { watch, ref } from '@nuxtjs/composition-api'
-import { contains } from 'reakit-utils/contains'
-import { getDocument } from '~/utils/dom/get-document'
+import { contains, getDocument } from '~/utils/reakit-utils/dom'
/**
* @param {Element} target
diff --git a/src/composables/use-focus-on-blur.js b/src/composables/use-focus-on-blur.js
index 2ec1d47b4..47974021e 100644
--- a/src/composables/use-focus-on-blur.js
+++ b/src/composables/use-focus-on-blur.js
@@ -1,8 +1,6 @@
-import { getActiveElement } from 'reakit-utils/getActiveElement'
-import { getNextActiveElementOnBlur } from 'reakit-utils/getNextActiveElementOnBlur'
import { ref, watch } from '@nuxtjs/composition-api'
-import { getDocument } from '~/utils/dom/get-document'
+import { getActiveElement, getDocument } from '~/utils/reakit-utils/dom'
/**
* @typedef Props
@@ -54,7 +52,7 @@ export function useFocusOnBlur({ dialogRef, visibleRef }) {
*/
const onBlur = (event) => {
if (visibleRef.value) return
- const nextActiveElement = getNextActiveElementOnBlur(event)
+ const nextActiveElement = event.relatedTarget
if (!isActualElement(nextActiveElement)) {
scheduleFocus()
}
diff --git a/src/composables/use-focus-on-hide.js b/src/composables/use-focus-on-hide.js
index c49b99379..7c8d6687c 100644
--- a/src/composables/use-focus-on-hide.js
+++ b/src/composables/use-focus-on-hide.js
@@ -1,8 +1,7 @@
-import { watch } from '@vue/composition-api'
-import { isTabbable } from 'reakit-utils/tabbable'
-import { getActiveElement } from 'reakit-utils/getActiveElement'
-import { contains } from 'reakit-utils/contains'
-import { ensureFocus } from 'reakit-utils/ensureFocus'
+import { watch } from '@nuxtjs/composition-api'
+
+import { contains, getActiveElement } from '~/utils/reakit-utils/dom'
+import { ensureFocus, isTabbable } from '~/utils/reakit-utils/focus'
/**
* @typedef Props
diff --git a/src/composables/use-focus-on-show.js b/src/composables/use-focus-on-show.js
index fbc9c2549..f84683545 100644
--- a/src/composables/use-focus-on-show.js
+++ b/src/composables/use-focus-on-show.js
@@ -1,9 +1,11 @@
import { ref, watch } from '@nuxtjs/composition-api'
-import { getFirstTabbableIn } from 'reakit-utils/tabbable'
-import { hasFocusWithin } from 'reakit-utils/hasFocusWithin'
-import { ensureFocus } from 'reakit-utils/ensureFocus'
import { warn } from '~/utils/console'
+import {
+ ensureFocus,
+ getFirstTabbableIn,
+ hasFocusWithin,
+} from '~/utils/reakit-utils/focus'
export const noFocusableElementWarning =
"It's recommended to have at least one tabbable element inside dialog. The dialog element has been automatically focused. If this is the intended behavior, pass `tabIndex={0}` to the dialog element to disable this warning."
diff --git a/src/composables/use-hide-on-click-outside.js b/src/composables/use-hide-on-click-outside.js
index da6e7ba6a..900ac634a 100644
--- a/src/composables/use-hide-on-click-outside.js
+++ b/src/composables/use-hide-on-click-outside.js
@@ -1,6 +1,6 @@
import { ref, watch, computed } from '@nuxtjs/composition-api'
-import { getDocument } from '~/utils/dom/get-document'
+import { getDocument } from '~/utils/reakit-utils/dom'
import { useEventListenerOutside } from './use-event-listener-outside'
diff --git a/src/utils/a11y/is-native-tabbable.ts b/src/utils/a11y/is-native-tabbable.ts
deleted file mode 100644
index 07f438827..000000000
--- a/src/utils/a11y/is-native-tabbable.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * @see https://github.com/reakit/reakit/blob/f05d36daa6fbcc52c70cf2c71baea69025aa2402/packages/reakit/src/Tabbable/Tabbable.ts#L44
- */
-export function isNativeTabbable(element: Element) {
- return ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'A'].includes(
- element.tagName
- )
-}
diff --git a/src/utils/dom/get-document.ts b/src/utils/dom/get-document.ts
deleted file mode 100644
index cb3013396..000000000
--- a/src/utils/dom/get-document.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Returns `element.ownerDocument || document`.
- * From reakit-utils/getDocument
- */
-export function getDocument(element: Element | Document | null): Document {
- return element ? element.ownerDocument || element : document
-}
diff --git a/src/utils/reakit-utils/README.md b/src/utils/reakit-utils/README.md
new file mode 100644
index 000000000..36417d9ee
--- /dev/null
+++ b/src/utils/reakit-utils/README.md
@@ -0,0 +1,5 @@
+# Contents
+
+This directory contains utilities from [`reakit-utils` version 0.15.2](https://github.com/ariakit/ariakit/tree/f05d36daa6fbcc52c70cf2c71baea69025aa2402/packages/reakit-utils) .
+
+We cannot use Reakit/Ariakit directly as it imports React's JSX types (`@types/react`) which conflict with Vue's own JSX types (`@vue/runtime-dom`). [Ariakit has essentially the same issue as Storybook, for the moment](https://github.com/storybookjs/storybook/issues/12505).
diff --git a/src/utils/reakit-utils/dom.ts b/src/utils/reakit-utils/dom.ts
new file mode 100644
index 000000000..916b2d41c
--- /dev/null
+++ b/src/utils/reakit-utils/dom.ts
@@ -0,0 +1,66 @@
+/**
+ * Returns `element.ownerDocument || document`.
+ */
+export function getDocument(node?: Node | null): Document {
+ return node ? node.ownerDocument || (node as Document) : document
+}
+
+/**
+ * Returns `element.ownerDocument.activeElement`.
+ */
+export function getActiveElement(
+ node?: Node | null,
+ activeDescendant = false
+): HTMLElement | null {
+ const { activeElement } = getDocument(node)
+ if (!activeElement?.nodeName) {
+ // In IE11, activeElement might be an empty object if we're interacting
+ // with elements inside of an iframe.
+ return null
+ }
+ if (isFrame(activeElement) && activeElement.contentDocument) {
+ return getActiveElement(
+ activeElement.contentDocument.body,
+ activeDescendant
+ )
+ }
+ if (activeDescendant) {
+ const id = activeElement.getAttribute('aria-activedescendant')
+ if (id) {
+ const element = getDocument(activeElement).getElementById(id)
+ if (element) {
+ return element
+ }
+ }
+ }
+ return activeElement as HTMLElement | null
+}
+
+/**
+ * Similar to `Element.prototype.contains`, but a little bit faster when
+ * `element` is the same as `child`.
+ * @example
+ * contains(document.getElementById("parent"), document.getElementById("child"));
+ */
+export function contains(parent: Node, child: Node): boolean {
+ return parent === child || parent.contains(child)
+}
+
+/**
+ * Checks whether `element` is a frame element.
+ */
+export function isFrame(element: Element): element is HTMLIFrameElement {
+ return element.tagName === 'IFRAME'
+}
+
+/**
+ * Checks if the element is visible or not.
+ */
+export function isVisible(element: Element) {
+ const htmlElement = element as HTMLElement
+ return (
+ htmlElement.offsetWidth > 0 ||
+ htmlElement.offsetHeight > 0 ||
+ element.getClientRects().length > 0
+ )
+}
diff --git a/src/utils/reakit-utils/focus.ts b/src/utils/reakit-utils/focus.ts
new file mode 100644
index 000000000..6552c505e
--- /dev/null
+++ b/src/utils/reakit-utils/focus.ts
@@ -0,0 +1,182 @@
+import { contains, getActiveElement, isFrame, isVisible } from './dom'
+
+const selector =
+ "input:not([type='hidden']):not([disabled]), select:not([disabled]), " +
+ 'textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], ' +
+ 'iframe, object, embed, area[href], audio[controls], video[controls], ' +
+ "[contenteditable]:not([contenteditable='false'])"
+
+function hasNegativeTabIndex(element: Element) {
+ const tabIndex = parseInt(element.getAttribute('tabindex') || '0', 10)
+ return tabIndex < 0
+}
+
+/**
+ * Checks whether `element` is focusable or not.
+ * @example
+ * isFocusable(document.querySelector("input")); // true
+ * isFocusable(document.querySelector("input[tabindex='-1']")); // true
+ * isFocusable(document.querySelector("input[hidden]")); // false
+ * isFocusable(document.querySelector("input:disabled")); // false
+ */
+export function isFocusable(element: Element): element is HTMLElement {
+ return element.matches(selector) && isVisible(element)
+}
+
+/**
+ * Checks whether `element` is tabbable or not.
+ * @example
+ * isTabbable(document.querySelector("input")); // true
+ * isTabbable(document.querySelector("input[tabindex='-1']")); // false
+ * isTabbable(document.querySelector("input[hidden]")); // false
+ * isTabbable(document.querySelector("input:disabled")); // false
+ */
+export function isTabbable(element: Element): element is HTMLElement {
+ return isFocusable(element) && !hasNegativeTabIndex(element)
+}
+
+/**
+ * Returns all the focusable elements in `container`.
+ */
+export function getAllFocusableIn(
+ container: HTMLElement,
+ includeContainer?: boolean
+) {
+ const elements = Array.from(container.querySelectorAll<HTMLElement>(selector))
+ if (includeContainer) {
+ elements.unshift(container)
+ }
+
+ const focusableElements = elements.filter(isFocusable)
+
+ focusableElements.forEach((element, i) => {
+ if (isFrame(element) && element.contentDocument) {
+ const frameBody = element.contentDocument.body
+ focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody))
+ }
+ })
+
+ return focusableElements
+}
+
+/**
+ * Returns all the tabbable elements in `container`, including the container
+ * itself.
+ */
+export function getAllTabbableIn(
+ container: HTMLElement,
+ includeContainer?: boolean,
+ fallbackToFocusable?: boolean
+) {
+ const elements = Array.from(container.querySelectorAll<HTMLElement>(selector))
+
+ const tabbableElements = elements.filter(isTabbable)
+
+ if (includeContainer && isTabbable(container)) {
+ tabbableElements.unshift(container)
+ }
+
+ tabbableElements.forEach((element, i) => {
+ if (isFrame(element) && element.contentDocument) {
+ const frameBody = element.contentDocument.body
+ const allFrameTabbable = getAllTabbableIn(
+ frameBody,
+ false,
+ fallbackToFocusable
+ )
+ tabbableElements.splice(i, 1, ...allFrameTabbable)
+ }
+ })
+
+ if (!tabbableElements.length && fallbackToFocusable) {
+ return elements
+ }
+ return tabbableElements
+}
+
+/**
+ * Returns the first tabbable element in `container`, including the container
+ * itself if it's tabbable.
+ */
+export function getFirstTabbableIn(
+ container: HTMLElement,
+ includeContainer?: boolean,
+ fallbackToFocusable?: boolean
+) {
+ const [first] = getAllTabbableIn(
+ container,
+ includeContainer,
+ fallbackToFocusable
+ )
+
+ return first || null
+}
+
+/**
+ * Checks if `element` has focus. Elements that are referenced by
+ * `aria-activedescendant` are also considered.
+ * @example
+ * hasFocus(document.getElementById("id"));
+ */
+export function hasFocus(element: Element) {
+ const activeElement = getActiveElement(element)
+ if (!activeElement) return false
+ if (activeElement === element) return true
+ const activeDescendant = activeElement.getAttribute('aria-activedescendant')
+ if (!activeDescendant) return false
+ return activeDescendant === element.id
+}
+
+/**
+ * Checks if `element` has focus within. Elements that are referenced by
+ * `aria-activedescendant` are also considered.
+ * @example
+ * hasFocusWithin(document.getElementById("id"));
+ */
+export function hasFocusWithin(element: Node | Element) {
+ const activeElement = getActiveElement(element)
+ if (!activeElement) return false
+ if (contains(element, activeElement)) return true
+ const activeDescendant = activeElement.getAttribute('aria-activedescendant')
+ if (!activeDescendant) return false
+ if (!('id' in element)) return false
+ if (activeDescendant === element.id) return true
+ return !!element.querySelector(`#${CSS.escape(activeDescendant)}`)
+}
+
+/**
+ * Ensures `element` will receive focus if it's not already.
+ * @example
+ * ensureFocus(document.activeElement); // does nothing
+ *
+ * const element = document.querySelector("input");
+ *
+ * ensureFocus(element); // focuses element
+ * ensureFocus(element, \{ preventScroll: true \}); // focuses element preventing scroll jump
+ *
+ * function isActive(el) \{
+ * return el.dataset.active === "true";
+ * \}
+ *
+ * ensureFocus(document.querySelector("[data-active='true']"), \{ isActive \}); // does nothing
+ *
+ * @returns \{number\} `requestAnimationFrame` call ID so it can be passed to `cancelAnimationFrame` if needed.
+ */
+export function ensureFocus(
+ element: HTMLElement,
+ { preventScroll, isActive = hasFocus }: EnsureFocusOptions = {}
+) {
+ // TODO: Try to use queueMicrotask before requestAnimationFrame and dispatch
+ // focus events if the element is not focusable?
+ if (isActive(element)) return -1
+ element.focus({ preventScroll })
+ if (isActive(element)) return -1
+ return requestAnimationFrame(() => {
+ if (isActive(element)) return
+ element.focus({ preventScroll })
+ })
+}
+
+type EnsureFocusOptions = FocusOptions & {
+ isActive?: typeof hasFocus
+}
diff --git a/test/unit/specs/components/v-popover.spec.js b/test/unit/specs/components/v-popover.spec.js
index 565d9314b..59a00d95b 100644
--- a/test/unit/specs/components/v-popover.spec.js
+++ b/test/unit/specs/components/v-popover.spec.js
@@ -109,8 +109,10 @@ describe('VPopover', () => {
it('should focus the first tabbable element in the popover by default and not warn', async () => {
render(TestWrapper, { props: { popoverContentTabIndex: 0 } })
await doOpen()
- expect(getPopover()).toHaveFocus()
- expect(warn).not.toHaveBeenCalled()
+ await nextTick(() => {
+ expect(getPopover()).toHaveFocus()
+ expect(warn).not.toHaveBeenCalled()
+ })
})
it('should neither focus no warn when the prop is false', async () => {
diff --git a/tsconfig.json b/tsconfig.json
index b6ae0c31f..2fd9a4615 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -51,13 +51,16 @@
"src/components/TableSortIcon.vue",
"src/components/VCopyButton.vue",
"src/components/VSketchFabViewer.vue",
+
"src/components/VAudioThumbnail/**.vue",
"src/components/VAudioTrack/**/*.vue",
"src/components/VCheckbox/**.vue",
+ "src/components/VContentLink/**.vue",
"src/components/VGlobalAudioSection/**.vue",
"src/components/VIcon/**.vue",
"src/components/VImageGrid/**.vue",
"src/components/VIconButton/**.vue",
+ "src/components/VInputField/**.vue",
"src/components/VLicense/**.vue",
"src/components/VLogoLoader/**.vue",
"src/components/VMediaInfo/**.vue",
@@ -66,16 +69,15 @@
"src/components/VSnackbar.vue",
"src/components/VSkeleton/**.vue",
"src/components/VTabs/**.vue",
+
"src/components/VAllResultsGrid/VAudioCell.vue",
"src/components/VAllResultsGrid/VImageCellSquare.vue",
- "src/components/VContentLink/**.vue",
"src/components/VContentReport/VReportDescForm.vue",
"src/components/VErrorSection/VErrorImage.vue",
- "src/components/VHeader/VFilterButton.vue",
- "src/components/VHeader/VSearchBar/VSearchBar.vue",
- "src/components/VInputField/VInputField.vue",
- "src/components/VErrorSection/VErrorImage.vue",
"src/components/VFilters/VLicenseExplanation.vue",
+ "src/components/VHeader/VFilterButton.vue",
+ "src/components/VHeader/VSearchBar/**.vue",
+ "src/components/VImageDetails/VRelatedImages.vue",
"src/pages/feedback.vue",
"src/pages/search-help.vue",
"src/composables/types.js",
diff --git a/typings/csstype/index.d.ts b/typings/csstype/index.d.ts
index 62ac280ea..326d7632f 100644
--- a/typings/csstype/index.d.ts
+++ b/typings/csstype/index.d.ts
@@ -8,5 +8,6 @@ declare module 'csstype' {
'--unusable-height'?: string
'--progress-time-left'?: string
'--seek-time-left'?: string
+ '--cell-idx'?: number
}
}