@objectstack/console 9.1.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AiPendingActionsPage-B9iWZUDQ.js → AiPendingActionsPage-Y9r83gqj.js} +1 -1
- package/dist/assets/{ApiConsolePage-ZBL7GLt2.js → ApiConsolePage-Dwbms0Zh.js} +1 -1
- package/dist/assets/{AppManagementPage-A8AufLcC.js → AppManagementPage-0JEALVYK.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-B-drSsxQ.js +1 -0
- package/dist/assets/{AuditLogPage-DWQl9my4.js → AuditLogPage-CXhNSVOU.js} +1 -1
- package/dist/assets/{ComponentNavView-CqfUzDMU.js → ComponentNavView-BI4O_zkC.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-CiODZIcp.js +1 -0
- package/dist/assets/{DeveloperHubPage-D7pt27Ji.js → DeveloperHubPage-D-UigRUA.js} +1 -1
- package/dist/assets/FlowRunsPage-_UeeNdBc.js +1 -0
- package/dist/assets/{IntegrationsPage-CHg7ApBe.js → IntegrationsPage-DsWyxKR6.js} +2 -2
- package/dist/assets/{ProfilePage-D7kxyCKj.js → ProfilePage-T27zVrMO.js} +1 -1
- package/dist/assets/{PublicFormsPage-B1VZJXuJ.js → PublicFormsPage-Pd453sW6.js} +1 -1
- package/dist/assets/{SettingsHub-DerOpof3.js → SettingsHub-B4oSx4ed.js} +1 -1
- package/dist/assets/{SettingsView-BNq6smI8.js → SettingsView-CkQEI5DW.js} +1 -1
- package/dist/assets/{SystemHubPage-UTl8x-Bf.js → SystemHubPage-Di6eqozE.js} +1 -1
- package/dist/assets/assistantBus-B-xBT6j1.js +1 -0
- package/dist/assets/data-adapter-3AJO7A2o.js +1 -0
- package/dist/assets/framework-crD8qZlm.js +34 -0
- package/dist/assets/highlighted-body-OFNGDK62-B3OlR_Nx.js +1 -0
- package/dist/assets/index-Cf7NsvAk.css +2 -0
- package/dist/assets/index-CiI7zDDo.js +32 -0
- package/dist/assets/mergeServerFields-DUkbynPg.js +7 -0
- package/dist/assets/mermaid-GHXKKRXX-CBocchJ2.js +1 -0
- package/dist/assets/plugin-calendar-ed7RoEFF.js +1 -0
- package/dist/assets/{plugin-charts-BjUzf65B.js → plugin-charts-QabQJ_NJ.js} +2 -2
- package/dist/assets/plugin-chatbot-Cy3tiXkg.js +120 -0
- package/dist/assets/plugin-dashboard-PA0xf59v.js +5 -0
- package/dist/assets/plugin-form-BABEMaum.js +1 -0
- package/dist/assets/{plugin-gantt-BRef4N3J.js → plugin-gantt-BNjfLkTR.js} +1 -1
- package/dist/assets/plugin-grid-BxyuFeJP.js +6 -0
- package/dist/assets/{plugin-kanban-C1UyFHza.js → plugin-kanban-D4yCkUn_.js} +1 -1
- package/dist/assets/plugin-map-C8Jxhxs1.js +1 -0
- package/dist/assets/{plugin-markdown-tayYSGF3.js → plugin-markdown-CR5TpghH.js} +1 -1
- package/dist/assets/plugin-report-rz8HUIsi.js +59 -0
- package/dist/assets/plugin-timeline-DQHQwtdw.js +1 -0
- package/dist/assets/plugin-view-BykLknWa.js +1 -0
- package/dist/assets/plugins-views-CBO5qxO-.js +4 -0
- package/dist/assets/{src-DOKKicsm.js → src-Tw2eleSi.js} +1 -1
- package/dist/assets/{types-TLjbGkho.js → types-BkFEpiv3.js} +1 -1
- package/dist/assets/{ui-components-DeXgqLMc.js → ui-components-BrY5joKQ.js} +8 -8
- package/dist/assets/{ui-layout-CvIgXgRF.js → ui-layout-KICrO2Oe.js} +1 -1
- package/dist/assets/vendor-objectstack-RB3xvhcR.js +102 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-Be6DrS7X.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-ByiTKdo6.js +0 -1
- package/dist/assets/FlowRunsPage-R-JzHY35.js +0 -1
- package/dist/assets/data-adapter-DlR5JXpU.js +0 -1
- package/dist/assets/framework-DoGxClbR.js +0 -34
- package/dist/assets/highlighted-body-OFNGDK62-Bu5WidAv.js +0 -1
- package/dist/assets/index-Bt0jFx__.js +0 -32
- package/dist/assets/index-CJppnf0b.css +0 -2
- package/dist/assets/mergeServerFields-DL5isEen.js +0 -7
- package/dist/assets/mermaid-GHXKKRXX-BAcku4Xs.js +0 -1
- package/dist/assets/plugin-calendar-CUnlH4Wo.js +0 -1
- package/dist/assets/plugin-chatbot-DUla2_T9.js +0 -120
- package/dist/assets/plugin-dashboard-DbPGiGy-.js +0 -5
- package/dist/assets/plugin-form-CcC4fdyJ.js +0 -1
- package/dist/assets/plugin-grid-BiWgglXK.js +0 -6
- package/dist/assets/plugin-map-Bt30Mxn6.js +0 -1
- package/dist/assets/plugin-report-qca5M0OZ.js +0 -59
- package/dist/assets/plugin-timeline-DZoFKL82.js +0 -1
- package/dist/assets/plugin-view-Ei4BPIYk.js +0 -1
- package/dist/assets/plugins-views-qoGCOQ47.js +0 -4
- package/dist/assets/vendor-objectstack-B2q1QmZh.js +0 -102
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,g as r,m as i,t as a}from"./vendor-react-DR370ovB.js";import{F as o,G as s,lt as c,mt as l,ut as u}from"./framework-crD8qZlm.js";import{A as d,N as f,P as p,k as m}from"./vendor-objectstack-RB3xvhcR.js";import{P as h,jt as g,rc as _}from"./ui-components-BrY5joKQ.js";var v=e(n(),1),y=v.createContext(null);function b(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 x(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(!x(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)||!x(e[r],t[r]))return!1;return!0}return!1}function S(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function C(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&&!x(n.padding,e.padding)&&(r.padding=n.padding),r}var w=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function T(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 w)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var E={version:8,sources:{},layers:[]},D={minZoom:0,maxZoom:22,minPitch:0,maxPitch:85,maxBounds:[-180,-85.051129,180,85.051129],projection:`mercator`,renderWorldCopies:!0},O={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`},k={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`},A={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`},j=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],M=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],N=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[A[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||S(this._map.transform);let t=this.props[k[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=S(e),C(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[O[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=E}=t,r={...t,...t.initialViewState,container:e,style:T(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 O)a.on(e,this._onPointerEvent);for(let e in k)a.on(e,this._onCameraEvent);for(let e in A)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=C(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 j)if((i in e||i in t)&&!x(e[i],t[i])){r=!0;let t=i in e?e[i]:D[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=E,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(T(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style?._loaded&&(e&&!x(e,a.light)&&(a.light=e,i.setLight(e)),t&&!x(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!x(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!x(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 M){let i=e[r]??!0;x(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}};N.savedMaps=[];var P=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function F(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of I(t))!(e in n)&&!P.includes(e)&&(n[e]=t[e].bind(t));return n}function I(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 L=typeof document<`u`?v.useLayoutEffect:v.useEffect;function R(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 z=v.createContext(null);function B(t,n){let r=(0,v.useContext)(y),[a,o]=(0,v.useState)(null),s=(0,v.useRef)(),{current:c}=(0,v.useRef)({mapLib:null,map:null});(0,v.useEffect)(()=>{let n=t.mapLib,a=!0,l;return Promise.resolve(n||i(()=>import(`./maplibre-gl-C3Ve5bV1.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`);R(n,t),t.reuseMaps&&(l=N.reuse(t,s.current)),l||=new N(n.Map,t,s.current),c.map=F(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())}},[]),L(()=>{a&&a.setProps(t)}),(0,v.useImperativeHandle)(n,()=>c.map,[a]);let l=(0,v.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...t.style}),[t.style]);return v.createElement(`div`,{id:t.id,ref:s,style:l},a&&v.createElement(z.Provider,{value:c},v.createElement(`div`,{"mapboxgl-children":``,style:{height:`100%`}},t.children)))}var ee=v.forwardRef(B),V=e(r(),1),H=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function U(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!H.test(e)?n[e]=`${r}px`:n[e]=r}}function W(e,t){if(e===t)return null;let n=G(e),r=G(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 G(e){return new Set(e?e.trim().split(/\s+/):[])}var K=(0,v.memo)((0,v.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,v.useContext)(z),i=(0,v.useRef)({props:e}),a=(0,v.useMemo)(()=>{let t=!1;v.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,v.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,v.useEffect)(()=>{U(a.getElement(),l)},[l]),(0,v.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!b(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=W(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,V.createPortal)(e.children,a.getElement())})),te=(0,v.memo)((0,v.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,v.useContext)(z),i=(0,v.useMemo)(()=>document.createElement(`div`),[]),a=(0,v.useRef)({props:e}),o=(0,v.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,v.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,v.useEffect)(()=>{U(o.getElement(),e.style)},[e.style]),(0,v.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&&!x(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=W(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,V.createPortal)(e.children,i)}));function q(e,t,n,r){let i=(0,v.useContext)(z),a=(0,v.useMemo)(()=>e(i),[]);return(0,v.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 J(e){let t=q(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(J);function Y(e){let t=q(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,v.useEffect)(()=>{U(t._controlContainer,e.style)},[e.style]),null}(0,v.memo)(Y);function X(e,t){let n=(0,v.useRef)({props:e}),r=q(({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,v.useImperativeHandle)(t,()=>r,[]),(0,v.useEffect)(()=>{U(r._container,e.style)},[e.style]),null}(0,v.memo)((0,v.forwardRef)(X));function Z(e){let t=q(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}var ne=(0,v.memo)(Z);function re(e){let t=q(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,v.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,v.useEffect)(()=>{U(t._container,i)},[i]),null}(0,v.memo)(re);function ie(e){let t=q(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(ie);function ae(e){let t=q(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.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()});function se(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function ce(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 le(e){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};let t=null;if(e.filter&&typeof e.filter==`object`&&`map`in e.filter?t=e.filter.map:e.map&&(t=e.map),t){let e=oe.safeParse(t);return e.success||console.warn(`[ObjectMap] Invalid map configuration:`,e.error.format()),t}return{latitudeField:`latitude`,longitudeField:`longitude`,locationField:`location`,titleField:`name`,descriptionField:`description`,zoom:10,center:[0,0]}}function ue(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 de(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 fe=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:a,onDelete:s,enableClustering:l,clusterRadius:d=50,...f})=>{let[p,m]=(0,v.useState)([]),[y,b]=(0,v.useState)(!0),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),k=g(),A=(0,v.useRef)(null),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),L=(0,v.useCallback)(()=>{if(typeof navigator>`u`||!navigator.geolocation){P(`Geolocation is not available in this browser.`);return}I(!0),P(null),navigator.geolocation.getCurrentPosition(e=>{let{longitude:t,latitude:n}=e.coords;M({lng:t,lat:n}),I(!1);try{A.current?.flyTo({center:[t,n],zoom:12,duration:800})}catch{}},e=>{I(!1),P(e.message||`Unable to retrieve location.`)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:6e4})},[]),R=se(e),z=(0,v.useMemo)(()=>R,[JSON.stringify(R)]),B=le(e),V=z?.provider===`value`;(0,v.useEffect)(()=>{(async()=>{try{if(b(!0),f.data){let e=f.data;if(Array.isArray(e)){m(e),b(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),b(!1);return}}if(V&&z?.provider===`value`){m(z.items),b(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(z?.provider===`object`){let n=z.object,r=c(C?.fields);m(u(await t.find(n,{$filter:e.filter,$orderby:ce(e.sort),...r.length>0?{$expand:r}:{}})))}else z?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));b(!1)}catch(e){S(e),b(!1)}})()},[z,t,V,e.filter,e.sort,C]),(0,v.useEffect)(()=>{!V&&t&&(async()=>{try{if(!t)return;let n=z?.provider===`object`?z.object:e.objectName;if(!n)return;w(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,V,z]);let{markers:H,invalidCount:U}=(0,v.useMemo)(()=>{let e=0;return{markers:p.map((t,n)=>{let r=ue(t,B);if(!r)return e++,null;let i=B.titleField?t[B.titleField]:`Marker`,a=B.descriptionField?t[B.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,B]),W=(0,v.useMemo)(()=>H.find(e=>e.id===T),[H,T]),[G,q]=(0,v.useState)(B.zoom||3),J=o({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),Y=(0,v.useMemo)(()=>{if(!D.trim())return H;let e=D.toLowerCase();return H.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[H,D]),X=(0,v.useMemo)(()=>l??(e.enableClustering||Y.length>100)?de(Y,G,d):Y.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[Y,G,l,d,e]),Z=(0,v.useMemo)(()=>{if(!Y.length)return{longitude:B.center?.[1]||0,latitude:B.center?.[0]||0,zoom:B.zoom||2};let e=Y.map(e=>e.coordinates[0]),t=Y.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:B.zoom||3}},[Y,B]);return y?(0,Q.jsx)(`div`,{className:_(`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...`})})}):x?(0,Q.jsx)(`div`,{className:_(`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: `,x.message]})})}):(0,Q.jsxs)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:[U>0&&(0,Q.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${U} record${U===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),H.length>0&&(0,Q.jsx)(`div`,{className:`mb-2`,children:(0,Q.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(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)(ee,{ref:e=>{A.current=e},initialViewState:Z,style:{width:`100%`,height:`100%`},mapStyle:`https://demotiles.maplibre.org/style.json`,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>q(Math.round(e.viewState.zoom)),children:[(0,Q.jsx)(ne,{position:`top-right`,showCompass:!0,showZoom:!0}),(0,Q.jsx)(`button`,{type:`button`,onClick:L,disabled:F,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:F?`⏳`:`🧭`})}),j&&(0,Q.jsx)(K,{longitude:j.lng,latitude:j.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`})}),X.map(e=>e.isCluster?(0,Q.jsx)(K,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,onClick:t=>{t.originalEvent.stopPropagation();try{let t=Math.min(20,Math.max(G+2,8));A.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)(K,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];E(n.id),J.handleClick(n.data),r?.(n.data)},children:(0,Q.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),W&&!k&&(0,Q.jsx)(te,{longitude:W.coordinates[0],latitude:W.coordinates[1],anchor:`top`,onClose:()=>E(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:W.title}),W.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:W.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(W.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>s(W.data),children:`Delete`})]})]})})]}),W&&k&&(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:W.title}),W.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground line-clamp-3`,children:W.description})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>E(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(W.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(W.data),children:`Delete`})]})]}),N&&(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:N})]}),J.isOverlay&&(0,Q.jsx)(h,{...J,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))})})]})},pe=t({ObjectMap:()=>fe,ObjectMapRenderer:()=>$}),$=({schema:e,...t})=>{let{dataSource:n}=s()||{};return(0,Q.jsx)(fe,{schema:e,dataSource:n,...t})};console.log(`Registering object-map...`),l.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`}]}),l.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{pe as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,m as r,t as i}from"./vendor-react-DR370ovB.js";import{mt as a}from"./framework-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,m as r,t as i}from"./vendor-react-DR370ovB.js";import{mt as a}from"./framework-crD8qZlm.js";import{At as o}from"./ui-components-BrY5joKQ.js";import{c as s,l as c,t as l}from"./vendor-markdown-C9mPywRm.js";var u=t({default:()=>p}),d=e(n(),1),f=i();function p({content:e,className:t}){return(0,f.jsx)(`div`,{"data-slot":`markdown`,className:((...e)=>e.filter(Boolean).join(` `))(`prose prose-sm dark:prose-invert max-w-none`,`prose-headings:font-semibold prose-headings:tracking-tight`,`prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl`,`prose-p:leading-relaxed prose-p:text-foreground`,`prose-a:text-primary prose-a:no-underline hover:prose-a:underline`,`prose-code:text-foreground prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none`,`prose-pre:bg-muted prose-pre:text-foreground prose-pre:border`,`prose-blockquote:border-l-primary prose-blockquote:text-muted-foreground`,`prose-strong:text-foreground prose-strong:font-semibold`,`prose-ul:list-disc prose-ol:list-decimal`,`prose-li:text-foreground prose-li:marker:text-muted-foreground`,`prose-table:border prose-th:border prose-th:bg-muted prose-td:border`,`prose-img:rounded-md prose-img:border`,t),children:(0,f.jsx)(l,{remarkPlugins:[s],rehypePlugins:[c],disallowedElements:[`script`,`style`,`iframe`,`object`,`embed`],unwrapDisallowed:!0,children:e})})}var m=t({MarkdownRenderer:()=>g,markdownComponents:()=>_}),h=d.lazy(()=>r(()=>Promise.resolve().then(()=>u),void 0,import.meta.url)),g=({schema:e})=>(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(o,{className:`w-full h-[200px]`}),children:(0,f.jsx)(h,{content:e.content||``,className:e.className})});a.register(`markdown`,g,{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-CMxvf4Kt.js";import{_ as n,t as r}from"./vendor-react-DR370ovB.js";import{B as i,H as a,mt as o,nt as s,rt as c}from"./framework-crD8qZlm.js";import{At as l,Da as u,Fr as d,Gn as f,Ii as ee,Jn as p,Kn as m,No as h,Yn as g,Yr as _,Zn as te,ji as ne,l as re,m as ie,pr as v,qn as y}from"./ui-components-BrY5joKQ.js";var b=e(n(),1),x=r(),S=({schema:e})=>{let{title:t,description:n,data:r,columns:i}=e;e.chart?.type;let a=!!e.chart;return(0,x.jsxs)(f,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,x.jsxs)(p,{children:[t&&(0,x.jsx)(g,{children:t}),n&&(0,x.jsx)(y,{children:n})]}),(0,x.jsxs)(m,{className:`flex-1 overflow-auto space-y-4`,children:[a&&(()=>{let t=e.chart?.type,n=t?o.get(t):null;return n||=o.get(`chart`),n?(0,x.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,x.jsx)(n,{schema:{...e.chart,data:e.chart.data||r}})}):(0,x.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,x.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=o.get(`grid`)||o.get(`table`);return e?(0,x.jsx)(e,{schema:{type:`grid`,rowData:r,columnDefs:i,domLayout:`autoHeight`}}):(0,x.jsx)(`div`,{className:`overflow-x-auto`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,x.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,x.jsx)(`tr`,{children:i?.map(e=>(0,x.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,x.jsx)(`tbody`,{children:r.map((e,t)=>(0,x.jsx)(`tr`,{className:`bg-background border-b`,children:i?.map(t=>(0,x.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function C(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=A(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
2
|
+
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));N([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
3
|
+
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function w(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};N(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function T(e,t,n){let r=e.fields||[],i=M(n?.orientation),a=j(n?.pageSize);N(`<!DOCTYPE html>
|
|
4
|
+
<html>
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<title>${k(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>${k(e.title||`Report`)}</h1>
|
|
22
|
+
${e.description?`<p class="description">${k(e.description)}</p>`:``}
|
|
23
|
+
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
24
|
+
<table>
|
|
25
|
+
<thead><tr>${r.map(e=>`<th>${k(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
26
|
+
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${k(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
</body>
|
|
29
|
+
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function E(e,t,n){let r=e.fields||[],i=M(n?.orientation),a=j(n?.pageSize),o=window.open(``,`_blank`);if(!o){T(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>${k(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>${k(e.title||`Report`)}</h1>
|
|
49
|
+
${e.description?`<p class="description">${k(e.description)}</p>`:``}
|
|
50
|
+
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
51
|
+
<table>
|
|
52
|
+
<thead><tr>${r.map(e=>`<th>${k(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
53
|
+
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${k(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
54
|
+
</table>
|
|
55
|
+
</body>
|
|
56
|
+
</html>`),o.document.close(),o.onload=()=>{o.print()}}function D(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=A(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
57
|
+
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));N(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
58
|
+
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function O(e,t,n,r){switch(e){case`csv`:C(t,n,r);break;case`json`:w(t,n,r);break;case`html`:T(t,n,r);break;case`pdf`:E(t,n,r);break;case`excel`:D(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function k(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function A(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 j(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function M(e){return e===`landscape`?`landscape`:`portrait`}function N(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 P(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||ae(e))return oe(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 ae(e){return typeof e==`string`?/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e):!1}function oe(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 se(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 F=({schema:e,onRefresh:t})=>{let{report:n,data:r,showToolbar:a=!0,allowExport:s=!0,allowPrint:c=!0,loading:u=!1}=e,d=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}O(e,n,r||[],n.exportConfigs?.[e])},_=()=>{window.print()},S=()=>{t?.()},C=(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``}},w=(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}}},T=(e,t)=>{if(e==null||e===``)return``;if(t.renderAs===`badge`&&(!t.type||t.type===`string`||t.type===`text`))return(0,x.jsx)(te,{className:t.colorMap?.[String(e)]||``,children:String(e)});if(t.aggregation)return P(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,x.jsx)(re(ie(n)),{value:e,field:n})}return P(e,t)};return n?(0,x.jsxs)(`div`,{className:`space-y-4`,children:[a&&(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,x.jsxs)(v,{variant:`outline`,size:`sm`,onClick:S,children:[(0,x.jsx)(ne,{className:`h-4 w-4 mr-2`}),`Refresh`]}),c&&(0,x.jsxs)(v,{variant:`outline`,size:`sm`,onClick:_,children:[(0,x.jsx)(ee,{className:`h-4 w-4 mr-2`}),`Print`]}),s&&n.showExportButtons&&(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>d(`pdf`),children:[(0,x.jsx)(h,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,x.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>d(`excel`),children:[(0,x.jsx)(h,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,x.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>d(`csv`),children:[(0,x.jsx)(h,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,x.jsxs)(f,{children:[(0,x.jsxs)(p,{children:[!a&&n.title&&(0,x.jsx)(g,{children:n.title}),!a&&n.description&&(0,x.jsx)(y,{children:n.description})]}),(0,x.jsxs)(m,{className:`space-y-6`,children:[u&&(0,x.jsxs)(`div`,{className:`space-y-6`,children:[(0,x.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,x.jsx)(f,{children:(0,x.jsxs)(m,{className:`p-4 space-y-2`,children:[(0,x.jsx)(l,{className:`h-4 w-20`}),(0,x.jsx)(l,{className:`h-8 w-28`})]})},e))}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(l,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,x.jsx)(l,{className:`h-8 w-full`},e))]})]}),!u&&n.sections?.map((e,t)=>e.visible===!1?null:(0,x.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,x.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,x.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,x.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,x.jsx)(f,{children:(0,x.jsxs)(m,{className:`p-4`,children:[(0,x.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,x.jsx)(`div`,{className:`text-2xl font-bold`,children:P(C(e.name,e.aggregation),e)})]})},t))}),e.type===`chart`&&e.chart&&(0,x.jsx)(`div`,{className:`min-h-[300px]`,children:(()=>{let t=e.chart.type,n=!!e.chart.chartType;!t&&n&&(t=`chart`),t&&o.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,x.jsx)(i,{schema:{...e.chart,type:t,...a,data:r||e.chart.data,className:e.chart.className||`w-full h-[350px]`}})})()}),e.type===`table`&&(0,x.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,x.jsx)(`thead`,{className:`bg-muted`,children:(0,x.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,x.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,x.jsx)(`tbody`,{children:(()=>{let t=se(r||[],n.groupBy||[]);return t?t.map(t=>(0,x.jsxs)(b.Fragment,{children:[(0,x.jsx)(`tr`,{className:`bg-muted/60`,children:(0,x.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,x.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,x.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:w(e.name,t[e.name]),children:T(t[e.name],e)},n))},n))]},t.key)):r?.map((t,n)=>(0,x.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,x.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:w(e.name,t[e.name]),children:T(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,x.jsx)(`div`,{className:`prose max-w-none`,children:(0,x.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,x.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,x.jsx)(i,{schema:e.content})]},t)),!n.sections&&r&&r.length>0&&(0,x.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,x.jsx)(`thead`,{className:`bg-muted`,children:(0,x.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,x.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,x.jsx)(`tbody`,{children:r.map((e,t)=>(0,x.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,x.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:w(t.name,e[t.name]),children:T(e[t.name],t)},n))},t))})]})})]})]})]}):(0,x.jsx)(f,{children:(0,x.jsx)(m,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})};function I(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 L(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 R(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function z(e){return e==null?`—`:typeof e==`number`?Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2}):String(e)}function B(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]}function V(e,t,n,r,i){let[a,o]=b.useState({status:`idle`,rows:[]}),s=JSON.stringify(r??null),c=`${e}|${t.join(`,`)}|${n.join(`,`)}|${s}`;return b.useEffect(()=>{let a=i;if(!a||typeof a.queryDataset!=`function`){o({status:`error`,rows:[],error:`This data source does not support dataset queries.`});return}if(!e||n.length===0){o({status:`idle`,rows:[]});return}let s=!1;return o({status:`loading`,rows:[]}),a.queryDataset(e,{dimensions:t,measures:n,...r&&Object.keys(r).length>0?{runtimeFilter:r}:{}}).then(e=>{s||o({status:`ok`,rows:Array.isArray(e?.rows)?e.rows:[]})}).catch(e=>{s||o({status:`error`,rows:[],error:String(e?.message??e)})}),()=>{s=!0}},[c]),a}function H({dataset:e}){return(0,x.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 U({status:e,error:t}){return e===`error`?(0,x.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,x.jsx)(d,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,x.jsx)(`span`,{className:`break-words`,children:t})]}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,x.jsx)(u,{className:`h-4 w-4 animate-spin`}),` Running report…`]})}function W(){return(0,x.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,x.jsx)(_,{className:`h-6 w-6`}),` The dataset returned no rows for this report’s scope.`]})}var G=`cursor-pointer hover:bg-accent/40`;function K({dataset:e,rows:t,values:n,runtimeFilter:r,dataSource:i,onDrill:a}){let o=V(e,t,n,r,i);if(n.length===0)return(0,x.jsx)(H,{dataset:e});if(o.status===`loading`||o.status===`idle`)return(0,x.jsx)(U,{status:o.status});if(o.status===`error`)return(0,x.jsx)(U,{status:`error`,error:o.error});if(o.rows.length===0)return(0,x.jsx)(W,{});let s=!!a&&t.length>0,c=n=>{let i={};for(let e of t)i[e]=n[e];a({dataset:e,groupKey:i,runtimeFilter:r})},l=[...t,...n];return(0,x.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,children:(0,x.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,x.jsx)(`thead`,{className:`bg-muted/40`,children:(0,x.jsx)(`tr`,{children:l.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:e},e))})}),(0,x.jsx)(`tbody`,{children:o.rows.map((e,t)=>(0,x.jsx)(`tr`,{className:`border-t${s?` ${G}`:``}`,"data-testid":s?`dataset-drill-row`:void 0,onClick:s?()=>c(e):void 0,children:l.map(t=>(0,x.jsx)(`td`,{className:`px-2 py-1 tabular-nums whitespace-nowrap`,children:z(e[t])},t))},t))})]})})}function q(e,t){return e.map(e=>String(t[e]??`∅`)).join(``)}function J(e,t){return e.map(e=>z(t[e])).join(` / `)}function Y({dataset:e,rows:t,columnsAcross:n,values:r,runtimeFilter:i,dataSource:a,onDrill:o}){let s=V(e,[...t,...n],r,i,a),c=b.useMemo(()=>{if(s.status!==`ok`)return null;let e=[],r=[],i=new Set,a=new Set,o=new Map;for(let c of s.rows){let s=q(t,c),l=q(n,c);if(!i.has(s)){i.add(s);let n={};for(let e of t)n[e]=c[e];e.push({id:s,label:J(t,c),key:n})}if(!a.has(l)){a.add(l);let e={};for(let t of n)e[t]=c[t];r.push({id:l,label:J(n,c),key:e})}o.set(`${s}${l}`,c)}return{rowHeaders:e,colHeaders:r,cells:o}},[s,t,n]);if(r.length===0)return(0,x.jsx)(H,{dataset:e});if(s.status===`loading`||s.status===`idle`)return(0,x.jsx)(U,{status:s.status});if(s.status===`error`)return(0,x.jsx)(U,{status:`error`,error:s.error});if(!c||c.rowHeaders.length===0)return(0,x.jsx)(W,{});let l=!!o,u=(t,n)=>{o({dataset:e,groupKey:{...t,...n},runtimeFilter:i})},d=c.colHeaders.flatMap(e=>r.map(t=>({col:e,measure:t,header:r.length===1?e.label:`${e.label} · ${t}`})));return(0,x.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,"data-testid":`dataset-matrix`,children:(0,x.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,x.jsx)(`thead`,{className:`bg-muted/40`,children:(0,x.jsxs)(`tr`,{children:[t.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:e},e)),d.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`))]})}),(0,x.jsx)(`tbody`,{children:c.rowHeaders.map(e=>(0,x.jsxs)(`tr`,{className:`border-t`,children:[t.map(t=>(0,x.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:z(e.key[t])},t)),d.map(t=>{let n=c.cells.get(`${e.id}${t.col.id}`),r=n?.[t.measure],i=l&&n!=null;return(0,x.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap${i?` ${G}`:``}`,"data-testid":i?`dataset-drill-cell`:void 0,onClick:i?()=>u(e.key,t.col.key):void 0,children:z(r)},`${t.col.id}-${t.measure}`)})]},e.id))})]})})}var X=({report:e,dataSource:t,runtimeFilter:n,onDrill:r,className:i})=>{let a=I(e.runtimeFilter??e.filter,n),o=e.drilldown===!1?void 0:r;if(e.type===`joined`&&Array.isArray(e.blocks))return(0,x.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=I(a,e.runtimeFilter??e.filter),i=B(e.columns),s=e.type===`matrix`&&i.length>0?(0,x.jsx)(Y,{dataset:String(e.dataset??``),rows:B(e.rows),columnsAcross:i,values:B(e.values),runtimeFilter:r,dataSource:t,onDrill:o}):(0,x.jsx)(K,{dataset:String(e.dataset??``),rows:B(e.rows),values:B(e.values),runtimeFilter:r,dataSource:t,onDrill:o});return(0,x.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,x.jsxs)(`header`,{className:`flex flex-col gap-0.5`,children:[(0,x.jsx)(`h3`,{className:`text-sm font-semibold`,children:R(e.label,e.name??`Block ${n+1}`)}),e.description?(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:R(e.description,``)}):null]}),s]},e.name??`block-${n}`)})});let s=B(e.columns);return e.type===`matrix`&&s.length>0?(0,x.jsx)(`div`,{className:i,"data-testid":`dataset-report`,"data-report-name":e.name,children:(0,x.jsx)(Y,{dataset:String(e.dataset??``),rows:B(e.rows),columnsAcross:s,values:B(e.values),runtimeFilter:a,dataSource:t,onDrill:o})}):(0,x.jsx)(`div`,{className:i,"data-testid":`dataset-report`,"data-report-name":e.name,children:(0,x.jsx)(K,{dataset:String(e.dataset??``),rows:B(e.rows),values:B(e.values),runtimeFilter:a,dataSource:t,onDrill:o})})},Z=e=>{let{dataSource:t,rows:n,runtimeFilter:r,onDrill:i,className:o}=e,l=b.useContext(a),u=t??l?.dataSource,d=e.schema;return d&&typeof d==`object`&&d.type===`spec-report`&&d.report&&typeof d.report==`object`&&(d=d.report),L(d)?(0,x.jsx)(X,{report:d,dataSource:u,runtimeFilter:r,onDrill:i,className:o}):s(d)?(0,x.jsx)(`div`,{className:o,"data-testid":`report-presentation-bridge`,children:(0,x.jsx)(F,{schema:{type:`report-viewer`,report:c(d),data:n??[],showToolbar:!1}})}):(0,x.jsx)(S,{schema:d})};async function Q(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 O(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 $(e,t,n={}){let{columns:r,filename:i,includeAggregationRow:a=!1}=n,o=r||(e.fields||[]).map(le),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 ue(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=fe(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)}me(``+[s.join(` `),...c.map(e=>e.join(` `))].join(`
|
|
59
|
+
`),i||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function ce(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 Q(e,{dataSource:t,resource:n,format:r});o.push(i)}return r(e,i),o}}function le(e){return{name:e.name,header:e.label||e.name}}function ue(e,t){return e==null?``:typeof e==`number`&&t?e.toLocaleString(`en-US`,de(t)):pe(String(e))}function de(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 fe(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function pe(e){if(e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`'${e}`}return e}function me(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 he=t({DatasetReportRenderer:()=>X,LegacyReportRenderer:()=>S,ReportRenderer:()=>Z,ReportViewer:()=>F,createScheduleTrigger:()=>ce,exportAsCSV:()=>C,exportAsExcel:()=>D,exportAsHTML:()=>T,exportAsJSON:()=>w,exportAsPDF:()=>E,exportExcelWithFormulas:()=>$,exportReport:()=>O,exportWithLiveData:()=>Q,formatValue:()=>P,isDatasetReport:()=>L,mergeFilters:()=>I});o.register(`report`,Z,{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`}]}),o.register(`spec-report`,Z,{namespace:`report`,label:`Spec Report`,category:`Report`,inputs:[{name:`dataset`,type:`string`,label:`Dataset`},{name:`type`,type:`string`,label:`Report Type`}]}),o.register(`report-viewer`,F,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]});export{he as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,t as r}from"./vendor-react-DR370ovB.js";import{F as i,G as a,W as o,lt as s,mt as c,r as l,ut as u}from"./framework-crD8qZlm.js";import{A as d,N as f,y as p}from"./vendor-objectstack-RB3xvhcR.js";import{P as m,ac as h,ic as g,rc as _}from"./ui-components-BrY5joKQ.js";import{i as v}from"./vendor-ui-utils-rQOI1gAo.js";import{a as ee}from"./plugin-grid-BxyuFeJP.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:_(`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:_(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&&g(e.content)]})]},t)};return r?(0,b.jsx)(`div`,{className:_(`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:_(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:i.map((e,t)=>(0,b.jsxs)(W,{className:_(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&&g(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:_(`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};c.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=l();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,...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}),[h,g]=(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&&!c.data?(async()=>{if(!t||typeof t.find!=`function`||!e.objectName){p(!1);return}p(!0);try{let n=s(x?.fields);d(u(await t.find(e.objectName,{options:{$top:100},...n.length>0?{$expand:n}:{}})))}catch(e){console.error(e),g(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=i({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 h?(0,b.jsxs)(`div`,{className:`p-4 text-destructive`,"data-testid":`timeline-error`,role:`alert`,children:[`Error loading timeline: `,h.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)(m,{...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:_(`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:_(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:_(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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`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:_(`px-2 py-1 text-white text-xs font-medium truncate`,e),...t}));Q.displayName=`TimelineGanttBarContent`;var $=({schema:e,...t})=>{let{dataSource:n}=a()||{};return(0,b.jsx)(M,{schema:e,dataSource:n,...t})};c.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`}]}),c.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{B as r,H as i,lt as a,mt as o,r as s}from"./framework-crD8qZlm.js";import{$a as c,$r as l,$t as u,Ao as d,Bn as f,Bt as p,Cn as m,Dn as h,Ds as g,Dt as _,Ea as v,En as y,Et as b,Fa as x,Fn as S,Ga as C,Hi as w,Ho as T,Ht as E,In as ee,Jr as D,Js as te,Ki as ne,Ks as O,Ln as k,Oa as re,Ot as A,P as ie,Qt as ae,Rn as j,Rr as M,Rt as N,Si as oe,Sn as P,Tn as F,U as se,Ui as I,Vt as L,Wn as R,Zn as z,Zt as B,_i as V,_n as ce,_s as le,ai as H,an as ue,bn as de,br as fe,ci as U,cn as W,dn as pe,en as G,eo as me,et as he,fn as ge,gi as K,gn as _e,hi as ve,hn as ye,hr as be,in as xe,ka as Se,kt as q,mn as Ce,nc as we,nt as J,on as Te,pn as Ee,pr as Y,rc as X,rt as Z,so as De,to as Oe,un as ke,vn as Ae,vo as je,vs as Me,wn as Ne,xa as Pe,xn as Fe,yi as Ie,yn as Le,zi as Re,zn as ze,zt as Be}from"./ui-components-BrY5joKQ.js";import{i as Ve}from"./vendor-ui-utils-rQOI1gAo.js";import{t as He}from"./plugin-form-BABEMaum.js";import{_ as Ue,a as We,c as Ge,d as Ke,g as qe,h as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt}from"./vendor-dndkit-DMFEUxSy.js";import{r as nt}from"./plugin-grid-BxyuFeJP.js";var Q=e(t(),1),$=n(),rt={list:`List`,detail:`Detail`,grid:`Grid`,kanban:`Kanban`,calendar:`Calendar`,timeline:`Timeline`,map:`Map`,gallery:`Gallery`,gantt:`Gantt`},it={list:re,detail:je,grid:me,kanban:x,calendar:g,timeline:we,map:Pe,gallery:C,gantt:H},at=Ve(`flex gap-4`,{variants:{position:{top:`flex-col`,bottom:`flex-col-reverse`,left:`flex-row`,right:`flex-row-reverse`}},defaultVariants:{position:`top`}}),ot=Ve(`w-full`,{variants:{orientation:{horizontal:`w-full`,vertical:`w-48`}},defaultVariants:{orientation:`horizontal`}}),st=Ve(`flex gap-2`,{variants:{orientation:{horizontal:`flex-row flex-wrap`,vertical:`flex-col`}},defaultVariants:{orientation:`horizontal`}}),ct=Ve(``,{variants:{orientation:{horizontal:``,vertical:`flex h-auto flex-col items-stretch`}},defaultVariants:{orientation:`horizontal`}});function lt(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}var ut={Home:`House`};function dt(e){if(!e)return null;let t=lt(e);return be[ut[t]||t]||null}function ft(e){return e.label?e.label:rt[e.type]||e.type}function pt(e){return e.icon?dt(e.icon):it[e.type]||null}function mt(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}var ht={share:ve,settings:K,duplicate:T,delete:M},gt={share:`Share`,settings:`Settings`,duplicate:`Duplicate`,delete:`Delete`},_t=({schema:e,className:t,onViewChange:n,onCreateView:i,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,u]=Q.useState(()=>mt(e));Q.useEffect(()=>{if(e.activeView){u(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&&u(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 d=Q.useCallback(t=>{n?.(t),e.onViewChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:t}}))},[n,e.onViewChange]),f=Q.useCallback(e=>{u(e),d(e)},[d]),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&&dt(e.icon)||ht[e.type];return(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a?.(e.type,m),title:gt[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)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i?.(),title:o,children:(0,$.jsx)(Re,{className:`h-3.5 w-3.5`})}):null,C=(0,$.jsxs)(`div`,{className:X(ot({orientation:b}),`flex items-center gap-1`),children:[_===`dropdown`&&(0,$.jsxs)(N,{value:h,onValueChange:e=>f(e),children:[(0,$.jsx)(L,{className:X(`w-full`,y?`h-10`:`h-9`),children:(0,$.jsx)(E,{placeholder:`Select view`})}),(0,$.jsx)(Be,{children:e.views.map((e,t)=>(0,$.jsx)(p,{value:e.type,children:ft(e)},`${e.type}-${t}`))})]}),_===`buttons`&&(0,$.jsx)(`div`,{className:X(st({orientation:b})),children:e.views.map((e,t)=>{let n=e.type===m,r=pt(e);return(0,$.jsxs)(Y,{type:`button`,size:`sm`,variant:n?`secondary`:`ghost`,className:X(`justify-start gap-2`,y?`w-full`:``),onClick:()=>f(e.type),children:[r?(0,$.jsx)(r,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:ft(e)})]},`${e.type}-${t}`)})}),_===`tabs`&&(0,$.jsx)(he,{value:h,onValueChange:e=>f(e),children:(0,$.jsx)(J,{className:X(ct({orientation:b})),children:e.views.map((e,t)=>{let n=pt(e);return(0,$.jsxs)(Z,{value:e.type,className:X(`gap-2`,y?`justify-start`:``),children:[n?(0,$.jsx)(n,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:ft(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)(r,{schema:e,...s},`${g.type}-${t}`))}):(0,$.jsx)(r,{schema:g.schema,...s}):null;return(0,$.jsxs)(`div`,{className:X(at({position:v}),t),children:[(0,$.jsx)(`div`,{className:X(`shrink-0`,y?`flex flex-col`:`flex`),children:C}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:w})]})},vt=r,yt=({schema:e,dataSource:t,className:n,views:r,activeViewId:i,onViewChange:o,onRowClick:s,onEdit:c,renderListView:l,toolbarAddon:u,onCreateView:d,onViewAction:p})=>{let[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null);g.current=m;let[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(`create`),[x,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!(!t?.onMutation||!e.objectName)&&!l)return t.onMutation(t=>{t.resource===e.objectName&&T(e=>e+1)})},[t,e.objectName,l]);let[E,D]=(0,Q.useState)([]),[te,ne]=(0,Q.useState)(!1),[O,re]=(0,Q.useState)({}),[A,ae]=(0,Q.useState)([]),j=e.listViews,M=j!=null&&Object.keys(j).length>0,[N,oe]=(0,Q.useState)(()=>e.defaultListView&&j?.[e.defaultListView]?e.defaultListView:j&&Object.keys(j)[0]||``),P=(0,Q.useMemo)(()=>!M||!N?null:j[N]||null,[M,N,j]),F=(0,Q.useMemo)(()=>r&&r.length>0?r:null,[r]),se=F!=null&&F.length>0,I=i||F?.[0]?.id,L=F?.find(e=>e.id===I)||F?.[0],R=(0,Q.useMemo)(()=>P?.type?P.type:L?.type?L.type:e.defaultViewType||`grid`,[P,L,e.defaultViewType]),z=e.navigation;(0,Q.useEffect)(()=>{let n=!0;return e.objectName&&t&&(async()=>{try{let r=await t.getObjectSchema(e.objectName);n&&h(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&&R!==`grid`&&!(!t||!e.objectName)){ne(!0);try{let r=P?.filter||L?.filter||e.table?.defaultFilters||[],i=Object.entries(O).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>[e,`=`,t]),o=[];o=r.length>0&&i.length>0?[`and`,...r,...i]:i.length===1?i[0]:i.length>1?[`and`,...i]:r;let s=A.length>0?A.map(e=>({field:e.field,order:e.direction})):P?.sort||L?.sort||e.table?.defaultSort||void 0,c=a(g.current?.fields),l=await t.find(e.objectName,{$filter:o.length>0?o:void 0,$orderby:s,$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&&D(u)}catch(e){console.error(`ObjectView data fetch error:`,e)}finally{n&&ne(!1)}}})(),()=>{n=!1}},[e.objectName,t,R,O,A,w,P,L,l]);let B=e.layout||`drawer`,V=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},le=(0,Q.useCallback)(()=>{B===`page`&&e.onNavigate?e.onNavigate(`new`,`edit`):(b(`create`),C(null),v(!0))},[B,e]),H=(0,Q.useCallback)(t=>{if(c){c(t);return}if(B===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`edit`)}else b(`edit`),C(t),v(!0)},[B,e,c]),ue=(0,Q.useCallback)(t=>{if(B===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`view`)}else b(`view`),C(t),v(!0)},[B,e]),de=(0,Q.useCallback)(t=>{if(s){s(t);return}if(z){if(z.mode===`none`||z.preventNavigation)return;if(z.mode===`new_window`||z.openNewTab){let n=t.id||t._id,r=`/${e.objectName}/${encodeURIComponent(String(n))}`;window.open(r,`_blank`);return}if(z.mode===`drawer`){b(`view`),C(t),v(!0);return}if(z.mode===`modal`){b(`view`),C(t),v(!0);return}if(z.mode===`page`){let n=t.id||t._id;e.onNavigate&&e.onNavigate(n,`view`);return}if(z.mode===`split`||z.mode===`popover`){b(`view`),C(t),v(!0);return}}V.read!==!1&&ue(t)},[s,z,V.read,ue,e]),fe=(0,Q.useCallback)(e=>{T(e=>e+1)},[]),U=(0,Q.useCallback)(e=>{T(e=>e+1)},[]),W=(0,Q.useCallback)(()=>{v(!1),C(null),T(e=>e+1)},[]),pe=(0,Q.useCallback)(()=>{v(!1),C(null)},[]);(0,Q.useCallback)(()=>{T(e=>e+1)},[]);let G=(0,Q.useMemo)(()=>!se||!F||F.length<=1?null:{type:`view-switcher`,variant:`tabs`,position:`top`,persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:L?.type||`grid`,activeView:L?.type||`grid`,views:F.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},[se,F,L,e.objectName,e.allowCreateView,e.viewActions]),me=(0,Q.useCallback)(e=>{if(!F)return;let t=F.find(t=>t.type===e);t&&o&&o(t.id)},[F,o]),ge=(0,Q.useCallback)(e=>{oe(e)},[]);(0,Q.useMemo)(()=>{if(e.showFilters===!1)return null;let t=e.filterableFields,n=m?.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:O}},[e.showFilters,e.filterableFields,m,O]);let K=e.showSort;(0,Q.useMemo)(()=>{if(K===!1)return null;let e=m?.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:A}},[m,A,K]);let ve=(0,Q.useCallback)(t=>{let n={objectName:e.objectName,fields:P?.columns||L?.columns||e.table?.fields,className:`h-full w-full`,showSearch:L?.showSearch??e.showSearch??!1,showSort:L?.showSort??e.showSort??!1,showFilters:L?.showFilters??e.showFilters??!1,striped:L?.striped??!1,bordered:L?.bordered??!1,color:L?.color},r=P?.options||L||{};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`chart`:{let t=r.chart||{},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,P,L]),be=(0,Q.useMemo)(()=>({type:`object-grid`,objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:P?.columns||L?.columns||e.table?.fields,columns:P?.columns||L?.columns||e.table?.columns,operations:{...V,create:!1},defaultFilters:P?.filter||L?.filter||e.table?.defaultFilters,defaultSort:P?.sort||L?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:L?.striped??e.table?.striped,bordered:L?.bordered??e.table?.bordered,className:e.table?.className}),[e,V,P,L]),xe=()=>{let t=x?x.id||x._id:void 0;return{type:`object-form`,objectName:e.objectName,mode:y,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||y===`view`,className:e.form?.className,subforms:e.form?.subforms,onSuccess:W,onCancel:pe}},Se=()=>{if(e.form?.title)return e.form.title;let t=m?.label||e.objectName;switch(y){case`create`:return`Create ${t}`;case`edit`:return`Edit ${t}`;case`view`:return`View ${t}`;default:return t}},q=(0,Q.useMemo)(()=>{let e=z?.width;return e?typeof e==`number`?`max-w-[${e}px]`:`max-w-[${e}]`:``},[z]),Ce=()=>(0,$.jsx)(ye,{open:_,onOpenChange:v,direction:`right`,children:(0,$.jsxs)(_e,{className:X(`w-full sm:max-w-2xl`,q),children:[(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Le,{children:Se()}),e.form?.description&&(0,$.jsx)(ce,{children:e.form.description})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:(0,$.jsx)(He,{schema:xe(),dataSource:t})})]})}),we=()=>(0,$.jsx)(S,{open:_,onOpenChange:v,children:(0,$.jsxs)(ee,{className:X(`max-w-2xl max-h-[90vh] overflow-y-auto`,q),children:[(0,$.jsxs)(ze,{children:[(0,$.jsx)(f,{children:Se()}),e.form?.description&&(0,$.jsx)(k,{children:e.form.description})]}),(0,$.jsx)(He,{schema:xe(),dataSource:t})]})}),Te=(0,Q.useMemo)(()=>Object.keys(O).some(e=>O[e]!==void 0&&O[e]!==``&&O[e]!==null)?Object.entries(O).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>({field:e,operator:`equals`,value:t})):P?.filter||L?.filter||e.table?.defaultFilters,[O,P,L,e.table?.defaultFilters]),Ee=(0,Q.useMemo)(()=>A.length>0?A:P?.sort||L?.sort||e.table?.defaultSort,[A,P,L,e.table?.defaultSort]),De=()=>{let n=`${e.objectName}-${N||L?.id||`default`}-${R}-${w}`;if(l)return l({schema:{type:`list-view`,objectName:e.objectName,viewType:R,fields:P?.columns||L?.columns||e.table?.fields,filters:Te,sort:Ee,rowHeight:L?.rowHeight,densityMode:L?.densityMode,groupBy:L?.groupBy,groupBy2:L?.groupBy2,grouping:L?.grouping,options:P?.options||L,showSearch:L?.showSearch??e.showSearch,showFilters:L?.showFilters??e.showFilters,showSort:L?.showSort??e.showSort,showHideFields:L?.showHideFields??e.showHideFields,showGroup:L?.showGroup??e.showGroup,showColor:L?.showColor??e.showColor,showDensity:L?.showDensity??e.showDensity,compactToolbar:L?.compactToolbar??e.compactToolbar,allowExport:L?.allowExport??e.allowExport,striped:L?.striped??e.striped,bordered:L?.bordered??e.bordered,color:L?.color??e.color,inlineEdit:L?.inlineEdit??e.inlineEdit,wrapHeaders:L?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:L?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:L?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:L?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:L?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:L?.fieldTextColor??e.fieldTextColor,prefixField:L?.prefixField??e.prefixField,showDescription:L?.showDescription??e.showDescription,navigation:L?.navigation??e.navigation,selection:L?.selection??e.selection,pagination:L?.pagination??e.pagination,searchableFields:L?.searchableFields??e.searchableFields,filterableFields:L?.filterableFields??e.filterableFields,resizable:L?.resizable??e.resizable,hiddenFields:L?.hiddenFields??e.hiddenFields,rowActions:L?.rowActions??e.rowActions,rowActionDefs:L?.rowActionDefs??e.rowActionDefs,bulkActions:L?.bulkActions??e.bulkActions,sharing:L?.sharing??e.sharing,addRecord:L?.addRecord??e.addRecord,conditionalFormatting:L?.conditionalFormatting??e.conditionalFormatting,quickFilters:L?.quickFilters??e.quickFilters,userFilters:L?.userFilters??e.userFilters,showRecordCount:L?.showRecordCount??e.showRecordCount,allowPrinting:L?.allowPrinting??e.allowPrinting,virtualScroll:L?.virtualScroll??e.virtualScroll,emptyState:L?.emptyState??e.emptyState,aria:L?.aria??e.aria,tabs:e.tabs,refreshTrigger:w},dataSource:t,onEdit:H,onRowClick:de,className:`h-full`,refreshKey:w});if(R!==`grid`){let e=ve(R);if(e&&vt)return(0,$.jsx)(vt,{schema:e,dataSource:t,data:E,loading:te},n);if(!vt)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 `,R,` views.`]})})}return(0,$.jsx)(nt,{schema:be,dataSource:t,onRowClick:de,onEdit:V.update===!1?void 0:H,onDelete:V.delete===!1?void 0:fe,onBulkDelete:V.delete===!1?void 0:U},n)},Oe=()=>{if(!M)return null;let e=Object.entries(j);return e.length<=1?null:(0,$.jsx)(he,{value:N,onValueChange:ge,className:`w-full`,children:(0,$.jsx)(J,{className:`w-auto`,children:e.map(([e,t])=>(0,$.jsx)(Z,{value:e,className:`text-sm`,children:t.label||e},e))})})},ke=()=>{let t=e.showCreate!==!1&&V.create!==!1,n=e.showViewSwitcher===!0,r=Oe();return!r&&!n&&!t&&!u?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(n||t||u)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:n&&G&&(0,$.jsx)(_t,{schema:G,onViewChange:me,onCreateView:d,onViewAction:p,className:`overflow-x-auto`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u,t&&(0,$.jsxs)(Y,{size:`sm`,onClick:le,children:[(0,$.jsx)(Re,{className:`h-4 w-4`}),`Create`]})]})]})]})},je=z?.mode===`modal`?`modal`:z?.mode===`drawer`?`drawer`:z?.mode===`split`?`split`:z?.mode===`popover`?`popover`:B,Me=e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsx)(He,{schema:xe(),dataSource:t})}),Ne=(0,Q.useCallback)(e=>{e||pe()},[pe]);if(je===`split`){let t=m?.label||e.objectName;return(0,$.jsxs)(`div`,{className:X(`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:ke()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:_&&x?(0,$.jsx)(ie,{isOpen:_,selectedRecord:x,mode:`split`,close:pe,setIsOpen:Ne,width:z?.width,isOverlay:!0,title:`${t} Detail`,mainContent:(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:De()}),children:Me}):De()})]})}return(0,$.jsxs)(`div`,{className:X(`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:ke()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:De()}),je===`drawer`&&Ce(),je===`modal`&&we(),je===`popover`&&_&&x&&(0,$.jsx)(ie,{isOpen:_,selectedRecord:x,mode:`popover`,close:pe,setIsOpen:Ne,width:z?.width,isOverlay:!0,title:Se(),children:Me})]})},bt=Ve(`flex`,{variants:{layout:{inline:`flex-col space-y-4`,popover:`items-center`,drawer:`items-center`}},defaultVariants:{layout:`inline`}}),xt=e=>e==null||e===``?!0:Array.isArray(e)?e.length===0:typeof e==`object`?Object.values(e).every(e=>e==null||e===``):!1,St=e=>Array.isArray(e)?{start:e[0]||``,end:e[1]||``}:e&&typeof e==`object`?{start:e.start||``,end:e.end||``}:{start:``,end:``},Ct=({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]),l=Q.useCallback(()=>{let t={};if(i(t),e.showApply){s(t);return}s(t)},[s,e.showApply]),d=Q.useCallback(()=>{s(r),o(!1)},[s,r]),f=Q.useMemo(()=>Object.values(r).filter(e=>!xt(e)).length,[r]),m=e=>{let t=e.label||e.field,n=e.placeholder||`Filter by ${t}`;switch(e.type){case`number`:return(0,$.jsx)(G,{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)(N,{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)(L,{children:(0,$.jsx)(E,{placeholder:n})}),(0,$.jsx)(Be,{children:e.options?.map(e=>(0,$.jsx)(p,{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:X(`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)(R,{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)(G,{type:`date`,value:r[e.field]??``,onChange:t=>c(e.field,t.target.value)});case`date-range`:{let t=St(r[e.field]);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{type:`date`,value:t.start??``,onChange:n=>{c(e.field,{...t,start:n.target.value})}}),(0,$.jsx)(G,{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)(R,{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)(G,{value:r[e.field]??``,placeholder:n,onChange:t=>c(e.field,t.target.value)})}},h=(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)(xe,{className:`text-xs text-muted-foreground`,children:e.label||e.field}),m(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)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:`Clear`}),e.showApply&&(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:d,children:`Apply`})]})]}),g=e.layout||`inline`;return g===`popover`?(0,$.jsx)(`div`,{className:X(bt({layout:g}),t),children:(0,$.jsxs)(B,{open:a,onOpenChange:o,children:[(0,$.jsx)(u,{asChild:!0,children:(0,$.jsxs)(Y,{type:`button`,variant:f>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(U,{className:`h-4 w-4`}),`Filters`,f>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:f})]})}),(0,$.jsx)(ae,{align:`start`,className:`w-[520px] p-4`,children:h})]})}):g===`drawer`?(0,$.jsxs)(`div`,{className:X(bt({layout:g}),t),children:[(0,$.jsxs)(Y,{type:`button`,variant:f>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,onClick:()=>o(!0),children:[(0,$.jsx)(U,{className:`h-4 w-4`}),`Filters`,f>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:f})]}),(0,$.jsx)(ye,{open:a,onOpenChange:o,children:(0,$.jsxs)(_e,{children:[(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Le,{children:`Filters`}),(0,$.jsx)(ce,{children:`Refine the data with advanced filters.`})]}),(0,$.jsx)(`div`,{className:`px-4 pb-6`,children:h})]})})]}):(0,$.jsxs)(`div`,{className:X(bt({layout:g}),t),children:[h,!e.showApply&&e.showClear&&(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`gap-2`,onClick:l,children:[(0,$.jsx)(fe,{className:`h-3.5 w-3.5`}),`Clear filters`]})]})},wt=Ve(``,{variants:{variant:{buttons:`flex flex-wrap gap-2`,dropdown:`flex flex-wrap items-center gap-3`,builder:`space-y-3`}},defaultVariants:{variant:`dropdown`}}),Tt=e=>e?e.map(e=>({field:e.field,direction:e.direction})):[],Et=e=>e.map(e=>({id:`${e.field}-${e.direction}`,field:e.field,order:e.direction})),Dt=e=>e.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})),Ot=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(()=>Tt(e.sort)),[a,o]=Q.useState(()=>Et(Tt(e.sort)));Q.useEffect(()=>{let t=Tt(e.sort);i(t),o(Et(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:X(wt({variant:`buttons`}),t),children:e.fields.map(e=>{let t=r.find(t=>t.field===e.field);return(0,$.jsxs)(Y,{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)(O,{className:X(`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:X(wt({variant:`builder`}),t),children:(0,$.jsx)(se,{fields:e.fields.map(e=>({value:e.field,label:e.label||e.field})),value:a,onChange:e=>{o(e),s(Dt(e))}})});let l=r[0];return(0,$.jsxs)(`div`,{className:X(wt({variant:`dropdown`}),t),children:[(0,$.jsxs)(N,{value:l?.field||``,onValueChange:e=>{if(!e){s([]);return}s([{field:e,direction:l?.direction||`asc`}])},children:[(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsx)(E,{placeholder:`Select field`})}),(0,$.jsx)(Be,{children:e.fields.map(e=>(0,$.jsx)(p,{value:e.field,children:e.label||e.field},e.field))})]}),(0,$.jsxs)(N,{value:l?.direction||`asc`,onValueChange:e=>{l?.field&&s([{field:l.field,direction:e}])},children:[(0,$.jsx)(L,{className:`w-36`,children:(0,$.jsx)(E,{})}),(0,$.jsxs)(Be,{children:[(0,$.jsx)(p,{value:`asc`,children:`Ascending`}),(0,$.jsx)(p,{value:`desc`,children:`Descending`})]})]})]})};function kt(){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 At(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}var jt=({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(``),_=n??(typeof window<`u`?window.location.origin:``),y=Q.useCallback(()=>{let n=At(_,e,t,kt());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})},[_,e,t,r,f,m]),b=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)(u,{asChild:!0,children:(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,className:X(`gap-2`,i),children:[(0,$.jsx)(ve,{className:`h-4 w-4`}),`Share`]})}),(0,$.jsxs)(ae,{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)(z,{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)(G,{value:a,readOnly:!0,className:`h-8 text-xs`,onClick:e=>e.target.select()}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:b,className:`shrink-0 gap-1`,children:s?(0,$.jsx)(Me,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(T,{className:`h-4 w-4`})})]}),(f||m)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[f&&(0,$.jsxs)(z,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(v,{className:`h-3 w-3`}),`Password protected`]}),m&&(0,$.jsxs)(z,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(g,{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)(v,{className:`h-3.5 w-3.5`}),`Password protection (optional)`]}),(0,$.jsx)(G,{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)(g,{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)(Y,{onClick:y,className:`w-full gap-2`,size:`sm`,children:[(0,$.jsx)(ve,{className:`h-4 w-4`}),`Generate Link`]})]})]})]})};function Mt(){try{let{t:e}=s();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:i}}catch{return(e,t)=>t}}var Nt={private:0,team:1,organization:2,public:3},Pt=8,Ft=({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:Ue.Transform.toString(o),transition:s,zIndex:c?10:void 0,opacity:c?.5:void 0},listeners:i,attributes:r,isDragging:c})})},It=({views:e,activeViewId:t,onViewChange:n,viewTypeIcons:r={},config:i={},onAddView:a,onRenameView:o,onDuplicateView:s,onDeleteView:u,onSetDefaultView:f,onShareView:p,onSaveAsView:g,onPinView:S,onReorderViews:C,onChangeViewType:E,onConfigView:ee,onManageViews:O,availableViewTypes:k,hasUnsavedChanges:re=!1,onResetChanges:ie,className:ae})=>{let{showAddButton:j=!0,inlineRename:N=!0,contextMenu:se=!0,reorderable:L=!1,maxVisibleTabs:R=4,showIndicators:z=!0,showSaveAsView:B=!0,showPinnedSection:ce=!0,showVisibilityGroups:H=!1}=i,fe=Mt(),[U,me]=(0,Q.useState)(null),[he,K]=(0,Q.useState)(``),_e=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{U&&_e.current&&(_e.current.focus(),_e.current.select())},[U]);let ye=(0,Q.useCallback)(t=>{if(!N||!o)return;let n=e.find(e=>e.id===t);n&&(n.readonly||(me(t),K(n.label)))},[N,o,e]),be=(0,Q.useCallback)(()=>{U&&he.trim()&&o&&o(U,he.trim()),me(null),K(``)},[U,he,o]),xe=(0,Q.useCallback)(()=>{me(null),K(``)},[]),we=(0,Q.useMemo)(()=>e.length>0&&e.every(e=>!!e.readonly),[e]),J=(0,Q.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{if(ce){let n=+!!e.isPinned,r=+!!t.isPinned;if(n!==r)return r-n}if(H){let n=Nt[e.visibility||`public`]??Nt.public,r=Nt[t.visibility||`public`]??Nt.public;if(n!==r)return n-r}return 0}),t},[e,ce,H]),{visibleViews:Z,overflowViews:Ae}=(0,Q.useMemo)(()=>{let e=J.slice(0,R),n=J.slice(R),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}},[J,R,t]),je=qe(Je(Ke,{activationConstraint:{distance:Pt}}),Je(tt)),Me=(0,Q.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!C)return;let r=J.findIndex(e=>e.id===t.id),i=J.findIndex(e=>e.id===n.id);r===-1||i===-1||C(Ye(J,r,i).map(e=>e.id))},[J,C]),Pe=D,Ie=(0,Q.useCallback)(e=>{if(!H||e===0)return!1;let t=Z[e-1],n=Z[e],r=e=>e.visibility===`private`;return r(t)&&!r(n)},[H,Z]),Le=(e,i)=>{let a=e.id===t,d=r[e.type]||Pe,g=U===e.id,D=z&&(e.hasActiveFilters||e.hasActiveSort),re=Ie(i),A=!!e.readonly,ie=(e=>H?e.visibility===`private`?(0,$.jsx)(v,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):e.visibility?(0,$.jsx)(Oe,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):null:null)(e),ae=t=>(0,$.jsxs)(`div`,{"data-testid":`view-tab-${e.id}`,role:`tab`,tabIndex:0,"aria-selected":a,onClick:()=>!g&&n(e.id),onDoubleClick:()=>ye(e.id),onKeyDown:t=>{!g&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id))},...t?.listeners??{},...t?.attributes??{},className:X(`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:[L&&C&&(0,$.jsx)(`span`,{"data-testid":`view-tab-drag-handle-${e.id}`,"aria-hidden":`true`,className:X(`text-muted-foreground transition-opacity pointer-events-none`,`opacity-0 group-hover/tab:opacity-100`,t?.isDragging&&`opacity-100`),children:(0,$.jsx)(c,{className:`h-3 w-3`})}),ce&&e.isPinned&&(0,$.jsx)(I,{"data-testid":`view-tab-pin-indicator-${e.id}`,className:`h-3 w-3 text-primary shrink-0`}),ie,(0,$.jsx)(d,{className:`h-3.5 w-3.5`}),g?(0,$.jsx)(G,{ref:_e,"data-testid":`view-tab-rename-input-${e.id}`,value:he,onChange:e=>K(e.target.value),onBlur:be,onKeyDown:e=>{e.key===`Enter`&&be(),e.key===`Escape`&&xe()},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}),A&&!we&&(0,$.jsxs)(b,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(v,{"data-testid":`view-tab-readonly-${e.id}`,"aria-label":fe(`view.readonlyAriaLabel`,`Read-only view`),className:`h-3 w-3 text-muted-foreground shrink-0`})}),(0,$.jsx)(_,{side:`bottom`,className:`text-xs`,children:e.readonlyReason||fe(`view.readonlyTooltip`,`System view — defined in code, read-only.`)})]}),D&&(0,$.jsxs)(b,{children:[(0,$.jsx)(q,{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)(De,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(te,{className:`h-2.5 w-2.5`})]})}),(0,$.jsx)(_,{side:`bottom`,className:`text-xs`,children:[e.hasActiveFilters&&`Active filters`,e.hasActiveSort&&`Active sort`].filter(Boolean).join(`, `)})]}),e.isDefault&&(0,$.jsx)(l,{className:`h-3 w-3 text-amber-500 fill-amber-500 shrink-0`}),a&&(ee||o||s||u)&&(0,$.jsxs)(ue,{children:[(0,$.jsx)(Ce,{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":fe(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),children:(0,$.jsx)(le,{className:`h-3 w-3`})})}),(0,$.jsxs)(Te,{align:`start`,className:`min-w-[180px]`,onClick:e=>e.stopPropagation(),children:[ee&&!A&&(0,$.jsxs)(W,{"data-testid":`view-tab-menu-config-${e.id}`,onClick:()=>ee(e.id),children:[(0,$.jsx)(V,{className:`h-4 w-4 mr-2`}),` Edit view config`]}),o&&!A&&(0,$.jsxs)(W,{"data-testid":`view-tab-menu-rename-${e.id}`,onClick:()=>ye(e.id),children:[(0,$.jsx)(ne,{className:`h-4 w-4 mr-2`}),` Rename`]}),s&&(0,$.jsxs)(W,{"data-testid":`view-tab-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Duplicate view`]}),p&&(0,$.jsxs)(W,{"data-testid":`view-tab-menu-share-${e.id}`,onClick:()=>p(e.id),children:[(0,$.jsx)(ve,{className:`h-4 w-4 mr-2`}),` Share view`]}),f&&!A&&(0,$.jsxs)(W,{"data-testid":`view-tab-menu-default-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(l,{className:`h-4 w-4 mr-2`}),` Set as default`]}),S&&!A&&(0,$.jsx)(W,{"data-testid":`view-tab-menu-pin-${e.id}`,onClick:()=>S(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` Unpin view`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` Pin view`]})}),E&&!A&&k&&k.length>0&&(0,$.jsxs)(pe,{children:[(0,$.jsxs)(Ee,{"data-testid":`view-tab-menu-change-type-${e.id}`,children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` Change view type`]}),(0,$.jsx)(ge,{children:k.map(t=>{let n=r[t.type]||Pe;return(0,$.jsxs)(W,{"data-testid":`view-tab-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>E(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsx)(`span`,{children:t.label})]},t.type)})})]}),u&&!A&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ke,{}),(0,$.jsxs)(W,{"data-testid":`view-tab-menu-delete-${e.id}`,onClick:()=>u(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(M,{className:`h-4 w-4 mr-2`}),` Delete view`]})]}),O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ke,{}),(0,$.jsxs)(W,{"data-testid":`view-tab-menu-manage-${e.id}`,onClick:O,children:[(0,$.jsx)(Se,{className:`h-4 w-4 mr-2`}),` Manage all views…`]})]})]})]})]}),j=t=>!se||g?t:(0,$.jsxs)(de,{children:[(0,$.jsx)(h,{asChild:!0,children:t}),(0,$.jsxs)(Fe,{children:[o&&!A&&(0,$.jsxs)(P,{"data-testid":`context-menu-rename-${e.id}`,onClick:()=>ye(e.id),children:[(0,$.jsx)(ne,{className:`h-4 w-4 mr-2`}),` Rename`]}),s&&(0,$.jsxs)(P,{"data-testid":`context-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Duplicate View`]}),p&&(0,$.jsxs)(P,{"data-testid":`context-menu-share-${e.id}`,onClick:()=>p(e.id),children:[(0,$.jsx)(ve,{className:`h-4 w-4 mr-2`}),` Share View`]}),f&&!A&&(0,$.jsxs)(P,{"data-testid":`context-menu-default-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(l,{className:`h-4 w-4 mr-2`}),` Set as Default`]}),S&&!A&&(0,$.jsx)(P,{"data-testid":`context-menu-pin-${e.id}`,onClick:()=>S(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` Unpin View`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` Pin View`]})}),E&&!A&&k&&k.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{}),(0,$.jsxs)(Ne,{children:[(0,$.jsxs)(y,{"data-testid":`context-menu-change-type-${e.id}`,children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` Change View Type`]}),(0,$.jsx)(F,{"data-testid":`context-menu-type-submenu-${e.id}`,children:k.map(t=>{let n=r[t.type]||Pe;return(0,$.jsxs)(P,{"data-testid":`context-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>E(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)})})]})]}),u&&!A&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{}),(0,$.jsxs)(P,{"data-testid":`context-menu-delete-${e.id}`,onClick:()=>u(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(M,{className:`h-4 w-4 mr-2`}),` Delete View`]})]}),O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{}),(0,$.jsxs)(P,{"data-testid":`context-menu-manage-${e.id}`,onClick:O,children:[(0,$.jsx)(Se,{className:`h-4 w-4 mr-2`}),` Manage all views…`]})]})]})]});return L&&C?(0,$.jsxs)(Q.Fragment,{children:[re&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),(0,$.jsx)(Ft,{id:e.id,children:({setNodeRef:e,style:t,listeners:n,attributes:r,isDragging:i})=>(0,$.jsx)(`div`,{ref:e,style:t,className:X(`flex`,i&&`z-10`),children:j(ae({listeners:n,attributes:r,isDragging:i}))})})]},e.id):(0,$.jsxs)(Q.Fragment,{children:[re&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),j(ae())]},e.id)},ze=(0,$.jsx)($.Fragment,{children:Z.map((e,t)=>Le(e,t))});return(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{"data-testid":`view-tab-bar`,className:X(`flex items-center gap-0.5 -mb-px`,ae),children:[L&&C?(0,$.jsx)(Ge,{sensors:je,collisionDetection:Ze,onDragEnd:Me,children:(0,$.jsx)(et,{items:Z.map(e=>e.id),strategy:Qe,children:(0,$.jsx)(`div`,{"data-testid":`view-tab-sortable-container`,className:`flex items-center gap-0.5`,children:ze})})}):ze,Ae.length>0&&(0,$.jsxs)(ue,{children:[(0,$.jsx)(Ce,{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)(d,{className:`h-4 w-4`}),(0,$.jsxs)(`span`,{className:`text-xs`,children:[Ae.length,` more`]})]})}),(0,$.jsxs)(Te,{align:`end`,children:[O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(W,{"data-testid":`view-tab-overflow-manage`,onClick:O,className:`font-medium`,children:[(0,$.jsx)(Se,{className:`h-4 w-4 mr-2`}),` Manage all views…`]}),(0,$.jsx)(ke,{})]}),Ae.map(e=>{let t=r[e.type]||Pe;return(0,$.jsxs)(W,{"data-testid":`view-tab-overflow-${e.id}`,onClick:()=>n(e.id),children:[e.isPinned&&(0,$.jsx)(I,{className:`h-3 w-3 mr-1 text-primary shrink-0`}),(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),e.label,z&&(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)(De,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(te,{className:`h-2.5 w-2.5`})]})]},e.id)})]})]}),j&&a&&(0,$.jsxs)(b,{children:[(0,$.jsx)(q,{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)(Re,{className:`h-4 w-4`})})}),(0,$.jsx)(_,{children:`Add View`})]}),B&&re&&(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)(oe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Unsaved changes`}),g&&(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-save-as-btn`,className:`h-6 px-2 text-xs`,onClick:g,children:`Save as View`}),ie&&(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-reset-btn`,className:`h-6 px-2 text-xs`,onClick:ie,children:`Reset`})]})]})})},Lt=D,Rt=({view:e,isActive:t,Icon:n,isRenaming:r,onStartRename:i,onCommitRename:a,onCancelRename:o,onRowClick:s,onDelete:u,onDuplicate:f,onSetDefault:p,onSetPinned:m,onConfigView:h})=>{let{attributes:g,listeners:y,setNodeRef:x,transform:S,transition:C,isDragging:E}=Xe({id:e.id}),ee={transform:Ue.Transform.toString(S),transition:C,opacity:E?.5:1},D=(0,Q.useRef)(null),[te,O]=(0,Q.useState)(e.label),k=!!e.readonly;(0,Q.useEffect)(()=>{r&&(O(e.label),requestAnimationFrame(()=>{D.current?.focus(),D.current?.select()}))},[r,e.label]);let re=(0,Q.useCallback)(()=>{let t=te.trim();t&&t!==e.label?a(e.id,t):o()},[te,e.id,e.label,a,o]);return(0,$.jsxs)(`li`,{ref:x,style:ee,"data-testid":`manage-views-row-${e.id}`,className:X(`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`,E&&`shadow-md bg-background border-border z-10`),children:[(0,$.jsx)(`button`,{type:`button`,...g,...y,"aria-label":`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)(c,{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)(G,{ref:D,value:te,onChange:e=>O(e.target.value),onBlur:re,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),re()):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)(v,{"aria-label":`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:`Default view`,children:[(0,$.jsx)(l,{className:`h-3 w-3 mr-0.5 fill-current`}),` default`]})]})}),m&&!r&&!k&&(0,$.jsx)(A,{delayDuration:300,children:(0,$.jsxs)(b,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":e.isPinned?`Unpin view`:`Pin view`,"data-testid":`manage-views-pin-${e.id}`,onClick:t=>{t.stopPropagation(),m(e.id,!e.isPinned)},className:X(`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)(I,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(I,{className:`h-4 w-4`})})}),(0,$.jsx)(_,{side:`top`,children:e.isPinned?`Unpin view`:`Pin view`})]})}),p&&!r&&!e.isDefault&&!k&&(0,$.jsx)(A,{delayDuration:300,children:(0,$.jsxs)(b,{children:[(0,$.jsx)(q,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Set as default`,"data-testid":`manage-views-default-${e.id}`,onClick:t=>{t.stopPropagation(),p(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)(l,{className:`h-4 w-4`})})}),(0,$.jsx)(_,{side:`top`,children:`Set as default`})]})}),!r&&(u||f||h||p)&&(0,$.jsxs)(ue,{children:[(0,$.jsx)(Ce,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Actions for ${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)(d,{className:`h-4 w-4`})})}),(0,$.jsxs)(Te,{align:`end`,className:`min-w-[180px]`,children:[!k&&(0,$.jsxs)(W,{"data-testid":`manage-views-action-rename-${e.id}`,onClick:()=>i(e.id),children:[(0,$.jsx)(ne,{className:`h-4 w-4 mr-2`}),` Rename`]}),f&&(0,$.jsxs)(W,{"data-testid":`manage-views-action-duplicate-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Duplicate`]}),h&&!k&&(0,$.jsxs)(W,{"data-testid":`manage-views-action-config-${e.id}`,onClick:()=>h(e.id),children:[(0,$.jsx)(ne,{className:`h-4 w-4 mr-2`}),` Edit configuration…`]}),p&&!e.isDefault&&!k&&(0,$.jsxs)(W,{"data-testid":`manage-views-action-default-${e.id}`,onClick:()=>p(e.id),children:[(0,$.jsx)(l,{className:`h-4 w-4 mr-2`}),` Set as default`]}),m&&!k&&(0,$.jsx)(W,{"data-testid":`manage-views-action-pin-${e.id}`,onClick:()=>m(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` Unpin`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` Pin`]})}),u&&!k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ke,{}),(0,$.jsxs)(W,{"data-testid":`manage-views-action-delete-${e.id}`,onClick:()=>u(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(M,{className:`h-4 w-4 mr-2`}),` Delete`]})]})]})]}),r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Save name`,onMouseDown:e=>e.preventDefault(),onClick:re,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-emerald-600`,children:(0,$.jsx)(Me,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Cancel rename`,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)(fe,{className:`h-4 w-4`})})]})]})},zt=({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:p})=>{let[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(()=>n.map(e=>e.id));(0,Q.useEffect)(()=>{y(n.map(e=>e.id))},[n]),(0,Q.useEffect)(()=>{e||(_(null),h(``))},[e]);let b=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e]));return v.map(t=>e.get(t)).filter(Boolean)},[v,n]),x=(0,Q.useMemo)(()=>{if(!m.trim())return b;let e=m.toLowerCase();return b.filter(t=>t.label.toLowerCase().includes(e))},[b,m]),C=qe(Je(Ke,{activationConstraint:{distance:5}}),Je(tt,{coordinateGetter:We})),w=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);y(a),u?.(a)},T=e=>{t(!1),requestAnimationFrame(()=>p?.(e))};return(0,$.jsx)(S,{open:e,onOpenChange:t,children:(0,$.jsxs)(ee,{className:`sm:max-w-[560px] p-0 gap-0 overflow-hidden`,"data-testid":`manage-views-dialog`,children:[(0,$.jsxs)(ze,{className:`px-5 pt-5 pb-3`,children:[(0,$.jsx)(f,{className:`text-base`,children:`Manage views`}),(0,$.jsx)(k,{className:`text-xs`,children:`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)(Ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(G,{value:m,onChange:e=>h(e.target.value),placeholder:`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:x.length===0?(0,$.jsx)(`div`,{className:`text-center text-sm text-muted-foreground py-10`,children:`No views match your search.`}):(0,$.jsx)(Ge,{sensors:C,collisionDetection:Ze,onDragEnd:w,children:(0,$.jsx)(et,{items:x.map(e=>e.id),strategy:$e,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:x.map(e=>(0,$.jsx)(Rt,{view:e,Icon:i[e.type]||Lt,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:p?T:void 0},e.id))})})})}),(0,$.jsxs)(j,{className:`border-t bg-muted/30 px-5 py-3 flex sm:justify-between gap-2`,children:[d?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),requestAnimationFrame(()=>d())},"data-testid":`manage-views-add`,className:`text-sm`,children:[(0,$.jsx)(Re,{className:`h-4 w-4 mr-1.5`}),` Add new view`]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>t(!1),"data-testid":`manage-views-done`,children:`Done`})]})]})})};function Bt(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 Vt(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:Bt(t.type),options:t.options,rawType:t.type,rawName:e})):[]}var Ht=new Set([`image`,`image_url`,`photo`,`picture`,`avatar`,`file`,`attachment`,`attachments`,`media`,`url`,`link`]),Ut=[`image`,`photo`,`picture`,`avatar`,`thumbnail`,`thumb`,`logo`,`cover`,`banner`,`icon`,`attachment`];function Wt(e){if(!e)return!1;let t=(e.rawType||e.type||``).toLowerCase();if(Ht.has(t))return!0;let n=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return n?Ut.some(e=>n.includes(e)):!1}var Gt=new Set([`geolocation`,`geo`,`geo_point`,`geopoint`,`location`,`latlng`,`lnglat`]);function Kt(e,t){if(!e)return!1;let n=(e.rawType||e.type||``).toLowerCase();if(Gt.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 qt(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 Jt=[`status`,`stage`,`state`,`priority`,`category`,`type`],Yt=[`start_date`,`startdate`,`due_date`,`duedate`,`event_date`,`date`,`created_at`,`createdat`,`created`],Xt=[`end_date`,`enddate`,`finish_date`,`completion_date`,`closed_at`],Zt=i,Qt=({schema:e})=>(0,$.jsx)(yt,{schema:e,dataSource:(0,Q.useContext)(Zt)?.dataSource??null});o.register(`object-view`,Qt,{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}}),o.register(`view`,Qt,{namespace:`plugin-view`,label:`View`,category:`view`}),o.register(`view-switcher`,_t,{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`}}]}}),o.register(`filter-ui`,Ct,{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`}]}}),o.register(`sort-ui`,Ot,{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`}]}}),o.register(`shared-view-link`,jt,{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`}}),o.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{Kt as a,zt as c,Vt as i,It as l,Jt as n,Wt as o,Yt as r,qt as s,Xt as t,yt as u};
|