@objectstack/console 12.4.0 → 12.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/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-DYYVhErE.js → AdapterProvider-qwVfmAEk.js} +1 -1
- package/dist/assets/{ApiConsolePage-DqCLFtg6.js → ApiConsolePage-V6XcLsX4.js} +1 -1
- package/dist/assets/{AppDocsIndex-ChTjYsgs.js → AppDocsIndex-C4IIeN6V.js} +1 -1
- package/dist/assets/{AppManagementPage-CpBtMYk7.js → AppManagementPage-WCLo2V17.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-BtSnKZ5C.js → ConsoleFloatingChatbot-mf-pVd3G.js} +1 -1
- package/dist/assets/{DashboardView-DTeb8b6a.js → DashboardView-CPFt6TBZ.js} +1 -1
- package/dist/assets/{DashboardWidgetInspector-CUJFDeER.js → DashboardWidgetInspector-DknOds9r.js} +1 -1
- package/dist/assets/{FlowRunsPage-BCTyVNQV.js → FlowRunsPage-QMVLQvu7.js} +1 -1
- package/dist/assets/{InterfaceListPage-CaG6oJ3-.js → InterfaceListPage-Dbt7lZbl.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-CxoOdisY.js → MarketplacePackagePage-CiRyU-vK.js} +1 -1
- package/dist/assets/{MetadataProvider-BpQl3Bw2.js → MetadataProvider-DKJsxrNu.js} +1 -1
- package/dist/assets/{ObjectDataPage-CnMdpBNe.js → ObjectDataPage-CAJf6Pu3.js} +1 -1
- package/dist/assets/{PageView-Ckvi7QO6.js → PageView-GYrk78oW.js} +1 -1
- package/dist/assets/{PublicFormsPage-xWq9jZzJ.js → PublicFormsPage-DmpEEcq4.js} +1 -1
- package/dist/assets/{RecordFormPage-DTyNzewM.js → RecordFormPage-DadWkJyX.js} +1 -1
- package/dist/assets/ReportDefaultInspector-CJGXWwWN.js +11 -0
- package/dist/assets/{ReportView-CHBbT7mP.js → ReportView-CIZjxMSJ.js} +1 -1
- package/dist/assets/{SearchResultsPage-BIuFjDoa.js → SearchResultsPage-BPDjxMw8.js} +1 -1
- package/dist/assets/{SystemHubPage-f4hYqDoI.js → SystemHubPage-2aGKeHcn.js} +1 -1
- package/dist/assets/data-adapter-Bm8GGtft.js +7 -0
- package/dist/assets/index-BXgUF5nO.css +2 -0
- package/dist/assets/{index-TdJi7kFM.js → index-PrzZHiAk.js} +1 -1
- package/dist/assets/{metadata-admin-DJAg5WLs.js → metadata-admin-CleGXds3.js} +1 -1
- package/dist/assets/src-BBieSqPB.js +16 -0
- package/dist/assets/{useMetadata-Eb5o6ihl.js → useMetadata-Ily0JuNR.js} +1 -1
- package/dist/assets/{useOpenRecordList-DIo7M1au.js → useOpenRecordList-tyj2_1bm.js} +1 -1
- package/dist/assets/{useReconcileOnError-4is_Tic6.js → useReconcileOnError-_XnUvYJA.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/ReportDefaultInspector-BA-D9th_.js +0 -11
- package/dist/assets/data-adapter-DLOPVTZ2.js +0 -7
- package/dist/assets/index-B-sF8xtC.css +0 -2
- package/dist/assets/src-6xqJEeiC.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{I as a}from"./framework-B3O15Lsq.js";import{n as o}from"./data-adapter-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{I as a}from"./framework-B3O15Lsq.js";import{n as o}from"./data-adapter-Bm8GGtft.js";import{i as s}from"./plugin-form-FeZEoC2R.js";import{a as c,o as l}from"./assistantBus-BFk4fCbM.js";var u=e(i(),1),d=r(),f=(0,u.createContext)(!1),p=`preview`,m=`draft`;function h(e){return new URLSearchParams(e).get(p)===m}var g=!1;function _(){g=!0}function v({force:e,children:r}){let i=t(),a=n(),o=(0,u.useMemo)(()=>h(i.search),[i.search]),[s,c]=(0,u.useState)(o);return(0,u.useEffect)(()=>{if(o){c(!0),g=!1;return}if(!s)return;if(g){g=!1,c(!1);return}let e=new URLSearchParams(i.search);e.set(p,m),a(`${i.pathname}?${e.toString()}${i.hash}`,{replace:!0})},[o,s,i.pathname,i.search,i.hash,a]),(0,d.jsx)(f.Provider,{value:e??(o||s),children:r})}function y(){return(0,u.useContext)(f)}var b=300*1e3,x=[`app`,`view`],S={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},C=`objectui:metadata:`;function w(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var T=w();function E(...e){T&&console.debug(`[MetadataProvider]`,...e)}function D(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function O(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function k(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function A(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function j(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)A(e)&&r.add(e.object);for(let e of t){if(A(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 M(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 N(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function P(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(C+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function F(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(C+e,JSON.stringify(t))}catch{}}function I({children:e,adapter:t,ttlMs:n=b}){let r=(0,u.useRef)(new Map),i=(0,u.useRef)(new Map),s=(0,u.useRef)(t);s.current=t;let f=y(),p=(0,u.useMemo)(()=>f?new o({baseUrl:``,previewDrafts:!0}):null,[f]),m=(0,u.useRef)(p);m.current=p;let[h,g]=(0,u.useState)(0),_=(0,u.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>g(e=>e+1)):Promise.resolve().then(()=>g(e=>e+1))},[]);(0,u.useEffect)(()=>{r.current.clear(),i.current.clear(),_()},[f,_]);let v=(0,u.useCallback)(e=>{let t=r.current.get(e);return t||(t=N(),r.current.set(e,t)),t},[]),C=(0,u.useCallback)(e=>{let t=v(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return E(`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=m.current,a=(i?i.list(e):s.current.getClient().meta.getItems(e)).then(n=>{let a=D(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)k(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&F(e,a),E(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),_(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,E(`fetch failed type=${e}`,r),_(),[]});return t.promise=a,a},[_,v,n]),w=(0,u.useCallback)((e,t)=>{let n=v(e);if(n.byName.has(t))return E(`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=m.current,l=(c?c.get(e,t):s.current.getClient().meta.getItem(e,t)).then(i=>{let a=O(i);return a&&n.byName.set(t,a),E(`fetched item type=${e} name=${t} in ${Date.now()-o}ms`),r.delete(t),a}).catch(n=>(r.delete(t),E(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[v]),T=(0,u.useCallback)(async e=>{if(e){let t=v(e);t.fetchedAt=0,t.byName.clear(),await C(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(),C(e)}))},[C,v]),A=(0,u.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),E(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,E(`invalidated type=${e}`)),_())},[_]);(0,u.useEffect)(()=>{if(f)return c(({type:e})=>{A(e)})},[f,A]),(0,u.useEffect)(()=>l(()=>{try{s.current?.clearCache?.()}catch{}T()}),[T]);let[I,L]=(0,u.useState)(!0),[R,z]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=!1,t=f?null:P(`app`);if(t){let e=v(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)k(n)&&e.byName.set(n.name,n);_(),L(!1)}return(async()=>{for(let t of x)try{await C(t),e||z(null)}catch(t){e||z(t instanceof Error?t:Error(String(t)))}e||L(!1)})(),()=>{e=!0}},[t,C,v,_,f]);let B=(0,u.useMemo)(()=>{let e=e=>{let t=v(e);return t.status===`idle`&&C(e),t.items};return{apps:v(`app`).items,get objects(){let t=e(S.objects),n=e(`view`);return M(n.length?j(t,n):t)},get dashboards(){return e(S.dashboards)},get reports(){return e(S.reports)},get pages(){return e(S.pages)},loading:I,error:R??v(`app`).error,refresh:T,invalidate:A,ensureType:C,getItem:w,getItemsByType:t=>e(t),getTypeStatus:e=>v(e).status}},[h,I,R,C,w,v,T,A]);return(0,d.jsx)(a.Provider,{value:B,children:e})}export{y as a,_ as i,p as n,v as r,I as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as ee,f as o,n as s,t as c}from"./infrastructure-Bcx6-8du.js";import{l,q as u}from"./framework-B3O15Lsq.js";import{Fc as te,G as d,J as f,Or as ne,Ra as re,V as ie,W as p,Yi as ae,ji as oe,ns as m,xr as h}from"./ui-components-rkvkkTxO.js";import{t as se}from"./RecordDetailView-CzR6BAUv.js";import{r as g}from"./useMetadata-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as ee,f as o,n as s,t as c}from"./infrastructure-Bcx6-8du.js";import{l,q as u}from"./framework-B3O15Lsq.js";import{Fc as te,G as d,J as f,Or as ne,Ra as re,V as ie,W as p,Yi as ae,ji as oe,ns as m,xr as h}from"./ui-components-rkvkkTxO.js";import{t as se}from"./RecordDetailView-CzR6BAUv.js";import{r as g}from"./useMetadata-Ily0JuNR.js";import{t as _}from"./getIcon-B5xaQx5N.js";import{n as v,t as y}from"./CreateViewDialog-CMNLzv6j.js";import{a as b,i as x,n as ce,o as le,r as ue,s as de}from"./InterfaceListPage-Dbt7lZbl.js";import{l as fe}from"./plugins-views-CibWNUsP.js";import{t as pe}from"./runtime-metadata-persistence-D1KKivGr.js";var S=e(a(),1),C=i();function w(e){let t=[];return e.forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.push([r[1],`=`,e])}),t}var T=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),E=4;function D({dataSource:e,objects:i}){let{appName:a,objectName:D}=r(),{t:O}=l(),{objectLabel:k,fieldLabel:A}=te(),j=t(),[M,N]=n(),{can:P}=s(),{canRead:F}=c(D??``),{user:I}=o(),L=ee(),R=g(),[z,B]=S.useState(!1),V=S.useMemo(()=>(i||[]).find(e=>e.name===D),[i,D]),[me]=S.useState(()=>de(new URLSearchParams(window.location.search))),he=S.useCallback(e=>{N(t=>le(t,e),{replace:!0})},[N]),H=Array.from(M.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),U=S.useMemo(()=>{let e=w(new URLSearchParams(H)),t=e.filter(([e])=>F(e));if(t.length<e.length){let t=e.filter(([e])=>!F(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return t.map(([e,t,n])=>n===`{current_user_id}`?[e,t,I?.id??n]:[e,t,n])},[H,F,I?.id]),ge=S.useCallback(e=>{N(t=>{let n=new URLSearchParams(t);return n.delete(`filter[${e}]`),n})},[N]),W=S.useMemo(()=>ue(V).filter(e=>F(e)),[V,F]),G=S.useMemo(()=>{let e=V?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&T.has(t.type)&&F(e)).slice(0,E).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[V,F]),K=S.useCallback(e=>`/apps/${a}/${D}/record/${encodeURIComponent(String(e))}`,[a,D]),q=u({navigation:{mode:`drawer`},objectName:D??``,onNavigate:e=>j(K(e))}),J=M.get(`recordId`),_e=S.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&N(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,N]),ve=S.useCallback(()=>{N(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[N]);S.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=S.useMemo(()=>b(V),[V]),X=S.useMemo(()=>ce(V),[V]),Z=S.useMemo(()=>x(V),[V]),Q=S.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=S.useMemo(()=>{if(V)return{type:`list-view`,objectName:V.name,viewType:`grid`,fields:W,...U.length?{filters:U}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,showSearch:!0,showSort:!0,showFilters:!0,showGroup:!0,showHideFields:!0,showDensity:!0,showRecordCount:!0}},[V,W,U,Y,X,Z,G,Q]),ye=S.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...U.length?{filter:U}:{}},n=await pe(`view`,String(e?.name??e?.id??``),t,{metadataClient:R});n&&j(`../view/${n}`,{relative:`path`})}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,U,R,j]);return V?P(V.name,`read`)?(0,C.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,C.jsx)(`div`,{className:`hidden sm:block`,children:(0,C.jsx)(v,{title:(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:k(V)}),(0,C.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:O(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:O(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:S.createElement(_(V?.icon),{className:`h-4 w-4`}),actions:(0,C.jsxs)(C.Fragment,{children:[P(V.name,`create`)&&(0,C.jsxs)(h,{size:`sm`,onClick:()=>j(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,C.jsx)(ae,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectView.new`)})]}),L&&(0,C.jsxs)(h,{size:`sm`,variant:`outline`,onClick:()=>B(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,C.jsx)(oe,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),U.length>0&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),U.map(([e,,t])=>(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,C.jsx)(`span`,{className:`font-medium`,children:A(V.name,e,e)}),(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[`= `,String(t)]}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>ge(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":O(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,C.jsx)(ne,{className:`h-3 w-3`})})]},e))]}),(0,C.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,C.jsx)(fe,{schema:$,dataSource:e,userFilterSelections:me,onUserFilterSelectionsChange:he,onRowClick:_e})}),q.isOverlay&&(0,C.jsx)(ie,{...q,setIsOpen:e=>{e||ve()},title:k(V),children:t=>(0,C.jsx)(se,{objectNameOverride:V.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),L&&(0,C.jsx)(y,{open:z,onOpenChange:B,onCreate:ye,objectDef:V})]}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(re,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(f,{children:O(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,C.jsx)(d,{children:O(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(f,{children:O(`console.objectView.objectNotFound`)}),(0,C.jsx)(d,{children:O(`console.objectView.objectNotFoundDescription`,{objectName:D})})]})})}export{D as ObjectDataPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BGDDiZfJ.js";import{d as c,f as l,m as u,n as d}from"./infrastructure-Bcx6-8du.js";import{H as f,L as p,R as m,Y as h,b as g,l as _}from"./framework-B3O15Lsq.js";import{B as v,Fc as y,Fo as b,G as x,J as S,W as C,_r as w,fr as T,gr as E,hr as D,mr as O,na as k,vr as A,xr as j,yr as M}from"./ui-components-rkvkkTxO.js";import{r as N}from"./vendor-ui-utils-BzQBRdq3.js";import"./MetadataProvider-BpQl3Bw2.js";import{r as P}from"./ExpressionProvider-ODpzkcN3.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-CzR6BAUv.js";import{n as F,r as I,t as L}from"./MetadataInspector-RvnQ-QOT.js";import{t as R}from"./InterfaceListPage-CaG6oJ3-.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(j,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(T,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(D,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(A,{children:[(0,B.jsx)(M,{children:r?.title}),(0,B.jsx)(E,{children:r?.message})]}),(0,B.jsxs)(w,{children:[(0,B.jsx)(O,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=l(),{systemPermissions:f}=d(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=y(),b=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),x=i||b?.name,S=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{S(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=re(e,{objectName:i||b?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),s=i||b?.name,c=o.map(e=>({...e,label:h(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(s,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:c,title:t?.label||t?.title,description:v(s,t?.name,t?.description),resolve:r})}),[i,b,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>u(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&S(),{success:!0,data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||x,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&S(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,x,W,c,S,G]),q=(0,z.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 n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||x,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 j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&S(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,x,S]),J=(0,z.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 n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}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||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&S(),{success:!0}}let i=e.objectName||x||`global`,a=await W(`/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{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&S();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||N(`浏览器拦截了弹窗 / 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{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,x,S]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),S()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=_(),{pageName:t}=a(),[o]=i(),{showDebug:s}=F(),l=r(),u=n(),d=c(),{pages:f,objects:g,getTypeStatus:y}=m(),{app:w}=P(),T=p(),[E,D]=(0,z.useState)(0),O=I(f,t,w?._packageId);if(!O){let n=y?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(v,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(C,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(b,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(S,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(x,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:T,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/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,B.jsx)(k,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(R,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(h,{schema:{...O,type:O.type||`page`,context:{...O.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(L,{open:s,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BGDDiZfJ.js";import{d as c,f as l,m as u,n as d}from"./infrastructure-Bcx6-8du.js";import{H as f,L as p,R as m,Y as h,b as g,l as _}from"./framework-B3O15Lsq.js";import{B as v,Fc as y,Fo as b,G as x,J as S,W as C,_r as w,fr as T,gr as E,hr as D,mr as O,na as k,vr as A,xr as j,yr as M}from"./ui-components-rkvkkTxO.js";import{r as N}from"./vendor-ui-utils-BzQBRdq3.js";import"./MetadataProvider-DKJsxrNu.js";import{r as P}from"./ExpressionProvider-ODpzkcN3.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-CzR6BAUv.js";import{n as F,r as I,t as L}from"./MetadataInspector-RvnQ-QOT.js";import{t as R}from"./InterfaceListPage-Dbt7lZbl.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(j,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(T,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(D,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(A,{children:[(0,B.jsx)(M,{children:r?.title}),(0,B.jsx)(E,{children:r?.message})]}),(0,B.jsxs)(w,{children:[(0,B.jsx)(O,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=l(),{systemPermissions:f}=d(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=y(),b=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),x=i||b?.name,S=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{S(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=re(e,{objectName:i||b?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),s=i||b?.name,c=o.map(e=>({...e,label:h(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(s,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:c,title:t?.label||t?.title,description:v(s,t?.name,t?.description),resolve:r})}),[i,b,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>u(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&S(),{success:!0,data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||x,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&S(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,x,W,c,S,G]),q=(0,z.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 n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||x,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 j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&S(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,x,S]),J=(0,z.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 n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}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||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&S(),{success:!0}}let i=e.objectName||x||`global`,a=await W(`/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{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&S();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||N(`浏览器拦截了弹窗 / 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{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,x,S]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),S()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=_(),{pageName:t}=a(),[o]=i(),{showDebug:s}=F(),l=r(),u=n(),d=c(),{pages:f,objects:g,getTypeStatus:y}=m(),{app:w}=P(),T=p(),[E,D]=(0,z.useState)(0),O=I(f,t,w?._packageId);if(!O){let n=y?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(v,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(C,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(b,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(S,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(x,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:T,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/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,B.jsx)(k,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(R,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(h,{schema:{...O,type:O.type||`page`,context:{...O.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(L,{open:s,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{L as r}from"./framework-B3O15Lsq.js";import{$n as i,Ei as a,Gn as o,Jn as s,Jo as ee,Ka as te,Kn as c,Un as l,Vi as ne,Wi as re,Wn as u,Yi as ie,_t as d,ar as ae,cs as oe,dn as f,ds as se,er as ce,ft as le,gt as ue,ht as p,mt as m,nr as de,pt as fe,qn as h,rr as pe,sn as g,tr as me,xr as _}from"./ui-components-rkvkkTxO.js";import{r as v}from"./vendor-ui-utils-BzQBRdq3.js";import"./src-6xqJEeiC.js";var y=e(n(),1),b=t();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 ye=typeof window<`u`?window.location.origin:``,X=e=>`${ye}/console/f/${e}`,Z=e=>`<iframe src="${X(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${X(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,n=t?.kind??`thank-you`;B(n),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)(i,{children:[(0,b.jsxs)(de,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(pe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(re,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(me,{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)(_,{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)(ie,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(_,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(ne,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(ce,{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)(le,{children:[(0,b.jsx)(ue,{children:(0,b.jsxs)(d,{children:[(0,b.jsx)(p,{children:`Name`}),(0,b.jsx)(p,{children:`Object`}),(0,b.jsx)(p,{children:`Slug`}),(0,b.jsx)(p,{children:`Public URL`}),(0,b.jsx)(p,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:t.map(e=>{let t=X(e.slug);return(0,b.jsxs)(d,{children:[(0,b.jsx)(m,{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)(m,{children:e.object?(0,b.jsx)(ae,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(m,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(m,{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)(ee,{className:`h-3 w-3`})]})}),(0,b.jsx)(m,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(_,{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)(_,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,Z(e.slug)),children:(0,b.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(oe,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(a,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(l,{open:_e,onOpenChange:D,children:(0,b.jsxs)(u,{className:`sm:max-w-md`,children:[(0,b.jsxs)(h,{children:[(0,b.jsx)(s,{children:`Publish a FormView`}),(0,b.jsxs)(o,{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)(f,{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)(f,{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)(g,{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)(c,{children:[(0,b.jsx)(_,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(_,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(l,{open:ve,onOpenChange:P,children:(0,b.jsxs)(u,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(h,{children:[(0,b.jsx)(s,{children:F?`Edit ${F.label??F.name}`:`Edit form`}),(0,b.jsx)(o,{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)(f,{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)(g,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{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)(f,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(g,{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)(f,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(g,{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)(f,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(g,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(c,{children:[(0,b.jsx)(_,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(_,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{L as r}from"./framework-B3O15Lsq.js";import{$n as i,Ei as a,Gn as o,Jn as s,Jo as ee,Ka as te,Kn as c,Un as l,Vi as ne,Wi as re,Wn as u,Yi as ie,_t as d,ar as ae,cs as oe,dn as f,ds as se,er as ce,ft as le,gt as ue,ht as p,mt as m,nr as de,pt as fe,qn as h,rr as pe,sn as g,tr as me,xr as _}from"./ui-components-rkvkkTxO.js";import{r as v}from"./vendor-ui-utils-BzQBRdq3.js";import"./src-BBieSqPB.js";var y=e(n(),1),b=t();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 ye=typeof window<`u`?window.location.origin:``,X=e=>`${ye}/console/f/${e}`,Z=e=>`<iframe src="${X(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${X(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,n=t?.kind??`thank-you`;B(n),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)(i,{children:[(0,b.jsxs)(de,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(pe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(re,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(me,{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)(_,{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)(ie,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(_,{variant:`outline`,size:`sm`,onClick:Y,disabled:C,children:[(0,b.jsx)(ne,{className:`h-3.5 w-3.5 ${C?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(ce,{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)(le,{children:[(0,b.jsx)(ue,{children:(0,b.jsxs)(d,{children:[(0,b.jsx)(p,{children:`Name`}),(0,b.jsx)(p,{children:`Object`}),(0,b.jsx)(p,{children:`Slug`}),(0,b.jsx)(p,{children:`Public URL`}),(0,b.jsx)(p,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:t.map(e=>{let t=X(e.slug);return(0,b.jsxs)(d,{children:[(0,b.jsx)(m,{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)(m,{children:e.object?(0,b.jsx)(ae,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(m,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(m,{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)(ee,{className:`h-3 w-3`})]})}),(0,b.jsx)(m,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(_,{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)(_,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,Z(e.slug)),children:(0,b.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(oe,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(_,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(a,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(l,{open:_e,onOpenChange:D,children:(0,b.jsxs)(u,{className:`sm:max-w-md`,children:[(0,b.jsxs)(h,{children:[(0,b.jsx)(s,{children:`Publish a FormView`}),(0,b.jsxs)(o,{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)(f,{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)(f,{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)(g,{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)(c,{children:[(0,b.jsx)(_,{variant:`ghost`,onClick:()=>D(!1),disabled:M,children:`Cancel`}),(0,b.jsx)(_,{onClick:xe,disabled:M||!O||!A,children:M?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(l,{open:ve,onOpenChange:P,children:(0,b.jsxs)(u,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(h,{children:[(0,b.jsx)(s,{children:F?`Edit ${F.label??F.name}`:`Edit form`}),(0,b.jsx)(o,{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)(f,{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)(g,{id:`edit-slug`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{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)(f,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(g,{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)(f,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(g,{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)(f,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(g,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:G,onChange:e=>K(e.target.value)})]})]}),(0,b.jsxs)(c,{children:[(0,b.jsx)(_,{variant:`ghost`,onClick:()=>P(!1),disabled:q,children:`Cancel`}),(0,b.jsx)(_,{onClick:Ce,disabled:q||!L,children:q?`Saving…`:`Save`})]})]})})]})}export{S as PublicFormsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{a as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BGDDiZfJ.js";import{f as c}from"./infrastructure-Bcx6-8du.js";import{L as l,R as u,Vt as d,l as f}from"./framework-B3O15Lsq.js";import{Cc as p,Fc as m,G as h,J as g,W as _,ns as v,xr as y}from"./ui-components-rkvkkTxO.js";import{r as b}from"./vendor-ui-utils-BzQBRdq3.js";import"./AdapterProvider-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{a as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BGDDiZfJ.js";import{f as c}from"./infrastructure-Bcx6-8du.js";import{L as l,R as u,Vt as d,l as f}from"./framework-B3O15Lsq.js";import{Cc as p,Fc as m,G as h,J as g,W as _,ns as v,xr as y}from"./ui-components-rkvkkTxO.js";import{r as b}from"./vendor-ui-utils-BzQBRdq3.js";import"./AdapterProvider-qwVfmAEk.js";import{t as x}from"./plugin-form-FeZEoC2R.js";import"./MetadataProvider-DKJsxrNu.js";import{n as S,t as C}from"./ExpressionProvider-ODpzkcN3.js";import{t as w}from"./ManagedByBadge-BGSB7vGi.js";import{t as T}from"./skeletons-CzC0fiXD.js";var E=t({RecordFormPage:()=>k}),D=e(s(),1),O=o();function k({mode:e}){let{appName:t,objectName:o,recordId:s}=a(),E=r(),[k]=i(),A=l(),{objects:j,loading:M}=u(),{t:N}=f(),{objectLabel:P}=m(),{user:F,getAuthConfig:I}=c(),[L,R]=(0,D.useState)({});(0,D.useEffect)(()=>{let e=!1;return I().then(t=>{e||R(t?.features??{})}).catch(()=>{}),()=>{e=!0}},[I]);let z=(0,D.useMemo)(()=>{if(e!==`create`)return;let t=[];for(let[e,n]of k.entries())e&&n&&t.push([e,n]);return t.length>0?Object.fromEntries(t):void 0},[e,k.toString()]),B=(0,D.useMemo)(()=>j.find(e=>e.name===o),[j,o]),V=`/apps/${t}`,H=`${V}/${o}`,U=e===`edit`&&s?`${V}/${o}/record/${encodeURIComponent(s)}`:H,W=(0,D.useCallback)(()=>{typeof window<`u`&&window.history.length>1?E(-1):E(U,{replace:!0})},[E,U]),G=B?P(B):o??``,K=e===`create`?N(`form.createTitle`,{object:G,defaultValue:`New ${G}`}):N(`form.editTitle`,{object:G,defaultValue:`Edit ${G}`}),q=(0,D.useCallback)(()=>{b.success(e===`create`?N(`form.createSuccess`,{object:G,defaultValue:`${G} created successfully`}):N(`form.updateSuccess`,{object:G,defaultValue:`${G} updated successfully`})),W()},[e,N,G,W]),J=(0,D.useCallback)(()=>{W()},[W]),Y=(0,D.useMemo)(()=>F?{name:F.name,email:F.email,role:F.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},[F]),X=(0,D.useMemo)(()=>new d({user:Y,app:{name:t},data:{}}),[Y,t]),Z=(0,D.useMemo)(()=>B?.fields?Array.isArray(B.fields)?B.fields.filter(e=>typeof e==`string`?!0:S(e.visible,X)).map(e=>typeof e==`string`?e:e.name):Object.entries(B.fields).filter(([,e])=>S(e.visible,X)).map(([e])=>e):[],[B,X]);if(M)return(0,O.jsx)(T,{});if(!B)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,O.jsxs)(_,{children:[(0,O.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,O.jsx)(v,{className:`h-6 w-6 text-muted-foreground`})}),(0,O.jsx)(g,{children:N(`empty.objectNotFound`)}),(0,O.jsx)(h,{children:N(`empty.objectNotFoundDescription`,{name:o})}),(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsxs)(y,{variant:`outline`,onClick:()=>E(V),children:[(0,O.jsx)(p,{className:`mr-2 h-4 w-4`}),N(`empty.back`)]})})]})});let Q=B.form??B.formViews?.default??{},$=[`tabbed`,`wizard`,`split`].includes(Q.type)?Q.type:`simple`,ee=Array.isArray(Q.sections)&&Q.sections.length>0?{sections:Q.sections,defaultTab:Q.defaultTab,tabPosition:Q.tabPosition,allowSkip:Q.allowSkip,showStepIndicator:Q.showStepIndicator,splitDirection:Q.splitDirection,splitSize:Q.splitSize,splitResizable:Q.splitResizable}:{};return(0,O.jsx)(C,{user:Y,app:{name:t},data:{},features:L,children:(0,O.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,"data-testid":`record-form-page`,"data-mode":e,children:[(0,O.jsxs)(`header`,{className:`sticky top-0 z-10 flex items-center gap-3 border-b bg-background px-4 py-3 sm:px-6`,children:[(0,O.jsx)(y,{variant:`ghost`,size:`sm`,onClick:W,"data-testid":`record-form-page-back`,"aria-label":N(`common.back`,{defaultValue:`Back`}),children:(0,O.jsx)(p,{className:`h-4 w-4`})}),(0,O.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(n,{to:H,className:`hover:text-foreground transition-colors`,children:G}),(0,O.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,O.jsx)(`span`,{className:`text-foreground font-medium`,"data-testid":`record-form-page-title`,children:K}),(0,O.jsx)(w,{managedBy:B?.managedBy,className:`ml-1`})]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6`,children:(0,O.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,O.jsx)(x,{schema:{type:`object-form`,formType:$,...ee,objectName:B.name,mode:e,recordId:e===`edit`?s:void 0,...z&&{initialValues:z},title:K,description:e===`create`?N(`form.createDescription`,{object:G,defaultValue:`Create a new ${G}.`}):N(`form.editDescription`,{object:G,defaultValue:`Edit this ${G}.`}),layout:`vertical`,fields:Z,subforms:B.form?.subforms??B.formViews?.default?.subforms,onSuccess:q,onCancel:J,showSubmit:!0,showCancel:!0,submitText:N(`form.saveRecord`,{defaultValue:`Save`}),cancelText:N(`common.cancel`,{defaultValue:`Cancel`})},dataSource:A??void 0},`${e}:${o}:${s??`new`}`)})})]})})}export{E as t};
|