@nice2dev/ui 1.4.1 → 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 +44 -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
@@ -1,5 +1,5 @@
1
- const f = /* @__PURE__ */ new Map();
2
- function c(t) {
1
+ const i = /* @__PURE__ */ new Map();
2
+ function m(t) {
3
3
  if (!t)
4
4
  return "en";
5
5
  try {
@@ -9,25 +9,35 @@ function c(t) {
9
9
  }
10
10
  }
11
11
  function a(t, e) {
12
- const n = c(t), o = `${n}|${JSON.stringify(e)}`;
13
- let r = f.get(o);
14
- return r || (r = new Intl.DateTimeFormat(n, e), f.set(o, r)), r;
12
+ const n = m(t), o = `${n}|${JSON.stringify(e)}`;
13
+ let r = i.get(o);
14
+ return r || (r = new Intl.DateTimeFormat(n, e), i.set(o, r)), r;
15
15
  }
16
- const m = (t, e) => t.charAt(0).toLocaleUpperCase(c(e)) + t.slice(1);
17
- function s(t, e = "short") {
16
+ const c = (t, e) => t.charAt(0).toLocaleUpperCase(m(e)) + t.slice(1);
17
+ function f(t, e = "short") {
18
18
  const n = a(t, { weekday: e });
19
- return Array.from({ length: 7 }, (o, r) => m(n.format(new Date(2023, 0, 1 + r)), t));
19
+ return Array.from({ length: 7 }, (o, r) => c(n.format(new Date(2023, 0, 1 + r)), t));
20
20
  }
21
- function i(t, e = "long") {
21
+ function u(t, e = "long") {
22
22
  const n = a(t, { month: e });
23
- return Array.from({ length: 12 }, (o, r) => m(n.format(new Date(2023, r, 1)), t));
23
+ return Array.from({ length: 12 }, (o, r) => c(n.format(new Date(2023, r, 1)), t));
24
24
  }
25
- function u(t, e) {
26
- return a(t, { dateStyle: "short", timeStyle: "short" }).format(e);
25
+ function s(t, e) {
26
+ return a(t, { year: "numeric", month: "2-digit", day: "2-digit" }).format(e);
27
+ }
28
+ function d(t, e) {
29
+ return a(t, {
30
+ year: "numeric",
31
+ month: "2-digit",
32
+ day: "2-digit",
33
+ hour: "2-digit",
34
+ minute: "2-digit"
35
+ }).format(e);
27
36
  }
28
37
  export {
29
- u as formatDateTime,
30
- i as monthNames,
31
- c as safeLocale,
32
- s as weekdayNames
38
+ s as formatNumericDate,
39
+ d as formatNumericDateTime,
40
+ u as monthNames,
41
+ m as safeLocale,
42
+ f as weekdayNames
33
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/ui",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Nice2Dev UI — Universal, themeable, i18n-ready React component library",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -97,12 +97,12 @@
97
97
  "react-dom": ">=17.0.0"
98
98
  },
99
99
  "dependencies": {
100
- "@nice2dev/i18n": "^1.4.1",
101
- "@nice2dev/ui-core": "^1.4.1",
100
+ "@nice2dev/i18n": "^1.4.2",
101
+ "@nice2dev/ui-core": "^1.4.2",
102
102
  "country-flag-icons": "^1.6.20"
103
103
  },
104
104
  "devDependencies": {
105
- "@nice2dev/testing": "^1.4.1",
105
+ "@nice2dev/testing": "^1.4.2",
106
106
  "@playwright/test": "^1.62.1",
107
107
  "@testing-library/dom": "^10.4.1",
108
108
  "@testing-library/jest-dom": "^7.0.1",
@@ -1,268 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("@nice2dev/ui-core"),n=require("react"),ue=require("./injectStyleOnce-DeWaxcdf.cjs"),qe=[{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 G=null,ne=null;const He="0.45.0",Ee=`https://cdn.jsdelivr.net/npm/monaco-editor@${He}/min`,de=`${Ee}/vs`,we=15e3;function _e(){const s=window;if(s.MonacoEnvironment?.getWorkerUrl)return;const l=`self.MonacoEnvironment={baseUrl:'${Ee}/'};importScripts('${de}/base/worker/workerMain.js');`,g=URL.createObjectURL(new Blob([l],{type:"text/javascript"}));s.MonacoEnvironment={getWorkerUrl:()=>g}}function X(s){if(s!=="auto")return s;if(typeof document>"u")return"vs";const l=document.documentElement.dataset.theme;return l==="dark"?"vs-dark":l==="light"?"vs":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function Be(s){if(!s)return"";try{return JSON.stringify([s.url,s.language,s.initOptions??null])}catch{return JSON.stringify([s.url,s.language])}}function Se(){return ne?Promise.resolve(ne):G||(G=new Promise((s,l)=>{if(window.monaco){_e(),ne=window.monaco,s(ne);return}let g=!1;const o=window.setTimeout(()=>{g||(g=!0,G=null,l(new Error(`Monaco editor failed to load within ${we}ms`)))},we),x=document.createElement("script");x.src=`${de}/loader.min.js`,x.async=!0,x.onload=()=>{const F=window.require;F.config({paths:{vs:de}}),_e(),F(["vs/editor/editor.main"],O=>{g||(g=!0,window.clearTimeout(o),ne=O,s(O))})},x.onerror=()=>{g||(g=!0,window.clearTimeout(o),G=null,l(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(x)}),G)}function je(s){n.useEffect(()=>{const l=s.current;if(!l)return;const g=h.createTabEscape(),o=x=>{g(x)&&x.stopPropagation()};return l.addEventListener("keydown",o,!0),()=>l.removeEventListener("keydown",o,!0)},[s])}const Ue=n.forwardRef(function(l,g){const{t:o}=h.useNiceTranslation();ue.injectStyleOnce(me,pe);const{value:x,defaultValue:F,onChange:O,language:b="plaintext",theme:_="auto",options:a={},height:ee=400,width:$="100%",markers:T=[],decorations:q=[],completionProvider:v,onMount:I,onCursorPositionChange:E,onSelectionChange:j,onSave:H,loading:P,disabled:A=!1,showToolbar:Y=!1,showStatusBar:D=!1,editorSize:B="standard",className:J,"data-testid":z,lsp:M,extraLibs:S,tutorial:Z}=l,[N,W,u]=h.useControllableState({value:x,defaultValue:F,fallbackValue:"",onChange:O,componentName:"NiceCodeEditor"}),m=n.useRef(W);m.current=W;const C=n.useRef(N);C.current=N;const f=n.useRef(!1),k=n.useRef(null);je(k);const i=n.useRef(null),w=n.useRef(null),R=n.useRef([]),V=n.useRef(null),[U,fe]=n.useState(!0),[ie,Me]=n.useState(null),[ge,Re]=n.useState({lineNumber:1,column:1}),[he,Le]=n.useState(""),[ce,Oe]=n.useState(a.wordWrap==="on"),re=n.useMemo(()=>({automaticLayout:!0,readOnly:A||a.readOnly,minimap:{enabled:a.minimap??!0},lineNumbers:a.lineNumbers??"on",wordWrap:a.wordWrap??"off",tabSize:a.tabSize??2,insertSpaces:a.insertSpaces??!0,fontSize:a.fontSize??14,fontFamily:a.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:a.fontLigatures??!0,cursorStyle:a.cursorStyle??"line",cursorBlinking:a.cursorBlinking??"blink",autoClosingBrackets:a.autoClosingBrackets??"languageDefined",autoClosingQuotes:a.autoClosingQuotes??"languageDefined",formatOnPaste:a.formatOnPaste??!1,formatOnType:a.formatOnType??!1,renderWhitespace:a.renderWhitespace??"selection",renderControlCharacters:a.renderControlCharacters??!1,scrollBeyondLastLine:a.scrollBeyondLastLine??!0,smoothScrolling:a.smoothScrolling??!0,folding:a.folding??!0,showFoldingControls:a.showFoldingControls??"mouseover","bracketPairColorization.enabled":a.bracketPairColorization??!0,guides:a.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:a.stickyScroll??!1},quickSuggestions:a.quickSuggestions??!0,suggestOnTriggerCharacters:a.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:a.acceptSuggestionOnEnter??"on",inlayHints:{enabled:a.inlayHints?"on":"off"}}),[a,A]),te=n.useRef({onCursorPositionChange:E,onSelectionChange:j,onSave:H,onMount:I});te.current={onCursorPositionChange:E,onSelectionChange:j,onSave:H,onMount:I};const be=n.useRef({language:b,theme:_,editorOptions:re});be.current={language:b,theme:_,editorOptions:re};const ve=n.useRef(M);ve.current=M;const Te=Be(M),ke=n.useRef(o);ke.current=o,n.useEffect(()=>{if(!k.current)return;let e=!0;const c=ve.current;return Se().then(async r=>{if(!e||!k.current)return;w.current=r;const p=be.current,y=r.editor.create(k.current,{value:C.current,language:p.language,theme:X(p.theme),...p.editorOptions});if(i.current=y,fe(!1),y.onDidChangeModelContent(()=>{f.current||m.current(y.getValue())}),y.onDidChangeCursorPosition(d=>{Re({lineNumber:d.position.lineNumber,column:d.position.column}),te.current.onCursorPositionChange?.({lineNumber:d.position.lineNumber,column:d.position.column})}),y.onDidChangeCursorSelection(d=>{const L=d.selection,Q=y.getModel()?.getValueInRange(L)??"";Le(Q),te.current.onSelectionChange?.({startLineNumber:L.startLineNumber,startColumn:L.startColumn,endLineNumber:L.endLineNumber,endColumn:L.endColumn})}),y.addCommand(r.KeyMod.CtrlCmd|r.KeyCode.KeyS,()=>{te.current.onSave?.(y.getValue())}),c&&typeof window<"u")try{await oe("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await oe("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const d=window,L=d.ReconnectingWebSocket,{MonacoLanguageClient:Q,CloseAction:Ae,ErrorAction:De,createConnection:ye}=d.monacoLanguageClient||{};if(Q&&ye){const ze=c.url,We=c.language,xe=new L(ze),Ve=new d.VSCodeWebSocketMessageReader(xe),Fe=new d.VSCodeWebSocketMessageWriter(xe),$e=ye(Ve,Fe),Ce=new Q({name:"LSP Client",clientOptions:{documentSelector:[We],initializationOptions:c.initOptions,errorHandler:{error:()=>De.Continue,closed:()=>Ae.Restart}},connectionProvider:{get:()=>Promise.resolve($e)}});Ce.start(),i.current.__lspClient=Ce}}catch(d){console.warn("LSP bridge failed to load:",d)}te.current.onMount?.(y,r)}).catch(r=>{e&&(Me(r.message??ke.current("codeEditor.failedToLoadEditor","Failed to load editor")),fe(!1))}),()=>{if(e=!1,i.current?.dispose(),V.current?.dispose(),i.current&&i.current.__lspClient)try{i.current.__lspClient.stop()}catch{}}},[Te]),n.useEffect(()=>{const e=i.current;if(!u||!e||N===e.getValue())return;const c=e.getPosition();f.current=!0;try{e.setValue(N)}finally{f.current=!1}c&&e.setPosition(c)},[N,u]),n.useEffect(()=>{const e=i.current,c=w.current;if(e&&c){const r=e.getModel();r&&c.editor.setModelLanguage(r,b)}},[b]),n.useEffect(()=>{const e=w.current;if(!e||U||!S||S.length===0||b!=="javascript"&&b!=="typescript")return;const c=e.languages?.typescript;if(!c)return;const r=[];try{S.forEach((p,y)=>{const d=p.filePath??`inmemory://model/nice-extralib-${y}.d.ts`,L=c.typescriptDefaults?.addExtraLib(p.content,d);L&&r.push(L);const Q=c.javascriptDefaults?.addExtraLib(p.content,d);Q&&r.push(Q)})}catch(p){console.warn("Failed to register extraLibs:",p)}return()=>{r.forEach(p=>{try{p.dispose()}catch{}})}},[S,b,U]),n.useEffect(()=>{const e=w.current;if(!e||(e.editor.setTheme(X(_)),_!=="auto"||typeof document>"u"))return;const c=()=>{w.current?.editor.setTheme(X("auto"))},r=new MutationObserver(c);r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const p=window.matchMedia?.("(prefers-color-scheme: dark)");return p?.addEventListener?.("change",c),()=>{r.disconnect(),p?.removeEventListener?.("change",c)}},[_]),n.useEffect(()=>{const e=i.current;e&&e.updateOptions(re)},[re]),n.useEffect(()=>{const e=i.current,c=w.current;if(e&&c){const r=e.getModel();if(r){const p=T.map(y=>({startLineNumber:y.startLineNumber,startColumn:y.startColumn,endLineNumber:y.endLineNumber,endColumn:y.endColumn,message:y.message,severity:y.severity}));c.editor.setModelMarkers(r,"owner",p)}}},[T]),n.useEffect(()=>{const e=i.current;if(e&&q.length>0){const c=q.map(r=>({range:{startLineNumber:r.range.startLineNumber,startColumn:r.range.startColumn,endLineNumber:r.range.endLineNumber,endColumn:r.range.endColumn},options:{className:r.className,glyphMarginClassName:r.glyphMarginClassName,hoverMessage:r.hoverMessage?{value:r.hoverMessage}:void 0,isWholeLine:r.isWholeLine}}));R.current=e.deltaDecorations(R.current,c)}},[q]),n.useEffect(()=>{const e=w.current;if(!e||!v)return;V.current?.dispose();const c={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(b,{provideCompletionItems:async(r,p)=>({suggestions:(await v(r,p)).map(d=>({label:d.label,kind:c[d.kind]??0,insertText:d.insertText,insertTextRules:d.insertTextRules==="insertAsSnippet"?4:void 0,documentation:d.documentation,detail:d.detail,range:{startLineNumber:p.lineNumber,startColumn:p.column,endLineNumber:p.lineNumber,endColumn:p.column}}))})}),()=>{V.current?.dispose()}},[b,v]),n.useImperativeHandle(g,()=>({getEditor:()=>i.current,getMonaco:()=>w.current,focus:()=>i.current?.focus(),getValue:()=>i.current?.getValue()??"",setValue:e=>i.current?.setValue(e),getSelection:()=>{const e=i.current;if(!e)return"";const c=e.getSelection();return c?e.getModel()?.getValueInRange(c)??"":""},insertText:e=>{const c=i.current;if(!c)return;const r=c.getSelection();r&&c.executeEdits("",[{range:r,text:e}])},formatDocument:()=>{i.current?.getAction("editor.action.formatDocument")?.run()},goToLine:(e,c=1)=>{const r=i.current;r&&(r.setPosition({lineNumber:e,column:c}),r.revealLineInCenter(e),r.focus())},findReplace:()=>{i.current?.getAction("editor.action.startFindReplaceAction")?.run()},undo:()=>{i.current?.trigger("keyboard","undo",null)},redo:()=>{i.current?.trigger("keyboard","redo",null)},getCursorPosition:()=>{const e=i.current?.getPosition();return{lineNumber:e?.lineNumber??1,column:e?.column??1}},setMarkers:e=>{const c=i.current,r=w.current;if(c&&r){const p=c.getModel();if(p){const y=e.map(d=>({startLineNumber:d.startLineNumber,startColumn:d.startColumn,endLineNumber:d.endLineNumber,endColumn:d.endColumn,message:d.message,severity:d.severity}));r.editor.setModelMarkers(p,"owner",y)}}}}),[]);const K=n.useMemo(()=>({format:()=>i.current?.getAction("editor.action.formatDocument")?.run(),undo:()=>i.current?.trigger("keyboard","undo",null),redo:()=>i.current?.trigger("keyboard","redo",null),find:()=>i.current?.getAction("editor.action.startFindReplaceAction")?.run(),toggleWordWrap:()=>{const e=!ce;Oe(e),i.current?.updateOptions({wordWrap:e?"on":"off"})},toggleMinimap:()=>{const e=i.current?.getOption?.(w.current?.editor?.EditorOption?.minimap);i.current?.updateOptions({minimap:{enabled:!e?.enabled}})},foldAll:()=>i.current?.getAction("editor.foldAll")?.run(),unfoldAll:()=>i.current?.getAction("editor.unfoldAll")?.run()}),[ce]),Ie=N.split(`
2
- `).length,Pe=N.length;return t.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${B} ${J??""}`,style:{height:ee,width:$,display:"flex",flexDirection:"column",position:"relative"},"data-testid":z,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(h.NiceTutorialButton,{steps:h.resolveTutorial(Z,qe)})}),ie&&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(h.NiceIcon,{name:"warning",size:16})," ",ie]}),t.jsx("textarea",{value:N,onChange:e=>W(e.target.value),readOnly:A||a.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),U&&!ie&&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:P??t.jsx("div",{className:"nice-code-editor__loader",children:o("codeEditor.loadingEditor","Loading editor...")})}),Y&&t.jsxs("div",{className:"nice-code-editor__toolbar",children:[t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.undo,title:o("codeEditor.undoCtrlZ","Undo (Ctrl+Z)"),"aria-label":o("codeEditor.undo","Undo"),children:t.jsx(h.NiceIcon,{name:"reply",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.redo,title:o("codeEditor.redoCtrlY","Redo (Ctrl+Y)"),"aria-label":o("codeEditor.redo","Redo"),children:t.jsx(h.NiceIcon,{name:"forward",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.format,title:o("codeEditor.formatShiftAltF","Format (Shift+Alt+F)"),"aria-label":o("codeEditor.format","Format"),children:t.jsx(h.NiceIcon,{name:"type",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.find,title:o("codeEditor.findReplaceCtrlH","Find & Replace (Ctrl+H)"),"aria-label":o("codeEditor.findReplace","Find & Replace"),children:t.jsx(h.NiceIcon,{name:"search",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:`nice-code-editor__toolbar-btn${ce?" nice-code-editor__toolbar-btn--active":""}`,onClick:K.toggleWordWrap,title:o("codeEditor.toggleWordWrap","Toggle Word Wrap"),"aria-label":o("codeEditor.toggleWordWrap","Toggle Word Wrap"),children:t.jsx(h.NiceIcon,{name:"align-left",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.toggleMinimap,title:o("codeEditor.toggleMinimap","Toggle Minimap"),"aria-label":o("codeEditor.toggleMinimap","Toggle Minimap"),children:t.jsx(h.NiceIcon,{name:"columns",size:16})}),t.jsx("span",{className:"nice-code-editor__toolbar-sep"}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.foldAll,title:o("codeEditor.foldAll","Fold All"),"aria-label":o("codeEditor.foldAll","Fold All"),children:t.jsx(h.NiceIcon,{name:"collapse",size:16})}),t.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:K.unfoldAll,title:o("codeEditor.unfoldAll","Unfold All"),"aria-label":o("codeEditor.unfoldAll","Unfold All"),children:t.jsx(h.NiceIcon,{name:"expand",size:16})})]}),t.jsx("div",{ref:k,className:"nice-code-editor",style:{flex:1,minHeight:0}}),D&&t.jsxs("div",{className:"nice-code-editor__statusbar",children:[t.jsx("span",{children:o("codeEditor.lnCol","Ln {lineNumber}, Col {column}").replace("{lineNumber}",String(ge.lineNumber)).replace("{column}",String(ge.column))}),he.length>0&&t.jsx("span",{children:o("codeEditor.selected","({selectionText} selected)").replace("{selectionText}",String(he.length))}),t.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),t.jsx("span",{children:o("codeEditor.linesChars","{lineCount} lines · {charCount} chars").replace("{lineCount}",String(Ie)).replace("{charCount}",String(Pe))}),t.jsx("span",{className:"nice-code-editor__statusbar-lang",children:b}),T.length>0&&t.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:[t.jsx(h.NiceIcon,{name:"warning",size:14})," ",T.length]})]})]})});function Ke(s){const{t:l}=h.useNiceTranslation();ue.injectStyleOnce(me,pe);const{original:g,defaultOriginal:o,modified:x,defaultModified:F,language:O="plaintext",theme:b="auto",height:_=400,width:a="100%",inline:ee=!1,renderSideBySide:$=!0,originalEditable:T=!1,modifiedEditable:q=!1,onOriginalChange:v,onModifiedChange:I,loading:E,className:j,"data-testid":H}=s,[P,A,Y]=h.useControllableState({value:g,defaultValue:o,fallbackValue:"",onChange:v,componentName:"NiceCodeDiffEditor.original"}),[D,B,J]=h.useControllableState({value:x,defaultValue:F,fallbackValue:"",onChange:I,componentName:"NiceCodeDiffEditor.modified"}),z=n.useRef({currentOriginal:P,currentModified:D,setOriginal:A,setModified:B});z.current={currentOriginal:P,currentModified:D,setOriginal:A,setModified:B};const M=n.useRef(!1),S=n.useRef(null);je(S);const Z=n.useRef(null),N=n.useRef(null),[W,u]=n.useState(!0),[m,C]=n.useState(null);return n.useEffect(()=>{if(!S.current)return;let f=!0;return Se().then(k=>{if(!f||!S.current)return;N.current=k;const{currentOriginal:i,currentModified:w}=z.current,R=k.editor.createModel(i,O),V=k.editor.createModel(w,O),U=k.editor.createDiffEditor(S.current,{automaticLayout:!0,theme:X(b),renderSideBySide:!ee&&$,originalEditable:T,readOnly:!q});U.setModel({original:R,modified:V}),Z.current=U,u(!1),T&&R.onDidChangeContent(()=>{M.current||z.current.setOriginal(R.getValue())}),q&&V.onDidChangeContent(()=>{M.current||z.current.setModified(V.getValue())})}).catch(k=>{f&&(C(k.message??l("codeEditor.failedToLoadDiffEditor","Failed to load diff editor")),u(!1))}),()=>{f=!1,Z.current?.dispose()}},[l]),n.useEffect(()=>{const f=Z.current?.getModel();if(f){M.current=!0;try{Y&&f.original.getValue()!==P&&f.original.setValue(P),J&&f.modified.getValue()!==D&&f.modified.setValue(D)}finally{M.current=!1}}},[P,D,Y,J]),n.useEffect(()=>{const f=N.current;if(!f||(f.editor.setTheme(X(b)),b!=="auto"||typeof document>"u"))return;const k=()=>{N.current?.editor.setTheme(X("auto"))},i=new MutationObserver(k);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const w=window.matchMedia?.("(prefers-color-scheme: dark)");return w?.addEventListener?.("change",k),()=>{i.disconnect(),w?.removeEventListener?.("change",k)}},[b,W]),m?t.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${j??""}`,style:{height:_,width:a},"data-testid":H,children:t.jsx("div",{className:"nice-code-editor__error",children:t.jsxs("span",{children:[t.jsx(h.NiceIcon,{name:"warning",size:16})," ",m]})})}):t.jsxs("div",{className:`nice-code-diff-editor ${j??""}`,style:{height:_,width:a,position:"relative"},"data-testid":H,children:[t.jsx("div",{ref:S,style:{position:"absolute",inset:0}}),W&&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:l("codeEditor.loadingDiffEditor","Loading diff editor...")})})]})}const Ye="1.29.0",Ne=`https://cdn.jsdelivr.net/npm/prismjs@${Ye}`;let ae=null;const le={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 oe(s){return new Promise((l,g)=>{if(document.querySelector(`script[data-prism-src="${s}"]`)){l();return}const o=document.createElement("script");o.src=s,o.async=!0,o.dataset.prismSrc=s,o.onload=()=>l(),o.onerror=()=>g(new Error(`Failed to load ${s}`)),document.head.appendChild(o)})}function Je(s){if(typeof window>"u")return Promise.resolve(null);const l=window,g=le[s]??"plain",o=async()=>{if(g!=="plain"&&!l.Prism?.languages?.[g])try{await oe(`${Ne}/components/prism-${g}.min.js`)}catch{}};return l.Prism?.languages?o().then(()=>l.Prism):(ae||(ae=(async()=>(window.Prism={manual:!0},await oe(`${Ne}/prism.min.js`),window.Prism))()),ae.then(async()=>(await o(),window.Prism)))}function se(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qe(s){ue.injectStyleOnce(me,pe);const{value:l,defaultValue:g,onChange:o,language:x="plaintext",height:F=300,width:O="100%",readOnly:b=!1,tabSize:_=2,lineNumbers:a=!0,placeholder:ee,theme:$="auto",className:T,"data-testid":q}=s,[v,I]=h.useControllableState({value:l,defaultValue:g,fallbackValue:"",onChange:o,componentName:"NiceSimpleCodeEditor"}),E=n.useRef(null),j=n.useRef(null),H=n.useRef(null),{t:P}=h.useNiceTranslation(),A=n.useId(),[Y]=n.useState(h.createTabEscape),[D,B]=n.useState(()=>se(v)),[J,z]=n.useState("light");n.useEffect(()=>{const u=()=>{if($!=="auto")return $;if(typeof document>"u")return"light";const k=document.documentElement.dataset.theme;return k==="dark"?"dark":k==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};if(z(u()),$!=="auto"||typeof document>"u")return;const m=()=>z(u()),C=new MutationObserver(m);C.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const f=window.matchMedia?.("(prefers-color-scheme: dark)");return f?.addEventListener?.("change",m),()=>{C.disconnect(),f?.removeEventListener?.("change",m)}},[$]),n.useEffect(()=>{let u=!0;return Je(x).then(m=>{if(!u)return;const C=le[x]??"plain";if(m?.languages?.[C])try{const f=m.highlight(v,m.languages[C],C);B(f);return}catch{}B(se(v))}).catch(()=>{u&&B(se(v))}),()=>{u=!1}},[v,x]);const M=n.useCallback(()=>{if(!j.current||!E.current)return;j.current.scrollTop=E.current.scrollTop,j.current.scrollLeft=E.current.scrollLeft;const u=H.current;if(u){const m=E.current.offsetHeight-E.current.clientHeight;u.style.paddingBottom=`calc(var(--nice-space-2, 8px) + ${m}px)`,u.scrollTop=E.current.scrollTop}},[]),S=n.useCallback(u=>{if(!Y(u)&&u.key==="Tab"&&!b){u.preventDefault();const m=u.currentTarget,C=m.selectionStart,f=m.selectionEnd,k=" ".repeat(_);if(u.shiftKey){const R=v.substring(0,C).lastIndexOf(`
3
- `)+1;if((v.substring(R,C).match(/^(\s*)/)?.[1]??"").length>=_){const U=v.substring(0,R)+v.substring(R+_);I(U),setTimeout(()=>{m.selectionStart=m.selectionEnd=C-_},0)}}else{const i=v.substring(0,C)+k+v.substring(f);I(i),setTimeout(()=>{m.selectionStart=m.selectionEnd=C+_},0)}}},[v,I,_,Y,b]),N=v.split(`
4
- `).length,W=le[x]??"plain";return t.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${J} ${T??""}`,style:{height:F,width:O},"data-testid":q,"data-language":x,"data-theme":J,children:[a&&t.jsx("div",{ref:H,className:"nice-simple-code-editor__line-numbers",children:Array.from({length:N},(u,m)=>t.jsx("div",{className:"nice-simple-code-editor__line-number",children:m+1},m))}),t.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[t.jsx("pre",{ref:j,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${W}`,children:t.jsx("code",{className:`language-${W}`,dangerouslySetInnerHTML:{__html:D+(v.endsWith(`
5
- `)?`
6
- `:"")}})}),t.jsx("textarea",{ref:E,className:"nice-simple-code-editor__textarea",value:v,onChange:u=>I(u.target.value),onKeyDown:S,onScroll:M,readOnly:b,placeholder:ee,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-describedby":b?void 0:A}),!b&&t.jsx("span",{id:A,className:"nice-sr-only",children:P("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")})]})]})}const me="nice-code-editor-styles",pe=`
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
-
129
- /* Prism token colors — light */
130
- .nice-simple-code-editor .token.comment,
131
- .nice-simple-code-editor .token.prolog,
132
- .nice-simple-code-editor .token.doctype,
133
- .nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
134
- .nice-simple-code-editor .token.punctuation { color: #586069; }
135
- .nice-simple-code-editor .token.property,
136
- .nice-simple-code-editor .token.tag,
137
- .nice-simple-code-editor .token.boolean,
138
- .nice-simple-code-editor .token.number,
139
- .nice-simple-code-editor .token.constant,
140
- .nice-simple-code-editor .token.symbol,
141
- .nice-simple-code-editor .token.deleted { color: #005cc5; }
142
- .nice-simple-code-editor .token.selector,
143
- .nice-simple-code-editor .token.attr-name,
144
- .nice-simple-code-editor .token.string,
145
- .nice-simple-code-editor .token.char,
146
- .nice-simple-code-editor .token.builtin,
147
- .nice-simple-code-editor .token.inserted { color: #032f62; }
148
- .nice-simple-code-editor .token.operator,
149
- .nice-simple-code-editor .token.entity,
150
- .nice-simple-code-editor .token.url,
151
- .nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
152
- .nice-simple-code-editor .token.atrule,
153
- .nice-simple-code-editor .token.attr-value,
154
- .nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
155
- .nice-simple-code-editor .token.function,
156
- .nice-simple-code-editor .token.class-name { color: #6f42c1; }
157
- .nice-simple-code-editor .token.regex,
158
- .nice-simple-code-editor .token.important { color: #e36209; }
159
-
160
- /* Prism token colors — dark */
161
- .nice-simple-code-editor--dark .token.comment,
162
- .nice-simple-code-editor--dark .token.prolog,
163
- .nice-simple-code-editor--dark .token.doctype,
164
- .nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
165
- .nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
166
- .nice-simple-code-editor--dark .token.property,
167
- .nice-simple-code-editor--dark .token.tag,
168
- .nice-simple-code-editor--dark .token.boolean,
169
- .nice-simple-code-editor--dark .token.number,
170
- .nice-simple-code-editor--dark .token.constant,
171
- .nice-simple-code-editor--dark .token.symbol,
172
- .nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
173
- .nice-simple-code-editor--dark .token.selector,
174
- .nice-simple-code-editor--dark .token.attr-name,
175
- .nice-simple-code-editor--dark .token.string,
176
- .nice-simple-code-editor--dark .token.char,
177
- .nice-simple-code-editor--dark .token.builtin,
178
- .nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
179
- .nice-simple-code-editor--dark .token.operator,
180
- .nice-simple-code-editor--dark .token.entity,
181
- .nice-simple-code-editor--dark .token.url,
182
- .nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
183
- .nice-simple-code-editor--dark .token.atrule,
184
- .nice-simple-code-editor--dark .token.attr-value,
185
- .nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
186
- .nice-simple-code-editor--dark .token.function,
187
- .nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
188
- .nice-simple-code-editor--dark .token.regex,
189
- .nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
190
-
191
- /* Toolbar */
192
- .nice-code-editor-wrap {
193
- border: 1px solid var(--nice-border, #e0e0e0);
194
- border-radius: var(--nice-radius-sm, 4px);
195
- overflow: hidden;
196
- }
197
- .nice-code-editor-wrap .nice-code-editor {
198
- border: none;
199
- border-radius: 0;
200
- }
201
- /* The editing surface draws no outline: while it has focus, the frame shows the ring
202
- (TODO_1.3.0 I4). */
203
- .nice-code-editor-wrap:has(.nice-code-editor:focus-within),
204
- .nice-code-diff-editor:focus-within,
205
- .nice-simple-code-editor:focus-within {
206
- border-color: var(--nice-color-primary, #3b82f6);
207
- box-shadow: var(--nice-focus-ring, 0 0 0 2px var(--nice-color-primary, #3b82f6));
208
- }
209
- .nice-code-editor__toolbar {
210
- display: flex;
211
- align-items: center;
212
- gap: var(--nice-space-0-5, 2px);
213
- padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
214
- background: var(--nice-bg-tertiary, #f5f5f5);
215
- border-bottom: 1px solid var(--nice-border, #e0e0e0);
216
- }
217
- .nice-code-editor__toolbar-btn {
218
- display: inline-flex;
219
- align-items: center;
220
- justify-content: center;
221
- width: 26px;
222
- height: 26px;
223
- border: none;
224
- border-radius: var(--nice-radius-sm, 3px);
225
- background: transparent;
226
- color: var(--nice-text-secondary, #666);
227
- cursor: pointer;
228
- font-size: 14px;
229
- transition: background 0.15s, color 0.15s;
230
- }
231
- .nice-code-editor__toolbar-btn:hover {
232
- background: var(--nice-hover-bg, #e0e0e0);
233
- color: var(--nice-text-primary, #333);
234
- }
235
- .nice-code-editor__toolbar-btn--active {
236
- background: var(--nice-accent, #1976d2);
237
- color: var(--nice-text-on-primary, #FFF);
238
- }
239
- .nice-code-editor__toolbar-sep {
240
- width: 1px;
241
- height: 18px;
242
- background: var(--nice-border, #e0e0e0);
243
- margin: 0 var(--nice-space-1, 4px);
244
- }
245
-
246
- /* Status bar */
247
- .nice-code-editor__statusbar {
248
- display: flex;
249
- align-items: center;
250
- gap: var(--nice-space-3, 12px);
251
- padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
252
- background: var(--nice-bg-tertiary, #f5f5f5);
253
- border-top: 1px solid var(--nice-border, #e0e0e0);
254
- font-size: 12px;
255
- color: var(--nice-text-secondary, #666);
256
- user-select: none;
257
- }
258
- .nice-code-editor__statusbar-spacer { flex: 1; }
259
- .nice-code-editor__statusbar-lang {
260
- text-transform: uppercase;
261
- font-weight: 600;
262
- font-size: 11px;
263
- }
264
- .nice-code-editor__statusbar-markers {
265
- color: var(--nice-warning, #f39c12);
266
- font-weight: 600;
267
- }
268
- `;exports.NiceCodeDiffEditor=Ke;exports.NiceCodeEditor=Ue;exports.NiceSimpleCodeEditor=Qe;
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),m=require("@nice2dev/ui-core"),s=require("react"),W=require("./NiceButton-DzCqkG5a.cjs"),B={info:e.jsx(m.NiceIcon,{name:"info",size:20}),success:e.jsx(m.NiceIcon,{name:"success",size:20}),warning:e.jsx(m.NiceIcon,{name:"warning",size:20}),error:e.jsx(m.NiceIcon,{name:"error",size:20})},U=({variant:t="info",title:i,children:a,closable:c,onClose:n,icon:r,size:d="md",className:l,style:u,displayStyle:h,testId:f,"data-testid":_})=>{const{t:p}=m.useNiceTranslation(),o=m.useComponentDisplayClass("card",h);return e.jsxs("div",{className:`nice-alert nice-alert--${t} nice-alert--${d} nice-alert--ds-${o} ${l||""}`,style:u,role:"alert","data-testid":_??f,children:[e.jsx("div",{className:`nice-alert__icon nice-alert__icon--${t}`,children:r||B[t]}),e.jsxs("div",{className:"nice-alert__content",children:[i&&e.jsx("div",{className:"nice-alert__title",children:i}),e.jsx("div",{children:a})]}),c&&e.jsx("button",{type:"button",className:"nice-alert__close",onClick:n,"aria-label":p("alert.close","Close"),children:e.jsx(m.NiceIcon,{name:"close",size:16})})]})},K=({open:t,onClose:i,title:a,position:c="right",size:n="md",children:r,footer:d,transitionDuration:l,className:u,style:h,displayStyle:f,testId:_,"data-testid":p})=>{const o=m.useComponentDisplayStyle("modal",f),v=m.useComponentDisplayClass("modal",f),{t:x}=m.useNiceTranslation(),g=s.useRef(null);return m.useOverlayFocus(g,{open:t,onClose:i}),s.useEffect(()=>{if(t)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[t]),t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-drawer-overlay",onMouseDown:j=>{j.target===j.currentTarget&&i()}}),e.jsxs("div",{ref:g,className:`nice-drawer nice-drawer--${c} nice-drawer--${n} nice-drawer--ds-${v} ${u||""}`,style:{...o,...h,...l!=null?{transitionDuration:`${l}ms`}:{}},role:"dialog","aria-modal":"true","aria-label":a,"data-testid":p??_,children:[a&&e.jsxs("div",{className:"nice-drawer__header",children:[e.jsx("h3",{className:"nice-drawer__title",children:a}),e.jsx("button",{type:"button",className:"nice-drawer__close",onClick:i,"aria-label":x("controls.close","Close"),children:e.jsx(m.NiceIcon,{name:"close",size:18})})]}),e.jsx("div",{className:"nice-drawer__body",children:r}),d&&e.jsx("div",{className:"nice-drawer__footer",children:d})]})]}):null},Y=({toasts:t,onDismiss:i,position:a="top-right"})=>{const{t:c}=m.useNiceTranslation(),n=s.useRef(null),r=s.useRef(null);m.useInputHints(n,[{intent:"back",label:c("toast.dismiss","Dismiss")}]);const d=s.useCallback(l=>{const u=n.current;if(!u||!l.contains(document.activeElement))return;const h=[...u.querySelectorAll(".nice-toast:not(.nice-toast--exiting)")],f=h.indexOf(l),_=h[f+1]??h[f-1];(_&&_!==l?_.querySelector("button"):r.current?.isConnected?r.current:null)?.focus()},[]);return s.useEffect(()=>{const l=n.current;if(!l)return;const u=h=>{const f=h.relatedTarget;f instanceof HTMLElement&&!l.contains(f)&&(r.current=f)};return l.addEventListener("focusin",u),()=>l.removeEventListener("focusin",u)},[]),e.jsx("div",{ref:n,className:`nice-toast-container nice-toast-container--${a}`,role:"region","aria-label":c("toast.region","Notifications"),children:t.map(l=>e.jsx(G,{toast:l,onDismiss:i,onLeave:d},l.id))})},G=({toast:t,onDismiss:i,onLeave:a})=>{const{t:c}=m.useNiceTranslation(),n=s.useRef(null),[r,d]=s.useState(!1),[l,u]=s.useState(!1),[h,f]=s.useState(!1),_=l||h,p=s.useCallback(()=>{n.current&&a(n.current),d(!0)},[a]);return s.useEffect(()=>{if(_||r)return;const o=t.duration??4e3;if(o>0){const v=setTimeout(()=>d(!0),o);return()=>clearTimeout(v)}},[t.duration,_,r]),s.useEffect(()=>{if(r){const o=setTimeout(()=>i(t.id),200);return()=>clearTimeout(o)}},[r,t.id,i]),s.useEffect(()=>{const o=n.current;if(!o)return;const v=N=>{N.key==="Escape"&&!N.defaultPrevented&&(N.preventDefault(),p())},x=()=>u(!0),g=()=>u(!1),j=()=>f(!0),b=N=>{o.contains(N.relatedTarget)||f(!1)};return o.addEventListener("keydown",v),o.addEventListener("mouseenter",x),o.addEventListener("mouseleave",g),o.addEventListener("focusin",j),o.addEventListener("focusout",b),()=>{o.removeEventListener("keydown",v),o.removeEventListener("mouseenter",x),o.removeEventListener("mouseleave",g),o.removeEventListener("focusin",j),o.removeEventListener("focusout",b)}},[p]),e.jsxs("div",{ref:n,className:`nice-toast nice-toast--${t.variant} ${r?"nice-toast--exiting":""}`,role:"alert",style:{position:"relative"},children:[e.jsx("div",{className:"nice-toast__icon",children:B[t.variant]}),e.jsxs("div",{className:"nice-toast__content",children:[t.title&&e.jsx("div",{className:"nice-toast__title",children:t.title}),e.jsx("div",{className:"nice-toast__message",children:t.message}),t.action&&e.jsx("button",{type:"button",className:"nice-toast__action",onClick:()=>{t.action?.onClick(),p()},children:t.action.label})]}),e.jsx("button",{type:"button",className:"nice-toast__close",onClick:p,"aria-label":c("toast.close","Close"),children:e.jsx(m.NiceIcon,{name:"close",size:16})})]})};let J=0;function Q(){const[t,i]=s.useState([]),a=s.useCallback((n,r,d)=>{const l=`toast-${++J}`;return i(u=>[...u,{id:l,variant:n,message:r,title:d?.title,duration:d?.duration,action:d?.action}]),l},[]),c=s.useCallback(n=>{i(r=>r.filter(d=>d.id!==n))},[]);return{toasts:t,dismiss:c,info:(n,r)=>a("info",n,r),success:(n,r)=>a("success",n,r),warning:(n,r)=>a("warning",n,r),error:(n,r)=>a("error",n,r)}}function X({error:t,showRetry:i,retryLabel:a,title:c,onReset:n}){const{t:r}=m.useNiceTranslation();return e.jsxs("div",{className:"nice-error-boundary",role:"alert",children:[e.jsx("div",{className:"nice-error-boundary__icon",children:e.jsx(m.NiceIcon,{name:"warning",size:32})}),e.jsx("h2",{className:"nice-error-boundary__title",children:c??r("errorBoundary.somethingWentWrong","Something went wrong")}),e.jsx("p",{className:"nice-error-boundary__message",children:t.message}),i&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",onClick:n,children:a??r("errorBoundary.retry","Retry")})]})}const M=class M extends s.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null},this.handleReset=()=>{this.setState({hasError:!1,error:null})}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}componentDidCatch(i,a){this.props.onError?.(i,a)}render(){if(this.state.hasError&&this.state.error){const{fallback:i,showRetry:a=!0,retryLabel:c,title:n}=this.props;return typeof i=="function"?i(this.state.error,this.handleReset):i||e.jsx(X,{error:this.state.error,showRetry:a,retryLabel:c,title:n,onReset:this.handleReset})}return this.props.children}};M.displayName="NiceErrorBoundary";let A=M;function Z(t){return window.addEventListener("online",t),window.addEventListener("offline",t),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",t)}}function ee(){return navigator.onLine}function se(){return!0}const ne=({message:t,variant:i="warning",icon:a,online:c,size:n="md",className:r,style:d,"data-testid":l})=>{const{t:u}=m.useNiceTranslation(),h=s.useSyncExternalStore(Z,ee,se);return c??h?null:e.jsxs("div",{className:`nice-offline-banner nice-offline-banner--${i} nice-offline-banner--${n} ${r||""}`,style:d,role:"alert","aria-live":"assertive","data-testid":l,children:[e.jsx("span",{className:"nice-offline-banner__icon",children:a??e.jsx(m.NiceIcon,{name:"wifi",size:18})}),e.jsx("span",{className:"nice-offline-banner__message",children:t??u("offlineBanner.message","You are offline. Some features may be unavailable.")})]})},te=({error:t,onRetry:i,retryLabel:a,title:c,autoRetrySeconds:n,variant:r="error",icon:d,size:l="md",className:u,style:h,"data-testid":f})=>{const{t:_}=m.useNiceTranslation(),p=a??_("retryPanel.retry","Retry"),o=c??_("retryPanel.operationFailed","Operation failed"),[v,x]=s.useState(n??0),g=s.useRef(void 0),j=typeof t=="string"?t:t.message,b=s.useCallback(()=>{x(n??0),i()},[i,n]);return s.useEffect(()=>{if(!(!n||n<=0))return x(n),g.current=setInterval(()=>{x(N=>N<=1?(clearInterval(g.current),i(),0):N-1)},1e3),()=>clearInterval(g.current)},[n,i]),e.jsxs("div",{className:`nice-retry-panel nice-retry-panel--${r} nice-retry-panel--${l} ${u||""}`,style:h,role:"alert","data-testid":f,children:[e.jsx("div",{className:"nice-retry-panel__icon",children:d??e.jsx(m.NiceIcon,{name:"warning",size:24})}),e.jsxs("div",{className:"nice-retry-panel__content",children:[e.jsx("div",{className:"nice-retry-panel__title",children:o}),e.jsx("p",{className:"nice-retry-panel__message",children:j})]}),e.jsxs("div",{className:"nice-retry-panel__actions",children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary nice-btn--sm",onClick:b,children:p}),n&&v>0&&e.jsx("span",{className:"nice-retry-panel__countdown",children:_("retryPanel.autoRetryInS","Auto-retry in {countdown}s").replace("{countdown}",String(v))})]})]})};function H({timeoutMs:t=1e4,slowThresholdMs:i=3e3,onTimeout:a,autoRetry:c=!1,autoRetryCount:n=3}={}){const[r,d]=s.useState(!1),[l,u]=s.useState(!1),[h,f]=s.useState(!1),[_,p]=s.useState(0),[o,v]=s.useState(0),x=s.useRef(null),g=s.useRef(null),j=s.useRef(null),b=s.useRef(0),N=s.useCallback(()=>{x.current&&clearTimeout(x.current),g.current&&clearTimeout(g.current),j.current&&clearInterval(j.current)},[]),C=s.useCallback(()=>{N(),d(!0),u(!1),f(!1),p(0),b.current=Date.now(),j.current=setInterval(()=>{p(Date.now()-b.current)},200),x.current=setTimeout(()=>{u(!0)},i),g.current=setTimeout(()=>{f(!0),d(!1),u(!1),N(),a?.()},t)},[N,i,t,a]),I=s.useCallback(()=>{N(),d(!1),u(!1)},[N]),T=s.useCallback(()=>{v(w=>w+1),f(!1),C()},[C]);return s.useEffect(()=>()=>N(),[N]),s.useEffect(()=>{if(c&&h&&o<n){const w=Math.pow(2,o)*1e3,k=setTimeout(()=>T(),w);return()=>clearTimeout(k)}},[c,n,h,o,T]),{isLoading:r,isSlow:l,isTimedOut:h,elapsed:_,retryCount:o,start:C,stop:I,retry:T}}const ie=({timeoutMs:t=1e4,slowThresholdMs:i=3e3,onTimeout:a,onRetry:c,autoRetry:n=!1,autoRetryCount:r=3,showProgress:d=!0,slowMessage:l,timeoutMessage:u,loading:h,children:f,size:_="md",className:p,style:o,"data-testid":v})=>{const{t:x}=m.useNiceTranslation(),{isSlow:g,isTimedOut:j,elapsed:b,start:N,stop:C,retry:I}=H({timeoutMs:t,slowThresholdMs:i,onTimeout:a,autoRetry:n,autoRetryCount:r}),T=s.useRef(N);T.current=N;const w=s.useRef(C);w.current=C,s.useEffect(()=>{h?T.current():w.current()},[h]);const k=()=>{I(),c?.()};if(!h)return e.jsx(e.Fragment,{children:f});if(j)return e.jsxs("div",{className:`nice-timeout-feedback nice-timeout-feedback--timeout nice-timeout-feedback--${_} ${p??""}`,style:o,role:"alert","data-testid":v,children:[e.jsx("p",{className:"nice-timeout-feedback__message",children:u??x("timeoutFeedback.timeout","The operation timed out. Please try again.")}),e.jsx(W.NiceButton,{size:"sm",className:"nice-timeout-feedback__retry-btn",onClick:k,children:x("timeoutFeedback.retry","Try again")})]});const E=Math.min(100,b/t*100);return e.jsxs("div",{className:`nice-timeout-feedback nice-timeout-feedback--${_} ${g?"nice-timeout-feedback--slow":""} ${p??""}`,style:o,role:"status","aria-busy":"true","data-testid":v,children:[e.jsx("div",{className:"nice-timeout-feedback__spinner","aria-hidden":"true"}),g&&e.jsx("p",{className:"nice-timeout-feedback__slow-msg",children:l??x("timeoutFeedback.slow","This is taking longer than usual…")}),d&&e.jsx("div",{className:"nice-timeout-feedback__progress",role:"progressbar","aria-label":x("timeoutFeedback.progress","Time until timeout"),"aria-valuenow":Math.round(E),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:"nice-timeout-feedback__progress-bar",style:{width:`${E}%`}})})]})},re=Object.assign(s.forwardRef(({visible:t,onAcceptAll:i,onRejectAll:a,onSave:c,categories:n=["necessary","analytics","marketing","preferences"],defaults:r,position:d="bottom",size:l="md",policyUrl:u,showDetails:h=!1,className:f,style:_,id:p,testId:o,"data-testid":v,...x},g)=>{const j=m.useControlId(p),{t:b}=m.useNiceTranslation(),[N,C]=s.useState(!0),I=t??N,[T,w]=s.useState(h),[k,E]=s.useState(()=>{const y={necessary:!0,analytics:!1,marketing:!1,preferences:!1};return r&&Object.assign(y,r),y.necessary=!0,y}),P={necessary:b("cookie.necessary","Necessary"),analytics:b("cookie.analytics","Analytics"),marketing:b("cookie.marketing","Marketing"),preferences:b("cookie.preferences","Preferences")},L={necessary:b("cookie.necessaryDesc","Required for the website to function. Cannot be disabled."),analytics:b("cookie.analyticsDesc","Help us understand how visitors interact with the website."),marketing:b("cookie.marketingDesc","Used to deliver relevant advertisements."),preferences:b("cookie.preferencesDesc","Allow the website to remember your choices.")},O=s.useCallback(()=>{const y={necessary:!0,analytics:!0,marketing:!0,preferences:!0};i?.(),c?.(y),C(!1)},[i,c]),R=s.useCallback(()=>{const y={necessary:!0,analytics:!1,marketing:!1,preferences:!1};a?.(),c?.(y),C(!1)},[a,c]),z=s.useCallback(()=>{c?.({...k,necessary:!0}),C(!1)},[k,c]),$=s.useRef(null);m.useOverlayFocus($,{open:I});const q=s.useCallback(y=>{$.current=y,typeof g=="function"?g(y):g&&(g.current=y)},[g]);return I?e.jsx("div",{ref:q,id:j,className:`nice-cookie-consent nice-cookie-consent--${d} nice-cookie-consent--${l} ${f??""}`,style:_,role:"dialog","aria-label":b("cookie.label","Cookie Consent"),"aria-modal":"true","data-testid":v??o,...x,children:e.jsxs("div",{className:"nice-cookie-consent__content",children:[e.jsxs("p",{className:"nice-cookie-consent__message",children:[b("cookie.message","We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies."),u&&e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:u,className:"nice-cookie-consent__link",target:"_blank",rel:"noopener noreferrer",children:b("cookie.learnMore","Learn more")})]})]}),T&&e.jsx("div",{className:"nice-cookie-consent__details",children:n.map(y=>e.jsxs("label",{className:"nice-cookie-consent__category",children:[e.jsx("input",{type:"checkbox",checked:k[y],disabled:y==="necessary",onChange:F=>E(D=>({...D,[y]:F.target.checked})),className:"nice-cookie-consent__checkbox"}),e.jsxs("div",{className:"nice-cookie-consent__cat-info",children:[e.jsx("strong",{children:P[y]}),e.jsx("span",{className:"nice-cookie-consent__cat-desc",children:L[y]})]})]},y))}),e.jsxs("div",{className:"nice-cookie-consent__actions",children:[!T&&e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--details",onClick:()=>w(!0),children:b("cookie.customize","Customize")}),T&&e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--save",onClick:z,children:b("cookie.savePreferences","Save preferences")}),e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--reject",onClick:R,children:b("cookie.rejectAll","Reject all")}),e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--accept",onClick:O,children:b("cookie.acceptAll","Accept all")})]})]})}):null}),{displayName:"NiceCookieConsent"}),ce=Object.assign(s.forwardRef(({onSubmit:t,onForgotPassword:i,onRegister:a,loading:c=!1,error:n,variant:r="primary",size:d="md",showRememberMe:l=!0,showForgotPassword:u=!0,showRegister:h=!1,title:f,logo:_,usernameLabel:p,passwordLabel:o,usernamePlaceholder:v,passwordPlaceholder:x,className:g,style:j,id:b,testId:N,"data-testid":C,...I},T)=>{const w=m.useControlId(b),{t:k}=m.useNiceTranslation(),[E,P]=s.useState(""),[L,O]=s.useState(""),[R,z]=s.useState(!1),[$,q]=s.useState(!1),y=`${w}-user`,F=`${w}-pass`,D=`${w}-remember`,V=s.useCallback(S=>{S.preventDefault(),!c&&t?.({username:E,password:L,rememberMe:R})},[c,E,L,R,t]);return e.jsxs("form",{ref:T,id:w,className:`nice-login nice-login--${r} nice-login--${d} ${g??""}`,style:j,onSubmit:V,noValidate:!0,"data-testid":C??N,...I,children:[_&&e.jsx("div",{className:"nice-login__logo",children:_}),f&&e.jsx("h2",{className:"nice-login__title",children:f??k("login.title","Sign In")}),n&&e.jsx("div",{className:"nice-login__error",role:"alert",children:n}),e.jsxs("div",{className:"nice-login__field",children:[e.jsx("label",{htmlFor:y,className:"nice-login__label",children:p??k("login.username","Username")}),e.jsx("input",{id:y,className:"nice-login__input",type:"text",value:E,onChange:S=>P(S.target.value),placeholder:v??k("login.usernamePlaceholder","Enter your username"),autoComplete:"username",required:!0,disabled:c,"aria-required":"true"})]}),e.jsxs("div",{className:"nice-login__field",children:[e.jsx("label",{htmlFor:F,className:"nice-login__label",children:o??k("login.password","Password")}),e.jsxs("div",{className:"nice-login__password-wrap",children:[e.jsx("input",{id:F,className:"nice-login__input",type:$?"text":"password",value:L,onChange:S=>O(S.target.value),placeholder:x??k("login.passwordPlaceholder","Enter your password"),autoComplete:"current-password",required:!0,disabled:c,"aria-required":"true"}),e.jsx("button",{type:"button",className:"nice-login__toggle-password",onClick:()=>q(!$),"aria-label":$?k("login.hidePassword","Hide password"):k("login.showPassword","Show password"),tabIndex:-1,children:e.jsx(m.NiceIcon,{name:$?"eye-off":"eye",size:16})})]})]}),e.jsxs("div",{className:"nice-login__options",children:[l&&e.jsxs("label",{className:"nice-login__remember",htmlFor:D,children:[e.jsx("input",{id:D,type:"checkbox",checked:R,onChange:S=>z(S.target.checked),disabled:c}),e.jsx("span",{children:k("login.rememberMe","Remember me")})]}),u&&i&&e.jsx("button",{type:"button",className:"nice-login__forgot",onClick:i,disabled:c,children:k("login.forgotPassword","Forgot password?")})]}),e.jsx("button",{type:"submit",className:`nice-login__submit nice-login__submit--${r}`,disabled:c||!E||!L,children:c?k("login.loading","Signing in..."):k("login.submit","Sign In")}),h&&a&&e.jsxs("p",{className:"nice-login__register",children:[k("login.noAccount","Don't have an account?")," ",e.jsx("button",{type:"button",className:"nice-login__register-link",onClick:a,disabled:c,children:k("login.register","Register")})]})]})}),{displayName:"NiceLoginForm"});exports.NiceAlert=U;exports.NiceCookieConsent=re;exports.NiceDrawer=K;exports.NiceErrorBoundary=A;exports.NiceLoginForm=ce;exports.NiceOfflineBanner=ne;exports.NiceRetryPanel=te;exports.NiceTimeoutFeedback=ie;exports.NiceToastContainer=Y;exports.alertIcons=B;exports.useNiceTimeout=H;exports.useNiceToast=Q;