@objectstack/console 12.0.0 → 12.2.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-BIB-F0Qa.js → AdapterProvider-ChCHN6h2.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-CMVG4Uuj.js → AiPendingActionsPage-ClqCWFhX.js} +1 -1
- package/dist/assets/{ApiConsolePage-BpBKlVk6.js → ApiConsolePage-DpoLdaGP.js} +1 -1
- package/dist/assets/{AppDocsIndex-35urFMpk.js → AppDocsIndex-ZARAa4-6.js} +1 -1
- package/dist/assets/{AppManagementPage-Q8hLq3cQ.js → AppManagementPage-fv86i1EJ.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-Cjd1esAG.js → ApprovalsInboxPage-CXfOaS-0.js} +1 -1
- package/dist/assets/{AuditLogPage-C2lQmF3X.js → AuditLogPage-Dkoy1n_H.js} +1 -1
- package/dist/assets/{ComponentNavView-BuEXrmXR.js → ComponentNavView-BWQSnGEu.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-Dq3dsO2v.js +1 -0
- package/dist/assets/CreateViewDialog-C1CxZesL.js +1 -0
- package/dist/assets/DashboardView-BQG9YaAq.js +1 -0
- package/dist/assets/DashboardWidgetInspector-BpU5bimE.js +1 -0
- package/dist/assets/{DeveloperHubPage-DO4z3Sj9.js → DeveloperHubPage-BRCN0NLA.js} +1 -1
- package/dist/assets/{ExpressionProvider-BI-jCA0B.js → ExpressionProvider-abtwTBsH.js} +1 -1
- package/dist/assets/{FlowRunsPage-DVvg_WMt.js → FlowRunsPage-BgcLefs2.js} +1 -1
- package/dist/assets/{IntegrationsPage-kF55v0ix.js → IntegrationsPage-BCklDgeZ.js} +1 -1
- package/dist/assets/InterfaceListPage-BS-RPt4J.js +1 -0
- package/dist/assets/{ManagedByBadge-DtZfR2w_.js → ManagedByBadge-j3ZfnZvE.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-JR0ElPYV.js → MarketplaceAccessDenied-CEfnLa3I.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-c1qqM0m9.js → MarketplaceInstalledPage-CWQTjUgZ.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-CT5bU1QW.js → MarketplacePackagePage-Bfbul0CU.js} +1 -1
- package/dist/assets/{MarketplacePage-BkOByUub.js → MarketplacePage-OJnmguF6.js} +1 -1
- package/dist/assets/{MetadataInspector-FQJn-0mY.js → MetadataInspector-BhsHTd-v.js} +1 -1
- package/dist/assets/{MetadataProvider-DlGQbrYS.js → MetadataProvider-C6q8MMOb.js} +1 -1
- package/dist/assets/ObjectDataPage-BS6o8mYp.js +1 -0
- package/dist/assets/{PageView-BR-dytGp.js → PageView-C9oZgX_T.js} +1 -1
- package/dist/assets/{ProfilePage-BfNhQTic.js → ProfilePage-ITmWpb2R.js} +1 -1
- package/dist/assets/{PublicFormsPage-D5HXZ9gs.js → PublicFormsPage-sLkhcwEv.js} +1 -1
- package/dist/assets/RecordDetailView-DHsj44KH.js +9 -0
- package/dist/assets/{RecordFormPage-dOx4tkq3.js → RecordFormPage-BgcPlnXv.js} +1 -1
- package/dist/assets/ReportDefaultInspector-Cg2S1xbC.js +11 -0
- package/dist/assets/ReportView-BaP-JFjB.js +2 -0
- package/dist/assets/SearchResultsPage-BshI0Zmt.js +1 -0
- package/dist/assets/{SettingsHub-BIUh_NaE.js → SettingsHub-CfrSasWE.js} +1 -1
- package/dist/assets/SettingsView-C0tiT7Ro.js +1 -0
- package/dist/assets/{SystemHubPage-BbYZjpSv.js → SystemHubPage-4IOffD9p.js} +1 -1
- package/dist/assets/appRoute-CbCiASix.js +1 -0
- package/dist/assets/data-adapter-Cx47KDt0.js +7 -0
- package/dist/assets/framework-VeaoJc6L.js +36 -0
- package/dist/assets/getIcon-DWShaytS.js +1 -0
- package/dist/assets/{highlighted-body-OFNGDK62-CLYrkLJN.js → highlighted-body-OFNGDK62-BVT4Ceg6.js} +1 -1
- package/dist/assets/index-B0iXZd_j.css +2 -0
- package/dist/assets/index-lt4ddaZz.js +2 -0
- package/dist/assets/{infrastructure-BySW-NB0.js → infrastructure-BnbfcrX8.js} +1 -1
- package/dist/assets/{marketplaceApi-2fWjbQI7.js → marketplaceApi-BLyDDfGk.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-eYtP2Vcs.js +1 -0
- package/dist/assets/metadata-admin-Cy38fzV_.js +22 -0
- package/dist/assets/{plugin-calendar-DJ1vxgSA.js → plugin-calendar-2kTJ0fc1.js} +1 -1
- package/dist/assets/plugin-charts-CvFyMc_d.js +7 -0
- package/dist/assets/{plugin-chatbot-DCC-44Dt.js → plugin-chatbot-BRmlCuRw.js} +44 -44
- package/dist/assets/plugin-dashboard-4HCwV8-X.js +6 -0
- package/dist/assets/plugin-form-EGV_mlKM.js +1 -0
- package/dist/assets/{plugin-gantt-BJIjCj1A.js → plugin-gantt-Dhuw4hkx.js} +2 -2
- package/dist/assets/plugin-grid-CddzO4VP.js +8 -0
- package/dist/assets/{plugin-kanban-DhARoJCa.js → plugin-kanban-BTZHONsN.js} +1 -1
- package/dist/assets/plugin-map-Depmdrg-.js +1 -0
- package/dist/assets/{plugin-markdown-DXEq1goV.js → plugin-markdown-D3pwlK_U.js} +1 -1
- package/dist/assets/plugin-report-IVabarJG.js +59 -0
- package/dist/assets/{plugin-timeline-6gVRcvzs.js → plugin-timeline-DKuFVmA_.js} +1 -1
- package/dist/assets/{plugin-tree-_9p0xC9K.js → plugin-tree-C6CVZ7Om.js} +1 -1
- package/dist/assets/plugin-view-UIMlPguJ.js +1 -0
- package/dist/assets/plugins-views-BpBxqePX.js +4 -0
- package/dist/assets/recordFormNavigation-8nEYNxNo.js +1 -0
- package/dist/assets/runtime-metadata-persistence-D1KKivGr.js +1 -0
- package/dist/assets/{skeletons-C2aQsjPE.js → skeletons-CCSQqh_1.js} +1 -1
- package/dist/assets/{src-B4OzWw0f.js → src-CU1Z1Z_t.js} +1 -1
- package/dist/assets/src-DZBNpupP.js +15 -0
- package/dist/assets/{types-B0Soeu38.js → types-6GJ5R1iS.js} +1 -1
- package/dist/assets/ui-components-Pnfq_-xI.js +42 -0
- package/dist/assets/ui-layout-9b1em1pV.js +1 -0
- package/dist/assets/useMetadata-Ja6XpRRW.js +1 -0
- package/dist/assets/useOpenRecordList-B4pH3R6Y.js +1 -0
- package/dist/assets/useReconcileOnError-zJ0Ga5t1.js +1 -0
- package/dist/assets/{useRecordApprovals-B_jxSZvZ.js → useRecordApprovals-DXvdSyp8.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ConsoleFloatingChatbot-XMVIlmjf.js +0 -1
- package/dist/assets/DashboardView-cKnnhVZW.js +0 -1
- package/dist/assets/DashboardWidgetInspector-DQzulo-e.js +0 -1
- package/dist/assets/InterfaceListPage-CH9wtpOt.js +0 -1
- package/dist/assets/RecordDetailView-BUBX12o3.js +0 -9
- package/dist/assets/ReportDefaultInspector-DQlvnczB.js +0 -11
- package/dist/assets/ReportView-BoYtuwGU.js +0 -2
- package/dist/assets/SearchResultsPage-Dn6Lg7cm.js +0 -1
- package/dist/assets/SettingsView-iFSFGurq.js +0 -1
- package/dist/assets/appRoute-D5vwtoc_.js +0 -1
- package/dist/assets/data-adapter-BJMUjXWO.js +0 -7
- package/dist/assets/framework-Bn8ShCi0.js +0 -36
- package/dist/assets/index-BecTd5hZ.js +0 -2
- package/dist/assets/index-Ci5dbUDe.css +0 -2
- package/dist/assets/mermaid-GHXKKRXX-B7A4_dsH.js +0 -1
- package/dist/assets/metadata-admin-CwGCDJE1.js +0 -22
- package/dist/assets/plugin-charts-vp7sTLa2.js +0 -7
- package/dist/assets/plugin-dashboard-z2hSPvkm.js +0 -6
- package/dist/assets/plugin-form-BUDPowXG.js +0 -1
- package/dist/assets/plugin-grid-ieKf1CBn.js +0 -8
- package/dist/assets/plugin-map-C2xGbkMv.js +0 -1
- package/dist/assets/plugin-report-Cho-TzT3.js +0 -59
- package/dist/assets/plugin-view-vYQlhE3F.js +0 -1
- package/dist/assets/plugins-views-ycDq-ZXC.js +0 -4
- package/dist/assets/recordFormNavigation-CXt3jCB4.js +0 -1
- package/dist/assets/src-CbqgiuxM.js +0 -15
- package/dist/assets/ui-components-DlauVk27.js +0 -42
- package/dist/assets/ui-layout-DnHby9xU.js +0 -1
- package/dist/assets/useOpenRecordList-DWDU_kYn.js +0 -1
- package/dist/assets/useReconcileOnError-B9komLeJ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,g as r,m as i,t as a}from"./vendor-react-slxo-5GC.js";import{Bt as o,Ht as s,ot as c,q as l,zt as u}from"./framework-VeaoJc6L.js";import{A as d,N as f,P as p,k as m}from"./vendor-objectstack-BGWJwgbT.js";import{Ac as h,V as g,zt as ee}from"./ui-components-Pnfq_-xI.js";var _=e(n(),1),te=_.createContext(null);function v(e,t){let n=Array.isArray(e)?e[0]:e?e.x:0,r=Array.isArray(e)?e[1]:e?e.y:0,i=Array.isArray(t)?t[0]:t?t.x:0,a=Array.isArray(t)?t[1]:t?t.y:0;return n===i&&r===a}function y(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!y(e[n],t[n]))return!1;return!0}else if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!y(e[r],t[r]))return!1;return!0}return!1}function b(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function x(e,t){let n=t.viewState||t,r={};if(`longitude`in n&&`latitude`in n&&(n.longitude!==e.center.lng||n.latitude!==e.center.lat)){let t=e.center.constructor;r.center=new t(n.longitude,n.latitude)}return`zoom`in n&&n.zoom!==e.zoom&&(r.zoom=n.zoom),`bearing`in n&&n.bearing!==e.bearing&&(r.bearing=n.bearing),`pitch`in n&&n.pitch!==e.pitch&&(r.pitch=n.pitch),n.padding&&e.padding&&!y(n.padding,e.padding)&&(r.padding=n.padding),r}var S=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function C(e){if(!e)return null;if(typeof e==`string`||(`toJS`in e&&(e=e.toJS()),!e.layers))return e;let t={};for(let n of e.layers)t[n.id]=n;let n=e.layers.map(e=>{let n=null;`interactive`in e&&(n=Object.assign({},e),delete n.interactive);let r=t[e.ref];if(r){n||=Object.assign({},e),delete n.ref;for(let e of S)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var w={version:8,sources:{},layers:[]},T={minZoom:0,maxZoom:22,minPitch:0,maxPitch:85,maxBounds:[-180,-85.051129,180,85.051129],projection:`mercator`,renderWorldCopies:!0},E={mousedown:`onMouseDown`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mousemove:`onMouseMove`,click:`onClick`,dblclick:`onDblClick`,mouseenter:`onMouseEnter`,mouseleave:`onMouseLeave`,mouseout:`onMouseOut`,contextmenu:`onContextMenu`,touchstart:`onTouchStart`,touchend:`onTouchEnd`,touchmove:`onTouchMove`,touchcancel:`onTouchCancel`},D={movestart:`onMoveStart`,move:`onMove`,moveend:`onMoveEnd`,dragstart:`onDragStart`,drag:`onDrag`,dragend:`onDragEnd`,zoomstart:`onZoomStart`,zoom:`onZoom`,zoomend:`onZoomEnd`,rotatestart:`onRotateStart`,rotate:`onRotate`,rotateend:`onRotateEnd`,pitchstart:`onPitchStart`,pitch:`onPitch`,pitchend:`onPitchEnd`},O={wheel:`onWheel`,boxzoomstart:`onBoxZoomStart`,boxzoomend:`onBoxZoomEnd`,boxzoomcancel:`onBoxZoomCancel`,resize:`onResize`,load:`onLoad`,render:`onRender`,idle:`onIdle`,remove:`onRemove`,data:`onData`,styledata:`onStyleData`,sourcedata:`onSourceData`,error:`onError`},k=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],A=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],j=class e{constructor(e,t,n){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=e=>{let t=this.props[O[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||b(this._map.transform);let t=this.props[D[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=b(e),x(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[E[e.type]];t&&(this.props.interactiveLayerIds&&e.type!==`mouseover`&&e.type!==`mouseout`&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._MapClass=e,this.props=t,this._initialize(n)}get map(){return this._map}setProps(e){let t=this.props;this.props=e;let n=this._updateSettings(e,t),r=this._updateSize(e),i=this._updateViewState(e);this._updateStyle(e,t),this._updateStyleComponents(e),this._updateHandlers(e,t),(n||r||i&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){let r=e.savedMaps.pop();if(!r)return null;let i=r.map,a=i.getContainer();for(n.className=a.className;a.childNodes.length>0;)n.appendChild(a.childNodes[0]);i._container=n;let o=i._resizeObserver;o&&(o.disconnect(),o.observe(n)),r.setProps({...t,styleDiffing:!1}),i.resize();let{initialViewState:s}=t;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s)),i.isStyleLoaded()?i.fire(`load`):i.once(`style.load`,()=>i.fire(`load`)),i._update(),r}_initialize(e){let{props:t}=this,{mapStyle:n=w}=t,r={...t,...t.initialViewState,container:e,style:C(n)},i=r.initialViewState||r.viewState||r;if(Object.assign(r,{center:[i.longitude||0,i.latitude||0],zoom:i.zoom||0,pitch:i.pitch||0,bearing:i.bearing||0}),t.gl){let e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}let a=new this._MapClass(r);i.padding&&a.setPadding(i.padding),t.cursor&&(a.getCanvas().style.cursor=t.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on(`style.load`,()=>{this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:a.getProjection?.(),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on(`sourcedata`,()=>{this._updateStyleComponents(this.props)});for(let e in E)a.on(e,this._onPointerEvent);for(let e in D)a.on(e,this._onCameraEvent);for(let e in O)a.on(e,this._onEvent);this._map=a}recycle(){this.map.getContainer().querySelector(`[mapboxgl-children]`)?.remove(),e.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){let e=this._map;e.style&&(e._frame&&=(e._frame.cancel(),null),e._render())}_updateSize(e){let{viewState:t}=e;if(t){let e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e){let t=this._map,n=t.transform;if(!t.isMoving()){let r=x(n,e);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(e,t){let n=this._map,r=!1;for(let i of k)if((i in e||i in t)&&!y(e[i],t[i])){r=!0;let t=i in e?e[i]:T[i];n[`set${i[0].toUpperCase()}${i.slice(1)}`]?.call(n,t)}return r}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||``),e.mapStyle!==t.mapStyle){let{mapStyle:t=w,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(C(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style?._loaded&&(e&&!y(e,a.light)&&(a.light=e,i.setLight(e)),t&&!y(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!y(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!y(r,a.terrain)&&(!r||i.getSource(r.source))&&(a.terrain=r,i.setTerrain(r)))}_updateHandlers(e,t){let n=this._map;for(let r of A){let i=e[r]??!0;y(i,t[r]??!0)||(i?n[r].enable(i):n[r].disable())}}_queryRenderedFeatures(e){let t=this._map,{interactiveLayerIds:n=[]}=this.props;try{return t.queryRenderedFeatures(e,{layers:n.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(e){let{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){let t=e.type,n=this._hoveredFeatures?.length>0,r=this._queryRenderedFeatures(e.point),i=r.length>0;!i&&n&&(e.type=`mouseleave`,this._onPointerEvent(e)),this._hoveredFeatures=r,i&&!n&&(e.type=`mouseenter`,this._onPointerEvent(e)),e.type=t}else this._hoveredFeatures=null}};j.savedMaps=[];var M=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function N(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of P(t))!(e in n)&&!M.includes(e)&&(n[e]=t[e].bind(t));return n}function P(e){let t=new Set,n=e;for(;n;){for(let r of Object.getOwnPropertyNames(n))r[0]!==`_`&&typeof e[r]==`function`&&r!==`fire`&&r!==`setEventedParent`&&t.add(r);n=Object.getPrototypeOf(n)}return Array.from(t)}var F=typeof document<`u`?_.useLayoutEffect:_.useEffect;function I(e,t){let{RTLTextPlugin:n,maxParallelImageRequests:r,workerCount:i,workerUrl:a}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()===`unavailable`){let{pluginUrl:t,lazy:r=!0}=typeof n==`string`?{pluginUrl:n}:n;e.setRTLTextPlugin(t,e=>{e&&console.error(e)},r)}r!==void 0&&e.setMaxParallelImageRequests(r),i!==void 0&&e.setWorkerCount(i),a!==void 0&&e.setWorkerUrl(a)}var L=_.createContext(null);function R(t,n){let r=(0,_.useContext)(te),[a,o]=(0,_.useState)(null),s=(0,_.useRef)(),{current:c}=(0,_.useRef)({mapLib:null,map:null});(0,_.useEffect)(()=>{let n=t.mapLib,a=!0,l;return Promise.resolve(n||i(()=>import(`./maplibre-gl-DGbvC0OV.js`).then(t=>e(t.default,1)),[],import.meta.url)).then(e=>{if(!a)return;if(!e)throw Error(`Invalid mapLib`);let n=`Map`in e?e:e.default;if(!n.Map)throw Error(`Invalid mapLib`);I(n,t),t.reuseMaps&&(l=j.reuse(t,s.current)),l||=new j(n.Map,t,s.current),c.map=N(l),c.mapLib=n,o(l),r?.onMapMount(c.map,t.id)}).catch(e=>{let{onError:n}=t;n?n({type:`error`,target:null,originalEvent:null,error:e}):console.error(e)}),()=>{a=!1,l&&(r?.onMapUnmount(t.id),t.reuseMaps?l.recycle():l.destroy())}},[]),F(()=>{a&&a.setProps(t)}),(0,_.useImperativeHandle)(n,()=>c.map,[a]);let l=(0,_.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...t.style}),[t.style]);return _.createElement(`div`,{id:t.id,ref:s,style:l},a&&_.createElement(L.Provider,{value:c},_.createElement(`div`,{"mapboxgl-children":``,style:{height:`100%`}},t.children)))}var ne=_.forwardRef(R),z=e(r(),1),B=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function V(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!B.test(e)?n[e]=`${r}px`:n[e]=r}}function H(e,t){if(e===t)return null;let n=U(e),r=U(t),i=[];for(let e of r)n.has(e)||i.push(e);for(let e of n)r.has(e)||i.push(e);return i.length===0?null:i}function U(e){return new Set(e?e.trim().split(/\s+/):[])}var W=(0,_.memo)((0,_.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,_.useContext)(L),i=(0,_.useRef)({props:e}),a=(0,_.useMemo)(()=>{let t=!1;_.Children.forEach(e.children,e=>{e&&(t=!0)});let n={...e,element:t?document.createElement(`div`):void 0},o=new r.Marker(n);return o.setLngLat([e.longitude,e.latitude]),o.getElement().addEventListener(`click`,e=>{i.current.props.onClick?.({type:`click`,target:o,originalEvent:e})}),o.on(`dragstart`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragStart?.(t)}),o.on(`drag`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDrag?.(t)}),o.on(`dragend`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragEnd?.(t)}),o},[]);(0,_.useEffect)(()=>(a.addTo(n.getMap()),()=>{a.remove()}),[]);let{longitude:o,latitude:s,offset:c,style:l,draggable:u=!1,popup:d=null,rotation:f=0,rotationAlignment:p=`auto`,pitchAlignment:m=`auto`}=e;(0,_.useEffect)(()=>{V(a.getElement(),l)},[l]),(0,_.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!v(a.getOffset(),c)&&a.setOffset(c),a.isDraggable()!==u&&a.setDraggable(u),a.getRotation()!==f&&a.setRotation(f),a.getRotationAlignment()!==p&&a.setRotationAlignment(p),a.getPitchAlignment()!==m&&a.setPitchAlignment(m),a.getPopup()!==d&&a.setPopup(d);let g=H(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,z.createPortal)(e.children,a.getElement())})),re=(0,_.memo)((0,_.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,_.useContext)(L),i=(0,_.useMemo)(()=>document.createElement(`div`),[]),a=(0,_.useRef)({props:e}),o=(0,_.useMemo)(()=>{let t={...e},n=new r.Popup(t);return n.setLngLat([e.longitude,e.latitude]),n.once(`open`,e=>{a.current.props.onOpen?.(e)}),n},[]);if((0,_.useEffect)(()=>{let e=e=>{a.current.props.onClose?.(e)};return o.on(`close`,e),o.setDOMContent(i).addTo(n.getMap()),()=>{o.off(`close`,e),o.isOpen()&&o.remove()}},[]),(0,_.useEffect)(()=>{V(o.getElement(),e.style)},[e.style]),(0,_.useImperativeHandle)(t,()=>o,[]),o.isOpen()){let t=a.current.props;(o.getLngLat().lng!==e.longitude||o.getLngLat().lat!==e.latitude)&&o.setLngLat([e.longitude,e.latitude]),e.offset&&!y(t.offset,e.offset)&&o.setOffset(e.offset),(t.anchor!==e.anchor||t.maxWidth!==e.maxWidth)&&(o.options.anchor=e.anchor,o.setMaxWidth(e.maxWidth));let n=H(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,z.createPortal)(e.children,i)}));function G(e,t,n,r){let i=(0,_.useContext)(L),a=(0,_.useMemo)(()=>e(i),[]);return(0,_.useEffect)(()=>{let e=r||n||t,o=typeof t==`function`&&typeof n==`function`?t:null,s=typeof n==`function`?n:typeof t==`function`?t:null,{map:c}=i;return c.hasControl(a)||(c.addControl(a,e?.position),o&&o(i)),()=>{s&&s(i),c.hasControl(a)&&c.removeControl(a)}},[]),a}function K(e){let t=G(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,_.useEffect)(()=>{V(t._container,e.style)},[e.style]),null}(0,_.memo)(K);function q(e){let t=G(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,_.useEffect)(()=>{V(t._controlContainer,e.style)},[e.style]),null}(0,_.memo)(q);function J(e,t){let n=(0,_.useRef)({props:e}),r=G(({mapLib:t})=>{let r=new t.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on(`geolocate`,e=>{n.current.props.onGeolocate?.(e)}),r.on(`error`,e=>{n.current.props.onError?.(e)}),r.on(`outofmaxbounds`,e=>{n.current.props.onOutOfMaxBounds?.(e)}),r.on(`trackuserlocationstart`,e=>{n.current.props.onTrackUserLocationStart?.(e)}),r.on(`trackuserlocationend`,e=>{n.current.props.onTrackUserLocationEnd?.(e)}),r},{position:e.position});return n.current.props=e,(0,_.useImperativeHandle)(t,()=>r,[]),(0,_.useEffect)(()=>{V(r._container,e.style)},[e.style]),null}(0,_.memo)((0,_.forwardRef)(J));function Y(e){let t=G(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,_.useEffect)(()=>{V(t._container,e.style)},[e.style]),null}var ie=(0,_.memo)(Y);function X(e){let t=G(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,_.useRef)(e),r=n.current;n.current=e;let{style:i}=e;return e.maxWidth!==void 0&&e.maxWidth!==r.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==r.unit&&t.setUnit(e.unit),(0,_.useEffect)(()=>{V(t._container,i)},[i]),null}(0,_.memo)(X);function Z(e){let t=G(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,_.useEffect)(()=>{V(t._container,e.style)},[e.style]),null}(0,_.memo)(Z);function ae(e){let t=G(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,_.useEffect)(()=>{V(t._container,e.style)},[e.style]),null}(0,_.memo)(ae);var Q=a(),oe=d({latitudeField:f().optional(),longitudeField:f().optional(),locationField:f().optional(),titleField:f().optional(),descriptionField:f().optional(),zoom:m().optional(),center:p([m(),m()]).optional(),style:f().optional()}),se=`https://demotiles.maplibre.org/style.json`;function ce(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function le(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function ue(e){let t=e.style||e.mapStyle||e.filter?.map?.style||e.map?.style;if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||`name`,descriptionField:e.descriptionField,zoom:e.zoom,center:e.center,style:t};let n=null;if(e.filter&&typeof e.filter==`object`&&`map`in e.filter?n=e.filter.map:e.map&&(n=e.map),n){let e=oe.safeParse(n);return e.success||console.warn(`[ObjectMap] Invalid map configuration:`,e.error.format()),{...n,style:n.style||t}}return{latitudeField:`latitude`,longitudeField:`longitude`,locationField:`location`,titleField:`name`,descriptionField:`description`,zoom:10,center:[0,0],style:t}}function de(e,t){if(t.latitudeField&&t.longitudeField){let n=e[t.latitudeField],r=e[t.longitudeField];if(typeof n==`number`&&typeof r==`number`)return[n,r]}if(t.locationField){let n=e[t.locationField];if(typeof n==`object`&&n){let e=n.lat||n.latitude,t=n.lng||n.lon||n.longitude;if(typeof e==`number`&&typeof t==`number`)return[e,t]}if(typeof n==`string`){let e=n.split(`,`).map(e=>parseFloat(e.trim()));if(e.length===2&&!isNaN(e[0])&&!isNaN(e[1]))return[e[0],e[1]]}if(Array.isArray(n)&&n.length===2){let e=parseFloat(n[0]),t=parseFloat(n[1]);if(!isNaN(e)&&!isNaN(t))return[e,t]}}return null}function fe(e,t,n=50){if(e.length<=1||t>=15)return e.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1}));let r=n/2**t,i=new Map;e.forEach(e=>{let t=`${Math.floor(e.coordinates[0]/r)}:${Math.floor(e.coordinates[1]/r)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)});let a=[];return i.forEach((e,t)=>{if(e.length===1)a.push({id:e[0].id,coordinates:e[0].coordinates,markers:e,isCluster:!1});else{let n=e.reduce((e,t)=>e+t.coordinates[0],0)/e.length,r=e.reduce((e,t)=>e+t.coordinates[1],0)/e.length;a.push({id:`cluster-${t}`,coordinates:[n,r],markers:e,isCluster:!0})}}),a}var pe=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:a,onDelete:s,enableClustering:c,clusterRadius:d=50,...f})=>{let[p,m]=(0,_.useState)([]),[te,v]=(0,_.useState)(!0),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(``),D=ee(),O=(0,_.useRef)(null),[k,A]=(0,_.useState)(null),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(null),L=(0,_.useCallback)(e=>{I(e?.error?.message||`Failed to load the map style/tiles.`)},[]),R=(0,_.useCallback)(()=>{if(typeof navigator>`u`||!navigator.geolocation){M(`Geolocation is not available in this browser.`);return}P(!0),M(null),navigator.geolocation.getCurrentPosition(e=>{let{longitude:t,latitude:n}=e.coords;A({lng:t,lat:n}),P(!1);try{O.current?.flyTo({center:[t,n],zoom:12,duration:800})}catch{}},e=>{P(!1),M(e.message||`Unable to retrieve location.`)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:6e4})},[]),z=ce(e),B=(0,_.useMemo)(()=>z,[JSON.stringify(z)]),V=ue(e),H=B?.provider===`value`;(0,_.useEffect)(()=>{(async()=>{try{if(v(!0),f.data){let e=f.data;if(Array.isArray(e)){m(e),v(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),v(!1);return}}if(H&&B?.provider===`value`){m(B.items),v(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(B?.provider===`object`){let n=B.object,r=u(x?.fields);m(o(await t.find(n,{$filter:e.filter,$orderby:le(e.sort),...r.length>0?{$expand:r}:{}})))}else B?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));v(!1)}catch(e){b(e),v(!1)}})()},[B,t,H,e.filter,e.sort,x]),(0,_.useEffect)(()=>{!H&&t&&(async()=>{try{if(!t)return;let n=B?.provider===`object`?B.object:e.objectName;if(!n)return;S(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,H,B]);let{markers:U,invalidCount:G}=(0,_.useMemo)(()=>{let e=0;return{markers:p.map((t,n)=>{let r=de(t,V);if(!r)return e++,null;let i=V.titleField?t[V.titleField]:`Marker`,a=V.descriptionField?t[V.descriptionField]:void 0,[o,s]=r;return!isFinite(o)||!isFinite(s)||o<-90||o>90||s<-180||s>180?(e++,null):{id:t.id||t._id||`marker-${n}`,title:i,description:a,coordinates:[s,o],data:t}}).filter(e=>e!==null),invalidCount:e}},[p,V]),K=(0,_.useMemo)(()=>U.find(e=>e.id===C),[U,C]),[q,J]=(0,_.useState)(V.zoom||3),Y=l({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),X=(0,_.useMemo)(()=>{if(!T.trim())return U;let e=T.toLowerCase();return U.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[U,T]),Z=(0,_.useMemo)(()=>c??(e.enableClustering||X.length>100)?fe(X,q,d):X.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[X,q,c,d,e]),ae=(0,_.useMemo)(()=>{if(!X.length)return{longitude:V.center?.[1]||0,latitude:V.center?.[0]||0,zoom:V.zoom||2};let e=X.map(e=>e.coordinates[0]),t=X.map(e=>e.coordinates[1]),n=Math.min(...e),r=Math.max(...e),i=Math.min(...t),a=Math.max(...t);return{longitude:(n+r)/2,latitude:(i+a)/2,zoom:V.zoom||3}},[X,V]);return te?(0,Q.jsx)(`div`,{className:h(`min-w-0 overflow-hidden`,n),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading map...`})})}):y?(0,Q.jsx)(`div`,{className:h(`min-w-0 overflow-hidden`,n),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Q.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,y.message]})})}):(0,Q.jsxs)(`div`,{className:h(`min-w-0 overflow-hidden`,n),children:[G>0&&(0,Q.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${G} record${G===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),U.length>0&&(0,Q.jsx)(`div`,{className:`mb-2`,children:(0,Q.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`Search locations…`,className:`w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),(0,Q.jsxs)(`div`,{className:`relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full`,children:[(0,Q.jsxs)(ne,{ref:e=>{O.current=e},initialViewState:ae,style:{width:`100%`,height:`100%`},mapStyle:V.style||se,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>J(Math.round(e.viewState.zoom)),onError:L,children:[F&&(0,Q.jsxs)(`div`,{role:`alert`,className:`absolute inset-x-0 top-0 z-20 p-2 text-sm text-center text-amber-900 bg-amber-50 border-b border-amber-200`,children:[`Map failed to load (`,F,`). Markers below are still listed in the search box;`,` `,V.style?`check the configured map style URL.`:`configure a custom map style for production use.`]}),(0,Q.jsx)(ie,{position:`top-right`,showCompass:!0,showZoom:!0}),(0,Q.jsx)(`button`,{type:`button`,onClick:R,disabled:N,className:`absolute top-2 left-2 z-10 inline-flex items-center justify-center size-9 rounded-md bg-background/95 border shadow-sm hover:bg-background disabled:opacity-50`,"aria-label":`Show my location`,"data-testid":`map-geolocate`,children:(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:N?`⏳`:`🧭`})}),k&&(0,Q.jsx)(W,{longitude:k.lng,latitude:k.lat,anchor:`center`,children:(0,Q.jsx)(`div`,{className:`size-3 rounded-full bg-blue-500 ring-4 ring-blue-500/30 shadow`,"aria-label":`Your location`,"data-testid":`map-user-location`})}),Z.map(e=>e.isCluster?(0,Q.jsx)(W,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,onClick:t=>{t.originalEvent.stopPropagation();try{let t=Math.min(20,Math.max(q+2,8));O.current?.flyTo({center:[e.coordinates[0],e.coordinates[1]],zoom:t,duration:600})}catch{}},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md`,style:{width:Math.min(48,24+e.markers.length*2),height:Math.min(48,24+e.markers.length*2)},title:`${e.markers.length} markers`,"data-testid":`map-cluster`,children:e.markers.length})},e.id):(0,Q.jsx)(W,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];w(n.id),Y.handleClick(n.data),r?.(n.data)},children:(0,Q.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),K&&!D&&(0,Q.jsx)(re,{longitude:K.coordinates[0],latitude:K.coordinates[1],anchor:`top`,onClose:()=>w(null),closeOnClick:!1,children:(0,Q.jsxs)(`div`,{className:`p-2 min-w-[150px] sm:min-w-[200px]`,children:[(0,Q.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:K.title}),K.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.description}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs flex gap-2`,children:[a&&(0,Q.jsx)(`button`,{className:`text-blue-500 hover:underline`,onClick:()=>a(K.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>s(K.data),children:`Delete`})]})]})})]}),K&&D&&(0,Q.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 z-30 bg-background border-t shadow-lg rounded-t-2xl p-4 pb-[max(env(safe-area-inset-bottom),1rem)]`,role:`dialog`,"aria-label":`Location details`,"data-testid":`map-mobile-record-sheet`,children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:K.title}),K.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground line-clamp-3`,children:K.description})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`text-muted-foreground hover:text-foreground text-lg leading-none px-2`,"aria-label":`Close details`,"data-testid":`map-mobile-record-close`,children:`×`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[a&&(0,Q.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border bg-card hover:bg-accent`,onClick:()=>a(K.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border border-destructive/30 text-destructive hover:bg-destructive/10`,onClick:()=>s(K.data),children:`Delete`})]})]}),j&&(0,Q.jsx)(`div`,{className:`absolute top-2 left-14 right-2 z-10 text-xs px-3 py-1.5 rounded-md bg-destructive/10 text-destructive border border-destructive/30`,children:j})]}),Y.isOverlay&&(0,Q.jsx)(g,{...Y,title:`Location Details`,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},me=t({ObjectMap:()=>pe,ObjectMapRenderer:()=>$}),$=({schema:e,...t})=>{let{dataSource:n}=c()||{};return(0,Q.jsx)(pe,{schema:e,dataSource:n,...t})};console.log(`Registering object-map...`),s.register(`object-map`,$,{namespace:`plugin-map`,label:`Object Map`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]}),s.register(`map`,$,{namespace:`view`,label:`Map View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]});export{me as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,m as r,t as i}from"./vendor-react-slxo-5GC.js";import{
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,m as r,t as i}from"./vendor-react-slxo-5GC.js";import{Ht as a}from"./framework-VeaoJc6L.js";import{Rt as o}from"./ui-components-Pnfq_-xI.js";import{a as s,h as c,i as l,m as u,n as d,o as f,p,r as m,t as h}from"./vendor-markdown-Cbritblm.js";var g=e(n(),1),_=i();function v(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/(\*\*|__)(.*?)\1/g,`$2`).replace(/(\*|_)(.*?)\1/g,`$2`).replace(/<[^>]+>/g,``).trim()}function y(e,t){let n=t?.minDepth??2,r=t?.maxDepth??3,i=new f,a=[],o=null;for(let t of(e??``).split(/\r?\n/)){let e=t.match(/^\s{0,3}(`{3,}|~{3,})/);if(e){let t=e[1][0];o===null?o=t:t===o&&(o=null);continue}if(o!==null)continue;let s=t.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);if(!s)continue;let c=s[1].length,l=v(s[2]);if(!l)continue;let u=i.slug(l);c>=n&&c<=r&&a.push({depth:c,text:l,id:u})}return a}var b=null;function x(){return b||=r(()=>import(`./mermaid.core-T8rJXbMH.js`).then(e=>e.default),[],import.meta.url),b}var S=0;function C(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)}function w({chart:e}){let[t,n]=g.useState(``),[r,i]=g.useState(null),[a,o]=g.useState(C);return g.useEffect(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=new MutationObserver(()=>o(C()));return t.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]),g.useEffect(()=>{let t=!1,r=e.trim();if(!r){n(``),i(null);return}return x().then(async e=>{e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:a?`dark`:`default`});let o=`os-mermaid-${S+=1}`,{svg:s}=await e.render(o,r);t||(n(s),i(null))}).catch(e=>{t||i(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,a]),r?(0,_.jsx)(`pre`,{"data-mermaid":!0,"data-mermaid-error":!0,className:`my-4 overflow-auto rounded border border-destructive/40 bg-muted p-3 text-xs`,children:(0,_.jsx)(`code`,{children:e})}):t?(0,_.jsx)(`div`,{"data-mermaid":!0,role:`img`,className:`my-4 flex justify-center overflow-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:t}}):(0,_.jsx)(`div`,{"data-mermaid":!0,"data-mermaid-pending":!0,className:`my-4 text-sm text-muted-foreground`,children:(0,_.jsx)(`pre`,{className:`sr-only`,children:e})})}var T=t({MarkdownRenderer:()=>D,Mermaid:()=>w,extractToc:()=>y,markdownComponents:()=>O}),E=g.lazy(()=>r(()=>Promise.resolve().then(()=>M),void 0,import.meta.url)),D=({schema:e})=>(0,_.jsx)(g.Suspense,{fallback:(0,_.jsx)(o,{className:`w-full h-[200px]`}),children:(0,_.jsx)(E,{content:e.content||``,className:e.className})});a.register(`markdown`,D,{namespace:`plugin-markdown`,label:`Markdown`,category:`plugin`,inputs:[{name:`content`,type:`string`,label:`Markdown Content`,required:!0,inputType:`textarea`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{content:`# Hello World
|
|
2
2
|
|
|
3
3
|
This is a **markdown** component with *formatting* support.
|
|
4
4
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,t as r}from"./vendor-react-slxo-5GC.js";import{Ht as i,Mt as a,Y as o,dt as s,ft as c,jt as l,lt as u,rt as d,s as f,ut as p}from"./framework-VeaoJc6L.js";import{$o as m,Ba as h,Gr as g,Hi as _,Lc as v,Rt as y,Sr as b,ai as x,d as ee,er as S,g as C,ir as w,nr as T,or as E,qi as D,rr as O,tr as k}from"./ui-components-Pnfq_-xI.js";var A=e(n(),1),j=r(),te=({schema:e})=>{let{title:t,description:n,data:r,columns:a}=e;e.chart?.type;let o=!!e.chart;return(0,j.jsxs)(S,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,j.jsxs)(O,{children:[t&&(0,j.jsx)(w,{children:t}),n&&(0,j.jsx)(T,{children:n})]}),(0,j.jsxs)(k,{className:`flex-1 overflow-auto space-y-4`,children:[o&&(()=>{let t=e.chart?.type,n=t?i.get(t):null;return n||=i.get(`chart`),n?(0,j.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,j.jsx)(n,{schema:{...e.chart,data:e.chart.data||r}})}):(0,j.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,t||`chart`]})})(),r&&r.length>0&&(0,j.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=i.get(`grid`)||i.get(`table`);return e?(0,j.jsx)(e,{schema:{type:`grid`,rowData:r,columnDefs:a,domLayout:`autoHeight`}}):(0,j.jsx)(`div`,{className:`overflow-x-auto`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,j.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,j.jsx)(`tr`,{children:a?.map(e=>(0,j.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,j.jsx)(`tbody`,{children:r.map((e,t)=>(0,j.jsx)(`tr`,{className:`bg-background border-b`,children:a?.map(t=>(0,j.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function M(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=R(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
2
|
+
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));V([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
3
|
+
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function ne(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};V(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function N(e,t,n){let r=e.fields||[],i=B(n?.orientation),a=z(n?.pageSize);V(`<!DOCTYPE html>
|
|
4
|
+
<html>
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<title>${L(e.title||`Report`)}</title>
|
|
8
|
+
<style>
|
|
9
|
+
@page { size: ${a} ${i}; margin: 20mm; }
|
|
10
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
11
|
+
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
12
|
+
.description { color: #666; margin-bottom: 24px; }
|
|
13
|
+
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
14
|
+
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
15
|
+
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
16
|
+
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
17
|
+
tr:nth-child(even) { background: #fafafa; }
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<h1>${L(e.title||`Report`)}</h1>
|
|
22
|
+
${e.description?`<p class="description">${L(e.description)}</p>`:``}
|
|
23
|
+
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
24
|
+
<table>
|
|
25
|
+
<thead><tr>${r.map(e=>`<th>${L(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
26
|
+
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${L(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
</body>
|
|
29
|
+
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function P(e,t,n){let r=e.fields||[],i=B(n?.orientation),a=z(n?.pageSize),o=window.open(``,`_blank`);if(!o){N(e,t,{...n,format:`html`,filename:n?.filename?.replace(/\.pdf$/,`.html`)||`${e.title||`report`}.html`});return}o.document.write(`<!DOCTYPE html>
|
|
30
|
+
<html>
|
|
31
|
+
<head>
|
|
32
|
+
<meta charset="utf-8">
|
|
33
|
+
<title>${L(e.title||`Report`)}</title>
|
|
34
|
+
<style>
|
|
35
|
+
@page { size: ${a} ${i}; margin: 20mm; }
|
|
36
|
+
@media print { .no-print { display: none; } }
|
|
37
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
38
|
+
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
39
|
+
.description { color: #666; margin-bottom: 24px; }
|
|
40
|
+
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
41
|
+
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
42
|
+
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
43
|
+
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
44
|
+
tr:nth-child(even) { background: #fafafa; }
|
|
45
|
+
</style>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<h1>${L(e.title||`Report`)}</h1>
|
|
49
|
+
${e.description?`<p class="description">${L(e.description)}</p>`:``}
|
|
50
|
+
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
51
|
+
<table>
|
|
52
|
+
<thead><tr>${r.map(e=>`<th>${L(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
53
|
+
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${L(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
54
|
+
</table>
|
|
55
|
+
</body>
|
|
56
|
+
</html>`),o.document.close(),o.onload=()=>{o.print()}}function F(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=R(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
57
|
+
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));V(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
58
|
+
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function I(e,t,n,r){switch(e){case`csv`:M(t,n,r);break;case`json`:ne(t,n,r);break;case`html`:N(t,n,r);break;case`pdf`:P(t,n,r);break;case`excel`:F(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function L(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function R(e){if(typeof e==`string`&&e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`\t${e}`}return e}function z(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function B(e){return e===`landscape`?`landscape`:`portrait`}function V(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function H(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||re(e))return ie(e);if(n===`number`||typeof e==`number`){let t=typeof e==`number`?e:Number(e);return isNaN(t)?String(e):r===`currency`||r===`currency_cny`?`¥${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`currency_usd`?`$${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`percent`?`${t.toLocaleString(`en-US`,{minimumFractionDigits:1,maximumFractionDigits:1})}%`:t.toLocaleString(`en-US`)}return String(e)}function re(e){return typeof e==`string`?/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e):!1}function ie(e){try{let t=new Date(e);return isNaN(t.getTime())?String(e):`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}catch{return String(e)}}function ae(e,t){if(!t||t.length===0||!e||e.length===0)return null;let n=t[0],r=n.field,i=new Map;for(let t of e){let e=String(t[r]??`(empty)`);i.has(e)||i.set(e,[]),i.get(e).push(t)}let a=[];for(let[e,t]of i)a.push({key:e,label:`${n.label||r}: ${e}`,rows:t});let o=n.sort===`desc`?-1:1;return a.sort((e,t)=>e.key.localeCompare(t.key)*o),a}var U=({schema:e,onRefresh:t})=>{let{report:n,data:r,showToolbar:a=!0,allowExport:s=!0,allowPrint:c=!0,loading:l=!1}=e,u=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}I(e,n,r||[],n.exportConfigs?.[e])},d=()=>{window.print()},f=()=>{t?.()},p=(e,t)=>{if(!r)return 0;let n=r.map(t=>Number(t[e])||0);switch(t){case`count`:return r.length;case`sum`:return n.reduce((e,t)=>e+t,0);case`avg`:return n.length>0?(n.reduce((e,t)=>e+t,0)/n.length).toFixed(2):0;case`min`:return n.length>0?Math.min(...n):0;case`max`:return n.length>0?Math.max(...n):0;default:return``}},h=(e,t)=>{let r=n?.conditionalFormatting;if(!(!r||!Array.isArray(r)))for(let n of r){if(n.field!==e)continue;let r=String(t??``),i=String(n.value??``),a=!1;switch(n.operator){case`equals`:a=r===i;break;case`not_equals`:a=r!==i;break;case`contains`:a=r.includes(i);break;case`greater_than`:a=Number(t)>Number(n.value);break;case`less_than`:a=Number(t)<Number(n.value);break}if(a){let e={};return n.backgroundColor&&(e.backgroundColor=n.backgroundColor),n.textColor&&(e.color=n.textColor),e}}},g=(e,t)=>{if(e==null||e===``)return``;if(t.renderAs===`badge`&&(!t.type||t.type===`string`||t.type===`text`))return(0,j.jsx)(E,{className:t.colorMap?.[String(e)]||``,children:String(e)});if(t.aggregation)return H(e,t);if(t.type){let n={...t};return t.colorMap&&!n.options&&(n.options=Object.entries(t.colorMap).map(([e,t])=>({value:e,label:e,color:t}))),(0,j.jsx)(ee(C(n)),{value:e,field:n})}return H(e,t)};return n?(0,j.jsxs)(`div`,{className:`space-y-4`,children:[a&&(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,j.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,j.jsxs)(b,{variant:`outline`,size:`sm`,onClick:f,children:[(0,j.jsx)(_,{className:`h-4 w-4 mr-2`}),`Refresh`]}),c&&(0,j.jsxs)(b,{variant:`outline`,size:`sm`,onClick:d,children:[(0,j.jsx)(D,{className:`h-4 w-4 mr-2`}),`Print`]}),s&&n.showExportButtons&&(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsxs)(b,{variant:`outline`,size:`sm`,onClick:()=>u(`pdf`),children:[(0,j.jsx)(m,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,j.jsxs)(b,{variant:`outline`,size:`sm`,onClick:()=>u(`excel`),children:[(0,j.jsx)(m,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,j.jsxs)(b,{variant:`outline`,size:`sm`,onClick:()=>u(`csv`),children:[(0,j.jsx)(m,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,j.jsxs)(S,{children:[(0,j.jsxs)(O,{children:[!a&&n.title&&(0,j.jsx)(w,{children:n.title}),!a&&n.description&&(0,j.jsx)(T,{children:n.description})]}),(0,j.jsxs)(k,{className:`space-y-6`,children:[l&&(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,j.jsx)(S,{children:(0,j.jsxs)(k,{className:`p-4 space-y-2`,children:[(0,j.jsx)(y,{className:`h-4 w-20`}),(0,j.jsx)(y,{className:`h-8 w-28`})]})},e))}),(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(y,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,j.jsx)(y,{className:`h-8 w-full`},e))]})]}),!l&&n.sections?.map((e,t)=>e.visible===!1?null:(0,j.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,j.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,j.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,j.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,j.jsx)(S,{children:(0,j.jsxs)(k,{className:`p-4`,children:[(0,j.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,j.jsx)(`div`,{className:`text-2xl font-bold`,children:H(p(e.name,e.aggregation),e)})]})},t))}),e.type===`chart`&&e.chart&&(0,j.jsx)(`div`,{className:`min-h-[300px]`,children:(()=>{let t=e.chart.type,n=!!e.chart.chartType;!t&&n&&(t=`chart`),t&&i.get(t)||(t=`chart`);let a=t===`chart`?{xAxisKey:e.chart.xAxisKey||e.chart.xAxisField||`name`,series:e.chart.series||(e.chart.yAxisFields?e.chart.yAxisFields.map(e=>({dataKey:e})):[]),chartType:e.chart.chartType||`bar`}:{};return(0,j.jsx)(o,{schema:{...e.chart,type:t,...a,data:r||e.chart.data,className:e.chart.className||`w-full h-[350px]`}})})()}),e.type===`table`&&(0,j.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,j.jsx)(`thead`,{className:`bg-muted`,children:(0,j.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,j.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,j.jsx)(`tbody`,{children:(()=>{let t=ae(r||[],n.groupBy||[]);return t?t.map(t=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsx)(`tr`,{className:`bg-muted/60`,children:(0,j.jsxs)(`td`,{colSpan:e.columns?.length||1,className:`px-4 py-2 font-semibold text-sm`,children:[t.label,` (`,t.rows.length,`)`]})}),t.rows.map((t,n)=>(0,j.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,j.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:h(e.name,t[e.name]),children:g(t[e.name],e)},n))},n))]},t.key)):r?.map((t,n)=>(0,j.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,j.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:h(e.name,t[e.name]),children:g(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,j.jsx)(`div`,{className:`prose max-w-none`,children:(0,j.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,j.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,j.jsx)(o,{schema:e.content})]},t)),!n.sections&&r&&r.length>0&&(0,j.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,j.jsx)(`thead`,{className:`bg-muted`,children:(0,j.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,j.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,j.jsx)(`tbody`,{children:r.map((e,t)=>(0,j.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,j.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:h(t.name,e[t.name]),children:g(e[t.name],t)},n))},t))})]})})]})]})]}):(0,j.jsx)(S,{children:(0,j.jsx)(k,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})};function W(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(n&&r)return{$and:[e,t]};if(n)return e;if(r)return t}function G(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.dataset==`string`&&t.dataset.length>0?!0:t.type===`joined`&&Array.isArray(t.blocks)&&t.blocks.some(e=>typeof e?.dataset==`string`)}function K(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]}function J(e,t,n,r,i,a){let[o,s]=A.useState({status:`idle`,rows:[]}),c=JSON.stringify(r??null),l=JSON.stringify(a??null),u=`${e}|${t.join(`,`)}|${n.join(`,`)}|${c}|${l}`;return A.useEffect(()=>{let o=i;if(!o||typeof o.queryDataset!=`function`){s({status:`error`,rows:[],error:`This data source does not support dataset queries.`});return}if(!e||n.length===0){s({status:`idle`,rows:[]});return}let c=!1;return s({status:`loading`,rows:[]}),o.queryDataset(e,{dimensions:t,measures:n,...r&&Object.keys(r).length>0?{runtimeFilter:r}:{},...a?{totals:{groupings:a}}:{}}).then(e=>{c||s({status:`ok`,rows:Array.isArray(e?.rows)?e.rows:[],fields:Array.isArray(e?.fields)?e.fields:[],object:e?.object,dimensionFields:e?.dimensionFields,drillRawRows:Array.isArray(e?.drillRawRows)?e.drillRawRows:void 0,totals:Array.isArray(e?.totals)?e.totals:void 0})}).catch(e=>{c||s({status:`error`,rows:[],error:String(e?.message??e)})}),()=>{c=!0}},[u]),o}function Y({dataset:e}){return(0,j.jsxs)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:[`This report binds the “`,e,`” dataset — choose at least one measure (values) to render.`]})}function X({status:e,error:t}){return e===`error`?(0,j.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:[(0,j.jsx)(g,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,j.jsx)(`span`,{className:`break-words`,children:t})]}):(0,j.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,j.jsx)(h,{className:`h-4 w-4 animate-spin`}),` Running report…`]})}function Z(){return(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-dashed bg-muted/20 p-6 text-xs text-muted-foreground`,children:[(0,j.jsx)(x,{className:`h-6 w-6`}),` The dataset returned no rows for this report’s scope.`]})}var oe=`cursor-pointer hover:bg-accent/40`;function se({dataset:e,rows:t,values:n,runtimeFilter:r,dataSource:i,onDrill:a}){let o=J(e,t,n,r,i),{fieldLabel:l}=v();if(n.length===0)return(0,j.jsx)(Y,{dataset:e});if(o.status===`loading`||o.status===`idle`)return(0,j.jsx)(X,{status:o.status});if(o.status===`error`)return(0,j.jsx)(X,{status:`error`,error:o.error});if(o.rows.length===0)return(0,j.jsx)(Z,{});let d=!!a&&t.length>0,f=o.dimensionFields?t.filter(e=>e in o.dimensionFields):[],m=(n,i)=>{let s={};for(let e of t)s[e]=n[e];let c=o.object&&o.dimensionFields&&f.length>0?u(o.drillRawRows?.[i],f,o.dimensionFields,r):void 0;a({dataset:e,groupKey:s,runtimeFilter:r,object:o.object,objectFilter:c})},{measureField:h,headerLabel:g}=p(o.fields,o.object,l),_=[...t,...n];return(0,j.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,children:(0,j.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,j.jsx)(`thead`,{className:`bg-muted/40`,children:(0,j.jsx)(`tr`,{children:_.map(e=>(0,j.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:g(e)},e))})}),(0,j.jsx)(`tbody`,{children:o.rows.map((e,t)=>(0,j.jsx)(`tr`,{className:`border-t${d?` ${oe}`:``}`,"data-testid":d?`dataset-drill-row`:void 0,onClick:d?()=>m(e,t):void 0,children:_.map(t=>(0,j.jsx)(`td`,{className:`px-2 py-1 tabular-nums whitespace-nowrap`,children:n.includes(t)?c(e[t],h(t)?.format,h(t)?.currency):s(e[t])},t))},t))})]})})}function ce(e){switch(e){case`line`:return`line`;case`area`:return`area`;case`pie`:return`pie`;case`donut`:return`donut`;case`radar`:return`radar`;case`scatter`:return`scatter`;default:return`bar`}}function le(e){let[,t]=A.useReducer(e=>e+1,0);return A.useEffect(()=>{if(i.get(e))return;let n=typeof i.subscribe==`function`?i.subscribe(()=>{i.get(e)&&t()}):void 0,r=i.loadLazy?.(e);return r&&typeof r.then==`function`&&r.then(()=>t()).catch(()=>{}),n},[e]),i.get(e)}function ue({dataset:e,chart:t,runtimeFilter:n,dataSource:r}){let i=typeof t.xAxis==`string`?t.xAxis:``,a=typeof t.yAxis==`string`?t.yAxis:``,o=J(e,i?[i]:[],a?[a]:[],n,r),s=le(`chart`);if(!i||!a)return null;if(o.status===`loading`||o.status===`idle`)return(0,j.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,j.jsx)(h,{className:`h-4 w-4 animate-spin`}),` Loading chart…`]});if(o.status===`error`||o.rows.length===0||!s)return null;let c=typeof t.title==`string`?t.title:void 0;return(0,j.jsxs)(`div`,{className:`rounded-md border bg-card p-3`,"data-testid":`dataset-report-chart`,children:[c?(0,j.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:c}):null,(0,j.jsx)(s,{schema:{chartType:ce(t.type),data:o.rows,xAxisKey:i,series:[{dataKey:a}],height:typeof t.height==`number`?t.height:280,isAnimationActive:!1}})]})}function Q(e,t){return e.map(e=>String(t[e]??`∅`)).join(``)}function de(e,t){return e.map(e=>s(t[e])).join(` / `)}function fe({dataset:e,rows:t,columnsAcross:n,values:r,runtimeFilter:i,dataSource:a,onDrill:o}){let l=J(e,[...t,...n],r,i,a,[t,n,[]]),d=f(),{fieldLabel:m}=v(),h=A.useMemo(()=>{if(l.status!==`ok`)return null;let e=[],r=[],i=new Set,a=new Set,o=new Map;return l.rows.forEach((s,c)=>{let l=Q(t,s),u=Q(n,s);if(!i.has(l)){i.add(l);let n={};for(let e of t)n[e]=s[e];e.push({id:l,label:de(t,s),key:n})}if(!a.has(u)){a.add(u);let e={};for(let t of n)e[t]=s[t];r.push({id:u,label:de(n,s),key:e})}o.set(`${l} ${u}`,{row:s,index:c})}),{rowHeaders:e,colHeaders:r,cells:o}},[l,t,n]);if(r.length===0)return(0,j.jsx)(Y,{dataset:e});if(l.status===`loading`||l.status===`idle`)return(0,j.jsx)(X,{status:l.status});if(l.status===`error`)return(0,j.jsx)(X,{status:`error`,error:l.error});if(!h||h.rowHeaders.length===0)return(0,j.jsx)(Z,{});let{measureField:g,headerLabel:_}=p(l.fields,l.object,m),y=d(`report.total`,`Total`),b=!!o,x=l.dimensionFields?[...t,...n].filter(e=>e in l.dimensionFields):[],ee=(t,n,r)=>{let a=l.object&&l.dimensionFields&&x.length>0?u(l.drillRawRows?.[r],x,l.dimensionFields,i):void 0;o({dataset:e,groupKey:{...t,...n},runtimeFilter:i,object:l.object,objectFilter:a})},S=h.colHeaders.flatMap(e=>r.map(t=>({col:e,measure:t,header:r.length===1?e.label:`${e.label} · ${_(t)}`}))),C=e=>l.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows,w=new Map;for(let e of C(t)??[])w.set(Q(t,e),e);let T=new Map;for(let e of C(n)??[])T.set(Q(n,e),e);let E=C([])?.[0],D=w.size>0,O=T.size>0;return(0,j.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,"data-testid":`dataset-matrix`,children:(0,j.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,j.jsx)(`thead`,{className:`bg-muted/40`,children:(0,j.jsxs)(`tr`,{children:[t.map(e=>(0,j.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:_(e)},e)),S.map(e=>(0,j.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),D&&r.map(e=>(0,j.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:r.length===1?y:`${y} · ${_(e)}`},`total-${e}`))]})}),(0,j.jsxs)(`tbody`,{children:[h.rowHeaders.map(e=>(0,j.jsxs)(`tr`,{className:`border-t`,children:[t.map(t=>(0,j.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:s(e.key[t])},t)),S.map(t=>{let n=h.cells.get(`${e.id} ${t.col.id}`),r=n?.row[t.measure],i=b&&n!=null;return(0,j.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap${i?` ${oe}`:``}`,"data-testid":i?`dataset-drill-cell`:void 0,onClick:i?()=>ee(e.key,t.col.key,n.index):void 0,children:c(r,g(t.measure)?.format,g(t.measure)?.currency)},`${t.col.id}-${t.measure}`)}),D&&r.map(t=>(0,j.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:c(w.get(e.id)?.[t],g(t)?.format,g(t)?.currency)},`total-${t}`))]},e.id)),O&&(0,j.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[t.length>0&&(0,j.jsx)(`td`,{colSpan:t.length,className:`px-2 py-1 whitespace-nowrap`,children:y}),S.map(e=>(0,j.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:c(T.get(e.col.id)?.[e.measure],g(e.measure)?.format,g(e.measure)?.currency)},`${e.col.id}-${e.measure}`)),D&&r.map(e=>(0,j.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:c(E?.[e],g(e)?.format,g(e)?.currency)},`grand-${e}`))]})]})]})})}var pe=({report:e,dataSource:t,runtimeFilter:n,onDrill:r,className:i})=>{let a=W(e.runtimeFilter??e.filter,n),o=e.drilldown===!1?void 0:r;if(e.type===`joined`&&Array.isArray(e.blocks))return(0,j.jsx)(`div`,{className:i,"data-testid":`dataset-joined-report`,"data-report-name":e.name,style:{display:`flex`,flexDirection:`column`,gap:24},children:e.blocks.map((e,n)=>{let r=W(a,e.runtimeFilter??e.filter),i=q(e.columns),s=e.type===`matrix`&&i.length>0?(0,j.jsx)(fe,{dataset:String(e.dataset??``),rows:q(e.rows),columnsAcross:i,values:q(e.values),runtimeFilter:r,dataSource:t,onDrill:o}):(0,j.jsx)(se,{dataset:String(e.dataset??``),rows:q(e.rows),values:q(e.values),runtimeFilter:r,dataSource:t,onDrill:o});return(0,j.jsxs)(`section`,{"data-testid":`dataset-report-block`,"data-block-id":e.name??`block-${n}`,className:`flex flex-col gap-2 rounded-lg border bg-card p-4`,children:[(0,j.jsxs)(`header`,{className:`flex flex-col gap-0.5`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold`,children:K(e.label,e.name??`Block ${n+1}`)}),e.description?(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K(e.description,``)}):null]}),s]},e.name??`block-${n}`)})});let s=q(e.columns);if(e.type===`matrix`&&s.length>0)return(0,j.jsx)(`div`,{className:i,"data-testid":`dataset-report`,"data-report-name":e.name,children:(0,j.jsx)(fe,{dataset:String(e.dataset??``),rows:q(e.rows),columnsAcross:s,values:q(e.values),runtimeFilter:a,dataSource:t,onDrill:o})});let c=e.chart&&typeof e.chart==`object`&&e.chart.type?e.chart:null;return(0,j.jsxs)(`div`,{className:`${i??``} flex flex-col gap-3`,"data-testid":`dataset-report`,"data-report-name":e.name,children:[c?(0,j.jsx)(ue,{dataset:String(e.dataset??``),chart:c,runtimeFilter:a,dataSource:t}):null,(0,j.jsx)(se,{dataset:String(e.dataset??``),rows:q(e.rows),values:q(e.values),runtimeFilter:a,dataSource:t,onDrill:o})]})},$=e=>{let{dataSource:t,rows:n,runtimeFilter:r,onDrill:i,className:o}=e,s=A.useContext(d),c=t??s?.dataSource,u=e.schema;return u&&typeof u==`object`&&u.type===`spec-report`&&u.report&&typeof u.report==`object`&&(u=u.report),G(u)?(0,j.jsx)(pe,{report:u,dataSource:c,runtimeFilter:r,onDrill:i,className:o}):l(u)?(0,j.jsx)(`div`,{className:o,"data-testid":`report-presentation-bridge`,children:(0,j.jsx)(U,{schema:{type:`report-viewer`,report:a(u),data:n??[],showToolbar:!1}})}):(0,j.jsx)(te,{schema:u})};async function me(e,t){let{dataSource:n,resource:r,queryParams:i,format:a,exportConfig:o}=t,s=a||e.defaultExportFormat||`pdf`;try{let t=(await n.find(r,i)).data||[];return I(s,e,t,{format:s,...e.exportConfigs?.[s],...o}),{success:!0,recordCount:t.length,format:s}}catch(e){return{success:!1,recordCount:0,format:s,error:e.message}}}function he(e,t,n={}){let{columns:r,filename:i,includeAggregationRow:a=!1}=n,o=r||(e.fields||[]).map(_e),s=o.map(e=>e.header),c=t.map((e,t)=>o.map(n=>{if(n.formula)return n.formula.replace(/\{ROW\}/g,String(t+2));let r=e[n.name];return ve(r,n.numberFormat)}));if(a&&t.length>0){let n=o.map((n,r)=>{let i=(e.fields||[]).find(e=>e.name===n.name);if(i?.aggregation){let e=be(r),n=t.length+1;switch(i.aggregation){case`sum`:return`=SUM(${e}2:${e}${n})`;case`avg`:return`=AVERAGE(${e}2:${e}${n})`;case`count`:return`=COUNTA(${e}2:${e}${n})`;case`min`:return`=MIN(${e}2:${e}${n})`;case`max`:return`=MAX(${e}2:${e}${n})`;default:return``}}return``});c.push(n)}Se(``+[s.join(` `),...c.map(e=>e.join(` `))].join(`
|
|
59
|
+
`),i||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function ge(e,t,n,r){return async()=>{let i=e.schedule;if(!i?.enabled)return[];let a=i.formats||[e.defaultExportFormat||`pdf`],o=[];for(let r of a){let i=await me(e,{dataSource:t,resource:n,format:r});o.push(i)}return r(e,i),o}}function _e(e){return{name:e.name,header:e.label||e.name}}function ve(e,t){return e==null?``:typeof e==`number`&&t?e.toLocaleString(`en-US`,ye(t)):xe(String(e))}function ye(e){if(e.includes(`%`))return{style:`percent`,minimumFractionDigits:0};let t=(e.match(/0/g)||[]).length;return{minimumFractionDigits:Math.max(0,t-1),maximumFractionDigits:Math.max(0,t-1)}}function be(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function xe(e){if(e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`'${e}`}return e}function Se(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}var Ce=t({DatasetReportRenderer:()=>pe,LegacyReportRenderer:()=>te,ReportRenderer:()=>$,ReportViewer:()=>U,createScheduleTrigger:()=>ge,exportAsCSV:()=>M,exportAsExcel:()=>F,exportAsHTML:()=>N,exportAsJSON:()=>ne,exportAsPDF:()=>P,exportExcelWithFormulas:()=>he,exportReport:()=>I,exportWithLiveData:()=>me,formatValue:()=>H,isDatasetReport:()=>G,mergeFilters:()=>W});i.register(`report`,$,{namespace:`report`,label:`Report`,category:`Report`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`chart`,type:`code`,label:`Chart Configuration`}]}),i.register(`spec-report`,$,{namespace:`report`,label:`Spec Report`,category:`Report`,inputs:[{name:`dataset`,type:`string`,label:`Dataset`},{name:`type`,type:`string`,label:`Report Type`}]}),i.register(`report-viewer`,U,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]});export{Ce as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,t as r}from"./vendor-react-slxo-5GC.js";import{Ft as i,It as a,Rt as o,U as s,a as c,nt as l,tt as u}from"./framework-Bn8ShCi0.js";import{A as d,N as f,y as p}from"./vendor-objectstack-BGWJwgbT.js";import{Ac as m,Ic as h,V as g,jc as _}from"./ui-components-DlauVk27.js";import{i as v}from"./vendor-ui-utils-C1OpMExs.js";import{a as ee}from"./plugin-grid-ieKf1CBn.js";var y=e(n(),1),b=r(),x=10080*60*1e3;function S(e){let t=e.flatMap(e=>(e.items||[]).flatMap(e=>[e.startDate,e.endDate])),n=Math.min(...t.map(e=>new Date(e).getTime())),r=Math.max(...t.map(e=>new Date(e).getTime()));return{minDate:new Date(n).toISOString().split(`T`)[0],maxDate:new Date(r).toISOString().split(`T`)[0]}}function C(e,t,n,r){let i=new Date(e).getTime(),a=new Date(t).getTime(),o=new Date(n).getTime(),s=new Date(r).getTime()-o,c=i-o,l=a-i;return{start:c/s*100,width:l/s*100}}function w(e,t){let n=new Date(e);return t===`short`?n.toLocaleDateString():t===`long`?n.toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`}):n.toISOString().split(`T`)[0]}function T({label:e,color:t}){let n=t?{backgroundColor:`${t}22`,color:t,borderColor:`${t}55`}:void 0;return(0,b.jsx)(`span`,{className:m(`inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium`,!t&&`bg-muted text-muted-foreground border-transparent`),style:n,children:e})}function E(e){let t=[];for(let n of e){let e=n.group==null?``:String(n.group),r=t[t.length-1];r&&r.key===e?r.items.push(n):t.push({key:e,items:[n]})}return t}var D=({schema:e,className:t,...n})=>{let{variant:r=`vertical`,items:i=[],dateFormat:a=`short`,onItemClick:o}=e;if(r===`vertical`){let e=E(i),r=e.some(e=>e.key!==``),s=(e,t)=>{let n=e.color?{backgroundColor:`${e.color}33`,borderColor:e.color}:void 0,r=e.time?w(e.time,a):e.startDate?w(e.startDate,a):``,i=e.endDate&&e.endDate!==e.startDate?w(e.endDate,a):``,s=Array.isArray(e.meta)?e.meta:[];return(0,b.jsxs)(I,{density:`compact`,className:m(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,b.jsx)(R,{variant:e.color?`default`:e.variant||`default`,style:n,children:e.icon&&(0,b.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,b.jsxs)(z,{children:[(r||i)&&(0,b.jsxs)(V,{dateTime:e.time||e.startDate,className:`!mb-1 text-xs`,children:[r,i&&(0,b.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` → `,i]})]}),e.title&&(0,b.jsx)(B,{className:`text-sm sm:text-base mb-1`,children:e.title}),s.length>0&&(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1 mb-1`,children:s.map(e=>(0,b.jsx)(T,{label:e.label,color:e.color},e.key))}),e.description&&(0,b.jsx)(H,{className:`text-sm text-muted-foreground line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&_(e.content)]})]},t)};return r?(0,b.jsx)(`div`,{className:m(`px-4 sm:px-6 py-2`,t),...n,children:e.map((e,t)=>(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsxs)(`header`,{className:`sticky top-0 z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 py-1.5 backdrop-blur bg-background/90 text-xs font-semibold uppercase tracking-wide text-muted-foreground border-b`,children:[(0,b.jsx)(`span`,{children:e.key}),(0,b.jsx)(`span`,{className:`ml-2 text-muted-foreground/60 font-normal normal-case`,children:e.items.length})]}),(0,b.jsx)(P,{className:`mt-3`,children:e.items.map((e,n)=>s(e,`${t}-${n}`))})]},`${e.key}-${t}`))}):(0,b.jsx)(P,{className:t,...n,children:i.map((e,t)=>s(e,t))})}if(r===`horizontal`)return(0,b.jsx)(U,{className:m(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:i.map((e,t)=>(0,b.jsxs)(W,{className:m(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,b.jsx)(R,{variant:e.variant||`default`,children:e.icon&&(0,b.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,b.jsxs)(`div`,{className:`mt-4 text-center`,children:[e.time&&(0,b.jsx)(V,{dateTime:e.time,children:w(e.time,a)}),e.title&&(0,b.jsx)(B,{children:e.title}),e.description&&(0,b.jsx)(H,{className:`text-center line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&_(e.content)]})]}),t<i.length-1&&(0,b.jsx)(`div`,{className:`absolute left-full w-16 border-t-2 border-gray-200 top-3`})]},t))});if(r===`gantt`){let r=S(i),s=e.minDate||r.minDate,c=e.maxDate||r.maxDate,l=e.timeScale||`month`,u=(()=>{let e=[],t=new Date(s),n=new Date(c);if(l===`month`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})),r.setMonth(r.getMonth()+1)}else if(l===`week`){let r=new Date(t);for(;r<=n;)e.push(`Week ${Math.ceil((r.getTime()-t.getTime())/x)+1}`),r.setDate(r.getDate()+7)}else if(l===`day`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})),r.setDate(r.getDate()+1)}return e})();return(0,b.jsxs)(G,{className:m(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:[(0,b.jsxs)(K,{children:[(0,b.jsx)(q,{className:`flex items-center px-2 sm:px-4 py-2 sm:py-3`,children:(0,b.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:e.rowLabel||`Items`})}),(0,b.jsx)(J,{children:(0,b.jsx)(`div`,{className:`flex h-full`,children:u.map((e,t)=>(0,b.jsx)(`div`,{className:`flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center`,children:e},t))})})]}),(0,b.jsx)(`div`,{children:(0,b.jsxs)(`div`,{className:`flex`,children:[(0,b.jsx)(q,{children:i.map((e,t)=>(0,b.jsx)(Y,{children:(0,b.jsx)(X,{title:e.label,className:`truncate`,children:e.label})},t))}),(0,b.jsx)(J,{className:`relative`,children:i.map((e,t)=>(0,b.jsx)(Y,{className:`relative`,children:(e.items||[]).map((n,r)=>{let i=C(n.startDate,n.endDate,s,c);return(0,b.jsx)(Z,{start:i.start,width:i.width,variant:n.variant||`default`,onClick:()=>o?.(n,e,t,r),title:`${n.title||``}\n${w(n.startDate,a)} - ${w(n.endDate,a)}`,children:(0,b.jsx)(Q,{children:n.title})},r)})},t))})]})})]})}return null};o.register(`timeline`,D,{namespace:`plugin-timeline`,label:`Timeline`,category:`data-display`,inputs:[{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],label:`Timeline Variant`,defaultValue:`vertical`},{name:`items`,type:`array`,label:`Timeline Items`,description:`For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }`},{name:`dateFormat`,type:`enum`,enum:[`short`,`long`,`iso`],label:`Date Format`,defaultValue:`short`},{name:`timeScale`,type:`enum`,enum:[`day`,`week`,`month`],label:`Time Scale (Gantt only)`,defaultValue:`month`},{name:`rowLabel`,type:`string`,label:`Row Label (Gantt only)`,defaultValue:`Items`},{name:`minDate`,type:`string`,label:`Min Date (Gantt only)`,description:`Override auto-calculated min date (YYYY-MM-DD)`},{name:`maxDate`,type:`string`,label:`Max Date (Gantt only)`,description:`Override auto-calculated max date (YYYY-MM-DD)`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{variant:`vertical`,dateFormat:`short`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`,icon:`🚀`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`,icon:`🎨`},{time:`2024-03-15`,title:`Beta Release`,description:`Released beta version to testers`,variant:`warning`,icon:`⚡`},{time:`2024-04-01`,title:`Launch`,description:`Official product launch`,variant:`success`,icon:`🎉`}]},examples:{vertical:{variant:`vertical`,dateFormat:`long`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`}]},horizontal:{variant:`horizontal`,dateFormat:`short`,items:[{time:`2024-01-01`,title:`Q1`,description:`First quarter`,variant:`default`},{time:`2024-04-01`,title:`Q2`,description:`Second quarter`,variant:`info`},{time:`2024-07-01`,title:`Q3`,description:`Third quarter`,variant:`warning`},{time:`2024-10-01`,title:`Q4`,description:`Fourth quarter`,variant:`success`}]},gantt:{variant:`gantt`,dateFormat:`short`,timeScale:`month`,rowLabel:`Projects`,items:[{label:`Backend Development`,items:[{title:`API Design`,startDate:`2024-01-01`,endDate:`2024-01-31`,variant:`success`},{title:`Implementation`,startDate:`2024-02-01`,endDate:`2024-03-31`,variant:`info`}]},{label:`Frontend Development`,items:[{title:`UI Design`,startDate:`2024-01-15`,endDate:`2024-02-15`,variant:`warning`},{title:`Component Dev`,startDate:`2024-02-15`,endDate:`2024-04-15`,variant:`default`}]},{label:`Testing`,items:[{title:`QA Phase`,startDate:`2024-03-01`,endDate:`2024-04-30`,variant:`danger`}]}]}}});var O={"timeline.bucket.overdue":`Overdue`,"timeline.bucket.today":`Today`,"timeline.bucket.tomorrow":`Tomorrow`,"timeline.bucket.thisWeek":`This week`,"timeline.bucket.nextWeek":`Next week`,"timeline.bucket.later":`Later`,"timeline.bucket.noDate":`No date`,"timeline.bucket.unassigned":`Unassigned`,"timeline.relative.today":`Today`,"timeline.relative.tomorrow":`Tomorrow`,"timeline.relative.yesterday":`Yesterday`,"timeline.relative.inDays":`In {{n}} days`,"timeline.relative.daysAgo":`{{n}} days ago`},k=`timeline.bucket.today`;function A(e,t){let n=O[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function j(){try{let e=c();return e.t(k)===k?{t:A}:{t:e.t}}catch{return{t:A}}}function te(){try{return h()}catch{return{fieldOptionLabel:(e,t,n,r)=>r,translateOptions:(e,t,n)=>n,fieldLabel:(e,t,n)=>n}}}var ne=d({mapping:d({title:f().optional(),date:f().optional(),description:f().optional(),variant:f().optional()}).optional(),objectName:f().optional(),titleField:f().optional(),dateField:f().optional(),startDateField:f().optional(),endDateField:f().optional(),descriptionField:f().optional(),groupByField:f().optional(),colorField:f().optional(),scale:p([`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional()}),M=({schema:e,dataSource:t,className:n,onRowClick:r,onItemClick:o,...c})=>{let[l,d]=(0,y.useState)([]),[f,p]=(0,y.useState)(()=>{let t=Array.isArray(e.items)&&e.items.length>0,n=Array.isArray(c.data)&&c.data.length>0;return!t&&!n&&!!e.objectName}),[m,h]=(0,y.useState)(null),[_,v]=(0,y.useState)(0),[x,S]=(0,y.useState)(null),C=e.timeline;(0,y.useEffect)(()=>{let t=ne.safeParse(e);t.success||console.warn(`[ObjectTimeline] Invalid timeline configuration:`,t.error.format())},[e]);let w=u(e.bind);(0,y.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||typeof t.getObjectSchema!=`function`||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&S(r)}catch(e){console.warn(`Failed to fetch object def for ObjectTimeline`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,y.useEffect)(()=>{e.objectName&&!w&&!e.items&&!c.data?(async()=>{if(!t||typeof t.find!=`function`||!e.objectName){p(!1);return}p(!0);try{let n=i(x?.fields);d(a(await t.find(e.objectName,{options:{$top:100},...n.length>0?{$expand:n}:{}})))}catch(e){console.error(e),h(e)}finally{p(!1)}})():p(!1)},[e.objectName,t,w,e.items,c.data,_,x]);let T=c.data||w||l,{t:E}=j(),{fieldOptionLabel:O}=te(),k=C?.titleField??e.mapping?.title??e.titleField??`name`,A=C?.startDateField??e.mapping?.date??e.startDateField??e.dateField??`date`,M=C?.endDateField??e.endDateField??A,N=e.mapping?.description??e.descriptionField??`description`,P=e.mapping?.variant??`variant`,F=C?.groupByField??e.groupByField,I=C?.colorField??e.colorField,L=(0,y.useMemo)(()=>{if(e.items)return e.items;if(!T||!Array.isArray(T))return[];let t=x?.fields??{},n=e.objectName||``,r=e=>{if(!e||!t[e]?.options)return{};let n={};for(let r of t[e].options)r&&r.value!=null&&(n[String(r.value)]=r);return n},i=r(I),a=Array.isArray(C?.metaFields)?C.metaFields.filter(e=>typeof e==`string`&&e):[`status`,`priority`].filter(e=>t[e]),o={};for(let e of a)o[e]=r(e);let s=e=>{if(e==null||e===``)return;let t=i[String(e)];if(t?.color)return String(t.color);let n=String(e);if(/^#([0-9a-f]{3}){1,2}$/i.test(n)||n.startsWith(`rgb`)||n.startsWith(`hsl`))return n},c=(e,t,r)=>{if(t==null||t===``)return null;let i=r[String(t)];return{label:i?.label?O(n,e,String(t),i.label):String(t),color:i?.color}},l=T.map(e=>{let t=e[A],r=e[M],i=I?e[I]:void 0,l=F?e[F]:void 0,u=[];if(n)for(let t of a){let n=c(t,e[t],o[t]||{});n&&u.push({key:t,label:n.label,color:n.color})}return{title:e[k],time:t,startDate:t,endDate:r,description:e[N],variant:e[P]||`default`,color:s(i),group:l,meta:u,_data:e}});l.sort((e,t)=>(e.startDate?new Date(e.startDate).getTime():1/0)-(t.startDate?new Date(t.startDate).getTime():1/0));let u=new Date,d=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),f=d(u),p=864e5,m=f-(u.getDay()+6)%7*p+7*p,h=m+7*p,g=e=>{if(!e)return E(`timeline.bucket.noDate`);let t=d(new Date(e));return Number.isNaN(t)?E(`timeline.bucket.noDate`):t<f?E(`timeline.bucket.overdue`):t===f?E(`timeline.bucket.today`):t===f+p?E(`timeline.bucket.tomorrow`):E(t<m?`timeline.bucket.thisWeek`:t<h?`timeline.bucket.nextWeek`:`timeline.bucket.later`)};if(F&&!l.every(e=>e.group==null||e.group===``)){let e=r(F);return l.map(t=>{let n=c(F,t.group,e);return{...t,group:n?n.label:t.group!=null&&t.group!==``?String(t.group):E(`timeline.bucket.unassigned`)}})}return l.map(e=>({...e,group:g(e.startDate)}))},[e.items,T,x,e.objectName,k,A,M,N,P,I,F,E,O]),{ref:R,isRefreshing:z,pullDistance:B}=ee({onRefresh:(0,y.useCallback)(async()=>{v(e=>e+1)},[]),enabled:!!e.objectName&&!!t}),V=s({navigation:e.navigation,objectName:e.objectName,onRowClick:r??o}),H=C?.scale??e.scale,U={...e,items:L||[],className:n||e.className,...H?{timeScale:H}:{},onItemClick:e=>{let t=e._data||e;V.handleClick(t),o?.(t)}};return m?(0,b.jsxs)(`div`,{className:`p-4 text-destructive`,"data-testid":`timeline-error`,role:`alert`,children:[`Error loading timeline: `,m.message]}):f&&(!L||L.length===0)?(0,b.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-3`,"data-testid":`timeline-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,b.jsx)(`span`,{className:`sr-only`,children:`Loading timeline…`}),[0,1,2,3].map(e=>(0,b.jsxs)(`div`,{className:`flex items-start gap-3`,style:{opacity:Math.max(.3,1-e*.18)},children:[(0,b.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-muted/70 animate-pulse mt-1.5 shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,b.jsx)(`div`,{className:`h-4 w-1/3 rounded bg-muted/70 animate-pulse`}),(0,b.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-muted/50 animate-pulse`})]})]},e))]}):(0,b.jsxs)(`div`,{ref:R,className:`relative overflow-auto h-full min-w-0`,children:[B>0&&(0,b.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:B},children:z?`Refreshing…`:`Pull to refresh`}),(0,b.jsx)(D,{schema:U}),V.isOverlay&&(0,b.jsx)(g,{...V,title:`Timeline Item`,children:e=>(0,b.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,b.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},N=t({ObjectTimeline:()=>M,ObjectTimelineRenderer:()=>$,Timeline:()=>P,TimelineContent:()=>z,TimelineDescription:()=>H,TimelineGantt:()=>G,TimelineGanttBar:()=>Z,TimelineGanttBarContent:()=>Q,TimelineGanttGrid:()=>J,TimelineGanttHeader:()=>K,TimelineGanttLabel:()=>X,TimelineGanttRow:()=>Y,TimelineGanttRowLabels:()=>q,TimelineHorizontal:()=>U,TimelineHorizontalItem:()=>W,TimelineItem:()=>I,TimelineMarker:()=>R,TimelineRenderer:()=>D,TimelineTime:()=>V,TimelineTitle:()=>B,timelineItemVariants:()=>F,timelineMarkerVariants:()=>L}),P=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`ol`,{ref:n,className:m(`relative ml-3 border-l border-gray-200`,e),...t}));P.displayName=`Timeline`;var F=v(`ml-6`,{variants:{density:{default:`mb-10`,compact:`mb-3`,comfortable:`mb-6`}},defaultVariants:{density:`default`}}),I=y.forwardRef(({className:e,density:t,...n},r)=>(0,b.jsx)(`li`,{ref:r,className:m(F({density:t}),e),...n}));I.displayName=`TimelineItem`;var L=v(`absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center`,{variants:{variant:{default:`bg-blue-200 border-blue-400`,success:`bg-emerald-200 border-emerald-500`,warning:`bg-amber-200 border-amber-500`,danger:`bg-red-200 border-red-500`,info:`bg-purple-200 border-purple-500`,todo:`bg-slate-200 border-slate-400`,"in-progress":`bg-blue-200 border-blue-500`,done:`bg-emerald-200 border-emerald-500`}},defaultVariants:{variant:`default`}}),R=y.forwardRef(({className:e,variant:t=`default`,...n},r)=>(0,b.jsx)(`div`,{ref:r,className:m(L({variant:t}),e),...n}));R.displayName=`TimelineMarker`;var z=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:e,...t}));z.displayName=`TimelineContent`;var B=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`h3`,{ref:n,className:m(`font-semibold text-lg mb-1`,e),...t}));B.displayName=`TimelineTitle`;var V=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`time`,{ref:n,className:m(`text-sm font-normal text-gray-500 mb-2 block`,e),...t}));V.displayName=`TimelineTime`;var H=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`p`,{ref:n,className:m(`text-base text-gray-700`,e),...t}));H.displayName=`TimelineDescription`;var U=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`relative flex overflow-x-auto py-8`,e),...t}));U.displayName=`TimelineHorizontal`;var W=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`shrink-0 w-64 relative`,e),...t}));W.displayName=`TimelineHorizontalItem`;var G=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`relative w-full border rounded-lg overflow-hidden`,e),...t}));G.displayName=`TimelineGantt`;var K=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`flex border-b bg-gray-50`,e),...t}));K.displayName=`TimelineGanttHeader`;var q=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`w-48 border-r bg-white`,e),...t}));q.displayName=`TimelineGanttRowLabels`;var J=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`flex-1 overflow-x-auto`,e),...t}));J.displayName=`TimelineGanttGrid`;var Y=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`flex items-center border-b min-h-12`,e),...t}));Y.displayName=`TimelineGanttRow`;var X=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`px-4 py-2 font-medium text-sm truncate`,e),...t}));X.displayName=`TimelineGanttLabel`;var Z=y.forwardRef(({className:e,start:t=0,width:n=100,variant:r=`default`,...i},a)=>(0,b.jsx)(`div`,{ref:a,className:m(`absolute h-8 rounded-md transition-colors cursor-pointer`,{default:`bg-blue-500 hover:bg-blue-600`,success:`bg-green-500 hover:bg-green-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,danger:`bg-red-500 hover:bg-red-600`,info:`bg-purple-500 hover:bg-purple-600`}[r],e),style:{left:`${t}%`,width:`${n}%`},...i}));Z.displayName=`TimelineGanttBar`;var Q=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`px-2 py-1 text-white text-xs font-medium truncate`,e),...t}));Q.displayName=`TimelineGanttBarContent`;var $=({schema:e,...t})=>{let{dataSource:n}=l()||{};return(0,b.jsx)(M,{schema:e,dataSource:n,...t})};o.register(`object-timeline`,$,{namespace:`plugin-timeline`,label:`Object Timeline`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]}),o.register(`timeline`,$,{namespace:`view`,label:`Timeline View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]});export{N as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,t as r}from"./vendor-react-slxo-5GC.js";import{Bt as i,Ht as a,at as o,l as s,ot as c,q as l,zt as u}from"./framework-VeaoJc6L.js";import{A as d,N as f,y as p}from"./vendor-objectstack-BGWJwgbT.js";import{Ac as m,Ic as h,V as g,jc as _}from"./ui-components-Pnfq_-xI.js";import{i as v}from"./vendor-ui-utils-C1OpMExs.js";import{a as ee}from"./plugin-grid-CddzO4VP.js";var y=e(n(),1),b=r(),x=10080*60*1e3;function S(e){let t=e.flatMap(e=>(e.items||[]).flatMap(e=>[e.startDate,e.endDate])),n=Math.min(...t.map(e=>new Date(e).getTime())),r=Math.max(...t.map(e=>new Date(e).getTime()));return{minDate:new Date(n).toISOString().split(`T`)[0],maxDate:new Date(r).toISOString().split(`T`)[0]}}function C(e,t,n,r){let i=new Date(e).getTime(),a=new Date(t).getTime(),o=new Date(n).getTime(),s=new Date(r).getTime()-o,c=i-o,l=a-i;return{start:c/s*100,width:l/s*100}}function w(e,t){let n=new Date(e);return t===`short`?n.toLocaleDateString():t===`long`?n.toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`}):n.toISOString().split(`T`)[0]}function T({label:e,color:t}){let n=t?{backgroundColor:`${t}22`,color:t,borderColor:`${t}55`}:void 0;return(0,b.jsx)(`span`,{className:m(`inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium`,!t&&`bg-muted text-muted-foreground border-transparent`),style:n,children:e})}function E(e){let t=[];for(let n of e){let e=n.group==null?``:String(n.group),r=t[t.length-1];r&&r.key===e?r.items.push(n):t.push({key:e,items:[n]})}return t}var D=({schema:e,className:t,...n})=>{let{variant:r=`vertical`,items:i=[],dateFormat:a=`short`,onItemClick:o}=e;if(r===`vertical`){let e=E(i),r=e.some(e=>e.key!==``),s=(e,t)=>{let n=e.color?{backgroundColor:`${e.color}33`,borderColor:e.color}:void 0,r=e.time?w(e.time,a):e.startDate?w(e.startDate,a):``,i=e.endDate&&e.endDate!==e.startDate?w(e.endDate,a):``,s=Array.isArray(e.meta)?e.meta:[];return(0,b.jsxs)(I,{density:`compact`,className:m(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,b.jsx)(R,{variant:e.color?`default`:e.variant||`default`,style:n,children:e.icon&&(0,b.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,b.jsxs)(z,{children:[(r||i)&&(0,b.jsxs)(V,{dateTime:e.time||e.startDate,className:`!mb-1 text-xs`,children:[r,i&&(0,b.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` → `,i]})]}),e.title&&(0,b.jsx)(B,{className:`text-sm sm:text-base mb-1`,children:e.title}),s.length>0&&(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1 mb-1`,children:s.map(e=>(0,b.jsx)(T,{label:e.label,color:e.color},e.key))}),e.description&&(0,b.jsx)(H,{className:`text-sm text-muted-foreground line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&_(e.content)]})]},t)};return r?(0,b.jsx)(`div`,{className:m(`px-4 sm:px-6 py-2`,t),...n,children:e.map((e,t)=>(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsxs)(`header`,{className:`sticky top-0 z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 py-1.5 backdrop-blur bg-background/90 text-xs font-semibold uppercase tracking-wide text-muted-foreground border-b`,children:[(0,b.jsx)(`span`,{children:e.key}),(0,b.jsx)(`span`,{className:`ml-2 text-muted-foreground/60 font-normal normal-case`,children:e.items.length})]}),(0,b.jsx)(P,{className:`mt-3`,children:e.items.map((e,n)=>s(e,`${t}-${n}`))})]},`${e.key}-${t}`))}):(0,b.jsx)(P,{className:t,...n,children:i.map((e,t)=>s(e,t))})}if(r===`horizontal`)return(0,b.jsx)(U,{className:m(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:i.map((e,t)=>(0,b.jsxs)(W,{className:m(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,b.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,b.jsx)(R,{variant:e.variant||`default`,children:e.icon&&(0,b.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,b.jsxs)(`div`,{className:`mt-4 text-center`,children:[e.time&&(0,b.jsx)(V,{dateTime:e.time,children:w(e.time,a)}),e.title&&(0,b.jsx)(B,{children:e.title}),e.description&&(0,b.jsx)(H,{className:`text-center line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&_(e.content)]})]}),t<i.length-1&&(0,b.jsx)(`div`,{className:`absolute left-full w-16 border-t-2 border-gray-200 top-3`})]},t))});if(r===`gantt`){let r=S(i),s=e.minDate||r.minDate,c=e.maxDate||r.maxDate,l=e.timeScale||`month`,u=(()=>{let e=[],t=new Date(s),n=new Date(c);if(l===`month`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})),r.setMonth(r.getMonth()+1)}else if(l===`week`){let r=new Date(t);for(;r<=n;)e.push(`Week ${Math.ceil((r.getTime()-t.getTime())/x)+1}`),r.setDate(r.getDate()+7)}else if(l===`day`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})),r.setDate(r.getDate()+1)}return e})();return(0,b.jsxs)(G,{className:m(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:[(0,b.jsxs)(K,{children:[(0,b.jsx)(q,{className:`flex items-center px-2 sm:px-4 py-2 sm:py-3`,children:(0,b.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:e.rowLabel||`Items`})}),(0,b.jsx)(J,{children:(0,b.jsx)(`div`,{className:`flex h-full`,children:u.map((e,t)=>(0,b.jsx)(`div`,{className:`flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center`,children:e},t))})})]}),(0,b.jsx)(`div`,{children:(0,b.jsxs)(`div`,{className:`flex`,children:[(0,b.jsx)(q,{children:i.map((e,t)=>(0,b.jsx)(Y,{children:(0,b.jsx)(X,{title:e.label,className:`truncate`,children:e.label})},t))}),(0,b.jsx)(J,{className:`relative`,children:i.map((e,t)=>(0,b.jsx)(Y,{className:`relative`,children:(e.items||[]).map((n,r)=>{let i=C(n.startDate,n.endDate,s,c);return(0,b.jsx)(Z,{start:i.start,width:i.width,variant:n.variant||`default`,onClick:()=>o?.(n,e,t,r),title:`${n.title||``}\n${w(n.startDate,a)} - ${w(n.endDate,a)}`,children:(0,b.jsx)(Q,{children:n.title})},r)})},t))})]})})]})}return null};a.register(`timeline`,D,{namespace:`plugin-timeline`,label:`Timeline`,category:`data-display`,inputs:[{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],label:`Timeline Variant`,defaultValue:`vertical`},{name:`items`,type:`array`,label:`Timeline Items`,description:`For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }`},{name:`dateFormat`,type:`enum`,enum:[`short`,`long`,`iso`],label:`Date Format`,defaultValue:`short`},{name:`timeScale`,type:`enum`,enum:[`day`,`week`,`month`],label:`Time Scale (Gantt only)`,defaultValue:`month`},{name:`rowLabel`,type:`string`,label:`Row Label (Gantt only)`,defaultValue:`Items`},{name:`minDate`,type:`string`,label:`Min Date (Gantt only)`,description:`Override auto-calculated min date (YYYY-MM-DD)`},{name:`maxDate`,type:`string`,label:`Max Date (Gantt only)`,description:`Override auto-calculated max date (YYYY-MM-DD)`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{variant:`vertical`,dateFormat:`short`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`,icon:`🚀`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`,icon:`🎨`},{time:`2024-03-15`,title:`Beta Release`,description:`Released beta version to testers`,variant:`warning`,icon:`⚡`},{time:`2024-04-01`,title:`Launch`,description:`Official product launch`,variant:`success`,icon:`🎉`}]},examples:{vertical:{variant:`vertical`,dateFormat:`long`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`}]},horizontal:{variant:`horizontal`,dateFormat:`short`,items:[{time:`2024-01-01`,title:`Q1`,description:`First quarter`,variant:`default`},{time:`2024-04-01`,title:`Q2`,description:`Second quarter`,variant:`info`},{time:`2024-07-01`,title:`Q3`,description:`Third quarter`,variant:`warning`},{time:`2024-10-01`,title:`Q4`,description:`Fourth quarter`,variant:`success`}]},gantt:{variant:`gantt`,dateFormat:`short`,timeScale:`month`,rowLabel:`Projects`,items:[{label:`Backend Development`,items:[{title:`API Design`,startDate:`2024-01-01`,endDate:`2024-01-31`,variant:`success`},{title:`Implementation`,startDate:`2024-02-01`,endDate:`2024-03-31`,variant:`info`}]},{label:`Frontend Development`,items:[{title:`UI Design`,startDate:`2024-01-15`,endDate:`2024-02-15`,variant:`warning`},{title:`Component Dev`,startDate:`2024-02-15`,endDate:`2024-04-15`,variant:`default`}]},{label:`Testing`,items:[{title:`QA Phase`,startDate:`2024-03-01`,endDate:`2024-04-30`,variant:`danger`}]}]}}});var O={"timeline.bucket.overdue":`Overdue`,"timeline.bucket.today":`Today`,"timeline.bucket.tomorrow":`Tomorrow`,"timeline.bucket.thisWeek":`This week`,"timeline.bucket.nextWeek":`Next week`,"timeline.bucket.later":`Later`,"timeline.bucket.noDate":`No date`,"timeline.bucket.unassigned":`Unassigned`,"timeline.relative.today":`Today`,"timeline.relative.tomorrow":`Tomorrow`,"timeline.relative.yesterday":`Yesterday`,"timeline.relative.inDays":`In {{n}} days`,"timeline.relative.daysAgo":`{{n}} days ago`},k=`timeline.bucket.today`;function A(e,t){let n=O[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function j(){try{let e=s();return e.t(k)===k?{t:A}:{t:e.t}}catch{return{t:A}}}function te(){try{return h()}catch{return{fieldOptionLabel:(e,t,n,r)=>r,translateOptions:(e,t,n)=>n,fieldLabel:(e,t,n)=>n}}}var ne=d({mapping:d({title:f().optional(),date:f().optional(),description:f().optional(),variant:f().optional()}).optional(),objectName:f().optional(),titleField:f().optional(),dateField:f().optional(),startDateField:f().optional(),endDateField:f().optional(),descriptionField:f().optional(),groupByField:f().optional(),colorField:f().optional(),scale:p([`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional()}),M=({schema:e,dataSource:t,className:n,onRowClick:r,onItemClick:a,...s})=>{let[c,d]=(0,y.useState)([]),[f,p]=(0,y.useState)(()=>{let t=Array.isArray(e.items)&&e.items.length>0,n=Array.isArray(s.data)&&s.data.length>0;return!t&&!n&&!!e.objectName}),[m,h]=(0,y.useState)(null),[_,v]=(0,y.useState)(0),[x,S]=(0,y.useState)(null),C=e.timeline;(0,y.useEffect)(()=>{let t=ne.safeParse(e);t.success||console.warn(`[ObjectTimeline] Invalid timeline configuration:`,t.error.format())},[e]);let w=o(e.bind);(0,y.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||typeof t.getObjectSchema!=`function`||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&S(r)}catch(e){console.warn(`Failed to fetch object def for ObjectTimeline`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,y.useEffect)(()=>{e.objectName&&!w&&!e.items&&!s.data?(async()=>{if(!t||typeof t.find!=`function`||!e.objectName){p(!1);return}p(!0);try{let n=u(x?.fields);d(i(await t.find(e.objectName,{options:{$top:100},...n.length>0?{$expand:n}:{}})))}catch(e){console.error(e),h(e)}finally{p(!1)}})():p(!1)},[e.objectName,t,w,e.items,s.data,_,x]);let T=s.data||w||c,{t:E}=j(),{fieldOptionLabel:O}=te(),k=C?.titleField??e.mapping?.title??e.titleField??`name`,A=C?.startDateField??e.mapping?.date??e.startDateField??e.dateField??`date`,M=C?.endDateField??e.endDateField??A,N=e.mapping?.description??e.descriptionField??`description`,P=e.mapping?.variant??`variant`,F=C?.groupByField??e.groupByField,I=C?.colorField??e.colorField,L=(0,y.useMemo)(()=>{if(e.items)return e.items;if(!T||!Array.isArray(T))return[];let t=x?.fields??{},n=e.objectName||``,r=e=>{if(!e||!t[e]?.options)return{};let n={};for(let r of t[e].options)r&&r.value!=null&&(n[String(r.value)]=r);return n},i=r(I),a=Array.isArray(C?.metaFields)?C.metaFields.filter(e=>typeof e==`string`&&e):[`status`,`priority`].filter(e=>t[e]),o={};for(let e of a)o[e]=r(e);let s=e=>{if(e==null||e===``)return;let t=i[String(e)];if(t?.color)return String(t.color);let n=String(e);if(/^#([0-9a-f]{3}){1,2}$/i.test(n)||n.startsWith(`rgb`)||n.startsWith(`hsl`))return n},c=(e,t,r)=>{if(t==null||t===``)return null;let i=r[String(t)];return{label:i?.label?O(n,e,String(t),i.label):String(t),color:i?.color}},l=T.map(e=>{let t=e[A],r=e[M],i=I?e[I]:void 0,l=F?e[F]:void 0,u=[];if(n)for(let t of a){let n=c(t,e[t],o[t]||{});n&&u.push({key:t,label:n.label,color:n.color})}return{title:e[k],time:t,startDate:t,endDate:r,description:e[N],variant:e[P]||`default`,color:s(i),group:l,meta:u,_data:e}});l.sort((e,t)=>(e.startDate?new Date(e.startDate).getTime():1/0)-(t.startDate?new Date(t.startDate).getTime():1/0));let u=new Date,d=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),f=d(u),p=864e5,m=f-(u.getDay()+6)%7*p+7*p,h=m+7*p,g=e=>{if(!e)return E(`timeline.bucket.noDate`);let t=d(new Date(e));return Number.isNaN(t)?E(`timeline.bucket.noDate`):t<f?E(`timeline.bucket.overdue`):t===f?E(`timeline.bucket.today`):t===f+p?E(`timeline.bucket.tomorrow`):E(t<m?`timeline.bucket.thisWeek`:t<h?`timeline.bucket.nextWeek`:`timeline.bucket.later`)};if(F&&!l.every(e=>e.group==null||e.group===``)){let e=r(F);return l.map(t=>{let n=c(F,t.group,e);return{...t,group:n?n.label:t.group!=null&&t.group!==``?String(t.group):E(`timeline.bucket.unassigned`)}})}return l.map(e=>({...e,group:g(e.startDate)}))},[e.items,T,x,e.objectName,k,A,M,N,P,I,F,E,O]),{ref:R,isRefreshing:z,pullDistance:B}=ee({onRefresh:(0,y.useCallback)(async()=>{v(e=>e+1)},[]),enabled:!!e.objectName&&!!t}),V=l({navigation:e.navigation,objectName:e.objectName,onRowClick:r??a}),H=C?.scale??e.scale,U={...e,items:L||[],className:n||e.className,...H?{timeScale:H}:{},onItemClick:e=>{let t=e._data||e;V.handleClick(t),a?.(t)}};return m?(0,b.jsxs)(`div`,{className:`p-4 text-destructive`,"data-testid":`timeline-error`,role:`alert`,children:[`Error loading timeline: `,m.message]}):f&&(!L||L.length===0)?(0,b.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-3`,"data-testid":`timeline-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,b.jsx)(`span`,{className:`sr-only`,children:`Loading timeline…`}),[0,1,2,3].map(e=>(0,b.jsxs)(`div`,{className:`flex items-start gap-3`,style:{opacity:Math.max(.3,1-e*.18)},children:[(0,b.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-muted/70 animate-pulse mt-1.5 shrink-0`}),(0,b.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,b.jsx)(`div`,{className:`h-4 w-1/3 rounded bg-muted/70 animate-pulse`}),(0,b.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-muted/50 animate-pulse`})]})]},e))]}):(0,b.jsxs)(`div`,{ref:R,className:`relative overflow-auto h-full min-w-0`,children:[B>0&&(0,b.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:B},children:z?`Refreshing…`:`Pull to refresh`}),(0,b.jsx)(D,{schema:U}),V.isOverlay&&(0,b.jsx)(g,{...V,title:`Timeline Item`,children:e=>(0,b.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,b.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},N=t({ObjectTimeline:()=>M,ObjectTimelineRenderer:()=>$,Timeline:()=>P,TimelineContent:()=>z,TimelineDescription:()=>H,TimelineGantt:()=>G,TimelineGanttBar:()=>Z,TimelineGanttBarContent:()=>Q,TimelineGanttGrid:()=>J,TimelineGanttHeader:()=>K,TimelineGanttLabel:()=>X,TimelineGanttRow:()=>Y,TimelineGanttRowLabels:()=>q,TimelineHorizontal:()=>U,TimelineHorizontalItem:()=>W,TimelineItem:()=>I,TimelineMarker:()=>R,TimelineRenderer:()=>D,TimelineTime:()=>V,TimelineTitle:()=>B,timelineItemVariants:()=>F,timelineMarkerVariants:()=>L}),P=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`ol`,{ref:n,className:m(`relative ml-3 border-l border-gray-200`,e),...t}));P.displayName=`Timeline`;var F=v(`ml-6`,{variants:{density:{default:`mb-10`,compact:`mb-3`,comfortable:`mb-6`}},defaultVariants:{density:`default`}}),I=y.forwardRef(({className:e,density:t,...n},r)=>(0,b.jsx)(`li`,{ref:r,className:m(F({density:t}),e),...n}));I.displayName=`TimelineItem`;var L=v(`absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center`,{variants:{variant:{default:`bg-blue-200 border-blue-400`,success:`bg-emerald-200 border-emerald-500`,warning:`bg-amber-200 border-amber-500`,danger:`bg-red-200 border-red-500`,info:`bg-purple-200 border-purple-500`,todo:`bg-slate-200 border-slate-400`,"in-progress":`bg-blue-200 border-blue-500`,done:`bg-emerald-200 border-emerald-500`}},defaultVariants:{variant:`default`}}),R=y.forwardRef(({className:e,variant:t=`default`,...n},r)=>(0,b.jsx)(`div`,{ref:r,className:m(L({variant:t}),e),...n}));R.displayName=`TimelineMarker`;var z=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:e,...t}));z.displayName=`TimelineContent`;var B=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`h3`,{ref:n,className:m(`font-semibold text-lg mb-1`,e),...t}));B.displayName=`TimelineTitle`;var V=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`time`,{ref:n,className:m(`text-sm font-normal text-gray-500 mb-2 block`,e),...t}));V.displayName=`TimelineTime`;var H=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`p`,{ref:n,className:m(`text-base text-gray-700`,e),...t}));H.displayName=`TimelineDescription`;var U=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`relative flex overflow-x-auto py-8`,e),...t}));U.displayName=`TimelineHorizontal`;var W=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`shrink-0 w-64 relative`,e),...t}));W.displayName=`TimelineHorizontalItem`;var G=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`relative w-full border rounded-lg overflow-hidden`,e),...t}));G.displayName=`TimelineGantt`;var K=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`flex border-b bg-gray-50`,e),...t}));K.displayName=`TimelineGanttHeader`;var q=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`w-48 border-r bg-white`,e),...t}));q.displayName=`TimelineGanttRowLabels`;var J=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`flex-1 overflow-x-auto`,e),...t}));J.displayName=`TimelineGanttGrid`;var Y=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`flex items-center border-b min-h-12`,e),...t}));Y.displayName=`TimelineGanttRow`;var X=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`px-4 py-2 font-medium text-sm truncate`,e),...t}));X.displayName=`TimelineGanttLabel`;var Z=y.forwardRef(({className:e,start:t=0,width:n=100,variant:r=`default`,...i},a)=>(0,b.jsx)(`div`,{ref:a,className:m(`absolute h-8 rounded-md transition-colors cursor-pointer`,{default:`bg-blue-500 hover:bg-blue-600`,success:`bg-green-500 hover:bg-green-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,danger:`bg-red-500 hover:bg-red-600`,info:`bg-purple-500 hover:bg-purple-600`}[r],e),style:{left:`${t}%`,width:`${n}%`},...i}));Z.displayName=`TimelineGanttBar`;var Q=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(`div`,{ref:n,className:m(`px-2 py-1 text-white text-xs font-medium truncate`,e),...t}));Q.displayName=`TimelineGanttBarContent`;var $=({schema:e,...t})=>{let{dataSource:n}=c()||{};return(0,b.jsx)(M,{schema:e,dataSource:n,...t})};a.register(`object-timeline`,$,{namespace:`plugin-timeline`,label:`Object Timeline`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]}),a.register(`timeline`,$,{namespace:`view`,label:`Timeline View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]});export{N as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,t as r}from"./vendor-react-slxo-5GC.js";import{
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,t as r}from"./vendor-react-slxo-5GC.js";import{Bt as i,Ht as a,ot as o,q as s,zt as c}from"./framework-VeaoJc6L.js";import{Ac as l,Us as u,V as d,Vs as f}from"./ui-components-Pnfq_-xI.js";var p=e(n(),1),m=r();function h(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function g(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`)return e.name||e.fieldName||e.field||e.key}function _(e){let t=e.tree||e.filter?.tree||{},n=Array.isArray(e.fields)?e.fields:Array.isArray(t.fields)?t.fields:[];return{parentField:g(e.parentField??t.parentField),labelField:g(e.labelField??t.labelField??e.titleField)??`name`,fields:n.map(g).filter(e=>!!e),defaultExpandedDepth:e.defaultExpandedDepth??t.defaultExpandedDepth}}function v(e,t){let n=e?.fields;if(!n||typeof n!=`object`)return;let r;for(let[e,i]of Object.entries(n)){if(i?.type===`tree`)return e;let n=i?.reference||i?.reference_to||i?.referenceTo;!r&&(i?.type===`lookup`||i?.type===`master_detail`)&&n&&t&&n===t&&(r=e)}return r}function y(e){let t=e?.id??e?._id;return t==null?void 0:String(t)}function b(e,t){if(!t)return;let n=e?.[t];if(n!=null){if(typeof n==`object`){let e=n.id??n._id;return e==null?void 0:String(e)}return String(n)}}function x(e,t){let n=new Map,r=[];for(let t of e){let e=y(t);e!=null&&(n.set(e,{id:e,record:t,depth:0,children:[]}),r.push(e))}let i=[];for(let e of r){let r=n.get(e),a=b(r.record,t),o=a==null?void 0:n.get(a);o&&o!==r?o.children.push(r):i.push(r)}let a=(e,t)=>{for(let n of e)n.depth=t,a(n.children,t+1)};return a(i,0),i}function S(e,t){let n=[],r=e=>{for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)};return r(e),n}function C(e,t){let n=new Set,r=e=>{for(let i of e)i.children.length!==0&&(t==null||i.depth<t)&&(n.add(i.id),r(i.children))};return r(e),n}function w(e){return e==null?``:String(typeof e==`object`?e.name??e.label??e.id??e._id??``:e)}var T=({schema:e,dataSource:t,className:n,onRowClick:r,...a})=>{let[o,g]=(0,p.useState)([]),[y,b]=(0,p.useState)(!0),[T,E]=(0,p.useState)(null),[D,O]=(0,p.useState)(null),k=(0,p.useMemo)(()=>h(e),[e]),A=Array.isArray(a.data)||Array.isArray(e.data)||k?.provider===`value`;(0,p.useEffect)(()=>{let n=!1;return A||(async()=>{try{if(!t||typeof t.getObjectSchema!=`function`)return;let r=k?.provider===`object`?k.object:e.objectName;if(!r)return;let i=await t.getObjectSchema(r);n||O(i)}catch(e){console.error(`[ObjectTree] Failed to fetch object schema:`,e)}})(),()=>{n=!0}},[e.objectName,t,k,A]),(0,p.useEffect)(()=>{let n=!1;return(async()=>{try{if(b(!0),E(null),k?.provider===`object`&&t&&typeof t.find==`function`){let r=c(D?.fields),a=await t.find(k.object,{$filter:e.filter,...r.length>0?{$expand:r}:{}});n||(g(i(a)),b(!1));return}let r=a.data??e.data;if(Array.isArray(r)){n||(g(r),b(!1));return}if(k?.provider===`value`){n||(g(k.items??[]),b(!1));return}n||(g([]),b(!1))}catch(e){n||(E(e),b(!1))}})(),()=>{n=!0}},[k,t,e.filter,D,a.data]);let j=(0,p.useMemo)(()=>_(e),[e]),M=(0,p.useMemo)(()=>j.parentField??v(D,e.objectName),[j.parentField,D,e.objectName]),N=(0,p.useMemo)(()=>x(o,M),[o,M]),[P,F]=(0,p.useState)(new Set);(0,p.useEffect)(()=>{F(C(N,j.defaultExpandedDepth))},[N,j.defaultExpandedDepth]);let I=e=>F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),L=(0,p.useMemo)(()=>S(N,P),[N,P]),R=e=>D?.fields?.[e]?.label||e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),z=s({navigation:e.navigation,objectName:e.objectName,onRowClick:r});return T?(0,m.jsx)(`div`,{className:l(`flex items-center justify-center h-40 text-destructive`,n),children:(0,m.jsxs)(`p`,{children:[`Failed to load tree: `,T.message]})}):y?(0,m.jsx)(`div`,{className:l(`flex items-center justify-center h-40 text-muted-foreground`,n),children:(0,m.jsx)(`p`,{children:`Loading…`})}):o.length===0?(0,m.jsx)(`div`,{className:l(`flex items-center justify-center h-40 text-muted-foreground`,n),children:(0,m.jsx)(`p`,{children:`No records`})}):(0,m.jsxs)(`div`,{className:l(`w-full overflow-auto`,n),"data-testid":`object-tree`,children:[(0,m.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,m.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:R(j.labelField)}),j.fields.filter(e=>e!==j.labelField).map(e=>(0,m.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:R(e)},e))]})}),(0,m.jsx)(`tbody`,{children:L.map(e=>{let t=e.children.length>0,n=P.has(e.id);return(0,m.jsxs)(`tr`,{className:`border-b hover:bg-accent/50 cursor-pointer`,"data-testid":`object-tree-row`,"data-depth":e.depth,onClick:t=>z.handleClick(e.record,t),children:[(0,m.jsx)(`td`,{className:`px-3 py-2`,children:(0,m.jsxs)(`div`,{className:`flex items-center gap-1`,style:{paddingLeft:`${e.depth*20}px`},children:[t?(0,m.jsx)(`button`,{type:`button`,"aria-label":n?`Collapse`:`Expand`,className:`flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted`,onClick:t=>{t.stopPropagation(),I(e.id)},children:n?(0,m.jsx)(u,{className:`h-4 w-4`}):(0,m.jsx)(f,{className:`h-4 w-4`})}):(0,m.jsx)(`span`,{className:`inline-block h-5 w-5`}),(0,m.jsx)(`span`,{className:`truncate`,children:w(e.record[j.labelField])||`—`})]})}),j.fields.filter(e=>e!==j.labelField).map(t=>(0,m.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:w(e.record[t])},t))]},e.id)})})]}),z.isOverlay&&(0,m.jsx)(d,{...z,title:`Record Details`,children:e=>(0,m.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,m.jsxs)(`div`,{className:`flex flex-col`,children:[(0,m.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,m.jsx)(`span`,{className:`text-sm`,children:w(t)||`—`})]},e))})})]})},E=t({ObjectTree:()=>T,ObjectTreeRenderer:()=>D}),D=({schema:e,...t})=>{let{dataSource:n}=o()||{};return(0,m.jsx)(T,{schema:e,dataSource:n,...t})},O=[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`tree`,type:`object`,label:`Tree Config`,description:`parentField, labelField, fields, defaultExpandedDepth`}];a.register(`object-tree`,D,{namespace:`plugin-tree`,label:`Object Tree`,category:`view`,inputs:O}),a.register(`tree`,D,{namespace:`view`,label:`Tree View`,category:`view`,inputs:O});export{E as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{Ht as r,Y as i,l as a,rt as o,zt as s}from"./framework-VeaoJc6L.js";import{$i as c,$n as l,Ac as u,An as d,Cn as f,Di as p,Dn as m,Ei as h,En as g,Fn as _,Ft as v,Gn as y,Ha as b,Io as x,It as S,Jn as C,Jr as w,Jt as T,Kn as ee,Kt as E,Lt as D,Mi as O,Mn as k,Nn as A,On as te,Pa as ne,Pn as re,Pt as ie,Sn as ae,Sr as j,Ti as M,Tn as oe,To as se,Ua as N,Us as ce,V as le,Va as P,Wn as ue,Ws as F,Xa as I,Xi as de,Xo as fe,Xt as L,Yn as pe,Yt as R,Z as z,_o as me,an as B,bn as V,cn as H,ct as U,dt as he,ea as ge,ec as W,fn as G,gn as K,hi as _e,ii as ve,jn as ye,kc as be,ki as xe,kn as Se,kr as q,li as J,ls as Ce,mn as we,on as Te,or as Y,pn as Ee,qn as X,qt as Z,ra as De,sn as Oe,so as ke,ut as Ae,vi as je,vn as Me,vo as Ne,wn as Pe,wr as Fe,xc as Ie,xn as Le,yc as Re,yn as ze,yo as Be,za as Ve,zt as He}from"./ui-components-Pnfq_-xI.js";import{i as Ue}from"./vendor-ui-utils-C1OpMExs.js";import{t as We}from"./plugin-form-EGV_mlKM.js";import{_ as Ge,a as Ke,c as qe,d as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt,v as nt,y as rt}from"./vendor-dndkit-0M_nRjzm.js";import{r as it}from"./plugin-grid-CddzO4VP.js";var Q=e(t(),1),$=n(),at={list:`List`,detail:`Detail`,grid:`Grid`,kanban:`Kanban`,calendar:`Calendar`,timeline:`Timeline`,map:`Map`,gallery:`Gallery`,gantt:`Gantt`,tree:`Tree`},ot={list:P,detail:x,grid:Ne,kanban:I,calendar:W,timeline:be,map:ne,gallery:ke,gantt:_e,tree:b},st=Ue(`flex gap-4`,{variants:{position:{top:`flex-col`,bottom:`flex-col-reverse`,left:`flex-row`,right:`flex-row-reverse`}},defaultVariants:{position:`top`}}),ct=Ue(`w-full`,{variants:{orientation:{horizontal:`w-full`,vertical:`w-48`}},defaultVariants:{orientation:`horizontal`}}),lt=Ue(`flex gap-2`,{variants:{orientation:{horizontal:`flex-row flex-wrap`,vertical:`flex-col`}},defaultVariants:{orientation:`horizontal`}}),ut=Ue(``,{variants:{orientation:{horizontal:``,vertical:`flex h-auto flex-col items-stretch`}},defaultVariants:{orientation:`horizontal`}});function dt(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}var ft={Home:`House`};function pt(e){if(!e)return null;let t=dt(e);return Fe[ft[t]||t]||null}function mt(e){return e.label?e.label:at[e.type]||e.type}function ht(e){return e.icon?pt(e.icon):ot[e.type]||null}function gt(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}var _t={share:M,settings:h,duplicate:Ce,delete:w},vt={share:`Share`,settings:`Settings`,duplicate:`Duplicate`,delete:`Delete`},yt=({schema:e,className:t,onViewChange:n,onCreateView:r,onViewAction:a,createViewLabel:o=`Create view`,...s})=>{let c=Q.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:``}`,[e.id,e.storageKey]),[l,d]=Q.useState(()=>gt(e));Q.useEffect(()=>{if(e.activeView){d(e.activeView);return}if(e.persistPreference)try{let t=localStorage.getItem(c);if(t){let n=e.views.find(e=>e.type===t)?.type;n&&d(n)}}catch{}},[e.activeView,e.persistPreference,e.views,c]),Q.useEffect(()=>{if(!(!e.persistPreference||!l||e.activeView))try{localStorage.setItem(c,l)}catch{}},[l,e.activeView,e.persistPreference,c]);let f=Q.useCallback(t=>{n?.(t),e.onViewChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:t}}))},[n,e.onViewChange]),p=Q.useCallback(e=>{d(e),f(e)},[f]),m=l||e.views?.[0]?.type,h=m||``,g=e.views.find(e=>e.type===m)||e.views?.[0],_=e.variant||`tabs`,v=e.position||`top`,y=v===`left`||v===`right`,b=y?`vertical`:`horizontal`,x=e.viewActions&&e.viewActions.length>0?(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:e.viewActions.map((e,t)=>{let n=e.icon&&pt(e.icon)||_t[e.type];return(0,$.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a?.(e.type,m),title:vt[e.type]||e.type,children:n?(0,$.jsx)(n,{className:`h-3.5 w-3.5`}):null},`action-${e.type}-${t}`)})}):null,S=e.allowCreateView?(0,$.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>r?.(),title:o,children:(0,$.jsx)(de,{className:`h-3.5 w-3.5`})}):null,C=(0,$.jsxs)(`div`,{className:u(ct({orientation:b}),`flex items-center gap-1`),children:[_===`dropdown`&&(0,$.jsxs)(E,{value:h,onValueChange:e=>p(e),children:[(0,$.jsx)(R,{className:u(`w-full`,y?`h-10`:`h-9`),children:(0,$.jsx)(L,{placeholder:`Select view`})}),(0,$.jsx)(Z,{children:e.views.map((e,t)=>(0,$.jsx)(T,{value:e.type,children:mt(e)},`${e.type}-${t}`))})]}),_===`buttons`&&(0,$.jsx)(`div`,{className:u(lt({orientation:b})),children:e.views.map((e,t)=>{let n=e.type===m,r=ht(e);return(0,$.jsxs)(j,{type:`button`,size:`sm`,variant:n?`secondary`:`ghost`,className:u(`justify-start gap-2`,y?`w-full`:``),onClick:()=>p(e.type),children:[r?(0,$.jsx)(r,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:mt(e)})]},`${e.type}-${t}`)})}),_===`tabs`&&(0,$.jsx)(U,{value:h,onValueChange:e=>p(e),children:(0,$.jsx)(Ae,{className:u(ut({orientation:b})),children:e.views.map((e,t)=>{let n=ht(e);return(0,$.jsxs)(he,{value:e.type,className:u(`gap-2`,y?`justify-start`:``),children:[n?(0,$.jsx)(n,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:mt(e)})]},`${e.type}-${t}`)})})}),x,S]}),w=g?.schema?Array.isArray(g.schema)?(0,$.jsx)(`div`,{className:`space-y-4`,children:g.schema.map((e,t)=>(0,$.jsx)(i,{schema:e,...s},`${g.type}-${t}`))}):(0,$.jsx)(i,{schema:g.schema,...s}):null;return(0,$.jsxs)(`div`,{className:u(st({position:v}),t),children:[(0,$.jsx)(`div`,{className:u(`shrink-0`,y?`flex flex-col`:`flex`),children:C}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:w})]})},bt=new Set([`created_at`,`created_by`,`updated_at`,`updated_by`,`organization_id`,`tenant_id`,`is_deleted`,`deleted_at`]);function xt(e){let t=e?.fields;if(!t||typeof t!=`object`||Array.isArray(t))return 0;let n=0;for(let[e,r]of Object.entries(t))r?.hidden!==!0&&(bt.has(e)||n++);return n}function St(e,t={}){if(t.viewport===`mobile`)return`page`;let n=t.pageThreshold??12;return xt(e)>=n?`page`:`drawer`}var Ct={sm:480,md:720,lg:960,xl:1200,full:1600};function wt(e){let t=xt(e);return t<=3?`sm`:t<=8?`md`:t<=15?`lg`:`xl`}function Tt(e,t){return`min(92vw, ${Ct[!e||e===`auto`?wt(t):e]}px)`}function Et(e,t,n={}){let r=St(e,n);return t===`view`?{container:r===`page`?`route`:`overlay`,surface:r,size:`auto`}:r===`page`?{container:`overlay`,surface:`modal`,size:`full`}:{container:`overlay`,surface:r,size:`auto`}}var Dt=i;function Ot(){try{let{t:e}=a(),t=e(`console.objectView.new`);return t===`console.objectView.new`?`New`:t}catch{return`New`}}var kt=({schema:e,dataSource:t,className:n,views:r,activeViewId:i,onViewChange:a,onRowClick:o,onEdit:c,renderListView:l,hideNamedViewTabs:d,toolbarAddon:p,onCreateView:h,onViewAction:_})=>{let v=Ot(),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null);S.current=b;let[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(`create`),[O,k]=(0,Q.useState)(null),[A,te]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!(!t?.onMutation||!e.objectName)&&!l)return t.onMutation(t=>{t.resource===e.objectName&&te(e=>e+1)})},[t,e.objectName,l]);let[ne,re]=(0,Q.useState)([]),[ie,ae]=(0,Q.useState)(!1),[M,se]=(0,Q.useState)({}),[N,ce]=(0,Q.useState)([]),P=e.listViews,F=P!=null&&Object.keys(P).length>0,[I,fe]=(0,Q.useState)(()=>e.defaultListView&&P?.[e.defaultListView]?e.defaultListView:P&&Object.keys(P)[0]||``),L=(0,Q.useMemo)(()=>!F||!I?null:P[I]||null,[F,I,P]),R=(0,Q.useMemo)(()=>r&&r.length>0?r:null,[r]),z=R!=null&&R.length>0,me=i||R?.[0]?.id,B=R?.find(e=>e.id===me)||R?.[0],V=(0,Q.useMemo)(()=>L?.type?L.type:B?.type?B.type:e.defaultViewType||`grid`,[L,B,e.defaultViewType]),H=e.navigation;(0,Q.useEffect)(()=>{let n=!0;return e.objectName&&t&&(async()=>{try{let r=await t.getObjectSchema(e.objectName);n&&x(r)}catch(e){console.error(`Failed to fetch object schema:`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,Q.useEffect)(()=>{let n=!0;return(async()=>{if(!l&&V!==`grid`&&!(!t||!e.objectName)){ae(!0);try{let r=L?.filter||B?.filter||e.table?.defaultFilters||[],i=Object.entries(M).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>[e,`=`,t]),a=[];a=r.length>0&&i.length>0?[`and`,...r,...i]:i.length===1?i[0]:i.length>1?[`and`,...i]:r;let o=N.length>0?N.map(e=>({field:e.field,order:e.direction})):L?.sort||B?.sort||e.table?.defaultSort||void 0,c=s(S.current?.fields),l=await t.find(e.objectName,{$filter:a.length>0?a:void 0,$orderby:o,$top:100,...c.length>0?{$expand:c}:{}}),u=[];Array.isArray(l)?u=l:l&&typeof l==`object`&&(Array.isArray(l.data)?u=l.data:Array.isArray(l.records)?u=l.records:Array.isArray(l.value)&&(u=l.value)),n&&re(u)}catch(e){console.error(`ObjectView data fetch error:`,e)}finally{n&&ae(!1)}}})(),()=>{n=!1}},[e.objectName,t,V,M,N,A,L,B,l]);let ge=He(),W=e.layout||St(b,{viewport:ge?`mobile`:`desktop`}),G=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},K=(0,Q.useCallback)(()=>{W===`page`&&e.onNavigate?e.onNavigate(`new`,`edit`):(D(`create`),k(null),T(!0))},[W,e]),_e=(0,Q.useCallback)(t=>{if(c){c(t);return}if(W===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`edit`)}else D(`edit`),k(t),T(!0)},[W,e,c]),ve=(0,Q.useCallback)(t=>{if(W===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`view`)}else D(`view`),k(t),T(!0)},[W,e]),ye=(0,Q.useCallback)(t=>{if(o){o(t);return}if(H){if(H.mode===`none`||H.preventNavigation)return;if(H.mode===`new_window`||H.openNewTab){let n=t.id||t._id,r=`/${e.objectName}/${encodeURIComponent(String(n))}`;window.open(r,`_blank`);return}if(H.mode===`drawer`){D(`view`),k(t),T(!0);return}if(H.mode===`modal`){D(`view`),k(t),T(!0);return}if(H.mode===`page`){let n=t.id||t._id;e.onNavigate&&e.onNavigate(n,`view`);return}if(H.mode===`split`||H.mode===`popover`){D(`view`),k(t),T(!0);return}}G.read!==!1&&ve(t)},[o,H,G.read,ve,e]),be=(0,Q.useCallback)(e=>{te(e=>e+1)},[]),xe=(0,Q.useCallback)(e=>{te(e=>e+1)},[]),Se=(0,Q.useCallback)(()=>{T(!1),k(null),te(e=>e+1)},[]),q=(0,Q.useCallback)(()=>{T(!1),k(null)},[]);(0,Q.useCallback)(()=>{te(e=>e+1)},[]);let J=(0,Q.useMemo)(()=>!z||!R||R.length<=1?null:{type:`view-switcher`,variant:`tabs`,position:`top`,persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:B?.type||`grid`,activeView:B?.type||`grid`,views:R.map(e=>({type:e.type,label:e.label,icon:{kanban:`kanban`,calendar:`calendar`,map:`map`,gallery:`layout-grid`,timeline:`activity`,gantt:`gantt-chart`,grid:`table`,list:`list`,detail:`file-text`,chart:`bar-chart-3`}[e.type]||`table`})),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[z,R,B,e.objectName,e.allowCreateView,e.viewActions]),Ce=(0,Q.useCallback)(e=>{if(!R)return;let t=R.find(t=>t.type===e);t&&a&&a(t.id)},[R,a]),we=(0,Q.useCallback)(e=>{fe(e)},[]);(0,Q.useMemo)(()=>{if(e.showFilters===!1)return null;let t=e.filterableFields,n=b?.fields||{},r=(t?t.map(e=>[e,n[e]||{label:e}]):Object.entries(n).filter(([,e])=>!e.hidden).slice(0,8)).map(([e,t])=>{let n=t.type||`text`,r=`text`,i;return n===`number`||n===`currency`||n===`percent`?r=`number`:n===`boolean`||n===`toggle`?r=`boolean`:n===`date`||n===`datetime`?r=`date`:n===`select`||n===`status`||t.options?(r=`select`,i=(t.options||[]).map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})):(n===`lookup`||n===`master_detail`||n===`user`||n===`owner`)&&t.options&&t.options.length>0&&(r=`multi-select`,i=(t.options||[]).map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})),{field:e,label:t.label||e,type:r,placeholder:`Filter ${t.label||e}...`,...i?{options:i}:{}}});return r.length===0?null:{type:`filter-ui`,layout:`popover`,showClear:!0,showApply:!0,filters:r,values:M}},[e.showFilters,e.filterableFields,b,M]);let Te=e.showSort;(0,Q.useMemo)(()=>{if(Te===!1)return null;let e=b?.fields||{},t=Object.entries(e).filter(([,e])=>!e.hidden).slice(0,10).map(([e,t])=>({field:e,label:t.label||e}));return t.length===0?null:{type:`sort-ui`,variant:`dropdown`,multiple:!1,fields:t,sort:N}},[b,N,Te]);let Y=(0,Q.useCallback)(t=>{let n={objectName:e.objectName,fields:L?.columns||B?.columns||e.table?.fields,className:`h-full w-full`,showSearch:B?.showSearch??e.showSearch??!1,showSort:B?.showSort??e.showSort??!1,showFilters:B?.showFilters??e.showFilters??!1,striped:B?.striped??!1,bordered:B?.bordered??!1,color:B?.color},r=L?.options||B||{};switch(t){case`kanban`:{let e=r.kanban||{},t=e.groupByField||e.groupField||`status`,i=(Array.isArray(e.columns)&&e.columns.length>0?e.columns:n.fields)||[],{columns:a,groupByField:o,groupField:s,titleField:c,...l}=e;return{type:`object-kanban`,...n,groupBy:t,groupField:t,titleField:e.titleField||`name`,cardFields:i,...l}}case`calendar`:return{type:`object-calendar`,...n,startDateField:r.calendar?.startDateField||`start_date`,endDateField:r.calendar?.endDateField||`end_date`,titleField:r.calendar?.titleField||`name`,...r.calendar||{}};case`gallery`:return{type:`object-gallery`,...n,imageField:r.gallery?.imageField,titleField:r.gallery?.titleField||`name`,subtitleField:r.gallery?.subtitleField,...r.gallery||{}};case`timeline`:return{type:`object-timeline`,...n,dateField:r.timeline?.dateField||`created_at`,titleField:r.timeline?.titleField||`name`,...r.timeline||{}};case`gantt`:return{type:`object-gantt`,...n,startDateField:r.gantt?.startDateField||`start_date`,endDateField:r.gantt?.endDateField||`end_date`,progressField:r.gantt?.progressField||`progress`,dependenciesField:r.gantt?.dependenciesField||`dependencies`,...r.gantt||{}};case`map`:return{type:`object-map`,...n,locationField:r.map?.locationField||`location`,...r.map||{}};case`tree`:return{type:`object-tree`,...n,parentField:r.tree?.parentField,labelField:r.tree?.labelField||r.tree?.titleField||`name`,fields:r.tree?.fields||n.fields,defaultExpandedDepth:r.tree?.defaultExpandedDepth,...r.tree||{}};case`chart`:{let t=r.chart||{};if(t.dataset){let e=Array.isArray(t.dimensions)?t.dimensions:[],n=Array.isArray(t.values)?t.values:[];return{type:`object-chart`,dataset:t.dataset,dimensions:e,values:n,chartType:t.chartType||`bar`,xAxisKey:e[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let n=Array.isArray(t.yAxisFields)&&t.yAxisFields[0]||t.valueField||`value`,i=t.xAxisField||t.categoryField||`name`;return{type:`object-chart`,objectName:e.objectName,chartType:t.chartType||`bar`,aggregate:{field:n,function:t.aggregation||`count`,groupBy:i},xAxisKey:i,series:[{dataKey:n,label:n}],className:`h-[400px] w-full`}}default:return null}},[e.objectName,e.table?.fields,L,B]),Ee=(0,Q.useMemo)(()=>({type:`object-grid`,objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:L?.columns||B?.columns||e.table?.fields,columns:L?.columns||B?.columns||e.table?.columns,operations:{...G,create:!1},defaultFilters:L?.filter||B?.filter||e.table?.defaultFilters,defaultSort:L?.sort||B?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:B?.striped??e.table?.striped,bordered:B?.bordered??e.table?.bordered,className:e.table?.className}),[e,G,L,B]),X=()=>{let t=O?O.id||O._id:void 0;return{type:`object-form`,objectName:e.objectName,mode:E,recordId:t,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,readOnly:e.form?.readOnly||E===`view`,className:e.form?.className,subforms:e.form?.subforms,onSuccess:Se,onCancel:q}},Z=()=>{if(e.form?.title)return e.form.title;let t=b?.label||e.objectName;switch(E){case`create`:return`Create ${t}`;case`edit`:return`Edit ${t}`;case`view`:return`View ${t}`;default:return t}},De=(0,Q.useMemo)(()=>{let e=H?.width;return e?typeof e==`number`?`max-w-[${e}px]`:`max-w-[${e}]`:``},[H]),Oe=()=>(0,$.jsx)(f,{open:w,onOpenChange:T,direction:`right`,children:(0,$.jsxs)(Pe,{className:u(`w-full sm:max-w-2xl`,De),children:[(0,$.jsxs)(g,{children:[(0,$.jsx)(m,{children:Z()}),e.form?.description&&(0,$.jsx)(oe,{children:e.form.description})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:(0,$.jsx)(We,{schema:X(),dataSource:t})})]})}),ke=()=>(0,$.jsx)(ue,{open:w,onOpenChange:T,children:(0,$.jsxs)(y,{className:u(`max-w-2xl max-h-[90vh] overflow-y-auto`,De),children:[(0,$.jsxs)(C,{children:[(0,$.jsx)(pe,{children:Z()}),e.form?.description&&(0,$.jsx)(ee,{children:e.form.description})]}),(0,$.jsx)(We,{schema:X(),dataSource:t})]})}),je=(0,Q.useMemo)(()=>Object.keys(M).some(e=>M[e]!==void 0&&M[e]!==``&&M[e]!==null)?Object.entries(M).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>({field:e,operator:`equals`,value:t})):L?.filter||B?.filter||e.table?.defaultFilters,[M,L,B,e.table?.defaultFilters]),Me=(0,Q.useMemo)(()=>N.length>0?N:L?.sort||B?.sort||e.table?.defaultSort,[N,L,B,e.table?.defaultSort]),Ne=()=>{let n=`${e.objectName}-${I||B?.id||`default`}-${V}-${A}`;if(l)return l({schema:{type:`list-view`,objectName:e.objectName,viewType:V,fields:L?.columns||B?.columns||e.table?.fields,filters:je,sort:Me,rowHeight:B?.rowHeight,densityMode:B?.densityMode,groupBy:B?.groupBy,groupBy2:B?.groupBy2,grouping:B?.grouping,options:L?.options||B,showSearch:B?.showSearch??e.showSearch,showFilters:B?.showFilters??e.showFilters,showSort:B?.showSort??e.showSort,showHideFields:B?.showHideFields??e.showHideFields,showGroup:B?.showGroup??e.showGroup,showColor:B?.showColor??e.showColor,showDensity:B?.showDensity??e.showDensity,compactToolbar:B?.compactToolbar??e.compactToolbar,allowExport:B?.allowExport??e.allowExport,striped:B?.striped??e.striped,bordered:B?.bordered??e.bordered,color:B?.color??e.color,inlineEdit:B?.inlineEdit??e.inlineEdit,wrapHeaders:B?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:B?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:B?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:B?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:B?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:B?.fieldTextColor??e.fieldTextColor,prefixField:B?.prefixField??e.prefixField,showDescription:B?.showDescription??e.showDescription,navigation:B?.navigation??e.navigation,selection:B?.selection??e.selection,pagination:B?.pagination??e.pagination,searchableFields:B?.searchableFields??e.searchableFields,filterableFields:B?.filterableFields??e.filterableFields,resizable:B?.resizable??e.resizable,hiddenFields:B?.hiddenFields??e.hiddenFields,rowActions:B?.rowActions??e.rowActions,rowActionDefs:B?.rowActionDefs??e.rowActionDefs,bulkActions:B?.bulkActions??e.bulkActions,sharing:B?.sharing??e.sharing,addRecord:B?.addRecord??e.addRecord,conditionalFormatting:B?.conditionalFormatting??e.conditionalFormatting,userFilters:B?.userFilters??e.userFilters,showRecordCount:B?.showRecordCount??e.showRecordCount,allowPrinting:B?.allowPrinting??e.allowPrinting,virtualScroll:B?.virtualScroll??e.virtualScroll,emptyState:B?.emptyState??e.emptyState,aria:B?.aria??e.aria,refreshTrigger:A},dataSource:t,onEdit:_e,onRowClick:ye,className:`h-full`,refreshKey:A});if(V!==`grid`){let e=Y(V);if(e&&Dt)return(0,$.jsx)(Dt,{schema:e,dataSource:t,data:ne,loading:ie},n);if(!Dt)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40 text-muted-foreground`,children:(0,$.jsxs)(`p`,{children:[`SchemaRenderer not available. Install @object-ui/react to render `,V,` views.`]})})}return(0,$.jsx)(it,{schema:Ee,dataSource:t,onRowClick:ye,onEdit:G.update===!1?void 0:_e,onDelete:G.delete===!1?void 0:be,onBulkDelete:G.delete===!1?void 0:xe},n)},Fe=()=>{if(d||!F)return null;let e=Object.entries(P);return e.length<=1?null:(0,$.jsx)(U,{value:I,onValueChange:we,className:`w-full`,children:(0,$.jsx)(Ae,{className:`w-auto`,children:e.map(([e,t])=>(0,$.jsx)(he,{value:e,className:`text-sm`,children:t.label||e},e))})})},Ie=()=>{let t=e.showCreate!==!1&&G.create!==!1,n=e.showViewSwitcher===!0,r=Fe();return!r&&!n&&!t&&!p?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(n||t||p)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:n&&J&&(0,$.jsx)(yt,{schema:J,onViewChange:Ce,onCreateView:h,onViewAction:_,className:`overflow-x-auto`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,t&&(0,$.jsxs)(j,{size:`sm`,onClick:K,children:[(0,$.jsx)(de,{className:`h-4 w-4`}),v]})]})]})]})},Le=H?.mode===`modal`?`modal`:H?.mode===`drawer`?`drawer`:H?.mode===`split`?`split`:H?.mode===`popover`?`popover`:W,Re=e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsx)(We,{schema:X(),dataSource:t})}),ze=(0,Q.useCallback)(e=>{e||q()},[q]);if(Le===`split`){let t=b?.label||e.objectName;return(0,$.jsxs)(`div`,{className:u(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:Ie()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:w&&O?(0,$.jsx)(le,{isOpen:w,selectedRecord:O,mode:`split`,close:q,setIsOpen:ze,width:H?.width,isOverlay:!0,title:`${t} Detail`,mainContent:(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:Ne()}),children:Re}):Ne()})]})}return(0,$.jsxs)(`div`,{className:u(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:Ie()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:Ne()}),Le===`drawer`&&Oe(),Le===`modal`&&ke(),Le===`popover`&&w&&O&&(0,$.jsx)(le,{isOpen:w,selectedRecord:O,mode:`popover`,close:q,setIsOpen:ze,width:H?.width,isOverlay:!0,title:Z(),children:Re})]})},At=Ue(`flex`,{variants:{layout:{inline:`flex-col space-y-4`,popover:`items-center`,drawer:`items-center`}},defaultVariants:{layout:`inline`}}),jt=e=>e==null||e===``?!0:Array.isArray(e)?e.length===0:typeof e==`object`?Object.values(e).every(e=>e==null||e===``):!1,Mt=e=>Array.isArray(e)?{start:e[0]||``,end:e[1]||``}:e&&typeof e==`object`?{start:e.start||``,end:e.end||``}:{start:``,end:``},Nt=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(e.values||{}),[a,o]=Q.useState(!1);Q.useEffect(()=>{e.values&&i(e.values)},[e.values]);let s=Q.useCallback(t=>{n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:t}}))},[n,e.onChange]),c=Q.useCallback((t,n)=>{let a={...r,[t]:n};i(a),e.showApply||s(a)},[s,e.showApply,r]),d=Q.useCallback(()=>{let t={};if(i(t),e.showApply){s(t);return}s(t)},[s,e.showApply]),p=Q.useCallback(()=>{s(r),o(!1)},[s,r]),h=Q.useMemo(()=>Object.values(r).filter(e=>!jt(e)).length,[r]),_=e=>{let t=e.label||e.field,n=e.placeholder||`Filter by ${t}`;switch(e.type){case`number`:return(0,$.jsx)(H,{type:`number`,value:r[e.field]??``,placeholder:n,onChange:t=>{let n=t.target.value,r=n===``?``:Number(n);c(e.field,r)}});case`select`:return(0,$.jsxs)(E,{value:r[e.field]===void 0?``:String(r[e.field]),onValueChange:t=>{let n=e.options?.find(e=>String(e.value)===t);c(e.field,n?n.value:t)},children:[(0,$.jsx)(R,{children:(0,$.jsx)(L,{placeholder:n})}),(0,$.jsx)(Z,{children:e.options?.map(e=>(0,$.jsx)(T,{value:String(e.value),children:e.label},String(e.value)))})]});case`multi-select`:{let t=r[e.field],n=Array.isArray(t)?t:t?[t]:[];return(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2`,children:e.options?.map(t=>{let r=n.map(String).includes(String(t.value));return(0,$.jsxs)(`label`,{className:u(`flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer`,r?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,$.jsx)(l,{checked:r,onCheckedChange:r=>{let i=r?[...n,t.value]:n.filter(e=>String(e)!==String(t.value));c(e.field,i)}}),(0,$.jsx)(`span`,{className:`truncate`,children:t.label})]},String(t.value))})})}case`date`:return(0,$.jsx)(H,{type:`date`,value:r[e.field]??``,onChange:t=>c(e.field,t.target.value)});case`date-range`:{let t=Mt(r[e.field]);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{type:`date`,value:t.start??``,onChange:n=>{c(e.field,{...t,start:n.target.value})}}),(0,$.jsx)(H,{type:`date`,value:t.end??``,onChange:n=>{c(e.field,{...t,end:n.target.value})}})]})}case`boolean`:return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{checked:!!r[e.field],onCheckedChange:t=>c(e.field,!!t)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Enabled`})]});default:return(0,$.jsx)(H,{value:r[e.field]??``,placeholder:n,onChange:t=>c(e.field,t.target.value)})}},v=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.filters.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(G,{className:`text-xs text-muted-foreground`,children:e.label||e.field}),_(e)]},e.field))}),(e.showApply||e.showClear)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t pt-3`,children:[e.showClear&&(0,$.jsx)(j,{type:`button`,variant:`ghost`,size:`sm`,onClick:d,children:`Clear`}),e.showApply&&(0,$.jsx)(j,{type:`button`,size:`sm`,onClick:p,children:`Apply`})]})]}),y=e.layout||`inline`;return y===`popover`?(0,$.jsx)(`div`,{className:u(At({layout:y}),t),children:(0,$.jsxs)(B,{open:a,onOpenChange:o,children:[(0,$.jsx)(Oe,{asChild:!0,children:(0,$.jsxs)(j,{type:`button`,variant:h>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(je,{className:`h-4 w-4`}),`Filters`,h>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:h})]})}),(0,$.jsx)(Te,{align:`start`,className:`w-[520px] p-4`,children:v})]})}):y===`drawer`?(0,$.jsxs)(`div`,{className:u(At({layout:y}),t),children:[(0,$.jsxs)(j,{type:`button`,variant:h>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,onClick:()=>o(!0),children:[(0,$.jsx)(je,{className:`h-4 w-4`}),`Filters`,h>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:h})]}),(0,$.jsx)(f,{open:a,onOpenChange:o,children:(0,$.jsxs)(Pe,{children:[(0,$.jsxs)(g,{children:[(0,$.jsx)(m,{children:`Filters`}),(0,$.jsx)(oe,{children:`Refine the data with advanced filters.`})]}),(0,$.jsx)(`div`,{className:`px-4 pb-6`,children:v})]})})]}):(0,$.jsxs)(`div`,{className:u(At({layout:y}),t),children:[v,!e.showApply&&e.showClear&&(0,$.jsxs)(j,{type:`button`,variant:`ghost`,size:`sm`,className:`gap-2`,onClick:d,children:[(0,$.jsx)(q,{className:`h-3.5 w-3.5`}),`Clear filters`]})]})},Pt=Ue(``,{variants:{variant:{buttons:`flex flex-wrap gap-2`,dropdown:`flex flex-wrap items-center gap-3`,builder:`space-y-3`}},defaultVariants:{variant:`dropdown`}}),Ft=e=>e?e.map(e=>({field:e.field,direction:e.direction})):[],It=e=>e.map(e=>({id:`${e.field}-${e.direction}`,field:e.field,order:e.direction})),Lt=e=>e.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})),Rt=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(()=>Ft(e.sort)),[a,o]=Q.useState(()=>It(Ft(e.sort)));Q.useEffect(()=>{let t=Ft(e.sort);i(t),o(It(t))},[e.sort]);let s=Q.useCallback(t=>{i(t),n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:t}}))},[n,e.onChange]),c=Q.useCallback(t=>{let n=r.find(e=>e.field===t),i=!!e.multiple;if(!n){s(i?[...r,{field:t,direction:`asc`}]:[{field:t,direction:`asc`}]);return}if(n.direction===`asc`){s(r.map(e=>e.field===t?{...e,direction:`desc`}:e));return}s(r.filter(e=>e.field!==t))},[s,e.multiple,r]);if((e.variant||`dropdown`)===`buttons`)return(0,$.jsx)(`div`,{className:u(Pt({variant:`buttons`}),t),children:e.fields.map(e=>{let t=r.find(t=>t.field===e.field);return(0,$.jsxs)(j,{type:`button`,variant:t?`secondary`:`outline`,size:`sm`,onClick:()=>c(e.field),className:`gap-2`,children:[(0,$.jsx)(`span`,{children:e.label||e.field}),t&&(0,$.jsx)(Re,{className:u(`h-3.5 w-3.5 motion-safe:transition-transform motion-safe:duration-200`,t.direction===`desc`&&`rotate-180`),"aria-label":t.direction===`asc`?`ascending`:`descending`})]},e.field)})});if(e.multiple)return(0,$.jsx)(`div`,{className:u(Pt({variant:`builder`}),t),children:(0,$.jsx)(z,{fields:e.fields.map(e=>({value:e.field,label:e.label||e.field})),value:a,onChange:e=>{o(e),s(Lt(e))}})});let l=r[0];return(0,$.jsxs)(`div`,{className:u(Pt({variant:`dropdown`}),t),children:[(0,$.jsxs)(E,{value:l?.field||``,onValueChange:e=>{if(!e){s([]);return}s([{field:e,direction:l?.direction||`asc`}])},children:[(0,$.jsx)(R,{className:`w-56`,children:(0,$.jsx)(L,{placeholder:`Select field`})}),(0,$.jsx)(Z,{children:e.fields.map(e=>(0,$.jsx)(T,{value:e.field,children:e.label||e.field},e.field))})]}),(0,$.jsxs)(E,{value:l?.direction||`asc`,onValueChange:e=>{l?.field&&s([{field:l.field,direction:e}])},children:[(0,$.jsx)(R,{className:`w-36`,children:(0,$.jsx)(L,{})}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(T,{value:`asc`,children:`Ascending`}),(0,$.jsx)(T,{value:`desc`,children:`Descending`})]})]})]})};function zt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function Bt(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}var Vt=({objectName:e,viewId:t=`default`,baseUrl:n,onShare:r,className:i})=>{let[a,o]=Q.useState(null),[s,c]=Q.useState(!1),[l,d]=Q.useState(!1),[f,p]=Q.useState(``),[m,h]=Q.useState(``),g=n??(typeof window<`u`?window.location.origin:``),_=Q.useCallback(()=>{let n=Bt(g,e,t,zt());o(n),c(!1);let i=m?new Date(Date.now()+parseInt(m,10)*864e5).toISOString():void 0;r?.(n,{password:f||void 0,expiresAt:i})},[g,e,t,r,f,m]),v=Q.useCallback(async()=>{if(a)try{await navigator.clipboard.writeText(a),c(!0),setTimeout(()=>c(!1),2e3)}catch{let e=document.createElement(`textarea`);e.value=a,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),c(!0),setTimeout(()=>c(!1),2e3)}},[a]);return(0,$.jsxs)(B,{open:l,onOpenChange:d,children:[(0,$.jsx)(Oe,{asChild:!0,children:(0,$.jsxs)(j,{variant:`outline`,size:`sm`,className:u(`gap-2`,i),children:[(0,$.jsx)(M,{className:`h-4 w-4`}),`Share`]})}),(0,$.jsxs)(Te,{className:`w-96 space-y-4`,align:`end`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-medium`,children:`Share View`}),(0,$.jsx)(Y,{variant:`secondary`,className:`text-xs`,children:`Read-only`})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Generate a public link to share this view. Recipients can view data without logging in.`})]}),a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{value:a,readOnly:!0,className:`h-8 text-xs`,onClick:e=>e.target.select()}),(0,$.jsx)(j,{variant:`outline`,size:`sm`,onClick:v,className:`shrink-0 gap-1`,children:s?(0,$.jsx)(F,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(Ce,{className:`h-4 w-4`})})]}),(f||m)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[f&&(0,$.jsxs)(Y,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(Ve,{className:`h-3 w-3`}),`Password protected`]}),m&&(0,$.jsxs)(Y,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(W,{className:`h-3 w-3`}),`Expires in `,m,` day`,m===`1`?``:`s`]})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(Ve,{className:`h-3.5 w-3.5`}),`Password protection (optional)`]}),(0,$.jsx)(H,{type:`password`,value:f,onChange:e=>p(e.target.value),placeholder:`Enter password...`,className:`h-8 text-xs`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(W,{className:`h-3.5 w-3.5`}),`Expires after (optional)`]}),(0,$.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`w-full h-8 text-xs rounded-md border border-input bg-background px-3`,children:[(0,$.jsx)(`option`,{value:``,children:`Never`}),(0,$.jsx)(`option`,{value:`1`,children:`1 day`}),(0,$.jsx)(`option`,{value:`7`,children:`7 days`}),(0,$.jsx)(`option`,{value:`30`,children:`30 days`}),(0,$.jsx)(`option`,{value:`90`,children:`90 days`})]})]}),(0,$.jsxs)(j,{onClick:_,className:`w-full gap-2`,size:`sm`,children:[(0,$.jsx)(M,{className:`h-4 w-4`}),`Generate Link`]})]})]})]})};function Ht(){try{let{t:e}=a();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:i}}catch{return(e,t)=>t}}var Ut={private:0,team:1,organization:2,public:3},Wt=8,Gt=({id:e,disabled:t,children:n})=>{let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=Xe({id:e,disabled:t,attributes:{role:`tab`,roleDescription:`view tab`,tabIndex:0}});return(0,$.jsx)($.Fragment,{children:n({setNodeRef:a,style:{transform:rt.Transform.toString(o),transition:s,zIndex:c?10:void 0,opacity:c?.5:void 0},listeners:i,attributes:r,isDragging:c})})},Kt=({views:e,activeViewId:t,onViewChange:n,viewTypeIcons:r={},config:i={},onAddView:a,onRenameView:o,onDuplicateView:s,onDeleteView:l,onSetDefaultView:f,onShareView:m,onSaveAsView:h,onPinView:g,onReorderViews:y,onChangeViewType:b,onConfigView:x,onManageViews:C,availableViewTypes:T,hasUnsavedChanges:ee=!1,onResetChanges:E,className:ne})=>{let{showAddButton:oe=!0,inlineRename:le=!0,contextMenu:P=!0,reorderable:ue=!1,maxVisibleTabs:F=4,showIndicators:L=!0,showSaveAsView:pe=!0,showPinnedSection:R=!0,showVisibilityGroups:z=!1}=i,B=Ht(),[U,he]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(``),_e=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{U&&_e.current&&(_e.current.focus(),_e.current.select())},[U]);let be=(0,Q.useCallback)(t=>{if(!le||!o)return;let n=e.find(e=>e.id===t);n&&(n.readonly||(he(t),G(n.label)))},[le,o,e]),xe=(0,Q.useCallback)(()=>{U&&W.trim()&&o&&o(U,W.trim()),he(null),G(``)},[U,W,o]),q=(0,Q.useCallback)(()=>{he(null),G(``)},[]),Te=(0,Q.useMemo)(()=>e.length>0&&e.every(e=>!!e.readonly),[e]),Y=(0,Q.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{if(R){let n=+!!e.isPinned,r=+!!t.isPinned;if(n!==r)return r-n}if(z){let n=Ut[e.visibility||`public`]??Ut.public,r=Ut[t.visibility||`public`]??Ut.public;if(n!==r)return n-r}return 0}),t},[e,R,z]),{visibleViews:X,overflowViews:Z}=(0,Q.useMemo)(()=>{let e=Y.slice(0,F),n=Y.slice(F),r=n.findIndex(e=>e.id===t);if(r===-1)return{visibleViews:e,overflowViews:n};let i=n[r],a=e.length>0?[...e.slice(0,-1),i]:[i],o=e.length>0?e[e.length-1]:null,s=n.filter((e,t)=>t!==r);return o&&s.unshift(o),{visibleViews:a,overflowViews:s}},[Y,F,t]),Oe=nt(Ge(Je,{activationConstraint:{distance:Wt}}),Ge(tt)),ke=(0,Q.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!y)return;let r=Y.findIndex(e=>e.id===t.id),i=Y.findIndex(e=>e.id===n.id);r===-1||i===-1||y(Ye(Y,r,i).map(e=>e.id))},[Y,y]),Ae=ve,je=(0,Q.useCallback)(e=>{if(!z||e===0)return!1;let t=X[e-1],n=X[e],r=e=>e.visibility===`private`;return r(t)&&!r(n)},[z,X]),Ne=(e,i)=>{let a=e.id===t,h=r[e.type]||Ae,S=U===e.id,ee=L&&(e.hasActiveFilters||e.hasActiveSort),E=je(i),O=!!e.readonly,ne=(e=>z?e.visibility===`private`?(0,$.jsx)(Ve,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):e.visibility?(0,$.jsx)(Be,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):null:null)(e),j=t=>(0,$.jsxs)(`div`,{"data-testid":`view-tab-${e.id}`,role:`tab`,tabIndex:0,"aria-selected":a,onClick:()=>!S&&n(e.id),onDoubleClick:()=>be(e.id),onKeyDown:t=>{!S&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id))},...t?.listeners??{},...t?.attributes??{},className:u(`group/tab inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap relative outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?.isDragging?`cursor-grabbing`:`cursor-pointer`,a?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-border`),children:[ue&&y&&(0,$.jsx)(`span`,{"data-testid":`view-tab-drag-handle-${e.id}`,"aria-hidden":`true`,className:u(`text-muted-foreground transition-opacity pointer-events-none`,`opacity-0 group-hover/tab:opacity-100`,t?.isDragging&&`opacity-100`),children:(0,$.jsx)(me,{className:`h-3 w-3`})}),R&&e.isPinned&&(0,$.jsx)(c,{"data-testid":`view-tab-pin-indicator-${e.id}`,className:`h-3 w-3 text-primary shrink-0`}),ne,(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),S?(0,$.jsx)(H,{ref:_e,"data-testid":`view-tab-rename-input-${e.id}`,value:W,onChange:e=>G(e.target.value),onBlur:xe,onKeyDown:e=>{e.key===`Enter`&&xe(),e.key===`Escape`&&q()},className:`h-5 w-24 px-1 py-0 text-sm border-none focus-visible:ring-1`,onClick:e=>e.stopPropagation()}):(0,$.jsx)(`span`,{children:e.label}),O&&!Te&&(0,$.jsxs)(ie,{children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(Ve,{"data-testid":`view-tab-readonly-${e.id}`,"aria-label":B(`view.readonlyAriaLabel`,`Read-only view`),className:`h-3 w-3 text-muted-foreground shrink-0`})}),(0,$.jsx)(v,{side:`bottom`,className:`text-xs`,children:e.readonlyReason||B(`view.readonlyTooltip`,`System view — defined in code, read-only.`)})]}),ee&&(0,$.jsxs)(ie,{children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsxs)(`span`,{"data-testid":`view-tab-indicator-${e.id}`,className:`ml-1 inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary shrink-0`,children:[e.hasActiveFilters&&(0,$.jsx)(se,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(Ie,{className:`h-2.5 w-2.5`})]})}),(0,$.jsx)(v,{side:`bottom`,className:`text-xs`,children:[e.hasActiveFilters&&`Active filters`,e.hasActiveSort&&`Active sort`].filter(Boolean).join(`, `)})]}),e.isDefault&&(0,$.jsx)(J,{className:`h-3 w-3 text-amber-500 fill-amber-500 shrink-0`}),a&&(x||o||s||l)&&(0,$.jsxs)(Ee,{children:[(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"data-testid":`view-tab-actions-${e.id}`,className:`ml-0.5 h-4 w-4 flex items-center justify-center rounded hover:bg-accent shrink-0 opacity-70 hover:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),"aria-label":B(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),children:(0,$.jsx)(ce,{className:`h-3 w-3`})})}),(0,$.jsxs)(we,{align:`start`,className:`min-w-[180px]`,onClick:e=>e.stopPropagation(),children:[x&&!O&&(0,$.jsxs)(K,{"data-testid":`view-tab-menu-config-${e.id}`,onClick:()=>x(e.id),children:[(0,$.jsx)(p,{className:`h-4 w-4 mr-2`}),` `,B(`view.editViewConfig`,`Edit view config`)]}),o&&!O&&(0,$.jsxs)(K,{"data-testid":`view-tab-menu-rename-${e.id}`,onClick:()=>be(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` `,B(`view.rename`,`Rename`)]}),s&&(0,$.jsxs)(K,{"data-testid":`view-tab-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(Ce,{className:`h-4 w-4 mr-2`}),` `,B(`view.duplicateView`,`Duplicate view`)]}),m&&(0,$.jsxs)(K,{"data-testid":`view-tab-menu-share-${e.id}`,onClick:()=>m(e.id),children:[(0,$.jsx)(M,{className:`h-4 w-4 mr-2`}),` `,B(`view.shareView`,`Share view`)]}),f&&!O&&(0,$.jsxs)(K,{"data-testid":`view-tab-menu-default-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(J,{className:`h-4 w-4 mr-2`}),` `,B(`view.setAsDefault`,`Set as default`)]}),g&&!O&&(0,$.jsx)(K,{"data-testid":`view-tab-menu-pin-${e.id}`,onClick:()=>g(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ge,{className:`h-4 w-4 mr-2`}),` `,B(`view.unpinView`,`Unpin view`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{className:`h-4 w-4 mr-2`}),` `,B(`view.pinView`,`Pin view`)]})}),b&&!O&&T&&T.length>0&&(0,$.jsxs)(ze,{children:[(0,$.jsxs)(Le,{"data-testid":`view-tab-menu-change-type-${e.id}`,children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` `,B(`view.changeViewType`,`Change view type`)]}),(0,$.jsx)(V,{children:T.map(t=>{let n=r[t.type]||Ae;return(0,$.jsxs)(K,{"data-testid":`view-tab-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>b(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsx)(`span`,{children:t.label})]},t.type)})})]}),l&&!O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Me,{}),(0,$.jsxs)(K,{"data-testid":`view-tab-menu-delete-${e.id}`,onClick:()=>l(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` `,B(`view.deleteView`,`Delete view`)]})]}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Me,{}),(0,$.jsxs)(K,{"data-testid":`view-tab-menu-manage-${e.id}`,onClick:C,children:[(0,$.jsx)(N,{className:`h-4 w-4 mr-2`}),` `,B(`view.manageAllViews`,`Manage all views…`)]})]})]})]})]}),oe=t=>!P||S?t:(0,$.jsxs)(te,{children:[(0,$.jsx)(_,{asChild:!0,children:t}),(0,$.jsxs)(Se,{children:[o&&!O&&(0,$.jsxs)(d,{"data-testid":`context-menu-rename-${e.id}`,onClick:()=>be(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` `,B(`view.rename`,`Rename`)]}),s&&(0,$.jsxs)(d,{"data-testid":`context-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(Ce,{className:`h-4 w-4 mr-2`}),` `,B(`view.duplicateView`,`Duplicate view`)]}),m&&(0,$.jsxs)(d,{"data-testid":`context-menu-share-${e.id}`,onClick:()=>m(e.id),children:[(0,$.jsx)(M,{className:`h-4 w-4 mr-2`}),` `,B(`view.shareView`,`Share view`)]}),f&&!O&&(0,$.jsxs)(d,{"data-testid":`context-menu-default-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(J,{className:`h-4 w-4 mr-2`}),` `,B(`view.setAsDefault`,`Set as default`)]}),g&&!O&&(0,$.jsx)(d,{"data-testid":`context-menu-pin-${e.id}`,onClick:()=>g(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ge,{className:`h-4 w-4 mr-2`}),` `,B(`view.unpinView`,`Unpin view`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{className:`h-4 w-4 mr-2`}),` `,B(`view.pinView`,`Pin view`)]})}),b&&!O&&T&&T.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ye,{}),(0,$.jsxs)(k,{children:[(0,$.jsxs)(re,{"data-testid":`context-menu-change-type-${e.id}`,children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` `,B(`view.changeViewType`,`Change view type`)]}),(0,$.jsx)(A,{"data-testid":`context-menu-type-submenu-${e.id}`,children:T.map(t=>{let n=r[t.type]||Ae;return(0,$.jsxs)(d,{"data-testid":`context-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>b(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{children:t.label}),t.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]})]},t.type)})})]})]}),l&&!O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ye,{}),(0,$.jsxs)(d,{"data-testid":`context-menu-delete-${e.id}`,onClick:()=>l(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` `,B(`view.deleteView`,`Delete view`)]})]}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ye,{}),(0,$.jsxs)(d,{"data-testid":`context-menu-manage-${e.id}`,onClick:C,children:[(0,$.jsx)(N,{className:`h-4 w-4 mr-2`}),` `,B(`view.manageAllViews`,`Manage all views…`)]})]})]})]});return ue&&y?(0,$.jsxs)(Q.Fragment,{children:[E&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),(0,$.jsx)(Gt,{id:e.id,children:({setNodeRef:e,style:t,listeners:n,attributes:r,isDragging:i})=>(0,$.jsx)(`div`,{ref:e,style:t,className:u(`flex`,i&&`z-10`),children:oe(j({listeners:n,attributes:r,isDragging:i}))})})]},e.id):(0,$.jsxs)(Q.Fragment,{children:[E&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),oe(j())]},e.id)},Pe=(0,$.jsx)($.Fragment,{children:X.map((e,t)=>Ne(e,t))});return(0,$.jsx)(S,{children:(0,$.jsxs)(`div`,{"data-testid":`view-tab-bar`,className:u(`flex items-center gap-0.5 -mb-px`,ne),children:[ue&&y?(0,$.jsx)(qe,{sensors:Oe,collisionDetection:Ze,onDragEnd:ke,children:(0,$.jsx)(et,{items:X.map(e=>e.id),strategy:Qe,children:(0,$.jsx)(`div`,{"data-testid":`view-tab-sortable-container`,className:`flex items-center gap-0.5`,children:Pe})})}):Pe,Z.length>0&&(0,$.jsxs)(Ee,{children:[(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`view-tab-overflow`,className:`inline-flex items-center gap-1 px-2 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(fe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-xs`,children:B(`view.moreViews`,`${Z.length} more`,{count:Z.length})})]})}),(0,$.jsxs)(we,{align:`end`,children:[C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{"data-testid":`view-tab-overflow-manage`,onClick:C,className:`font-medium`,children:[(0,$.jsx)(N,{className:`h-4 w-4 mr-2`}),` `,B(`view.manageAllViews`,`Manage all views…`)]}),(0,$.jsx)(Me,{})]}),Z.map(e=>{let t=r[e.type]||Ae;return(0,$.jsxs)(K,{"data-testid":`view-tab-overflow-${e.id}`,onClick:()=>n(e.id),children:[e.isPinned&&(0,$.jsx)(c,{className:`h-3 w-3 mr-1 text-primary shrink-0`}),(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),e.label,L&&(e.hasActiveFilters||e.hasActiveSort)&&(0,$.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary`,children:[e.hasActiveFilters&&(0,$.jsx)(se,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(Ie,{className:`h-2.5 w-2.5`})]})]},e.id)})]})]}),oe&&a&&(0,$.jsxs)(ie,{children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{"data-testid":`view-tab-add`,onClick:a,className:`inline-flex items-center px-2 py-2 text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(de,{className:`h-4 w-4`})})}),(0,$.jsx)(v,{children:`Add View`})]}),pe&&ee&&(0,$.jsxs)(`div`,{"data-testid":`view-tab-save-as`,className:`flex items-center gap-1 ml-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Unsaved changes`}),h&&(0,$.jsx)(j,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-save-as-btn`,className:`h-6 px-2 text-xs`,onClick:h,children:`Save as View`}),E&&(0,$.jsx)(j,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-reset-btn`,className:`h-6 px-2 text-xs`,onClick:E,children:`Reset`})]})]})})};function qt(){try{let{t:e}=a();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:i}}catch{return(e,t)=>t}}var Jt=ve,Yt=({view:e,isActive:t,Icon:n,isRenaming:r,onStartRename:i,onCommitRename:a,onCancelRename:o,onRowClick:s,onDelete:l,onDuplicate:d,onSetDefault:f,onSetPinned:p,onConfigView:m})=>{let h=qt(),{attributes:g,listeners:_,setNodeRef:y,transform:b,transition:x,isDragging:C}=Xe({id:e.id}),T={transform:rt.Transform.toString(b),transition:x,opacity:C?.5:1},ee=(0,Q.useRef)(null),[E,O]=(0,Q.useState)(e.label),k=!!e.readonly;(0,Q.useEffect)(()=>{r&&(O(e.label),requestAnimationFrame(()=>{ee.current?.focus(),ee.current?.select()}))},[r,e.label]);let A=(0,Q.useCallback)(()=>{let t=E.trim();t&&t!==e.label?a(e.id,t):o()},[E,e.id,e.label,a,o]);return(0,$.jsxs)(`li`,{ref:y,style:T,"data-testid":`manage-views-row-${e.id}`,className:u(`group/row flex items-center gap-2 px-2 py-2 rounded-md border border-transparent`,`hover:bg-accent/50 transition-colors`,t&&`bg-accent/40 border-border`,C&&`shadow-md bg-background border-border z-10`),children:[(0,$.jsx)(`button`,{type:`button`,...g,..._,"aria-label":h(`view.dragToReorder`,`Drag to reorder`),"data-testid":`manage-views-drag-${e.id}`,className:`shrink-0 h-6 w-5 flex items-center justify-center text-muted-foreground/40 hover:text-muted-foreground cursor-grab active:cursor-grabbing rounded hover:bg-accent`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(me,{className:`h-4 w-4`})}),(0,$.jsx)(n,{className:`shrink-0 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,onClick:()=>{r||s?.(e.id)},children:r?(0,$.jsx)(H,{ref:ee,value:E,onChange:e=>O(e.target.value),onBlur:A,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),o())},onClick:e=>e.stopPropagation(),className:`h-7 text-sm`,"data-testid":`manage-views-rename-input-${e.id}`}):(0,$.jsxs)(`button`,{type:`button`,className:`w-full text-left text-sm font-medium truncate cursor-pointer flex items-center gap-1.5`,onDoubleClick:t=>{t.stopPropagation(),k||i(e.id)},title:e.label,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label}),k&&(0,$.jsx)(Ve,{"aria-label":h(`view.readonlyAriaLabel`,`Read-only view`),"data-testid":`manage-views-readonly-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}),e.isDefault&&(0,$.jsxs)(`span`,{className:`ml-1 inline-flex items-center text-[10px] uppercase tracking-wide text-muted-foreground`,title:h(`view.defaultView`,`Default view`),children:[(0,$.jsx)(J,{className:`h-3 w-3 mr-0.5 fill-current`}),` `,h(`view.defaultBadge`,`default`)]})]})}),p&&!r&&!k&&(0,$.jsx)(S,{delayDuration:300,children:(0,$.jsxs)(ie,{children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":e.isPinned?h(`view.unpinView`,`Unpin View`):h(`view.pinView`,`Pin View`),"data-testid":`manage-views-pin-${e.id}`,onClick:t=>{t.stopPropagation(),p(e.id,!e.isPinned)},className:u(`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent transition-colors`,e.isPinned?`text-amber-500`:`text-muted-foreground/40 opacity-0 group-hover/row:opacity-100`),children:e.isPinned?(0,$.jsx)(c,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(c,{className:`h-4 w-4`})})}),(0,$.jsx)(v,{side:`top`,children:e.isPinned?h(`view.unpinView`,`Unpin View`):h(`view.pinView`,`Pin View`)})]})}),f&&!r&&!e.isDefault&&!k&&(0,$.jsx)(S,{delayDuration:300,children:(0,$.jsxs)(ie,{children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":h(`view.setAsDefault`,`Set as Default`),"data-testid":`manage-views-default-${e.id}`,onClick:t=>{t.stopPropagation(),f(e.id)},className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground/40 hover:text-foreground opacity-0 group-hover/row:opacity-100 transition-colors`,children:(0,$.jsx)(J,{className:`h-4 w-4`})})}),(0,$.jsx)(v,{side:`top`,children:h(`view.setAsDefault`,`Set as Default`)})]})}),!r&&(l||d||m||f)&&(0,$.jsxs)(Ee,{children:[(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":h(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),"data-testid":`manage-views-actions-${e.id}`,onClick:e=>e.stopPropagation(),className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground opacity-60 group-hover/row:opacity-100 transition-opacity`,children:(0,$.jsx)(fe,{className:`h-4 w-4`})})}),(0,$.jsxs)(we,{align:`end`,className:`min-w-[180px]`,children:[!k&&(0,$.jsxs)(K,{"data-testid":`manage-views-action-rename-${e.id}`,onClick:()=>i(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` `,h(`view.rename`,`Rename`)]}),d&&(0,$.jsxs)(K,{"data-testid":`manage-views-action-duplicate-${e.id}`,onClick:()=>d(e.id),children:[(0,$.jsx)(Ce,{className:`h-4 w-4 mr-2`}),` `,h(`view.duplicateView`,`Duplicate View`)]}),m&&!k&&(0,$.jsxs)(K,{"data-testid":`manage-views-action-config-${e.id}`,onClick:()=>m(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` `,h(`view.editViewConfig`,`Edit view config`)]}),f&&!e.isDefault&&!k&&(0,$.jsxs)(K,{"data-testid":`manage-views-action-default-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(J,{className:`h-4 w-4 mr-2`}),` `,h(`view.setAsDefault`,`Set as Default`)]}),p&&!k&&(0,$.jsx)(K,{"data-testid":`manage-views-action-pin-${e.id}`,onClick:()=>p(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ge,{className:`h-4 w-4 mr-2`}),` `,h(`view.unpinView`,`Unpin View`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{className:`h-4 w-4 mr-2`}),` `,h(`view.pinView`,`Pin View`)]})}),l&&!k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Me,{}),(0,$.jsxs)(K,{"data-testid":`manage-views-action-delete-${e.id}`,onClick:()=>l(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` `,h(`view.deleteView`,`Delete View`)]})]})]})]}),r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":h(`common.save`,`Save`),onMouseDown:e=>e.preventDefault(),onClick:A,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-emerald-600`,children:(0,$.jsx)(F,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":h(`common.cancel`,`Cancel`),onMouseDown:e=>e.preventDefault(),onClick:o,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:(0,$.jsx)(q,{className:`h-4 w-4`})})]})]})},Xt=({open:e,onOpenChange:t,views:n,activeViewId:r,viewTypeIcons:i={},onRename:a,onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onReorder:u,onAddView:d,onConfigView:f})=>{let p=qt(),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)(()=>n.map(e=>e.id));(0,Q.useEffect)(()=>{b(n.map(e=>e.id))},[n]),(0,Q.useEffect)(()=>{e||(_(null),h(``))},[e]);let x=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e]));return v.map(t=>e.get(t)).filter(Boolean)},[v,n]),S=(0,Q.useMemo)(()=>{if(!m.trim())return x;let e=m.toLowerCase();return x.filter(t=>t.label.toLowerCase().includes(e))},[x,m]),w=nt(Ge(Je,{activationConstraint:{distance:5}}),Ge(tt,{coordinateGetter:Ke})),T=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=v.indexOf(String(t.id)),i=v.indexOf(String(n.id));if(r<0||i<0)return;let a=Ye(v,r,i);b(a),u?.(a)},E=e=>{t(!1),requestAnimationFrame(()=>f?.(e))};return(0,$.jsx)(ue,{open:e,onOpenChange:t,children:(0,$.jsxs)(y,{className:`sm:max-w-[560px] p-0 gap-0 overflow-hidden`,"data-testid":`manage-views-dialog`,children:[(0,$.jsxs)(C,{className:`px-5 pt-5 pb-3`,children:[(0,$.jsx)(pe,{className:`text-base`,children:p(`view.manageViews`,`Manage views`)}),(0,$.jsx)(ee,{className:`text-xs`,children:p(`view.manageViewsDescription`,`Reorder, rename, pin, or delete every view in this object.`)})]}),(0,$.jsx)(`div`,{className:`px-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(xe,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(H,{value:m,onChange:e=>h(e.target.value),placeholder:p(`view.searchViews`,`Search views`),className:`pl-8 h-9`,"data-testid":`manage-views-search`})]})}),(0,$.jsx)(`div`,{className:`px-3 pb-3 max-h-[55vh] overflow-y-auto`,"data-testid":`manage-views-list`,children:S.length===0?(0,$.jsx)(`div`,{className:`text-center text-sm text-muted-foreground py-10`,children:p(`view.noViewsFound`,`No views match your search.`)}):(0,$.jsx)(qe,{sensors:w,collisionDetection:Ze,onDragEnd:T,children:(0,$.jsx)(et,{items:S.map(e=>e.id),strategy:$e,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:S.map(e=>(0,$.jsx)(Yt,{view:e,Icon:i[e.type]||Jt,isActive:e.id===r,isRenaming:g===e.id,onStartRename:e=>_(e),onCancelRename:()=>_(null),onCommitRename:(e,t)=>{_(null),a?.(e,t)},onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onConfigView:f?E:void 0},e.id))})})})}),(0,$.jsxs)(X,{className:`border-t bg-muted/30 px-5 py-3 flex sm:justify-between gap-2`,children:[d?(0,$.jsxs)(j,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),requestAnimationFrame(()=>d())},"data-testid":`manage-views-add`,className:`text-sm`,children:[(0,$.jsx)(de,{className:`h-4 w-4 mr-1.5`}),` `,p(`view.addNewView`,`Add new view`)]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(j,{size:`sm`,onClick:()=>t(!1),"data-testid":`manage-views-done`,children:p(`view.done`,`Done`)})]})]})})};function Zt(e){let t=(e||``).toLowerCase();return[`integer`,`int`,`float`,`double`,`number`,`currency`,`money`,`percent`,`rating`].includes(t)?`number`:[`date`,`datetime`,`datetime_tz`,`timestamp`,`time`].includes(t)?`date`:[`boolean`,`bool`,`checkbox`,`switch`].includes(t)?`boolean`:[`select`,`picklist`,`single_select`,`multi_select`,`enum`,`status`,`lookup`,`master_detail`,`user`,`owner`].includes(t)?`select`:`text`}function Qt(e){return e.fields?Object.entries(e.fields).filter(([e,t])=>!(e.startsWith(`_`)||t?.hidden)).map(([e,t])=>({value:e,label:t.label||e,type:Zt(t.type),options:t.options,rawType:t.type,rawName:e})):[]}var $t=new Set([`image`,`image_url`,`photo`,`picture`,`avatar`,`file`,`attachment`,`attachments`,`media`,`url`,`link`]),en=[`image`,`photo`,`picture`,`avatar`,`thumbnail`,`thumb`,`logo`,`cover`,`banner`,`icon`,`attachment`];function tn(e){if(!e)return!1;let t=(e.rawType||e.type||``).toLowerCase();if($t.has(t))return!0;let n=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return n?en.some(e=>n.includes(e)):!1}var nn=new Set([`geolocation`,`geo`,`geo_point`,`geopoint`,`location`,`latlng`,`lnglat`]);function rn(e,t){if(!e)return!1;let n=(e.rawType||e.type||``).toLowerCase();if(nn.has(n))return!0;let r=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return r?t===`latitude`?/(^|[_-])lat([^a-z]|itude)?($|[_-])/.test(r)||r===`lat`:/(^|[_-])(lng|lon|long)([^a-z]|gitude)?($|[_-])/.test(r)||r===`lng`||r===`lon`:!1}function an(e,t){if(e.length!==0){for(let n of t){let t=e.find(e=>e.value.toLowerCase().includes(n));if(t)return t.value}return e[0]?.value}}var on=[`status`,`stage`,`state`,`priority`,`category`,`type`],sn=[`start_date`,`startdate`,`due_date`,`duedate`,`event_date`,`date`,`created_at`,`createdat`,`created`],cn=[`end_date`,`enddate`,`finish_date`,`completion_date`,`closed_at`],ln=o,un=({schema:e})=>(0,$.jsx)(kt,{schema:e,dataSource:(0,Q.useContext)(ln)?.dataSource??null});r.register(`object-view`,un,{namespace:`plugin-view`,label:`Object View`,category:`view`,icon:`LayoutDashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Form Layout`,enum:[`drawer`,`modal`,`page`]},{name:`defaultViewType`,type:`enum`,label:`Default View Type`,enum:[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`]},{name:`defaultListView`,type:`string`,label:`Default Named View`},{name:`showSearch`,type:`boolean`,label:`Show Search`},{name:`showFilters`,type:`boolean`,label:`Show Filters`},{name:`showCreate`,type:`boolean`,label:`Show Create Button`},{name:`showRefresh`,type:`boolean`,label:`Show Refresh Button`},{name:`showViewSwitcher`,type:`boolean`,label:`Show View Switcher`},{name:`listViews`,type:`object`,label:`Named List Views`},{name:`navigation`,type:`object`,label:`Navigation Config`},{name:`searchableFields`,type:`array`,label:`Searchable Fields`},{name:`filterableFields`,type:`array`,label:`Filterable Fields`}],defaultProps:{layout:`drawer`,defaultViewType:`grid`,showSearch:!0,showFilters:!0,showCreate:!0,showRefresh:!0,showViewSwitcher:!0}}),r.register(`view`,un,{namespace:`plugin-view`,label:`View`,category:`view`}),r.register(`view-switcher`,yt,{namespace:`view`,label:`View Switcher`,category:`view`,icon:`LayoutGrid`,inputs:[{name:`views`,type:`array`,label:`Views`,required:!0},{name:`defaultView`,type:`string`,label:`Default View`},{name:`activeView`,type:`string`,label:`Active View`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`tabs`,`buttons`,`dropdown`]},{name:`position`,type:`enum`,label:`Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`persistPreference`,type:`boolean`,label:`Persist Preference`},{name:`storageKey`,type:`string`,label:`Storage Key`},{name:`onViewChange`,type:`string`,label:`On View Change Event`}],defaultProps:{variant:`tabs`,position:`top`,defaultView:`grid`,views:[{type:`grid`,label:`Grid`,schema:{type:`text`,content:`Grid view`}},{type:`list`,label:`List`,schema:{type:`text`,content:`List view`}}]}}),r.register(`filter-ui`,Nt,{namespace:`view`,label:`Filter UI`,category:`view`,icon:`SlidersHorizontal`,inputs:[{name:`filters`,type:`array`,label:`Filters`,required:!0},{name:`values`,type:`object`,label:`Values`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`showClear`,type:`boolean`,label:`Show Clear Button`},{name:`showApply`,type:`boolean`,label:`Show Apply Button`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`inline`,`popover`,`drawer`]}],defaultProps:{layout:`inline`,showApply:!1,showClear:!0,filters:[{field:`name`,label:`Name`,type:`text`,placeholder:`Search name`},{field:`status`,label:`Status`,type:`select`,options:[{label:`Open`,value:`open`},{label:`Closed`,value:`closed`}]},{field:`created_at`,label:`Created`,type:`date`}]}}),r.register(`sort-ui`,Rt,{namespace:`view`,label:`Sort UI`,category:`view`,icon:`ArrowUpDown`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`sort`,type:`array`,label:`Sort`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`multiple`,type:`boolean`,label:`Allow Multiple`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`dropdown`,`buttons`]}],defaultProps:{variant:`dropdown`,multiple:!0,fields:[{field:`name`,label:`Name`},{field:`created_at`,label:`Created At`}],sort:[{field:`name`,direction:`asc`}]}}),r.register(`shared-view-link`,Vt,{namespace:`view`,label:`Shared View Link`,category:`view`,icon:`Share2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewId`,type:`string`,label:`View ID`},{name:`baseUrl`,type:`string`,label:`Base URL`}],defaultProps:{objectName:`objects`,viewId:`default`}}),r.register(`view:simple`,({schema:e,className:t,children:n,dataSource:r,...i})=>(0,$.jsx)(`div`,{className:t,style:e.props?.columns?{display:`grid`,gridTemplateColumns:`repeat(${e.props.columns}, 1fr)`,gap:`1rem`}:void 0,...i,children:n}),{namespace:`plugin-view`,label:`Simple View`,category:`view`});export{rn as a,Xt as c,Et as d,St as f,Qt as i,Kt as l,on as n,tn as o,Tt as p,sn as r,an as s,cn as t,kt as u};
|