siegel
Version:
Web application development ecosystem
1 lines • 722 B
JavaScript
import e from"../../../common/is/exists/index.js";import*as t from"./key_codes.js";export default function(r,o){let{selectStore:n,keyCode:i,options:s,selectedOptionIndex:d}=r,{onDelete:a,onEnter:c}=o,[f,l]=n,{arrowSelectIndex:m}=f,u=i==t.UP;u||i==t.DOWN?(f.arrowSelectIndex=function(t){let{options:r,selectedOptionIndex:o,arrowSelectIndex:n,isUp:i}=t,s=o?.constructor.name=="Set",{length:d}=r,a=d-1,c=i?-1:1,f=new Set([]),l=e(n)?n+c:i?a:0;l=l<0?a:l>a?0:l;for(let e=l;0<=e&&e<d;e+=c){if(!(s?o.has(e):o==e)&&!r[e].disabled)return e;if(f.add(e),i?0==e&&(e=a):e==a&&(e=-1),f.size==a)return}}({options:s,selectedOptionIndex:d,arrowSelectIndex:m,isUp:u}),e(f.arrowSelectIndex)&&l({...f})):i==t.DELETE?a():e(m)&&i==t.ENTER&&c()};