p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
1 lines • 5.24 kB
JavaScript
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{N as t,V as n,d as r,r as i,w as a}from"./Box-CN-vzd2M.js";import{o}from"./i18n.store-cEFY1tQT.js";function s(e){return t(e).defaultView||window}var c=s,l=n;function u(e,t){if(!e||!t)return!1;if(e.contains(t))return!0;let n=t.getRootNode?.();if(n&&n instanceof ShadowRoot){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode??n.host??null}}return!1}function d(e,t=166){let n;function r(...r){clearTimeout(n),n=setTimeout(()=>{e.apply(this,r)},t)}return r.clear=()=>{clearTimeout(n)},r}var f=t;function p(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}var m=p,h=u,g=e(o(),1),_=g.createContext(void 0);function v(){let e=g.useContext(_);if(e===void 0)throw Error(`MUI: RovingTabIndexContext is missing. Roving tab index items must be placed within a roving tab index provider.`);return e}var y=Object.is;function b(e,t){if(e===t)return!0;if(!(e instanceof Object)||!(t instanceof Object))return!1;let n=0,r=0;for(let r in e)if(n+=1,!y(e[r],t[r])||!(r in t))return!1;for(let e in t)r+=1;return n===r}var x=[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function S(e){let{activeItemId:n,getDefaultActiveItemId:i,orientation:a,isRtl:o=!1,isItemFocusable:s=I,wrap:c=!0}=e,[l,u]=g.useState(n),[d,f]=g.useState(n),m=l;n!==d&&(f(n),n!==void 0&&n!==l&&(m=n,u(n)));let h=g.useRef(null),_=g.useRef(new Map),[v,y]=g.useState(0),S=g.useMemo(()=>N(_.current),[v]),C=w(m,S,s,i),T=g.useRef(C);T.current=C;let E=g.useCallback(()=>{let e=N(_.current);return A(e,w(T.current,e,s,i))},[i,s]),k=g.useCallback(()=>_.current,[]),j=r(e=>{b(_.current.get(e.id)??null,e)||(_.current.set(e.id,e),y(e=>e+1))}),F=r(e=>{_.current.delete(e)&&y(e=>e+1)}),L=r(e=>{u(e)}),R=g.useCallback(e=>T.current===e,[]),B=g.useCallback((e,t,n,r)=>{let i=O(P(_.current),e,t,n,r??s);return i?(i.element?.focus(),u(i.id),i):null},[s]),V=g.useCallback(e=>({onFocus:e=>{let t=P(_.current),n=M(t,e.target);n!==-1&&u(t[n].id)},onKeyDown:e=>{if(e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||!x.includes(e.key))return;let n=a===`horizontal`?`ArrowLeft`:`ArrowUp`,r=a===`horizontal`?`ArrowRight`:`ArrowDown`;a===`horizontal`&&o&&(n=`ArrowRight`,r=`ArrowLeft`);let i=P(_.current),s=p(t(h.current)),l=s===h.current,u=D(i,s,T.current),d=`next`;switch(e.key){case n:d=`previous`,e.preventDefault(),l&&(u=i.length);break;case r:e.preventDefault(),l&&(u=-1);break;case`Home`:e.preventDefault(),u=-1;break;case`End`:e.preventDefault(),d=`previous`,u=i.length;break;default:return}B(u,d,c)},ref:z(e,e=>{h.current=e})}),[B,o,a,c]),H=g.useCallback(e=>{let n=P(_.current),r=p(t(h.current));return B(r===h.current?-1:D(n,r,T.current),`next`,!0,e)?.id??null},[B]);return g.useMemo(()=>({activeItemId:C,focusNext:H,getActiveItem:E,getContainerProps:V,getItemMap:k,isItemActive:R,registerItem:j,setActiveItemId:L,unregisterItem:F}),[C,H,E,V,k,R,j,L,F])}function C(e){let{activeItemId:t,registerItem:r,unregisterItem:i}=v(),o=g.useRef(null),s=g.useMemo(()=>({disabled:e.disabled??!1,element:null,focusableWhenDisabled:e.focusableWhenDisabled??!1,id:e.id,selected:e.selected??!1,textValue:e.textValue}),[e.disabled,e.focusableWhenDisabled,e.id,e.selected,e.textValue]),c=g.useRef(s);c.current=s;let l=g.useCallback(t=>{if(o.current=t,t==null){queueMicrotask(()=>{o.current??i(e.id)});return}r({...c.current,element:t})},[e.id,r,i]),u=a(e.ref,l);return n(()=>{o.current&&r({...s,element:o.current})},[s,r]),n(()=>{let t=e.id;return()=>{i(t)}},[e.id,i]),{ref:u,tabIndex:t===e.id?0:-1}}function w(e,t,n,r){return e==null?E(t,n,r):T(e,t,n)}function T(e,t,n){let r=j(t,e);return r===-1?k(t,n):n(t[r])?t[r].id:O(t,r,`next`,!1,n)?.id??null}function E(e,t,n){let r=n?.(e);if(r!=null){let n=A(e,r);if(n&&t(n))return n.id}return k(e,t)}function D(e,t,n){if(t){let n=M(e,t);if(n!==-1)return n}return j(e,n)}function O(e,t,n,r,i){let a=e.length-1;if(a===-1)return null;let o=!1,s=F(t,a,n,r),c=s;for(;s!==-1;){if(s===c){if(o)return null;o=!0}let t=e[s];if(!t||!i(t))s=F(s,a,n,r);else return t}return null}function k(e,t){return e.find(e=>t(e))?.id??null}function A(e,t){return t==null?null:e.find(e=>e.id===t)??null}function j(e,t){return t==null?-1:e.findIndex(e=>e.id===t)}function M(e,t){return t?e.findIndex(e=>e.element===t||e.element?.contains(t)):-1}function N(e){let t=Array.from(e.values());if(t.every(e=>e.element==null))return t;let n=t.filter(L).sort((e,t)=>R(e.element,t.element)),r=t.filter(e=>!L(e));return[...n,...r]}function P(e){return N(e).filter(L)}function F(e,t,n,r=!0){return n===`next`?e===t?r?0:-1:e+1:e===0?r?t:-1:e-1}function I(e){return e.element?e.focusableWhenDisabled?!0:!e.disabled&&!e.element.hasAttribute(`disabled`)&&e.element.getAttribute(`aria-disabled`)!==`true`&&e.element.hasAttribute(`tabindex`):!1}function L(e){return e.element!=null&&e.element.isConnected}function R(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function z(...e){return t=>{e.forEach(e=>{i(e??null,t)})}}var B=d;export{_ as a,m as c,u as d,l as f,S as i,f as l,s as m,I as n,v as o,c as p,C as r,h as s,B as t,d as u};