efficient-shell 4.175.0 → 4.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +426 -6
- package/dist/{Browser-PZIVSYLM.js → Browser-LZMLL4CZ.js} +14 -14
- package/dist/Calculator-R5OEHQ67.js +29 -0
- package/dist/ConfirmDialog-CMNQZQA3.js +1 -0
- package/dist/{CurrencyConverter-4RZZ5STO.js → CurrencyConverter-AMXUOQR2.js} +7 -7
- package/dist/{Documents-ERSFDOCV.js → Documents-M4HKZAPJ.js} +12 -12
- package/dist/{Files-3J2DW6ET.js → Files-OY5GKCXA.js} +24 -24
- package/dist/Notepad-JLDNTMVB.js +25 -0
- package/dist/PdfViewer-3SC3LE4U.js +1 -0
- package/dist/{PomodoroTimer-D6VQJICB.js → PomodoroTimer-LE6J2KUU.js} +24 -24
- package/dist/Preview-2KHLL6NP.js +188 -0
- package/dist/{Sidebar-2BZJ2MEI.js → Sidebar-BQ4P5LBI.js} +25 -25
- package/dist/Spreadsheet-B5Z5MSX4.js +37 -0
- package/dist/{Stock-KRPM6NSB.js → Stock-GWVG2INU.js} +4 -4
- package/dist/{Weather-HRH4JHTF.js → Weather-APBCG4TO.js} +13 -13
- package/dist/{WorldClock-OUSV52XM.js → WorldClock-2LMZYKWR.js} +7 -7
- package/dist/apps/index.d.ts +4 -2
- package/dist/apps/index.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/{chunk-L3U2R7DH.js → chunk-3DGTIWZP.js} +1 -1
- package/dist/{chunk-6BZCJQCT.js → chunk-47VJNVB6.js} +643 -643
- package/dist/{chunk-KS7OSQ3Y.js → chunk-5ZDM6WIC.js} +11 -11
- package/dist/{chunk-E2D54MVV.js → chunk-6CFBF543.js} +2 -2
- package/dist/{chunk-LCTSBQBJ.js → chunk-7WZEFHPS.js} +1 -1
- package/dist/{chunk-PGVUO7GB.js → chunk-AA4TMQOS.js} +3 -3
- package/dist/chunk-AZURXTRB.js +1 -0
- package/dist/chunk-C3QOHMR6.js +1 -0
- package/dist/{chunk-YJRC6IKD.js → chunk-CIXQKCFA.js} +4 -4
- package/dist/chunk-CZK2VKIO.js +9 -0
- package/dist/{chunk-KG4NRNFS.js → chunk-FORN7LG7.js} +1 -1
- package/dist/chunk-J3LIIIHJ.js +1 -0
- package/dist/chunk-KDRAU4XQ.js +27 -0
- package/dist/{chunk-ZOPYAOUP.js → chunk-KVOFUFPP.js} +1 -1
- package/dist/{chunk-KDHXRJIX.js → chunk-LK7V32MR.js} +1 -1
- package/dist/{chunk-GCO3A63X.js → chunk-N6STBYXR.js} +111 -111
- package/dist/{chunk-54OP3M3K.js → chunk-NHIGOEZF.js} +1 -1
- package/dist/{chunk-EXXHI5DO.js → chunk-OGXU7QFW.js} +2 -2
- package/dist/{chunk-JOOXVX4A.js → chunk-PE4F4MJE.js} +4 -4
- package/dist/chunk-R7EBJKN2.js +69 -0
- package/dist/{chunk-TMQEH7WA.js → chunk-SVO3ES2E.js} +1 -1
- package/dist/{chunk-RKR5V4QR.js → chunk-T4CFSGSL.js} +6 -6
- package/dist/{chunk-D3UQLWIZ.js → chunk-UAIVAA5X.js} +11 -11
- package/dist/{chunk-REXHKIIJ.js → chunk-WNEO7TSP.js} +1 -1
- package/dist/{chunk-XJYXKO7K.js → chunk-ZAE6ROV7.js} +15 -15
- package/dist/file-intake/index.js +1 -1
- package/dist/i18n/index.d.ts +79 -0
- package/dist/i18n/index.js +2 -0
- package/dist/{index-DIaav9a1.d.ts → index-DcUj0nXY.d.ts} +39 -927
- package/dist/index.d.ts +3 -2
- package/dist/index.js +656 -656
- package/dist/locales/zh-Hans.d.ts +59 -0
- package/dist/locales/zh-Hans.js +1 -0
- package/dist/map/index.js +3 -3
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/strings-ZbotP_I6.d.ts +1292 -0
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +1 -1
- package/package.json +21 -1
- package/dist/Calculator-6BJVESFN.js +0 -29
- package/dist/ConfirmDialog-6PVUVYXZ.js +0 -1
- package/dist/Notepad-MVMFJE2F.js +0 -25
- package/dist/PdfViewer-RKRGO7Q2.js +0 -1
- package/dist/Preview-VIHMVC7B.js +0 -187
- package/dist/Spreadsheet-KTB6JLBV.js +0 -37
- package/dist/chunk-3YTHR7IC.js +0 -1
- package/dist/chunk-7LAPNAKS.js +0 -1
- package/dist/chunk-FEK5ELXS.js +0 -27
- package/dist/chunk-VIIBZ6DE.js +0 -69
- package/dist/chunk-VRLHUZSC.js +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setPdfPreview as e}from"./chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"./chunk-VTVSMRFX.js";import{toast_default as n}from"./chunk-
|
|
1
|
+
import{setPdfPreview as e}from"./chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"./chunk-VTVSMRFX.js";import{toast_default as n}from"./chunk-3DGTIWZP.js";var i="react-os-shell:preview-opened";async function o(o){const{filePath:a,filename:r,kind:c,onStaged:s}=o;try{const o=await fetch(`${("undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000").replace(/\/$/,"")}/api/file?path=${encodeURIComponent(a)}`,{credentials:"include"});if(!o.ok)return n.error(`Download failed (${o.status})`),!1;const d=await o.blob();if("csv"===c){const e=await d.text();t({csv:e,filename:r}),s?.("/spreadsheet")}else{const t=URL.createObjectURL(d);e({url:t,filename:r,kind:c}),s?.("/preview")}return"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:{filePath:a,filename:r,kind:c}})),!0}catch(e){return n.error(e?.message||"Open failed"),!1}}export{i as PREVIEW_OPENED_EVENT,o as openPreviewFile};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{glassStyle as t,glassFill as e}from"./chunk-HZZNJHRH.js";import{
|
|
1
|
+
import{glassStyle as t,glassFill as e}from"./chunk-HZZNJHRH.js";import{registerModalEscapeInterceptor as o,escapeSurfaceAbove as i,onOverlayOpen as r,Z_LAYERS as n}from"./chunk-X4FJ54PP.js";import{useBrowserLayoutEffect as a}from"./chunk-D65T4H6J.js";import{forwardRef as l,useId as s,useState as h,useRef as c,useEffect as d,isValidElement as m,cloneElement as u}from"react";import{createPortal as f}from"react-dom";import{jsxs as g,jsx as p,Fragment as b}from"react/jsx-runtime";var x="aria-disabled:cursor-not-allowed aria-disabled:opacity-60",w="inline-flex items-center justify-center rounded-(--radius-control) font-medium transition-colors rosh-focus-ring focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 "+x,v={primary:"bg-blue-600 text-white shadow-sm hover:bg-blue-700 focus-visible:ring-[color:var(--rosh-focus-ring-strong)]",secondary:"border border-gray-300 bg-white text-gray-700 shadow-sm hover:bg-gray-50 focus-visible:ring-[color:var(--rosh-focus-ring)]",ghost:"text-gray-700 hover:bg-gray-100 focus-visible:ring-[color:var(--rosh-focus-ring)]","ghost-danger":"text-red-600 hover:bg-red-50 focus-visible:ring-[color:var(--rosh-focus-ring-invalid)]",danger:"bg-red-600 text-white shadow-sm hover:bg-red-700 focus-visible:ring-[color:var(--rosh-focus-ring-invalid-strong)]",link:"text-blue-600 underline-offset-4 hover:underline focus-visible:ring-[color:var(--rosh-focus-ring)]"},y={sm:"gap-1 px-2.5 py-1 text-xs",md:"gap-1.5 px-3 py-1.5 text-sm",lg:"gap-2 px-4 py-2.5 text-sm","touch-sm":"gap-1.5 h-11 px-4 text-base",touch:"gap-2 h-14 px-5 text-base","touch-lg":"gap-2 h-16 px-6 text-lg","touch-xl":"gap-3 h-20 px-8 text-2xl"},M="inline-flex items-center font-medium transition-colors rosh-focus-ring focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60 "+x,N={sm:"gap-1 text-xs",md:"gap-1.5 text-sm",lg:"gap-2 text-sm","touch-sm":"gap-1.5 text-base",touch:"gap-2 text-base","touch-lg":"gap-2 text-lg","touch-xl":"gap-3 text-2xl"},W={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10","touch-sm":"h-11 w-11",touch:"h-14 w-14","touch-lg":"h-16 w-16","touch-xl":"h-20 w-20"};function k({variant:t="primary",size:e="md",block:o=!1,className:i=""}={}){const r="link"===t;return[r?M:w,v[t],r?N[e]:y[e],o?"w-full":"",i].filter(Boolean).join(" ")}function H({variant:t="ghost",size:e="md",pressed:o=!1,className:i=""}={}){const r=!o||"ghost"!==t&&"secondary"!==t?v[t]:"bg-blue-50 text-blue-700 hover:bg-blue-100 focus-visible:ring-[color:var(--rosh-focus-ring)]";return[w,r,W[e],"shrink-0 p-0",i].filter(Boolean).join(" ")}var C=448,B=240,R=8,j=()=>({left:0,right:window.innerWidth,top:0,bottom:window.innerHeight});function z(t){const e=j(),o=t?.closest?.("[data-modal-panel]");if(!o)return e;const i=o.getBoundingClientRect();return i.width<=0||i.height<=0?e:{left:Math.max(e.left,i.left),right:Math.min(e.right,i.right),top:Math.max(e.top,i.top),bottom:Math.min(e.bottom,i.bottom)}}var E=/* @__PURE__ */new Set(["hidden","clip","auto","scroll"]);var T={top:"bottom",bottom:"top",left:"right",right:"left"},F={top:["right","left"],bottom:["right","left"],left:["top","bottom"],right:["top","bottom"]};function L(t,e,o){return{top:t.top-o-(e.top+8),bottom:e.bottom-8-(t.bottom+o),left:t.left-o-(e.left+8),right:e.right-8-(t.right+o)}}var P=(t,e,o)=>Math.max(e,Math.min(t,o));function A(t,e,o){let i=NaN,r=NaN,n=NaN,a=NaN,l=NaN;const s=()=>{const e=t()?.getBoundingClientRect();if(!e)return!1;const s=o?o():NaN,h=e.left!==i||e.top!==r||e.right!==n||e.bottom!==a||s!==l&&!(Number.isNaN(s)&&Number.isNaN(l));return i=e.left,r=e.top,n=e.right,a=e.bottom,l=s,h};s();const h=()=>{s(),e()};let c=requestAnimationFrame(function t(){s()&&e(),c=requestAnimationFrame(t)});return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{cancelAnimationFrame(c),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}}function D({trigger:t,menu:e,bounds:o,align:i,side:r}){const n=L(t,o,4),a="bottom"===r?"top":"bottom",l=e.height>n[r]&&(e.height<=n[a]||n[a]>n[r])?a:r,s=Math.max(Math.min(e.height,96),n[l]),h=Math.min(e.height,s),c=P("bottom"===l?t.bottom+4:t.top-4-h,o.top+8,o.bottom-8-h),d=Math.max(0,o.right-o.left-16),m=Math.min(e.width,d);return{left:P("start"===i?t.left:t.right-m,o.left+8,o.right-8-m),top:c,side:l,maxHeight:s,maxWidth:d}}function I(t,e,o={}){const{matchTriggerWidth:i=!1,preferredMaxWidth:r=C,preferredMaxHeight:n=B,popupRef:l}=o,[s,c]=h(null);return a(()=>{if(!e)return void c(null);const o=()=>{const e=t.current,o=e?.getBoundingClientRect();if(!o)return;const a=z(e),s=a.bottom-o.bottom-4-8,h=o.top-a.top-4-8,d=s<Math.min(n,160)&&h>s,m=Math.max(96,Math.min(n,d?h:s)),u=Math.max(0,a.right-a.left-16),f={minWidth:o.width,maxWidth:Math.min(r,u),maxHeight:m};if(i){const t=Math.min(o.width,u);f.width=t,f.maxWidth=t,f.left=Math.min(Math.max(a.left+8,o.left),a.right-8-t)}else if(l&&a.right-8-o.left<f.maxWidth&&Math.min(o.right,a.right-8)-a.left-8<f.maxWidth){const t=l.current?.offsetWidth??0,e=t>0?Math.min(t,f.maxWidth):f.maxWidth;f.left=Math.max(a.left+8,Math.min(o.left,a.right-8-e))}else if(a.right-8-o.left<f.maxWidth){const t=Math.min(o.right,a.right-8);f.right=window.innerWidth-t,f.maxWidth=Math.min(f.maxWidth,Math.max(0,t-a.left-8))}else f.left=Math.max(a.left+8,o.left);d?f.bottom=window.innerHeight-o.top+4:f.top=o.bottom+4,c(f)};return o(),A(()=>t.current,o,l?()=>l.current?.offsetWidth??NaN:void 0)},[e,t,i,r,n,l]),s}function J({point:t,menu:e,bounds:o}){const i={left:t.x,right:t.x,top:t.y,bottom:t.y},r=o.right-8-t.x,n=t.x-(o.left+8);return D({trigger:i,menu:e,bounds:o,align:e.width<=r||r>=n?"start":"end",side:"bottom"})}var S={top:"bottom-full left-1/2 -translate-x-1/2 mb-3",bottom:"top-full left-1/2 -translate-x-1/2 mt-3",left:"right-full top-1/2 -translate-y-1/2 mr-3",right:"left-full top-1/2 -translate-y-1/2 ml-3"};function $({content:l,side:b="top",delay:x=200,children:w,className:v="relative inline-flex",describe:y=!0}){const[M,N]=h(!1),[W,k]=h(null),H=c(void 0),C=c(null),B=c(null),R=s(),D=c(!1),I=()=>{window.clearTimeout(H.current),D.current||(H.current=window.setTimeout(()=>N(!0),x))},J=()=>{window.clearTimeout(H.current),N(!1)},$=()=>{D.current=!0,J()},q=()=>{D.current=!1,J()};d(()=>()=>window.clearTimeout(H.current),[]),a(()=>{if(!M)return void k(null);const t=()=>{const t=C.current,e=B.current;if(!t||!e)return;const o=z(t),i=Math.max(0,o.right-o.left-16),r=Math.max(0,o.bottom-o.top-16);e.style.maxWidth=`${i}px`,e.style.maxHeight=`${r}px`;const n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return;const a=t.getBoundingClientRect();if(!function(t){const e=t.getBoundingClientRect();if(e.width<=0&&e.height<=0&&0===e.left&&0===e.top)return null;const o=j(),i={left:Math.max(o.left,e.left),right:Math.min(o.right,e.right),top:Math.max(o.top,e.top),bottom:Math.min(o.bottom,e.bottom)};let r=getComputedStyle(t).position;for(let e=t.parentElement;e&&e!==document.documentElement&&"fixed"!==r;e=e.parentElement){const t=getComputedStyle(e);if("absolute"===r&&"static"===t.position)continue;r=t.position;const o=E.has(t.overflowX),n=E.has(t.overflowY);if(!o&&!n)continue;const a=e.getBoundingClientRect();a.width<=0&&a.height<=0||(o&&(i.left=Math.max(i.left,a.left),i.right=Math.min(i.right,a.right)),n&&(i.top=Math.max(i.top,a.top),i.bottom=Math.min(i.bottom,a.bottom)))}return i.right>=i.left&&i.bottom>=i.top?i:null}(t))return void J();const l=function(t,e,o,i,r){const n=L(t,i,r),a=t=>n[t]-("top"===t||"bottom"===t?e.height:e.width),l=[o,T[o],...F[o]],s=l.find(t=>a(t)>=0)??l.reduce((t,e)=>a(e)>a(t)?e:t),h=(t.left+t.right)/2,c=(t.top+t.bottom)/2;let d,m;switch(s){case"top":d=h-e.width/2,m=t.top-r-e.height;break;case"bottom":d=h-e.width/2,m=t.bottom+r;break;case"left":d=t.left-r-e.width,m=c-e.height/2;break;case"right":d=t.right+r,m=c-e.height/2}return{side:s,left:P(d,i.left+8,i.right-8-e.width),top:P(m,i.top+8,i.bottom-8-e.height)}}(a,n,b,o,12),s=function(t,e,o,i,r){const{side:n,left:a,top:l}=e,s=a+o.width,h=l+o.height;if({top:t.top-h,bottom:l-t.bottom,left:t.left-s,right:a-t.right}[n]<r)return null;const c=(t,e,o)=>o<2*i?e+o/2:Math.max(e+i,Math.min(t,e+o-i)),d=(t.left+t.right)/2,m=(t.top+t.bottom)/2;switch(n){case"top":return{side:n,x:c(d,a,o.width),y:h};case"bottom":return{side:n,x:c(d,a,o.width),y:l};case"left":return{side:n,x:s,y:c(m,l,o.height)};case"right":return{side:n,x:a,y:c(m,l,o.height)}}}(a,l,n,16,6),h={anchor:{left:a.left,top:a.top,width:a.width,height:a.height},left:l.left-a.left,top:l.top-a.top,maxWidth:i,maxHeight:r,side:l.side,arrow:s&&{left:s.x-a.left,top:s.y-a.top}};k(t=>{return t&&(o=h,(e=t).anchor.left===o.anchor.left&&e.anchor.top===o.anchor.top&&e.anchor.width===o.anchor.width&&e.anchor.height===o.anchor.height&&e.left===o.left&&e.top===o.top&&e.maxWidth===o.maxWidth&&e.maxHeight===o.maxHeight&&e.side===o.side&&e.arrow?.left===o.arrow?.left&&e.arrow?.top===o.arrow?.top)?t:h;var e,o})};return t(),A(()=>C.current,t)},[M,b,l]),d(()=>{if(!M)return;const t=o(t=>"Escape"===t.key&&(J(),!i(C.current))),e=r(J);return()=>{t(),e()}},[M]);const X=M&&y?R:void 0,Z=m(w)?u(w,{"aria-describedby":[w.props["aria-describedby"],X].filter(Boolean).join(" ")||void 0}):w,Y=M?t():void 0,G=M?e():void 0;/* @__PURE__ */
|
|
2
2
|
return g("span",{ref:C,className:v,"aria-describedby":m(w)?void 0:X,onMouseEnter:I,onMouseLeave:q,onFocus:I,onBlur:q,onPointerDown:$,onClick:$,children:[Z,M&&f(
|
|
3
|
-
/* @__PURE__ */g("span",{className:"pointer-events-none fixed left-0 top-0",style:{zIndex:
|
|
3
|
+
/* @__PURE__ */g("span",{className:"pointer-events-none fixed left-0 top-0",style:{zIndex:n.popup,...W?.anchor},children:[
|
|
4
4
|
/* @__PURE__ */p("span",{ref:B,id:R,role:"tooltip",className:`pointer-events-none absolute z-[300] box-border w-max overflow-hidden whitespace-normal break-words text-start rounded-md px-2 py-1 text-xs text-gray-800 ${W?"":S[b]}`,style:{...Y,...W&&{left:W.left,top:W.top,maxWidth:W.maxWidth,maxHeight:W.maxHeight}},children:l}),(!W||W.arrow)&&
|
|
5
5
|
/* @__PURE__ */p("span",{"aria-hidden":"true",className:"rosh-tooltip-arrow","data-side":W?.side??b,style:{background:G,"--rosh-tooltip-edge":Y?.border,...W?.arrow&&{left:W.arrow.left,top:W.arrow.top}}})]}),document.body)]})}var q=t=>!0===t||"true"===t;function X(t){t.preventDefault(),t.stopPropagation()}var Z=(t,e)=>[t,e].filter(Boolean).join(" ")||void 0;function Y({reason:t,id:e,block:o=!1,children:i}){/* @__PURE__ */
|
|
6
6
|
return g(b,{children:[
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Tooltip as e}from"./chunk-
|
|
2
|
-
return a(e,{content:y??N.hint,side:"left"===c?"right":"left",delay:600,className:`absolute inset-y-0 ${M} z-10 flex w-2 ${w}`.trim(),children:/* @__PURE__ */a("div",{role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":p??N.label,"aria-valuenow":Math.round(t),"aria-valuemin":m,"aria-valuemax":f,"aria-controls":x,"data-resize-handle":c,onPointerDown:e=>{0===e.button&&(e.preventDefault(),z.current={x:e.clientX,width:t,moved:!1,pointer:e.pointerId},e.currentTarget.setPointerCapture?.(e.pointerId),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},onPointerMove:e=>{const r=z.current;if(!r)return;if(0===e.buttons)return void P();const t=e.clientX-r.x;if(!r.moved){if(Math.abs(t)<3)return;r.moved=!0}const{onResize:n,min:o,max:i,side:l}=k.current;n(d(r.width,t,l,o,i))},onPointerUp:
|
|
1
|
+
import{Tooltip as e}from"./chunk-OGXU7QFW.js";import{useBrowserLayoutEffect as r,useBrowserState as t}from"./chunk-D65T4H6J.js";import{useShellStrings as n}from"./chunk-J3LIIIHJ.js";import{useRef as o,useEffect as i,useCallback as l}from"react";import{jsx as a,jsxs as s,Fragment as c}from"react/jsx-runtime";var u=(e,r,t)=>Math.min(t,Math.max(r,e));function d(e,r,t,n,o){return Math.round(u("left"===t?e+r:e-r,n,o))}function h(e,r,t){let n=null;try{n=window.localStorage.getItem(e)}catch{return null}const o=n?parseInt(n,10):NaN;return Number.isNaN(o)?null:u(o,r,t)}function m({width:t,onResize:s,side:c,min:m,max:f,defaultWidth:v=m,step:b=16,storageKey:g,label:p,hint:y,controls:x,className:w=""}){const N=n().resizeHandle,z=o(null),k=o({onResize:s,min:m,max:f,side:c});k.current={onResize:s,min:m,max:f,side:c},r(()=>{if(!g)return;const e=h(g,m,f);null!==e&&e!==t&&s(e)},[g]),i(()=>{if(!g)return;const e=window.setTimeout(()=>{try{window.localStorage.setItem(g,String(Math.round(t)))}catch{}},200);return()=>window.clearTimeout(e)},[t,g]);const P=l(()=>{z.current=null,document.body.style.removeProperty("cursor"),document.body.style.removeProperty("user-select")},[]);i(()=>P,[P]);const I=e=>{z.current&&(e.currentTarget.hasPointerCapture?.(z.current.pointer)&&e.currentTarget.releasePointerCapture(z.current.pointer),P())},M="left"===c?"right-0":"left-0";/* @__PURE__ */
|
|
2
|
+
return a(e,{content:y??N.hint,side:"left"===c?"right":"left",delay:600,className:`absolute inset-y-0 ${M} z-10 flex w-2 ${w}`.trim(),children:/* @__PURE__ */a("div",{role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":p??N.label,"aria-valuenow":Math.round(t),"aria-valuemin":m,"aria-valuemax":f,"aria-controls":x,"data-resize-handle":c,onPointerDown:e=>{0===e.button&&(e.preventDefault(),z.current={x:e.clientX,width:t,moved:!1,pointer:e.pointerId},e.currentTarget.setPointerCapture?.(e.pointerId),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},onPointerMove:e=>{const r=z.current;if(!r)return;if(0===e.buttons)return void P();const t=e.clientX-r.x;if(!r.moved){if(Math.abs(t)<3)return;r.moved=!0}const{onResize:n,min:o,max:i,side:l}=k.current;n(d(r.width,t,l,o,i))},onPointerUp:I,onPointerCancel:I,onLostPointerCapture:()=>{z.current&&P()},onDoubleClick:()=>s(u(v,m,f)),onKeyDown:e=>{const r="ArrowRight"===e.key?b:"ArrowLeft"===e.key?-b:null,n=null!==r?d(t,r,c,m,f):"Home"===e.key?m:"End"===e.key?f:"Enter"===e.key?u(v,m,f):null;null!==n&&(e.preventDefault(),n!==t&&s(n))},className:"group/resize relative h-full w-full cursor-col-resize touch-none rosh-focus-ring focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */a("div",{"aria-hidden":"true",className:`absolute inset-y-0 ${M} w-px bg-transparent transition-colors group-hover/resize:bg-[var(--accent-500,var(--rosh-resize-handle))] group-focus-visible/resize:w-0.5 group-focus-visible/resize:bg-[var(--accent-500,var(--rosh-resize-handle))]`})})})}var f=(e,r,t)=>Math.min(Math.max(e,r),t);function v({sidebar:e,sidebarTop:r,sidebarBottom:o,children:i,side:l="left",storageKey:u,defaultWidth:d=256,minWidth:v=180,maxWidth:b=480,className:g="",sidebarClassName:p=("right"===l?"border-l border-gray-200 bg-gray-50":"border-r border-gray-200 bg-gray-50"),contentClassName:y="bg-white"}){const x="right"===l,w=n().sidebar,[N,z]=t(()=>(u?h(u,v,b):null)??f(d,v,b),f(d,v,b)),k=null!=r||null!=o,P=/* @__PURE__ */s("div",{className:"relative flex h-full shrink-0 flex-col",style:{width:N},children:[
|
|
3
3
|
/* @__PURE__ */s("div",{className:`flex h-full flex-col ${k?"overflow-hidden":"overflow-y-auto"} ${p}`,children:[null!=r&&/* @__PURE__ */a("div",{className:"flex shrink-0 flex-col gap-2 px-2 pt-3 pb-2",children:r}),k?/* @__PURE__ */a("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e}):e,null!=o&&/* @__PURE__ */a("div",{className:"mt-auto flex shrink-0 flex-col gap-2 border-t border-gray-200 px-2 py-3",children:o})]}),
|
|
4
|
-
/* @__PURE__ */a(m,{side:l,width:N,onResize:z,min:v,max:b,defaultWidth:f(d,v,b),storageKey:u,hint:w.resize})]}),
|
|
5
|
-
return a("div",{className:`flex h-full w-full overflow-hidden ${g}`,children:/* @__PURE__ */s(c,x?{children:[
|
|
4
|
+
/* @__PURE__ */a(m,{side:l,width:N,onResize:z,min:v,max:b,defaultWidth:f(d,v,b),storageKey:u,hint:w.resize})]}),I=/* @__PURE__ */a("div",{className:`flex min-w-0 flex-1 flex-col ${y}`,children:i});/* @__PURE__ */
|
|
5
|
+
return a("div",{className:`flex h-full w-full overflow-hidden ${g}`,children:/* @__PURE__ */s(c,x?{children:[I,P]}:{children:[P,I]})})}export{m as ResizeHandle,v as SidebarLayout};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import{toast_default as e}from"./chunk-3DGTIWZP.js";import{useShellStrings as t}from"./chunk-J3LIIIHJ.js";import{forwardRef as r,useRef as n,useState as o,useMemo as i,useEffect as a,useImperativeHandle as l}from"react";import{jsx as c,jsxs as s,Fragment as d}from"react/jsx-runtime";var h=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],u=[{id:"system",name:"fontSystem",css:"-apple-system, system-ui, sans-serif"},{id:"serif",name:"fontSerif",css:'Georgia, "Times New Roman", serif'},{id:"mono",name:"fontMono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",name:"fontCursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],p=()=>Math.random().toString(36).slice(2,9),y=r(function({src:r,filename:y,onApply:m,onCancel:g},N){const L=n(null),z=n(null),D=n(null),I=n(null),P=t().annotator,$=n(P);$.current=P;const[E,W]=o("select"),[S,B]=o(h[0]),[R,j]=o(4),[H,T]=o(24),[F,U]=o(u[0].id),[A,O]=o(!0),[K,Z]=o(!1),[V,G]=o(!1),[X,q]=o(null),[J,Y]=o(null),[_,Q]=o(6),[ee,te]=o(12),[re,ne]=o([]),[oe,ie]=o(null),[ae,le]=o(null),[ce,se]=o(null),[de,he]=o(1),[ue,pe]=o(null),[ye,xe]=o(null),[me,ge]=o(null),we=n(null),[fe,be]=o(!1),ve=i(()=>ce?{w:ce.w*de,h:ce.h*de}:null,[ce,de]),ke=ve&&ae?ve.w/ae.w:1,Me=i(()=>re.find(e=>e.id===oe)??null,[re,oe]);a(()=>{"select"===E&&Me&&("color"in Me&&B(Me.color),"stroke"in Me&&j(Me.stroke),"rect"===Me.type&&te(Me.radius),"text"===Me.type&&(T(Me.size),U(Me.font),O(Me.bold),Z(Me.italic),G(Me.underline),q(Me.borderColor),Y(Me.background),Q(Me.padding)))},[oe]),a(()=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{I.current=t,le({w:t.naturalWidth,h:t.naturalHeight}),ne([]),ie(null)},t.onerror=()=>e.error($.current.loadFailed),t.src=r},[r]),a(()=>{if(!ae)return;const e=()=>{const e=L.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ae.w/ae.h;let i=ae.w,a=ae.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),se({w:i,h:a})};e();const t=new ResizeObserver(e);return L.current&&t.observe(L.current),()=>t.disconnect()},[ae]);const Ne=i(()=>re.filter(e=>"mosaic"===e.type),[re]);a(()=>{const e=I.current,t=z.current;if(!e||!t||!ae)return;t.width=ae.w,t.height=ae.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of Ne)C(r,e)},[ae,Ne,ce]);const Ce=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Le=e=>{we.current=e,be(!0)};a(()=>{if(!fe)return;const e=e=>{const t=we.current;if(!t)return;const r=Ce(e);if("draw"===t.kind)pe(b(E,t.start,r,S,R,ee));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),pe({id:"",type:"draw",points:t.points.slice(),color:S,stroke:R}))}else if("crop"===t.kind)ge(M(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ne(r=>r.map(r=>r.id===t.id?v(t.original,e,n):r))}else"resize"===t.kind&&ne(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,c=i,s=o,d=a;"nw"===t&&(l=r.x,c=r.y);"ne"===t&&(s=r.x,c=r.y);"se"===t&&(s=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=M({x:l,y:c},{x:s,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=we.current;if(we.current=null,be(!1),"draw"===e?.kind)pe(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:p()};return ne(e=>[...e,r]),ie(r.id),W("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void pe(null);const t={id:p(),type:"draw",points:e.points,color:S,stroke:R};ne(e=>[...e,t]),ie(t.id),W("select"),pe(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[fe,E,S,R,ee]);a(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(oe&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ne(e=>e.filter(e=>e.id!==oe)),ie(null)):"Escape"===e.key&&ie(null))):(e.preventDefault(),ne(e=>e.slice(0,-1)),void ie(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe]);const ze=e=>{const t=!{bold:A,italic:K,underline:V}[e];"bold"===e&&O(t),"italic"===e&&Z(t),"underline"===e&&G(t),oe&&ne(r=>r.map(r=>r.id===oe&&"text"===r.type?{...r,[e]:t}:r))},De=e=>{q(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,borderColor:e}:t))},Ie=e=>{Y(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,background:e}:t))},Pe=e=>{if(!ye)return;const t=e??ye.value;if(!t.trim())return ye.editingId&&ne(e=>e.filter(e=>e.id!==ye.editingId)),void xe(null);if(ye.editingId)ne(e=>e.map(e=>e.id===ye.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:p(),type:"text",x:ye.x,y:ye.y,text:t,color:S,size:H,font:F,bold:A,italic:K,underline:V,borderColor:X,background:J,padding:_};ne(t=>[...t,e]),ie(e.id),W("select")}xe(null)},$e=async()=>{const e=z.current,t=D.current;if(!e||!t||!ae)return null;const r=document.createElement("canvas");r.width=ae.w,r.height=ae.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),c=new Image;return await new Promise(e=>{c.onload=()=>e(),c.onerror=()=>e(),c.src=l}),n.drawImage(c,0,0,ae.w,ae.h),URL.revokeObjectURL(l),r};l(N,()=>({save:async()=>{const t=await $e();t&&t.toBlob(t=>{if(!t)return void e.error($.current.exportFailed);const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=y.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error($.current.clipboardUnsupported);const t=await $e();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success($.current.copied)}catch{e.error($.current.copyRefused)}else e.error($.current.copyFailed)},"image/png")}}),[ae,y]);const Ee=i(()=>[{id:"select",label:P.toolSelect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:P.toolDraw,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:P.toolRect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:P.toolEllipse,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:P.toolArrow,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:P.toolMosaic,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:P.toolText,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:P.toolCrop,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[P]),We=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),Se=Me?.type??("select"===E?null:E),Be="rect"===Se||"circle"===Se||"arrow"===Se||"draw"===Se,Re="rect"===Se,je="text"===Se;/* @__PURE__ */
|
|
2
|
+
return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
|
|
3
|
+
/* @__PURE__ */s("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-[12px]",children:[Ee.map(e=>/* @__PURE__ */c("button",{onClick:()=>{W(e.id),ie(null)},title:e.label,className:We(E===e.id),children:e.icon},e.id)),
|
|
4
|
+
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
5
|
+
/* @__PURE__ */c("div",{className:"flex items-center gap-1",children:h.map(e=>/* @__PURE__ */c("button",{onClick:()=>(e=>{B(e),oe&&ne(t=>t.map(t=>t.id!==oe||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(S===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Be&&/* @__PURE__ */s(d,{children:[
|
|
6
|
+
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
7
|
+
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
8
|
+
/* @__PURE__ */c("span",{children:P.weight}),
|
|
9
|
+
/* @__PURE__ */c("input",{type:"range",min:1,max:20,step:1,value:R,onChange:e=>{return t=Number(e.target.value),j(t),void(oe&&ne(e=>e.map(e=>e.id!==oe?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
10
|
+
/* @__PURE__ */c("span",{className:"tabular-nums w-5 text-right",children:R})]})]}),Re&&/* @__PURE__ */s(d,{children:[
|
|
11
|
+
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
12
|
+
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
13
|
+
/* @__PURE__ */c("span",{children:P.radius}),
|
|
14
|
+
/* @__PURE__ */c("input",{type:"range",min:0,max:48,step:1,value:ee,onChange:e=>{return t=Number(e.target.value),te(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
15
|
+
/* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:ee})]})]}),je&&/* @__PURE__ */s(d,{children:[
|
|
16
|
+
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
17
|
+
/* @__PURE__ */c("select",{value:F,onChange:e=>{return t=e.target.value,U(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:u.map(e=>/* @__PURE__ */c("option",{value:e.id,children:P[e.name]},e.id))}),
|
|
18
|
+
/* @__PURE__ */c("button",{onClick:()=>ze("bold"),className:We(A),title:P.bold,children:/* @__PURE__ */c("span",{className:"font-bold",children:P.boldLetter})}),
|
|
19
|
+
/* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:We(K),title:P.italic,children:/* @__PURE__ */c("span",{className:"italic",children:P.italicLetter})}),
|
|
20
|
+
/* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:We(V),title:P.underline,children:/* @__PURE__ */c("span",{className:"underline",children:P.underlineLetter})}),
|
|
21
|
+
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
22
|
+
/* @__PURE__ */c("span",{children:P.size}),
|
|
23
|
+
/* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:H,onChange:e=>{return t=Number(e.target.value),T(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
24
|
+
/* @__PURE__ */c("span",{className:"tabular-nums w-7 text-right",children:H})]}),
|
|
25
|
+
/* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
|
|
26
|
+
/* @__PURE__ */c("span",{children:P.border}),X?/* @__PURE__ */s(d,{children:[
|
|
27
|
+
/* @__PURE__ */c("input",{type:"color",value:X,onChange:e=>De(e.target.value),title:P.borderColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
|
|
28
|
+
/* @__PURE__ */c("button",{onClick:()=>De(null),title:P.removeBorder,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>De(S),title:P.addBorder,className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:P.add})]}),
|
|
29
|
+
/* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
|
|
30
|
+
/* @__PURE__ */c("span",{children:P.fill}),J?/* @__PURE__ */s(d,{children:[
|
|
31
|
+
/* @__PURE__ */c("input",{type:"color",value:J,onChange:e=>Ie(e.target.value),title:P.fillColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
|
|
32
|
+
/* @__PURE__ */c("button",{onClick:()=>Ie(null),title:P.removeFill,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>Ie("#ffffff"),title:P.addFill,className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:P.add})]}),
|
|
33
|
+
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
34
|
+
/* @__PURE__ */c("span",{children:P.padding}),
|
|
35
|
+
/* @__PURE__ */c("input",{type:"range",min:0,max:40,step:1,value:_,onChange:e=>{return t=Number(e.target.value),Q(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
|
|
36
|
+
/* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),
|
|
37
|
+
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
38
|
+
/* @__PURE__ */c("button",{onClick:()=>he(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:P.zoomOut,children:"−"}),
|
|
39
|
+
/* @__PURE__ */s("span",{className:"text-gray-600 tabular-nums w-10 text-center",children:[Math.round(100*de),"%"]}),
|
|
40
|
+
/* @__PURE__ */c("button",{onClick:()=>he(e=>Math.min(4,Math.round(100*(e+.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:P.zoomIn,children:"+"}),
|
|
41
|
+
/* @__PURE__ */c("button",{onClick:()=>he(1),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:P.fitHint,children:P.fit}),
|
|
42
|
+
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
43
|
+
/* @__PURE__ */c("button",{onClick:()=>{ne(e=>e.slice(0,-1)),ie(null)},disabled:0===re.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children:P.undo}),
|
|
44
|
+
/* @__PURE__ */s("div",{className:"ml-auto flex items-center gap-2",children:[me&&/* @__PURE__ */s(d,{children:[
|
|
45
|
+
/* @__PURE__ */c("button",{onClick:()=>{if(!me||!I.current||!ae)return;const e=me,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ae.w,n.height=ae.h;const o=n.getContext("2d");o.drawImage(I.current,0,0);for(const e of Ne)C(o,e);r.drawImage(n,e.x,e.y,e.w,e.h,0,0,e.w,e.h);const i=new Image;i.onload=()=>{I.current=i,le({w:i.naturalWidth,h:i.naturalHeight}),ne(t=>t.filter(e=>"mosaic"!==e.type).map(t=>v(t,-e.x,-e.y)).filter(e=>function(e,t,r){const n=k(e);return n.x+n.w>0&&n.y+n.h>0&&n.x<t&&n.y<r}(e,i.naturalWidth,i.naturalHeight))),ge(null)},i.src=t.toDataURL("image/png")},className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600",children:P.applyCrop}),
|
|
46
|
+
/* @__PURE__ */c("button",{onClick:()=>ge(null),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",children:P.cancel})]}),m&&!me&&/* @__PURE__ */s(d,{children:[g&&/* @__PURE__ */c("button",{onClick:g,className:"px-3 py-1 rounded hover:bg-gray-200 text-gray-700 text-xs font-medium",children:P.cancel}),
|
|
47
|
+
/* @__PURE__ */c("button",{onClick:async()=>{const t=await $e();t?t.toBlob(t=>{t?m(t):e.error($.current.exportFailed)},"image/png"):e.error($.current.exportFailed)},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:P.apply})]})]})]}),
|
|
48
|
+
/* @__PURE__ */c("div",{ref:L,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:ve&&ae&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:ve.w,height:ve.h},children:[
|
|
49
|
+
/* @__PURE__ */c("canvas",{ref:z,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
|
|
50
|
+
/* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===E?"default":"text"===E?"text":"crosshair"},onPointerDown:e=>{if("select"===E)return void ie(null);if("text"===E){if(ye)return void Pe();const t=Ce(e);return void xe({x:t.x,y:t.y,value:""})}const t=Ce(e);if("crop"!==E){if("draw"===E)return Le({kind:"pen",points:[t]}),void pe({id:"",type:"draw",points:[t],color:S,stroke:R});pe(b(E,t,t,S,R,ee)),Le({kind:"draw",start:t})}else Le({kind:"crop",start:t})},children:[re.map(e=>/* @__PURE__ */c(x,{anno:e,selected:oe===e.id,zoom:de,onPointerDown:t=>((e,t)=>{"select"===E&&(e.stopPropagation(),ie(t.id),Le({kind:"move",id:t.id,start:Ce(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&xe({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Le({kind:"resize",id:t.id,corner:r,start:Ce(e),original:t})})(t,e,r)},e.id)),ue&&/* @__PURE__ */c(x,{anno:{...ue,id:"__preview"},preview:!0}),me&&/* @__PURE__ */c(w,{rect:me,imageSize:ae})]}),ye&&/* @__PURE__ */c(f,{pendingText:ye,color:S,size:H,font:u.find(e=>e.id===F)?.css??u[0].css,bold:A,italic:K,underline:V,borderColor:X,background:J,padding:_,scale:ke,onChange:e=>xe({...ye,value:e}),onCommit:Pe,onCancel:()=>xe(null)})]})}),
|
|
51
|
+
/* @__PURE__ */c("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===E?oe?P.hintSelected:P.hintSelect:"text"===E?P.hintText:"crop"===E?P.hintCrop:"draw"===E?P.hintDraw:P.hintShape})]})});function x({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const l=k(e),h=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("circle"===e.type)y=/* @__PURE__ */c("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...h});else if("arrow"===e.type)y=/* @__PURE__ */c(g,{anno:e,interactive:h});else if("draw"===e.type)y=/* @__PURE__ */c("path",{d:N(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("mosaic"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...h});else{const t=u.find(t=>t.id===e.font)?.css??u[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=k(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...h,...p,children:[n&&/* @__PURE__ */c("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
|
|
52
|
+
/* @__PURE__ */c("text",{x:e.x,y:e.y+e.size,fill:e.color,fontSize:e.size,fontWeight:e.bold?700:400,fontStyle:e.italic?"italic":"normal",textDecoration:e.underline?"underline":void 0,fontFamily:t,style:{userSelect:"none"},children:e.text.split("\n").map((t,r)=>/* @__PURE__ */c("tspan",{x:e.x,dy:0===r?0:1.2*e.size,children:t},r))})]})}/* @__PURE__ */
|
|
53
|
+
return s("g",{children:[y,t&&!r&&/* @__PURE__ */s(d,{children:[
|
|
54
|
+
/* @__PURE__ */c("rect",{"data-chrome":"selection",x:l.x-4,y:l.y-4,width:l.w+8,height:l.h+8,fill:"none",stroke:"#3b82f6",strokeWidth:2/n,strokeDasharray:`${6/n},${4/n}`,pointerEvents:"none"}),a&&/* @__PURE__ */c(m,{anno:e,zoom:n,onHandlePointerDown:a})]})]})}function m({anno:e,zoom:t,onHandlePointerDown:r}){const n=6/t,o=1.5/t,i=e=>({fill:"#fff",stroke:"#3b82f6",strokeWidth:o,pointerEvents:"all",style:{cursor:e},"data-chrome":"handle"});if("arrow"===e.type)/* @__PURE__ */
|
|
55
|
+
return s(d,{children:[
|
|
56
|
+
/* @__PURE__ */c("circle",{cx:e.x1,cy:e.y1,r:n,...i("grab"),onPointerDown:e=>r(e,"start")}),
|
|
57
|
+
/* @__PURE__ */c("circle",{cx:e.x2,cy:e.y2,r:n,...i("grab"),onPointerDown:e=>r(e,"end")})]});if("text"===e.type||"draw"===e.type)return null;const a=e.x,l=e.y,h=e.w,u=e.h;/* @__PURE__ */
|
|
58
|
+
return s(d,{children:[
|
|
59
|
+
/* @__PURE__ */c("circle",{cx:a,cy:l,r:n,...i("nwse-resize"),onPointerDown:e=>r(e,"nw")}),
|
|
60
|
+
/* @__PURE__ */c("circle",{cx:a+h,cy:l,r:n,...i("nesw-resize"),onPointerDown:e=>r(e,"ne")}),
|
|
61
|
+
/* @__PURE__ */c("circle",{cx:a+h,cy:l+u,r:n,...i("nwse-resize"),onPointerDown:e=>r(e,"se")}),
|
|
62
|
+
/* @__PURE__ */c("circle",{cx:a,cy:l+u,r:n,...i("nesw-resize"),onPointerDown:e=>r(e,"sw")})]})}function g({anno:e,interactive:t}){const r=Math.max(12,4*e.stroke),n=Math.atan2(e.y2-e.y1,e.x2-e.x1),o=n+Math.PI-Math.PI/7,i=n+Math.PI+Math.PI/7,a=`M${e.x2},${e.y2} L${e.x2+r*Math.cos(o)},${e.y2+r*Math.sin(o)} L${e.x2+r*Math.cos(i)},${e.y2+r*Math.sin(i)} Z`;/* @__PURE__ */
|
|
63
|
+
return s("g",{...t,children:[
|
|
64
|
+
/* @__PURE__ */c("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round"}),
|
|
65
|
+
/* @__PURE__ */c("path",{d:a,fill:e.color})]})}function w({rect:e,imageSize:t}){/* @__PURE__ */
|
|
66
|
+
return s("g",{pointerEvents:"none",children:[
|
|
67
|
+
/* @__PURE__ */c("path",{d:`M0,0 H${t.w} V${t.h} H0 Z M${e.x},${e.y} V${e.y+e.h} H${e.x+e.w} V${e.y} Z`,fill:"rgba(0,0,0,0.45)",fillRule:"evenodd"}),
|
|
68
|
+
/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"8,6"})]})}function f({pendingText:e,color:r,size:o,font:i,bold:l,italic:s,underline:d,borderColor:h,background:u,padding:p,scale:y,onChange:x,onCommit:m,onCancel:g}){const w=n(null),f=t().annotator;a(()=>{const e=requestAnimationFrame(()=>{w.current?.focus(),w.current?.select?.()});return()=>cancelAnimationFrame(e)},[]);const b=()=>m(w.current?.value),v=h?Math.max(1,Math.round(o/12)):0;/* @__PURE__ */
|
|
69
|
+
return c("div",{style:{position:"absolute",left:e.x*y+"px",top:e.y*y+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */c("textarea",{ref:w,value:e.value,onChange:e=>x(e.target.value),onBlur:b,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),g()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:f.textPlaceholder,rows:1,className:"outline-none resize-none shadow-md",style:{color:r,fontSize:o*y+"px",fontFamily:i,fontWeight:l?700:400,fontStyle:s?"italic":"normal",textDecoration:d?"underline":void 0,minWidth:80,padding:p*y+"px",borderRadius:Math.min(8,p)*y+"px",border:h?`${v*y}px solid ${h}`:"1px dashed #60a5fa",background:u??"rgba(255,255,255,0.95)"}})})}function b(e,t,r,n,o,i){if("rect"===e){const e=M(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=M(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=M(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function v(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function k(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function M(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function N(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function C(e,t){const r=Math.round(Math.max(0,t.x)),n=Math.round(Math.max(0,t.y)),o=Math.round(Math.min(e.canvas.width-r,t.w)),i=Math.round(Math.min(e.canvas.height-n,t.h));if(o<2||i<2)return;const a=e.getImageData(r,n,o,i);for(let e=0;e<i;e+=12)for(let t=0;t<o;t+=12){let r=0,n=0,l=0,c=0,s=0;const d=Math.min(12,o-t),h=Math.min(12,i-e);for(let i=0;i<h;i++)for(let h=0;h<d;h++){const d=4*((e+i)*o+(t+h));r+=a.data[d],n+=a.data[d+1],l+=a.data[d+2],c+=a.data[d+3],s++}r=Math.round(r/s),n=Math.round(n/s),l=Math.round(l/s),c=Math.round(c/s);for(let i=0;i<h;i++)for(let s=0;s<d;s++){const d=4*((e+i)*o+(t+s));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=c}}e.putImageData(a,r,n)}export{y as ImageAnnotator_default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Modal as e}from"./chunk-
|
|
1
|
+
import{Modal as e}from"./chunk-N6STBYXR.js";import{keepsNativeMenu as a}from"./chunk-AA4TMQOS.js";import{jsx as i,jsxs as n}from"react/jsx-runtime";var t={activeOpacity:70,inactiveOpacity:50,activeBlur:0,inactiveBlur:0};function r(e){try{const a=JSON.parse(localStorage.getItem(e)||"");return null!=a.blur&&null==a.activeBlur&&(a.activeBlur=a.blur,a.inactiveBlur=a.blur,delete a.blur),{...t,...a}}catch{return t}}function l({open:t,onClose:r,title:l,appearance:c,onAppearanceChange:s,onSave:d,children:o}){if(!t)return null;const u="w-full h-1.5 rounded-full appearance-none bg-gray-200 cursor-pointer accent-blue-500",p="flex items-center justify-between text-xs text-gray-500";/* @__PURE__ */
|
|
2
2
|
return i("div",{onPointerDown:e=>e.stopPropagation(),onContextMenu:e=>{e.stopPropagation(),a(e.target)||e.preventDefault()},children:/* @__PURE__ */i(e,{open:t,onClose:r,title:l,size:"sm",children:/* @__PURE__ */n("div",{className:"space-y-4",children:[o,
|
|
3
3
|
/* @__PURE__ */n("div",{children:[
|
|
4
4
|
/* @__PURE__ */i("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Appearance"}),
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{useBrowserLayoutEffect as t}from"./chunk-D65T4H6J.js";import{useShellStrings as n}from"./chunk-
|
|
2
|
-
return u("div",{...n,dangerouslySetInnerHTML:r})}function g({columns:e,data:g,onChange:m,onColumnsChange:f,fixedRows:p=!1,minRows:y=15,maxHeight:b="260px",cellStyles:v,onFocusChange:x,onSelectionChange:M}){const D=r(null),k=n().grid,[C,E]=o(null);l(()=>{x?.(C)},[C,x]);const[L,S]=o({}),$=r(null),[N,A]=o({}),z=r(null),[T
|
|
1
|
+
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{useBrowserLayoutEffect as t}from"./chunk-D65T4H6J.js";import{useShellStrings as n}from"./chunk-J3LIIIHJ.js";import{useRef as r,useState as o,useEffect as l,useCallback as c,useMemo as a}from"react";import{createPortal as s}from"react-dom";import{jsxs as i,jsx as u,Fragment as d}from"react/jsx-runtime";function h(e,t){const n=e[e.length-1];return n&&!n.some(e=>e.trim())?e:[...e,Array(t).fill("")]}function w({text:t,...n}){const r=a(()=>({__html:e(t)}),[t]);/* @__PURE__ */
|
|
2
|
+
return u("div",{...n,dangerouslySetInnerHTML:r})}function g({columns:e,data:g,onChange:m,onColumnsChange:f,fixedRows:p=!1,minRows:y=15,maxHeight:b="260px",cellStyles:v,onFocusChange:x,onSelectionChange:M}){const D=r(null),k=n().grid,[C,E]=o(null);l(()=>{x?.(C)},[C,x]);const[L,S]=o({}),$=r(null),[N,A]=o({}),z=r(null),[O,T]=o(null),[R,K]=o(null),[I,P]=o(null),[F,H]=o(null),[X,Y]=o(null),j=r(null);t(()=>{const e=j.current;if(!e||e.row!==X?.row||e.col!==X?.col)return;j.current=null;const t=D.current?.querySelector(`[data-row="${e.row}"][data-col="${e.col}"]`);if(!t)return;t.focus();const n=document.createRange();n.selectNodeContents(t),n.collapse(!1);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(n)},[X]);const[q,B]=o(null),[W,J]=o(null);l(()=>{M?.(q&&W?{anchor:q,end:W}:null)},[q,W,M]);const _=r(!1),[U,V]=o(null),G=r(!1),Q=r({a:null,e:null});Q.current={a:q,e:W};const Z=q&&W&&(q.row!==W.row||q.col!==W.col),ee=[...g];if(!p)for(;ee.length<y;)ee.push(Array(e.length).fill(""));const te=c((t,n,r)=>{const o=ee.map(e=>[...e]);for(;o.length<=t;)o.push(Array(e.length).fill(""));for(;o[t].length<e.length;)o[t].push("");o[t][n]=r,m(o)},[ee,e.length,m]),ne=c((e,t,n)=>{if(0!==e.button)return;const r=document.activeElement;if(r?.dataset?.row&&r?.dataset?.col){const e=parseInt(r.dataset.row),t=parseInt(r.dataset.col),n=r.textContent||"";if(n!==(ee[e]?.[t]||"")){const r=ee.map(e=>[...e]);r[e]&&(r[e][t]=n,m(r))}}_.current=!0,e.shiftKey&&q||B({row:t,col:n}),J({row:t,col:n})},[ee,m,q]),re=c((e,t)=>{_.current&&J({row:e,col:t})},[]);l(()=>{const e=()=>{_.current=!1};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{if(!e.ctrlKey&&!e.metaKey||"c"!==e.key)return;if(!q||!W)return;const t=window.getSelection();if(t&&t.toString().length>0&&!Z)return;const n=Math.min(q.row,W.row),r=Math.max(q.row,W.row),o=Math.min(q.col,W.col),l=Math.max(q.col,W.col),c=[];for(let e=n;e<=r;e++){const t=[];for(let n=o;n<=l;n++)t.push(ee[e]?.[n]||"");c.push(t.join("\t"))}const a=c.join("\n");a&&(e.preventDefault(),navigator.clipboard.writeText(a))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[q,W,ee,Z]),l(()=>{const t=t=>{if(!C)return;const n=document.activeElement;if(n?.isContentEditable)return;if(!D.current?.contains(n))return;const r=t.clipboardData?.getData("text/plain");if(!r)return;t.preventDefault();const o=r.split("\n").filter(e=>e).map(e=>e.split("\t")),l=ee.map(e=>[...e]);for(let t=0;t<o.length;t++){const n=C.row+t;for(;l.length<=n;)l.push(Array(e.length).fill(""));for(;l[n].length<e.length;)l[n].push("");for(let r=0;r<o[t].length;r++){const c=C.col+r;if(c>=e.length)break;e[c].readOnly||(l[n][c]=o[t][r].trim())}}m(p?l:h(l,e.length)),B({row:C.row,col:C.col}),J({row:Math.min(C.row+o.length-1,l.length-1),col:Math.min(C.col+(o[0]?.length||1)-1,e.length-1)})};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)},[C,ee,e,m,p]);const oe=c((t,n,r)=>{const o=t.clipboardData.getData("text/plain");if(!o)return;const l=o.split("\n").map(e=>e.split("\t"));if(l.length<=1&&l[0]?.length<=1)return;t.preventDefault();const c=ee.map(e=>[...e]);for(let t=0;t<l.length;t++){const o=n+t;for(;c.length<=o;)c.push(Array(e.length).fill(""));for(;c[o].length<e.length;)c[o].push("");for(let n=0;n<l[t].length;n++){const a=r+n;if(a>=e.length)break;e[a].readOnly||(c[o][a]=l[t][n].trim())}}m(p?c:h(c,e.length))},[ee,e,m,p]),le=c((t,n,r)=>{let o=n,l=r;if("Tab"===t.key)t.preventDefault(),l=t.shiftKey?r-1:r+1,l>=e.length&&(l=0,o=n+1),l<0&&(l=e.length-1,o=n-1);else if("Enter"===t.key)t.preventDefault(),o=t.shiftKey?n-1:n+1;else if("ArrowDown"===t.key)t.preventDefault(),o=n+1;else if("ArrowUp"===t.key)t.preventDefault(),o=n-1;else if("ArrowLeft"===t.key)t.preventDefault(),l=r-1;else{if("ArrowRight"!==t.key){if("Delete"===t.key||"Backspace"===t.key){const o=t.target;if(o.isContentEditable)return void(o.textContent&&window.getSelection()?.toString()===o.textContent&&(t.preventDefault(),te(n,r,"")));if(t.preventDefault(),q&&W){const t=Math.min(q.row,W.row),n=Math.max(q.row,W.row),r=Math.min(q.col,W.col),o=Math.max(q.col,W.col),l=ee.map(e=>[...e]);for(let c=t;c<=n;c++)for(let t=r;t<=o;t++)l[c]&&!e[t]?.readOnly&&(l[c][t]="");m(l)}else te(n,r,"");return}return}t.preventDefault(),l=r+1}for(;l>=0&&l<e.length&&e[l].readOnly;)l+="Tab"===t.key&&t.shiftKey?-1:1;if(o>=0&&o<ee.length&&l>=0&&l<e.length){const e=D.current?.querySelector(`[data-row="${o}"][data-col="${l}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}),E({row:o,col:l}),Y(null),B({row:o,col:l}),J({row:o,col:l}))}},[e,ee,ee.length,te,q,W,m]),ce=c(t=>{if(!p&&t>=ee.length-2){const t=ee.map(e=>[...e]);for(let n=0;n<5;n++)t.push(Array(e.length).fill(""));m(t)}},[p,ee,e.length,m]),[ae,se]=o(null);l(()=>{if(!ae)return;const e=()=>se(null);return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[ae]);const ie=c(t=>{const n=ee.map(e=>[...e]);n.splice(t,0,Array(e.length).fill("")),m(n)},[ee,e.length,m]),ue=c(e=>{if(ee.length<=1)return;const t=ee.filter((t,n)=>n!==e);m(t)},[ee,m]),de=c(e=>{const t=ee.map(t=>{const n=[...t];return n.splice(e,0,""),n});m(t)},[ee,m]),he=c(t=>{if(e.length<=1)return;const n=ee.map(e=>{const n=[...e];return n.splice(t,1),n});m(n)},[ee,e.length,m]),we=c((e,t)=>{e.preventDefault(),p||se({x:e.clientX,y:e.clientY,items:[{label:k.insertRowAbove,onClick:()=>{ie(t),se(null)}},{label:k.insertRowBelow,onClick:()=>{ie(t+1),se(null)}},{label:k.deleteRow(t+1),onClick:()=>{ue(t),se(null)}}]})},[p,ie,ue,k]),ge=c((t,n)=>{t.preventDefault(),p||se({x:t.clientX,y:t.clientY,items:[{label:k.insertColumnLeft,onClick:()=>{de(n),se(null)}},{label:k.insertColumnRight,onClick:()=>{de(n+1),se(null)}},{label:k.deleteColumn(String(e[n]?.title||n+1)),onClick:()=>{he(n),se(null)}}]})},[p,e,de,he,k]),me=t=>L[t]??e[t]?.width??150;l(()=>{const t=e=>{if(!$.current)return;const t=e.clientX-$.current.startX,n=Math.max(40,$.current.startW+t);S(e=>({...e,[$.current.col]:n}))},n=()=>{if($.current&&f){const t=e.map((e,t)=>({...e,width:L[t]??e.width}));t[$.current.col]={...t[$.current.col],width:L[$.current.col]??e[$.current.col].width},f(t)}$.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)}},[e,L,f]);const fe=e=>N[e]??28;l(()=>{const e=e=>{if(!z.current)return;const t=e.clientY-z.current.startY,n=Math.max(20,z.current.startH+t);A(e=>({...e,[z.current.row]:n}))},t=()=>{z.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[]);const pe=c(t=>{const n=document.createElement("canvas").getContext("2d");if(!n)return;n.font="12px ui-monospace, SFMono-Regular, Menlo, monospace";let r=0;for(const e of ee){const o=String(e[t]??"").replace(/<[^>]*>/g,""),l=n.measureText(o).width;l>r&&(r=l)}const o=n.measureText(e[t]?.title??"").width;o>r&&(r=o);const l=Math.max(40,Math.ceil(r+24));if(S(e=>({...e,[t]:l})),f){const n=e.map((e,n)=>({...e,width:n===t?l:L[n]??e.width}));f(n)}},[ee,e,L,f]),ye=c(e=>{A(t=>{const n={...t};return delete n[e],n})},[]),be=c(t=>{const{a:n,e:r}=Q.current;if(!n||!r)return;const o=Math.min(n.row,r.row),l=Math.max(n.row,r.row),c=Math.min(n.col,r.col),a=Math.max(n.col,r.col);let s=o,i=l,u=c,d=a;t.row>l?i=t.row:t.row<o&&(s=t.row),t.col>a?d=t.col:t.col<c&&(u=t.col);const h=l-o+1,w=a-c+1,g=ee.map(e=>[...e]);for(;g.length<=i;)g.push(Array(e.length).fill(""));for(const e of g)for(;e.length<=d;)e.push("");function f(e){const t=e.map(e=>parseFloat(e));if(t.length<2||t.some(e=>Number.isNaN(e)))return null;const n=t[1]-t[0];for(let e=2;e<t.length;e++)if(Math.abs(t[e]-t[e-1]-n)>1e-9)return null;return{step:n}}for(let e=s;e<=i;e++)for(let t=u;t<=d;t++){if(e>=o&&e<=l&&t>=c&&t<=a)continue;let n;if(1===w&&u===c&&d===a){const r=f(Array.from({length:h},(e,n)=>g[o+n]?.[t]??""));if(r){const c=parseFloat(g[l]?.[t]??"0"),a=parseFloat(g[o]?.[t]??"0"),s=e>l?e-l:-(o-e);n=String((e>l?c:a)+r.step*s)}else{const r=((e-o)%h+h)%h;n=g[o+r]?.[t]??""}}else if(1===h&&s===o&&i===l){const r=f(Array.from({length:w},(t,n)=>g[e]?.[c+n]??""));if(r){const o=parseFloat(g[e]?.[a]??"0"),l=parseFloat(g[e]?.[c]??"0"),s=t>a?t-a:-(c-t);n=String((t>a?o:l)+r.step*s)}else{const r=((t-c)%w+w)%w;n=g[e]?.[c+r]??""}}else{const r=((e-o)%h+h)%h,l=((t-c)%w+w)%w;n=g[o+r]?.[c+l]??""}g[e][t]=n}m(g),B({row:s,col:u}),J({row:i,col:d})},[ee,e.length,m]);l(()=>{const e=e=>{if(!G.current)return;const t=document.elementFromPoint(e.clientX,e.clientY),n=t?.closest?.("[data-row][data-col]");if(!n)return;const r=parseInt(n.dataset.row),o=parseInt(n.dataset.col);V({row:r,col:o})},t=()=>{G.current&&U&&be(U),G.current=!1,V(null),document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[U,be]);const ve=e=>{e.preventDefault(),e.stopPropagation(),G.current=!0,document.body.style.cursor="crosshair"},xe=r(null),[Me,De]=o(0),[ke,Ce]=o(800);l(()=>{const e=xe.current;if(!e)return;const t=()=>Ce(e.clientHeight||800);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const Ee=ee.length>100,Le=Ee?Math.max(0,Math.floor(Me/28)-20):0,Se=Ee?Math.min(ee.length,Math.ceil((Me+ke)/28)+20):ee.length,$e=a(()=>ee.slice(Le,Se),[ee,Le,Se]),Ne=28*Le,Ae=28*(ee.length-Se),ze="px-2 py-1.5 text-left text-xs font-medium text-gray-500 uppercase bg-gray-100 border-b border-r border-gray-200 select-none";/* @__PURE__ */
|
|
3
3
|
return i("div",{ref:xe,className:"border border-gray-300 rounded overflow-scroll grid-scroll",style:{maxHeight:b,height:b},onScroll:e=>De(e.target.scrollTop),children:[
|
|
4
4
|
/* @__PURE__ */i("table",{ref:D,className:"border-collapse select-none",style:{tableLayout:"fixed",minWidth:36+e.reduce((t,n)=>t+me(e.indexOf(n)),0)},children:[
|
|
5
5
|
/* @__PURE__ */i("colgroup",{children:[
|
|
6
6
|
/* @__PURE__ */u("col",{style:{width:36}}),e.map((e,t)=>/* @__PURE__ */u("col",{style:{width:me(t)}},e.key))]}),
|
|
7
7
|
/* @__PURE__ */u("thead",{className:"sticky top-0 z-10",children:/* @__PURE__ */i("tr",{children:[
|
|
8
|
-
/* @__PURE__ */u("th",{className:ze+" text-center w-9 cursor-pointer hover:bg-gray-200",onClick:()=>{B({row:0,col:0}),
|
|
9
|
-
return i("th",{className:`${ze} cursor-pointer hover:bg-gray-200 relative${r?" !bg-blue-200":""}${
|
|
8
|
+
/* @__PURE__ */u("th",{className:ze+" text-center w-9 cursor-pointer hover:bg-gray-200",onClick:()=>{B({row:0,col:0}),J({row:ee.length-1,col:e.length-1})},title:k.selectAll,children:"#"}),e.map((t,n)=>{const r=q&&W&&Math.min(q.col,W.col)<=n&&n<=Math.max(q.col,W.col)&&0===Math.min(q.row,W.row)&&Math.max(q.row,W.row)===ee.length-1;/* @__PURE__ */
|
|
9
|
+
return i("th",{className:`${ze} cursor-pointer hover:bg-gray-200 relative${r?" !bg-blue-200":""}${F===n?" !bg-blue-100":""}`,style:{width:me(n)},draggable:!0,onDragStart:()=>(e=>P(e))(n),onDragOver:e=>((e,t)=>{e.preventDefault(),H(t)})(e,n),onDrop:()=>(t=>{if(null===I||I===t)return P(null),void H(null);const n=ee.map(e=>{const n=[...e],[r]=n.splice(I,1);return n.splice(t,0,r),n});if(m(n),f){const n=[...e],[r]=n.splice(I,1);n.splice(t,0,r),f(n)}P(null),H(null)})(n),onDragEnd:()=>{P(null),H(null)},onClick:e=>{e.shiftKey&&q||B({row:0,col:n}),J({row:ee.length-1,col:n})},onContextMenu:e=>ge(e,n),children:[t.title,
|
|
10
10
|
/* @__PURE__ */u("div",{className:"absolute -right-1 top-0 bottom-0 w-2 cursor-col-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),$.current={col:t,startX:e.clientX,startW:me(t)},document.body.style.cursor="col-resize"})(e,n),onDoubleClick:e=>{e.stopPropagation(),pe(n)},title:k.resize})]},t.key)})]})}),
|
|
11
11
|
/* @__PURE__ */i("tbody",{children:[Ne>0&&/* @__PURE__ */u("tr",{style:{height:Ne}}),$e.map((t,n)=>{const r=Le+n,o=q&&W&&Math.min(q.row,W.row)<=r&&r<=Math.max(q.row,W.row)&&0===Math.min(q.col,W.col)&&Math.max(q.col,W.col)===e.length-1;/* @__PURE__ */
|
|
12
12
|
return i("tr",{style:{height:fe(r)},children:[
|
|
13
|
-
/* @__PURE__ */i("td",{className:`relative px-1 py-1 text-center text-[10px] text-gray-400 border-b border-r border-gray-200 bg-gray-50 select-none cursor-pointer hover:bg-gray-200${o?" !bg-blue-200 !text-gray-700":""}${R===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>
|
|
13
|
+
/* @__PURE__ */i("td",{className:`relative px-1 py-1 text-center text-[10px] text-gray-400 border-b border-r border-gray-200 bg-gray-50 select-none cursor-pointer hover:bg-gray-200${o?" !bg-blue-200 !text-gray-700":""}${R===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>T(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),K(t)})(e,r),onDrop:()=>(e=>{if(null===O||O===e)return T(null),void K(null);const t=ee.map(e=>[...e]),[n]=t.splice(O,1);t.splice(e,0,n),m(t),T(null),K(null)})(r),onDragEnd:()=>{T(null),K(null)},onClick:t=>{t.shiftKey&&q||B({row:r,col:0}),J({row:r,col:e.length-1})},onContextMenu:e=>we(e,r),children:[r+1,
|
|
14
14
|
/* @__PURE__ */u("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),z.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),ye(r)},title:k.resize})]}),e.map((e,n)=>{const o=q&&W&&function(e,t,n,r){const o=Math.min(e.row,t.row),l=Math.max(e.row,t.row),c=Math.min(e.col,t.col),a=Math.max(e.col,t.col);return n>=o&&n<=l&&r>=c&&r<=a}(q,W,r,n),l=X?.row===r&&X?.col===n&&!e.readOnly,c=C?.row===r&&C?.col===n,a=v?.[`${r}:${n}`],s=q&&W?Math.max(q.row,W.row):-1,d=q&&W?Math.max(q.col,W.col):-1,h=q&&W&&r===s&&n===d,g=G.current&&U&&q&&W&&(()=>{const e=Math.min(q.row,W.row),t=Math.max(q.row,W.row),o=Math.min(q.col,W.col),l=Math.max(q.col,W.col);let c=e,a=t,s=o,i=l;return U.row>t?a=U.row:U.row<e&&(c=U.row),U.col>l?i=U.col:U.col<o&&(s=U.col),r>=c&&r<=a&&n>=s&&n<=i&&!(r>=e&&r<=t&&n>=o&&n<=l)})(),m="sm"===a?.fontSize?"text-[11px]":"lg"===a?.fontSize?"text-sm":"xl"===a?.fontSize?"text-base":"text-xs",f=`${a?.bold?" font-bold":""}${a?.italic?" italic":""}${a?.underline?" underline":""}`;/* @__PURE__ */
|
|
15
15
|
return i("td",{className:`relative px-0 py-0 border-b border-r border-gray-200 text-sm${e.readOnly?" bg-gray-50 text-gray-500 cursor-default":" cursor-cell"}${o?" !bg-blue-100":""}${c&&!o?" ring-2 ring-inset ring-blue-400":""}${g?" !bg-blue-50 ring-1 ring-inset ring-blue-300":""}`,onMouseDown:e=>{if(e.target===e.currentTarget){ne(e,r,n);const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onMouseEnter:()=>re(r,n),onClick:e=>{if(e.target===e.currentTarget){const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onDoubleClick:t=>{t.target!==t.currentTarget||e.readOnly||Y({row:r,col:n})},children:[
|
|
16
|
-
/* @__PURE__ */u(w,{contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,"data-row":r,"data-col":n,className:`w-full h-full px-2 py-1 rosh-focus-ring whitespace-nowrap overflow-hidden ${"right"===e.align?"text-right":"center"===e.align?"text-center":""} ${e.readOnly?"cursor-default":"cursor-cell"} font-mono ${m}${f}`,onMouseDown:e=>ne(e,r,n),onMouseEnter:()=>re(r,n),onDoubleClick:()=>{e.readOnly||Y({row:r,col:n})},onFocus:()=>{E({row:r,col:n}),
|
|
16
|
+
/* @__PURE__ */u(w,{contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,"data-row":r,"data-col":n,className:`w-full h-full px-2 py-1 rosh-focus-ring whitespace-nowrap overflow-hidden ${"right"===e.align?"text-right":"center"===e.align?"text-center":""} ${e.readOnly?"cursor-default":"cursor-cell"} font-mono ${m}${f}`,onMouseDown:e=>ne(e,r,n),onMouseEnter:()=>re(r,n),onDoubleClick:()=>{e.readOnly||Y({row:r,col:n})},onFocus:()=>{E({row:r,col:n}),_.current||(B({row:r,col:n}),J({row:r,col:n}))},onBlur:e=>{const o=e.currentTarget.textContent||"";o!==(t[n]||"")&&te(r,n,o),Y(null)},onInput:()=>ce(r),onPaste:e=>oe(e,r,n),onKeyDown:t=>{if(!(l||e.readOnly||1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey))return t.preventDefault(),te(r,n,t.key),j.current={row:r,col:n},void Y({row:r,col:n});le(t,r,n)},text:t[n]||""}),h&&/* @__PURE__ */u("div",{onMouseDown:ve,title:k.fill,className:"absolute -bottom-[3px] -right-[3px] w-[7px] h-[7px] bg-blue-500 border border-white cursor-crosshair z-30 hover:bg-blue-600"})]},n)})]},r)}),Ae>0&&/* @__PURE__ */u("tr",{style:{height:Ae}})]})]}),ae&&s(
|
|
17
17
|
/* @__PURE__ */i(d,{children:[
|
|
18
18
|
/* @__PURE__ */u("div",{className:"fixed inset-0 z-[200]",onPointerDown:()=>se(null)}),
|
|
19
19
|
/* @__PURE__ */u("div",{className:"fixed z-[201] bg-white rounded-lg shadow-lg border border-gray-200 py-1 min-w-[160px]",style:{left:ae.x,top:ae.y},children:ae.items.map((e,t)=>/* @__PURE__ */u("button",{onPointerDown:t=>{t.stopPropagation(),e.onClick()},className:"w-full text-left px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100",children:e.label},t))})]}),document.body)]})}export{g as EditableGrid,h as withSpareRow};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{useCopyText as e,CopyGlyph as t}from"./chunk-
|
|
1
|
+
import{useCopyText as e,CopyGlyph as t}from"./chunk-KVOFUFPP.js";import{PopupMenu as r,PopupMenuItem as n,PopupMenuDivider as l}from"./chunk-AA4TMQOS.js";import{useShellStrings as i}from"./chunk-J3LIIIHJ.js";import{useState as a,useEffect as o,Fragment as s}from"react";import{jsxs as c,jsx as d,Fragment as m}from"react/jsx-runtime";var u="outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-500";function p(){/* @__PURE__ */
|
|
2
2
|
return d("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",className:"size-3.5",children:/* @__PURE__ */d("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})}function y({text:r,label:n,copiedLabel:l}){const{copied:i,copy:a}=e(r);/* @__PURE__ */
|
|
3
|
-
return d("button",{type:"button",tabIndex:-1,"aria-label":i?l:n,title:i?l:n,onClick:a,className:"flex size-5 shrink-0 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 @max-[10rem]:hidden",children:/* @__PURE__ */d(t,{copied:i,className:"size-3.5"})})}function h({tabs:e,activeKey:t,idFor:h,panelMounted:b,onActivate:f,onClose:g,onCloseMany:x,label:k,className:v,activeClassName:w,end:N,onIconMenu:C,menuItems
|
|
3
|
+
return d("button",{type:"button",tabIndex:-1,"aria-label":i?l:n,title:i?l:n,onClick:a,className:"flex size-5 shrink-0 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 @max-[10rem]:hidden",children:/* @__PURE__ */d(t,{copied:i,className:"size-3.5"})})}function h({tabs:e,activeKey:t,idFor:h,panelMounted:b,onActivate:f,onClose:g,onCloseMany:x,label:k,className:v,activeClassName:w,end:N,onIconMenu:C,menuItems:I}){const $=i().pageTabs,[j,z]=a(null),M=e.length;o(()=>{if(!t)return;const e=document.getElementById(h(t,"tab"));e?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[h,t,M]);const L=e.some(e=>e.key===t)?t:e[0]?.key,A=t=>{const r=e[(t+e.length)%e.length];r&&document.getElementById(h(r.key,"tab"))?.focus()},D=j?e.find(e=>e.key===j.key):void 0,_=D&&I?I(D.key):[],B=D?e.indexOf(D):-1,E=e=>e.some(e=>!e.pinned),F=e=>()=>{z(null),e()};/* @__PURE__ */
|
|
4
4
|
return c("div",{className:v??"relative flex h-10 shrink-0 items-end gap-3 bg-gray-100 px-3",children:[
|
|
5
5
|
/* @__PURE__ */d("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 h-px bg-gray-200"}),
|
|
6
|
-
/* @__PURE__ */d("div",{role:"tablist","aria-label":k,onKeyDown:t=>{const r=e.findIndex(e=>document.getElementById(h(e.key,"tab"))===t.target);if(!(r<0)){if("ArrowRight"===t.key)
|
|
6
|
+
/* @__PURE__ */d("div",{role:"tablist","aria-label":k,onKeyDown:t=>{const r=e.findIndex(e=>document.getElementById(h(e.key,"tab"))===t.target);if(!(r<0)){if("ArrowRight"===t.key)A(r+1);else if("ArrowLeft"===t.key)A(r-1);else if("Home"===t.key)A(0);else if("End"===t.key)A(e.length-1);else{if("Delete"!==t.key||e[r].pinned)return;g(e[r].key)}t.preventDefault()}},className:"flex min-w-0 flex-1 items-end overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map((r,n)=>{const l=r.key===t,i=!!r.dirty,a=r.icon,o=l?w??"z-[1] border-gray-200 bg-gray-50 text-gray-900":"border-transparent text-gray-600 hover:bg-gray-200/70 hover:text-gray-900",m=n>0&&!l&&e[n-1].key!==t,x={type:"button",role:"tab",id:h(r.key,"tab"),"aria-selected":l,"aria-controls":b?.(r.key)?h(r.key,"panel"):void 0,tabIndex:r.key===L?0:-1,title:r.title,onClick:()=>f(r.key)},k={onContextMenu:e=>((e,t)=>{e.preventDefault(),z({x:e.clientX,y:e.clientY,key:t.key})})(e,r),onAuxClick:e=>((e,t)=>{1!==e.button||t.pinned||(e.preventDefault(),g(t.key))})(e,r),onMouseDown:e=>{1===e.button&&e.preventDefault()}},v=a&&
|
|
7
7
|
/* @__PURE__ */c("span",{className:"relative flex size-4 shrink-0 items-center justify-center text-gray-500 [&>svg]:size-4","aria-hidden":"true",children:[a,i&&!l&&!r.pinned&&
|
|
8
8
|
/* @__PURE__ */d("span",{className:"absolute -right-1 -top-1 hidden size-2 rounded-full bg-gray-500 ring-2 ring-gray-100 @max-[6.5rem]:block @max-[6.5rem]:group-hover:hidden"})]}),N=l&&!!C&&!!a;return r.pinned?/* @__PURE__ */d("div",{role:"presentation",className:`group relative flex h-9 flex-none items-center justify-center rounded-t-md border border-b-0 transition-colors ${a?"w-10":""} ${o}`,...k,children:/* @__PURE__ */c("button",{...x,className:`flex h-full items-center justify-center rounded-t-md ${a?"w-full":"px-3"} ${u}`,children:[v,
|
|
9
9
|
/* @__PURE__ */d("span",{className:a?"sr-only":"whitespace-nowrap text-[13px]",children:r.title})]})},r.key):/* @__PURE__ */c(s,{children:[m&&/* @__PURE__ */d("span",{"aria-hidden":"true",className:"mb-2.5 h-4 w-px shrink-0 self-end border-l border-gray-300"}),
|
|
10
10
|
/* @__PURE__ */c("div",{role:"presentation",className:`group @container relative flex h-9 items-center rounded-t-md border border-b-0 text-[13px] transition-colors ${l&&(r.copy||N)?"flex-[0_1_20rem]":"flex-[0_1_15rem]"} ${l?"min-w-[4.25rem]":"min-w-[2.75rem]"} ${o}`,...k,children:[N&&
|
|
11
|
-
/* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-label"
|
|
11
|
+
/* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-label":$.tabMenu,title:$.tabMenu,onClick:e=>{const t=e.currentTarget.getBoundingClientRect();C?.(r.key,t.left,t.bottom+4)},className:`ml-2 flex size-6 shrink-0 items-center justify-center rounded hover:bg-gray-200 @max-[5rem]:ml-1.5 ${u}`,children:v}),
|
|
12
12
|
/* @__PURE__ */c("button",{...x,className:`flex h-full min-w-0 flex-1 items-center gap-2 rounded-t-md pr-1 text-left ${N?"pl-1.5":"pl-3"} ${u} ${l?N?"":"@max-[5rem]:pl-2.5":"@max-[6.5rem]:pr-3 @max-[6.5rem]:group-hover:pr-1 @max-[4.5rem]:justify-center @max-[4.5rem]:px-0 @max-[4.5rem]:group-hover:pl-1.5"}`,children:[!N&&v,
|
|
13
|
-
/* @__PURE__ */d("span",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,#000_calc(100%-1rem),transparent)] "+(a?l?"@max-[5rem]:sr-only":"@max-[4.5rem]:sr-only":""),children:r.title})]}),l&&r.copy&&/* @__PURE__ */d(y,{text:r.copy,label
|
|
14
|
-
/* @__PURE__ */c("span",{className:"mr-1.5 flex size-5 shrink-0 items-center justify-center "+(l?"":"@max-[6.5rem]:hidden @max-[6.5rem]:group-hover:flex"),children:[i&&/* @__PURE__ */d("span",{role:"img","aria-label"
|
|
15
|
-
/* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-label"
|
|
13
|
+
/* @__PURE__ */d("span",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,#000_calc(100%-1rem),transparent)] "+(a?l?"@max-[5rem]:sr-only":"@max-[4.5rem]:sr-only":""),children:r.title})]}),l&&r.copy&&/* @__PURE__ */d(y,{text:r.copy,label:$.copy(r.copy),copiedLabel:$.copied}),
|
|
14
|
+
/* @__PURE__ */c("span",{className:"mr-1.5 flex size-5 shrink-0 items-center justify-center "+(l?"":"@max-[6.5rem]:hidden @max-[6.5rem]:group-hover:flex"),children:[i&&/* @__PURE__ */d("span",{role:"img","aria-label":$.unsaved,className:"size-2 rounded-full bg-gray-500 group-hover:hidden"}),
|
|
15
|
+
/* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-label":$.closeTab?.(r.title)??`${$.close} ${r.title}`,onClick:()=>g(r.key),className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(i?"hidden group-hover:flex":l?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */d(p,{})})]})]})]},r.key)})}),N&&/* @__PURE__ */d("div",{className:"flex shrink-0 items-center gap-2 self-center",children:N}),j&&D&&/* @__PURE__ */c(r,{portal:!0,style:{left:j.x,top:j.y},onClose:()=>z(null),children:[_.length>0&&/* @__PURE__ */c(m,{children:[_.map((e,t)=>/* @__PURE__ */c(n,{onClick:F(e.onSelect),children:[e.icon,e.label]},t)),
|
|
16
16
|
/* @__PURE__ */d(l,{})]}),
|
|
17
|
-
/* @__PURE__ */d(n,{disabled:
|
|
17
|
+
/* @__PURE__ */d(n,{disabled:D.pinned,onClick:F(()=>g(D.key)),children:$.close}),
|
|
18
18
|
/* @__PURE__ */d(l,{}),
|
|
19
|
-
/* @__PURE__ */d(n,{disabled:!
|
|
20
|
-
/* @__PURE__ */d(n,{disabled:!
|
|
21
|
-
/* @__PURE__ */d(n,{disabled:!
|
|
19
|
+
/* @__PURE__ */d(n,{disabled:!E(e.filter(e=>e.key!==D.key)),onClick:F(()=>x("others",D.key)),children:$.closeOthers}),
|
|
20
|
+
/* @__PURE__ */d(n,{disabled:!E(e.slice(B+1)),onClick:F(()=>x("right",D.key)),children:$.closeRight}),
|
|
21
|
+
/* @__PURE__ */d(n,{disabled:!E(e),onClick:F(()=>x("all",null)),children:$.closeAll})]})]})}export{h as TabStrip};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_SHELL_STRINGS as e,useShellStrings as t}from"./chunk-
|
|
1
|
+
import{DEFAULT_SHELL_STRINGS as e,useShellStrings as t}from"./chunk-J3LIIIHJ.js";import{useRef as r,useState as n,useCallback as s}from"react";import{jsx as a}from"react/jsx-runtime";function o(e,t){const r=(t??"").split(",").map(e=>e.trim().toLocaleLowerCase()).filter(Boolean);if(0===r.length||r.includes("*")||r.includes("*/*"))return!0;const n=e.name.toLocaleLowerCase(),s=e.type.toLocaleLowerCase();return r.some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?s.startsWith(e.slice(0,-1)):s===e)}var l=(t,r=e.files)=>t<1024?r.bytes(t):t<1048576?r.kilobytes(Math.round(t/1024)):r.megabytes(t/1048576),i=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function c({onAccept:e,accept:a,maxSizeBytes:c,maxFiles:u,multiple:f=!0,currentCount:p=0,acceptHint:m,disabled:d=!1}){const h=t().files,g=r(null),[y,x]=n(!1),[v,D]=n([]),L=r(0),b="string"==typeof m?m:"",A=s(t=>{if(d||!t)return;const r=Array.from(t);if(0===r.length)return;const n=[],s=[];for(const e of f?r:r.slice(0,1))o(e,a)?null!=c&&e.size>c?s.push({file:e,reason:"size",message:h.tooLarge(e.name,l(e.size,h),l(c,h))}):f&&null!=u&&p+n.length>=u?s.push({file:e,reason:"count",message:h.tooMany(e.name,u)}):n.push(e):s.push({file:e,reason:"type",message:h.notAccepted(e.name,b)});D(s),n.length&&e(n),g.current&&(g.current.value="")},[d,f,a,b,c,u,p,e,h]),j=s(()=>{d||g.current?.click()},[d]),k=s(()=>D([]),[]);return{inputRef:g,inputProps:{ref:g,type:"file",accept:a||void 0,multiple:f,disabled:d,tabIndex:-1,"aria-hidden":!0,className:"hidden",onChange:e=>A(e.target.files)},zoneProps:d?{}:{onDragEnter:e=>{i(e)&&(e.preventDefault(),L.current+=1,x(!0))},onDragOver:e=>{i(e)&&(e.preventDefault(),y||x(!0))},onDragLeave:e=>{i(e)&&(L.current=Math.max(0,L.current-1),0===L.current&&x(!1))},onDrop:e=>{i(e)&&(e.preventDefault(),L.current=0,x(!1),A(e.dataTransfer.files))}},pasteProps:d?{}:{onPaste:e=>{const t=function(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length>0)return Array.from(t.files);const r=[];for(const e of Array.from(t.items??[]))if("file"===e.kind){const t=e.getAsFile();t&&r.push(t)}return r}(e);0!==t.length&&(e.preventDefault(),A(t))}},open:j,take:A,dragOver:y,rejections:v,clearRejections:k}}function u({rejections:e,className:t="mt-2"}){return 0===e.length?null:/* @__PURE__ */a("ul",{role:"alert",className:`${t} flex flex-col gap-0.5`,children:e.map(({file:e,message:t},r)=>/* @__PURE__ */a("li",{className:"text-xs text-red-600",children:t},`${e.name}-${r}`))})}export{u as FileIntakeAlert,o as acceptsFile,l as humanSize,c as useFileIntake};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{useDismissPopupsOnOpen as e}from"./chunk-AFYQTVZO.js";import{registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-X4FJ54PP.js";import{useShellStrings as r,splitAround as o}from"./chunk-
|
|
1
|
+
import{useDismissPopupsOnOpen as e}from"./chunk-AFYQTVZO.js";import{registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-X4FJ54PP.js";import{useShellStrings as r,splitAround as o}from"./chunk-J3LIIIHJ.js";import{createContext as l,useEffect as i,useRef as a,useId as s,useContext as c,useState as d,useCallback as u}from"react";import{jsxs as m,jsx as f,Fragment as h}from"react/jsx-runtime";var b=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function g(e){return Array.from(e.querySelectorAll(b)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var p=[];function v(e){const t=p.findIndex(t=>t!==e&&e.contains(t));-1===t?p.push(e):p.splice(t,0,e)}function x(e){const t=p.lastIndexOf(e);-1!==t&&p.splice(t,1)}var y=/* @__PURE__ */new WeakSet;function w(e){return g(e)}function N(e,t){i(()=>{if(!t)return;const n=e.current;return n?(y.add(n),v(n),()=>{x(n),y.delete(n)}):void 0},[e,t])}function k(e,t){const n=p.lastIndexOf(t),r=n>0?p[n-1]:-1===n?p[p.length-1]??null:null,o=g(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),l=o.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return l||(r&&!y.has(r)?o[0]??null:null)}function C(e,t,n){i(()=>{if(!t)return;const r=e.current;if(!r)return;const o=document.activeElement,l=n?.current??g(r)[0]??r;l!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),l.focus();const i=e=>{if("Tab"!==e.key)return;if(p[p.length-1]!==r)return;const t=g(r);if(0===t.length)return void e.preventDefault();const n=t[0],o=t[t.length-1],l=document.activeElement;!e.shiftKey||l!==n&&r.contains(l)?e.shiftKey||l!==o&&r.contains(l)||(e.preventDefault(),n.focus()):(e.preventDefault(),o.focus())};return v(r),document.addEventListener("keydown",i,!0),()=>{x(r),document.removeEventListener("keydown",i,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&o?.focus?.()}},[e,t,n])}var L=0,E=null;function P(e){i(()=>{if(!e)return;const t=document.body;if(0===L){E={overflow:t.style.overflow,paddingRight:t.style.paddingRight};const e=window.innerWidth-document.documentElement.clientWidth;t.style.overflow="hidden",e>0&&(t.style.paddingRight=`${e}px`)}return L+=1,()=>{0===(L-=1)&&E&&(t.style.overflow=E.overflow,t.style.paddingRight=E.paddingRight,E=null)}},[e])}var j={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function I({open:o,onClose:l,title:c,description:d,role:u="dialog",children:h,footer:b,blocking:g=!1,size:p="md",initialFocus:v,"aria-label":x,"aria-labelledby":y,"aria-describedby":w,className:N=""}){const k=a(null),L=s(),E=s(),I=!g&&!b,F=s(),T=r().dialog;return e(o),C(k,o,v),P(o),i(()=>{if(o)return t(()=>(g||l(),!0),()=>k.current)},[o,g,l]),o?/* @__PURE__ */m("div",{className:"fixed inset-0",style:{zIndex:n.overlay},role:"presentation",children:[
|
|
2
2
|
/* @__PURE__ */f("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),
|
|
3
|
-
/* @__PURE__ */f("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:g?void 0:e=>{e.target===e.currentTarget&&l()},children:/* @__PURE__ */m("div",{ref:k,role:u,"aria-modal":"true","aria-labelledby":c?F:y,"aria-label":c||y?void 0:x,"aria-describedby":w??(d?E:h?L:void 0),className:`relative max-h-full w-full ${j[p]} overflow-y-auto overscroll-contain rounded-(--radius-card) bg-white p-6 shadow-xl ${N}`.trim(),children:[c&&/* @__PURE__ */f("h2",{id:F,className:(
|
|
3
|
+
/* @__PURE__ */f("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:g?void 0:e=>{e.target===e.currentTarget&&l()},children:/* @__PURE__ */m("div",{ref:k,role:u,"aria-modal":"true","aria-labelledby":c?F:y,"aria-label":c||y?void 0:x,"aria-describedby":w??(d?E:h?L:void 0),className:`relative max-h-full w-full ${j[p]} overflow-y-auto overscroll-contain rounded-(--radius-card) bg-white p-6 shadow-xl ${N}`.trim(),children:[c&&/* @__PURE__ */f("h2",{id:F,className:(I?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:c}),d&&/* @__PURE__ */f("p",{id:E,className:((c?"mt-1":I?"pr-8":"")+" text-sm text-gray-500").trim(),children:d}),h&&/* @__PURE__ */f("div",{id:L,className:"mt-2 text-sm text-gray-600",children:h}),b&&/* @__PURE__ */f("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:b}),I&&/* @__PURE__ */f("button",{type:"button",onClick:l,"aria-label":T.close,className:"absolute right-3 top-3 rounded-(--radius-control) p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */f("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:/* @__PURE__ */f("path",{d:"M6 6l8 8M14 6l-8 8"})})})]})})]}):null}var F=l(()=>Promise.resolve(!1)),T=()=>c(F),D=()=>Promise.resolve(!1),O=e=>D(e),W=()=>Promise.resolve(!1),M=e=>W(e),$=()=>Promise.resolve(null),A=e=>$(e),R={danger:{icon:"text-red-600 bg-red-100",button:"bg-red-600 hover:bg-red-700 text-white"},warning:{icon:"text-yellow-600 bg-yellow-100",button:"bg-yellow-600 hover:bg-yellow-700 text-white"},info:{icon:"text-blue-600 bg-blue-100",button:"bg-blue-600 hover:bg-blue-700 text-white"}},z="bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50";function K(){/* @__PURE__ */
|
|
4
4
|
return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}function B(){/* @__PURE__ */
|
|
5
|
-
return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function
|
|
5
|
+
return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function J({children:e}){const[t,n]=d(!1),[l,s]=d({message:""}),[c,b]=d(0),g=a(),p=a(null),v=a(0),x=a([]),y=a(null),w=a(null),N=u(e=>{p.current=e.id,g.current=e.resolve,b(e.id),s(e.options),n(!0)},[]),k=u(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++v.current,options:t,resolve:e};null===p.current?N(n):x.current.push(n)})},[N]),[C,L]=d(!1),[E,P]=d({message:""}),[j,T]=d(""),O=a(),M=u(e=>(P(e),T(""),L(!0),new Promise(e=>{O.current=e})),[]),[A,J]=d(!1),[S,H]=d({}),[V,_]=d(""),q=a(),G=u(e=>{const t="string"==typeof e?{message:e}:e;return H(t),_(t.defaultValue??""),J(!0),new Promise(e=>{q.current=e})},[]);i(()=>{D=k,W=M,$=G},[k,M,G]);const Q=(e,t)=>{if(p.current!==e)return;const r=g.current,o=x.current.shift();o?N(o):(p.current=null,g.current=void 0,n(!1)),r?.(t)},U=e=>{L(!1),T(""),O.current?.(e)},X=e=>{if(e){const e=V.trim();if(!e&&!S.allowEmpty)return J(!1),void q.current?.(null);J(!1),q.current?.(e)}else J(!1),q.current?.(null)},Y=l.variant||(l.confirmLabel?.toLowerCase().includes("delete")||l.message.toLowerCase().includes("delete")?"danger":"info"),Z=R[Y],ee=R["warning"===E.variant?"warning":"danger"],te=E.confirmWord,ne=null==te||j===te,re=r().dialog,[oe,le]=o(re.typeToConfirm);/* @__PURE__ */
|
|
6
6
|
return m(F.Provider,{value:k,children:[e,
|
|
7
|
-
/* @__PURE__ */f(
|
|
8
|
-
/* @__PURE__ */f("button",{ref:y,type:"button",onClick:()=>
|
|
9
|
-
/* @__PURE__ */f("button",{type:"button",onClick:()=>
|
|
7
|
+
/* @__PURE__ */f(I,{open:t,onClose:()=>Q(c,!1),initialFocus:y,footer:/* @__PURE__ */m(h,{children:[
|
|
8
|
+
/* @__PURE__ */f("button",{ref:y,type:"button",onClick:()=>Q(c,!1),className:z,children:l.cancelLabel||re.cancel}),
|
|
9
|
+
/* @__PURE__ */f("button",{type:"button",onClick:()=>Q(c,!0),className:`px-4 py-2 text-sm font-medium rounded-lg ${Z.button}`,children:l.confirmLabel||re.ok})]}),children:/* @__PURE__ */m("div",{className:"flex gap-4",children:[
|
|
10
10
|
/* @__PURE__ */f("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${Z.icon}`,children:/* @__PURE__ */f(K,{})}),
|
|
11
11
|
/* @__PURE__ */m("div",{className:"flex-1",children:[
|
|
12
12
|
/* @__PURE__ */f("h2",{className:"text-base font-semibold text-gray-900",children:l.title||re.confirmTitle}),
|
|
13
13
|
/* @__PURE__ */f("p",{className:"mt-2 text-sm text-gray-600",children:l.message})]})]})}),
|
|
14
|
-
/* @__PURE__ */m(
|
|
15
|
-
/* @__PURE__ */f("button",{ref:w,type:"button",onClick:()=>
|
|
16
|
-
/* @__PURE__ */f("button",{type:"button",onClick:()=>
|
|
17
|
-
/* @__PURE__ */f("button",{type:"button",onClick:()=>
|
|
14
|
+
/* @__PURE__ */m(I,{open:C,onClose:()=>U(!1),initialFocus:null!=te?void 0:w,footer:/* @__PURE__ */m(h,{children:[
|
|
15
|
+
/* @__PURE__ */f("button",{ref:w,type:"button",onClick:()=>U(!1),className:z,children:E.cancelLabel||re.destructiveCancel}),
|
|
16
|
+
/* @__PURE__ */f("button",{type:"button",onClick:()=>U(!0),disabled:!ne,className:`px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40 ${ee.button}`,children:te??E.confirmLabel??re.destructiveConfirm})]}),children:[
|
|
17
|
+
/* @__PURE__ */f("button",{type:"button",onClick:()=>U(!1),"aria-label":re.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */f(B,{})}),
|
|
18
18
|
/* @__PURE__ */m("div",{className:"flex gap-4",children:[
|
|
19
19
|
/* @__PURE__ */f("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ee.icon}`,children:/* @__PURE__ */f(K,{})}),
|
|
20
20
|
/* @__PURE__ */m("div",{className:"flex-1",children:[
|
|
@@ -22,8 +22,8 @@ return m(F.Provider,{value:k,children:[e,
|
|
|
22
22
|
/* @__PURE__ */f("p",{className:"mt-2 text-sm text-gray-600",children:E.message}),null!=te&&/* @__PURE__ */m(h,{children:[
|
|
23
23
|
/* @__PURE__ */m("p",{className:"mt-3 text-sm text-gray-700",children:[oe,
|
|
24
24
|
/* @__PURE__ */f("kbd",{className:"rounded border border-gray-300 bg-gray-50 px-1.5 py-0.5 text-xs font-bold text-red-600 font-mono",children:te}),le]}),
|
|
25
|
-
/* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:j,onChange:e=>
|
|
26
|
-
/* @__PURE__ */m(
|
|
27
|
-
/* @__PURE__ */f("button",{type:"button",onClick:()=>
|
|
28
|
-
/* @__PURE__ */f("button",{type:"button",onClick:()=>
|
|
29
|
-
/* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:
|
|
25
|
+
/* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:j,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===te&&U(!0)},placeholder:te,className:"mt-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-red-500"})]})]})]})]}),
|
|
26
|
+
/* @__PURE__ */m(I,{open:A,onClose:()=>X(!1),title:S.title||re.promptTitle,footer:/* @__PURE__ */m(h,{children:[
|
|
27
|
+
/* @__PURE__ */f("button",{type:"button",onClick:()=>X(!1),className:z,children:S.cancelLabel||re.cancel}),
|
|
28
|
+
/* @__PURE__ */f("button",{type:"button",onClick:()=>X(!0),disabled:!S.allowEmpty&&!V.trim(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40",children:S.confirmLabel||re.ok})]}),children:[S.message&&/* @__PURE__ */f("p",{className:"text-sm text-gray-600",children:S.message}),
|
|
29
|
+
/* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:V,onChange:e=>_(e.target.value),onKeyDown:e=>{"Enter"===e.key?X(!0):"Escape"===e.key&&X(!1)},onFocus:e=>e.target.select(),placeholder:S.placeholder,className:"mt-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]"})]})]})}export{J as ConfirmProvider,I as Dialog,O as confirm,M as confirmDestructive,w as focusableIn,A as prompt,k as stopAfter,T as useConfirm,C as useFocusTrap,P as useScrollLock,N as useTabLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{FileIntakeAlert,acceptsFile,useFileIntake}from"../chunk-
|
|
2
|
+
export{FileIntakeAlert,acceptsFile,useFileIntake}from"../chunk-WNEO7TSP.js";import"../chunk-J3LIIIHJ.js";import"../chunk-C3QOHMR6.js";
|