@nice2dev/ui 1.4.0 → 1.4.2

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/NiceCodeEditor-DhdjnDLV.cjs +289 -0
  3. package/dist/{NiceDataGrid-BT6iCUgP.cjs → NiceDataGrid-CrKDzMM1.cjs} +1 -1
  4. package/dist/{NiceForm-Bysp66Ef.cjs → NiceForm-CT9hEXpc.cjs} +1 -1
  5. package/dist/NiceLoginForm-C2-WgRn0.cjs +1 -0
  6. package/dist/NiceMention-BZEHqPrf.cjs +432 -0
  7. package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +1 -0
  8. package/dist/{NiceSavedQueryPanel-BbznsXFd.cjs → NiceSavedQueryPanel-C5Ab_NWx.cjs} +1 -1
  9. package/dist/NiceScheduler-BZQAKEVF.cjs +5 -0
  10. package/dist/{NiceWindow-pgR4c-kQ.cjs → NiceWindow-BklnkBpu.cjs} +1 -1
  11. package/dist/charts/NiceLinearGauge.mjs +96 -83
  12. package/dist/charts/NicePolarChart.mjs +47 -47
  13. package/dist/charts-BzlvCCg9.cjs +768 -0
  14. package/dist/charts.cjs +1 -1
  15. package/dist/{core-lazy-CL4ZIxF-.cjs → core-lazy-VTd5zfoZ.cjs} +1 -1
  16. package/dist/data.cjs +1 -1
  17. package/dist/display/NiceAvatar.mjs +40 -24
  18. package/dist/editors/pickers/NiceDateRangeBox.mjs +92 -92
  19. package/dist/editors/pickers/NiceDateTimePicker.mjs +173 -173
  20. package/dist/editors/rich/NiceCodeEditor.mjs +645 -584
  21. package/dist/editors/rich/NiceDocumentEditor.mjs +277 -254
  22. package/dist/editors.cjs +1 -1
  23. package/dist/feedback/NiceDrawer.mjs +15 -15
  24. package/dist/feedback.cjs +1 -1
  25. package/dist/index.cjs +202 -202
  26. package/dist/index.d.ts +18 -0
  27. package/dist/lazy.cjs +1 -1
  28. package/dist/navigation/NiceNavShell.mjs +646 -593
  29. package/dist/navigation/NiceSidebarNav.mjs +844 -823
  30. package/dist/navigation.cjs +1 -1
  31. package/dist/overlays/NiceWindow.mjs +91 -91
  32. package/dist/overlays.cjs +1 -1
  33. package/dist/planning/NiceScheduler.mjs +170 -169
  34. package/dist/planning/NiceSchedulerViews.mjs +242 -233
  35. package/dist/style.css +2 -2
  36. package/dist/utility/intlNames.mjs +26 -16
  37. package/package.json +4 -4
  38. package/dist/NiceCodeEditor-D0QZW88r.cjs +0 -268
  39. package/dist/NiceLoginForm-FGf32sro.cjs +0 -1
  40. package/dist/NiceMention-sc8W-DwH.cjs +0 -430
  41. package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +0 -1
  42. package/dist/NiceScheduler-3Ez0zSQJ.cjs +0 -5
  43. package/dist/charts-B0tHOpJ7.cjs +0 -768
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # [1.0.27] — 2026-06-07
2
2
 
3
+ ## 1.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 59c88ca: Controls, showcase feedback round 43.
8
+
9
+ Fixes:
10
+
11
+ - NiceDrawer no longer slides off-screen right after opening: it carries `nice-drawer--open` (and its
12
+ overlay `nice-drawer-overlay--visible`). Top and bottom drawers span the width.
13
+ - NiceDocumentEditor: typing no longer comes out backwards ("Test" → "tseT") — editable blocks are
14
+ uncontrolled, and a toggle keeps its title line when its body is edited.
15
+ - NiceNavShell: on a phone with a `topNav` slot of your own, `api.mobileMenuButton` is a ready
16
+ hamburger that opens the menu (the sidebar's tree) in a drawer; `api.mobileMenuOpen` /
17
+ `api.setMobileMenuOpen` for a button of your own. A narrow window no longer leaves you with no
18
+ way to the menu.
19
+ - NiceSidebarNav: a shortcut scrolls the tree to its row once the row is shown.
20
+ - NiceBottomSheet: the handle drags with a mouse or pen too (pointer events), so the snap points work.
21
+ - NiceMenu `fullWidth` spreads the items over the whole bar.
22
+ - NiceForm: a number field keeps its own width instead of stretching over the column.
23
+ - NiceWindow follows the theme (text, title bar), pads its content and turns see-through while dragged.
24
+ - NiceDateTimePicker / NiceDateRangeBox: inside a NiceThemeProvider the popup keeps the named theme's
25
+ colours (no light/dark class over them).
26
+ - NiceCodeEditor / NiceCodeDiffEditor (`theme="auto"`) follow the app's theme, including a scoped
27
+ NiceThemeProvider; NiceSimpleCodeEditor uses the theme's colours in dark mode.
28
+ - NiceScheduler shows dates as the date pickers do: the app locale, two-digit day and month,
29
+ a four-digit year.
30
+ - NicePieChart labels 50% larger; NicePolarChart's title gets a band of its own; NiceLinearGauge's
31
+ label sits lower.
32
+ - NiceChatWindow / NiceChannelView: the hover actions sit next to the message.
33
+ - NiceMessenger / NiceChatWindow use NiceAvatar with a larger presence dot.
34
+ - NiceGenericPlayer: theme colours for text, toggles and sliders, the stage tinted by the theme;
35
+ the progress updates ten times a second.
36
+ - NiceDiagramViewer: `autoFit` (default `true`) fits the whole diagram; without `showWorkspace` the
37
+ diagram sits on the page's background.
38
+ - NiceDesktop's taskbar uses the theme's surface.
39
+
40
+ New:
41
+
42
+ - NiceAvatar `badge` + `badgePosition` — a presence dot, count or icon on the avatar's edge.
43
+
44
+ - @nice2dev/i18n@1.4.2
45
+ - @nice2dev/ui-core@1.4.2
46
+
47
+ ## 1.4.1
48
+
49
+ ### Patch Changes
50
+
51
+ - @nice2dev/i18n@1.4.1
52
+ - @nice2dev/ui-core@1.4.1
53
+
3
54
  ## 1.4.0
4
55
 
5
56
  ### Minor Changes
@@ -0,0 +1,289 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),k=require("@nice2dev/ui-core"),n=require("react"),fe=require("./injectStyleOnce-DeWaxcdf.cjs"),Ke=[{target:".nice-code-editor-wrap",titleKey:"tutorial.codeEditor.intro.title",title:"Code editor",contentKey:"tutorial.codeEditor.intro.content",content:"Edit code with syntax highlighting, IntelliSense and the toolbar. Ctrl+S saves; the status bar shows the cursor position and any problems.",placement:"auto"}];let X=null,ne=null;const Ye="0.45.0",Me=`https://cdn.jsdelivr.net/npm/monaco-editor@${Ye}/min`,me=`${Me}/vs`,Ne=15e3;function Se(){const o=window;if(o.MonacoEnvironment?.getWorkerUrl)return;const c=`self.MonacoEnvironment={baseUrl:'${Me}/'};importScripts('${me}/base/worker/workerMain.js');`,d=URL.createObjectURL(new Blob([c],{type:"text/javascript"}));o.MonacoEnvironment={getWorkerUrl:()=>d}}function ie(o){if(o!=="auto")return o;if(typeof document>"u")return"vs";const c=document.documentElement.dataset.theme;return c==="dark"?"vs-dark":c==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}const Ee="nice-auto";let ee;function Je(o){if(!o||typeof document>"u"||(ee===void 0&&(ee=document.createElement("canvas").getContext("2d")),!ee))return null;const c="#010203";ee.fillStyle=c,ee.fillStyle=o;const d=String(ee.fillStyle);if(d===c&&o.trim().toLowerCase()!==c)return null;if(d.startsWith("#"))return d;const r=d.match(/rgba?\(([^)]+)\)/);if(!r)return null;const[m,C,w,f=1]=r[1].split(",").map(i=>parseFloat(i)),h=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${h(m)}${h(C)}${h(w)}${f<1?h(f*255):""}`}function Qe(o){const c=parseInt(o.slice(1,3),16),d=parseInt(o.slice(3,5),16),r=parseInt(o.slice(5,7),16);return(.299*c+.587*d+.114*r)/255}function ce(o,c,d){if(c!=="auto"||!d||typeof getComputedStyle>"u")return ie(c);const r=getComputedStyle(d),m=(...M)=>{for(const L of M){const b=Je(r.getPropertyValue(L).trim());if(b)return b}return null},C=m("--nice-bg-primary","--bg-primary"),w=m("--nice-text-primary","--text-primary");if(!C||!w)return ie(c);const f=m("--nice-bg-secondary","--bg-secondary")??C,h=m("--nice-text-secondary","--text-secondary")??w,i=m("--nice-color-primary","--primary")??w,$=m("--nice-border-color","--border-color")??h,j=i.slice(0,7);return o.editor.defineTheme(Ee,{base:Qe(C)<.5?"vs-dark":"vs",inherit:!0,rules:[],colors:{"editor.background":C,"editor.foreground":w,"editorLineNumber.foreground":h,"editorLineNumber.activeForeground":w,"editorCursor.foreground":j,"editor.selectionBackground":`${j}40`,"editor.inactiveSelectionBackground":`${j}26`,"editor.lineHighlightBackground":f,"editor.lineHighlightBorder":f,"editorWidget.background":f,"editorWidget.border":$,"editorSuggestWidget.background":f,"editorSuggestWidget.border":$,"minimap.background":C}}),Ee}function Re(o,c){const d=new MutationObserver(c),r={attributes:!0,attributeFilter:["data-theme","class","style"]};d.observe(document.documentElement,r);const m=o?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");m&&m!==document.documentElement&&d.observe(m,r);const C=window.matchMedia?.("(prefers-color-scheme: dark)");return C?.addEventListener?.("change",c),()=>{d.disconnect(),C?.removeEventListener?.("change",c)}}function Ze(o){if(!o)return"";try{return JSON.stringify([o.url,o.language,o.initOptions??null])}catch{return JSON.stringify([o.url,o.language])}}function Le(){return ne?Promise.resolve(ne):X||(X=new Promise((o,c)=>{if(window.monaco){Se(),ne=window.monaco,o(ne);return}let d=!1;const r=window.setTimeout(()=>{d||(d=!0,X=null,c(new Error(`Monaco editor failed to load within ${Ne}ms`)))},Ne),m=document.createElement("script");m.src=`${me}/loader.min.js`,m.async=!0,m.onload=()=>{const C=window.require;C.config({paths:{vs:me}}),Se(),C(["vs/editor/editor.main"],w=>{d||(d=!0,window.clearTimeout(r),ne=w,o(w))})},m.onerror=()=>{d||(d=!0,window.clearTimeout(r),X=null,c(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(m)}),X)}function Te(o){n.useEffect(()=>{const c=o.current;if(!c)return;const d=k.createTabEscape(),r=m=>{d(m)&&m.stopPropagation()};return c.addEventListener("keydown",r,!0),()=>c.removeEventListener("keydown",r,!0)},[o])}const Ge=n.forwardRef(function(c,d){const{t:r}=k.useNiceTranslation();fe.injectStyleOnce(ge,be);const{value:m,defaultValue:C,onChange:w,language:f="plaintext",theme:h="auto",options:i={},height:$=400,width:j="100%",markers:M=[],decorations:L=[],completionProvider:b,onMount:P,onCursorPositionChange:E,onSelectionChange:T,onSave:F,loading:A,disabled:D=!1,showToolbar:K=!1,showStatusBar:W=!1,editorSize:H="standard",className:Y,"data-testid":B,lsp:O,extraLibs:_,tutorial:J}=c,[N,Q,Z]=k.useControllableState({value:m,defaultValue:C,fallbackValue:"",onChange:w,componentName:"NiceCodeEditor"}),U=n.useRef(Q);U.current=Q;const v=n.useRef(N);v.current=N;const u=n.useRef(!1),g=n.useRef(null);Te(g);const s=n.useRef(null),S=n.useRef(null),z=n.useRef([]),V=n.useRef(null),[R,se]=n.useState(!0),[te,Oe]=n.useState(null),[he,Ie]=n.useState({lineNumber:1,column:1}),[ke,Pe]=n.useState(""),[de,Ae]=n.useState(i.wordWrap==="on"),oe=n.useMemo(()=>({automaticLayout:!0,readOnly:D||i.readOnly,minimap:{enabled:i.minimap??!0},lineNumbers:i.lineNumbers??"on",wordWrap:i.wordWrap??"off",tabSize:i.tabSize??2,insertSpaces:i.insertSpaces??!0,fontSize:i.fontSize??14,fontFamily:i.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:i.fontLigatures??!0,cursorStyle:i.cursorStyle??"line",cursorBlinking:i.cursorBlinking??"blink",autoClosingBrackets:i.autoClosingBrackets??"languageDefined",autoClosingQuotes:i.autoClosingQuotes??"languageDefined",formatOnPaste:i.formatOnPaste??!1,formatOnType:i.formatOnType??!1,renderWhitespace:i.renderWhitespace??"selection",renderControlCharacters:i.renderControlCharacters??!1,scrollBeyondLastLine:i.scrollBeyondLastLine??!0,smoothScrolling:i.smoothScrolling??!0,folding:i.folding??!0,showFoldingControls:i.showFoldingControls??"mouseover","bracketPairColorization.enabled":i.bracketPairColorization??!0,guides:i.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:i.stickyScroll??!1},quickSuggestions:i.quickSuggestions??!0,suggestOnTriggerCharacters:i.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:i.acceptSuggestionOnEnter??"on",inlayHints:{enabled:i.inlayHints?"on":"off"}}),[i,D]),re=n.useRef({onCursorPositionChange:E,onSelectionChange:T,onSave:F,onMount:P});re.current={onCursorPositionChange:E,onSelectionChange:T,onSave:F,onMount:P};const ye=n.useRef({language:f,theme:h,editorOptions:oe});ye.current={language:f,theme:h,editorOptions:oe};const ve=n.useRef(O);ve.current=O;const De=Ze(O),xe=n.useRef(r);xe.current=r,n.useEffect(()=>{if(!g.current)return;let e=!0;const l=ve.current;return Le().then(async a=>{if(!e||!g.current)return;S.current=a;const y=ye.current,x=a.editor.create(g.current,{value:v.current,language:y.language,theme:ie(y.theme),...y.editorOptions});if(s.current=x,se(!1),x.onDidChangeModelContent(()=>{u.current||U.current(x.getValue())}),x.onDidChangeCursorPosition(p=>{Ie({lineNumber:p.position.lineNumber,column:p.position.column}),re.current.onCursorPositionChange?.({lineNumber:p.position.lineNumber,column:p.position.column})}),x.onDidChangeCursorSelection(p=>{const I=p.selection,G=x.getModel()?.getValueInRange(I)??"";Pe(G),re.current.onSelectionChange?.({startLineNumber:I.startLineNumber,startColumn:I.startColumn,endLineNumber:I.endLineNumber,endColumn:I.endColumn})}),x.addCommand(a.KeyMod.CtrlCmd|a.KeyCode.KeyS,()=>{re.current.onSave?.(x.getValue())}),l&&typeof window<"u")try{await ae("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await ae("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const p=window,I=p.ReconnectingWebSocket,{MonacoLanguageClient:G,CloseAction:Ve,ErrorAction:$e,createConnection:Ce}=p.monacoLanguageClient||{};if(G&&Ce){const Fe=l.url,He=l.language,we=new I(Fe),Be=new p.VSCodeWebSocketMessageReader(we),Ue=new p.VSCodeWebSocketMessageWriter(we),qe=Ce(Be,Ue),_e=new G({name:"LSP Client",clientOptions:{documentSelector:[He],initializationOptions:l.initOptions,errorHandler:{error:()=>$e.Continue,closed:()=>Ve.Restart}},connectionProvider:{get:()=>Promise.resolve(qe)}});_e.start(),s.current.__lspClient=_e}}catch(p){console.warn("LSP bridge failed to load:",p)}re.current.onMount?.(x,a)}).catch(a=>{e&&(Oe(a.message??xe.current("codeEditor.failedToLoadEditor","Failed to load editor")),se(!1))}),()=>{if(e=!1,s.current?.dispose(),V.current?.dispose(),s.current&&s.current.__lspClient)try{s.current.__lspClient.stop()}catch{}}},[De]),n.useEffect(()=>{const e=s.current;if(!Z||!e||N===e.getValue())return;const l=e.getPosition();u.current=!0;try{e.setValue(N)}finally{u.current=!1}l&&e.setPosition(l)},[N,Z]),n.useEffect(()=>{const e=s.current,l=S.current;if(e&&l){const a=e.getModel();a&&l.editor.setModelLanguage(a,f)}},[f]),n.useEffect(()=>{const e=S.current;if(!e||R||!_||_.length===0||f!=="javascript"&&f!=="typescript")return;const l=e.languages?.typescript;if(!l)return;const a=[];try{_.forEach((y,x)=>{const p=y.filePath??`inmemory://model/nice-extralib-${x}.d.ts`,I=l.typescriptDefaults?.addExtraLib(y.content,p);I&&a.push(I);const G=l.javascriptDefaults?.addExtraLib(y.content,p);G&&a.push(G)})}catch(y){console.warn("Failed to register extraLibs:",y)}return()=>{a.forEach(y=>{try{y.dispose()}catch{}})}},[_,f,R]),n.useEffect(()=>{const e=S.current;if(e&&(e.editor.setTheme(ce(e,h,g.current)),!(h!=="auto"||typeof document>"u")))return Re(g.current,()=>{const l=S.current;l?.editor.setTheme(ce(l,"auto",g.current))})},[h,R]),n.useEffect(()=>{const e=s.current;e&&e.updateOptions(oe)},[oe]),n.useEffect(()=>{const e=s.current,l=S.current;if(e&&l){const a=e.getModel();if(a){const y=M.map(x=>({startLineNumber:x.startLineNumber,startColumn:x.startColumn,endLineNumber:x.endLineNumber,endColumn:x.endColumn,message:x.message,severity:x.severity}));l.editor.setModelMarkers(a,"owner",y)}}},[M]),n.useEffect(()=>{const e=s.current;if(e&&L.length>0){const l=L.map(a=>({range:{startLineNumber:a.range.startLineNumber,startColumn:a.range.startColumn,endLineNumber:a.range.endLineNumber,endColumn:a.range.endColumn},options:{className:a.className,glyphMarginClassName:a.glyphMarginClassName,hoverMessage:a.hoverMessage?{value:a.hoverMessage}:void 0,isWholeLine:a.isWholeLine}}));z.current=e.deltaDecorations(z.current,l)}},[L]),n.useEffect(()=>{const e=S.current;if(!e||!b)return;V.current?.dispose();const l={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return V.current=e.languages.registerCompletionItemProvider(f,{provideCompletionItems:async(a,y)=>({suggestions:(await b(a,y)).map(p=>({label:p.label,kind:l[p.kind]??0,insertText:p.insertText,insertTextRules:p.insertTextRules==="insertAsSnippet"?4:void 0,documentation:p.documentation,detail:p.detail,range:{startLineNumber:y.lineNumber,startColumn:y.column,endLineNumber:y.lineNumber,endColumn:y.column}}))})}),()=>{V.current?.dispose()}},[f,b]),n.useImperativeHandle(d,()=>({getEditor:()=>s.current,getMonaco:()=>S.current,focus:()=>s.current?.focus(),getValue:()=>s.current?.getValue()??"",setValue:e=>s.current?.setValue(e),getSelection:()=>{const e=s.current;if(!e)return"";const l=e.getSelection();return l?e.getModel()?.getValueInRange(l)??"":""},insertText:e=>{const l=s.current;if(!l)return;const a=l.getSelection();a&&l.executeEdits("",[{range:a,text:e}])},formatDocument:()=>{s.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,l=1)=>{const a=s.current;a&&(a.setPosition({lineNumber:e,column:l}),a.revealLineInCenter(e),a.focus())},findReplace:()=>{s.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{s.current?.trigger("keyboard","undo",null)},redo:()=>{s.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=s.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const l=s.current,a=S.current;if(l&&a){const y=l.getModel();if(y){const x=e.map(p=>({startLineNumber:p.startLineNumber,startColumn:p.startColumn,endLineNumber:p.endLineNumber,endColumn:p.endColumn,message:p.message,severity:p.severity}));a.editor.setModelMarkers(y,"owner",x)}}}}),[]);const q=n.useMemo(()=>({format:()=>s.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>s.current?.trigger("keyboard","undo",null),redo:()=>s.current?.trigger("keyboard","redo",null),find:()=>s.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!de;Ae(e),s.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=s.current?.getOption?.(S.current?.editor?.EditorOption?.minimap);s.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>s.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>s.current?.getAction("editor.unfoldAll")?.run()}),[de]),We=N.split(`
2
+ `).length,ze=N.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${H} ${Y??""}`,style:{height:$,width:j,display:"flex",flexDirection:"column",position:"relative"},"data-testid":B,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(J,Ke)})}),te&&t.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[t.jsxs("span",{children:[t.jsx(k.NiceIcon,{name:"warning",size:16})," ",te]}),t.jsx("textarea",{value:N,onChange:e=>Q(e.target.value),readOnly:D||i.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),R&&!te&&t.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:A??t.jsx("div",{className:"nice-code-editor__loader",children:r("codeEditor.loadingEditor","Loading editor...")})}),K&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.undo,title:r("codeEditor.undoCtrlZ","Undo (Ctrl+Z)"),"aria-label":r("codeEditor.undo","Undo"),children:t.jsx(k.NiceIcon,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.redo,title:r("codeEditor.redoCtrlY","Redo (Ctrl+Y)"),"aria-label":r("codeEditor.redo","Redo"),children:t.jsx(k.NiceIcon,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.format,title:r("codeEditor.formatShiftAltF","Format (Shift+Alt+F)"),"aria-label":r("codeEditor.format","Format"),children:t.jsx(k.NiceIcon,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.find,title:r("codeEditor.findReplaceCtrlH","Find & Replace (Ctrl+H)"),"aria-label":r("codeEditor.findReplace","Find & Replace"),children:t.jsx(k.NiceIcon,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${de?" nice-code-editor__toolbar-btn--active":""}`,onClick:q.toggleWordWrap,title:r("codeEditor.toggleWordWrap","Toggle Word Wrap"),"aria-label":r("codeEditor.toggleWordWrap","Toggle Word Wrap"),children:t.jsx(k.NiceIcon,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.toggleMinimap,title:r("codeEditor.toggleMinimap","Toggle Minimap"),"aria-label":r("codeEditor.toggleMinimap","Toggle Minimap"),children:t.jsx(k.NiceIcon,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.foldAll,title:r("codeEditor.foldAll","Fold All"),"aria-label":r("codeEditor.foldAll","Fold All"),children:t.jsx(k.NiceIcon,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:q.unfoldAll,title:r("codeEditor.unfoldAll","Unfold All"),"aria-label":r("codeEditor.unfoldAll","Unfold All"),children:t.jsx(k.NiceIcon,{name:"expand",size:16})})]}),t.jsx("div",{ref:g,className:"nice-code-editor",style:{flex:1,minHeight:0}}),W&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsx("span",{children:r("codeEditor.lnCol","Ln {lineNumber}, Col {column}").replace("{lineNumber}",String(he.lineNumber)).replace("{column}",String(he.column))}),ke.length>0&&t.jsx("span",{children:r("codeEditor.selected","({selectionText} selected)").replace("{selectionText}",String(ke.length))}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsx("span",{children:r("codeEditor.linesChars","{lineCount} lines · {charCount} chars").replace("{lineCount}",String(We)).replace("{charCount}",String(ze))}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:f}),M.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(k.NiceIcon,{name:"warning",size:14})," ",M.length]})]})]})});function Xe(o){const{t:c}=k.useNiceTranslation();fe.injectStyleOnce(ge,be);const{original:d,defaultOriginal:r,modified:m,defaultModified:C,language:w="plaintext",theme:f="auto",height:h=400,width:i="100%",inline:$=!1,renderSideBySide:j=!0,originalEditable:M=!1,modifiedEditable:L=!1,onOriginalChange:b,onModifiedChange:P,loading:E,className:T,"data-testid":F}=o,[A,D,K]=k.useControllableState({value:d,defaultValue:r,fallbackValue:"",onChange:b,componentName:"NiceCodeDiffEditor.original"}),[W,H,Y]=k.useControllableState({value:m,defaultValue:C,fallbackValue:"",onChange:P,componentName:"NiceCodeDiffEditor.modified"}),B=n.useRef({currentOriginal:A,currentModified:W,setOriginal:D,setModified:H});B.current={currentOriginal:A,currentModified:W,setOriginal:D,setModified:H};const O=n.useRef(!1),_=n.useRef(null);Te(_);const J=n.useRef(null),N=n.useRef(null),[Q,Z]=n.useState(!0),[U,v]=n.useState(null);return n.useEffect(()=>{if(!_.current)return;let u=!0;return Le().then(g=>{if(!u||!_.current)return;N.current=g;const{currentOriginal:s,currentModified:S}=B.current,z=g.editor.createModel(s,w),V=g.editor.createModel(S,w),R=g.editor.createDiffEditor(_.current,{automaticLayout:!0,theme:ie(f),renderSideBySide:!$&&j,originalEditable:M,readOnly:!L});R.setModel({original:z,modified:V}),J.current=R,Z(!1),M&&z.onDidChangeContent(()=>{O.current||B.current.setOriginal(z.getValue())}),L&&V.onDidChangeContent(()=>{O.current||B.current.setModified(V.getValue())})}).catch(g=>{u&&(v(g.message??c("codeEditor.failedToLoadDiffEditor","Failed to load diff editor")),Z(!1))}),()=>{u=!1,J.current?.dispose()}},[c]),n.useEffect(()=>{const u=J.current?.getModel();if(u){O.current=!0;try{K&&u.original.getValue()!==A&&u.original.setValue(A),Y&&u.modified.getValue()!==W&&u.modified.setValue(W)}finally{O.current=!1}}},[A,W,K,Y]),n.useEffect(()=>{const u=N.current;if(u&&(u.editor.setTheme(ce(u,f,_.current)),!(f!=="auto"||typeof document>"u")))return Re(_.current,()=>{const g=N.current;g?.editor.setTheme(ce(g,"auto",_.current))})},[f,Q]),U?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${T??""}`,style:{height:h,width:i},"data-testid":F,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(k.NiceIcon,{name:"warning",size:16})," ",U]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${T??""}`,style:{height:h,width:i,position:"relative"},"data-testid":F,children:[t.jsx("div",{ref:_,style:{position:"absolute",inset:0}}),Q&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:E??t.jsx("div",{className:"nice-code-editor__loader",children:c("codeEditor.loadingDiffEditor","Loading diff editor...")})})]})}const et="1.29.0",je=`https://cdn.jsdelivr.net/npm/prismjs@${et}`;let le=null;const pe={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function ae(o){return new Promise((c,d)=>{if(document.querySelector(`script[data-prism-src="${o}"]`)){c();return}const r=document.createElement("script");r.src=o,r.async=!0,r.dataset.prismSrc=o,r.onload=()=>c(),r.onerror=()=>d(new Error(`Failed to load ${o}`)),document.head.appendChild(r)})}function tt(o){if(typeof window>"u")return Promise.resolve(null);const c=window,d=pe[o]??"plain",r=async()=>{if(d!=="plain"&&!c.Prism?.languages?.[d])try{await ae(`${je}/components/prism-${d}.min.js`)}catch{}};return c.Prism?.languages?r().then(()=>c.Prism):(le||(le=(async()=>(window.Prism={manual:!0},await ae(`${je}/prism.min.js`),window.Prism))()),le.then(async()=>(await r(),window.Prism)))}function ue(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rt(o){fe.injectStyleOnce(ge,be);const{value:c,defaultValue:d,onChange:r,language:m="plaintext",height:C=300,width:w="100%",readOnly:f=!1,tabSize:h=2,lineNumbers:i=!0,placeholder:$,theme:j="auto",className:M,"data-testid":L}=o,[b,P]=k.useControllableState({value:c,defaultValue:d,fallbackValue:"",onChange:r,componentName:"NiceSimpleCodeEditor"}),E=n.useRef(null),T=n.useRef(null),F=n.useRef(null),{t:A}=k.useNiceTranslation(),D=n.useId(),[K]=n.useState(k.createTabEscape),[W,H]=n.useState(()=>ue(b)),Y=n.useRef(null),[B]=n.useState(()=>({get current(){return Y.current?.parentElement??null}})),O=k.useThemeIsDark(B),_=j==="auto"?O?"dark":"light":j;n.useEffect(()=>{let v=!0;return tt(m).then(u=>{if(!v)return;const g=pe[m]??"plain";if(u?.languages?.[g])try{const s=u.highlight(b,u.languages[g],g);H(s);return}catch{}H(ue(b))}).catch(()=>{v&&H(ue(b))}),()=>{v=!1}},[b,m]);const J=n.useCallback(()=>{if(!T.current||!E.current)return;T.current.scrollTop=E.current.scrollTop,T.current.scrollLeft=E.current.scrollLeft;const v=F.current;if(v){const u=E.current.offsetHeight-E.current.clientHeight;v.style.paddingBottom=`calc(var(--nice-space-2, 8px) + ${u}px)`,v.scrollTop=E.current.scrollTop}},[]),N=n.useCallback(v=>{if(!K(v)&&v.key==="Tab"&&!f){v.preventDefault();const u=v.currentTarget,g=u.selectionStart,s=u.selectionEnd,S=" ".repeat(h);if(v.shiftKey){const R=b.substring(0,g).lastIndexOf(`
3
+ `)+1;if((b.substring(R,g).match(/^(\s*)/)?.[1]??"").length>=h){const te=b.substring(0,R)+b.substring(R+h);P(te),setTimeout(()=>{u.selectionStart=u.selectionEnd=g-h},0)}}else{const z=b.substring(0,g)+S+b.substring(s);P(z),setTimeout(()=>{u.selectionStart=u.selectionEnd=g+h},0)}}},[b,P,h,K,f]),Z=b.split(`
4
+ `).length,U=pe[m]??"plain";return t.jsxs("div",{ref:Y,className:`nice-simple-code-editor nice-simple-code-editor--${_}${j==="auto"?" nice-simple-code-editor--auto":""} ${M??""}`,style:{height:C,width:w},"data-testid":L,"data-language":m,"data-theme":_,children:[i&&t.jsx("div",{ref:F,className:"nice-simple-code-editor__line-numbers",children:Array.from({length:Z},(v,u)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:u+1},u))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:T,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${U}`,children:t.jsx("code",{className:`language-${U}`,dangerouslySetInnerHTML:{__html:W+(b.endsWith(`
5
+ `)?`
6
+ `:"")}})}),t.jsx("textarea",{ref:E,className:"nice-simple-code-editor__textarea",value:b,onChange:v=>P(v.target.value),onKeyDown:N,onScroll:J,readOnly:f,placeholder:$,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-describedby":f?void 0:D}),!f&&t.jsx("span",{id:D,className:"nice-sr-only",children:A("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")})]})]})}const ge="nice-code-editor-styles",be=`
7
+ .nice-code-editor,
8
+ .nice-code-diff-editor {
9
+ border: 1px solid var(--nice-border, #e0e0e0);
10
+ border-radius: var(--nice-radius-sm, 4px);
11
+ overflow: hidden;
12
+ }
13
+
14
+ .nice-code-editor--loading,
15
+ .nice-code-editor--error,
16
+ .nice-code-diff-editor--loading {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ background: var(--nice-bg-tertiary, #f5f5f5);
21
+ }
22
+
23
+ .nice-code-editor__loader {
24
+ color: var(--nice-text-secondary, #666);
25
+ font-size: 14px;
26
+ }
27
+
28
+ .nice-code-editor__error {
29
+ display: flex;
30
+ flex-direction: column;
31
+ width: 100%;
32
+ height: 100%;
33
+ padding: var(--nice-space-2, 8px);
34
+ gap: var(--nice-space-2, 8px);
35
+ }
36
+
37
+ .nice-code-editor__error span {
38
+ color: var(--nice-error, #d32f2f);
39
+ }
40
+
41
+ /* Simple code editor */
42
+ .nice-simple-code-editor {
43
+ display: flex;
44
+ border: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
45
+ border-radius: var(--nice-radius-sm, 4px);
46
+ overflow: hidden;
47
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
48
+ font-size: 14px;
49
+ line-height: 1.5;
50
+ background: var(--nice-bg-primary, var(--nice-bg-surface, #fff));
51
+ color: var(--nice-text-primary, var(--nice-text-primary, #333));
52
+ }
53
+ .nice-simple-code-editor--dark {
54
+ background: var(--nice-bg, #1e1e1e);
55
+ color: var(--nice-text, #d4d4d4);
56
+ }
57
+
58
+ .nice-simple-code-editor__line-numbers {
59
+ padding: var(--nice-space-2, 8px) 0;
60
+ background: var(--nice-bg-secondary, var(--nice-bg-tertiary, #f5f5f5));
61
+ border-right: 1px solid var(--nice-border-color, var(--nice-border, #e0e0e0));
62
+ user-select: none;
63
+ text-align: right;
64
+ color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
65
+ overflow: hidden;
66
+ }
67
+ .nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
68
+ background: var(--nice-bg-secondary, #252526);
69
+ border-right-color: var(--nice-border, #3c3c3c);
70
+ color: var(--nice-text-muted, #858585);
71
+ }
72
+
73
+ .nice-simple-code-editor__line-number {
74
+ padding: 0 var(--nice-space-3, 12px);
75
+ min-width: 40px;
76
+ }
77
+
78
+ .nice-simple-code-editor__editor-area {
79
+ position: relative;
80
+ flex: 1;
81
+ overflow: hidden;
82
+ }
83
+
84
+ .nice-simple-code-editor__highlight,
85
+ .nice-simple-code-editor__textarea {
86
+ position: absolute;
87
+ inset: 0;
88
+ margin: 0;
89
+ padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
90
+ border: 0;
91
+ font: inherit;
92
+ line-height: inherit;
93
+ white-space: pre;
94
+ overflow: auto;
95
+ tab-size: 2;
96
+ }
97
+
98
+ .nice-simple-code-editor__highlight {
99
+ pointer-events: none;
100
+ background: transparent;
101
+ color: inherit;
102
+ }
103
+ .nice-simple-code-editor__highlight code {
104
+ font: inherit;
105
+ background: transparent;
106
+ }
107
+
108
+ .nice-simple-code-editor__textarea {
109
+ background: transparent;
110
+ color: transparent;
111
+ caret-color: var(--nice-text-primary, var(--nice-text-primary, #333));
112
+ resize: none;
113
+ outline: none;
114
+ -webkit-text-fill-color: transparent;
115
+ }
116
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
117
+ caret-color: var(--nice-text, #d4d4d4);
118
+ }
119
+
120
+ .nice-simple-code-editor__textarea::placeholder {
121
+ color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
122
+ -webkit-text-fill-color: var(--nice-text-secondary, var(--nice-text-secondary, #999));
123
+ }
124
+ .nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
125
+ color: var(--nice-text-muted, #858585);
126
+ -webkit-text-fill-color: var(--nice-text-muted, #858585);
127
+ }
128
+ /* theme="auto": the page's theme colours in both light and dark (R43) — the --dark rules above
129
+ are for an explicit theme="dark" on a light page */
130
+ .nice-simple-code-editor--auto.nice-simple-code-editor--dark {
131
+ background: var(--nice-bg-primary);
132
+ color: var(--nice-text-primary);
133
+ }
134
+ .nice-simple-code-editor--auto.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
135
+ background: var(--nice-bg-secondary);
136
+ border-right-color: var(--nice-border-color);
137
+ color: var(--nice-text-secondary);
138
+ }
139
+ .nice-simple-code-editor--auto.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
140
+ caret-color: var(--nice-text-primary);
141
+ }
142
+ .nice-simple-code-editor--auto.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
143
+ color: var(--nice-text-secondary);
144
+ -webkit-text-fill-color: var(--nice-text-secondary);
145
+ }
146
+ .nice-simple-code-editor--auto.nice-simple-code-editor--dark .token.punctuation {
147
+ color: var(--nice-text-primary);
148
+ }
149
+
150
+ /* Prism token colors — light */
151
+ .nice-simple-code-editor .token.comment,
152
+ .nice-simple-code-editor .token.prolog,
153
+ .nice-simple-code-editor .token.doctype,
154
+ .nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
155
+ .nice-simple-code-editor .token.punctuation { color: #586069; }
156
+ .nice-simple-code-editor .token.property,
157
+ .nice-simple-code-editor .token.tag,
158
+ .nice-simple-code-editor .token.boolean,
159
+ .nice-simple-code-editor .token.number,
160
+ .nice-simple-code-editor .token.constant,
161
+ .nice-simple-code-editor .token.symbol,
162
+ .nice-simple-code-editor .token.deleted { color: #005cc5; }
163
+ .nice-simple-code-editor .token.selector,
164
+ .nice-simple-code-editor .token.attr-name,
165
+ .nice-simple-code-editor .token.string,
166
+ .nice-simple-code-editor .token.char,
167
+ .nice-simple-code-editor .token.builtin,
168
+ .nice-simple-code-editor .token.inserted { color: #032f62; }
169
+ .nice-simple-code-editor .token.operator,
170
+ .nice-simple-code-editor .token.entity,
171
+ .nice-simple-code-editor .token.url,
172
+ .nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
173
+ .nice-simple-code-editor .token.atrule,
174
+ .nice-simple-code-editor .token.attr-value,
175
+ .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
176
+ .nice-simple-code-editor .token.function,
177
+ .nice-simple-code-editor .token.class-name { color: #6f42c1; }
178
+ .nice-simple-code-editor .token.regex,
179
+ .nice-simple-code-editor .token.important { color: #e36209; }
180
+
181
+ /* Prism token colors — dark */
182
+ .nice-simple-code-editor--dark .token.comment,
183
+ .nice-simple-code-editor--dark .token.prolog,
184
+ .nice-simple-code-editor--dark .token.doctype,
185
+ .nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
186
+ .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
187
+ .nice-simple-code-editor--dark .token.property,
188
+ .nice-simple-code-editor--dark .token.tag,
189
+ .nice-simple-code-editor--dark .token.boolean,
190
+ .nice-simple-code-editor--dark .token.number,
191
+ .nice-simple-code-editor--dark .token.constant,
192
+ .nice-simple-code-editor--dark .token.symbol,
193
+ .nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
194
+ .nice-simple-code-editor--dark .token.selector,
195
+ .nice-simple-code-editor--dark .token.attr-name,
196
+ .nice-simple-code-editor--dark .token.string,
197
+ .nice-simple-code-editor--dark .token.char,
198
+ .nice-simple-code-editor--dark .token.builtin,
199
+ .nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
200
+ .nice-simple-code-editor--dark .token.operator,
201
+ .nice-simple-code-editor--dark .token.entity,
202
+ .nice-simple-code-editor--dark .token.url,
203
+ .nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
204
+ .nice-simple-code-editor--dark .token.atrule,
205
+ .nice-simple-code-editor--dark .token.attr-value,
206
+ .nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
207
+ .nice-simple-code-editor--dark .token.function,
208
+ .nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
209
+ .nice-simple-code-editor--dark .token.regex,
210
+ .nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
211
+
212
+ /* Toolbar */
213
+ .nice-code-editor-wrap {
214
+ border: 1px solid var(--nice-border, #e0e0e0);
215
+ border-radius: var(--nice-radius-sm, 4px);
216
+ overflow: hidden;
217
+ }
218
+ .nice-code-editor-wrap .nice-code-editor {
219
+ border: none;
220
+ border-radius: 0;
221
+ }
222
+ /* The editing surface draws no outline: while it has focus, the frame shows the ring
223
+ (TODO_1.3.0 I4). */
224
+ .nice-code-editor-wrap:has(.nice-code-editor:focus-within),
225
+ .nice-code-diff-editor:focus-within,
226
+ .nice-simple-code-editor:focus-within {
227
+ border-color: var(--nice-color-primary, #3b82f6);
228
+ box-shadow: var(--nice-focus-ring, 0 0 0 2px var(--nice-color-primary, #3b82f6));
229
+ }
230
+ .nice-code-editor__toolbar {
231
+ display: flex;
232
+ align-items: center;
233
+ gap: var(--nice-space-0-5, 2px);
234
+ padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
235
+ background: var(--nice-bg-tertiary, #f5f5f5);
236
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
237
+ }
238
+ .nice-code-editor__toolbar-btn {
239
+ display: inline-flex;
240
+ align-items: center;
241
+ justify-content: center;
242
+ width: 26px;
243
+ height: 26px;
244
+ border: none;
245
+ border-radius: var(--nice-radius-sm, 3px);
246
+ background: transparent;
247
+ color: var(--nice-text-secondary, #666);
248
+ cursor: pointer;
249
+ font-size: 14px;
250
+ transition: background 0.15s, color 0.15s;
251
+ }
252
+ .nice-code-editor__toolbar-btn:hover {
253
+ background: var(--nice-hover-bg, #e0e0e0);
254
+ color: var(--nice-text-primary, #333);
255
+ }
256
+ .nice-code-editor__toolbar-btn--active {
257
+ background: var(--nice-accent, #1976d2);
258
+ color: var(--nice-text-on-primary, #FFF);
259
+ }
260
+ .nice-code-editor__toolbar-sep {
261
+ width: 1px;
262
+ height: 18px;
263
+ background: var(--nice-border, #e0e0e0);
264
+ margin: 0 var(--nice-space-1, 4px);
265
+ }
266
+
267
+ /* Status bar */
268
+ .nice-code-editor__statusbar {
269
+ display: flex;
270
+ align-items: center;
271
+ gap: var(--nice-space-3, 12px);
272
+ padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
273
+ background: var(--nice-bg-tertiary, #f5f5f5);
274
+ border-top: 1px solid var(--nice-border, #e0e0e0);
275
+ font-size: 12px;
276
+ color: var(--nice-text-secondary, #666);
277
+ user-select: none;
278
+ }
279
+ .nice-code-editor__statusbar-spacer { flex: 1; }
280
+ .nice-code-editor__statusbar-lang {
281
+ text-transform: uppercase;
282
+ font-weight: 600;
283
+ font-size: 11px;
284
+ }
285
+ .nice-code-editor__statusbar-markers {
286
+ color: var(--nice-warning, #f39c12);
287
+ font-weight: 600;
288
+ }
289
+ `;exports.NiceCodeDiffEditor=Xe;exports.NiceCodeEditor=Ge;exports.NiceSimpleCodeEditor=rt;
@@ -1,4 +1,4 @@
1
- "use strict";const t=require("react/jsx-runtime"),y=require("@nice2dev/ui-core"),r=require("react"),pn=require("react-dom"),Wi=require("./NiceForm-Bysp66Ef.cjs"),qi=require("./devops-cgRBnZVX.cjs"),Vi=require("./NiceModal-BRVzjuUN.cjs"),Ui=require("./NicePagination-D7XxeNFz.cjs"),ys=require("./NiceSelect-BNPXs6FQ.cjs"),Hi=[],Ji=[{target:".nice-filterbuilder",titleKey:"tutorial.filterBuilder.intro.title",title:"Filter builder",contentKey:"tutorial.filterBuilder.intro.content",content:"Build complex AND/OR filter trees: add conditions and nested groups, choose fields and operators, and save reusable presets.",placement:"auto"}],Xi=[{value:"=",label:"Equals"},{value:"<>",label:"Not Equals"},{value:"<",label:"Less Than"},{value:"<=",label:"Less or Equal"},{value:">",label:"Greater Than"},{value:">=",label:"Greater or Equal"},{value:"contains",label:"Contains"},{value:"notcontains",label:"Not Contains"},{value:"startswith",label:"Starts With"},{value:"endswith",label:"Ends With"},{value:"isblank",label:"Is Blank"},{value:"isnotblank",label:"Is Not Blank"}],Yi=({condition:l,fields:x,onChange:m,onRemove:_})=>{const{t:b}=y.useNiceTranslation(),h=x.find(g=>g.field===l.field),N=l.operator==="isblank"||l.operator==="isnotblank",S=h?.operators||Xi;return t.jsxs("div",{className:"nice-filterbuilder__condition",children:[t.jsx("select",{className:"nice-filterbuilder__select",value:l.field,onChange:g=>m({...l,field:g.target.value,value:""}),children:x.map(g=>t.jsx("option",{value:g.field,children:g.label},g.field))}),t.jsx("select",{className:"nice-filterbuilder__select",value:l.operator,onChange:g=>m({...l,operator:g.target.value}),children:S.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))}),!N&&(h?.options?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value}),children:[t.jsx("option",{value:"",children:"--"}),h.options.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]}):h?.type==="boolean"?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value==="true"}),children:[t.jsx("option",{value:"true",children:b("filterBuilder.true","True")}),t.jsx("option",{value:"false",children:b("filterBuilder.false","False")})]}):t.jsx("input",{className:"nice-filterbuilder__input",type:h?.type==="number"?"number":h?.type==="date"?"date":"text",value:String(l.value??""),onChange:g=>m({...l,value:h?.type==="number"?Number(g.target.value):g.target.value})})),t.jsx("button",{"aria-label":b("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]})},vs=({group:l,fields:x,onChange:m,onRemove:_,depth:b,maxDepth:h})=>{const{t:N}=y.useNiceTranslation(),[S,g]=r.useState(!1),Z=()=>m({...l,logic:l.logic==="and"?"or":"and"}),K=l.items.filter(C=>C.type==="condition").length,ee=l.items.length-K,de=[K?`${K} condition${K>1?"s":""}`:"",ee?`${ee} group${ee>1?"s":""}`:""].filter(Boolean).join(" · ")||"empty",ue=()=>{const C={type:"condition",field:x[0]?.field||"",operator:"=",value:""};m({...l,items:[...l.items,C]})},fe=()=>{if(b>=h)return;const C={type:"group",logic:"and",items:[]};m({...l,items:[...l.items,C]})},M=(C,R)=>{const k=[...l.items];k[C]=R,m({...l,items:k})},te=C=>{m({...l,items:l.items.filter((R,k)=>k!==C)})};return t.jsxs("div",{className:`nice-filterbuilder__group nice-filterbuilder__group--depth-${Math.min(b,3)}`,children:[t.jsxs("div",{className:"nice-filterbuilder__group-header",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__collapse",onClick:()=>g(C=>!C),"aria-expanded":!S,title:S?N("filterBuilder.expandGroup","Expand group"):N("filterBuilder.collapseGroup","Collapse group"),children:t.jsx(y.NiceIcon,{name:S?"chevron-right":"chevron-down",size:"sm"})}),t.jsx("button",{className:"nice-filterbuilder__logic",onClick:Z,title:N("filterBuilder.matchClickToSwitch","Match {mode} — click to switch to {other}").replace("{mode}",l.logic==="and"?N("filterBuilder.matchAll","ALL"):N("filterBuilder.matchAny","ANY")).replace("{other}",l.logic==="and"?"OR":"AND"),children:l.logic.toUpperCase()}),S?t.jsx("span",{className:"nice-filterbuilder__summary",children:de}):t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:ue,children:N("filterBuilder.condition","+ Condition")}),b<h&&t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:fe,children:N("filterBuilder.group","+ Group")})]}),_&&t.jsx("button",{"aria-label":N("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]}),!S&&t.jsx("div",{className:"nice-filterbuilder__group-body",children:l.items.map((C,R)=>t.jsx(r.Fragment,{children:C.type==="condition"?t.jsx(Yi,{condition:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R)}):t.jsx(vs,{group:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R),depth:b+1,maxDepth:h})},R))})]})},xn=({fields:l=Hi,value:x,defaultValue:m,onChange:_,maxDepth:b=3,presets:h,onSavePreset:N,onDeletePreset:S,tutorial:g,className:Z,style:K,"data-testid":ee})=>{const{t:de}=y.useNiceTranslation(),[ue,fe]=y.useControllableState({value:x,defaultValue:m,fallbackValue:{type:"group",logic:"and",items:[]},onChange:_,componentName:"NiceFilterBuilder"}),[M,te]=r.useState(""),C=r.useCallback(k=>{const Qe=h?.find(ze=>ze.name===k);Qe&&fe(structuredClone(Qe.filter))},[h,fe]),R=r.useCallback(()=>{!M.trim()||!N||(N({name:M.trim(),filter:structuredClone(ue)}),te(""))},[M,ue,N]);return t.jsxs("div",{className:`nice-filterbuilder ${Z||""}`,style:{position:"relative",...K},"data-testid":ee,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(g,Ji)})}),(h?.length||N)&&t.jsxs("div",{className:"nice-filterbuilder__presets",children:[h&&h.length>0&&t.jsx("div",{className:"nice-filterbuilder__preset-list",children:h.map(k=>t.jsxs("span",{className:"nice-filterbuilder__preset-tag",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__preset-btn",onClick:()=>C(k.name),children:k.name}),S&&t.jsx("button",{"aria-label":de("filterBuilder.close","Close"),type:"button",className:"nice-filterbuilder__preset-del",onClick:()=>S(k.name),children:t.jsx(y.NiceIcon,{name:"close",size:14})})]},k.name))}),N&&t.jsxs("div",{className:"nice-filterbuilder__preset-save",children:[t.jsx("input",{className:"nice-filterbuilder__input",value:M,onChange:k=>te(k.target.value),placeholder:de("filterBuilder.presetName","Preset name...")}),t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:R,disabled:!M.trim(),children:de("filterBuilder.save","Save")})]})]}),t.jsx(vs,{group:ue,fields:l,onChange:fe,depth:0,maxDepth:b})]})};process.env.NODE_ENV!=="production"&&(xn.displayName="NiceFilterBuilder");const js="nice-datagrid-";function mn(l){if(typeof window>"u")return null;try{const x=window.localStorage.getItem(js+l);return x?JSON.parse(x):null}catch{return null}}function _s(l,x){if(!(typeof window>"u"))try{window.localStorage.setItem(js+l,x)}catch{}}function Ns(l){const x={};return Object.keys(l.columnWidths).length>0&&(x.columnWidths=l.columnWidths),l.columnOrder&&l.columnOrder.length>0&&(x.columnOrder=l.columnOrder),l.hiddenColumns&&l.hiddenColumns.length>0&&(x.hiddenColumns=l.hiddenColumns),l.sortField&&l.sortDirection&&(x.sortField=l.sortField,x.sortDirection=l.sortDirection),l.pageSize!==void 0&&(x.pageSize=l.pageSize),l.expandedGroups.size>0&&(x.expandedGroups=Array.from(l.expandedGroups)),x}function Cs(l,x,m){const _=l.map(b=>b[x]).filter(b=>typeof b=="number");if(_.length===0)return m==="count"?"0":"";switch(m){case"sum":return _.reduce((b,h)=>b+h,0).toLocaleString();case"avg":return(_.reduce((b,h)=>b+h,0)/_.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(l.length);case"min":return Math.min(..._).toLocaleString();case"max":return Math.max(..._).toLocaleString()}}function Ss(l,x){const m=/^([^#0,.]*)([#0,]+(?:\.[#0]+)?)(.*)$/.exec(x);if(!m)return String(l);const[,_,b,h]=m,[N,S=""]=b.split("."),g=new Intl.NumberFormat(void 0,{useGrouping:N.includes(","),minimumIntegerDigits:Math.min(21,Math.max(1,(N.match(/0/g)??[]).length)),minimumFractionDigits:(S.match(/0/g)??[]).length,maximumFractionDigits:S.length}).format(l);return`${_}${g}${h}`}function gn(l,x,m=40){let _=m;return l.querySelectorAll(`[data-field="${x.replace(/["\\]/g,"\\$&")}"]`).forEach(h=>{let N=h.scrollWidth;const S=typeof document.createRange=="function"?document.createRange():null;if(S&&typeof S.getBoundingClientRect=="function"){S.selectNodeContents(h);const g=S.getBoundingClientRect().width;if(g>0){const Z=window.getComputedStyle(h),K=(parseFloat(Z.paddingLeft)||0)+(parseFloat(Z.paddingRight)||0);N=Math.ceil(g+K)}}_=Math.max(_,N)}),_}function hn(l,x){const m=new Map(l.map(b=>[b.field,b])),_=[];for(const b of x){const h=m.get(b);h&&(_.push(h),m.delete(b))}return[..._,...l.filter(b=>m.has(b.field))]}function ks(l,x){const m=[];for(const _ of l){const b=x.find(N=>N.columns.includes(_))??null,h=m[m.length-1];h&&h.group===b?h.span+=1:m.push({group:b,span:1})}return m}function Ye(l){return l.includes(",")||l.includes('"')||l.includes(`
1
+ "use strict";const t=require("react/jsx-runtime"),y=require("@nice2dev/ui-core"),r=require("react"),pn=require("react-dom"),Wi=require("./NiceForm-CT9hEXpc.cjs"),qi=require("./devops-cgRBnZVX.cjs"),Vi=require("./NiceModal-BRVzjuUN.cjs"),Ui=require("./NicePagination-D7XxeNFz.cjs"),ys=require("./NiceSelect-BNPXs6FQ.cjs"),Hi=[],Ji=[{target:".nice-filterbuilder",titleKey:"tutorial.filterBuilder.intro.title",title:"Filter builder",contentKey:"tutorial.filterBuilder.intro.content",content:"Build complex AND/OR filter trees: add conditions and nested groups, choose fields and operators, and save reusable presets.",placement:"auto"}],Xi=[{value:"=",label:"Equals"},{value:"<>",label:"Not Equals"},{value:"<",label:"Less Than"},{value:"<=",label:"Less or Equal"},{value:">",label:"Greater Than"},{value:">=",label:"Greater or Equal"},{value:"contains",label:"Contains"},{value:"notcontains",label:"Not Contains"},{value:"startswith",label:"Starts With"},{value:"endswith",label:"Ends With"},{value:"isblank",label:"Is Blank"},{value:"isnotblank",label:"Is Not Blank"}],Yi=({condition:l,fields:x,onChange:m,onRemove:_})=>{const{t:b}=y.useNiceTranslation(),h=x.find(g=>g.field===l.field),N=l.operator==="isblank"||l.operator==="isnotblank",S=h?.operators||Xi;return t.jsxs("div",{className:"nice-filterbuilder__condition",children:[t.jsx("select",{className:"nice-filterbuilder__select",value:l.field,onChange:g=>m({...l,field:g.target.value,value:""}),children:x.map(g=>t.jsx("option",{value:g.field,children:g.label},g.field))}),t.jsx("select",{className:"nice-filterbuilder__select",value:l.operator,onChange:g=>m({...l,operator:g.target.value}),children:S.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))}),!N&&(h?.options?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value}),children:[t.jsx("option",{value:"",children:"--"}),h.options.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]}):h?.type==="boolean"?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value==="true"}),children:[t.jsx("option",{value:"true",children:b("filterBuilder.true","True")}),t.jsx("option",{value:"false",children:b("filterBuilder.false","False")})]}):t.jsx("input",{className:"nice-filterbuilder__input",type:h?.type==="number"?"number":h?.type==="date"?"date":"text",value:String(l.value??""),onChange:g=>m({...l,value:h?.type==="number"?Number(g.target.value):g.target.value})})),t.jsx("button",{"aria-label":b("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]})},vs=({group:l,fields:x,onChange:m,onRemove:_,depth:b,maxDepth:h})=>{const{t:N}=y.useNiceTranslation(),[S,g]=r.useState(!1),Z=()=>m({...l,logic:l.logic==="and"?"or":"and"}),K=l.items.filter(C=>C.type==="condition").length,ee=l.items.length-K,de=[K?`${K} condition${K>1?"s":""}`:"",ee?`${ee} group${ee>1?"s":""}`:""].filter(Boolean).join(" · ")||"empty",ue=()=>{const C={type:"condition",field:x[0]?.field||"",operator:"=",value:""};m({...l,items:[...l.items,C]})},fe=()=>{if(b>=h)return;const C={type:"group",logic:"and",items:[]};m({...l,items:[...l.items,C]})},M=(C,R)=>{const k=[...l.items];k[C]=R,m({...l,items:k})},te=C=>{m({...l,items:l.items.filter((R,k)=>k!==C)})};return t.jsxs("div",{className:`nice-filterbuilder__group nice-filterbuilder__group--depth-${Math.min(b,3)}`,children:[t.jsxs("div",{className:"nice-filterbuilder__group-header",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__collapse",onClick:()=>g(C=>!C),"aria-expanded":!S,title:S?N("filterBuilder.expandGroup","Expand group"):N("filterBuilder.collapseGroup","Collapse group"),children:t.jsx(y.NiceIcon,{name:S?"chevron-right":"chevron-down",size:"sm"})}),t.jsx("button",{className:"nice-filterbuilder__logic",onClick:Z,title:N("filterBuilder.matchClickToSwitch","Match {mode} — click to switch to {other}").replace("{mode}",l.logic==="and"?N("filterBuilder.matchAll","ALL"):N("filterBuilder.matchAny","ANY")).replace("{other}",l.logic==="and"?"OR":"AND"),children:l.logic.toUpperCase()}),S?t.jsx("span",{className:"nice-filterbuilder__summary",children:de}):t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:ue,children:N("filterBuilder.condition","+ Condition")}),b<h&&t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:fe,children:N("filterBuilder.group","+ Group")})]}),_&&t.jsx("button",{"aria-label":N("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]}),!S&&t.jsx("div",{className:"nice-filterbuilder__group-body",children:l.items.map((C,R)=>t.jsx(r.Fragment,{children:C.type==="condition"?t.jsx(Yi,{condition:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R)}):t.jsx(vs,{group:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R),depth:b+1,maxDepth:h})},R))})]})},xn=({fields:l=Hi,value:x,defaultValue:m,onChange:_,maxDepth:b=3,presets:h,onSavePreset:N,onDeletePreset:S,tutorial:g,className:Z,style:K,"data-testid":ee})=>{const{t:de}=y.useNiceTranslation(),[ue,fe]=y.useControllableState({value:x,defaultValue:m,fallbackValue:{type:"group",logic:"and",items:[]},onChange:_,componentName:"NiceFilterBuilder"}),[M,te]=r.useState(""),C=r.useCallback(k=>{const Qe=h?.find(ze=>ze.name===k);Qe&&fe(structuredClone(Qe.filter))},[h,fe]),R=r.useCallback(()=>{!M.trim()||!N||(N({name:M.trim(),filter:structuredClone(ue)}),te(""))},[M,ue,N]);return t.jsxs("div",{className:`nice-filterbuilder ${Z||""}`,style:{position:"relative",...K},"data-testid":ee,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(g,Ji)})}),(h?.length||N)&&t.jsxs("div",{className:"nice-filterbuilder__presets",children:[h&&h.length>0&&t.jsx("div",{className:"nice-filterbuilder__preset-list",children:h.map(k=>t.jsxs("span",{className:"nice-filterbuilder__preset-tag",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__preset-btn",onClick:()=>C(k.name),children:k.name}),S&&t.jsx("button",{"aria-label":de("filterBuilder.close","Close"),type:"button",className:"nice-filterbuilder__preset-del",onClick:()=>S(k.name),children:t.jsx(y.NiceIcon,{name:"close",size:14})})]},k.name))}),N&&t.jsxs("div",{className:"nice-filterbuilder__preset-save",children:[t.jsx("input",{className:"nice-filterbuilder__input",value:M,onChange:k=>te(k.target.value),placeholder:de("filterBuilder.presetName","Preset name...")}),t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:R,disabled:!M.trim(),children:de("filterBuilder.save","Save")})]})]}),t.jsx(vs,{group:ue,fields:l,onChange:fe,depth:0,maxDepth:b})]})};process.env.NODE_ENV!=="production"&&(xn.displayName="NiceFilterBuilder");const js="nice-datagrid-";function mn(l){if(typeof window>"u")return null;try{const x=window.localStorage.getItem(js+l);return x?JSON.parse(x):null}catch{return null}}function _s(l,x){if(!(typeof window>"u"))try{window.localStorage.setItem(js+l,x)}catch{}}function Ns(l){const x={};return Object.keys(l.columnWidths).length>0&&(x.columnWidths=l.columnWidths),l.columnOrder&&l.columnOrder.length>0&&(x.columnOrder=l.columnOrder),l.hiddenColumns&&l.hiddenColumns.length>0&&(x.hiddenColumns=l.hiddenColumns),l.sortField&&l.sortDirection&&(x.sortField=l.sortField,x.sortDirection=l.sortDirection),l.pageSize!==void 0&&(x.pageSize=l.pageSize),l.expandedGroups.size>0&&(x.expandedGroups=Array.from(l.expandedGroups)),x}function Cs(l,x,m){const _=l.map(b=>b[x]).filter(b=>typeof b=="number");if(_.length===0)return m==="count"?"0":"";switch(m){case"sum":return _.reduce((b,h)=>b+h,0).toLocaleString();case"avg":return(_.reduce((b,h)=>b+h,0)/_.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(l.length);case"min":return Math.min(..._).toLocaleString();case"max":return Math.max(..._).toLocaleString()}}function Ss(l,x){const m=/^([^#0,.]*)([#0,]+(?:\.[#0]+)?)(.*)$/.exec(x);if(!m)return String(l);const[,_,b,h]=m,[N,S=""]=b.split("."),g=new Intl.NumberFormat(void 0,{useGrouping:N.includes(","),minimumIntegerDigits:Math.min(21,Math.max(1,(N.match(/0/g)??[]).length)),minimumFractionDigits:(S.match(/0/g)??[]).length,maximumFractionDigits:S.length}).format(l);return`${_}${g}${h}`}function gn(l,x,m=40){let _=m;return l.querySelectorAll(`[data-field="${x.replace(/["\\]/g,"\\$&")}"]`).forEach(h=>{let N=h.scrollWidth;const S=typeof document.createRange=="function"?document.createRange():null;if(S&&typeof S.getBoundingClientRect=="function"){S.selectNodeContents(h);const g=S.getBoundingClientRect().width;if(g>0){const Z=window.getComputedStyle(h),K=(parseFloat(Z.paddingLeft)||0)+(parseFloat(Z.paddingRight)||0);N=Math.ceil(g+K)}}_=Math.max(_,N)}),_}function hn(l,x){const m=new Map(l.map(b=>[b.field,b])),_=[];for(const b of x){const h=m.get(b);h&&(_.push(h),m.delete(b))}return[..._,...l.filter(b=>m.has(b.field))]}function ks(l,x){const m=[];for(const _ of l){const b=x.find(N=>N.columns.includes(_))??null,h=m[m.length-1];h&&h.group===b?h.span+=1:m.push({group:b,span:1})}return m}function Ye(l){return l.includes(",")||l.includes('"')||l.includes(`
2
2
  `)?`"${l.replace(/"/g,'""')}"`:l}const ye={width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},Qi=()=>t.jsx("svg",{...ye,children:t.jsx("polyline",{points:"6 15 12 9 18 15"})}),Je=()=>t.jsx("svg",{...ye,children:t.jsx("polyline",{points:"6 9 12 15 18 9"})}),Zi=()=>t.jsxs("svg",{...ye,style:{opacity:.55},children:[t.jsx("polyline",{points:"6 10 12 5 18 10"}),t.jsx("polyline",{points:"6 14 12 19 18 14"})]}),jt=()=>t.jsx("svg",{...ye,children:t.jsx("polyline",{points:"9 6 15 12 9 18"})}),ea=()=>t.jsxs("svg",{...ye,children:[t.jsx("polyline",{points:"3 17 9 11 13 15 21 7"}),t.jsx("polyline",{points:"14 7 21 7 21 14"})]}),ta=()=>t.jsxs("svg",{...ye,children:[t.jsx("polyline",{points:"3 7 9 13 13 9 21 17"}),t.jsx("polyline",{points:"14 17 21 17 21 10"})]}),na=()=>t.jsx("svg",{...ye,children:t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})}),sa=40,Xe=l=>l.stopPropagation(),ia=[];function aa(l){return typeof l=="boolean"?l?t.jsx(y.NiceIcon,{name:"check",size:16,className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--true",title:"true"}):t.jsx(y.NiceIcon,{name:"close",size:16,className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--false",title:"false"}):String(l??"")}function bn({columns:l=ia,data:x,keyField:m="id",dataSource:_,sortable:b=!0,sortField:h,sortDirection:N,onSort:S,showAdvancedFilter:g,advancedFilter:Z,onAdvancedFilterChange:K,filterFields:ee,filterPresets:de,onSaveFilterPreset:ue,onDeleteFilterPreset:fe,selectable:M,selectedKeys:te,onSelectionChange:C,pagination:R,pageSize:k=10,page:Qe,onPageChange:ze,totalRows:yn,autoPagination:ne=!1,stickyHeader:_t=!0,stickyFooter:ws=!0,searchable:vn,searchPlaceholder:Ms,virtualScroll:X,rowHeight:W=40,groupBy:Nt,groupRender:Ze,onCellEdit:$,editMode:Re="inline",formItems:Ds,formColumns:Is=2,editFormTitle:zs,formProps:Rs,onRowEdit:et,onRowAdd:tt,onRowDelete:ve,confirmDelete:nt,bulkActions:Ct,onBulkDelete:St,exportCsv:jn,exportFilename:_n="export",detailRow:q,expandedRowKeys:As,onExpandedRowChange:kt,columnReorder:Es,onColumnReorder:Nn,columnResize:wt,rowDraggable:z,onRowReorder:st,striped:Os,compact:Ts,size:Mt,loading:$s,emptyText:Fs,toolbar:Cn,onRowClick:pe,pinnedTopKeys:Dt,pinnedBottomKeys:It,colSpan:Sn,showStatusBar:Ls,contextMenuItems:it,onContextMenuAction:Ps,printFriendly:Bs,keyboardNavigation:Ae,focusedCell:Gs,onFocusedCellChange:zt,cellRangeSelection:kn,selectedCellRange:Ks,onCellRangeChange:Rt,clipboard:me,clipboardFormat:At="text",onBeforeCopy:wn,onCopy:Mn,onPaste:Et,quickFilters:se,activeQuickFilters:Ws,onQuickFilterChange:Ot,columnGroups:Tt,stateStorageKey:U,initialState:qs,onStateChange:Dn,flashRowKeys:$t,flashDuration:In=500,autoFitColumns:Ft,showColumnStats:Ee,rowIndicator:Oe,frozenRows:Vs,className:Us,style:Hs,accessMode:Js,id:Xs,displayStyle:zn,disabled:Ys,readOnly:Rn,error:Lt}){const Pt=y.useNiceAccessMode(Js,Xs),Qs=Pt==="hidden",je=Ys||Pt==="disabled",Te=Rn||je||Pt==="readOnly",ie=!!ve&&!Te,ge=Math.max(0,Math.floor(Vs??0)),{t:u}=y.useNiceTranslation();y.useComponentDisplayStyle("table",zn),y.useComponentDisplayClass("table",zn);const D=y.useNiceDataSource(_??null,{autoLoad:!!_,defaultPageSize:k}),w=!!_,Bt=r.useMemo(()=>w?D.data:x??[],[w,D.data,x]),at=w?D.loading:$s,[O]=r.useState(()=>qs??(U?mn(U):null)),[An,En]=r.useState(()=>({field:O?.sortField??"",dir:O?.sortDirection??null})),[Zs,ei]=r.useState(1),[ti,Gt]=r.useState(new Set),[rt,ni]=r.useState(""),[si,ii]=r.useState({type:"group",logic:"and",items:[]}),[On,Tn]=r.useState(!1),ae=Z??si,$n=e=>{K?K(e):ii(e)},ai=r.useMemo(()=>ee??l.filter(e=>e.filterable!==!1&&e.field).map(e=>({field:String(e.field),label:String(e.header??e.field)})),[ee,l]),he=ae.items.length,[lt,Fn]=r.useState(O?.pageSize??k),[re,Kt]=r.useState(null),[ot,$e]=r.useState(null),[_e,xe]=r.useState(null),[Wt,Ln]=r.useState(()=>new Set(O?.expandedGroups??[])),[qt,ri]=r.useState(0),ct=r.useRef(null),[li,oi]=r.useState(new Set),dt=As??li,[Fe,Vt]=r.useState(()=>O?.columnWidths??{}),[Ne,Ce]=r.useState(null),[Se,Ut]=r.useState(null),[Ht,Jt]=r.useState(null),[ci,di]=r.useState(null),[ui,fi]=r.useState(null),[pi,mi]=r.useState([]),[ke,Xt]=r.useState(null),Yt=r.useRef(null),[ut,Qt]=r.useState(()=>O?.hiddenColumns??[]),[Le,Pn]=r.useState(()=>O?.columnOrder??null),[Zt,en]=r.useState(null),[Bn,ft]=r.useState(null),tn=r.useRef(null),[gi,Gn]=r.useState(new Set),[Pe,nn]=r.useState(null),Kn=r.useRef(null),[hi,xi]=r.useState({}),le=r.useRef(null),[bi,yi]=r.useState(k);r.useEffect(()=>{if(!ne)return;const e=ct.current;if(!e||typeof ResizeObserver>"u")return;const n=()=>{const i=e.clientHeight;if(i<=0)return;const a=Math.max(1,Math.floor(i/W)-1);yi(o=>o===a?o:a),w&&D.setPageSize(a)};n();const s=new ResizeObserver(n);return s.observe(e),()=>s.disconnect()},[ne,W,w]);const B=Gs??ci,F=Ks??ui,H=Ws??pi,Wn=r.useRef(U);r.useEffect(()=>{if(Wn.current===U)return;Wn.current=U;const e=U?mn(U):null;e&&(Vt(e.columnWidths??{}),Ln(new Set(e.expandedGroups??[])),Qt(e.hiddenColumns??[]),Pn(e.columnOrder??null),En({field:e.sortField??"",dir:e.sortDirection??null}),e.pageSize!==void 0&&Fn(e.pageSize))},[U]),r.useEffect(()=>{!w||!O||(O.sortField&&O.sortDirection&&D.setSortField(O.sortField,O.sortDirection),O.pageSize!==void 0&&!ne&&D.setPageSize(O.pageSize))},[]),r.useEffect(()=>{if(!$t?.size)return;Gn(new Set($t));const e=setTimeout(()=>Gn(new Set),In);return()=>clearTimeout(e)},[$t,In]),r.useEffect(()=>{if(!Se)return;const e=()=>Ut(null);return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Se]);const vi=r.useCallback((e,n)=>{it?.length&&(e.preventDefault(),Ut({x:e.clientX,y:e.clientY,row:n}))},[it]),qn=r.useCallback(e=>{const n=new Set(dt);n.has(e)?n.delete(e):n.add(e),kt?kt(n):oi(n)},[dt,kt]),ji=r.useCallback((e,n)=>{if(!wt)return;n.preventDefault();const s=n.clientX,a=n.target.closest("th")?.offsetWidth??100,o=f=>{const d=Math.max(40,a+f.clientX-s);Vt(j=>({...j,[e]:d}))},c=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",c)},[wt]),J=w?D.sort[0]?.field??"":h??An.field,G=w?D.sort[0]?.direction??null:N??An.dir,we=w?D.page:Qe??Zs,I=te??ti,Y=r.useMemo(()=>Le?hn(l,Le):l,[l,Le]),T=r.useMemo(()=>Y.filter(e=>!e.hidden&&!ut.includes(e.field)),[Y,ut]),sn=r.useMemo(()=>T.filter(e=>e.pinned==="left"),[T]),pt=r.useMemo(()=>T.filter(e=>e.pinned==="right"),[T]),Vn=r.useMemo(()=>T.filter(e=>!e.pinned),[T]),v=r.useMemo(()=>[...sn,...Vn,...pt],[sn,Vn,pt]),_i=r.useMemo(()=>T.some(e=>e.aggregate),[T]),Be=sn.length>0||pt.length>0,an=r.useMemo(()=>{if(!Tt?.length)return null;const e=ks(v.map(n=>n.field),Tt);return e.some(n=>n.group)?e:null},[Tt,v]),Ge=r.useCallback((e,n)=>{w?n?D.setSortField(e,n):D.setSort([]):S?S(e,n):En({field:e,dir:n})},[w,D,S]),Un=r.useCallback(e=>{Ge(e,J===e?G==="asc"?"desc":G==="desc"?null:"asc":"asc")},[J,G,Ge]),L=r.useMemo(()=>{if(w)return Bt;let e=[...Bt];if(rt){const n=rt.toLowerCase();e=e.filter(s=>T.some(i=>String(s[i.field]??"").toLowerCase().includes(n)))}return ae.items.length>0&&(e=e.filter(n=>y.matchesFilterGroup(n,ae))),!S&&J&&G&&e.sort((n,s)=>{const i=n[J]??"",a=s[J]??"",o=typeof i=="number"?i-a:String(i).localeCompare(String(a));return G==="desc"?-o:o}),e},[Bt,rt,ae,T,J,G,S,w]),mt=w?D.totalCount:yn??L.length,oe=ne?bi:w?D.pageSize:lt,rn=Math.max(1,Math.ceil(mt/oe)),V=w?L:R&&!yn?L.slice((we-1)*oe,we*oe):L,Ke=r.useCallback(e=>{w?D.setPage(e):ze?ze(e):ei(e)},[w,D,ze]);y.useIntent(["pagePrev","pageNext"],e=>{const n=we+(e.intent==="pageNext"?1:-1);if(e.source==="keyboard"||n<1||n>rn)return!1;Ke(n)},{ref:le,enabled:!!R}),y.useInputHints(le,[{intent:"pagePrev",label:u("input.intent.pagePrev","Previous page")},{intent:"pageNext",label:u("input.intent.pageNext","Next page")}],{enabled:!!R&&rn>1});const We=JSON.stringify(Ns({columnWidths:Fe,sortField:J,sortDirection:G,pageSize:ne?void 0:oe,expandedGroups:Wt,hiddenColumns:ut,columnOrder:Le??void 0})),Hn=r.useRef(Dn);Hn.current=Dn;const ln=r.useRef(U);ln.current=U;const gt=r.useRef(null),qe=r.useRef(null),ht=r.useCallback(e=>{gt.current=e,qe.current=null,ln.current&&_s(ln.current,e),Hn.current?.(JSON.parse(e))},[]);r.useEffect(()=>{if(gt.current===null){gt.current=We;return}if(We===gt.current){qe.current=null;return}qe.current=We;const e=setTimeout(()=>ht(We),300);return()=>clearTimeout(e)},[We,ht]),r.useEffect(()=>()=>{qe.current!==null&&ht(qe.current)},[ht]);const on=r.useCallback(()=>{Xt(null),Yt.current?.focus()},[]),Q=ys.useAnchoredPopup(ke!==null,Yt,on),Jn=Q.popupRef,Xn=Q.ready;r.useEffect(()=>{ke===null||!Xn||Jn.current?.querySelector('[role="menuitem"]:not(:disabled)')?.focus()},[ke,Xn,Jn]);const Ni=r.useCallback(e=>{const n=le.current;if(!n)return;const s=l.find(a=>a.field===e),i=gn(n,e,s?.minWidth??40);Vt(a=>({...a,[e]:i}))},[l]),Yn=r.useId(),Ci=r.useCallback(()=>nn(null),[]),be=ys.useAnchoredPopup(Pe!==null,Kn,Ci,{anchorKey:Pe}),Qn=(e,n)=>{Kn.current=e.currentTarget,nn(n)},Zn=e=>nn(n=>n===e?null:n),es=r.useCallback((e,n)=>{const s=Y.findIndex(c=>c.field===e),i=Y.findIndex(c=>c.field===n);if(s<0||i<0||s===i||(Y[s].pinned??null)!==(Y[i].pinned??null))return;const a=Y.map(c=>c.field).filter(c=>c!==e),o=a.indexOf(n)+(s<i?1:0);a.splice(o,0,e),Pn(a),Nn?.(hn(l,a))},[Y,l,Nn]);r.useEffect(()=>{const e=tn.current;e&&(tn.current=null,le.current?.querySelector(`thead th[data-field="${e.replace(/["\\]/g,"\\$&")}"]`)?.focus())},[Le]);const Si=e=>{ae.items.some(s=>s.type==="condition"&&s.field===e)||$n({...ae,items:[...ae.items,{type:"condition",field:e,operator:"contains",value:""}]}),Tn(!0)},ki=e=>{e(),on()},wi=e=>{const n=Array.from(e.currentTarget.querySelectorAll('[role="menuitem"]:not(:disabled)'));if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const s=e.key==="ArrowDown"?1:-1,i=n.indexOf(document.activeElement),a=i<0?s>0?0:n.length-1:(i+s+n.length)%n.length;n[a]?.focus()}else e.key==="Tab"&&Xt(null)},Me=r.useMemo(()=>V.map(e=>String(e[m])),[V,m]),De=Me.length>0&&Me.every(e=>I.has(e)),ts=Me.some(e=>I.has(e)),ns=r.useCallback(()=>{const e=new Set(I);De?Me.forEach(n=>e.delete(n)):Me.forEach(n=>e.add(n)),C?C(e):Gt(e)},[De,Me,I,C]),ss=r.useCallback(e=>{const n=new Set(I);n.has(e)?n.delete(e):n.add(e),C?C(n):Gt(n)},[I,C]),Mi=({field:e})=>J!==e||!G?t.jsx("span",{className:"nice-table__sort-icon",children:t.jsx(Zi,{})}):t.jsx("span",{className:"nice-table__sort-icon",children:G==="asc"?t.jsx(Qi,{}):t.jsx(Je,{})}),A=r.useMemo(()=>{if(!Nt)return V.map((s,i)=>({type:"data",row:s,key:String(s[m]??i)}));const e=new Map;V.forEach(s=>{const i=s[Nt];e.has(i)||e.set(i,[]),e.get(i).push(s)});const n=[];return e.forEach((s,i)=>{const a=`__group_${String(i)}`,o=Wt.has(a);n.push({type:"group",value:i,rows:s,expanded:o,key:a}),o&&s.forEach((c,f)=>n.push({type:"data",row:c,key:String(c[m]??`${a}_${f}`)}))}),n},[V,Nt,m,Wt]),{pinnedTopRows:cn,pinnedBottomRows:Di,normalRows:dn}=r.useMemo(()=>{if(!Dt?.size&&!It?.size)return{pinnedTopRows:[],pinnedBottomRows:[],normalRows:A};const e=[],n=[],s=[];for(const i of A){if(i.type==="data"){const a=i.key;if(Dt?.has(a)){e.push(i);continue}if(It?.has(a)){n.push(i);continue}}s.push(i)}return{pinnedTopRows:e,pinnedBottomRows:n,normalRows:s}},[A,Dt,It]),is=r.useCallback(e=>{Ln(n=>{const s=new Set(n);return s.has(e)?s.delete(e):s.add(e),s})},[]),as=r.useMemo(()=>{if(!X)return A;const e=ct.current?.clientHeight??400,n=Math.ceil(e/W),s=Math.max(0,Math.floor(qt/W)-3),i=Math.min(A.length-1,s+n+6),a=A.slice(s,i+1).map((c,f)=>({...c,_vIdx:s+f}));return[...A.slice(0,Math.min(ge,s)).map((c,f)=>({...c,_vIdx:f})),...a]},[X,A,qt,W,ge]),Ve=r.useMemo(()=>ge>0?[...cn,...dn].slice(0,ge).map(e=>e.key):[],[ge,cn,dn]),[Ii,zi]=r.useState([]);r.useLayoutEffect(()=>{if(X||Ve.length===0)return;const e=ct.current?.querySelector("table");if(!e)return;const n=Array.from(e.tBodies[0]?.rows??[]);let s=_t?e.tHead?.offsetHeight??0:0;const i=Ve.map(a=>{const o=s;return s+=n.find(c=>c.dataset.rowKey===a)?.offsetHeight??0,o});zi(a=>a.length===i.length&&a.every((o,c)=>o===i[c])?a:i)},[X,Ve,_t,Fe,v,an]);const rs=e=>{const n=Ve.indexOf(e);return n<0?{className:""}:{className:n===Ve.length-1?"nice-datagrid__row--frozen nice-datagrid__row--frozen-last":"nice-datagrid__row--frozen",style:{position:"sticky",top:Ii[n]??0,zIndex:2}}};r.useLayoutEffect(()=>{const e=le.current;if(!Ft||!e)return;const n={};for(const s of v)s.width===void 0&&Fe[s.field]===void 0&&(n[s.field]=gn(e,s.field,s.minWidth??40));xi(s=>{const i=Object.keys(n);return i.length===Object.keys(s).length&&i.every(o=>Math.abs((s[o]??-1/0)-n[o])<=1)?s:n})},[Ft,v,Fe,as]);const Ie=e=>Fe[e.field]||e.width||(Ft?hi[e.field]:void 0),xt=r.useCallback((e,n,s)=>{!$||Te||(Kt({rowKey:e,field:n}),$e(s))},[$,Te]),ls=r.useCallback(()=>{re&&$&&$(re.rowKey,re.field,ot),Kt(null),$e(null)},[re,ot,$]),Ri=r.useCallback(()=>{Kt(null),$e(null)},[]),Ai=r.useCallback((e,n)=>{!ve||Te||(nt?Jt({key:e,row:n}):ve(e,n))},[ve,Te,nt]),Ei=r.useCallback(()=>{const e=Ht;Jt(null),e&&ve?.(e.key,e.row)},[Ht,ve]),Oi=r.useCallback(()=>Jt(null),[]),Ue=`nice-datagrid__actions-col${pt.length>0?" nice-datagrid__actions-col--sticky":""}`,os=(e,n)=>t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs nice-btn--ghost nice-datagrid__row-delete","aria-label":u("controls.delete","Delete"),title:u("controls.delete","Delete"),onClick:s=>{s.stopPropagation(),Ai(e,n)},onDoubleClick:Xe,onKeyDown:Xe,children:t.jsx(y.NiceIcon,{name:"trash",size:14})}),Ti=r.useCallback(()=>{const e=T,n=e.map(f=>Ye(f.header)).join(","),s=L.map(f=>e.map(d=>Ye(String(f[d.field]??""))).join(",")),i=[n,...s].join(`
3
3
  `),a=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(a),c=document.createElement("a");c.href=o,c.download=`${_n}.csv`,c.click(),URL.revokeObjectURL(o)},[T,L,_n]),bt=r.useCallback(e=>{zt?zt(e):di(e)},[zt]),yt=r.useCallback(e=>{Rt?Rt(e):fi(e)},[Rt]),P=r.useMemo(()=>A.filter(e=>e.type==="data").map(e=>e.key),[A]),$i=r.useCallback(e=>{if(e.target!==e.currentTarget||!Ae||re||!B)return;const n=P.indexOf(B.rowKey),s=v.findIndex(c=>c.field===B.field);if(n<0||s<0)return;let i=n,a=s;switch(e.key){case"ArrowUp":i=Math.max(0,n-1);break;case"ArrowDown":i=Math.min(P.length-1,n+1);break;case"ArrowLeft":a=Math.max(0,s-1);break;case"ArrowRight":a=Math.min(v.length-1,s+1);break;case"Tab":{const c=s+(e.shiftKey?-1:1);if(c<0||c>=v.length)return;a=c;break}case"Enter":{const c=v[s];if(c.editable&&$){const f=V.find(d=>String(d[m])===B.rowKey);f&&xt(B.rowKey,c.field,f[c.field])}return}case"Escape":bt(null),yt(null);return;case"Home":e.ctrlKey&&(i=0),a=0;break;case"End":e.ctrlKey&&(i=P.length-1),a=v.length-1;break;case"PageUp":i=Math.max(0,n-lt);break;case"PageDown":i=Math.min(P.length-1,n+lt);break;default:return}e.preventDefault();const o={rowKey:P[i],field:v[a].field};if(bt(o),e.shiftKey&&kn){const c=F?.start??B;yt({start:c,end:o})}else yt(null)},[Ae,re,B,P,v,kn,F,bt,yt,$,V,m,xt,lt]),cs=r.useCallback(()=>{let e=[],n=[];if(F){const s=P.indexOf(F.start.rowKey),i=P.indexOf(F.end.rowKey),a=Math.min(s,i),o=Math.max(s,i),c=v.findIndex(p=>p.field===F.start.field),f=v.findIndex(p=>p.field===F.end.field),d=Math.min(c,f),j=Math.max(c,f);n=v.slice(d,j+1).map(p=>p.field),e=V.filter(p=>{const E=P.indexOf(String(p[m]));return E>=a&&E<=o})}else I.size>0&&(e=V.filter(s=>I.has(String(s[m]))),n=v.map(s=>s.field));return{rows:e,fields:n}},[F,P,v,V,m,I]),ds=r.useCallback((e,n,s)=>{const i=v.filter(a=>n.includes(a.field));switch(s){case"json":return JSON.stringify(e.map(a=>Object.fromEntries(n.map(o=>[o,a[o]]))),null,2);case"csv":{const a=i.map(c=>Ye(c.header)).join(","),o=e.map(c=>i.map(f=>Ye(String(c[f.field]??""))).join(",")).join(`
4
4
  `);return a+`