@objectstack/console 11.5.0 → 11.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-BoIMfid0.js → AdapterProvider-DvWb2IeS.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-C2yWGA5c.js → AiPendingActionsPage-BZfkGc0a.js} +1 -1
  4. package/dist/assets/{ApiConsolePage-CbOA7yU_.js → ApiConsolePage-C5gnskHZ.js} +1 -1
  5. package/dist/assets/{AppDocsIndex-DG7I33Q0.js → AppDocsIndex-DNt53Oi9.js} +1 -1
  6. package/dist/assets/{AppManagementPage-pZT1FFC3.js → AppManagementPage-Cy8KizoY.js} +1 -1
  7. package/dist/assets/{ApprovalsInboxPage-Bf1G6M2j.js → ApprovalsInboxPage-DvlDfedF.js} +1 -1
  8. package/dist/assets/{AuditLogPage-DhCB5Z43.js → AuditLogPage-CB99k9wq.js} +1 -1
  9. package/dist/assets/{ComponentNavView-DytkOwgZ.js → ComponentNavView-BuCUzee1.js} +1 -1
  10. package/dist/assets/ConsoleFloatingChatbot-ChPZiQGQ.js +1 -0
  11. package/dist/assets/{DashboardView-DfLxEvu6.js → DashboardView-CjTWewIf.js} +1 -1
  12. package/dist/assets/{DashboardWidgetInspector-kTGmMwv9.js → DashboardWidgetInspector-BhYevZBF.js} +1 -1
  13. package/dist/assets/{DeveloperHubPage-D754TyQo.js → DeveloperHubPage-BJG70ylS.js} +1 -1
  14. package/dist/assets/{ExpressionProvider-4nWMRYZf.js → ExpressionProvider-DHcGo-ds.js} +1 -1
  15. package/dist/assets/{FlowRunsPage-vP2vIZpQ.js → FlowRunsPage-CaFZwtCv.js} +1 -1
  16. package/dist/assets/{IntegrationsPage-CUcCoo0I.js → IntegrationsPage-D11m2Mgs.js} +1 -1
  17. package/dist/assets/{InterfaceListPage-BnbDtTf1.js → InterfaceListPage-qgFW8tPe.js} +1 -1
  18. package/dist/assets/{ManagedByBadge-BOZOeONh.js → ManagedByBadge-B_3CAxVP.js} +1 -1
  19. package/dist/assets/{MarketplaceAccessDenied-DQriAyJJ.js → MarketplaceAccessDenied-H_Jx42ON.js} +1 -1
  20. package/dist/assets/{MarketplaceInstalledPage-HCwduRx9.js → MarketplaceInstalledPage-Cspj47M8.js} +1 -1
  21. package/dist/assets/{MarketplacePackagePage-zwcTnk73.js → MarketplacePackagePage-BrIitTbZ.js} +2 -2
  22. package/dist/assets/MarketplacePage-h3TH16Xi.js +1 -0
  23. package/dist/assets/{MetadataInspector-uzqN-c_S.js → MetadataInspector--jXw9q3_.js} +1 -1
  24. package/dist/assets/{MetadataProvider-C517hbHZ.js → MetadataProvider-DuoHqlCv.js} +1 -1
  25. package/dist/assets/{PageView-C902zOSZ.js → PageView-B7XyzoE3.js} +1 -1
  26. package/dist/assets/{ProfilePage-D4ODPlXD.js → ProfilePage-CGieHQKA.js} +1 -1
  27. package/dist/assets/{PublicFormsPage-DyuMcLOS.js → PublicFormsPage-C5YlZJCf.js} +1 -1
  28. package/dist/assets/RecordDetailView-DdNF49JU.js +9 -0
  29. package/dist/assets/{RecordFormPage-Brux9Pwn.js → RecordFormPage-BWF_n9K1.js} +1 -1
  30. package/dist/assets/{ReportDefaultInspector-D5vXyOGX.js → ReportDefaultInspector-DXCs9PIk.js} +2 -2
  31. package/dist/assets/{ReportView-C-5CEger.js → ReportView-CnNDV38L.js} +1 -1
  32. package/dist/assets/{SearchResultsPage-DXcagT6P.js → SearchResultsPage-DXU1qpcP.js} +1 -1
  33. package/dist/assets/{SettingsHub-D7rRZ-on.js → SettingsHub-Dgn8w9aO.js} +1 -1
  34. package/dist/assets/SettingsView-C9v8ffrk.js +1 -0
  35. package/dist/assets/{SystemHubPage-Do0l-rwF.js → SystemHubPage-_QTnnAxO.js} +1 -1
  36. package/dist/assets/data-adapter-B8GFCm-C.js +7 -0
  37. package/dist/assets/{framework-C3RMhKDr.js → framework-BzwUcFJm.js} +8 -7
  38. package/dist/assets/{highlighted-body-OFNGDK62-DLIcWL3h.js → highlighted-body-OFNGDK62-JtalCdv1.js} +1 -1
  39. package/dist/assets/index-Ba1vnWIZ.css +2 -0
  40. package/dist/assets/index-BopJm3PU.js +2 -0
  41. package/dist/assets/mermaid-GHXKKRXX-G7SDbIK1.js +1 -0
  42. package/dist/assets/{metadata-admin-DigQrDYj.js → metadata-admin-BklciJ5H.js} +6 -6
  43. package/dist/assets/{plugin-calendar-Dt70natA.js → plugin-calendar-DVu__gQc.js} +1 -1
  44. package/dist/assets/plugin-charts-yK7P8AX5.js +7 -0
  45. package/dist/assets/plugin-chatbot-0LmsN1Va.js +120 -0
  46. package/dist/assets/plugin-dashboard-BCk2PLlx.js +6 -0
  47. package/dist/assets/plugin-form-DGPdqA5u.js +1 -0
  48. package/dist/assets/{plugin-gantt-DH-QLptQ.js → plugin-gantt-DcuxnZEc.js} +2 -2
  49. package/dist/assets/plugin-grid-BVUr9dNv.js +8 -0
  50. package/dist/assets/{plugin-kanban-BRV0WN7L.js → plugin-kanban-cqlDEL7v.js} +1 -1
  51. package/dist/assets/{plugin-map-CAe_xoWI.js → plugin-map-DufmkIU8.js} +1 -1
  52. package/dist/assets/{plugin-markdown-DVImgQYk.js → plugin-markdown-Dlim2oQH.js} +1 -1
  53. package/dist/assets/{plugin-report-B6rh7YXX.js → plugin-report-nKNTjtyj.js} +2 -2
  54. package/dist/assets/{plugin-timeline-ZyTfjz7e.js → plugin-timeline-HVMwCSYX.js} +1 -1
  55. package/dist/assets/{plugin-tree-DGkyQ0lj.js → plugin-tree-CVXeKvcL.js} +1 -1
  56. package/dist/assets/plugin-view-CF03uyex.js +1 -0
  57. package/dist/assets/plugins-views-D-6k7FrC.js +4 -0
  58. package/dist/assets/{skeletons-C-42w_MY.js → skeletons-CRKtyrMr.js} +1 -1
  59. package/dist/assets/src-Ce8iWu_4.js +12 -0
  60. package/dist/assets/{src-yxeLzGBZ.js → src-ClJ9jvV1.js} +1 -1
  61. package/dist/assets/{types-ChDtzQZB.js → types-BXER-wux.js} +1 -1
  62. package/dist/assets/ui-components-CLgu4Fon.js +42 -0
  63. package/dist/assets/{ui-layout-D1KjRJsh.js → ui-layout-FpTj4VqO.js} +1 -1
  64. package/dist/assets/{useActionModal-CsAqakCv.js → useActionModal-BPkUp8XL.js} +1 -1
  65. package/dist/assets/{useOpenRecordList-BYOFaY8y.js → useOpenRecordList-DzVq8Uen.js} +1 -1
  66. package/dist/assets/{useReconcileOnError-_QGJOfLf.js → useReconcileOnError-DSjYP3Fi.js} +1 -1
  67. package/dist/assets/vendor-objectstack-DTDITeDR.js +95 -0
  68. package/dist/assets/vendor-zod-DNgwlUUI.js +65 -0
  69. package/dist/index.html +4 -4
  70. package/package.json +1 -1
  71. package/dist/assets/ConsoleFloatingChatbot-5PFTo79W.js +0 -1
  72. package/dist/assets/MarketplacePage-Cr5TJn45.js +0 -1
  73. package/dist/assets/RecordDetailView-VR81HXSp.js +0 -9
  74. package/dist/assets/SettingsView-D0ApSSCe.js +0 -1
  75. package/dist/assets/data-adapter-BCQWtGB_.js +0 -1
  76. package/dist/assets/index-C_-Pgv1J.css +0 -2
  77. package/dist/assets/index-D27qs-mG.js +0 -2
  78. package/dist/assets/mermaid-GHXKKRXX-Du2PFYcS.js +0 -1
  79. package/dist/assets/plugin-charts-8ZEdKLDL.js +0 -7
  80. package/dist/assets/plugin-chatbot-CHOTmGHB.js +0 -120
  81. package/dist/assets/plugin-dashboard-Dpzs7Slc.js +0 -6
  82. package/dist/assets/plugin-form-ji-Rgf2e.js +0 -1
  83. package/dist/assets/plugin-grid-D1F45Vnr.js +0 -8
  84. package/dist/assets/plugin-view-24sHw0Ev.js +0 -1
  85. package/dist/assets/plugins-views-BT7UDPqk.js +0 -4
  86. package/dist/assets/src-rCeRf142.js +0 -12
  87. package/dist/assets/ui-components-CqkwtQve.js +0 -42
  88. package/dist/assets/vendor-objectstack-AFc_0VfZ.js +0 -96
  89. package/dist/assets/vendor-zod-BzP-Jkm3.js +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,m as i,t as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BySW-NB0.js";import{A as s,i as c,j as l,y as u}from"./framework-C3RMhKDr.js";import{Ar as d,Cr as f,G as p,K as m,Qs as h,Va as g,Y as _,ia as v}from"./ui-components-CqkwtQve.js";import"./AdapterProvider-BoIMfid0.js";import"./MetadataProvider-C517hbHZ.js";import{r as y}from"./ExpressionProvider-4nWMRYZf.js";import{Q as b,n as x,v as S}from"./ReportDefaultInspector-D5vXyOGX.js";import{n as C,r as w,t as T}from"./MetadataInspector-uzqN-c_S.js";import{i as ee,n as E,t as D}from"./useOpenRecordList-BYOFaY8y.js";import{r as O}from"./plugin-dashboard-Dpzs7Slc.js";var k=e(n(),1),A=a();function j({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,name:a,metadataClient:o,onAfterChange:s}){let{t:l}=c(),u=(0,k.useMemo)(()=>S(),[]),[p,m]=(0,k.useState)(!1),h=(0,k.useMemo)(()=>({...n??{}}),[n]),[g,_]=(0,k.useState)(h),v=(0,k.useRef)(g),y=(0,k.useRef)(h);y.current!==h&&(y.current=h,v.current=h,_(h),m(!1));let b=(0,k.useCallback)(e=>{let t={...v.current,...e};if(v.current=t,_(t),m(!0),i)for(let[n,r]of Object.entries(e))i(n,r,t)},[i]),C=(0,k.useCallback)(()=>{r(v.current),m(!1),t()},[r,t]),w=(0,k.useCallback)(e=>{let t={...e};v.current=t,_(t),m(!1)},[]),T=(0,k.useCallback)(()=>{t()},[t]);return e?(0,A.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`report-config-panel`,role:`complementary`,"aria-label":l(`report.editor.title`,{defaultValue:`Edit report`}),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium truncate`,children:l(`report.editor.title`,{defaultValue:`Edit report`})}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":l(`common.close`,{defaultValue:`Close`}),"data-testid":`report-config-close`,children:(0,A.jsx)(d,{className:`h-4 w-4`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,A.jsx)(x,{type:`report`,name:typeof g.name==`string`?g.name:``,draft:g,readOnly:!1,locale:u,onPatch:b})}),(0,A.jsxs)(`div`,{"data-testid":`report-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,A.jsx)(E,{type:`report`,name:a,metadataClient:o,dirty:p,onResume:w,onAfterChange:s}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:T,"data-testid":`report-config-discard`,children:l(`common.cancel`,{defaultValue:`Cancel`})}),(0,A.jsx)(f,{size:`sm`,onClick:C,"data-testid":`report-config-save`,children:l(`common.save`,{defaultValue:`Save`})})]})]}):null}var M=t({ReportView:()=>P}),N=(0,k.lazy)(()=>i(()=>import(`./plugin-report-B6rh7YXX.js`).then(e=>e.t).then(e=>({default:e.ReportViewer})),__vite__mapDeps([0]),import.meta.url)),te=(0,k.lazy)(()=>i(()=>import(`./plugin-report-B6rh7YXX.js`).then(e=>e.t).then(e=>({default:e.ReportRenderer})),__vite__mapDeps([0]),import.meta.url)),ne=[{value:`month`,label:`Month`,type:`text`},{value:`revenue`,label:`Revenue`,type:`number`},{value:`count`,label:`Count`,type:`number`},{value:`region`,label:`Region`,type:`text`},{value:`product`,label:`Product`,type:`text`},{value:`source`,label:`Lead Source`,type:`text`},{value:`stage`,label:`Stage`,type:`text`},{value:`amount`,label:`Amount`,type:`number`}];function P({dataSource:e}){let{t}=c(),{reportName:n}=r(),{showDebug:i}=C();s();let a=b(),d=o(),[f,x]=(0,k.useState)(!1),[S,E]=(0,k.useState)(0),{reports:M,objects:P,loading:F,refresh:I}=l(),{app:L}=y(),R=w(M,n,L?._packageId),[z,re]=(0,k.useState)(R),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)([]),[W,G]=(0,k.useState)(!1),K=D(),[q,J]=(0,k.useState)(null),Y=(0,k.useCallback)(e=>{if(!e||!P?.length)return;let t=P.find(t=>t.name===e);if(!t?.fields)return;let n=t.fields;return Array.isArray(n)?n.map(e=>typeof e==`string`?{value:e,label:e,type:`text`}:{value:e.name,label:e.label||e.name,type:e.type||`text`}):Object.entries(n).map(([e,t])=>({value:e,label:t.label||e,type:t.type||`text`}))},[P]),ie=(0,k.useCallback)(async({dataset:e,groupKey:t,object:n,objectFilter:r})=>{try{let i=Object.values(t).filter(e=>e!=null).map(e=>String(e)).join(` / `)||String(z?.label??z?.name??`Details`);if(n&&r){J({object:n,filter:r,title:i});return}let o=await a.get(`dataset`,e),s=typeof o?.object==`string`?o.object:void 0;if(!s)return;let c=Array.isArray(o?.dimensions)?o.dimensions:[],l=new Map(c.filter(e=>e?.name).map(e=>[e.name,e])),u=P?.find(e=>e.name===s)?.fields,d=e=>{if(Array.isArray(u))return u.find(t=>t?.name===e);if(u&&typeof u==`object`)return u[e]},f={};for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=l.get(e);if(t?.dateGranularity)continue;let r=t?.field||e,i=d(r);if(i?.type===`lookup`||i?.type===`master_detail`)continue;let a=n;if(Array.isArray(i?.options)){let e=i.options.find(e=>e?.label===n||e?.value===n);e&&e.value!=null&&(a=e.value)}f[r]=a}J({object:s,filter:f,title:i})}catch(e){console.warn(`ReportView: drill failed`,e)}},[a,P,z]),ae=(0,k.useMemo)(()=>{let e=B||z;return Y(e?.objectName||e?.dataSource?.object||e?.dataSource?.resource)??ne},[B,z,Y]),X=(0,k.useCallback)(async e=>{try{a&&(await ee(`report`,n,e,{metadataClient:a}),I().catch(()=>{}))}catch(e){console.warn(`[ReportView] Auto-save failed:`,e)}},[a,n,I]),oe=(0,k.useCallback)(()=>{V(z),x(!0),E(e=>e+1)},[z]),se=(0,k.useCallback)(()=>{x(!1)},[]),ce=(0,k.useMemo)(()=>B||z,[S]),le=(0,k.useCallback)(e=>{V(e),X(e),E(e=>e+1)},[X]),ue=(0,k.useCallback)((e,t)=>{V(n=>({...n,[e]:t}))},[]);(0,k.useEffect)(()=>{re(R)},[R]),(0,k.useEffect)(()=>{f||V(null)},[R]);let Z=B||z,Q=(0,k.useMemo)(()=>JSON.stringify(Z?.filters),[Z?.filters]),de=(0,k.useMemo)(()=>JSON.stringify(Z?.dataSource),[Z?.dataSource]),fe=(0,k.useMemo)(()=>JSON.stringify(Z?.data),[Z?.data]);if((0,k.useEffect)(()=>{if(!Z||!e){U([]);return}if(Z.data&&Array.isArray(Z.data)){U(Z.data);return}if(Z.dataSource){(async()=>{G(!0);try{let t=Z.dataSource.object||Z.dataSource.resource;if(!t){console.warn(`ReportView: dataSource missing object/resource property`),U([]);return}U((await e.find(t,{$filter:Z.dataSource.filter,$orderby:Z.dataSource.sort,$top:Z.dataSource.limit})).data||[])}catch(e){console.error(`ReportView: Failed to load data from dataSource`,e),U([])}finally{G(!1)}})();return}if(Z.objectName){(async()=>{G(!0);try{U((await e.find(Z.objectName,{$filter:Z.filters,$orderby:Z.sort,$top:Z.limit||100})).data||[])}catch(e){console.error(`ReportView: Failed to load data from objectName`,e),U([])}finally{G(!1)}})();return}U([])},[Z?.objectName,Z?.limit,Q,de,fe,e]),F)return(0,A.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,A.jsx)(g,{className:`h-8 w-8 animate-spin text-muted-foreground`})});if(!R||!z)return!F&&!R?(0,A.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,A.jsxs)(p,{children:[(0,A.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,A.jsx)(h,{className:`h-6 w-6 text-muted-foreground`})}),(0,A.jsx)(_,{children:t(`empty.reportNotFound`)}),(0,A.jsx)(m,{children:t(`empty.reportNotFoundDescription`,{name:n})})]})}):(0,A.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,A.jsx)(g,{className:`h-8 w-8 animate-spin text-muted-foreground`})});let pe=e=>{let t={...e};!t.title&&t.label&&(t.title=t.label);let n=t.objectName||t.dataSource?.object||t.dataSource?.resource,r=n?P?.find(e=>e.name===n):null,i=Array.isArray(r?.fields)?r.fields:r?.fields?Object.entries(r.fields).map(([e,t])=>({name:e,...t})):[],a={};for(let e of i)e&&e.name&&(a[e.name]=e);let o=e=>{let t=e.name||e.field,n=t?a[t]:void 0;if(!n)return e;let r={...e};if(r.type===void 0&&n.type!==void 0&&(r.type=n.type),r.options===void 0&&Array.isArray(n.options)&&(r.options=n.options),r.referenceTo===void 0){let e=n.referenceTo||n.reference?.to||n.target;e&&(r.referenceTo=e)}return r.label===void 0&&n.label&&(r.label=n.label),r};if(!t.fields&&Array.isArray(t.columns)?t.fields=t.columns.map(e=>{let t=o(e);return{name:t.field||t.name,label:t.label,type:t.type,options:t.options,referenceTo:t.referenceTo,format:t.format,renderAs:t.renderAs,colorMap:t.colorMap,...t.aggregate?{aggregation:t.aggregate,showInSummary:!0}:{}}}):Array.isArray(t.fields)&&(t.fields=t.fields.map(o)),t.fields&&Array.isArray(t.fields)&&t.fields.length>0){let n=t.fields.some(e=>e.showInSummary||e.aggregation),r=t.type||t.reportType||`tabular`,i=[];(r===`summary`||n)&&i.push({type:`summary`,title:`Key Metrics`}),i.push({type:`table`,title:`Details`,columns:t.fields.map(e=>({name:e.name,label:e.label,type:e.type,options:e.options,referenceTo:e.referenceTo,format:e.format,renderAs:e.renderAs,colorMap:e.colorMap}))});let a=t.chart||t.chartConfig,o=a?.type||a?.chartType;if(o){let e=a.xAxis||a.xAxisField,t=a.yAxis||a.yAxisFields?.[0];i.push({type:`chart`,title:`Chart`,chart:{type:`chart`,chartType:o,xAxisField:e,yAxisFields:t?[t]:a.yAxisFields}})}if(Array.isArray(e.sections)){let t=e.sections.filter(e=>e.type===`chart`&&!o);i.push(...t)}t.sections=i}else t.sections||=[];return t},$=B||z,me=!!($&&(typeof $.dataset==`string`||$.type===`joined`&&Array.isArray($.blocks)&&$.blocks.some(e=>typeof e?.dataset==`string`)))||!!($&&$.objectName&&($.type===`matrix`||$.type===`joined`||$.type===`summary`||$.type===`tabular`||$.type===void 0||Array.isArray($.groupingsAcross)&&$.groupingsAcross.length>0||Array.isArray($.columns))),he={type:`report-viewer`,report:pe($),data:H,showToolbar:!0,allowExport:!0,loading:W};return(0,A.jsxs)(u,{value:{openRecordList:K},children:[(0,A.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:$.title||$.label||`Report Viewer`}),$.description&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:$.description})]}),(0,A.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:d&&(0,A.jsxs)(`button`,{type:`button`,onClick:oe,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`report-edit-button`,children:[(0,A.jsx)(v,{className:`h-3.5 w-3.5`}),t(`common.edit`)]})})]}),(0,A.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,A.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-4 sm:p-6 lg:p-8 bg-muted/5`,children:(0,A.jsx)(`div`,{className:`w-full shadow-sm border rounded-lg sm:rounded-xl bg-background overflow-hidden min-h-150`,children:(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-8 text-sm text-muted-foreground`,children:t(`common.loading`,{defaultValue:`Loading…`})}),children:me?(0,A.jsx)(`div`,{className:`p-4 sm:p-6`,children:(0,A.jsx)(te,{schema:$,dataSource:e,rows:H,onDrill:ie})}):(0,A.jsx)(N,{schema:he})})})}),(0,A.jsx)(j,{open:f&&d,onClose:se,config:ce,onSave:le,onFieldChange:ue,availableFields:ae,getFieldsForObject:Y,name:n,metadataClient:a,onAfterChange:()=>I().catch(()=>{})}),(0,A.jsx)(T,{open:i,sections:[{title:`Report Configuration`,data:$}]})]})]}),(0,A.jsx)(O,{open:!!q,onClose:()=>J(null),title:q?.title??``,objectName:q?.object??``,filter:q?.filter,dataSource:e})]})}export{M as t};
2
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,m as i,t as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BySW-NB0.js";import{M as s,a as c,b as l,j as u}from"./framework-BzwUcFJm.js";import{Ar as d,Cr as f,G as p,K as m,Qs as h,Va as g,Y as _,ia as v}from"./ui-components-CLgu4Fon.js";import"./AdapterProvider-DvWb2IeS.js";import"./MetadataProvider-DuoHqlCv.js";import{r as y}from"./ExpressionProvider-DHcGo-ds.js";import{Q as b,n as x,v as S}from"./ReportDefaultInspector-DXCs9PIk.js";import{n as C,r as w,t as T}from"./MetadataInspector--jXw9q3_.js";import{i as ee,n as E,t as D}from"./useOpenRecordList-DzVq8Uen.js";import{r as O}from"./plugin-dashboard-BCk2PLlx.js";var k=e(n(),1),A=a();function j({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,name:a,metadataClient:o,onAfterChange:s}){let{t:l}=c(),u=(0,k.useMemo)(()=>S(),[]),[p,m]=(0,k.useState)(!1),h=(0,k.useMemo)(()=>({...n??{}}),[n]),[g,_]=(0,k.useState)(h),v=(0,k.useRef)(g),y=(0,k.useRef)(h);y.current!==h&&(y.current=h,v.current=h,_(h),m(!1));let b=(0,k.useCallback)(e=>{let t={...v.current,...e};if(v.current=t,_(t),m(!0),i)for(let[n,r]of Object.entries(e))i(n,r,t)},[i]),C=(0,k.useCallback)(()=>{r(v.current),m(!1),t()},[r,t]),w=(0,k.useCallback)(e=>{let t={...e};v.current=t,_(t),m(!1)},[]),T=(0,k.useCallback)(()=>{t()},[t]);return e?(0,A.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`report-config-panel`,role:`complementary`,"aria-label":l(`report.editor.title`,{defaultValue:`Edit report`}),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium truncate`,children:l(`report.editor.title`,{defaultValue:`Edit report`})}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":l(`common.close`,{defaultValue:`Close`}),"data-testid":`report-config-close`,children:(0,A.jsx)(d,{className:`h-4 w-4`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,A.jsx)(x,{type:`report`,name:typeof g.name==`string`?g.name:``,draft:g,readOnly:!1,locale:u,onPatch:b})}),(0,A.jsxs)(`div`,{"data-testid":`report-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,A.jsx)(E,{type:`report`,name:a,metadataClient:o,dirty:p,onResume:w,onAfterChange:s}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:T,"data-testid":`report-config-discard`,children:l(`common.cancel`,{defaultValue:`Cancel`})}),(0,A.jsx)(f,{size:`sm`,onClick:C,"data-testid":`report-config-save`,children:l(`common.save`,{defaultValue:`Save`})})]})]}):null}var M=t({ReportView:()=>P}),N=(0,k.lazy)(()=>i(()=>import(`./plugin-report-nKNTjtyj.js`).then(e=>e.t).then(e=>({default:e.ReportViewer})),__vite__mapDeps([0]),import.meta.url)),te=(0,k.lazy)(()=>i(()=>import(`./plugin-report-nKNTjtyj.js`).then(e=>e.t).then(e=>({default:e.ReportRenderer})),__vite__mapDeps([0]),import.meta.url)),ne=[{value:`month`,label:`Month`,type:`text`},{value:`revenue`,label:`Revenue`,type:`number`},{value:`count`,label:`Count`,type:`number`},{value:`region`,label:`Region`,type:`text`},{value:`product`,label:`Product`,type:`text`},{value:`source`,label:`Lead Source`,type:`text`},{value:`stage`,label:`Stage`,type:`text`},{value:`amount`,label:`Amount`,type:`number`}];function P({dataSource:e}){let{t}=c(),{reportName:n}=r(),{showDebug:i}=C();u();let a=b(),d=o(),[f,x]=(0,k.useState)(!1),[S,E]=(0,k.useState)(0),{reports:M,objects:P,loading:F,refresh:I}=s(),{app:L}=y(),R=w(M,n,L?._packageId),[z,re]=(0,k.useState)(R),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)([]),[W,G]=(0,k.useState)(!1),K=D(),[q,J]=(0,k.useState)(null),Y=(0,k.useCallback)(e=>{if(!e||!P?.length)return;let t=P.find(t=>t.name===e);if(!t?.fields)return;let n=t.fields;return Array.isArray(n)?n.map(e=>typeof e==`string`?{value:e,label:e,type:`text`}:{value:e.name,label:e.label||e.name,type:e.type||`text`}):Object.entries(n).map(([e,t])=>({value:e,label:t.label||e,type:t.type||`text`}))},[P]),ie=(0,k.useCallback)(async({dataset:e,groupKey:t,object:n,objectFilter:r})=>{try{let i=Object.values(t).filter(e=>e!=null).map(e=>String(e)).join(` / `)||String(z?.label??z?.name??`Details`);if(n&&r){J({object:n,filter:r,title:i});return}let o=await a.get(`dataset`,e),s=typeof o?.object==`string`?o.object:void 0;if(!s)return;let c=Array.isArray(o?.dimensions)?o.dimensions:[],l=new Map(c.filter(e=>e?.name).map(e=>[e.name,e])),u=P?.find(e=>e.name===s)?.fields,d=e=>{if(Array.isArray(u))return u.find(t=>t?.name===e);if(u&&typeof u==`object`)return u[e]},f={};for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=l.get(e);if(t?.dateGranularity)continue;let r=t?.field||e,i=d(r);if(i?.type===`lookup`||i?.type===`master_detail`)continue;let a=n;if(Array.isArray(i?.options)){let e=i.options.find(e=>e?.label===n||e?.value===n);e&&e.value!=null&&(a=e.value)}f[r]=a}J({object:s,filter:f,title:i})}catch(e){console.warn(`ReportView: drill failed`,e)}},[a,P,z]),ae=(0,k.useMemo)(()=>{let e=B||z;return Y(e?.objectName||e?.dataSource?.object||e?.dataSource?.resource)??ne},[B,z,Y]),X=(0,k.useCallback)(async e=>{try{a&&(await ee(`report`,n,e,{metadataClient:a}),I().catch(()=>{}))}catch(e){console.warn(`[ReportView] Auto-save failed:`,e)}},[a,n,I]),oe=(0,k.useCallback)(()=>{V(z),x(!0),E(e=>e+1)},[z]),se=(0,k.useCallback)(()=>{x(!1)},[]),ce=(0,k.useMemo)(()=>B||z,[S]),le=(0,k.useCallback)(e=>{V(e),X(e),E(e=>e+1)},[X]),ue=(0,k.useCallback)((e,t)=>{V(n=>({...n,[e]:t}))},[]);(0,k.useEffect)(()=>{re(R)},[R]),(0,k.useEffect)(()=>{f||V(null)},[R]);let Z=B||z,Q=(0,k.useMemo)(()=>JSON.stringify(Z?.filters),[Z?.filters]),de=(0,k.useMemo)(()=>JSON.stringify(Z?.dataSource),[Z?.dataSource]),fe=(0,k.useMemo)(()=>JSON.stringify(Z?.data),[Z?.data]);if((0,k.useEffect)(()=>{if(!Z||!e){U([]);return}if(Z.data&&Array.isArray(Z.data)){U(Z.data);return}if(Z.dataSource){(async()=>{G(!0);try{let t=Z.dataSource.object||Z.dataSource.resource;if(!t){console.warn(`ReportView: dataSource missing object/resource property`),U([]);return}U((await e.find(t,{$filter:Z.dataSource.filter,$orderby:Z.dataSource.sort,$top:Z.dataSource.limit})).data||[])}catch(e){console.error(`ReportView: Failed to load data from dataSource`,e),U([])}finally{G(!1)}})();return}if(Z.objectName){(async()=>{G(!0);try{U((await e.find(Z.objectName,{$filter:Z.filters,$orderby:Z.sort,$top:Z.limit||100})).data||[])}catch(e){console.error(`ReportView: Failed to load data from objectName`,e),U([])}finally{G(!1)}})();return}U([])},[Z?.objectName,Z?.limit,Q,de,fe,e]),F)return(0,A.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,A.jsx)(g,{className:`h-8 w-8 animate-spin text-muted-foreground`})});if(!R||!z)return!F&&!R?(0,A.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,A.jsxs)(p,{children:[(0,A.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,A.jsx)(h,{className:`h-6 w-6 text-muted-foreground`})}),(0,A.jsx)(_,{children:t(`empty.reportNotFound`)}),(0,A.jsx)(m,{children:t(`empty.reportNotFoundDescription`,{name:n})})]})}):(0,A.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,A.jsx)(g,{className:`h-8 w-8 animate-spin text-muted-foreground`})});let pe=e=>{let t={...e};!t.title&&t.label&&(t.title=t.label);let n=t.objectName||t.dataSource?.object||t.dataSource?.resource,r=n?P?.find(e=>e.name===n):null,i=Array.isArray(r?.fields)?r.fields:r?.fields?Object.entries(r.fields).map(([e,t])=>({name:e,...t})):[],a={};for(let e of i)e&&e.name&&(a[e.name]=e);let o=e=>{let t=e.name||e.field,n=t?a[t]:void 0;if(!n)return e;let r={...e};if(r.type===void 0&&n.type!==void 0&&(r.type=n.type),r.options===void 0&&Array.isArray(n.options)&&(r.options=n.options),r.referenceTo===void 0){let e=n.referenceTo||n.reference?.to||n.target;e&&(r.referenceTo=e)}return r.label===void 0&&n.label&&(r.label=n.label),r};if(!t.fields&&Array.isArray(t.columns)?t.fields=t.columns.map(e=>{let t=o(e);return{name:t.field||t.name,label:t.label,type:t.type,options:t.options,referenceTo:t.referenceTo,format:t.format,renderAs:t.renderAs,colorMap:t.colorMap,...t.aggregate?{aggregation:t.aggregate,showInSummary:!0}:{}}}):Array.isArray(t.fields)&&(t.fields=t.fields.map(o)),t.fields&&Array.isArray(t.fields)&&t.fields.length>0){let n=t.fields.some(e=>e.showInSummary||e.aggregation),r=t.type||t.reportType||`tabular`,i=[];(r===`summary`||n)&&i.push({type:`summary`,title:`Key Metrics`}),i.push({type:`table`,title:`Details`,columns:t.fields.map(e=>({name:e.name,label:e.label,type:e.type,options:e.options,referenceTo:e.referenceTo,format:e.format,renderAs:e.renderAs,colorMap:e.colorMap}))});let a=t.chart||t.chartConfig,o=a?.type||a?.chartType;if(o){let e=a.xAxis||a.xAxisField,t=a.yAxis||a.yAxisFields?.[0];i.push({type:`chart`,title:`Chart`,chart:{type:`chart`,chartType:o,xAxisField:e,yAxisFields:t?[t]:a.yAxisFields}})}if(Array.isArray(e.sections)){let t=e.sections.filter(e=>e.type===`chart`&&!o);i.push(...t)}t.sections=i}else t.sections||=[];return t},$=B||z,me=!!($&&(typeof $.dataset==`string`||$.type===`joined`&&Array.isArray($.blocks)&&$.blocks.some(e=>typeof e?.dataset==`string`)))||!!($&&$.objectName&&($.type===`matrix`||$.type===`joined`||$.type===`summary`||$.type===`tabular`||$.type===void 0||Array.isArray($.groupingsAcross)&&$.groupingsAcross.length>0||Array.isArray($.columns))),he={type:`report-viewer`,report:pe($),data:H,showToolbar:!0,allowExport:!0,loading:W};return(0,A.jsxs)(l,{value:{openRecordList:K},children:[(0,A.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:$.title||$.label||`Report Viewer`}),$.description&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:$.description})]}),(0,A.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:d&&(0,A.jsxs)(`button`,{type:`button`,onClick:oe,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`report-edit-button`,children:[(0,A.jsx)(v,{className:`h-3.5 w-3.5`}),t(`common.edit`)]})})]}),(0,A.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,A.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-4 sm:p-6 lg:p-8 bg-muted/5`,children:(0,A.jsx)(`div`,{className:`w-full shadow-sm border rounded-lg sm:rounded-xl bg-background overflow-hidden min-h-150`,children:(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(`div`,{className:`p-8 text-sm text-muted-foreground`,children:t(`common.loading`,{defaultValue:`Loading…`})}),children:me?(0,A.jsx)(`div`,{className:`p-4 sm:p-6`,children:(0,A.jsx)(te,{schema:$,dataSource:e,rows:H,onDrill:ie})}):(0,A.jsx)(N,{schema:he})})})}),(0,A.jsx)(j,{open:f&&d,onClose:se,config:ce,onSave:le,onFieldChange:ue,availableFields:ae,getFieldsForObject:Y,name:n,metadataClient:a,onAfterChange:()=>I().catch(()=>{})}),(0,A.jsx)(T,{open:i,sections:[{title:`Report Configuration`,data:$}]})]})]}),(0,A.jsx)(O,{open:!!q,onClose:()=>J(null),title:q?.title??``,objectName:q?.object??``,filter:q?.filter,dataSource:e})]})}export{M as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,p as i,r as a,t as o}from"./vendor-react-slxo-5GC.js";import{f as s}from"./infrastructure-BySW-NB0.js";import{i as c,j as l}from"./framework-C3RMhKDr.js";import{Ai as u,Io as d,Qa as f,Qs as p,ln as m,nr as h,rs as g,sr as _,tr as v,wc as y}from"./ui-components-CqkwtQve.js";import"./MetadataProvider-C517hbHZ.js";import{n as b}from"./ui-layout-D1KjRJsh.js";import{n as x}from"./appRoute-D5vwtoc_.js";var S=t({SearchResultsPage:()=>O}),C=e(n(),1),w=o();function T(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...T(n.children)):t.push(n);return t}var E={object:g,dashboard:f,page:d,report:p},D={object:`bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200`,dashboard:`bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200`,page:`bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200`,report:`bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200`};function O(){let{t:e}=c(),{appName:t}=r(),[n,o]=i(),[d,f]=(0,C.useState)(n.get(`q`)||``),{apps:p}=l(),S=p||[],O=x(S,t)||S[0],k=`/apps/${t}`,{user:A}=s(),j=(0,C.useMemo)(()=>{if(!O)return[];let e=T(O.navigation||[]),t={currentUserId:A?.id??null};return e.map(e=>{let{href:n}=b(e,k,t);return{id:e.id,label:e.label||e.objectName||e.dashboardName||e.pageName||e.reportName||``,href:n,type:e.type,description:e.description}}).filter(e=>e.href!==`#`)},[O,k,A?.id]),M=(0,C.useMemo)(()=>{if(!d.trim())return j;let e=d.toLowerCase();return j.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))},[j,d]),N=e=>{f(e),o(e?{q:e}:{})},P=(0,C.useMemo)(()=>{let e={};for(let t of M)(e[t.type]||=[]).push(t);return e},[M]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-4xl mx-auto`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsxs)(a,{to:k,className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(y,{className:`h-4 w-4`}),e(`search.back`)]}),(0,w.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`search.title`)})]}),(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(`label`,{htmlFor:`search-results-input`,className:`sr-only`,children:e(`search.placeholder`)}),(0,w.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(m,{id:`search-results-input`,value:d,onChange:e=>N(e.target.value),placeholder:e(`search.placeholder`),className:`pl-10 h-11 text-base`,autoFocus:!0})]}),(0,w.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:d.trim()?e(M.length===1?`search.resultsCount`:`search.resultsCountPlural`,{count:M.length,query:d}):e(`search.itemsAvailable`,{count:j.length})}),M.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,w.jsx)(u,{className:`h-12 w-12 text-muted-foreground/30 mb-4`}),(0,w.jsx)(`p`,{className:`text-lg font-medium text-muted-foreground`,children:e(`search.noResults`)}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground/80 mt-1`,children:e(`search.noResultsHint`)})]}):(0,w.jsx)(`div`,{className:`space-y-6`,children:Object.entries(P).map(([t,n])=>{let r=E[t]||g,i=`search.type${t.charAt(0).toUpperCase()}${t.slice(1)}s`;return`${t.charAt(0).toUpperCase()}${t.slice(1)}`,(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{className:`text-sm font-medium text-muted-foreground mb-2 flex items-center gap-1.5`,children:[(0,w.jsx)(r,{className:`h-4 w-4`}),e(i),(0,w.jsx)(_,{variant:`secondary`,className:`ml-1 text-xs`,children:n.length})]}),(0,w.jsx)(`div`,{className:`grid gap-2`,children:n.map(t=>{let n=E[t.type]||g,r=`search.badge${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}`;return(0,w.jsx)(a,{to:t.href,className:`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:(0,w.jsx)(v,{className:`hover:bg-accent/50 transition-colors cursor-pointer`,children:(0,w.jsxs)(h,{className:`flex items-center gap-3 p-3`,children:[(0,w.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded ${D[t.type]||``}`,children:(0,w.jsx)(n,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t.label}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:t.description})]}),(0,w.jsx)(_,{variant:`outline`,className:`text-xs shrink-0`,children:e(r)})]})})},t.id)})})]},t)})})]})}export{S as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,p as i,r as a,t as o}from"./vendor-react-slxo-5GC.js";import{f as s}from"./infrastructure-BySW-NB0.js";import{M as c,a as l}from"./framework-BzwUcFJm.js";import{Ai as u,Io as d,Qa as f,Qs as p,ln as m,nr as h,rs as g,sr as _,tr as v,wc as y}from"./ui-components-CLgu4Fon.js";import"./MetadataProvider-DuoHqlCv.js";import{n as b}from"./ui-layout-FpTj4VqO.js";import{n as x}from"./appRoute-D5vwtoc_.js";var S=t({SearchResultsPage:()=>O}),C=e(n(),1),w=o();function T(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...T(n.children)):t.push(n);return t}var E={object:g,dashboard:f,page:d,report:p},D={object:`bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200`,dashboard:`bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200`,page:`bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200`,report:`bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200`};function O(){let{t:e}=l(),{appName:t}=r(),[n,o]=i(),[d,f]=(0,C.useState)(n.get(`q`)||``),{apps:p}=c(),S=p||[],O=x(S,t)||S[0],k=`/apps/${t}`,{user:A}=s(),j=(0,C.useMemo)(()=>{if(!O)return[];let e=T(O.navigation||[]),t={currentUserId:A?.id??null};return e.map(e=>{let{href:n}=b(e,k,t);return{id:e.id,label:e.label||e.objectName||e.dashboardName||e.pageName||e.reportName||``,href:n,type:e.type,description:e.description}}).filter(e=>e.href!==`#`)},[O,k,A?.id]),M=(0,C.useMemo)(()=>{if(!d.trim())return j;let e=d.toLowerCase();return j.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))},[j,d]),N=e=>{f(e),o(e?{q:e}:{})},P=(0,C.useMemo)(()=>{let e={};for(let t of M)(e[t.type]||=[]).push(t);return e},[M]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-4xl mx-auto`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsxs)(a,{to:k,className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(y,{className:`h-4 w-4`}),e(`search.back`)]}),(0,w.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`search.title`)})]}),(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(`label`,{htmlFor:`search-results-input`,className:`sr-only`,children:e(`search.placeholder`)}),(0,w.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(m,{id:`search-results-input`,value:d,onChange:e=>N(e.target.value),placeholder:e(`search.placeholder`),className:`pl-10 h-11 text-base`,autoFocus:!0})]}),(0,w.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:d.trim()?e(M.length===1?`search.resultsCount`:`search.resultsCountPlural`,{count:M.length,query:d}):e(`search.itemsAvailable`,{count:j.length})}),M.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,w.jsx)(u,{className:`h-12 w-12 text-muted-foreground/30 mb-4`}),(0,w.jsx)(`p`,{className:`text-lg font-medium text-muted-foreground`,children:e(`search.noResults`)}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground/80 mt-1`,children:e(`search.noResultsHint`)})]}):(0,w.jsx)(`div`,{className:`space-y-6`,children:Object.entries(P).map(([t,n])=>{let r=E[t]||g,i=`search.type${t.charAt(0).toUpperCase()}${t.slice(1)}s`;return`${t.charAt(0).toUpperCase()}${t.slice(1)}`,(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{className:`text-sm font-medium text-muted-foreground mb-2 flex items-center gap-1.5`,children:[(0,w.jsx)(r,{className:`h-4 w-4`}),e(i),(0,w.jsx)(_,{variant:`secondary`,className:`ml-1 text-xs`,children:n.length})]}),(0,w.jsx)(`div`,{className:`grid gap-2`,children:n.map(t=>{let n=E[t.type]||g,r=`search.badge${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}`;return(0,w.jsx)(a,{to:t.href,className:`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:(0,w.jsx)(v,{className:`hover:bg-accent/50 transition-colors cursor-pointer`,children:(0,w.jsxs)(h,{className:`flex items-center gap-3 p-3`,children:[(0,w.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded ${D[t.type]||``}`,children:(0,w.jsx)(n,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t.label}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:t.description})]}),(0,w.jsx)(_,{variant:`outline`,className:`text-xs shrink-0`,children:e(r)})]})})},t.id)})})]},t)})})]})}export{S as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n,u as r}from"./vendor-react-slxo-5GC.js";import{Di as i,ar as a,ir as o,nr as s,rr as c,sr as l,tr as u,zt as d}from"./ui-components-CqkwtQve.js";import{o as f,r as p,t as m}from"./types-ChDtzQZB.js";var h=e(t(),1),g=n();function _(){let e=r(),[t,n]=(0,h.useState)(null),[_,v]=(0,h.useState)(null);(0,h.useEffect)(()=>{p().then(e=>n(e.manifests??[])).catch(e=>v(e?.message??`Failed to load settings`))},[]);let y=(0,h.useMemo)(()=>{if(!t)return null;let e=new Map;for(let n of[...t].sort((e,t)=>(e.order??999)-(t.order??999))){let t=n.category??`Other`,r=e.get(t)??[];r.push(n),e.set(t,r)}return e},[t]);return(0,g.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,g.jsx)(i,{className:`h-7 w-7 text-muted-foreground`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Settings`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure your workspace, integrations, and feature flags.`})]})]}),_?(0,g.jsx)(u,{children:(0,g.jsx)(s,{className:`py-8 text-center text-sm text-destructive`,children:_})}):null,t?t.length===0?(0,g.jsx)(u,{children:(0,g.jsx)(s,{className:`py-12 text-center text-sm text-muted-foreground`,children:`No settings registered. Plugins can register settings manifests via the SettingsService.`})}):Array.from(y??[]).map(([t,n])=>(0,g.jsxs)(`section`,{className:`mb-8`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold tracking-wide uppercase text-muted-foreground mb-3`,children:t}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:n.map(t=>(0,g.jsxs)(u,{className:`cursor-pointer hover:border-primary/50 hover:shadow-sm transition-all`,onClick:()=>e(`/system/settings/${t.namespace}`),children:[(0,g.jsxs)(o,{className:`pb-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,g.jsx)(t.icon?f(t.icon):i,{className:`h-6 w-6 text-muted-foreground`}),t.beta?(0,g.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`Beta`}):null]}),(0,g.jsx)(a,{className:`text-base mt-2`,children:m(t.label)}),t.description?(0,g.jsx)(c,{className:`text-xs`,children:t.description}):null]}),(0,g.jsx)(s,{className:`pt-0`,children:(0,g.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[t.specifiers.length,` setting`,t.specifiers.length===1?``:`s`]})})]},t.namespace))})]},t)):(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsx)(d,{className:`h-6 w-32`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3}).map((e,t)=>(0,g.jsx)(d,{className:`h-32 w-full`},t))})]})]})}export{_ as SettingsHub};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n,u as r}from"./vendor-react-slxo-5GC.js";import{Di as i,ar as a,ir as o,nr as s,rr as c,sr as l,tr as u,zt as d}from"./ui-components-CLgu4Fon.js";import{o as f,r as p,t as m}from"./types-BXER-wux.js";var h=e(t(),1),g=n();function _(){let e=r(),[t,n]=(0,h.useState)(null),[_,v]=(0,h.useState)(null);(0,h.useEffect)(()=>{p().then(e=>n(e.manifests??[])).catch(e=>v(e?.message??`Failed to load settings`))},[]);let y=(0,h.useMemo)(()=>{if(!t)return null;let e=new Map;for(let n of[...t].sort((e,t)=>(e.order??999)-(t.order??999))){let t=n.category??`Other`,r=e.get(t)??[];r.push(n),e.set(t,r)}return e},[t]);return(0,g.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,g.jsx)(i,{className:`h-7 w-7 text-muted-foreground`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Settings`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure your workspace, integrations, and feature flags.`})]})]}),_?(0,g.jsx)(u,{children:(0,g.jsx)(s,{className:`py-8 text-center text-sm text-destructive`,children:_})}):null,t?t.length===0?(0,g.jsx)(u,{children:(0,g.jsx)(s,{className:`py-12 text-center text-sm text-muted-foreground`,children:`No settings registered. Plugins can register settings manifests via the SettingsService.`})}):Array.from(y??[]).map(([t,n])=>(0,g.jsxs)(`section`,{className:`mb-8`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold tracking-wide uppercase text-muted-foreground mb-3`,children:t}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:n.map(t=>(0,g.jsxs)(u,{className:`cursor-pointer hover:border-primary/50 hover:shadow-sm transition-all`,onClick:()=>e(`/system/settings/${t.namespace}`),children:[(0,g.jsxs)(o,{className:`pb-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,g.jsx)(t.icon?f(t.icon):i,{className:`h-6 w-6 text-muted-foreground`}),t.beta?(0,g.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`Beta`}):null]}),(0,g.jsx)(a,{className:`text-base mt-2`,children:m(t.label)}),t.description?(0,g.jsx)(c,{className:`text-xs`,children:t.description}):null]}),(0,g.jsx)(s,{className:`pt-0`,children:(0,g.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[t.specifiers.length,` setting`,t.specifiers.length===1?``:`s`]})})]},t.namespace))})]},t)):(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsx)(d,{className:`h-6 w-32`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3}).map((e,t)=>(0,g.jsx)(d,{className:`h-32 w-full`},t))})]})]})}export{_ as SettingsHub};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{a}from"./framework-BzwUcFJm.js";import{Ba as o,Cr as s,Jt as c,Kt as l,Ri as u,Va as d,Vs as f,Xt as p,Yt as m,Zt as h,bt as g,ct as _,dr as v,er as y,fr as b,in as x,ln as S,nr as C,oo as w,pn as T,pr as E,qt as D,rn as O,sr as k,tr as A,wc as j,yt as M,zt as N}from"./ui-components-CLgu4Fon.js";import{r as P}from"./vendor-ui-utils-C1OpMExs.js";import{a as F,i as I,n as L,o as R,t as z}from"./types-BXER-wux.js";var B=e(t(),1),V=r();function H({reason:e,className:t}){return(0,V.jsxs)(k,{variant:`outline`,className:`gap-1 border-amber-300 bg-amber-50 text-amber-900 ${t??``}`,title:e??`Pinned by environment variable — cannot be edited from the UI.`,children:[(0,V.jsx)(o,{className:`h-3 w-3`}),`Locked by env`]})}function U({resolved:e,labels:t}){let n=e.cascadeChain;if(!n||n.length===0)return null;let r=n.find(e=>e.effective)??n[n.length-1],i=n.find(e=>e!==r&&e.value!==null&&e.value!==void 0),a=e=>t?.sourceLabel?.(e)??e;return r.scope!=="default"&&r.scope!==`user`&&r.scope!==`tenant`?(0,V.jsxs)(k,{variant:`outline`,className:`text-blue-700 border-blue-300 text-[10px]`,children:[`Inherited from `,a(r.scope)]}):i?(0,V.jsxs)(k,{variant:`outline`,className:`text-amber-700 border-amber-300 text-[10px]`,children:[`Overrides `,a(i.scope)]}):null}function W({spec:e,resolved:t,labelText:n,labels:r}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(T,{className:`text-sm font-medium`,children:[n,e.required?(0,V.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}):null]}),e.deprecated?(0,V.jsxs)(k,{variant:`outline`,className:`text-amber-700 border-amber-300`,children:[`Deprecated`,e.replacedBy?` → ${e.replacedBy}`:``]}):null,t?.locked?(0,V.jsx)(H,{reason:t.lockedReason}):null,t&&!t.locked?(0,V.jsx)(U,{resolved:t,labels:r}):null,t?.source&&t.source!=="default"&&!t.locked?(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r?.sourceLabel?.(t.source)??t.source}):null]})}function G({description:e}){return e?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e}):null}function K(e){let{spec:t,resolved:n,value:r,onChange:i,onAction:a,locked:o,saving:u,labels:d}=e,C=(0,B.useId)(),k=!!(o||u),A=z(t.label),j=t.key&&d?d.fieldLabel(t.key,A):A,N=t.key&&d?d.fieldHelp(t.key,t.description):t.description;if(t.type===`group`){let e=t.id&&d?d.groupTitle(t.id,A):A,n=t.id&&d?d.groupDescription(t.id,t.description):t.description;return(0,V.jsxs)(`div`,{className:`pt-6 pb-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold tracking-tight text-foreground/90`,children:e}),n?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n}):null,(0,V.jsx)(l,{className:`mt-3`})]})}if(t.type===`info_banner`)return(0,V.jsxs)(v,{variant:t.bannerSeverity===`error`?`destructive`:`default`,className:`my-2`,children:[(0,V.jsx)(w,{className:`h-4 w-4`}),(0,V.jsx)(E,{children:A}),t.bannerText?(0,V.jsx)(b,{children:t.bannerText}):null]});if(t.type===`child_pane`)return(0,V.jsxs)(`a`,{href:`#/settings/${t.childNamespace}`,className:`flex items-center justify-between rounded-md border border-border bg-card px-4 py-3 hover:bg-accent transition-colors`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium`,children:A}),t.description?(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.description}):null]}),(0,V.jsx)(f,{className:`h-4 w-4 text-muted-foreground`})]});if(t.type===`title_value`)return(0,V.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,V.jsx)(W,{spec:t,resolved:n,labelText:j,labels:d}),(0,V.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:String(r??`—`)})]});if(t.type===`action_button`){let e=t.icon?R(t.icon):null,n=t.id??t.key??`test`,r=d?d.actionLabel(n,A):A;return(0,V.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium`,children:r}),t.description?(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t.description}):null]}),(0,V.jsxs)(s,{size:`sm`,variant:`secondary`,onClick:a,disabled:u,children:[e?(0,V.jsx)(e,{className:`h-4 w-4 mr-1.5`}):null,r]})]})}let P=e=>(0,V.jsxs)(`div`,{className:`space-y-1.5 py-2`,children:[(0,V.jsx)(W,{spec:t,resolved:n,labelText:j,labels:d}),e,(0,V.jsx)(G,{description:N})]}),F=e=>{let n=typeof e.label==`string`?e.label:e.label?.defaultValue??String(e.value);return!t.key||!d?n:d.optionLabel(t.key,String(e.value),n)};switch(t.type){case`text`:case`email`:case`url`:case`phone`:return P((0,V.jsx)(S,{id:C,type:t.type===`email`?`email`:t.type===`url`?`url`:`text`,value:r??``,minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,disabled:k,onChange:e=>i(e.target.value)}));case`password`:return P((0,V.jsx)(S,{id:C,type:`password`,autoComplete:`new-password`,placeholder:r?`••••••••`:``,disabled:k,onChange:e=>i(e.target.value)}));case`textarea`:return P((0,V.jsx)(_,{id:C,rows:t.rows??4,value:r??``,minLength:t.minLength,maxLength:t.maxLength,disabled:k,onChange:e=>i(e.target.value)}));case`number`:return P((0,V.jsx)(S,{id:C,type:`number`,value:r,min:t.min,max:t.max,step:t.step,disabled:k,onChange:e=>i(e.target.value===``?null:Number(e.target.value))}));case`toggle`:return(0,V.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(W,{spec:t,resolved:n,labelText:j,labels:d}),(0,V.jsx)(G,{description:N})]}),(0,V.jsx)(M,{id:C,checked:!!r,disabled:k,onCheckedChange:e=>i(e)})]});case`select`:return P((0,V.jsxs)(D,{value:r==null?void 0:String(r),onValueChange:e=>i(e),disabled:k,children:[(0,V.jsx)(p,{id:C,children:(0,V.jsx)(h,{placeholder:`Select…`})}),(0,V.jsx)(c,{children:t.options?.map(e=>(0,V.jsx)(m,{value:String(e.value),children:F(e)},String(e.value)))})]}));case`radio`:return P((0,V.jsx)(O,{value:r==null?void 0:String(r),onValueChange:e=>i(e),disabled:k,children:t.options?.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsx)(x,{value:String(e.value),id:`${C}-${e.value}`}),(0,V.jsx)(T,{htmlFor:`${C}-${e.value}`,className:`text-sm font-normal`,children:F(e)})]},String(e.value)))}));case`multiselect`:{let e=Array.isArray(r)?r:[];return P((0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:t.options?.map(t=>{let n=String(t.value);return(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(y,{checked:e.map(String).includes(n),disabled:k,onCheckedChange:t=>{let r=new Set(e.map(String));t?r.add(n):r.delete(n),i(Array.from(r))}}),F(t)]},n)})}))}case`slider`:return P((0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(g,{value:[Number(r??t.min??0)],min:t.min??0,max:t.max??100,step:t.step??1,disabled:k,onValueChange:e=>i(e[0]),className:`flex-1`}),(0,V.jsx)(`span`,{className:`text-sm tabular-nums w-12 text-right`,children:String(r??t.min??0)})]}));case`color`:return P((0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(S,{id:C,type:`color`,value:r??`#000000`,disabled:k,onChange:e=>i(e.target.value),className:`w-16 h-9 p-1`}),(0,V.jsx)(S,{value:r??``,disabled:k,onChange:e=>i(e.target.value),className:`flex-1 font-mono text-sm`})]}));case`json`:return P((0,V.jsx)(_,{id:C,rows:t.rows??6,className:`font-mono text-xs`,value:typeof r==`string`?r:JSON.stringify(r??null,null,2),disabled:k,onChange:e=>i(e.target.value)}));default:return P((0,V.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Unsupported specifier type: `,t.type]}))}}var q=new Set([`common`,`validation`,`errors`,`system`,`auth`]);function J(e){let{t,i18n:n}=a();return(0,B.useMemo)(()=>{let r=()=>{if(!n||typeof n.getResourceBundle!=`function`)return[];let e=n.language||`en`,t=n.getResourceBundle(e,`translation`);return t?Object.keys(t).filter(e=>!q.has(e)&&t[e]&&typeof t[e]==`object`&&t[e].settings):[]},i=(n,i)=>{if(!e)return i;try{let i=r();for(let r of i){let i=`${r}.settings.${e}.${n}`,a=t(i,{defaultValue:``});if(a&&a!==i&&a!==``)return a}}catch{}return i},a=(e,r)=>{try{if(!n||typeof n.getResourceBundle!=`function`)return r;let i=n.language||`en`,a=n.getResourceBundle(i,`translation`);if(!a)return r;for(let n of Object.keys(a)){if(q.has(n))continue;let r=a[n];if(!r||typeof r!=`object`||!(`settingsCommon`in r))continue;let i=`${n}.settingsCommon.${e}`,o=t(i,{defaultValue:``});if(o&&o!==i&&o!==``)return o}}catch{}return r},o={env:`Env`,global:`Global`,tenant:`Tenant`,user:`User`,default:`Default`};return{title:e=>i(`title`,e)??e,description:e=>i(`description`,e),groupTitle:(e,t)=>i(`groups.${e}.title`,t)??t,groupDescription:(e,t)=>i(`groups.${e}.description`,t),fieldLabel:(e,t)=>i(`keys.${e}.label`,t)??t,fieldHelp:(e,t)=>i(`keys.${e}.help`,t),fieldPlaceholder:(e,t)=>i(`keys.${e}.placeholder`,t),optionLabel:(e,t,n)=>i(`keys.${e}.options.${t}`,n)??n,actionLabel:(e,t)=>i(`actions.${e}.label`,t)??t,actionConfirm:(e,t)=>i(`actions.${e}.confirmText`,t),actionSuccess:(e,t)=>i(`actions.${e}.successMessage`,t),sourceLabel:e=>a(`sourceLabels.${e}`,o[e]??e)}},[e,t,n,n?.language])}function Y(e,t){if(!e)return!0;let n=e.trim().match(/^\$\{(.+)\}$/);if(!n)return!0;try{return!!Function(`data`,`with (data) { return (${n[1]}); }`)(t)}catch{return!0}}function X(){let e=n(),t=i(),r=e.namespace??``,[a,o]=(0,B.useState)(null),[c,l]=(0,B.useState)(!0),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)({}),v=(0,B.useCallback)(async()=>{l(!0),h(null);try{o(await L(r)),_({})}catch(e){h(e?.message??`Failed to load settings`)}finally{l(!1)}},[r]);(0,B.useEffect)(()=>{r&&v()},[r,v]);let y=(0,B.useMemo)(()=>{let e={};if(!a)return e;for(let[t,n]of Object.entries(a.values))e[t]=n.value;return{...e,...g}},[a,g]),b=(0,B.useMemo)(()=>Object.keys(g),[g]),x=J(r);if(!r)return(0,V.jsx)(`div`,{className:`p-6 text-muted-foreground`,children:`No namespace selected.`});if(c)return(0,V.jsxs)(`div`,{className:`p-6 space-y-3 max-w-3xl`,children:[(0,V.jsx)(N,{className:`h-8 w-1/3`}),(0,V.jsx)(N,{className:`h-4 w-2/3`}),(0,V.jsx)(N,{className:`h-32 w-full`}),(0,V.jsx)(N,{className:`h-32 w-full`})]});if(m)return(0,V.jsxs)(`div`,{className:`p-6 max-w-3xl`,children:[(0,V.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:()=>t(-1),children:[(0,V.jsx)(j,{className:`h-4 w-4 mr-1`}),` Back`]}),(0,V.jsx)(A,{className:`mt-3`,children:(0,V.jsx)(C,{className:`py-8 text-center text-sm text-destructive`,children:m})})]});if(!a)return null;let{manifest:S,values:w}=a,T=S.icon?R(S.icon):null,E=x.title(z(S.label)),D=x.description(S.description),O=async()=>{if(b.length!==0){p(!0);try{let e=await F(r,g);o({...a,values:{...w,...e.values}}),_({}),P.success(`Settings saved`)}catch(e){e?.payload?.error?.code===`SETTINGS_LOCKED`?P.error(`Locked by environment: ${e.payload.error.key}`):P.error(e?.message??`Save failed`)}finally{p(!1)}}},M=async e=>{p(!0);try{let t=await I(r,e,g);t.ok?P.success(t.message??`Action succeeded`):P.error(t.message??`Action failed`)}catch(e){P.error(e?.message??`Action failed`)}finally{p(!1)}};return(0,V.jsxs)(`div`,{className:`p-6 max-w-3xl mx-auto pb-32`,children:[(0,V.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:()=>t(`/system/settings`),children:[(0,V.jsx)(j,{className:`h-4 w-4 mr-1`}),` All settings`]}),(0,V.jsxs)(`div`,{className:`mt-3 flex items-start gap-3`,children:[T?(0,V.jsx)(T,{className:`h-7 w-7 mt-0.5 text-muted-foreground`}):null,(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:E}),S.beta?(0,V.jsx)(k,{variant:`secondary`,children:`Beta`}):null]}),D?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:D}):null]})]}),S.helpText?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground mt-4 whitespace-pre-wrap`,children:S.helpText}):null,(0,V.jsx)(`div`,{className:`mt-6 divide-y`,children:S.specifiers.filter(e=>Y(e.visible,y)).map((e,t)=>{let n=e.key,r=n?w[n]:void 0;return(0,V.jsx)(K,{spec:e,resolved:r,value:n?n in g?g[n]:r?.value:void 0,onChange:e=>n&&_(t=>({...t,[n]:e})),onAction:e.type===`action_button`?()=>M(e.id??n??`test`):void 0,locked:r?.locked,saving:f,labels:x},(n??`_layout_${t}`)+t)})}),b.length>0?(0,V.jsx)(`div`,{className:`fixed bottom-0 inset-x-0 bg-background/95 backdrop-blur border-t shadow-lg z-40`,children:(0,V.jsxs)(`div`,{className:`max-w-3xl mx-auto px-6 py-3 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[b.length,` unsaved change`,b.length>1?`s`:``]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:()=>_({}),disabled:f,children:[(0,V.jsx)(u,{className:`h-4 w-4 mr-1`}),` Discard`]}),(0,V.jsxs)(s,{onClick:O,disabled:f,children:[f?(0,V.jsx)(d,{className:`h-4 w-4 mr-1 animate-spin`}):null,`Save changes`]})]})]})}):null]})}export{X as SettingsView};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BySW-NB0.js";import{A as o}from"./framework-C3RMhKDr.js";import{Di as s,Rr as c,Si as l,Va as u,Za as d,ar as f,ci as p,ir as m,ji as h,lc as g,nc as _,ni as v,no as y,nr as b,rr as x,rs as S,sc as C,sr as w,tr as T,zr as E}from"./ui-components-CqkwtQve.js";import"./src-rCeRf142.js";var D=e(t(),1),O=r();function k(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,k=o(),A=a(),[j,M]=(0,D.useState)({users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[N,P]=(0,D.useState)(!0),F=(0,D.useCallback)(async()=>{if(k){P(!0);try{let[e,t,n,r,i]=await Promise.all([k.find(`sys_user`).catch(()=>({data:[]})),k.find(`sys_org`).catch(()=>({data:[]})),k.find(`sys_role`).catch(()=>({data:[]})),k.find(`sys_permission`).catch(()=>({data:[]})),k.find(`sys_audit_log`).catch(()=>({data:[]}))]);M({users:e.data?.length??0,orgs:t.data?.length??0,roles:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{P(!1)}}},[k]);(0,D.useEffect)(()=>{F()},[F]);let I=[{title:`Applications`,description:`Manage all configured applications`,icon:d,href:`${r}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:S,href:`${r}/component/metadata/directory`,countLabel:``,count:null},{title:`Datasources`,description:`Connect external databases and sync their tables in as objects`,icon:C,href:`${r}/component/metadata/resource?type=datasource`,countLabel:``,count:null}],L=[{title:`Users`,description:`Manage system users and accounts`,icon:c,href:`${r}/system/users`,countLabel:`users`,count:j.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:_,href:`${r}/system/organizations`,countLabel:`organizations`,count:j.orgs},{title:`Roles`,description:`Configure roles and access levels`,icon:l,href:`${r}/system/roles`,countLabel:`roles`,count:j.roles},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:y,href:`${r}/system/permissions`,countLabel:`permissions`,count:j.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:h,href:`${r}/system/audit-log`,countLabel:`entries`,count:j.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:g,href:`${r}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:p,href:`${r}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:s,href:`${r}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:v,href:`${r}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:E,href:`${r}/system/profile`,countLabel:``,count:null}],R=[...I,...L].filter(e=>!e.adminOnly||A);return(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, roles, permissions, and system configuration`})]}),N&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,O.jsx)(u,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:R.map(t=>{let n=t.icon;return(0,O.jsxs)(T,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,O.jsxs)(m,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,O.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,O.jsx)(n,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base`,children:t.title}),(0,O.jsx)(x,{className:`text-xs`,children:t.description})]})]}),(0,O.jsx)(b,{className:`pt-0`,children:t.count!==null&&(0,O.jsxs)(w,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{k as SystemHubPage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BySW-NB0.js";import{j as o}from"./framework-BzwUcFJm.js";import{Di as s,Rr as c,Si as l,Va as u,Za as d,ar as f,ci as p,ir as m,ji as h,lc as g,nc as _,ni as v,no as y,nr as b,rr as x,rs as S,sc as C,sr as w,tr as T,zr as E}from"./ui-components-CLgu4Fon.js";import"./src-Ce8iWu_4.js";var D=e(t(),1),O=r();function k(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,k=o(),A=a(),[j,M]=(0,D.useState)({users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[N,P]=(0,D.useState)(!0),F=(0,D.useCallback)(async()=>{if(k){P(!0);try{let[e,t,n,r,i]=await Promise.all([k.find(`sys_user`).catch(()=>({data:[]})),k.find(`sys_org`).catch(()=>({data:[]})),k.find(`sys_role`).catch(()=>({data:[]})),k.find(`sys_permission`).catch(()=>({data:[]})),k.find(`sys_audit_log`).catch(()=>({data:[]}))]);M({users:e.data?.length??0,orgs:t.data?.length??0,roles:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{P(!1)}}},[k]);(0,D.useEffect)(()=>{F()},[F]);let I=[{title:`Applications`,description:`Manage all configured applications`,icon:d,href:`${r}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:S,href:`${r}/component/metadata/directory`,countLabel:``,count:null},{title:`Datasources`,description:`Connect external databases and sync their tables in as objects`,icon:C,href:`${r}/component/metadata/resource?type=datasource`,countLabel:``,count:null}],L=[{title:`Users`,description:`Manage system users and accounts`,icon:c,href:`${r}/system/users`,countLabel:`users`,count:j.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:_,href:`${r}/system/organizations`,countLabel:`organizations`,count:j.orgs},{title:`Roles`,description:`Configure roles and access levels`,icon:l,href:`${r}/system/roles`,countLabel:`roles`,count:j.roles},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:y,href:`${r}/system/permissions`,countLabel:`permissions`,count:j.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:h,href:`${r}/system/audit-log`,countLabel:`entries`,count:j.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:g,href:`${r}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:p,href:`${r}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:s,href:`${r}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:v,href:`${r}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:E,href:`${r}/system/profile`,countLabel:``,count:null}],R=[...I,...L].filter(e=>!e.adminOnly||A);return(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, roles, permissions, and system configuration`})]}),N&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,O.jsx)(u,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:R.map(t=>{let n=t.icon;return(0,O.jsxs)(T,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,O.jsxs)(m,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,O.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,O.jsx)(n,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base`,children:t.title}),(0,O.jsx)(x,{className:`text-xs`,children:t.description})]})]}),(0,O.jsx)(b,{className:`pt-0`,children:t.count!==null&&(0,O.jsxs)(w,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{k as SystemHubPage};