@objectstack/console 9.4.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdapterProvider-BNNEwHx0.js → AdapterProvider-SUUXFZyj.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-DOSHy962.js → AiPendingActionsPage-CO8ZvJjv.js} +1 -1
- package/dist/assets/{ApiConsolePage-CruwU0Up.js → ApiConsolePage-Lut37HSM.js} +1 -1
- package/dist/assets/AppDocsIndex-pApFrxYy.js +1 -0
- package/dist/assets/{AppManagementPage-BohnYqad.js → AppManagementPage-02_IDuK5.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-BGmv2uNL.js → ApprovalsInboxPage-jrOq7K_-.js} +1 -1
- package/dist/assets/{AuditLogPage-KrpMMNiw.js → AuditLogPage-dNTjEy4d.js} +1 -1
- package/dist/assets/{ComponentNavView-JMyYlvFq.js → ComponentNavView-DZTCPZQw.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-C7wdj16w.js → ConsoleFloatingChatbot-aVi2RipX.js} +1 -1
- package/dist/assets/{DashboardView-DUqOAEyx.js → DashboardView-tRpQP3s_.js} +1 -1
- package/dist/assets/{DashboardWidgetInspector-Dhe9hv9A.js → DashboardWidgetInspector-BZXT2waT.js} +1 -1
- package/dist/assets/{DeveloperHubPage-D4ErhCeD.js → DeveloperHubPage-D1Gr8nhZ.js} +1 -1
- package/dist/assets/{ExpressionProvider-Cj6XEnZF.js → ExpressionProvider-w-i3oDR9.js} +1 -1
- package/dist/assets/{FlowRunsPage-CJsr4xgF.js → FlowRunsPage-CntX-tGf.js} +1 -1
- package/dist/assets/{IntegrationsPage-zbcGFqxM.js → IntegrationsPage-BoWdvbMh.js} +1 -1
- package/dist/assets/{InterfaceListPage-BJRTel_h.js → InterfaceListPage-CtbkRAlr.js} +1 -1
- package/dist/assets/{ManagedByBadge-DOMbPlbf.js → ManagedByBadge-BYezQxs4.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-CSgqJuot.js → MarketplaceInstalledPage-CuPkbetm.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-0TU_eJIx.js → MarketplacePackagePage-CKJ_NEnI.js} +1 -1
- package/dist/assets/{MarketplacePage-YO75QMEO.js → MarketplacePage-BTGE5DuS.js} +1 -1
- package/dist/assets/{MetadataInspector-CamKLf7x.js → MetadataInspector-eUKibp4P.js} +1 -1
- package/dist/assets/{MetadataProvider-Bxendsnd.js → MetadataProvider-DVGxIr-Y.js} +1 -1
- package/dist/assets/{PageView-z1PfFaQS.js → PageView-CoZhWVVc.js} +1 -1
- package/dist/assets/{ProfilePage-5QuBSV4z.js → ProfilePage-qRetxYIs.js} +1 -1
- package/dist/assets/{PublicFormsPage-CMTz6MfD.js → PublicFormsPage-Cpy38W-9.js} +1 -1
- package/dist/assets/{RecordDetailView-DOcGflPY.js → RecordDetailView-CD05ObAk.js} +1 -1
- package/dist/assets/{RecordFormPage-C1M3jdnG.js → RecordFormPage-OOn5fyVq.js} +1 -1
- package/dist/assets/{ReportDefaultInspector-DDBJTAYx.js → ReportDefaultInspector--g5afStS.js} +1 -1
- package/dist/assets/{ReportView-CItKDFSn.js → ReportView-w6a1FyHp.js} +1 -1
- package/dist/assets/{RuntimeDraftBar-QF3pF8K2.js → RuntimeDraftBar-e5TgPCLp.js} +1 -1
- package/dist/assets/{SearchResultsPage-Mdphx8Ca.js → SearchResultsPage-B2D6vns1.js} +1 -1
- package/dist/assets/{SettingsHub-CtfOIqOJ.js → SettingsHub-Bi06edK0.js} +1 -1
- package/dist/assets/{SettingsView-One2JiPG.js → SettingsView-zJInYHeN.js} +1 -1
- package/dist/assets/{SystemHubPage-Dzi5_s3T.js → SystemHubPage-DV53wHHA.js} +1 -1
- package/dist/assets/architecture-7EHR7CIX-BdMnUPE0.js +1 -0
- package/dist/assets/architectureDiagram-3BPJPVTR-SscyJlk0.js +36 -0
- package/dist/assets/blockDiagram-GPEHLZMM-D6-9deBJ.js +132 -0
- package/dist/assets/c4Diagram-AAUBKEIU-VLeNt7tD.js +10 -0
- package/dist/assets/channel-ByUUDCyR.js +1 -0
- package/dist/assets/chunk-2J33WTMH-DyXQVMuc.js +1 -0
- package/dist/assets/chunk-3OPIFGDE-3g0dk_di.js +62 -0
- package/dist/assets/chunk-4BX2VUAB-BpAZJ7ZC.js +1 -0
- package/dist/assets/chunk-55IACEB6-BhOjfCrn.js +1 -0
- package/dist/assets/chunk-5ZQYHXKU-DG12s6lW.js +2 -0
- package/dist/assets/chunk-727SXJPM-DwSFE_v-.js +206 -0
- package/dist/assets/chunk-AQP2D5EJ-DWgSztUW.js +231 -0
- package/dist/assets/chunk-BSJP7CBP-okvguKD4.js +1 -0
- package/dist/assets/chunk-CSCIHK7Q-DfSAlgJl.js +124 -0
- package/dist/assets/chunk-FMBD7UC4-CZzqt4RW.js +15 -0
- package/dist/assets/chunk-KSCS5N6A-IxEh4Ag5.js +10 -0
- package/dist/assets/chunk-L5ZTLDWV-DW1lPBoG.js +1 -0
- package/dist/assets/chunk-LZXEDZCA-C_-aaYcd.js +1 -0
- package/dist/assets/chunk-ND2GUHAM-C1toj0H3.js +1 -0
- package/dist/assets/chunk-NNHCCRGN-Ud6GGuM7.js +159 -0
- package/dist/assets/chunk-NZK2D7GU-H2MwBqQV.js +1 -0
- package/dist/assets/chunk-O5CBEL6O-BzyWPZhZ.js +70 -0
- package/dist/assets/chunk-QZHKN3VN-ujroCBCz.js +1 -0
- package/dist/assets/chunk-WU5MYG2G-DwQt8tuZ.js +1 -0
- package/dist/assets/chunk-XPW4576I-DPNxFY7Q.js +32 -0
- package/dist/assets/classDiagram-4FO5ZUOK-B7mTyEXp.js +1 -0
- package/dist/assets/classDiagram-v2-Q7XG4LA2-B7mTyEXp.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-HKJWDQRL.js +1 -0
- package/dist/assets/cytoscape.esm-h6BdjjI9.js +321 -0
- package/dist/assets/dagre-BM42HDAG-CU8nx02l.js +4 -0
- package/dist/assets/dagre-Bx709z4p.js +1 -0
- package/dist/assets/{data-adapter-Dl2IvbPC.js → data-adapter-BEs3zHWP.js} +1 -1
- package/dist/assets/diagram-2AECGRRQ-CormMz8j.js +43 -0
- package/dist/assets/diagram-5GNKFQAL-Dh1SagBx.js +10 -0
- package/dist/assets/diagram-KO2AKTUF-DcG6Z05V.js +3 -0
- package/dist/assets/diagram-LMA3HP47-DrVLZ6ZE.js +24 -0
- package/dist/assets/diagram-OG6HWLK6-C4_MMUc2.js +24 -0
- package/dist/assets/dist-Cna34lZe.js +1 -0
- package/dist/assets/erDiagram-TEJ5UH35-BZH_OrBL.js +85 -0
- package/dist/assets/eventmodeling-FCH6USID-CFiyy8DS.js +1 -0
- package/dist/assets/flowDiagram-I6XJVG4X-CnjHQUK0.js +162 -0
- package/dist/assets/{framework-D7UWfRl4.js → framework-BSpP7C0B.js} +11 -11
- package/dist/assets/ganttDiagram-6RSMTGT7-rVbHlqzo.js +292 -0
- package/dist/assets/gitGraph-WXDBUCRP-9vsQCBlr.js +1 -0
- package/dist/assets/gitGraphDiagram-PVQCEYII-CH2LgClA.js +106 -0
- package/dist/assets/graphlib-B8gBHxth.js +1 -0
- package/dist/assets/{highlighted-body-OFNGDK62-Dgcl8-h_.js → highlighted-body-OFNGDK62-BgGi60U1.js} +1 -1
- package/dist/assets/index-QQUFI17s.js +4 -0
- package/dist/assets/index-mrmp6qU6.css +2 -0
- package/dist/assets/info-J43DQDTF-CfWeH1Bg.js +1 -0
- package/dist/assets/infoDiagram-5YYISTIA-CRC7ojj-.js +2 -0
- package/dist/assets/ishikawaDiagram-YF4QCWOH-8v73fBR1.js +70 -0
- package/dist/assets/journeyDiagram-JHISSGLW-DbRK-WaU.js +139 -0
- package/dist/assets/kanban-definition-UN3LZRKU-BggLxHvZ.js +89 -0
- package/dist/assets/katex-Vhh-h91d.js +257 -0
- package/dist/assets/{marketplaceApi-Do90JxGv.js → marketplaceApi-C2Xs-8x9.js} +1 -1
- package/dist/assets/mergeServerFields-C7bGC7hp.js +7 -0
- package/dist/assets/mermaid-GHXKKRXX-DpdgSEiY.js +1 -0
- package/dist/assets/mermaid-parser.core-iuxcj-n_.js +3 -0
- package/dist/assets/mermaid.core-C41Aiku8.js +8 -0
- package/dist/assets/metadata-admin-B5BnMMNz.js +19 -0
- package/dist/assets/mindmap-definition-RKZ34NQL-kqhi9XCR.js +96 -0
- package/dist/assets/packet-YPE3B663-C0xexAqH.js +1 -0
- package/dist/assets/pie-LRSECV5Y-DbQVOiyX.js +1 -0
- package/dist/assets/pieDiagram-4H26LBE5-9fHcPmFE.js +30 -0
- package/dist/assets/{plugin-calendar-DSvXqOQV.js → plugin-calendar-DqouTXvx.js} +1 -1
- package/dist/assets/plugin-charts-Bg-32_xO.js +7 -0
- package/dist/assets/{plugin-chatbot-D6s22V14.js → plugin-chatbot-1Bip2OCu.js} +7 -7
- package/dist/assets/{plugin-dashboard-PEMuLOVn.js → plugin-dashboard-bF8okIBS.js} +1 -1
- package/dist/assets/plugin-form-DkI3TvRN.js +1 -0
- package/dist/assets/{plugin-gantt-CB1bbY8J.js → plugin-gantt-iFmeqHwf.js} +1 -1
- package/dist/assets/plugin-grid-KSDSYH4h.js +6 -0
- package/dist/assets/{plugin-kanban-BxxI6fit.js → plugin-kanban-CecteZ3L.js} +1 -1
- package/dist/assets/{plugin-map-B-TiJAz8.js → plugin-map-DD9uSXB0.js} +1 -1
- package/dist/assets/plugin-markdown-BR56zxrV.js +113 -0
- package/dist/assets/{plugin-report-jQPIUbaf.js → plugin-report-KJw4u9x7.js} +1 -1
- package/dist/assets/{plugin-timeline-BNRp2sKQ.js → plugin-timeline-D8Lkn6Qk.js} +1 -1
- package/dist/assets/{plugin-view-BeiRMGis.js → plugin-view-DJrJBUdE.js} +1 -1
- package/dist/assets/{plugins-views-D0zS0yz2.js → plugins-views-BhPRkeWo.js} +1 -1
- package/dist/assets/quadrantDiagram-W4KKPZXB-CaMxia_k.js +7 -0
- package/dist/assets/radar-GUYGQ44K-DapGfmwo.js +1 -0
- package/dist/assets/requirementDiagram-4Y6WPE33-CXwY4Gdd.js +84 -0
- package/dist/assets/{resolveActionParams-eRBdMG9b.js → resolveActionParams-C1HIbU1j.js} +1 -1
- package/dist/assets/rough.esm-CSKSodPl.js +1 -0
- package/dist/assets/runtime-config-BeHVOPm3.js +1 -0
- package/dist/assets/sankeyDiagram-5OEKKPKP-KEb3hSPZ.js +40 -0
- package/dist/assets/sequenceDiagram-3UESZ5HK-BfbOOh3M.js +162 -0
- package/dist/assets/{skeletons-DNzeXHI1.js → skeletons-qACAXjbp.js} +1 -1
- package/dist/assets/src-CVz7aDdY.js +1 -0
- package/dist/assets/{src-LBsSMdO2.js → src-CZAP7E6v.js} +1 -1
- package/dist/assets/stateDiagram-AJRCARHV-BLJI6xj_.js +1 -0
- package/dist/assets/stateDiagram-v2-BHNVJYJU-DPQJ1_JB.js +1 -0
- package/dist/assets/timeline-definition-PNZ67QCA-aiklZXLq.js +120 -0
- package/dist/assets/treeView-BLDUP644-Byr_7ESV.js +1 -0
- package/dist/assets/treemap-LRROVOQU-B6DiJnlo.js +1 -0
- package/dist/assets/{types-D2P-aXxM.js → types-CW2d8LfD.js} +1 -1
- package/dist/assets/ui-components-D7IOmcqZ.js +42 -0
- package/dist/assets/{ui-layout-DYMEUX5t.js → ui-layout-toYvxCNh.js} +1 -1
- package/dist/assets/{useActionModal-VGsmP3uO.js → useActionModal-yawBu4nr.js} +1 -1
- package/dist/assets/vendor-charts-fo4ZbB_t.js +39 -0
- package/dist/assets/vendor-i18n-Bz5UncqE.js +1 -0
- package/dist/assets/{vendor-markdown-BXE1apAC.js → vendor-markdown-DIJxJfmj.js} +3 -3
- package/dist/assets/vennDiagram-CIIHVFJN-DsKC4yvC.js +34 -0
- package/dist/assets/wardley-L42UT6IY-f1iiSYpj.js +1 -0
- package/dist/assets/wardleyDiagram-YWT4CUSO-DbrUmWlY.js +78 -0
- package/dist/assets/xychartDiagram-2RQKCTM6-B4biX1Sz.js +7 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/index-BjfDho4T.js +0 -4
- package/dist/assets/index-CJFqfWpW.css +0 -2
- package/dist/assets/mergeServerFields-Co1NIO7_.js +0 -7
- package/dist/assets/mermaid-GHXKKRXX-BY4z2Mh6.js +0 -1
- package/dist/assets/metadata-admin-B-99o4dC.js +0 -19
- package/dist/assets/plugin-charts-EoSn84Ag.js +0 -7
- package/dist/assets/plugin-form-MXrWd_1Z.js +0 -1
- package/dist/assets/plugin-grid-D9HjQh3d.js +0 -6
- package/dist/assets/plugin-markdown-BUIHw2kZ.js +0 -113
- package/dist/assets/runtime-config-ir5bt3TX.js +0 -1
- package/dist/assets/ui-components-Clv7N77v.js +0 -42
- package/dist/assets/vendor-charts-DAigH0Ti.js +0 -39
- package/dist/assets/vendor-i18n-CdF5ccW5.js +0 -1
package/dist/assets/{DashboardWidgetInspector-Dhe9hv9A.js → DashboardWidgetInspector-BZXT2waT.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{R as r,l as i,m as a}from"./vendor-objectstack-RB3xvhcR.js";import{$n as o,As as s,Bo as c,Br as l,Bt as u,Es as d,Hi as f,Ht as p,Ma as m,Ms as h,Os as g,Qo as _,Qr as v,Si as y,Sr as b,Ts as x,Uo as S,Ut as C,Vt as w,Wt as T,cc as ee,eo as E,hr as D,ks as O,nn as k,on as A,ro as j}from"./ui-components-Clv7N77v.js";import{_ as M,b as N,g as P,h as F,i as I,n as L,p as te,t as ne,v as R,y as re}from"./mergeServerFields-Co1NIO7_.js";var z=e(t(),1),B={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:E},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:O},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:g},line:{id:`line`,label:`Line chart`,category:`chart`,icon:s},area:{id:`area`,label:`Area chart`,category:`chart`,icon:h},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:d},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:c},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:x},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:l},table:{id:`table`,label:`Data table`,category:`data`,icon:v},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:_}},V={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},H=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(B).filter(t=>t.category===e)})),U=ee,W=n();function G({onAdd:e,label:t=`Add widget`}){let[n,r]=z.useState(!1),[i,a]=z.useState(``),o=z.useRef(null),s=z.useRef(null);z.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=z.useMemo(()=>{let e=i.trim().toLowerCase();return e?H.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):H},[i]);return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,W.jsx)(f,{className:`h-3 w-3`}),t]}),n&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,W.jsx)(y,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,W.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,W.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:V[t.category]}),t.types.map(t=>(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,W.jsx)(B[t.id]?.icon??U,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,W.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var K={io:`input`,unrepresentable:`any`},q=new Set([`widgets`,`label`,`description`,`name`]),J,Y=!1;function ie(){if(J||Y)return J;try{J=r(i,K)}catch(e){Y=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return J}var X;function ae(){if(X)return X;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!q.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),X=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return X}}var oe=new Set([`name`,`label`,`description`,`widgets`]);function se({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let s=z.useCallback(e=>I(e,r),[r]),c=typeof e.label==`string`?e.label:``,l=typeof e.description==`string`?e.description:``,u=z.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),d=e=>{let n=N(`widget`,u.map(e=>e?.id).filter(Boolean)),r=B[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:M(u,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},f=e=>{t({widgets:re(u,e,null)})},p=(e,n)=>{e!==n&&t({widgets:R(u,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=z.useState(null),[_,v]=z.useState(null),{schema:y,form:x}=z.useMemo(()=>ne({bundledSchema:ie(),bundledForm:ae(),serverSchema:a,excludeFields:oe,sectionTitle:I(`engine.inspector.moreFields`,r)}),[a,r]);return(0,W.jsxs)(F,{kindLabel:s(`engine.inspector.dashboard.kind`),title:String(c||e.name||s(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:s(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.label`),value:c,onCommit:e=>t({label:e}),placeholder:s(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.description`),value:l,onCommit:e=>t({description:e}),placeholder:s(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,W.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(A,{className:`text-xs text-muted-foreground`,children:s(`engine.inspector.dashboard.widgets`)}),(0,W.jsx)(o,{variant:`outline`,className:`text-[10px]`,children:u.length})]}),u.length===0?(0,W.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.widgetsEmpty`)}):(0,W.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>{let r=B[e?.type]?.icon??U;return(0,W.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,W.jsx)(j,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,W.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,W.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>f(t),title:s(`engine.inspector.dashboard.removeWidget`),"aria-label":s(`engine.inspector.dashboard.removeWidget`),children:(0,W.jsx)(b,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,W.jsx)(G,{onAdd:d,label:s(`engine.inspector.add.widget`)})]}),(0,W.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,W.jsx)(L,{schema:y,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.noSchema`)})})]})}var ce=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Z=[`count`,`sum`,`avg`,`min`,`max`],le=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function ue(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function de({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){if(t.kind!==`widget`)return(0,W.jsx)($,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});let s=ue(e,t.id);if(!s)return(0,W.jsx)($,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:c,index:l}=s,d=Array.isArray(e.widgets)?e.widgets:[];function f(e){let t=[...d];t[l]={...t[l],...e},n({widgets:t})}let m=c,h=typeof m.dataset==`string`?m.dataset:``,g=Array.isArray(m.dimensions)?m.dimensions.join(`, `):``,_=Array.isArray(m.values)?m.values.join(`, `):``,v=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function y(e){n({widgets:R(d,l,e)}),c.id&&i?.({kind:`widget`,id:c.id,label:c.title??void 0})}return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:I(`engine.inspector.widget.kind`,o)}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:c.title||t.label||`Widget ${l+1}`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(te,{index:l,total:d.length,onMove:y,upLabel:I(`engine.inspector.reorder.up`,o),downLabel:I(`engine.inspector.reorder.down`,o),disabled:a}),(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:I(`engine.inspector.widget.close`,o),"aria-label":I(`engine.inspector.widget.close`,o),children:(0,W.jsx)(b,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)(Q,{id:`widget-title`,label:I(`engine.inspector.widget.title`,o),children:(0,W.jsx)(k,{id:`widget-title`,value:c.title??``,onChange:e=>f({title:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-type`,label:I(`engine.inspector.widget.type`,o),children:(0,W.jsxs)(u,{value:c.type??`metric`,onValueChange:e=>f({type:e}),disabled:a,children:[(0,W.jsx)(C,{id:`widget-type`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(w,{children:ce.map(e=>(0,W.jsx)(p,{value:e.value,children:e.label},e.value))})]})}),(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:I(`engine.inspector.widget.datasetSection`,o)}),(0,W.jsxs)(Q,{id:`widget-dataset`,label:I(`engine.inspector.widget.dataset`,o),children:[(0,W.jsx)(k,{id:`widget-dataset`,value:h,placeholder:I(`engine.inspector.widget.datasetPlaceholder`,o),onChange:e=>f({dataset:e.target.value||void 0}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.datasetHint`,o)})]}),h&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Q,{id:`widget-dimensions`,label:I(`engine.inspector.widget.dimensions`,o),children:[(0,W.jsx)(k,{id:`widget-dimensions`,value:g,placeholder:I(`engine.inspector.widget.dimensionsPlaceholder`,o),onChange:e=>f({dimensions:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.dimensionsHint`,o)})]}),(0,W.jsxs)(Q,{id:`widget-values`,label:I(`engine.inspector.widget.values`,o),children:[(0,W.jsx)(k,{id:`widget-values`,value:_,placeholder:I(`engine.inspector.widget.valuesPlaceholder`,o),onChange:e=>f({values:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.valuesHint`,o)})]})]})]}),(0,W.jsx)(Q,{id:`widget-object`,label:I(`engine.inspector.widget.object`,o),children:(0,W.jsx)(k,{id:`widget-object`,value:c.object??``,placeholder:`e.g. order`,onChange:e=>f({object:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-value-field`,label:I(`engine.inspector.widget.valueField`,o),children:(0,W.jsx)(k,{id:`widget-value-field`,value:c.valueField??``,placeholder:`e.g. amount`,onChange:e=>f({valueField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-category-field`,label:I(`engine.inspector.widget.categoryField`,o),children:(0,W.jsx)(k,{id:`widget-category-field`,value:c.categoryField??``,placeholder:`e.g. status`,onChange:e=>f({categoryField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-aggregate`,label:I(`engine.inspector.widget.aggregate`,o),children:(0,W.jsxs)(u,{value:c.aggregate??`count`,onValueChange:e=>f({aggregate:e}),disabled:a,children:[(0,W.jsx)(C,{id:`widget-aggregate`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(w,{children:Z.map(e=>(0,W.jsx)(p,{value:e,children:e},e))})]})}),(0,W.jsx)(Q,{id:`widget-color`,label:I(`engine.inspector.widget.color`,o),children:(0,W.jsxs)(u,{value:c.colorVariant??`default`,onValueChange:e=>f({colorVariant:e}),disabled:a,children:[(0,W.jsx)(C,{id:`widget-color`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(w,{children:le.map(e=>(0,W.jsx)(p,{value:e,children:e},e))})]})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsx)(Q,{id:`widget-w`,label:I(`engine.inspector.widget.width`,o),children:(0,W.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:c.layout?.w??1,onChange:e=>f({layout:{...c.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-h`,label:I(`engine.inspector.widget.height`,o),children:(0,W.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:c.layout?.h??1,onChange:e=>f({layout:{...c.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,W.jsx)(`div`,{className:`pt-2 border-t`,children:(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(l,1),n({widgets:t}),r()},children:I(`engine.inspector.widget.remove`,o)})})]})}function Q({id:e,label:t,children:n}){return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(A,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function $({message:e,onClose:t,locale:n}){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,W.jsx)(`p`,{children:e}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:I(`engine.inspector.widget.close`,n)})]})}export{B as i,se as n,G as r,de as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{R as r,l as i,m as a}from"./vendor-objectstack-RB3xvhcR.js";import{$n as o,As as s,Bo as c,Br as l,Bt as u,Es as d,Hi as f,Ht as p,Ma as m,Ms as h,Os as g,Qo as _,Qr as v,Si as y,Sr as b,Ts as x,Uo as S,Ut as C,Vt as w,Wt as T,cc as ee,eo as E,hr as D,ks as O,nn as k,on as A,ro as j}from"./ui-components-D7IOmcqZ.js";import{_ as M,b as N,g as P,h as F,i as I,n as L,p as te,t as ne,v as R,y as re}from"./mergeServerFields-C7bGC7hp.js";var z=e(t(),1),B={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:E},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:O},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:g},line:{id:`line`,label:`Line chart`,category:`chart`,icon:s},area:{id:`area`,label:`Area chart`,category:`chart`,icon:h},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:d},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:c},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:x},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:l},table:{id:`table`,label:`Data table`,category:`data`,icon:v},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:_}},V={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},H=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(B).filter(t=>t.category===e)})),U=ee,W=n();function G({onAdd:e,label:t=`Add widget`}){let[n,r]=z.useState(!1),[i,a]=z.useState(``),o=z.useRef(null),s=z.useRef(null);z.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=z.useMemo(()=>{let e=i.trim().toLowerCase();return e?H.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):H},[i]);return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,W.jsx)(f,{className:`h-3 w-3`}),t]}),n&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,W.jsx)(y,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,W.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,W.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:V[t.category]}),t.types.map(t=>(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,W.jsx)(B[t.id]?.icon??U,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,W.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var K={io:`input`,unrepresentable:`any`},q=new Set([`widgets`,`label`,`description`,`name`]),J,Y=!1;function ie(){if(J||Y)return J;try{J=r(i,K)}catch(e){Y=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return J}var X;function ae(){if(X)return X;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!q.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),X=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return X}}var oe=new Set([`name`,`label`,`description`,`widgets`]);function se({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let s=z.useCallback(e=>I(e,r),[r]),c=typeof e.label==`string`?e.label:``,l=typeof e.description==`string`?e.description:``,u=z.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),d=e=>{let n=N(`widget`,u.map(e=>e?.id).filter(Boolean)),r=B[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:M(u,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},f=e=>{t({widgets:re(u,e,null)})},p=(e,n)=>{e!==n&&t({widgets:R(u,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=z.useState(null),[_,v]=z.useState(null),{schema:y,form:x}=z.useMemo(()=>ne({bundledSchema:ie(),bundledForm:ae(),serverSchema:a,excludeFields:oe,sectionTitle:I(`engine.inspector.moreFields`,r)}),[a,r]);return(0,W.jsxs)(F,{kindLabel:s(`engine.inspector.dashboard.kind`),title:String(c||e.name||s(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:s(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.label`),value:c,onCommit:e=>t({label:e}),placeholder:s(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.description`),value:l,onCommit:e=>t({description:e}),placeholder:s(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,W.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(A,{className:`text-xs text-muted-foreground`,children:s(`engine.inspector.dashboard.widgets`)}),(0,W.jsx)(o,{variant:`outline`,className:`text-[10px]`,children:u.length})]}),u.length===0?(0,W.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.widgetsEmpty`)}):(0,W.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>{let r=B[e?.type]?.icon??U;return(0,W.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,W.jsx)(j,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,W.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,W.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>f(t),title:s(`engine.inspector.dashboard.removeWidget`),"aria-label":s(`engine.inspector.dashboard.removeWidget`),children:(0,W.jsx)(b,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,W.jsx)(G,{onAdd:d,label:s(`engine.inspector.add.widget`)})]}),(0,W.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,W.jsx)(L,{schema:y,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.noSchema`)})})]})}var ce=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Z=[`count`,`sum`,`avg`,`min`,`max`],le=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function ue(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function de({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){if(t.kind!==`widget`)return(0,W.jsx)($,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});let s=ue(e,t.id);if(!s)return(0,W.jsx)($,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:c,index:l}=s,d=Array.isArray(e.widgets)?e.widgets:[];function f(e){let t=[...d];t[l]={...t[l],...e},n({widgets:t})}let m=c,h=typeof m.dataset==`string`?m.dataset:``,g=Array.isArray(m.dimensions)?m.dimensions.join(`, `):``,_=Array.isArray(m.values)?m.values.join(`, `):``,v=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function y(e){n({widgets:R(d,l,e)}),c.id&&i?.({kind:`widget`,id:c.id,label:c.title??void 0})}return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:I(`engine.inspector.widget.kind`,o)}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:c.title||t.label||`Widget ${l+1}`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(te,{index:l,total:d.length,onMove:y,upLabel:I(`engine.inspector.reorder.up`,o),downLabel:I(`engine.inspector.reorder.down`,o),disabled:a}),(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:I(`engine.inspector.widget.close`,o),"aria-label":I(`engine.inspector.widget.close`,o),children:(0,W.jsx)(b,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)(Q,{id:`widget-title`,label:I(`engine.inspector.widget.title`,o),children:(0,W.jsx)(k,{id:`widget-title`,value:c.title??``,onChange:e=>f({title:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-type`,label:I(`engine.inspector.widget.type`,o),children:(0,W.jsxs)(u,{value:c.type??`metric`,onValueChange:e=>f({type:e}),disabled:a,children:[(0,W.jsx)(C,{id:`widget-type`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(w,{children:ce.map(e=>(0,W.jsx)(p,{value:e.value,children:e.label},e.value))})]})}),(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:I(`engine.inspector.widget.datasetSection`,o)}),(0,W.jsxs)(Q,{id:`widget-dataset`,label:I(`engine.inspector.widget.dataset`,o),children:[(0,W.jsx)(k,{id:`widget-dataset`,value:h,placeholder:I(`engine.inspector.widget.datasetPlaceholder`,o),onChange:e=>f({dataset:e.target.value||void 0}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.datasetHint`,o)})]}),h&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Q,{id:`widget-dimensions`,label:I(`engine.inspector.widget.dimensions`,o),children:[(0,W.jsx)(k,{id:`widget-dimensions`,value:g,placeholder:I(`engine.inspector.widget.dimensionsPlaceholder`,o),onChange:e=>f({dimensions:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.dimensionsHint`,o)})]}),(0,W.jsxs)(Q,{id:`widget-values`,label:I(`engine.inspector.widget.values`,o),children:[(0,W.jsx)(k,{id:`widget-values`,value:_,placeholder:I(`engine.inspector.widget.valuesPlaceholder`,o),onChange:e=>f({values:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.valuesHint`,o)})]})]})]}),(0,W.jsx)(Q,{id:`widget-object`,label:I(`engine.inspector.widget.object`,o),children:(0,W.jsx)(k,{id:`widget-object`,value:c.object??``,placeholder:`e.g. order`,onChange:e=>f({object:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-value-field`,label:I(`engine.inspector.widget.valueField`,o),children:(0,W.jsx)(k,{id:`widget-value-field`,value:c.valueField??``,placeholder:`e.g. amount`,onChange:e=>f({valueField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-category-field`,label:I(`engine.inspector.widget.categoryField`,o),children:(0,W.jsx)(k,{id:`widget-category-field`,value:c.categoryField??``,placeholder:`e.g. status`,onChange:e=>f({categoryField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-aggregate`,label:I(`engine.inspector.widget.aggregate`,o),children:(0,W.jsxs)(u,{value:c.aggregate??`count`,onValueChange:e=>f({aggregate:e}),disabled:a,children:[(0,W.jsx)(C,{id:`widget-aggregate`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(w,{children:Z.map(e=>(0,W.jsx)(p,{value:e,children:e},e))})]})}),(0,W.jsx)(Q,{id:`widget-color`,label:I(`engine.inspector.widget.color`,o),children:(0,W.jsxs)(u,{value:c.colorVariant??`default`,onValueChange:e=>f({colorVariant:e}),disabled:a,children:[(0,W.jsx)(C,{id:`widget-color`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(w,{children:le.map(e=>(0,W.jsx)(p,{value:e,children:e},e))})]})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsx)(Q,{id:`widget-w`,label:I(`engine.inspector.widget.width`,o),children:(0,W.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:c.layout?.w??1,onChange:e=>f({layout:{...c.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-h`,label:I(`engine.inspector.widget.height`,o),children:(0,W.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:c.layout?.h??1,onChange:e=>f({layout:{...c.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,W.jsx)(`div`,{className:`pt-2 border-t`,children:(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(l,1),n({widgets:t}),r()},children:I(`engine.inspector.widget.remove`,o)})})]})}function Q({id:e,label:t,children:n}){return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(A,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function $({message:e,onClose:t,locale:n}){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,W.jsx)(`p`,{children:e}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:I(`engine.inspector.widget.close`,n)})]})}export{B as i,se as n,G as r,de as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,t,u as n}from"./vendor-react-DR370ovB.js";import{Jn as r,Jr as i,So as a,Ui as o,Xn as s,Yn as c,Zn as l,qn as u,wr as d}from"./ui-components-
|
|
1
|
+
import{f as e,t,u as n}from"./vendor-react-DR370ovB.js";import{Jn as r,Jr as i,So as a,Ui as o,Xn as s,Yn as c,Zn as l,qn as u,wr as d}from"./ui-components-D7IOmcqZ.js";var f=t();function p(){let t=n(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:o,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:i,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:d,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:a,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let n=e.icon;return(0,f.jsxs)(u,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>t(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:[(0,f.jsxs)(s,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(n,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(l,{className:`text-base`,children:e.title}),(0,f.jsx)(c,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(r,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{L as r,st as i}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{L as r,st as i}from"./framework-BSpP7C0B.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({user:t,app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,evaluator:new i(e)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-D7UWfRl4.js";import{$n as i,Ft as a,Gt as o,It as s,Jn as c,Lt as l,Mt as u,Pi as d,Pt as f,Rt as p,Wi as m,Xn as h,Yn as g,Zn as _,_s as v,ct as y,dt as b,ft as x,hr as S,hs as C,ja as w,lt as T,nn as E,ns as D,on as O,ot as k,qn as A,ss as j,st as M,tt as N,ut as P,wr as F}from"./ui-components-Clv7N77v.js";import"./index-BjfDho4T.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:C,cls:`text-emerald-600 border-emerald-300`},completed:{icon:C,cls:`text-emerald-600 border-emerald-300`},failed:{icon:j,cls:`text-red-600 border-red-300`},error:{icon:j,cls:`text-red-600 border-red-300`},running:{icon:w,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:D,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(i,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[o,s]=(0,I.useState)(null),[l,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(0),v=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&f(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,l]);(0,I.useEffect)(()=>{v()},[v]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(F,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(A,{children:[(0,L.jsx)(h,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(_,{className:`text-base`,children:`Flow`}),(0,L.jsx)(g,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(S,{variant:`outline`,size:`sm`,onClick:v,disabled:i,children:[(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(c,{children:[i&&(0,L.jsx)(u,{className:`h-9 w-72`}),o&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!i&&!o&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!o&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[s,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),d(null),p(null)},[t?.name]);let v=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(A,{children:[(0,L.jsxs)(h,{className:`pb-3`,children:[(0,L.jsx)(_,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(g,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(c,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(x,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>v(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(N,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(S,{onClick:async()=>{if(!e?.automation?.execute){p(`automation.execute is not available on this client`);return}l(!0),p(null),d(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){p(e?.message??String(e))}finally{l(!1)}},disabled:s,size:`sm`,children:[s?(0,L.jsx)(w,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(m,{className:`h-3.5 w-3.5 mr-2`}),s?`Running…`:`Run Flow`]})}),(u||f)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[f||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(j,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),f&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:f}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,m]=(0,I.useState)([]),[v,x]=(0,I.useState)(!0),[C,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(null),[j,N]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){E(`automation.listRuns is not available on this client`),x(!1);return}x(!0),E(null);try{let n=await e.automation.listRuns(t,{limit:20});m(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){E(e?.message??String(e))}finally{x(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{O(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(A,{children:[(0,L.jsx)(h,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(_,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(g,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(S,{variant:`outline`,size:`sm`,onClick:W,disabled:v,children:[v?(0,L.jsx)(w,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(c,{children:[v&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(u,{className:`h-8 w-full`}),(0,L.jsx)(u,{className:`h-8 w-full`}),(0,L.jsx)(u,{className:`h-8 w-full`})]}),!v&&C&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:C}),!v&&!C&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!v&&!C&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(P,{children:(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(M,{children:r.map(e=>(0,L.jsxs)(b,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(y,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(y,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(y,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(y,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(f,{open:!!D,onOpenChange:e=>{e||(O(null),N(null))},children:(0,L.jsxs)(a,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(l,{className:`p-4 border-b`,children:[(0,L.jsxs)(p,{className:`font-mono text-sm break-all`,children:[`Run `,D]}),(0,L.jsx)(s,{children:j&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:j.status}),typeof j.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[j.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(j.startedAt)})]})})]}),(0,L.jsxs)(o,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(u,{className:`h-16 w-full`}),(0,L.jsx)(u,{className:`h-16 w-full`}),(0,L.jsx)(u,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&j&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(j.steps)&&j.steps.length>0?j.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:j})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-BSpP7C0B.js";import{$n as i,Ft as a,Gt as o,It as s,Jn as c,Lt as l,Mt as u,Pi as d,Pt as f,Rt as p,Wi as m,Xn as h,Yn as g,Zn as _,_s as v,ct as y,dt as b,ft as x,hr as S,hs as C,ja as w,lt as T,nn as E,ns as D,on as O,ot as k,qn as A,ss as j,st as M,tt as N,ut as P,wr as F}from"./ui-components-D7IOmcqZ.js";import"./index-QQUFI17s.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:C,cls:`text-emerald-600 border-emerald-300`},completed:{icon:C,cls:`text-emerald-600 border-emerald-300`},failed:{icon:j,cls:`text-red-600 border-red-300`},error:{icon:j,cls:`text-red-600 border-red-300`},running:{icon:w,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:D,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(i,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[o,s]=(0,I.useState)(null),[l,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(0),v=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&f(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,l]);(0,I.useEffect)(()=>{v()},[v]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(F,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(A,{children:[(0,L.jsx)(h,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(_,{className:`text-base`,children:`Flow`}),(0,L.jsx)(g,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(S,{variant:`outline`,size:`sm`,onClick:v,disabled:i,children:[(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(c,{children:[i&&(0,L.jsx)(u,{className:`h-9 w-72`}),o&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!i&&!o&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!o&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[s,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),d(null),p(null)},[t?.name]);let v=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(A,{children:[(0,L.jsxs)(h,{className:`pb-3`,children:[(0,L.jsx)(_,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(g,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(c,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(x,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>v(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(N,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(S,{onClick:async()=>{if(!e?.automation?.execute){p(`automation.execute is not available on this client`);return}l(!0),p(null),d(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){p(e?.message??String(e))}finally{l(!1)}},disabled:s,size:`sm`,children:[s?(0,L.jsx)(w,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(m,{className:`h-3.5 w-3.5 mr-2`}),s?`Running…`:`Run Flow`]})}),(u||f)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[f||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(j,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),f&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:f}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,m]=(0,I.useState)([]),[v,x]=(0,I.useState)(!0),[C,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(null),[j,N]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){E(`automation.listRuns is not available on this client`),x(!1);return}x(!0),E(null);try{let n=await e.automation.listRuns(t,{limit:20});m(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){E(e?.message??String(e))}finally{x(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{O(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(A,{children:[(0,L.jsx)(h,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(_,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(g,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(S,{variant:`outline`,size:`sm`,onClick:W,disabled:v,children:[v?(0,L.jsx)(w,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(c,{children:[v&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(u,{className:`h-8 w-full`}),(0,L.jsx)(u,{className:`h-8 w-full`}),(0,L.jsx)(u,{className:`h-8 w-full`})]}),!v&&C&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:C}),!v&&!C&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!v&&!C&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(P,{children:(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(M,{children:r.map(e=>(0,L.jsxs)(b,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(y,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(y,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(y,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(y,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(f,{open:!!D,onOpenChange:e=>{e||(O(null),N(null))},children:(0,L.jsxs)(a,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(l,{className:`p-4 border-b`,children:[(0,L.jsxs)(p,{className:`font-mono text-sm break-all`,children:[`Run `,D]}),(0,L.jsx)(s,{children:j&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:j.status}),typeof j.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[j.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(j.startedAt)})]})})]}),(0,L.jsxs)(o,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(u,{className:`h-16 w-full`}),(0,L.jsx)(u,{className:`h-16 w-full`}),(0,L.jsx)(u,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&j&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(j.steps)&&j.steps.length>0?j.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:j})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{$n as a,Bn as o,Ga as s,Hn as c,Hs as l,Jn as u,Jo as d,Jr as f,Ln as p,Rn as m,Ui as h,Uo as g,Vn as _,Xn as v,Yn as y,Zn as b,_i as x,ar as S,hr as C,ir as w,nn as T,qn as E,rr as D,ws as O,zn as k,zo as A}from"./ui-components-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{$n as a,Bn as o,Ga as s,Hn as c,Hs as l,Jn as u,Jo as d,Jr as f,Ln as p,Rn as m,Ui as h,Uo as g,Vn as _,Xn as v,Yn as y,Zn as b,_i as x,ar as S,hr as C,ir as w,nn as T,qn as E,rr as D,ws as O,zn as k,zo as A}from"./ui-components-D7IOmcqZ.js";var j=e(t(),1),M=`objectstack`,N=`Query and modify data in an ObjectStack app over MCP — discover objects, read and filter records, and create/update/delete under your own permissions and row-level security. Use when the user wants to inspect or change data in their ObjectStack environment.`,P=`<YOUR_ENV_MCP_URL>`;function F(e={}){let t=e.mcpUrl?.trim()||P,n=e.envName?.trim();return`---
|
|
2
2
|
name: ${M}
|
|
3
3
|
description: ${N}
|
|
4
4
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{T as i,r as a,w as o}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{T as i,r as a,w as o}from"./framework-BSpP7C0B.js";import{H as s,R as c,Uo as l,z as u}from"./ui-components-D7IOmcqZ.js";import"./MetadataProvider-DVGxIr-Y.js";import{c as d}from"./plugins-views-BhPRkeWo.js";var f=e(t(),1),p=`uf_`;function m(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(p)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function h(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=p+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var g=r();function _(e){return Array.isArray(e?.columns)&&e.columns.length>0}function v(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(_)??r[0]}var y=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function b(e){if(Array.isArray(e?.compactLayout)&&e.compactLayout.length>0)return e.compactLayout.filter(t=>e.fields?.[t]);let t=e?.fields;return t&&typeof t==`object`?Object.entries(t).filter(([e,t])=>t&&!t.hidden&&!y.has(e)).map(([e])=>e).slice(0,6):[]}function x(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!y.has(e)&&t(e,n))?.[0]}var S=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),C=new Set([`date`,`datetime`,`time`]),w=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function T(e){let t=x(e,(e,t)=>S.has(t.type))??x(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function E(e){return x(e,(e,t)=>C.has(t.type))??x(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function D(e){let t=E(e);return t?{startDateField:t}:void 0}function O(e){let t=x(e,(e,t)=>w.has(t.type));return t?{coverField:t}:void 0}function k({page:e,className:t}){let{t:r}=a(),{objects:p}=i(),y=o(),[,x]=n(),[S]=f.useState(()=>m(new URLSearchParams(window.location.search))),C=f.useCallback(e=>{x(t=>h(t,e),{replace:!0})},[x]),w=e?.interfaceConfig||{},E=f.useMemo(()=>(p||[]).find(e=>e.name===w.source),[p,w.source]),k=f.useMemo(()=>v(E,w.sourceView),[E,w.sourceView]),A=E?.name,j=!!k&&!_(k),M=k?.name??(w.sourceView?`${w.source}.${w.sourceView}`:void 0),[N,P]=f.useState(null);f.useEffect(()=>{let e=!1;if(P(null),!(!A||!w.source||!j||!M))return(async()=>{try{let t=y,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(w.source))?.[M]??null),!_(n)&&typeof t?.getView==`function`&&(n=await t.getView(w.source,M)),!e&&n&&typeof n==`object`&&P(n)}catch{}})(),()=>{e=!0}},[A,w.source,w.sourceView,j,M,y]);let F=f.useMemo(()=>N?{...k,...N}:k,[k,N]),I=JSON.stringify(F??null),L=f.useMemo(()=>{if(!E)return;let e=F||{},t=w.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=w.userActions||{},a=e.kanban??(r.has(`kanban`)?T(E):void 0),o=e.calendar??(r.has(`calendar`)?D(E):void 0),s=e.timeline??(r.has(`timeline`)?D(E):void 0),c=e.gallery??(r.has(`gallery`)?O(E):void 0),l=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(w.filterBy)?w.filterBy:[]],u=_(e)?e.columns:b(E);return{type:`list-view`,objectName:E.name,viewType:n[0]??e.type??`grid`,fields:u,...l.length?{filters:l}:{},...e.sort?.length?{sort:e.sort}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:e.gantt,userFilters:w.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:w.showRecordCount,addRecord:w.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:!1}},[A,I,w]);return!E||!L?(0,g.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,g.jsxs)(c,{children:[(0,g.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,g.jsx)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,g.jsx)(s,{children:r(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,g.jsx)(u,{children:r(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:w.source||`?`})})]})}):(0,g.jsxs)(`div`,{className:t??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,g.jsxs)(`div`,{className:`px-4 pt-4 pb-2 shrink-0`,children:[(0,g.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),(0,g.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,g.jsx)(d,{schema:L,dataSource:y,userFilterSelections:S,onUserFilterSelectionsChange:C})})]})}export{h as n,m as r,k as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-DR370ovB.js";import{$n as t,Aa as n,At as r,Ot as i,_i as a,ac as o,bi as s,jt as c,kt as l,lc as u}from"./ui-components-
|
|
1
|
+
import{t as e}from"./vendor-react-DR370ovB.js";import{$n as t,Aa as n,At as r,Ot as i,_i as a,ac as o,bi as s,jt as c,kt as l,lc as u}from"./ui-components-D7IOmcqZ.js";var d=e(),f={config:{icon:s,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:n,short:`System-managed`,title:`Managed by the platform`,body:()=>`Rows here are created automatically when actions run on the source record. The list below is a read-only monitoring surface — row-level actions (Approve, Recall, Resend, …) live on each row.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"append-only":{icon:o,short:`Read-only · Audit log`,title:`Read-only historical record`,body:()=>`Immutable audit log. Rows cannot be created, edited, or deleted from the UI — they're written by the platform when events occur. Use Export to download for compliance review.`,tone:`border-zinc-300/60 bg-zinc-50 text-zinc-900 hover:bg-zinc-100 dark:border-zinc-500/40 dark:bg-zinc-950/40 dark:text-zinc-100`},"better-auth":{icon:a,short:`Identity`,title:`Managed by the identity provider`,body:e=>`This object's schema is owned by ${e}. Direct edits bypass password hashing, session validation, two-factor checks, and audit hooks. Use the dedicated identity workflows instead (Invite User, Reset Password, Revoke Session, Rotate Key, …).`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function p({managedBy:e,label:n,className:a}){if(!e||e===`platform`)return null;let o=f[e];if(!o)return null;let s=o.icon,p=n??`better-auth`;return(0,d.jsx)(r,{delayDuration:200,children:(0,d.jsxs)(i,{children:[(0,d.jsx)(c,{asChild:!0,children:(0,d.jsxs)(t,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:u(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,o.tone,a),children:[(0,d.jsx)(s,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:o.short})]})}),(0,d.jsxs)(l,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:o.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:o.body(p)})]})]})})}export{p as t};
|
package/dist/assets/{MarketplaceInstalledPage-CSgqJuot.js → MarketplaceInstalledPage-CuPkbetm.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as o}from"./infrastructure-ckitl7Ev.js";import{mt as s,r as c}from"./framework-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as o}from"./infrastructure-ckitl7Ev.js";import{mt as s,r as c}from"./framework-BSpP7C0B.js";import{$n as l,Fi as u,Fo as d,Jn as f,Mt as p,Vr as m,Xn as h,Zn as g,_s as _,ei as v,hr as y,qn as b,rc as x}from"./ui-components-D7IOmcqZ.js";import{_ as S,c as C,g as w,l as T}from"./marketplaceApi-C2Xs-8x9.js";var E=e(n(),1),D=i();function O(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:s}=c(),v=t?`/apps/${t}`:``,[x,O]=(0,E.useState)([]),[k,A]=(0,E.useState)(`local`),[j,M]=(0,E.useState)(!0),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)(null),L=async()=>{M(!0);try{let e=await C();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await T()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(i(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await w(e.manifestId),I({ok:!0,message:i(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})}),F&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${F.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&x.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(p,{className:`h-20 w-full`},t))}):x.length===0?(0,D.jsxs)(`div`,{className:`text-center py-12 text-sm text-muted-foreground border rounded-md`,children:[(0,D.jsx)(`p`,{children:i(`marketplace.installedEmpty`)}),(0,D.jsx)(y,{variant:`link`,className:`mt-2`,onClick:()=>e(`${v}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:x.map(t=>(0,D.jsxs)(b,{children:[(0,D.jsxs)(h,{className:`flex flex-row items-start justify-between gap-3 pb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(g,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(l,{variant:`outline`,children:i(`marketplace.versionBadge`,{version:t.version})})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{children:i(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:i(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[i(`marketplace.installedPackageId`),` `,(0,D.jsx)(`code`,{className:`font-mono`,children:t.packageId})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>e(`${v}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?i(`marketplace.action.uninstalling`):i(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(f,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:i(`marketplace.cachedAs`,{path:`.objectstack/installed-packages/${t.manifestId.replace(/[^a-zA-Z0-9._-]/g,`_`)}.json`})}})]},t.manifestId))}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground border-t pt-4`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(S,{})}s.register(`marketplace:installed-list`,()=>(0,D.jsx)(O,{}),{namespace:`app-shell`,label:`Installed Marketplace Packages`,category:`plugin`,inputs:[]});var k=t({MarketplaceInstalledPage:()=>A});function A(){let e=a(),{appName:t}=r(),{t:n}=c(),i=t?`/apps/${t}`:``;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-5xl`,children:[(0,D.jsxs)(y,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(x,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),n(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(v,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:n(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:n(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
|
package/dist/assets/{MarketplacePackagePage-0TU_eJIx.js → MarketplacePackagePage-CKJ_NEnI.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-ckitl7Ev.js";import{T as te,r as ne}from"./framework-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-ckitl7Ev.js";import{T as te,r as ne}from"./framework-BSpP7C0B.js";import{$n as o,Bn as re,Bs as s,Bt as ie,Er as c,Fo as ae,Hn as oe,Ht as se,Io as ce,Jn as le,Kn as l,Ln as ue,Mt as u,Qo as d,Rn as de,Uo as fe,Ut as pe,Vn as me,Vr as f,Vt as he,Wt as ge,Xn as _e,Zn as ve,_i as p,_s as m,cn as ye,da as h,gi as be,gn as xe,hr as g,hs as _,ja as v,la as Se,mo as Ce,on as y,qn as we,rc as Te,sn as Ee,un as b,zn as De,zo as Oe}from"./ui-components-D7IOmcqZ.js";import"./MetadataProvider-DVGxIr-Y.js";import{i as x}from"./runtime-config-BeHVOPm3.js";import{n as ke,t as Ae}from"./usePackageL10n-shLsxEAx.js";import{_ as je,a as Me,f as Ne,g as Pe,h as Fe,i as Ie,l as Le,m as Re,n as ze,o as Be,p as Ve,r as He,s as Ue,t as We}from"./marketplaceApi-C2Xs-8x9.js";var S=e(n(),1),C=i();function w(e){let t=e.replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
|
|
4
4
|
`),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function T(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,C.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,C.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,C.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,C.jsx)(C.Fragment,{children:t.map((e,t)=>(0,C.jsx)(S.Fragment,{children:e},t))})}function Ge({source:e,className:t}){let n=w(e);return(0,C.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,C.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:T(e.text??``)},t);case`h2`:return(0,C.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:T(e.text??``)},t);case`h3`:return(0,C.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:T(e.text??``)},t);case`p`:return(0,C.jsx)(`p`,{children:T(e.text??``)},t);case`ul`:return(0,C.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,C.jsx)(`span`,{children:T(e)})]},t))},t);case`ol`:return(0,C.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,C.jsx)(`li`,{className:`pl-1`,children:T(e)},t))},t);case`code`:return(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,C.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var E={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function D({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,C.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Ke({version:e}){let{t}=ne();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,C.jsx)(d,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,C.jsx)(o,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:E[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(o,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(be,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(o,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(p,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(o,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,C.jsx)(D,{icon:s,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(D,{icon:c,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(D,{icon:h,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(D,{icon:Ce,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var O=t({MarketplacePackagePage:()=>k});function k(){let e=a(),{packageId:t,appName:n}=r(),i=ee(),{t:s,language:c}=ne(),d=n?`/apps/${n}`:``,{refresh:p}=te(),[h,be]=(0,S.useState)(null),[Ce,w]=(0,S.useState)(!0),[T,E]=(0,S.useState)(null),[D,O]=(0,S.useState)(!1),[k,qe]=(0,S.useState)([]),[Je,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(``),[F,Ye]=(0,S.useState)(!1),[Xe,Ze]=(0,S.useState)(!1),[I,Qe]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,$e]=(0,S.useState)(null),[B,V]=(0,S.useState)(null),[H,U]=(0,S.useState)(null),[W,G]=(0,S.useState)(null),[et,K]=(0,S.useState)([]),[q,J]=(0,S.useState)(!1),[Y,X]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!x().features.installLocal)return;let e=!1;return(async()=>{let t=await Le();e||K(t)})(),()=>{e=!0}},[t,Y]),(0,S.useEffect)(()=>{if(!t)return;let e=x().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await ze(t,e);n||!r||(V(r),$e(r.version))})(),()=>{n=!0}},[t]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{if(t){w(!0),E(null);try{let n=await He(t);e||be(n)}catch(t){e||E(t?.message??String(t))}finally{e||w(!1)}}})(),()=>{e=!0}},[t]);let tt=async()=>{O(!0),R(null),M(null);let e=x().defaultEnvironmentId;if(e){A(!1),P(e),qe([]);return}A(!0);try{let[e,t]=await Promise.all([Be(),Ue()]),n=e.filter(e=>{let n=e.organization_id;return n?t.has(String(n)):!1});qe(n),e.length>0&&n.length===0?M(s(`marketplace.install.noPermission`)):n.length===1&&P(n[0].id)}catch(e){let t=e?.status;M(t===401||t===403?s(`marketplace.install.signInFirst`):e?.message??String(e))}finally{A(!1)}},nt=async()=>{if(!(!t||!N)){Qe(!0),R(null);try{$e(((await Me({packageId:t,environmentId:N,seedSampleData:F}))?.installation?.version??h?.package?.latest_version?.version??h?.versions?.[0]?.version??``)||`installed`);try{let e=x().defaultEnvironmentId||N;if(e){let n=await ze(t,e);n&&V(n)}}catch{}let e=x().defaultEnvironmentId;if(!e||e===N)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await p()}catch{}R({ok:!0,message:s(`marketplace.install.success`)})}catch(e){R({ok:!1,message:e?.message??String(e)})}finally{Qe(!1)}}},rt=async()=>{if(t){J(!0),X(null);try{let e=await Ie({packageId:t});try{await p(`app`)}catch{}X({ok:!0,message:s(`marketplace.install.localSuccess`,{version:e.version,name:h?.package?Ae(h.package,c).displayName:e.manifestId})})}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=s(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=s(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=s(`marketplace.install.localMarketplaceUnavailable`)),X({ok:!1,message:n})}finally{J(!1)}}},it=async()=>{if($&&confirm(s(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){J(!0),X(null);try{await Pe($.manifestId);try{await p(`app`)}catch{}X({ok:!0,message:s(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){X({ok:!1,message:e?.message??String(e)})}finally{J(!1)}}},at=async()=>{if(B){U(`reseed`),G(null);try{let e=await Fe(B.installationId);e.ok?(V({...B,withSampleData:!0}),G({ok:!0,text:s(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):G({ok:!1,text:e.error||`Re-seed failed`})}finally{U(null)}}},ot=async()=>{if(B&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){U(`purge`),G(null);try{let e=await Ve(B.installationId);if(e.ok){V({...B,withSampleData:!1});let t=e.deleted??0;G({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else G({ok:!1,text:e.error||`Purge failed`})}finally{U(null)}}},st=async()=>{if($){U(`reseed`),G(null);try{let e=await Re($.manifestId);K(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0;G({ok:!0,text:s(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`})}catch(e){G({ok:!1,text:e?.message||`Re-seed failed`})}finally{U(null)}}},ct=async()=>{if($&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){U(`purge`),G(null);try{let e=await Ne($.manifestId);K(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;G({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){G({ok:!1,text:e?.message||`Purge failed`})}finally{U(null)}}};if(Ce)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsx)(u,{className:`h-8 w-32`}),(0,C.jsx)(u,{className:`h-16 w-full`}),(0,C.jsx)(u,{className:`h-64 w-full`})]});if(T||!h)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:()=>e(`${d}/system/marketplace`),children:[(0,C.jsx)(Te,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`font-medium text-destructive`,children:s(`marketplace.load.packageFailed`)}),(0,C.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:T??s(`marketplace.load.notFound`)})]})]})]});let Z=h.package,Q=Ae(Z,c),lt=Z.latest_version?.version??h.versions[0]?.version??null,$=et.find(e=>e.manifestId===Z.manifest_id)??null,ut=!!Z.latest_version?.contains_code,dt=x().features.installLocal,ft=!lt||q||I||!dt&&!!z,pt=dt?{label:s(q?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:rt}:{label:I?s(`marketplace.action.installing`):z?s(`marketplace.action.installed`,{defaultValue:`Installed`}):s(`marketplace.action.installToCloud`),onClick:tt},mt=Z.category?s(`marketplace.category.${Z.category}`,{defaultValue:Z.category}):null;return i?(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(g,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${d}/system/marketplace`),children:[(0,C.jsx)(Te,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,C.jsx)(ke,{iconUrl:Z.icon_url,displayName:Q.displayName,manifestId:Z.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,C.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Q.displayName||Z.manifest_id}),Z.homepage_url&&(0,C.jsxs)(`a`,{href:Z.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:s(`marketplace.detail.homepage`),children:[(0,C.jsx)(ae,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:s(`marketplace.detail.homepage`)})]})]}),(0,C.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:Z.manifest_id}),lt&&(0,C.jsx)(o,{variant:`outline`,children:s(`marketplace.versionBadge`,{version:lt})}),Z.publisher&&Z.publisher!==`private`&&(0,C.jsx)(o,{variant:Z.publisher===`objectstack`?`default`:`secondary`,children:Z.publisher}),mt&&(0,C.jsx)(o,{variant:`outline`,children:mt}),Z.license&&(0,C.jsx)(o,{variant:`outline`,className:`font-normal`,children:Z.license}),$&&(0,C.jsxs)(o,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:$.version})]}),!$&&z&&(0,C.jsxs)(o,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:z})]})]}),Q.description&&(0,C.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Q.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,C.jsxs)(g,{onClick:pt.onClick,disabled:ft,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(Oe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),pt.label]}),$&&(0,C.jsxs)(Ee,{children:[(0,C.jsx)(xe,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`),children:(0,C.jsx)(ce,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(ye,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(b,{onSelect:st,disabled:H!==null,children:[H===`reseed`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(b,{onSelect:ct,disabled:H!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(f,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(b,{onSelect:it,disabled:q,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(f,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&B&&!x().cloudUrl&&(0,C.jsxs)(Ee,{children:[(0,C.jsx)(xe,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`)||`More options`,children:(0,C.jsx)(ce,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(ye,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(b,{onSelect:at,disabled:H!==null,children:[H===`reseed`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),B.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(b,{onSelect:ot,disabled:H!==null||!B.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(f,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),W&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${W.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[W.ok?(0,C.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:W.text}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>G(null),children:s(`marketplace.action.dismiss`)})]}),Y&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${Y.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[Y.ok?(0,C.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:Y.message}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>X(null),children:s(`marketplace.action.dismiss`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,C.jsxs)(we,{children:[(0,C.jsx)(_e,{children:(0,C.jsx)(ve,{className:`text-base`,children:s(`marketplace.detail.about`)})}),(0,C.jsx)(le,{children:Q.readme?(0,C.jsx)(Ge,{source:Q.readme}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noReadme`)})})]})}),(0,C.jsx)(`div`,{className:`space-y-4`,children:(0,C.jsxs)(we,{children:[(0,C.jsx)(_e,{children:(0,C.jsx)(ve,{className:`text-base`,children:s(`marketplace.detail.versions`)})}),(0,C.jsx)(le,{children:h.versions.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noApprovedVersions`)}):(0,C.jsx)(`ul`,{className:`space-y-2`,children:h.versions.map(e=>(0,C.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(Se,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,C.jsx)(o,{variant:`outline`,className:`text-xs`,children:s(`marketplace.detail.prerelease`)})]}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]},e.id))})})]})})]}),(0,C.jsx)(ue,{open:D,onOpenChange:e=>{O(e),e||(R(null),Ze(!1))},children:(0,C.jsxs)(de,{children:[(0,C.jsxs)(me,{children:[(0,C.jsx)(oe,{children:s(`marketplace.install.dialogTitle`,{name:Q.displayName||Z.manifest_id})}),(0,C.jsx)(De,{children:x().defaultEnvironmentId?s(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):s(`marketplace.install.dialogDescPicker`)})]}),Je?(0,C.jsx)(u,{className:`h-10 w-full`}):j?(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:j})]}),(0,C.jsx)(`a`,{href:We(Z.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ae,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.action.openOnCloud`)]})})]}):x().defaultEnvironmentId?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:F,onCheckedChange:e=>Ye(e===!0)}),(0,C.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]}):k.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.install.noEnvs`)}):(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(y,{htmlFor:`env-select`,children:s(`marketplace.install.environment`)}),(0,C.jsxs)(ie,{value:N,onValueChange:P,children:[(0,C.jsx)(pe,{id:`env-select`,children:(0,C.jsx)(ge,{placeholder:s(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(he,{children:k.map(e=>(0,C.jsxs)(se,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]})]},e.id))})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:F,onCheckedChange:e=>Ye(e===!0)}),(0,C.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]})]}),ut&&!j&&(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(Ke,{version:Z.latest_version}),(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(l,{id:`ack-perms`,checked:Xe,onCheckedChange:e=>Ze(e===!0)}),(0,C.jsx)(y,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:s(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),L&&(0,C.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${L.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:L.message}),(0,C.jsxs)(re,{children:[(0,C.jsx)(g,{variant:`outline`,onClick:()=>O(!1),children:s(`marketplace.action.close`)}),!j&&(0,C.jsx)(g,{onClick:nt,disabled:!N||I||L?.ok===!0||ut&&!Xe,children:s(I?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,C.jsx)(je,{})}export{O as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-ckitl7Ev.js";import{r as o}from"./framework-D7UWfRl4.js";import{$n as s,Fi as c,Jn as l,Mt as u,Si as te,Xn as d,Yn as f,Zn as p,_s as ne,ei as m,hr as h,hs as g,la as _,nn as v,qn as y,yi as re}from"./ui-components-Clv7N77v.js";import{i as ie}from"./runtime-config-ir5bt3TX.js";import{n as b,t as x}from"./usePackageL10n-shLsxEAx.js";import{_ as S,a as ae,c as oe,d as se,i as ce,l as C,u as w}from"./marketplaceApi-Do90JxGv.js";var T=t({MarketplacePage:()=>k}),E=e(n(),1),D=i();function O(){let{language:e,t}=o();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function k(){let e=a(),{appName:t}=r(),n=ee(),{t:i,language:T}=o(),k=O(),A=t?`/apps/${t}`:``,[j,M]=(0,E.useState)([]),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(null),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]),[G,K]=(0,E.useState)(null),[q,J]=(0,E.useState)(null),[le,Y]=(0,E.useState)(new Set),ue=(0,E.useMemo)(()=>{let e=new Map;for(let t of V)e.set(t.manifestId,t);return e},[V]),X=async()=>{P(!0),I(null);try{let[e,t,n,r]=await Promise.all([w({limit:100}),C(),se(),oe()]);M(e.items??[]),H(t),W(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);Y(i)}catch(e){I(e?.message??String(e)),M([])}finally{P(!1)}};(0,E.useEffect)(()=>{X()},[]);let de=async e=>{K(e.id),J(null);try{ie().features.installLocal?await ce({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,E.useMemo)(()=>{let e=new Set;for(let t of j)t.category&&e.add(t.category);return Array.from(e).sort()},[j]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,E.useMemo)(()=>{let e=L.trim().toLowerCase();return j.filter(t=>{if(z&&t.category!==z)return!1;if(!e)return!0;let n=x(t,T);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[j,L,z,T]);return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>e(`${A}/system/marketplace/installed`),children:[(0,D.jsx)(re,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),V.length>0?i(`marketplace.installedCount`,{count:V.length}):i(`marketplace.installed`)]}),(0,D.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:N,children:[(0,D.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1`,children:[(0,D.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,D.jsx)(v,{value:L,onChange:e=>R(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,D.jsx)(h,{size:`sm`,variant:z===``?`default`:`outline`,onClick:()=>B(``),children:i(`marketplace.all`)}),Z.map(e=>(0,D.jsx)(h,{size:`sm`,variant:z===e?`default`:`outline`,onClick:()=>B(e),children:Q(e)},e))]})]}),F&&(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,D.jsx)(ne,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,D.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:F}),(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),U.length>0&&(0,D.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,D.jsx)(s,{variant:`secondary`,className:`text-xs`,children:U.length})]}),q&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:U.map(e=>{let t=le.has(e.manifest_id);return(0,D.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,D.jsxs)(d,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,D.jsx)(b,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(p,{className:`text-base truncate`,children:e.display_name}),(0,D.jsx)(f,{className:`text-xs truncate`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,D.jsx)(s,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,D.jsxs)(l,{className:`flex-1 flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,D.jsxs)(s,{variant:`outline`,className:`text-xs`,children:[(0,D.jsx)(_,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,D.jsx)(`div`,{className:`ml-auto`,children:t?(0,D.jsxs)(s,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,D.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,D.jsx)(h,{size:`sm`,onClick:()=>void de(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,D.jsx)(`div`,{className:`border-b pt-2`})]}),N&&j.length===0?(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,D.jsxs)(y,{children:[(0,D.jsxs)(d,{className:`pb-2`,children:[(0,D.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,D.jsx)(u,{className:`h-5 w-3/4`}),(0,D.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,D.jsx)(l,{children:(0,D.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,D.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:j.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=ue.get(t.manifest_id),r=x(t,T);return(0,D.jsxs)(y,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${A}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${A}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,D.jsxs)(d,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,D.jsx)(b,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(p,{className:`text-base truncate`,children:r.displayName}),(0,D.jsx)(f,{className:`text-xs truncate`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,D.jsx)(s,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,D.jsxs)(l,{className:`flex-1 flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,D.jsxs)(s,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,D.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,D.jsxs)(s,{variant:`outline`,className:`text-xs`,children:[(0,D.jsx)(_,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,D.jsx)(s,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:k(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,D.jsx)(S,{})}export{T as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-ckitl7Ev.js";import{r as o}from"./framework-BSpP7C0B.js";import{$n as s,Fi as c,Jn as l,Mt as u,Si as te,Xn as d,Yn as f,Zn as p,_s as ne,ei as m,hr as h,hs as g,la as _,nn as v,qn as y,yi as re}from"./ui-components-D7IOmcqZ.js";import{i as ie}from"./runtime-config-BeHVOPm3.js";import{n as b,t as x}from"./usePackageL10n-shLsxEAx.js";import{_ as S,a as ae,c as oe,d as se,i as ce,l as C,u as w}from"./marketplaceApi-C2Xs-8x9.js";var T=t({MarketplacePage:()=>k}),E=e(n(),1),D=i();function O(){let{language:e,t}=o();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function k(){let e=a(),{appName:t}=r(),n=ee(),{t:i,language:T}=o(),k=O(),A=t?`/apps/${t}`:``,[j,M]=(0,E.useState)([]),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(null),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]),[G,K]=(0,E.useState)(null),[q,J]=(0,E.useState)(null),[le,Y]=(0,E.useState)(new Set),ue=(0,E.useMemo)(()=>{let e=new Map;for(let t of V)e.set(t.manifestId,t);return e},[V]),X=async()=>{P(!0),I(null);try{let[e,t,n,r]=await Promise.all([w({limit:100}),C(),se(),oe()]);M(e.items??[]),H(t),W(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);Y(i)}catch(e){I(e?.message??String(e)),M([])}finally{P(!1)}};(0,E.useEffect)(()=>{X()},[]);let de=async e=>{K(e.id),J(null);try{ie().features.installLocal?await ce({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,E.useMemo)(()=>{let e=new Set;for(let t of j)t.category&&e.add(t.category);return Array.from(e).sort()},[j]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,E.useMemo)(()=>{let e=L.trim().toLowerCase();return j.filter(t=>{if(z&&t.category!==z)return!1;if(!e)return!0;let n=x(t,T);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[j,L,z,T]);return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>e(`${A}/system/marketplace/installed`),children:[(0,D.jsx)(re,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),V.length>0?i(`marketplace.installedCount`,{count:V.length}):i(`marketplace.installed`)]}),(0,D.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:N,children:[(0,D.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1`,children:[(0,D.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,D.jsx)(v,{value:L,onChange:e=>R(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,D.jsx)(h,{size:`sm`,variant:z===``?`default`:`outline`,onClick:()=>B(``),children:i(`marketplace.all`)}),Z.map(e=>(0,D.jsx)(h,{size:`sm`,variant:z===e?`default`:`outline`,onClick:()=>B(e),children:Q(e)},e))]})]}),F&&(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,D.jsx)(ne,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,D.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:F}),(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),U.length>0&&(0,D.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,D.jsx)(s,{variant:`secondary`,className:`text-xs`,children:U.length})]}),q&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:U.map(e=>{let t=le.has(e.manifest_id);return(0,D.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,D.jsxs)(d,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,D.jsx)(b,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(p,{className:`text-base truncate`,children:e.display_name}),(0,D.jsx)(f,{className:`text-xs truncate`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,D.jsx)(s,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,D.jsxs)(l,{className:`flex-1 flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,D.jsxs)(s,{variant:`outline`,className:`text-xs`,children:[(0,D.jsx)(_,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,D.jsx)(`div`,{className:`ml-auto`,children:t?(0,D.jsxs)(s,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,D.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,D.jsx)(h,{size:`sm`,onClick:()=>void de(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,D.jsx)(`div`,{className:`border-b pt-2`})]}),N&&j.length===0?(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,D.jsxs)(y,{children:[(0,D.jsxs)(d,{className:`pb-2`,children:[(0,D.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,D.jsx)(u,{className:`h-5 w-3/4`}),(0,D.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,D.jsx)(l,{children:(0,D.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,D.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:j.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=ue.get(t.manifest_id),r=x(t,T);return(0,D.jsxs)(y,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${A}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${A}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,D.jsxs)(d,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,D.jsx)(b,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(p,{className:`text-base truncate`,children:r.displayName}),(0,D.jsx)(f,{className:`text-xs truncate`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,D.jsx)(s,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,D.jsxs)(l,{className:`flex-1 flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,D.jsxs)(s,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,D.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,D.jsxs)(s,{variant:`outline`,className:`text-xs`,children:[(0,D.jsx)(_,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,D.jsx)(s,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:k(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,D.jsx)(S,{})}export{T as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{Q as r,r as i}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{Q as r,r as i}from"./framework-BSpP7C0B.js";import{Cs as a,Jo as o,ws as s,xs as c}from"./ui-components-D7IOmcqZ.js";function l(e,t,n){if(!(!e||t==null)){if(n){let r=e.find(e=>e.name===t&&e._packageId===n);if(r)return r}return e.find(e=>e.name===t)}}var u=e(t(),1),d=n();function f({sections:e,open:t}){if(!t)return null;let{t:n}=i(),[r,l]=(0,u.useState)([`0`]),[f,p]=(0,u.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(c,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(s,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?r(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{C as a}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{C as a}from"./framework-BSpP7C0B.js";import{n as o}from"./data-adapter-BEs3zHWP.js";import{i as s}from"./plugin-form-DkI3TvRN.js";var c=e(t(),1),l=r(),u=(0,c.createContext)(!1),d=`preview`,f=`draft`;function p(e){return new URLSearchParams(e).get(d)===f}var m=!1;function h(){m=!0}function g({force:e,children:t}){let r=n(),a=i(),o=(0,c.useMemo)(()=>p(r.search),[r.search]),[s,h]=(0,c.useState)(o);return(0,c.useEffect)(()=>{if(o){h(!0),m=!1;return}if(!s)return;if(m){m=!1,h(!1);return}let e=new URLSearchParams(r.search);e.set(d,f),a(`${r.pathname}?${e.toString()}${r.hash}`,{replace:!0})},[o,s,r.pathname,r.search,r.hash,a]),(0,l.jsx)(u.Provider,{value:e??(o||s),children:t})}function _(){return(0,c.useContext)(u)}var v=null,y=0,b=0,x=null,S={editor:v,openSeq:y,reviewSeq:b,reviewTarget:x},C=new Set;function w(){S={editor:v,openSeq:y,reviewSeq:b,reviewTarget:x};for(let e of C)e()}function T(e,t){return e===t?!0:JSON.stringify(e)===JSON.stringify(t)}var E={subscribe(e){return C.add(e),()=>{C.delete(e)}},getSnapshot(){return S},setEditor(e){T(v,e)||(v=e,w())},requestOpen(){y+=1,w()},requestReview(e){b+=1,x=e,w()}},D=new Set;function O(e){for(let t of D)t(e)}function k(e){return D.add(e),()=>{D.delete(e)}}function A(){return(0,c.useSyncExternalStore)(E.subscribe,E.getSnapshot,E.getSnapshot)}function j(e){(0,c.useEffect)(()=>(E.setEditor(e),()=>E.setEditor(null)),[e?JSON.stringify(e):``])}function M(){E.requestOpen()}function N(e){E.requestReview(e)}var P=300*1e3,F=[`app`,`view`],I={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},L=`objectui:metadata:`;function R(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var z=R();function B(...e){z&&console.debug(`[MetadataProvider]`,...e)}function V(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function H(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function U(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function W(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function G(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)W(e)&&r.add(e.object);for(let e of t){if(W(e)){let t=n[e.object]||={listViews:{},formViews:{}},r=e.name||`${e.object}.${e.viewKind}`,i=e.config&&typeof e.config==`object`?e.config:{},a={...i,name:r,label:e.label??i.label,isDefault:!!e.isDefault};e.viewKind===`form`?(t.formViews[r]=a,(e.isDefault||!t.form)&&(t.form=a)):(t.listViews[r]=a,e.isDefault&&(t.primary=a));continue}let t=e?.name||e?.list?.data?.object||e?.form?.data?.object;if(!t||r.has(t))continue;let i=n[t]||={listViews:{},formViews:{}};if(e.list){i.primary=e.list;let t=e.list.name||`list`;i.listViews[t]=e.list}if(e.form&&(i.form=e.form),e.listViews&&typeof e.listViews==`object`)for(let[t,n]of Object.entries(e.listViews))i.listViews[t]=n;if(e.formViews&&typeof e.formViews==`object`)for(let[t,n]of Object.entries(e.formViews))i.formViews[t]=n}return e.map(e=>{let t=n[e.name];if(!t)return e;let r=e.listViews||e.list_views||{},i=e.formViews||e.form_views||{},a={...e,listViews:{...t.listViews,...r}};return(Object.keys(t.formViews).length||Object.keys(i).length)&&(a.formViews={...t.formViews,...i}),t.primary&&!e.list&&(a.list=t.primary),t.form&&!e.form&&(a.form=t.form),a})}function K(e){if(!e?.length)return e;let t={};for(let n of e){let e=n?.fields;if(!e)continue;let r=Array.isArray(e)?e.map(e=>[e?.name,e]):Object.entries(e);for(let[e,i]of r){let r=i;if(!e||!r?.inlineEdit||r.type!==`master_detail`&&r.type!==`lookup`)continue;let a=r.reference;a&&(t[a]||=[]).push({childObject:n.name,relationshipField:e,inlineMode:s(n,r.inlineEdit,{relationshipField:e}),...r.inlineTitle?{title:r.inlineTitle}:{},...Array.isArray(r.inlineColumns)?{columns:r.inlineColumns}:{},...typeof r.inlineAmountField==`string`?{amountField:r.inlineAmountField}:{}})}}return Object.keys(t).length?e.map(e=>{let n=t[e.name];if(!n?.length)return e;let r={...e.form||{type:`simple`}},i=Array.isArray(r.subforms)?r.subforms:[],a=new Set(i.map(e=>e.childObject));r.subforms=[...n.filter(e=>!a.has(e.childObject)),...i];let o={...e,form:r};return e.formViews?.default&&(o.formViews={...e.formViews,default:{...e.formViews.default,subforms:r.subforms}}),o}):e}function q(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function J(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(L+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function Y(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(L+e,JSON.stringify(t))}catch{}}function X({children:e,adapter:t,ttlMs:n=P}){let r=(0,c.useRef)(new Map),i=(0,c.useRef)(new Map),s=(0,c.useRef)(t);s.current=t;let u=_(),d=(0,c.useMemo)(()=>u?new o({baseUrl:``,previewDrafts:!0}):null,[u]),f=(0,c.useRef)(d);f.current=d;let[p,m]=(0,c.useState)(0),h=(0,c.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>m(e=>e+1)):Promise.resolve().then(()=>m(e=>e+1))},[]);(0,c.useEffect)(()=>{r.current.clear(),i.current.clear(),h()},[u,h]);let g=(0,c.useCallback)(e=>{let t=r.current.get(e);return t||(t=q(),r.current.set(e,t)),t},[]),v=(0,c.useCallback)(e=>{let t=g(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return B(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=f.current,a=(i?i.list(e):s.current.getClient().meta.getItems(e)).then(n=>{let a=V(n);t.items=a,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of a)U(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&Y(e,a),B(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),h(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,B(`fetch failed type=${e}`,r),h(),[]});return t.promise=a,a},[h,g,n]),y=(0,c.useCallback)((e,t)=>{let n=g(e);if(n.byName.has(t))return B(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=i.current.get(e);r||(r=new Map,i.current.set(e,r));let a=r.get(t);if(a)return a;let o=Date.now(),c=f.current,l=(c?c.get(e,t):s.current.getClient().meta.getItem(e,t)).then(i=>{let a=H(i);return a&&n.byName.set(t,a),B(`fetched item type=${e} name=${t} in ${Date.now()-o}ms`),r.delete(t),a}).catch(n=>(r.delete(t),B(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[g]),b=(0,c.useCallback)(async e=>{if(e){let t=g(e);t.fetchedAt=0,t.byName.clear(),await v(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),v(e)}))},[v,g]),x=(0,c.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),B(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,B(`invalidated type=${e}`)),h())},[h]);(0,c.useEffect)(()=>{if(u)return k(({type:e})=>{x(e)})},[u,x]);let[S,C]=(0,c.useState)(!0),[w,T]=(0,c.useState)(null);(0,c.useEffect)(()=>{let e=!1,t=u?null:J(`app`);if(t){let e=g(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)U(n)&&e.byName.set(n.name,n);h(),C(!1)}return(async()=>{for(let t of F)try{await v(t),e||T(null)}catch(t){e||T(t instanceof Error?t:Error(String(t)))}e||C(!1)})(),()=>{e=!0}},[t,v,g,h,u]);let E=(0,c.useMemo)(()=>{let e=e=>{let t=g(e);return t.status===`idle`&&v(e),t.items};return{apps:g(`app`).items,get objects(){let t=e(I.objects),n=e(`view`);return K(n.length?G(t,n):t)},get dashboards(){return e(I.dashboards)},get reports(){return e(I.reports)},get pages(){return e(I.pages)},loading:S,error:w??g(`app`).error,refresh:b,invalidate:x,ensureType:v,getItem:y,getItemsByType:t=>e(t),getTypeStatus:e=>g(e).status}},[p,S,w,v,y,g,b,x]);return(0,l.jsx)(a.Provider,{value:E,children:e})}export{A as a,g as c,N as i,h as l,O as n,j as o,M as r,d as s,X as t,_ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-DR370ovB.js";import{f as c,m as l}from"./infrastructure-ckitl7Ev.js";import{B as u,O as d,T as f,r as p,w as m}from"./framework-D7UWfRl4.js";import{H as h,R as g,So as _,Yi as v,dc as y,z as b}from"./ui-components-Clv7N77v.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./MetadataProvider-Bxendsnd.js";import{r as S}from"./ExpressionProvider-Cj6XEnZF.js";import{n as C,r as w,t as T}from"./MetadataInspector-CamKLf7x.js";import{t as E}from"./InterfaceListPage-BJRTel_h.js";import{a as D,i as O,n as k,r as A,t as j}from"./resolveActionParams-eRBdMG9b.js";var M=e(n(),1),N=o(),P={id:`current-user`,name:`Demo User`};function F(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:u}=c(),{fieldLabel:d,fieldOptionLabel:f,actionParamText:p}=y(),m=(0,M.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),h=r||m?.name,g=(0,M.useCallback)(()=>{i?.()},[i]),[_,v]=(0,M.useState)({open:!1,message:``}),[b,S]=(0,M.useState)({open:!1,params:[]}),[C,w]=(0,M.useState)({open:!1}),[T,E]=(0,M.useState)(null),F=(0,M.useRef)(new Set),I=(0,M.useCallback)((e,t)=>new Promise(n=>{w({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,M.useCallback)((e,t)=>new Promise(n=>{v({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,M.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=j(e,{objectName:r||m?.name||``,objects:n||[],fieldLabel:d,fieldOptionLabel:f,row:a}),s=r||m?.name;S({open:!0,params:o.map(e=>({...e,label:p(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:p(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:p(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText})),title:t?.label||t?.title,description:t?.description,resolve:i})}),[r,m,n,d,f,p]),z=o?{id:o.id,name:o.name,avatar:o.image}:P,B=(0,M.useCallback)((e,t)=>{t?.type===`error`?x.error(e):x.success(e)},[]),V=(0,M.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),H=(0,M.useMemo)(()=>l(),[]),U=(0,M.useCallback)(async e=>{try{let n=e.target||e.name,r=e.params||{},i=typeof n==`string`?n:``;if(i.startsWith(`/`)||/^https?:\/\//i.test(i)){let t={...r},n=t._rowRecord;delete t._rowRecord;let a=i;n&&/\{[a-z_][a-z0-9_]*\}/i.test(a)&&(a=a.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let r=n[t];return r==null?``:encodeURIComponent(String(r))}));let o=a.startsWith(`http`)?a:`${a}`,s=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,c=s?{[s]:t}:{...t};if(n&&e.recordIdParam){let t=n[e.recordIdField||`id`];t!=null&&(c[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(a)&&!c.organizationId&&u?.id&&(c.organizationId=u.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(c,e.bodyExtra);let l=(e.method||`POST`).toUpperCase(),d={method:l,headers:{"Content-Type":`application/json`},credentials:`include`};l!==`GET`&&l!==`DELETE`&&(d.body=JSON.stringify(c));let f=await H(o,d);if(!f.ok){let e=`HTTP ${f.status}`;try{let t=await f.json();e=t?.error||t?.message||e}catch{}return{success:!1,error:e}}let p=await f.json().catch(()=>({}));return e.refreshAfter!==!1&&g(),{success:!0,data:p,reload:e.refreshAfter!==!1}}let a=e.objectName||h;a&&typeof t?.execute==`function`?await t.execute(a,n,r):a&&r.recordId&&Object.keys(r).length>1&&typeof t?.update==`function`&&await t.update(a,r.recordId,r);let o=e.refreshAfter!==!1;return o&&g(),{success:!0,reload:o}}catch(e){return{success:!1,error:e.message}}},[t,h,H,u,g]),W=(0,M.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)a=e[0]?.id;else if(e.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await H(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||h,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return E({flowName:n,runId:c.runId,screen:c.screen}),{success:!0};let l=e.refreshAfter!==!1;return l&&g(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[H,h,g]),G=(0,M.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)o=e[0]?.[a];else if(e.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&g(),{success:!0}}let i=e.objectName||h||`global`,a=await H(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return x.error(e),{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&g();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}let t=e.message;return x.error(t),{success:!1,error:t}}finally{F.current.delete(s)}},[H,h,g]);return{confirmHandler:L,toastHandler:B,navigateHandler:V,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:U,flowHandler:W,serverActionHandler:G,authFetch:H,actionProviderProps:(0,M.useMemo)(()=>({context:{...r?{objectName:r}:{},user:z,apiBase:``,activeOrganization:u?{id:u.id,slug:u.slug,name:u.name}:null},onConfirm:L,onToast:B,onNavigate:V,onParamCollection:R,onResultDialog:I,handlers:{api:U,flow:W,script:G,modal:G}}),[r,z,u,L,B,V,R,I,U,W,G]),dialogs:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(D,{state:_,onOpenChange:e=>{e||v({open:!1,message:``})}}),(0,N.jsx)(O,{state:b,onOpenChange:e=>{e||S({open:!1,params:[]})}}),(0,N.jsx)(A,{state:C,onAcknowledge:()=>{C.resolve?.(),w({open:!1})}}),(0,N.jsx)(k,{state:T,authFetch:H,baseUrl:``,onClose:()=>E(null),onComplete:()=>{E(null),g()}})]})}}function I({children:e,...t}){let n=F(t);return(0,N.jsxs)(d,{...n.actionProviderProps,children:[e,n.dialogs]})}var L=t({PageView:()=>R});function R(){let{t:e}=p(),{pageName:t}=r(),[n]=a(),{showDebug:o}=C(),l=s(),d=i(),{user:y}=c(),x=y?.role===`admin`,{pages:D,objects:O}=f(),{app:k}=S(),A=m(),[j,P]=(0,M.useState)(0),F=w(D,t,k?._packageId);if(!F)return(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(g,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(_,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(h,{children:e(`empty.pageNotFound`)}),(0,N.jsx)(b,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})});let L=Object.fromEntries(n.entries()),R=d.pathname.match(/\/apps\/([^/]+)/)?.[1],z=x&&!!R&&!!t;return(0,N.jsx)(I,{dataSource:A,objects:O,onRefresh:()=>P(e=>e+1),children:(0,N.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,N.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[z&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{z&&l(`/apps/${R}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,N.jsx)(v,{className:`h-3.5 w-3.5`})}),F.interfaceConfig?.source?(0,N.jsx)(E,{page:F},j):(0,N.jsx)(u,{schema:{...F,type:F.type||`page`,context:{...F.context,params:L,refreshKey:j}}},j)]}),(0,N.jsx)(T,{open:o,sections:[{title:`Page Configuration`,data:F}]})]})})}export{F as n,L as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-DR370ovB.js";import{f as c,m as l}from"./infrastructure-ckitl7Ev.js";import{B as u,O as d,T as f,r as p,w as m}from"./framework-BSpP7C0B.js";import{H as h,R as g,So as _,Yi as v,dc as y,z as b}from"./ui-components-D7IOmcqZ.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./MetadataProvider-DVGxIr-Y.js";import{r as S}from"./ExpressionProvider-w-i3oDR9.js";import{n as C,r as w,t as T}from"./MetadataInspector-eUKibp4P.js";import{t as E}from"./InterfaceListPage-CtbkRAlr.js";import{a as D,i as O,n as k,r as A,t as j}from"./resolveActionParams-C1HIbU1j.js";var M=e(n(),1),N=o(),P={id:`current-user`,name:`Demo User`};function F(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:u}=c(),{fieldLabel:d,fieldOptionLabel:f,actionParamText:p}=y(),m=(0,M.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),h=r||m?.name,g=(0,M.useCallback)(()=>{i?.()},[i]),[_,v]=(0,M.useState)({open:!1,message:``}),[b,S]=(0,M.useState)({open:!1,params:[]}),[C,w]=(0,M.useState)({open:!1}),[T,E]=(0,M.useState)(null),F=(0,M.useRef)(new Set),I=(0,M.useCallback)((e,t)=>new Promise(n=>{w({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,M.useCallback)((e,t)=>new Promise(n=>{v({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,M.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=j(e,{objectName:r||m?.name||``,objects:n||[],fieldLabel:d,fieldOptionLabel:f,row:a}),s=r||m?.name;S({open:!0,params:o.map(e=>({...e,label:p(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:p(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:p(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText})),title:t?.label||t?.title,description:t?.description,resolve:i})}),[r,m,n,d,f,p]),z=o?{id:o.id,name:o.name,avatar:o.image}:P,B=(0,M.useCallback)((e,t)=>{t?.type===`error`?x.error(e):x.success(e)},[]),V=(0,M.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),H=(0,M.useMemo)(()=>l(),[]),U=(0,M.useCallback)(async e=>{try{let n=e.target||e.name,r=e.params||{},i=typeof n==`string`?n:``;if(i.startsWith(`/`)||/^https?:\/\//i.test(i)){let t={...r},n=t._rowRecord;delete t._rowRecord;let a=i;n&&/\{[a-z_][a-z0-9_]*\}/i.test(a)&&(a=a.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let r=n[t];return r==null?``:encodeURIComponent(String(r))}));let o=a.startsWith(`http`)?a:`${a}`,s=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,c=s?{[s]:t}:{...t};if(n&&e.recordIdParam){let t=n[e.recordIdField||`id`];t!=null&&(c[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(a)&&!c.organizationId&&u?.id&&(c.organizationId=u.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(c,e.bodyExtra);let l=(e.method||`POST`).toUpperCase(),d={method:l,headers:{"Content-Type":`application/json`},credentials:`include`};l!==`GET`&&l!==`DELETE`&&(d.body=JSON.stringify(c));let f=await H(o,d);if(!f.ok){let e=`HTTP ${f.status}`;try{let t=await f.json();e=t?.error||t?.message||e}catch{}return{success:!1,error:e}}let p=await f.json().catch(()=>({}));return e.refreshAfter!==!1&&g(),{success:!0,data:p,reload:e.refreshAfter!==!1}}let a=e.objectName||h;a&&typeof t?.execute==`function`?await t.execute(a,n,r):a&&r.recordId&&Object.keys(r).length>1&&typeof t?.update==`function`&&await t.update(a,r.recordId,r);let o=e.refreshAfter!==!1;return o&&g(),{success:!0,reload:o}}catch(e){return{success:!1,error:e.message}}},[t,h,H,u,g]),W=(0,M.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)a=e[0]?.id;else if(e.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await H(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||h,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return E({flowName:n,runId:c.runId,screen:c.screen}),{success:!0};let l=e.refreshAfter!==!1;return l&&g(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[H,h,g]),G=(0,M.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)o=e[0]?.[a];else if(e.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&g(),{success:!0}}let i=e.objectName||h||`global`,a=await H(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return x.error(e),{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&g();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}let t=e.message;return x.error(t),{success:!1,error:t}}finally{F.current.delete(s)}},[H,h,g]);return{confirmHandler:L,toastHandler:B,navigateHandler:V,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:U,flowHandler:W,serverActionHandler:G,authFetch:H,actionProviderProps:(0,M.useMemo)(()=>({context:{...r?{objectName:r}:{},user:z,apiBase:``,activeOrganization:u?{id:u.id,slug:u.slug,name:u.name}:null},onConfirm:L,onToast:B,onNavigate:V,onParamCollection:R,onResultDialog:I,handlers:{api:U,flow:W,script:G,modal:G}}),[r,z,u,L,B,V,R,I,U,W,G]),dialogs:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(D,{state:_,onOpenChange:e=>{e||v({open:!1,message:``})}}),(0,N.jsx)(O,{state:b,onOpenChange:e=>{e||S({open:!1,params:[]})}}),(0,N.jsx)(A,{state:C,onAcknowledge:()=>{C.resolve?.(),w({open:!1})}}),(0,N.jsx)(k,{state:T,authFetch:H,baseUrl:``,onClose:()=>E(null),onComplete:()=>{E(null),g()}})]})}}function I({children:e,...t}){let n=F(t);return(0,N.jsxs)(d,{...n.actionProviderProps,children:[e,n.dialogs]})}var L=t({PageView:()=>R});function R(){let{t:e}=p(),{pageName:t}=r(),[n]=a(),{showDebug:o}=C(),l=s(),d=i(),{user:y}=c(),x=y?.role===`admin`,{pages:D,objects:O}=f(),{app:k}=S(),A=m(),[j,P]=(0,M.useState)(0),F=w(D,t,k?._packageId);if(!F)return(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(g,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(_,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(h,{children:e(`empty.pageNotFound`)}),(0,N.jsx)(b,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})});let L=Object.fromEntries(n.entries()),R=d.pathname.match(/\/apps\/([^/]+)/)?.[1],z=x&&!!R&&!!t;return(0,N.jsx)(I,{dataSource:A,objects:O,onRefresh:()=>P(e=>e+1),children:(0,N.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,N.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[z&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{z&&l(`/apps/${R}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,N.jsx)(v,{className:`h-3.5 w-3.5`})}),F.interfaceConfig?.source?(0,N.jsx)(E,{page:F},j):(0,N.jsx)(u,{schema:{...F,type:F.type||`page`,context:{...F.context,params:L,refreshKey:j}}},j)]}),(0,N.jsx)(T,{open:o,sections:[{title:`Page Configuration`,data:F}]})]})})}export{F as n,L as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{f as r,o as i}from"./infrastructure-ckitl7Ev.js";import{$n as a,Aa as o,Jn as s,Pr as c,Sr as l,Xn as u,Yn as d,Zn as f,_s as p,b as m,er as h,hr as g,hs as _,ir as v,ja as y,jr as b,nn as x,nr as S,on as C,qn as w,rr as T,tr as E}from"./ui-components-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{f as r,o as i}from"./infrastructure-ckitl7Ev.js";import{$n as a,Aa as o,Jn as s,Pr as c,Sr as l,Xn as u,Yn as d,Zn as f,_s as p,b as m,er as h,hr as g,hs as _,ir as v,ja as y,jr as b,nn as x,nr as S,on as C,qn as w,rr as T,tr as E}from"./ui-components-D7IOmcqZ.js";var D=e(t(),1),O=n();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:o,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=m(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,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:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(w,{children:(0,O.jsxs)(s,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(h,{className:`h-16 w-16`,children:[(0,O.jsx)(S,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(E,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(a,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{await t({image:(await M(n)).url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(g,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(y,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(c,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(g,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(l,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(T,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(p,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:H})]})]})}),(0,O.jsxs)(w,{children:[(0,O.jsxs)(u,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(b,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(f,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(d,{children:`Update your name and view account details`})]}),(0,O.jsx)(s,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(T,{variant:`destructive`,children:[(0,O.jsx)(p,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:L})]}),F&&(0,O.jsxs)(T,{children:[(0,O.jsx)(_,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(v,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(C,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(x,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(C,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(x,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(C,{children:`Role`}),(0,O.jsx)(x,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(g,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:o,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[a,c]=(0,D.useState)(null),[l,m]=(0,D.useState)(``),[h,y]=(0,D.useState)(``),[b,S]=(0,D.useState)(``),[E,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||c(t)}).catch(()=>{e||c(!1)}),()=>{e=!0}},[n]);let P=()=>{m(``),y(``),S(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),h.length<8){j(`Password must be at least 8 characters`);return}if(h!==b){j(`Passwords do not match`);return}k(!0);try{if(a){if(!l){j(`Enter your current password`),k(!1);return}await e(l,h),N(`Password changed.`)}else await t(h),N(`Local password set. You can now sign in with email and password on this environment.`),c(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=a===null;return(0,O.jsxs)(w,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(u,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(f,{className:`text-base sm:text-lg`,children:a?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(d,{children:a?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(s,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[a&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(C,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(x,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:l,onChange:e=>m(e.target.value),disabled:E||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(C,{htmlFor:`new-password`,children:a?`New password`:`Password`}),(0,O.jsx)(x,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:h,onChange:e=>y(e.target.value),disabled:E||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(C,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(x,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:b,onChange:e=>S(e.target.value),disabled:E||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(T,{variant:`destructive`,children:[(0,O.jsx)(p,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:A})]}),M&&(0,O.jsxs)(T,{children:[(0,O.jsx)(_,{className:`h-4 w-4`}),(0,O.jsx)(v,{children:M})]}),(0,O.jsx)(g,{type:`submit`,disabled:E||I,className:`w-full sm:w-auto`,children:E?`Saving…`:a?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-D7UWfRl4.js";import{$n as i,Bn as a,Fo as o,Hi as ee,Hn as s,Ia as te,Jn as ne,Jo as re,Li as ie,Ln as c,Pi as ae,Qo as oe,Rn as l,Vn as u,Xn as se,Yn as ce,Zn as le,bi as ue,ct as d,dt as f,hr as p,lt as m,nn as h,on as g,ot as de,qn as fe,st as pe,ut as me,zn as _}from"./ui-components-Clv7N77v.js";import{r as v}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-BjfDho4T.js";var y=e(t(),1),b=n();function he(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function S(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[S,ge]=(0,y.useState)([]),[C,w]=(0,y.useState)(!0),[T,E]=(0,y.useState)(null),[_e,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(!1),[ve,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(``),[z,B]=(0,y.useState)(`thank-you`),[V,H]=(0,y.useState)(``),[U,W]=(0,y.useState)(``),[G,K]=(0,y.useState)(``),[q,J]=(0,y.useState)(!1),Y=async()=>{if(!e?.meta?.getItems){E(`meta.getItems is not available on this client`),w(!1);return}w(!0),E(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=he(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),ge(a)}catch(e){E(e?.message??String(e))}finally{w(!1)}};(0,y.useEffect)(()=>{Y()},[]);let X=typeof window<`u`?window.location.origin:``,Z=e=>`${X}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!O||!A)return;let t=S.find(e=>e.name===O);if(!t)return;let n=x(A);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};N(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),D(!1),k(``),j(``),await Y()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{N(!1)}},Se=e=>{I(e),R(e.slug);let t=e.spec?.submitBehavior;B(t?.kind??`thank-you`),H(t?.title??``),W(t?.message??``),K(t?.url??``),P(!0)},Ce=async()=>{if(!F)return;let t=x(L);if(!t){v.error(`Invalid slug`);return}let n;switch(z){case`thank-you`:n={kind:`thank-you`},V&&(n.title=V),U&&(n.message=U);break;case`redirect`:if(!G){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:G};break;case`continue`:case`next-record`:n={kind:z};break}let r={...F.spec,sharing:{...F.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};J(!0);try{await e.meta.saveItem(`view`,F.name,r),v.success(`Saved ${F.name}`),P(!1),I(null),await Y()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{J(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(fe,{children:[(0,b.jsxs)(se,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(le,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ie,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ce,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(p,{variant:`default`,size:`sm`,onClick:()=>D(!0),disabled:S.length===0,title:S.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(ee,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(p,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(ae,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(ne,{children:[T&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:T}),!C&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(de,{children:[(0,b.jsx)(me,{children:(0,b.jsxs)(f,{children:[(0,b.jsx)(m,{children:`Name`}),(0,b.jsx)(m,{children:`Object`}),(0,b.jsx)(m,{children:`Slug`}),(0,b.jsx)(m,{children:`Public URL`}),(0,b.jsx)(m,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(pe,{children:t.map(e=>{let t=Z(e.slug);return(0,b.jsxs)(f,{children:[(0,b.jsx)(d,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(d,{children:e.object?(0,b.jsx)(i,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(d,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(d,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(o,{className:`h-3 w-3`})]})}),(0,b.jsx)(d,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,b.jsx)(oe,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(ue,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(c,{open:_e,onOpenChange:D,children:(0,b.jsxs)(l,{className:`sm:max-w-md`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(s,{children:`Publish a FormView`}),(0,b.jsxs)(_,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:O,onChange:e=>k(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),S.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(h,{id:`publish-slug`,placeholder:`contact-us`,value:A,onChange:e=>j(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(a,{children:[(0,b.jsx)(p,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(p,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(c,{open:ve,onOpenChange:P,children:(0,b.jsxs)(l,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(s,{children:F?`Edit ${F.label??F.name}`:`Edit form`}),(0,b.jsx)(_,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(h,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:z,onChange:e=>B(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),z===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(h,{id:`edit-tytitle`,placeholder:`Thanks!`,value:V,onChange:e=>H(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(h,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:U,onChange:e=>W(e.target.value)})]})]}),z===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(h,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(a,{children:[(0,b.jsx)(p,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(p,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-BSpP7C0B.js";import{$n as i,Bn as a,Fo as o,Hi as ee,Hn as s,Ia as te,Jn as ne,Jo as re,Li as ie,Ln as c,Pi as ae,Qo as oe,Rn as l,Vn as u,Xn as se,Yn as ce,Zn as le,bi as ue,ct as d,dt as f,hr as p,lt as m,nn as h,on as g,ot as de,qn as fe,st as pe,ut as me,zn as _}from"./ui-components-D7IOmcqZ.js";import{r as v}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-QQUFI17s.js";var y=e(t(),1),b=n();function he(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function S(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[S,ge]=(0,y.useState)([]),[C,w]=(0,y.useState)(!0),[T,E]=(0,y.useState)(null),[_e,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(!1),[ve,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(``),[z,B]=(0,y.useState)(`thank-you`),[V,H]=(0,y.useState)(``),[U,W]=(0,y.useState)(``),[G,K]=(0,y.useState)(``),[q,J]=(0,y.useState)(!1),Y=async()=>{if(!e?.meta?.getItems){E(`meta.getItems is not available on this client`),w(!1);return}w(!0),E(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=he(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),ge(a)}catch(e){E(e?.message??String(e))}finally{w(!1)}};(0,y.useEffect)(()=>{Y()},[]);let X=typeof window<`u`?window.location.origin:``,Z=e=>`${X}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!O||!A)return;let t=S.find(e=>e.name===O);if(!t)return;let n=x(A);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};N(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),D(!1),k(``),j(``),await Y()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{N(!1)}},Se=e=>{I(e),R(e.slug);let t=e.spec?.submitBehavior;B(t?.kind??`thank-you`),H(t?.title??``),W(t?.message??``),K(t?.url??``),P(!0)},Ce=async()=>{if(!F)return;let t=x(L);if(!t){v.error(`Invalid slug`);return}let n;switch(z){case`thank-you`:n={kind:`thank-you`},V&&(n.title=V),U&&(n.message=U);break;case`redirect`:if(!G){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:G};break;case`continue`:case`next-record`:n={kind:z};break}let r={...F.spec,sharing:{...F.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};J(!0);try{await e.meta.saveItem(`view`,F.name,r),v.success(`Saved ${F.name}`),P(!1),I(null),await Y()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{J(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(fe,{children:[(0,b.jsxs)(se,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(le,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ie,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ce,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(p,{variant:`default`,size:`sm`,onClick:()=>D(!0),disabled:S.length===0,title:S.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(ee,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(p,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(ae,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(ne,{children:[T&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:T}),!C&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(de,{children:[(0,b.jsx)(me,{children:(0,b.jsxs)(f,{children:[(0,b.jsx)(m,{children:`Name`}),(0,b.jsx)(m,{children:`Object`}),(0,b.jsx)(m,{children:`Slug`}),(0,b.jsx)(m,{children:`Public URL`}),(0,b.jsx)(m,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(pe,{children:t.map(e=>{let t=Z(e.slug);return(0,b.jsxs)(f,{children:[(0,b.jsx)(d,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(d,{children:e.object?(0,b.jsx)(i,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(d,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(d,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(o,{className:`h-3 w-3`})]})}),(0,b.jsx)(d,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,b.jsx)(oe,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(ue,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(c,{open:_e,onOpenChange:D,children:(0,b.jsxs)(l,{className:`sm:max-w-md`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(s,{children:`Publish a FormView`}),(0,b.jsxs)(_,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:O,onChange:e=>k(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),S.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(h,{id:`publish-slug`,placeholder:`contact-us`,value:A,onChange:e=>j(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(a,{children:[(0,b.jsx)(p,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(p,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(c,{open:ve,onOpenChange:P,children:(0,b.jsxs)(l,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(s,{children:F?`Edit ${F.label??F.name}`:`Edit form`}),(0,b.jsx)(_,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(h,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:z,onChange:e=>B(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),z===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(h,{id:`edit-tytitle`,placeholder:`Thanks!`,value:V,onChange:e=>H(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(h,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:U,onChange:e=>W(e.target.value)})]})]}),z===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(h,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(a,{children:[(0,b.jsx)(p,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(p,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
|