Localisation updates from https://translatewiki.net.
[mediawiki.git] / resources / lib / codex / modules / useButtonGroupKeyboardNav.js
blob8feca4415cd40848f9d58690afa39179913a2254
1 "use strict";const f=require("vue"),h=require("./useComputedDirection.cjs");function y(t){return t.label===void 0?t.value:t.label===null?"":t.label}function A(t){const i=f.ref(),o=f.ref(),s=f.ref(new Map),v=h(i);function p(e,u){const n=e;n&&s.value.set(u,n)}function w(e){o.value=e}function g(){o.value=void 0}function r(e,u){var b;const n=e+u,d=t.value[n];if(d)if(d.disabled)r(n,u);else{const c=(b=s.value.get(n))==null?void 0:b.$el;c==null||c.focus()}}function a(){var e;r((e=o.value)!=null?e:-1,1)}function l(){var e;r((e=o.value)!=null?e:t.value.length,-1)}function D(){v.value==="rtl"?l():a()}function B(){v.value==="rtl"?a():l()}function k(e){switch(e.key){case"ArrowRight":e.preventDefault(),D();break;case"ArrowLeft":e.preventDefault(),B();break;case"ArrowDown":e.preventDefault(),a();break;case"ArrowUp":e.preventDefault(),l();break}}return{rootElement:i,assignTemplateRef:p,onFocus:w,onBlur:g,onKeydown:k}}exports.getButtonLabel=y;exports.useButtonGroupKeyboardNav=A;