UNPKG

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 • 4.58 kB
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{F as t,it as n,t as r}from"./Box-CN-vzd2M.js";import{n as i,o as a}from"./i18n.store-cEFY1tQT.js";import{n as o}from"./KeyboardArrowDown-D7WhzLBq.js";import{n as s,t as c}from"./Delete--d__ZiCF.js";import{a as l,m as ee,n as te,p as ne}from"./esm-B1_nJaTZ.js";import{r as re}from"./Save-BBHi0U07.js";import{t as u}from"./Download-TUclGRoE.js";import{r as d}from"./redis-state.store-DegzWxJZ.js";import{_ as f,d as p}from"./index-B6abhTyw.js";import{a as m,c as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S}from"./KeyPagerInline-BWGRNe0y.js";var C=e(a()),w=n();function T({response:e,value:n,valueBuffer:a,keyName:T,valueFormat:E,onRefresh:D}){let O=i(e=>e.strings),k=d(e=>e.connection),{toast:A,confirm:j,generalHandleError:M}=f(),N=t(),P=k?.readonly===!0,F=N.palette.mode===`dark`,[I,L]=(0,C.useState)(()=>g(n?Object.keys(n).length:0)),[R,z]=(0,C.useState)([]),[B,V]=(0,C.useState)(!1),[H,U]=(0,C.useState)(null),[W,G]=(0,C.useState)(!1),[K,q]=(0,C.useState)(``),J=(0,C.useCallback)(()=>n?Object.keys(n).sort((e,t)=>Number(e)-Number(t)):[],[n]);(0,C.useEffect)(()=>{if(!n)return;let e=J(),t=h(I,e.length);L(t),z(e.slice(t.startIndex,t.endIndex).map(e=>({key:e,value:n[e]})))},[n]);let Y=(0,C.useCallback)(e=>{if(L(e),!n){z([]);return}z(J().slice(e.startIndex,e.endIndex).map(e=>({key:e,value:n[e]})))},[n,J]),ie=(0,C.useCallback)(()=>{U({type:`append`,model:{type:`array`,key:T}}),V(!0)},[T]),X=(0,C.useCallback)(async e=>{try{await j({message:O?.confirm?.deleteArrayIndex??O?.confirm?.areYouSure??`Are you sure?`}),await p({action:`key/array-delete-index`,payload:{key:T,index:e}}),A(O?.status?.deletedArrayIndex),D()}catch(e){M(e)}},[T,O,j,A,D,M]),Z=(0,C.useCallback)((e,t)=>{U({type:`edit`,model:{type:`array`,key:T,index:e,value:typeof t==`string`&&t.length>=d.getState().maxValueAsBuffer?a?.[e]:t}}),V(!0)},[T,a]),ae=(0,C.useCallback)(e=>{V(!1),U(null),e&&D()},[D]),oe=F?`rgba(255,255,255,0.1)`:`rgba(0,0,0,0.1)`,se=F?`rgba(255,255,255,0.05)`:`rgba(0,0,0,0.04)`,Q=F?`rgba(255,255,255,0.05)`:`rgba(0,0,0,0.06)`,$=e=>({fontSize:24,cursor:`pointer`,mx:`2px`,opacity:.7,color:e,"&:hover":{opacity:1}});return(0,w.jsxs)(r,{children:[(0,w.jsx)(S,{paging:I,onPageChange:Y}),(0,w.jsxs)(r,{children:[(0,w.jsxs)(r,{sx:{display:`flex`,alignItems:`center`,gap:1,px:2,py:1,fontWeight:`bold`,bgcolor:N.palette.primary.main,color:N.palette.primary.contrastText,borderBottom:`2px solid ${Q}`},children:[(0,w.jsx)(r,{component:`span`,sx:{flex:`20%`},children:O?.page?.key?.array?.table?.index??`Index`}),(0,w.jsx)(r,{component:`span`,sx:{flex:`60%`},children:O?.page?.key?.array?.table?.value??`Value`}),(0,w.jsx)(r,{component:`span`,sx:{flex:`20%`,textAlign:`right`,display:`flex`,justifyContent:`flex-end`,alignItems:`center`},children:!P&&(0,w.jsx)(o,{title:O?.intention?.add,children:(0,w.jsx)(s,{sx:{cursor:`pointer`,color:`inherit`},onClick:ie})})})]}),R.map((e,t)=>(0,w.jsxs)(r,{sx:{display:`flex`,alignItems:`flex-start`,gap:1,px:2,py:`6px`,borderBottom:`1px solid ${Q}`,bgcolor:t%2==0?se:`transparent`,"&:hover":{bgcolor:`${oe} !important`}},children:[(0,w.jsx)(r,{component:`span`,sx:{flex:`20%`,cursor:`pointer`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,userSelect:`text`},onClick:()=>Z(e.key,e.value),children:e.key}),(0,w.jsx)(r,{component:`span`,sx:{flex:`60%`,cursor:`pointer`,overflow:`auto`,maxHeight:200,...E===`hex`?{}:{whiteSpace:`pre-wrap`,wordBreak:`break-all`,fontFamily:`'Roboto Mono', monospace`},userSelect:`text`},onClick:()=>Z(e.key,e.value),children:E===`hex`?(0,w.jsx)(v,{value:_(e.value),truncated:x(e.value)}):(0,w.jsxs)(w.Fragment,{children:[_(y(e.value,E)),x(e.value)&&(0,w.jsx)(`span`,{style:{opacity:.5},children:`...`})]})}),(0,w.jsxs)(r,{component:`span`,sx:{flex:`20%`,textAlign:`right`,whiteSpace:`nowrap`},children:[!P&&(0,w.jsx)(o,{title:O?.intention?.delete,children:(0,w.jsx)(c,{sx:$(`error.main`),onClick:()=>X(e.key)})}),(0,w.jsx)(o,{title:O?.intention?.jsonViewShow,children:(0,w.jsx)(ee,{sx:$(`secondary.main`),onClick:()=>{q(String(e.value??``)),G(!0)}})}),(0,w.jsx)(o,{title:O?.intention?.copy,children:(0,w.jsx)(ne,{sx:$(`secondary.main`),onClick:()=>b(e.value)})}),(0,w.jsx)(o,{title:O?.intention?.downloadBuffer,children:(0,w.jsx)(u,{sx:$(`secondary.main`),onClick:()=>m(a?.[e.key],T,`${T}-${e.key}`)})}),!P&&(0,w.jsx)(o,{title:O?.intention?.edit,children:(0,w.jsx)(re,{sx:$(`primary.main`),onClick:()=>Z(e.key,e.value)})})]})]},e.key))]}),(0,w.jsx)(te,{open:B,data:H,onClose:ae}),(0,w.jsx)(l,{open:W,value:K,onClose:()=>G(!1)})]})}export{T as default};