@object-ui/console 3.3.1 → 3.4.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/AppManagementPage-CLr3paaF.js +1 -0
- package/dist/assets/ConsoleFloatingChatbot-C_ClJ2NU.js +1 -0
- package/dist/assets/DashboardView-CODdYLuL.js +1 -0
- package/dist/assets/MetadataDetailPage-C1sWJhl2.js +1 -0
- package/dist/assets/MetadataFormDialog-Cje6P_Wf.js +1 -0
- package/dist/assets/MetadataManagerPage-DobP393N.js +1 -0
- package/dist/assets/PageView-DZHuurne.js +2 -0
- package/dist/assets/ProfilePage-6u6k00rh.js +1 -0
- package/dist/assets/RecordDetailView-cFSCvmx3.js +1 -0
- package/dist/assets/ReportView-oYVEbfYq.js +2 -0
- package/dist/assets/SearchResultsPage-BjAVc5rm.js +1 -0
- package/dist/assets/SystemHubPage-D08IDX3M.js +1 -0
- package/dist/assets/data-adapter-CleWpyQH.js +1 -0
- package/dist/assets/framework-CoXA0nY6.js +2 -0
- package/dist/assets/getIcon-vBP44wSb.js +1 -0
- package/dist/assets/index-98Lfd5ty.js +2 -0
- package/dist/assets/index-C162ArSl.css +2 -0
- package/dist/assets/{infrastructure-94fpO8jL.js → infrastructure-Djv3I7gr.js} +2 -2
- package/dist/assets/plugin-calendar-DX_UWouT.js +1 -0
- package/dist/assets/plugin-charts-BvZ1cSiZ.js +7 -0
- package/dist/assets/plugin-chatbot-DeSEtutf.js +24 -0
- package/dist/assets/plugin-form-BhbVu8jO.js +1 -0
- package/dist/assets/plugin-gantt-BG1WaV_b.js +1 -0
- package/dist/assets/plugin-grid-DwpWK0E8.js +8 -0
- package/dist/assets/plugin-kanban-Dzjqra5U.js +1 -0
- package/dist/assets/plugin-map-B7EfyDsf.js +1 -0
- package/dist/assets/plugin-map-CsMXqW6n.css +1 -0
- package/dist/assets/plugin-markdown-CiHluuxA.js +7 -0
- package/dist/assets/plugin-timeline-D8_YFDQQ.js +1 -0
- package/dist/assets/plugin-view-CXAFUa14.js +1 -0
- package/dist/assets/plugins-views-C5gstDGy.js +63 -0
- package/dist/assets/src-iMF4J4F7.js +1 -0
- package/dist/assets/ui-components-BCmPcwhR.js +36 -0
- package/dist/assets/ui-layout-BLl7ARoe.js +1 -0
- package/dist/assets/vendor-charts-DHZsyaJw.js +36 -0
- package/dist/assets/vendor-dndkit-BGB4qgc3.js +5 -0
- package/dist/assets/vendor-i18n-D3W5EAHR.js +1 -0
- package/dist/assets/vendor-icons-core-s9WPLoP3.js +1 -0
- package/dist/assets/vendor-markdown-D-LpQJes.js +29 -0
- package/dist/assets/vendor-objectstack-CBpPY_xk.js +39 -0
- package/dist/assets/vendor-radix-Bj7uHNWN.js +56 -0
- package/dist/assets/vendor-react-B1k2FF9f.js +11 -0
- package/dist/assets/vendor-ui-utils-AywTz3cM.js +1 -0
- package/dist/index.html +7 -26
- package/package.json +33 -33
- package/dist/assets/AdapterProvider-Cd4HYb7q.js +0 -1
- package/dist/assets/AdvancedChartImpl-AY6sVw1n.js +0 -7
- package/dist/assets/AppManagementPage-6l5ZKnv5.js +0 -1
- package/dist/assets/ChartImpl-DiKY5voi.js +0 -1
- package/dist/assets/DashboardView-BnX2k5Kx.js +0 -1
- package/dist/assets/KanbanEnhanced-BKCx2XIr.js +0 -1
- package/dist/assets/KanbanImpl-e9jzV-UD.js +0 -1
- package/dist/assets/MarkdownImpl-B-r7jSIS.js +0 -1
- package/dist/assets/MetadataDetailPage--3o8VI1T.js +0 -1
- package/dist/assets/MetadataFormDialog-Cy7k0Y55.js +0 -1
- package/dist/assets/MetadataInspector-DVtCDQtx.js +0 -1
- package/dist/assets/MetadataManagerPage-CYfvXG6X.js +0 -1
- package/dist/assets/MetadataProvider-Dvc9BxbC.js +0 -1
- package/dist/assets/PageView-CUDEz8Xo.js +0 -2
- package/dist/assets/ProfilePage-B0BXoAus.js +0 -1
- package/dist/assets/RecordDetailView-CYgcTNQp.js +0 -1
- package/dist/assets/ReportView-ovWyjJsZ.js +0 -1
- package/dist/assets/SearchResultsPage-B-NchFoJ.js +0 -1
- package/dist/assets/SystemHubPage-D8S1hN1a.js +0 -1
- package/dist/assets/data-adapter-v22lWuhc.js +0 -39
- package/dist/assets/framework-BW6KsEI0.js +0 -2
- package/dist/assets/getIcon-N5xWCMJy.js +0 -1
- package/dist/assets/index-DATdOX6r.js +0 -59
- package/dist/assets/index-nwlbpqhl.css +0 -2
- package/dist/assets/plugins-core-Ccvbi6db.js +0 -105
- package/dist/assets/plugins-views-CbLIJkBs.js +0 -62
- package/dist/assets/skeletons-CIQE_YYE.js +0 -1
- package/dist/assets/src-BGoL_8qF.js +0 -1
- package/dist/assets/ui-layout-CYz0tyDf.js +0 -3
- package/dist/assets/vendor-charts-D1AP0-EV.js +0 -33
- package/dist/assets/vendor-icons-CrSf7tAH.js +0 -1
- package/dist/assets/vendor-objectstack-Dhrq31KF.js +0 -1
- package/dist/assets/vendor-react-ryfytPb-.js +0 -9
- /package/dist/assets/{maplibre-gl-BR3qC6SX.js → maplibre-gl-ChgVR8ni.js} +0 -0
- /package/dist/assets/{plugins-core-B5ROGaJH.css → ui-components-B5ROGaJH.css} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t,t as n}from"./vendor-react-B1k2FF9f.js";import{D as r,H as i}from"./framework-CoXA0nY6.js";import{f as a}from"./infrastructure-Djv3I7gr.js";import{$n as o,Gt as s,Hn as c,Ht as l,Jt as u,Kn as d,Kt as f,NL as p,QA as m,Qn as h,Sy as g,Ut as _,Wn as v,Wt as y,XA as b,an as x,er as S,et as C,fj as w,gt as T,ht as E,in as D,mt as O,n as k,nj as A,nr as j,o as M,pt as N,qn as P,qt as F,rn as I,t as L,tr as R,u as z,vr as B}from"./ui-components-BCmPcwhR.js";var V=e(t(),1),H=n(),U=({label:e,description:t,collapsible:n=!1,collapsed:r=!1,columns:i=1,children:a,className:o,gridClassName:s})=>{let[c,l]=(0,V.useState)(r);return(0,H.jsxs)(`div`,{className:p(`form-section`,o),children:[(e||t)&&(0,H.jsxs)(`div`,{className:p(`flex items-start gap-2 mb-4`,n&&`cursor-pointer select-none`),onClick:()=>{n&&l(!c)},role:n?`button`:void 0,"aria-expanded":n?!c:void 0,children:[n&&(0,H.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,children:c?(0,H.jsx)(b,{className:`h-4 w-4`}):(0,H.jsx)(A,{className:`h-4 w-4`})}),(0,H.jsxs)(`div`,{className:`flex-1`,children:[e&&(0,H.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:e}),t&&(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:t})]})]}),!c&&(0,H.jsx)(`div`,{className:p(`grid gap-4`,s||{1:`grid-cols-1`,2:`grid-cols-1 md:grid-cols-2`,3:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`,4:`grid-cols-1 md:grid-cols-2 lg:grid-cols-4`}[i]),children:a})]})},W=({schema:e,dataSource:t,className:n})=>{let{fieldLabel:i}=a(),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)({}),[u,d]=(0,V.useState)(!0),[f,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(e.defaultTab||e.sections[0]?.name||e.sections[0]?.label||`tab-0`);V.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{s(await t.getObjectSchema(e.objectName))}catch(e){m(e)}})()},[e.objectName,t]),V.useEffect(()=>{(o||!t)&&(async()=>{if(e.mode===`create`||!e.recordId||!t){l(e.initialData||e.initialValues||{}),d(!1);return}try{l(await t.findOne(e.objectName,e.recordId)||{})}catch(e){m(e)}finally{d(!1)}})()},[o,e.mode,e.recordId,e.initialData,e.initialValues,t,e.objectName]);let _=(0,V.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(o?.fields?.[t]){let r=o.fields[t];n.push({name:t,label:i(e.objectName,t,r.label||t),type:z(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:L(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[o,e.readOnly,e.mode]),v=(0,V.useCallback)(async n=>{if(!t)return e.onSuccess&&await e.onSuccess(n),n;try{let r;return e.mode===`create`?r=await t.create(e.objectName,n):e.mode===`edit`&&e.recordId&&(r=await t.update(e.objectName,e.recordId,n)),e.onSuccess&&await e.onSuccess(r),r}catch(t){throw e.onError&&e.onError(t),t}},[e,t]),y=(0,V.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),b=(e,t)=>e.name||e.label||`tab-${t}`;if(f)return(0,H.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,H.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,H.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:f.message})]});if(u)return(0,H.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let x={type:`form`,fields:e.sections.flatMap(e=>_(e)),layout:`vertical`,defaultValues:c,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,onSubmit:v,onCancel:y},S=e.tabPosition===`left`||e.tabPosition===`right`;return(0,H.jsx)(`div`,{className:p(`w-full`,n,e.className),children:(0,H.jsxs)(N,{value:h,onValueChange:g,orientation:S?`vertical`:`horizontal`,className:p(S&&`flex gap-4`),children:[(0,H.jsx)(E,{className:p(S?`flex-col h-auto`:``,e.tabPosition===`bottom`&&`order-last`,e.tabPosition===`right`&&`order-last`),children:e.sections.map((e,t)=>(0,H.jsx)(T,{value:b(e,t),className:S?`w-full justify-start`:``,children:e.label||`Tab ${t+1}`},b(e,t)))}),(0,H.jsx)(`div`,{className:`flex-1`,children:e.sections.map((t,n)=>(0,H.jsx)(O,{value:b(t,n),className:`mt-0`,children:(0,H.jsx)(U,{description:t.description,columns:t.columns||1,children:(0,H.jsx)(r,{schema:{...x,fields:_(t),showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1}})})},b(t,n)))})]})})},G=({schema:e,dataSource:t,className:n})=>{let{fieldLabel:i}=a(),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)({}),[u,d]=(0,V.useState)(!0),[f,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(0),[v,y]=(0,V.useState)(new Set),[x,S]=(0,V.useState)(!1),C=e.sections.length,T=g===0,E=g===C-1;V.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{s(await t.getObjectSchema(e.objectName))}catch(e){h(e)}})()},[e.objectName,t]),V.useEffect(()=>{(o||!t)&&(async()=>{if(e.mode===`create`||!e.recordId||!t){l(e.initialData||e.initialValues||{}),d(!1);return}try{l(await t.findOne(e.objectName,e.recordId)||{})}catch(e){h(e)}finally{d(!1)}})()},[o,e.mode,e.recordId,e.initialData,e.initialValues,t,e.objectName]);let D=(0,V.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(o?.fields?.[t]){let r=o.fields[t];n.push({name:t,label:i(e.objectName,t,r.label||t),type:z(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:L(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[o,e.readOnly,e.mode]),O=(0,V.useMemo)(()=>g>=0&&g<C?D(e.sections[g]):[],[g,C,e.sections,D]),k=(0,V.useCallback)(async n=>{let r={...c,...n};if(l(r),y(e=>new Set(e).add(g)),E){S(!0);try{if(!t)return e.onSuccess&&await e.onSuccess(r),r;let n;return e.mode===`create`?n=await t.create(e.objectName,r):e.mode===`edit`&&e.recordId&&(n=await t.update(e.objectName,e.recordId,r)),e.onSuccess&&await e.onSuccess(n),n}catch(t){throw e.onError&&e.onError(t),t}finally{S(!1)}}else A(g+1)},[c,g,E,e,t]),A=(0,V.useCallback)(t=>{t>=0&&t<C&&(_(t),e.onStepChange&&e.onStepChange(t))},[C,e]),j=(0,V.useCallback)(()=>{A(g-1)},[g,A]),M=(0,V.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),N=(0,V.useCallback)(t=>{(e.allowSkip||v.has(t)||t<=g)&&A(t)},[e.allowSkip,v,g,A]);if(f)return(0,H.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,H.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,H.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:f.message})]});if(u)return(0,H.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let P=e.sections[g];return(0,H.jsxs)(`div`,{className:p(`w-full`,n,e.className),children:[e.showStepIndicator!==!1&&(0,H.jsx)(`nav`,{"aria-label":`Progress`,className:`mb-8`,children:(0,H.jsx)(`ol`,{className:`flex items-center`,children:e.sections.map((t,n)=>{let r=n===g,i=v.has(n),a=e.allowSkip||i||n<=g;return(0,H.jsxs)(`li`,{className:p(`relative flex-1`,n!==C-1&&`pr-8 sm:pr-12`),children:[n!==C-1&&(0,H.jsx)(`div`,{className:`absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5`,"aria-hidden":`true`,children:(0,H.jsx)(`div`,{className:p(`h-full`,i?`bg-primary`:`bg-muted`)})}),(0,H.jsxs)(`button`,{type:`button`,className:p(`group relative flex items-center`,a?`cursor-pointer`:`cursor-not-allowed`),onClick:()=>N(n),disabled:!a,children:[(0,H.jsx)(`span`,{className:p(`flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors`,i&&`bg-primary text-primary-foreground`,r&&!i&&`border-2 border-primary bg-background text-primary`,!r&&!i&&`border-2 border-muted bg-background text-muted-foreground`),children:i?(0,H.jsx)(w,{className:`h-3 w-3 sm:h-4 sm:w-4`}):n+1}),(0,H.jsx)(`span`,{className:`ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block`,children:(0,H.jsx)(`span`,{className:p(r?`text-foreground`:`text-muted-foreground`),children:t.label||`Step ${n+1}`})})]})]},n)})})}),(0,H.jsx)(`div`,{className:`min-h-[200px]`,children:P&&(0,H.jsx)(U,{label:P.label,description:P.description,columns:P.columns||1,children:O.length>0?(0,H.jsx)(r,{schema:{type:`form`,fields:O,layout:`vertical`,defaultValues:c,showSubmit:!1,showCancel:!1,onSubmit:k}}):(0,H.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No fields configured for this step`})})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between mt-6 pt-4 border-t`,children:[(0,H.jsx)(`div`,{children:e.showCancel!==!1&&(0,H.jsx)(B,{variant:`ghost`,onClick:M,children:e.cancelText||`Cancel`})}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`text-sm text-muted-foreground mr-2`,children:[`Step `,g+1,` of `,C]}),!T&&(0,H.jsxs)(B,{variant:`outline`,onClick:j,children:[(0,H.jsx)(m,{className:`h-4 w-4 mr-1`}),e.prevText||`Back`]}),E?(0,H.jsx)(B,{onClick:()=>k(c),disabled:x||e.mode===`view`,children:x?`Submitting...`:e.submitText||(e.mode===`create`?`Create`:`Update`)}):(0,H.jsxs)(B,{onClick:()=>k(c),children:[e.nextText||`Next`,(0,H.jsx)(b,{className:`h-4 w-4 ml-1`})]})]})]})]})},K=({schema:e,dataSource:t,className:n})=>{let{fieldLabel:i}=a(),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)({}),[u,d]=(0,V.useState)(!0),[f,m]=(0,V.useState)(null);(0,V.useEffect)(()=>{(async()=>{if(!t){d(!1);return}try{s(await t.getObjectSchema(e.objectName))}catch(e){m(e),d(!1)}})()},[e.objectName,t]),(0,V.useEffect)(()=>{(o||!t)&&(async()=>{if(e.mode===`create`||!e.recordId){l(e.initialData||e.initialValues||{}),d(!1);return}if(!t){l(e.initialData||e.initialValues||{}),d(!1);return}try{l(await t.findOne(e.objectName,e.recordId)||{})}catch(e){m(e)}finally{d(!1)}})()},[o,e.mode,e.recordId,e.initialData,e.initialValues,t,e.objectName]);let h=(0,V.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(o?.fields?.[t]){let r=o.fields[t];n.push({name:t,label:i(e.objectName,t,r.label||t),type:z(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:L(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[o,e.readOnly,e.mode]),g=(0,V.useCallback)(async n=>{if(!t)return e.onSuccess&&await e.onSuccess(n),n;try{let r;return e.mode===`create`?r=await t.create(e.objectName,n):e.mode===`edit`&&e.recordId&&(r=await t.update(e.objectName,e.recordId,n)),e.onSuccess&&await e.onSuccess(r),r}catch(t){throw e.onError&&e.onError(t),t}},[e,t]),_=(0,V.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),v=(0,V.useMemo)(()=>e.sections.slice(0,1),[e.sections]),y=(0,V.useMemo)(()=>e.sections.slice(1),[e.sections]);(0,V.useMemo)(()=>e.sections.flatMap(e=>h(e)),[e.sections,h]);let b=e.splitDirection||`horizontal`,S=e.splitSize||50;if(f)return(0,H.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,H.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,H.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:f.message})]});if(u)return(0,H.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let C={type:`form`,layout:`vertical`,defaultValues:c,onSubmit:g,onCancel:_},w=(t,n)=>(0,H.jsx)(`div`,{className:`space-y-4 p-4`,children:t.map((t,i)=>(0,H.jsx)(U,{label:t.label,description:t.description,columns:t.columns||1,children:(0,H.jsx)(r,{schema:{...C,fields:h(t),showSubmit:n&&e.showSubmit!==!1&&e.mode!==`view`,showCancel:n&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText}})},t.name||t.label||i))});return(0,H.jsx)(`div`,{className:p(`w-full`,n,e.className),children:(0,H.jsxs)(x,{orientation:b,className:`min-h-[300px] rounded-lg border`,children:[(0,H.jsx)(D,{defaultSize:S,minSize:20,children:w(v,y.length===0)}),y.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(I,{withHandle:e.splitResizable!==!1}),(0,H.jsx)(D,{defaultSize:100-S,minSize:20,children:w(y,!0)})]})]})})},ee=new Set([`field:formula`,`field:summary`,`field:auto_number`,`field:autonumber`,`field:master_detail`]),te=new Set([`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`,`textarea`,`markdown`,`html`,`grid`,`rich-text`]),ne=new Set([`formula`,`summary`,`auto_number`,`autonumber`,`master_detail`,`masterDetail`]);function re(e){return te.has(e)}function ie(e){return ne.has(e)}function ae(e){return e<=3?1:2}function q(e,t){return t<=1?e:e.map(e=>e.colSpan===void 0&&e.type&&re(e.type)?{...e,colSpan:t}:e)}var oe=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`owner`,`owner_id`,`_version`,`_rev`]);function se(e,t){return e.filter(e=>{if(oe.has(e.name)||e.type&&ee.has(e.type))return!1;if(!t?.fields)return!0;let n=t.fields[e.name];return n?n.readonly===!0?!1:!ie(n.type):!0})}function J(e){return e<=1?`default`:e===2?`xl`:`full`}function Y(e,t,n,r){let i=[...e];if(r===`create`&&(i=se(i,t)),n!==void 0)return i=q(i,n),{fields:i,columns:n};let a=ae(i.length);return i=q(i,a),{fields:i,columns:a}}var ce={1:void 0,2:`grid gap-4 grid-cols-1 @md:grid-cols-2`,3:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3`,4:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4`},X=({schema:e,dataSource:t,className:n})=>{let{fieldLabel:i}=a(),[o,c]=(0,V.useState)(null),[l,d]=(0,V.useState)([]),[m,h]=(0,V.useState)({}),[g,_]=(0,V.useState)(!0),[v,b]=(0,V.useState)(null),x=e.open!==!1,S=e.drawerSide||`right`,[C,w]=(0,V.useState)(()=>{let t={};return e.sections?.forEach((e,n)=>{let r=e.name||String(n);e.collapsed&&(t[r]=!0)}),t});(0,V.useEffect)(()=>{(async()=>{if(!t){_(!1);return}try{c(await t.getObjectSchema(e.objectName))}catch(e){b(e),_(!1)}})()},[e.objectName,t]),(0,V.useEffect)(()=>{(o||!t)&&(async()=>{if(e.mode===`create`||!e.recordId){h(e.initialData||e.initialValues||{}),_(!1);return}if(!t){h(e.initialData||e.initialValues||{}),_(!1);return}try{h(await t.findOne(e.objectName,e.recordId)||{})}catch(e){b(e)}finally{_(!1)}})()},[o,e.mode,e.recordId,e.initialData,e.initialValues,t,e.objectName]);let T=(0,V.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(o?.fields?.[t]){let r=o.fields[t];n.push({name:t,label:i(e.objectName,t,r.label||t),type:z(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:L(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[o,e.readOnly,e.mode]);(0,V.useEffect)(()=>{if(!o&&t)return;if(e.customFields?.length){d(e.customFields),_(!1);return}if(e.sections?.length){_(!1);return}if(!o)return;let n=e.fields||Object.keys(o.fields||{}),r=[];for(let t of n){let n=typeof t==`string`?t:t.name;if(!n)continue;let a=o.fields?.[n];a&&r.push({name:n,label:i(e.objectName,n,a.label||n),type:z(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:L(a),field:a,options:a.options,multiple:a.multiple})}d(r),_(!1)},[o,e.fields,e.customFields,e.sections,e.readOnly,e.mode,t]);let E=(0,V.useCallback)(async n=>{if(!t)return e.onSuccess&&await e.onSuccess(n),e.onOpenChange?.(!1),n;try{let r;return e.mode===`create`?r=await t.create(e.objectName,n):e.mode===`edit`&&e.recordId&&(r=await t.update(e.objectName,e.recordId,n)),e.onSuccess&&await e.onSuccess(r),e.onOpenChange?.(!1),r}catch(t){throw e.onError&&e.onError(t),t}},[e,t]),D=(0,V.useCallback)(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),O=(0,V.useMemo)(()=>{if(e.drawerWidth)return S===`left`||S===`right`?{width:e.drawerWidth,maxWidth:e.drawerWidth}:{height:e.drawerWidth,maxHeight:e.drawerWidth}},[e.drawerWidth,S]),k={type:`form`,layout:e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`,defaultValues:m,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,onSubmit:E,onCancel:D};return(0,H.jsx)(y,{open:x,onOpenChange:e.onOpenChange,children:(0,H.jsxs)(s,{side:S,className:p(`overflow-y-auto`,n,e.className),style:O,children:[(e.title||e.description)&&(0,H.jsxs)(F,{children:[e.title&&(0,H.jsx)(u,{children:e.title}),e.description&&(0,H.jsx)(f,{children:e.description})]}),(0,H.jsx)(`div`,{className:`@container py-4`,children:(()=>{if(v)return(0,H.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,H.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,H.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:v.message})]});if(g)return(0,H.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});if(e.sections?.length){let t=[];return e.sections.forEach((e,n)=>{let r=e.name||String(n),i=C[r]??e.collapsed??!1;t.push({name:`__section_${r}`,label:e.label||``,type:`section-divider`,colSpan:4,collapsible:e.collapsible,collapsed:i,onToggle:e.collapsible?()=>w(e=>({...e,[r]:!i})):void 0});let a=T(e);i?t.push(...a.map(e=>({...e,hidden:!0}))):t.push(...a)}),(0,H.jsx)(r,{schema:{...k,fields:t}})}let t=Y(l,o,e.columns,e.mode),n=ce[t.columns||1];return(0,H.jsx)(r,{schema:{...k,fields:t.fields,columns:t.columns,...n?{fieldContainerClass:n}:{}}})})()})]})})},Z={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},Q={1:void 0,2:`grid gap-4 grid-cols-1 @md:grid-cols-2`,3:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3`,4:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4`},le=({schema:e,dataSource:t,className:n})=>{let{fieldLabel:i}=a(),[o,s]=(0,V.useState)(null),[u,f]=(0,V.useState)([]),[m,h]=(0,V.useState)({}),[_,y]=(0,V.useState)(!0),[b,x]=(0,V.useState)(null),[S,w]=(0,V.useState)(!1),T=e.open!==!1,E=(0,V.useId)(),D=(0,V.useMemo)(()=>e.sections?.length||e.customFields?.length?null:Y(u,o,e.columns,e.mode),[u,o,e.columns,e.mode,e.sections,e.customFields]),O=Z[(0,V.useMemo)(()=>{if(e.modalSize)return e.modalSize;if(D?.columns&&D.columns>1)return J(D.columns);if(e.sections?.length){let t=Math.max(...e.sections.map(e=>Number(e.columns)||1));if(t>1)return J(t)}return`default`},[e.modalSize,D,e.sections])]||Z.default;(0,V.useEffect)(()=>{(async()=>{if(!t){y(!1);return}try{s(await t.getObjectSchema(e.objectName))}catch(e){x(e),y(!1)}})()},[e.objectName,t]),(0,V.useEffect)(()=>{(o||!t)&&(async()=>{if(e.mode===`create`||!e.recordId){h(e.initialData||e.initialValues||{}),y(!1);return}if(!t){h(e.initialData||e.initialValues||{}),y(!1);return}try{h(await t.findOne(e.objectName,e.recordId)||{})}catch(e){x(e)}finally{y(!1)}})()},[o,e.mode,e.recordId,e.initialData,e.initialValues,t,e.objectName]);let k=(0,V.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(o?.fields?.[t]){let r=o.fields[t];n.push({name:t,label:i(e.objectName,t,r.label||t),type:z(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:L(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[o,e.readOnly,e.mode]);(0,V.useEffect)(()=>{if(!o&&t)return;if(e.customFields?.length){f(e.customFields),y(!1);return}if(e.sections?.length){y(!1);return}if(!o)return;let n=e.fields||Object.keys(o.fields||{}),r=[];for(let t of n){let n=typeof t==`string`?t:t.name;if(!n)continue;let a=o.fields?.[n];a&&r.push({name:n,label:i(e.objectName,n,a.label||n),type:z(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:L(a),field:a,options:a.options,multiple:a.multiple})}f(r),y(!1)},[o,e.fields,e.customFields,e.sections,e.readOnly,e.mode,t]);let A=(0,V.useCallback)(async n=>{w(!0);try{if(!t)return e.onSuccess&&await e.onSuccess(n),e.onOpenChange?.(!1),n;let r;return e.mode===`create`?r=await t.create(e.objectName,n):e.mode===`edit`&&e.recordId&&(r=await t.update(e.objectName,e.recordId,n)),e.onSuccess&&await e.onSuccess(r),e.onOpenChange?.(!1),r}catch(t){throw e.onError&&e.onError(t),t}finally{w(!1)}},[e,t]),j=(0,V.useCallback)(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),M=e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`,N=e.showSubmit!==!1&&e.mode!==`view`,F=e.showCancel!==!1,I=e.submitText||(e.mode===`create`?`Create`:`Update`),R=e.cancelText||`Cancel`,W={type:`form`,layout:M,defaultValues:m,submitLabel:I,cancelLabel:R,showSubmit:N,showCancel:F,onSubmit:A,onCancel:j,showActions:!1,id:E},G=()=>{if(b)return(0,H.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,H.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,H.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:b.message})]});if(_)return(0,H.jsx)(`div`,{className:`space-y-4`,"data-testid":`modal-form-skeleton`,children:[1,2,3].map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(l,{className:`h-4 w-24`}),(0,H.jsx)(l,{className:`h-10 w-full`})]},e))});if(e.sections?.length)return(0,H.jsx)(`div`,{className:`space-y-6`,children:e.sections.map((e,t)=>{let n=e.columns||1;return(0,H.jsx)(U,{label:e.label,description:e.description,columns:n,gridClassName:Q[n],children:(0,H.jsx)(r,{schema:{...W,fields:k(e)}})},e.name||e.label||t)})});let t=D??Y(u,o,e.columns,e.mode),n=Q[t.columns||1];return(0,H.jsx)(r,{schema:{...W,fields:t.fields,columns:t.columns,...n?{fieldContainerClass:n}:{}}})},K=!_&&!b&&(N||F);return(0,H.jsx)(c,{open:T,onOpenChange:e.onOpenChange,children:(0,H.jsxs)(C,{className:p(O,`flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0`,n,e.className),children:[(e.title||e.description)&&(0,H.jsxs)(d,{className:`shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b`,children:[e.title&&(0,H.jsx)(P,{children:e.title}),e.description&&(0,H.jsx)(v,{children:e.description})]}),(0,H.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-4 sm:px-6 py-4`,children:G()}),K&&(0,H.jsx)(`div`,{className:`shrink-0 border-t px-4 sm:px-6 py-3 bg-background`,"data-testid":`modal-form-footer`,children:(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2 sm:justify-end`,children:[F&&(0,H.jsx)(B,{type:`button`,variant:`outline`,onClick:j,disabled:S,className:`w-full sm:w-auto`,children:R}),N&&(0,H.jsxs)(B,{type:`submit`,form:E,disabled:S,className:`w-full sm:w-auto`,children:[S&&(0,H.jsx)(g,{className:`mr-2 h-4 w-4 animate-spin`}),I]})]})})]})})},$=({schema:e,dataSource:t})=>{if(e.formType===`tabbed`&&e.sections?.length)return(0,H.jsx)(W,{schema:{...e,formType:`tabbed`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),defaultTab:e.defaultTab,tabPosition:e.tabPosition},dataSource:t,className:e.className});if(e.formType===`wizard`&&e.sections?.length)return(0,H.jsx)(G,{schema:{...e,formType:`wizard`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),allowSkip:e.allowSkip,showStepIndicator:e.showStepIndicator,nextText:e.nextText,prevText:e.prevText,onStepChange:e.onStepChange},dataSource:t,className:e.className});if(e.formType===`split`&&e.sections?.length)return(0,H.jsx)(K,{schema:{...e,formType:`split`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),splitDirection:e.splitDirection,splitSize:e.splitSize,splitResizable:e.splitResizable},dataSource:t,className:e.className});if(e.formType===`drawer`){let{layout:n,...r}=e,i=e.layout===`vertical`||e.layout===`horizontal`?e.layout:void 0;return(0,H.jsx)(X,{schema:{...r,layout:i,formType:`drawer`,sections:e.sections?.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields,collapsible:e.collapsible,collapsed:e.collapsed})),open:e.open,onOpenChange:e.onOpenChange,drawerSide:e.drawerSide,drawerWidth:e.drawerWidth},dataSource:t,className:e.className})}if(e.formType===`modal`){let{layout:n,...r}=e,i=e.layout===`vertical`||e.layout===`horizontal`?e.layout:void 0;return(0,H.jsx)(le,{schema:{...r,layout:i,formType:`modal`,sections:e.sections?.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),open:e.open,onOpenChange:e.onOpenChange,modalSize:e.modalSize,modalCloseButton:e.modalCloseButton},dataSource:t,className:e.className})}return(0,H.jsx)(ue,{schema:e,dataSource:t})},ue=({schema:e,dataSource:t})=>{let{fieldLabel:n}=a(),i=_(),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)([]),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(null),g=e.customFields&&e.customFields.length>0;(0,V.useEffect)(()=>{g&&(d(e.initialData||e.initialValues||{}),p(!1))},[g,e.initialData,e.initialValues]),(0,V.useEffect)(()=>{g?s({name:e.objectName,fields:{}}):e.objectName&&t?(async()=>{try{if(!t)throw Error(`DataSource is required when using ObjectQL schema fetching (inline fields not provided)`);let n=await t.getObjectSchema(e.objectName);if(!n)throw Error(`No schema found for object "${e.objectName}"`);s(n)}catch(e){h(e),p(!1)}})():g||p(!1)},[e.objectName,t,g]),(0,V.useEffect)(()=>{o&&!g&&(async()=>{if(!e.recordId||e.mode===`create`){d(e.initialData||e.initialValues||{}),p(!1);return}if(!g){if(!t){h(Error(`DataSource is required for fetching record data (inline data not provided)`)),p(!1);return}p(!0);try{d(await t.findOne(e.objectName,e.recordId))}catch(e){console.error(`Failed to fetch record:`,e),h(e)}finally{p(!1)}}})()},[e.objectName,e.recordId,e.mode,e.initialValues,e.initialData,t,o,g]),(0,V.useEffect)(()=>{if(g&&e.customFields){l(e.customFields),p(!1);return}if(!o)return;let r=[],i=e.fields||Object.keys(o.fields||{});(Array.isArray(i)?i:Object.keys(i)).forEach(t=>{let i=typeof t==`string`?t:t.name;if(!i)return;let a=o.fields?.[i];if(!a&&!g)return;let s=!a?.permissions||a?.permissions.write!==!1;if(e.mode!==`view`&&!s)return;let c=e.customFields?.find(e=>e.name===i);if(c)r.push(c);else if(a){let o={name:i,label:n(e.objectName,i,a.label||t),type:z(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:L(a),field:a};if((a.type===`select`||a.type===`lookup`||a.type===`master_detail`)&&(o.options=a.options||[],o.multiple=a.multiple),(a.type===`number`||a.type===`currency`||a.type===`percent`)&&(o.inputType=`number`,o.min=a.min,o.max=a.max,o.step=a.precision?10**-a.precision:void 0),a.type===`date`&&(o.inputType=`date`),a.type===`datetime`&&(o.inputType=`datetime-local`),(a.type===`text`||a.type===`textarea`||a.type===`markdown`||a.type===`html`)&&(o.maxLength=a.max_length,o.minLength=a.min_length),(a.type===`file`||a.type===`image`)&&(o.inputType=`file`,o.multiple=a.multiple,o.accept=a.accept?a.accept.join(`,`):void 0,a.max_size)){let e=`Max size: ${M(a.max_size)}`;o.description=o.description?`${o.description} (${e})`:e}a.type===`email`&&(o.inputType=`email`),a.type===`phone`&&(o.inputType=`tel`),a.type===`url`&&(o.inputType=`url`),a.type===`password`&&(o.inputType=`password`),a.type===`time`&&(o.inputType=`time`),(a.type===`formula`||a.type===`summary`||a.type===`auto_number`)&&(o.disabled=!0),a.visible_on&&(o.visible=e=>k(a.visible_on,e)),r.push(o)}}),l(r),!g&&e.recordId&&e.mode!==`create`&&t||p(!1)},[o,e.fields,e.customFields,e.readOnly,e.mode,g,e.recordId,t]);let v=(0,V.useCallback)(async(n,r)=>{if(n&&(n.nativeEvent||n._reactName===`onSubmit`)&&(console.warn(`ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue.`),r===void 0&&(r=n,n={})),g&&!t)return e.onSuccess&&await e.onSuccess(n),n;if(!t)throw Error(`DataSource is required for form submission (inline mode not configured)`);try{let r;if(e.mode===`create`)r=await t.create(e.objectName,n);else if(e.mode===`edit`&&e.recordId)r=await t.update(e.objectName,e.recordId,n);else throw Error(`Invalid form mode or missing record ID`);return e.onSuccess&&await e.onSuccess(r),r}catch(t){throw console.error(`Failed to submit form:`,t),e.onError&&e.onError(t),t}},[e,t,g]),y=(0,V.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),b={...V.useMemo(()=>{if(!o?.fields)return{};let e={};return Object.keys(o.fields).forEach(t=>{let n=o.fields[t];n.defaultValue!==void 0&&(e[t]=n.defaultValue)}),e},[o]),...u};if(m)return(0,H.jsxs)(`div`,{className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,H.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,H.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,H.jsxs)(`div`,{className:`p-4 sm:p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let x=e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`;if(e.sections?.length&&(!e.formType||e.formType===`simple`))return(0,H.jsx)(`div`,{className:`w-full space-y-6`,children:e.sections.map((t,n)=>{let i=t.fields.map(e=>typeof e==`string`?e:e.name),a=c.filter(e=>i.includes(e.name));return(0,H.jsx)(U,{label:t.label,description:t.description,collapsible:t.collapsible,collapsed:t.collapsed,columns:t.columns,children:(0,H.jsx)(r,{schema:{type:`form`,fields:a,layout:x,defaultValues:b,showSubmit:n===e.sections.length-1&&e.showSubmit!==!1&&e.mode!==`view`,showCancel:n===e.sections.length-1&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,onSubmit:v,onCancel:y}})},t.name||t.label||n)})});let S=e.sections?.length,C=S?{fields:c,columns:e.columns}:Y(c,o,e.columns,e.mode),w=e.mobile,T=w?.fullscreenLongText?C.fields.map(e=>{let t=e.type;return t===`textarea`||t===`field:textarea`||t===`string-multiline`||t===`field:markdown`||t===`field:html`?{...e,mobile_fullscreen:!0}:e}):C.fields,E=w?.stepper,D=w?.stepperMinFields??8,O=Math.max(1,w?.stepperFieldsPerStep??1);if(!e.formType&&!S&&T.length>=2&&(E===!0||E===`auto`&&i&&T.length>=D)){let n=T,r=[];for(let e=0;e<n.length;e+=O){let t=n.slice(e,e+O);r.push({name:`step-${Math.floor(e/O)+1}`,label:t[0]?.label||t[0]?.name||`Step ${Math.floor(e/O)+1}`,fields:t})}return(0,H.jsx)(G,{schema:{...e,formType:`wizard`,sections:r,showStepIndicator:!0},dataSource:t,className:e.className})}let A={type:`form`,fields:T,layout:x,columns:C.columns,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,resetOnSubmit:e.showReset,defaultValues:b,onSubmit:v,onCancel:y,className:e.className,mobileStickyActions:!!w?.stickyActions};return(0,H.jsx)(`div`,{className:w?.stickyActions?`w-full pb-20 md:pb-0`:`w-full`,"data-mobile-form":w?`true`:void 0,children:(0,H.jsx)(r,{schema:A})})},de=({config:e,dataSource:t,prefillParams:n,className:r})=>{let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useMemo)(()=>{let e={};if(n)for(let[t,r]of Object.entries(n))e[t]=r;return typeof window<`u`&&new URLSearchParams(window.location.search).forEach((t,n)=>{n in e||(e[n]=t)}),Object.keys(e).length>0?e:void 0},[n]),d=(0,V.useCallback)(async n=>{s(!0),l(null);try{if(t&&await t.create(e.objectName,n),a(!0),e.thankYouPage?.redirectUrl){let t=e.thankYouPage.redirectDelay??3e3;setTimeout(()=>{window.location.href=e.thankYouPage.redirectUrl},t)}}catch(e){l(e instanceof Error?e.message:`Failed to submit form. Please try again.`)}finally{s(!1)}},[t,e]),f=(0,V.useCallback)(()=>{a(!1),l(null)},[]),p=(0,V.useMemo)(()=>{let t={};return e.branding?.backgroundColor&&(t.backgroundColor=e.branding.backgroundColor),t},[e.branding]);if(i){let t=e.thankYouPage;return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 ${r||``}`,style:p,children:(0,H.jsxs)(`div`,{className:`max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4`,children:[(0,H.jsx)(`div`,{className:`text-4xl`,children:`✓`}),(0,H.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:t?.title||`Thank You!`}),(0,H.jsx)(`p`,{className:`text-muted-foreground`,children:t?.message||`Your submission has been received successfully.`}),e.allowMultiple&&(0,H.jsx)(`button`,{onClick:f,className:`mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors`,children:`Submit Another Response`}),t?.redirectUrl&&(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Redirecting in `,Math.ceil((t.redirectDelay??3e3)/1e3),` seconds...`]})]})})}return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 ${r||``}`,style:p,children:(0,H.jsxs)(`div`,{className:`max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`p-6 border-b`,style:e.branding?.primaryColor?{borderBottomColor:e.branding.primaryColor}:void 0,children:[e.branding?.logo&&(0,H.jsx)(`img`,{src:e.branding.logo,alt:`Logo`,className:`h-8 mb-4`}),e.title&&(0,H.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:e.title}),e.description&&(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description})]}),(0,H.jsxs)(`div`,{className:`p-6`,children:[c&&(0,H.jsx)(`div`,{className:`mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive`,children:c}),(0,H.jsx)($,{schema:{type:`object-form`,objectName:e.objectName,mode:`create`,fields:e.fields,customFields:e.customFields,initialData:u,onSuccess:d,submitLabel:o?`Submitting...`:`Submit`},dataSource:t})]}),(0,H.jsx)(`div`,{className:`px-6 py-3 border-t bg-muted/20 text-center`,children:(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Powered by ObjectStack`})})]})})};function fe(e){return e<60?`${Math.round(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.round(e%60)}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}var pe=({formId:e,formTitle:t,metrics:n,className:r})=>{let i=(0,V.useMemo)(()=>{if(!n.abandonedSubmissions)return 100;let e=n.totalSubmissions+n.abandonedSubmissions;return e===0?0:Math.round(n.totalSubmissions/e*100)},[n.totalSubmissions,n.abandonedSubmissions]),a=(0,V.useMemo)(()=>n.dailySubmissions?.length?Math.max(...n.dailySubmissions.map(e=>e.count),1):1,[n.dailySubmissions]);return(0,H.jsxs)(`div`,{className:`space-y-4 ${r||``}`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:t||`Form Analytics`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Form ID: `,e]})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,H.jsx)(h,{children:(0,H.jsxs)(R,{className:`pb-2`,children:[(0,H.jsx)(S,{children:`Total Submissions`}),(0,H.jsx)(j,{className:`text-2xl`,children:n.totalSubmissions.toLocaleString()})]})}),(0,H.jsxs)(h,{children:[(0,H.jsxs)(R,{className:`pb-2`,children:[(0,H.jsx)(S,{children:`Fill Rate`}),(0,H.jsxs)(j,{className:`text-2xl`,children:[i,`%`]})]}),(0,H.jsx)(o,{children:(0,H.jsx)(`div`,{className:`w-full bg-muted rounded-full h-2`,children:(0,H.jsx)(`div`,{className:`bg-primary rounded-full h-2 transition-all`,style:{width:`${i}%`}})})})]}),(0,H.jsx)(h,{children:(0,H.jsxs)(R,{className:`pb-2`,children:[(0,H.jsx)(S,{children:`Avg. Completion Time`}),(0,H.jsx)(j,{className:`text-2xl`,children:n.avgCompletionTime?fe(n.avgCompletionTime):`—`})]})})]}),n.dailySubmissions&&n.dailySubmissions.length>0&&(0,H.jsxs)(h,{children:[(0,H.jsx)(R,{children:(0,H.jsx)(j,{className:`text-sm font-medium`,children:`Daily Submissions`})}),(0,H.jsx)(o,{children:(0,H.jsx)(`div`,{className:`flex items-end gap-1 h-32`,children:n.dailySubmissions.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-1`,children:[(0,H.jsx)(`div`,{className:`w-full bg-primary/80 rounded-t transition-all hover:bg-primary`,style:{height:`${e.count/a*100}%`,minHeight:e.count>0?`4px`:`0`},title:`${e.date}: ${e.count} submissions`}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate w-full text-center`,children:e.date.slice(-5)})]},t))})})]}),n.fieldDropOff&&n.fieldDropOff.length>0&&(0,H.jsxs)(h,{children:[(0,H.jsxs)(R,{children:[(0,H.jsx)(j,{className:`text-sm font-medium`,children:`Field Completion Rates`}),(0,H.jsx)(S,{children:`Percentage of users who completed each field`})]}),(0,H.jsx)(o,{children:(0,H.jsx)(`div`,{className:`space-y-3`,children:n.fieldDropOff.map((e,t)=>(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,H.jsx)(`span`,{className:`text-foreground`,children:e.label}),(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.completionRate,`%`]})]}),(0,H.jsx)(`div`,{className:`w-full bg-muted rounded-full h-1.5`,children:(0,H.jsx)(`div`,{className:`rounded-full h-1.5 transition-all ${e.completionRate>=80?`bg-green-500`:e.completionRate>=50?`bg-yellow-500`:`bg-destructive`}`,style:{width:`${e.completionRate}%`}})})]},t))})})]})]})},me=({schema:e})=>(0,H.jsx)($,{schema:e});i.register(`object-form`,me,{namespace:`plugin-form`,label:`Object Form`,category:`plugin`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`},{name:`mode`,type:`enum`,label:`Mode`,enum:[`create`,`edit`,`view`]},{name:`formType`,type:`enum`,label:`Form Type`,enum:[`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`]},{name:`sections`,type:`array`,label:`Sections`},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`vertical`,`horizontal`,`inline`,`grid`]},{name:`columns`,type:`number`,label:`Columns`},{name:`defaultTab`,type:`string`,label:`Default Tab`},{name:`tabPosition`,type:`enum`,label:`Tab Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`allowSkip`,type:`boolean`,label:`Allow Skip Steps`},{name:`showStepIndicator`,type:`boolean`,label:`Show Step Indicator`},{name:`splitDirection`,type:`enum`,label:`Split Direction`,enum:[`horizontal`,`vertical`]},{name:`splitSize`,type:`number`,label:`Split Panel Size (%)`},{name:`splitResizable`,type:`boolean`,label:`Split Resizable`},{name:`drawerSide`,type:`enum`,label:`Drawer Side`,enum:[`top`,`bottom`,`left`,`right`]},{name:`drawerWidth`,type:`string`,label:`Drawer Width`},{name:`modalSize`,type:`enum`,label:`Modal Size`,enum:[`sm`,`default`,`lg`,`xl`,`full`]}]}),i.register(`form`,me,{namespace:`view`,skipFallback:!0,label:`Data Form View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`},{name:`mode`,type:`enum`,label:`Mode`,enum:[`create`,`edit`,`view`]}]}),i.register(`embeddable-form`,({schema:e})=>(0,H.jsx)(de,{config:e}),{namespace:`plugin-form`,label:`Embeddable Form`,category:`plugin`,inputs:[{name:`formId`,type:`string`,label:`Form ID`,required:!0},{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Form Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`},{name:`allowMultiple`,type:`boolean`,label:`Allow Multiple Submissions`}]}),i.register(`form-analytics`,({schema:e})=>(0,H.jsx)(pe,{formId:e.formId,formTitle:e.formTitle,metrics:e.metrics||{totalSubmissions:0}}),{namespace:`plugin-form`,label:`Form Analytics`,category:`plugin`,inputs:[{name:`formId`,type:`string`,label:`Form ID`,required:!0},{name:`formTitle`,type:`string`,label:`Form Title`},{name:`metrics`,type:`object`,label:`Submission Metrics`}]});export{le as n,X as r,$ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as n,t as r}from"./vendor-react-B1k2FF9f.js";import{H as i,L as a,M as o,R as s,w as c}from"./framework-CoXA0nY6.js";import{t as l}from"./vendor-objectstack-CBpPY_xk.js";import{$t as u,NL as d,OM as f,Oh as p,QA as m,Qt as h,Sr as g,XA as _,Y as v,Zt as y,br as b,en as x,jh as S,lm as ee,nt as te,tn as C,vr as w}from"./ui-components-BCmPcwhR.js";var T=t(n(),1),E=r();function D(e){return e<640?35:e<1024?50:60}function O(e){return e<640?120:e<1024?200:300}function ne(e){return e<640?32:40}function k({tasks:e,viewMode:t=`month`,startDate:n,endDate:r,onTaskClick:i,onTaskUpdate:a,onViewChange:o,onAddClick:s,className:c,inlineEdit:l=!1}){let[te,k]=T.useState(new Date),A=T.useRef(null),{width:j}=v(A),M=j||(typeof window<`u`?window.innerWidth:1024),N=M<640,P=ne(M),F=D(M),[re,I]=T.useState(null),L=re??F,[R,z]=T.useState(!1),B=T.useRef(!1);T.useEffect(()=>{!B.current&&N&&(z(!0),B.current=!0)},[N]);let V=R?0:O(M),[H,U]=T.useState(null),[W,G]=T.useState({}),K=T.useMemo(()=>{let t=n?new Date(n):new Date,i=r?new Date(r):new Date;return!n&&e.length>0&&(t=new Date(Math.min(...e.map(e=>e.start.getTime()))),t.setDate(t.getDate()-7)),!r&&e.length>0&&(i=new Date(Math.max(...e.map(e=>e.end.getTime()))),i.setDate(i.getDate()+14)),t.setHours(0,0,0,0),i.setHours(23,59,59,999),{start:t,end:i}},[n,r,e]),q=T.useMemo(()=>{let e=[],t=new Date(K.start);for(;t<=K.end;)e.push({date:new Date(t),label:t.getDate().toString(),isWeekend:t.getDay()===0||t.getDay()===6}),t.setDate(t.getDate()+1);return e},[K]),J=T.useRef(null),Y=T.useRef(null),ie=T.useRef(null),X=T.useRef(null),Z=T.useRef(null),ae=T.useCallback(e=>{if(e.touches.length===2){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;Z.current={baseDistance:Math.max(1,Math.sqrt(t*t+n*n)),baseColumn:L}}},[L]),oe=T.useCallback(e=>{if(e.touches.length!==2||!Z.current)return;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.max(1,Math.sqrt(t*t+n*n))/Z.current.baseDistance;I(Math.max(15,Math.min(120,Math.round(Z.current.baseColumn*r))))},[]),Q=T.useCallback(()=>{Z.current=null},[]),$=T.useMemo(()=>{let e=new Date;if(e<K.start||e>K.end)return null;let t=(e.getTime()-K.start.getTime())/(1440*60*1e3);return Math.round(t*L)},[K,L]),se=T.useCallback(()=>{if($==null||!X.current)return;let e=Math.max(0,$-X.current.clientWidth/2);X.current.scrollTo({left:e,behavior:`smooth`})},[$]),ce=e=>{J.current&&(J.current.scrollLeft=e.currentTarget.scrollLeft),Y.current&&(Y.current.scrollTop=e.currentTarget.scrollTop)},le=e=>{K.end.getTime()-K.start.getTime();let t=L,n=1e3*60*60*24,r=e.start.getTime()-K.start.getTime(),i=e.end.getTime()-e.start.getTime();return{left:r/n*t,width:Math.max(i/n*t,t)}};return(0,E.jsxs)(`div`,{ref:A,className:d(`flex flex-col h-full bg-background border rounded-lg overflow-hidden min-w-0`,c),children:[(0,E.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(w,{variant:`outline`,size:`sm`,onClick:()=>s?.(),"aria-label":`Create new task`,children:[(0,E.jsx)(ee,{className:`h-4 w-4 mr-1 sm:mr-2`}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`New Task`}),(0,E.jsx)(`span`,{className:`sm:hidden`,children:`New`})]}),(0,E.jsx)(`div`,{className:`h-4 w-px bg-border mx-1 sm:mx-2`}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`Previous period`,children:(0,E.jsx)(m,{className:`h-4 w-4`})}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`Next period`,children:(0,E.jsx)(_,{className:`h-4 w-4`})}),(0,E.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:K.start.toLocaleDateString(void 0,{month:`long`,year:`numeric`})})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(y,{value:t,onValueChange:e=>o?.(e),children:[(0,E.jsx)(x,{className:`w-[100px] sm:w-[120px] h-8`,children:(0,E.jsx)(C,{})}),(0,E.jsxs)(h,{children:[(0,E.jsx)(u,{value:`day`,children:`Day View`}),(0,E.jsx)(u,{value:`week`,children:`Week View`}),(0,E.jsx)(u,{value:`month`,children:`Month View`}),(0,E.jsx)(u,{value:`quarter`,children:`Quarter View`})]})]}),(0,E.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,E.jsx)(w,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>I(Math.max(15,L-10)),"aria-label":`Zoom out`,children:(0,E.jsx)(b,{className:`h-3 w-3`})}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>I(Math.min(120,L+10)),"aria-label":`Zoom in`,children:(0,E.jsx)(g,{className:`h-3 w-3`})})]}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>z(e=>!e),"aria-label":R?`Show task list`:`Hide task list`,"aria-pressed":R,"data-testid":`gantt-toggle-task-list`,children:R?(0,E.jsx)(p,{className:`h-4 w-4`}):(0,E.jsx)(S,{className:`h-4 w-4`})}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:se,disabled:$==null,"aria-label":`Jump to today`,"data-testid":`gantt-jump-today`,children:(0,E.jsx)(f,{className:`h-4 w-4`})})]})]}),(0,E.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 sm:h-[50px]`,children:[(0,E.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:V,minWidth:V},children:[(0,E.jsx)(`div`,{className:`flex-1`,children:`Task Name`}),(0,E.jsx)(`div`,{className:`w-16 sm:w-20 text-right hidden sm:block`,children:`Start`}),(0,E.jsx)(`div`,{className:`w-16 sm:w-20 text-right hidden sm:block`,children:`End`})]}),(0,E.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:J,children:(0,E.jsx)(`div`,{className:`flex h-full`,style:{width:q.length*L},children:q.map((e,t)=>(0,E.jsxs)(`div`,{className:d(`flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full`,e.isWeekend&&`bg-muted/50`),style:{width:L,minWidth:L},children:[(0,E.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,E.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.date.toLocaleDateString(void 0,{weekday:`narrow`})})]},t))})})]}),(0,E.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,E.jsx)(`div`,{className:`overflow-hidden border-r bg-card z-10 shadow-sm`,ref:Y,style:{width:V,minWidth:V},children:e.map(e=>{let t=l&&H===e.id;return(0,E.jsxs)(`div`,{className:`flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation`,style:{height:P},onClick:()=>!t&&i?.(e),onDoubleClick:()=>{l&&a&&(U(e.id),G({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:e.end.toLocaleDateString(`en-CA`),progress:String(e.progress)}))},children:[(0,E.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:e.color||`#3b82f6`}}),t?(0,E.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:W.title||``,onChange:e=>G(t=>({...t,title:e.target.value})),onKeyDown:t=>{t.key===`Enter`?(a?.(e,{title:W.title,start:new Date(W.start),end:new Date(W.end),progress:Number(W.progress)||0}),U(null)):t.key===`Escape`&&U(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,E.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,E.jsx)(`span`,{className:`truncate`,children:e.title}),(0,E.jsxs)(`span`,{className:`text-[10px] text-muted-foreground sm:hidden`,children:[e.start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})]})]})]}),(0,E.jsx)(`div`,{className:`w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block`,children:t?(0,E.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:W.start||``,onChange:e=>G(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})}),(0,E.jsx)(`div`,{className:`w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block`,children:t?(0,E.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:W.end||``,onChange:e=>G(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})})]},e.id)})}),(0,E.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:e=>{ie.current=e,X.current=e},onScroll:ce,onTouchStart:ae,onTouchMove:oe,onTouchEnd:Q,"data-testid":`gantt-timeline`,children:(0,E.jsxs)(`div`,{className:`relative`,style:{width:q.length*L},children:[$!=null&&(0,E.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-red-500/80 z-20 pointer-events-none`,style:{left:$},"data-testid":`gantt-today-marker`,"aria-label":`Today`,children:(0,E.jsx)(`div`,{className:`absolute -top-2 -translate-x-1/2 left-0 text-[10px] font-semibold text-white bg-red-500 rounded-sm px-1 py-0.5 whitespace-nowrap`,children:`Today`})}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 flex pointer-events-none z-0`,children:q.map((e,t)=>(0,E.jsx)(`div`,{className:d(`border-r h-full`,e.isWeekend&&`bg-muted/20`),style:{width:L,minWidth:L}},t))}),e.map(e=>{let t=le(e);return(0,E.jsx)(`div`,{className:`relative border-b hover:bg-black/5`,style:{height:P},children:(0,E.jsxs)(`div`,{className:`absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm bg-primary border border-primary-foreground/20 shadow-sm cursor-pointer hover:brightness-110 flex items-center px-2 group`,style:{left:t.left,width:t.width,backgroundColor:e.color||`#3b82f6`},onClick:()=>i?.(e),children:[e.progress>0&&(0,E.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm`,style:{width:`${e.progress}%`}}),(0,E.jsxs)(`span`,{className:`text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity`,children:[Math.round(e.progress),`%`]})]})},e.id)}),(0,E.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-red-500 z-20 pointer-events-none`,style:{left:(new Date().getTime()-K.start.getTime())/(1e3*60*60*24)*L},children:(0,E.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-red-500 -ml-[3px]`})})]})]})})]})]})]})}function A(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function j(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 M(e){let t=null;if(e.startDateField&&e.endDateField)return t={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField},t;if(e.gantt&&(t=e.gantt),t){let e=l.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var N=({schema:e,dataSource:t,className:n,onTaskClick:r,onRowClick:i,...o})=>{let[l,u]=(0,T.useState)([]),[d,f]=(0,T.useState)(!0),[p,m]=(0,T.useState)(null),[h,g]=(0,T.useState)(null),_=A(e),v=(0,T.useMemo)(()=>_,[JSON.stringify(_)]),y=M(e),b=v?.provider===`value`;(0,T.useEffect)(()=>{(async()=>{try{if(f(!0),o.data&&Array.isArray(o.data)){u(o.data),f(!1);return}if(b&&v?.provider===`value`){u(v.items),f(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(v?.provider===`object`){let n=v.object,r=a(h?.fields);u(s(await t.find(n,{$filter:e.filter,$orderby:j(e.sort),...r.length>0?{$expand:r}:{}})))}else v?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectGantt`),u([]));f(!1)}catch(e){m(e),f(!1)}})()},[v,t,b,e.filter,e.sort,h]),(0,T.useEffect)(()=>{!b&&t&&(async()=>{try{if(!t)return;let n=v?.provider===`object`?v.object:e.objectName;if(!n)return;g(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,b,v]);let x=(0,T.useMemo)(()=>{if(!y||!l.length)return[];let{startDateField:e,endDateField:t,titleField:n,progressField:r,dependenciesField:i,colorField:a}=y;return l.map((o,s)=>{let c=o[e],l=o[t],u=o[n]||`Untitled Task`,d=r?o[r]:0,f=i?o[i]:[],p=a?o[a]:void 0;return{id:o.id||o._id||`task-${s}`,title:u,start:c?new Date(c):new Date,end:l?new Date(l):new Date,progress:Math.min(100,Math.max(0,d||0)),dependencies:Array.isArray(f)?f:[],color:p,data:o}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[l,y]),S=c({navigation:e.navigation,objectName:e.objectName,onRowClick:i});return d?(0,E.jsx)(`div`,{className:n,children:(0,E.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,E.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):p?(0,E.jsx)(`div`,{className:n,children:(0,E.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,E.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,p.message]})})}):y?(0,E.jsxs)(`div`,{className:n,children:[(0,E.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:(0,E.jsx)(k,{tasks:x,onTaskClick:e=>{S.handleClick(e.data),r?.(e.data)},onAddClick:()=>{}})}),S.isOverlay&&(0,E.jsx)(te,{...S,title:`Task Details`,children:e=>(0,E.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,E.jsxs)(`div`,{className:`flex flex-col`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,E.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]}):(0,E.jsx)(`div`,{className:n,children:(0,E.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,E.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},P=e({GanttView:()=>k,ObjectGantt:()=>N,ObjectGanttRenderer:()=>F}),F=({schema:e})=>{let{dataSource:t}=o()||{};return(0,E.jsx)(N,{schema:e,dataSource:t})};i.register(`object-gantt`,F,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),i.register(`gantt`,F,{namespace:`view`,label:`Gantt View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]});export{P as t};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t,g as n,t as r}from"./vendor-react-B1k2FF9f.js";import{D as i,H as a,I as o,L as s,M as c,_ as l,a as u,j as d,w as f}from"./framework-CoXA0nY6.js";import{f as p}from"./infrastructure-Djv3I7gr.js";import{$ as m,$t as h,Ba as g,Br as ee,Df as _,FA as v,Gn as te,Hn as y,J as b,KE as ne,Kn as re,NL as x,Os as ie,Qt as S,St as C,Tf as ae,Tl as oe,Un as se,Wn as w,XA as T,Xc as E,Zt as D,_t as O,a as k,bt as A,c as j,cn as ce,cs as le,dS as ue,df as de,eI as fe,en as pe,fn as me,hn as M,i as he,ir as ge,kf as _e,l as N,ln as ve,na as ye,nj as be,nk as xe,nt as Se,on as Ce,ot as we,pM as Te,pT as P,pn as F,po as Ee,qn as De,r as Oe,s as ke,sI as Ae,sn as je,tn as Me,un as I,vr as L,vt as Ne,wA as Pe,wE as Fe,wa as Ie,xn as Le,xt as R,yt as z}from"./ui-components-BCmPcwhR.js";var B=e(t(),1),Re={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},V=[`xs`,`sm`,`md`,`lg`,`xl`,`2xl`];function H(e){for(let t=V.length-1;t>=0;t--){let n=V[t];if(e>=Re[n])return n}return`xs`}function U(){let[e,t]=(0,B.useState)(()=>typeof window<`u`?window.innerWidth:1024);(0,B.useEffect)(()=>{if(typeof window>`u`)return;let e,n=()=>{clearTimeout(e),e=setTimeout(()=>{t(window.innerWidth)},100)};return window.addEventListener(`resize`,n),()=>{clearTimeout(e),window.removeEventListener(`resize`,n)}},[]);let n=H(e),r=V.indexOf(n);return{breakpoint:n,width:e,isMobile:r<V.indexOf(`md`),isTablet:r>=V.indexOf(`md`)&&r<V.indexOf(`lg`),isDesktop:r>=V.indexOf(`lg`),isAbove:t=>e>=Re[t],isBelow:t=>e<Re[t]}}function ze(e){let{onRefresh:t,threshold:n=80,enabled:r=!0}=e,i=(0,B.useRef)(null),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(0),l=(0,B.useRef)(0),u=(0,B.useCallback)(e=>{if(!r||a)return;let t=i.current;t&&t.scrollTop===0&&(l.current=e.touches[0].clientY)},[r,a]),d=(0,B.useCallback)(e=>{if(!r||a||!l.current)return;let t=e.touches[0].clientY-l.current;t>0&&c(Math.min(t,n*1.5))},[r,a,n]),f=(0,B.useCallback)(async()=>{if(!r||a)return;let e=s;if(c(0),l.current=0,e>=n){o(!0);try{await t()}finally{o(!1)}}},[r,a,s,n,t]);return(0,B.useEffect)(()=>{let e=i.current;if(!(!e||!r))return e.addEventListener(`touchstart`,u,{passive:!0}),e.addEventListener(`touchmove`,d,{passive:!0}),e.addEventListener(`touchend`,f,{passive:!0}),()=>{e.removeEventListener(`touchstart`,u),e.removeEventListener(`touchmove`,d),e.removeEventListener(`touchend`,f)}},[u,d,f,r]),{ref:i,isRefreshing:a,pullDistance:s}}var W=r(),G=(0,B.createContext)(null);G.displayName=`MobileContext`;function K({pwa:e,offline:t,children:n}){let r=U(),i=(0,B.useMemo)(()=>({...r,pwa:e,offline:t}),[r,e,t]);return(0,W.jsx)(G.Provider,{value:i,children:n})}var Be={red:`bg-red-100`,green:`bg-green-100`,blue:`bg-blue-100`,yellow:`bg-yellow-100`,orange:`bg-orange-100`,purple:`bg-purple-100`,pink:`bg-pink-100`,gray:`bg-gray-100`,grey:`bg-gray-100`,indigo:`bg-indigo-100`,teal:`bg-teal-100`,cyan:`bg-cyan-100`,amber:`bg-amber-100`,lime:`bg-lime-100`,emerald:`bg-emerald-100`,rose:`bg-rose-100`,sky:`bg-sky-100`,violet:`bg-violet-100`,fuchsia:`bg-fuchsia-100`,slate:`bg-slate-100`,zinc:`bg-zinc-100`,stone:`bg-stone-100`,neutral:`bg-neutral-100`};function q(e){return e.startsWith(`bg-`)?e:Be[e.toLowerCase().trim()]}function Ve(e){return(0,B.useCallback)(t=>{if(!e?.field||!e.colors)return;let n=String(t[e.field]??``),r=e.colors[n];if(r)return q(r)},[e?.field,e?.colors])}function He(e,t){return t.map(t=>String(e[t.field]??``)).join(` / `)}function Ue(e,t){return t.map(t=>{let n=e[t.field];return n!=null&&n!==``?String(n):`(empty)`}).join(` / `)}function J(e,t){return t.map(({field:t,type:n})=>{let r=e.map(e=>Number(e[t])).filter(e=>Number.isFinite(e)),i;switch(n){case`count`:i=r.length;break;case`sum`:i=r.reduce((e,t)=>e+t,0);break;case`avg`:i=r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0;break;case`min`:i=r.length>0?Math.min(...r):0;break;case`max`:i=r.length>0?Math.max(...r):0;break;default:i=0}return{field:t,type:n,value:i}})}function Y(e,t,n){let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}function We(e,t,n){let r=e?.fields,i=!!(r&&r.length>0),[a,o]=(0,B.useState)({}),s=(0,B.useMemo)(()=>r?r.some(e=>e.collapsed):!1,[r]);return{groups:(0,B.useMemo)(()=>{if(!i||!r)return[];let e=new Map,o=[];for(let n of t){let t=He(n,r);e.has(t)||(e.set(t,{label:Ue(n,r),rows:[]}),o.push(t)),e.get(t).rows.push(n)}let c=r[0]?.order??`asc`;return o.sort((e,t)=>Y(e,t,c)),o.map(t=>{let r=e.get(t),i=t in a?a[t]:s,o=n&&n.length>0?J(r.rows,n):[];return{key:t,label:r.label,rows:r.rows,collapsed:i,aggregations:o}})},[t,r,i,a,s,n]),isGrouped:i,toggleGroup:(0,B.useCallback)(e=>{o(t=>({...t,[e]:t[e]===void 0?!s:!t[e]}))},[s])}}var Ge=({groupKey:e,label:t,count:n,collapsed:r,aggregations:i,onToggle:a,children:o})=>(0,W.jsxs)(`div`,{className:`border rounded-md`,"data-testid":`group-row-${e}`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>a(e),"aria-expanded":!r,children:[r?(0,W.jsx)(T,{className:`h-4 w-4 shrink-0`}):(0,W.jsx)(be,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{className:`group-label`,children:t}),i&&i.length>0&&(0,W.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground group-aggregations`,children:i.map(e=>(0,W.jsxs)(`span`,{className:`mr-2`,children:[e.type,`: `,Number.isInteger(e.value)?e.value:e.value.toFixed(2)]},`${e.field}-${e.type}`))}),(0,W.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground group-count`,children:[`(`,n,`)`]})]}),!r&&o]});function Ke(e){return typeof e==`string`?{type:e}:e}function qe(e,t){if(t.length===0)return null;switch(e){case`count`:return t.length;case`sum`:return t.reduce((e,t)=>e+t,0);case`avg`:return t.reduce((e,t)=>e+t,0)/t.length;case`min`:return Math.min(...t);case`max`:return Math.max(...t);default:return null}}function Je(e,t){return t===null?``:`${{count:`Count`,sum:`Sum`,avg:`Avg`,min:`Min`,max:`Max`}[e]||e}: ${e===`avg`?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString()}`}function Ye(e,t){return(0,B.useMemo)(()=>{let n=new Map;if(!e||e.length===0||t.length===0)return{summaries:n,hasSummary:!1};for(let r of e){if(!r.summary)continue;let e=Ke(r.summary),i=e.field||r.field,a=[];for(let e of t){let t=e[i];if(t!=null&&typeof t==`number`&&!isNaN(t))a.push(t);else if(t!=null&&typeof t==`string`){let e=parseFloat(t);isNaN(e)||a.push(e)}}let o;if(e.type===`count`){let e=t.filter(e=>e[i]!=null&&e[i]!==``).length;o=e>0?e:null}else o=qe(e.type,a);n.set(r.field,{field:r.field,value:o,label:Je(e.type,o)})}return{summaries:n,hasSummary:n.size>0}},[e,t])}function Xe(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var Ze=({row:e,rowActions:t,canEdit:n,canDelete:r,onEdit:i,onDelete:a,onAction:o})=>(0,W.jsxs)(me,{children:[(0,W.jsx)(Le,{asChild:!0,children:(0,W.jsxs)(L,{variant:`ghost`,size:`icon`,className:`h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0`,"data-testid":`row-action-trigger`,children:[(0,W.jsx)(Fe,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Open menu`})]})}),(0,W.jsxs)(F,{align:`end`,children:[n&&i&&(0,W.jsxs)(M,{onClick:()=>i(e),children:[(0,W.jsx)(E,{className:`mr-2 h-4 w-4`}),`Edit`]}),r&&a&&(0,W.jsxs)(M,{onClick:()=>a(e),children:[(0,W.jsx)(Ee,{className:`mr-2 h-4 w-4`}),`Delete`]}),t?.map(t=>(0,W.jsx)(M,{onClick:()=>o?.(t,e),"data-testid":`row-action-${t}`,children:Xe(t)},t))]})]}),Qe=({selectedRows:e,actions:t,onAction:n,onClearSelection:r})=>!t||t.length===0||e.length===0?null:(0,W.jsxs)(`div`,{className:`border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0`,"data-testid":`bulk-actions-bar`,children:[(0,W.jsxs)(`span`,{className:`text-muted-foreground font-medium`,children:[e.length,` selected`]}),(0,W.jsx)(`div`,{className:`flex items-center gap-1 ml-2`,children:t.map(t=>(0,W.jsx)(L,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>n?.(t,e),"data-testid":`bulk-action-${t}`,children:Xe(t)},t))}),(0,W.jsx)(L,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs ml-auto`,onClick:r,children:`Clear`})]}),$e={"grid.actions":`Actions`,"grid.edit":`Edit`,"grid.delete":`Delete`,"grid.export":`Export`,"grid.exportAs":`Export as {{format}}`,"grid.loading":`Loading grid...`,"grid.errorLoading":`Error loading grid`,"grid.pullToRefresh":`Pull to refresh`,"grid.refreshing":`Refreshing…`,"grid.openRecord":`Open record`};function et(){try{let e=u();return e.t(`grid.actions`)===`grid.actions`?{t:(e,t)=>{let n=$e[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}:{t:e.t}}catch{return{t:(e,t)=>{let n=$e[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}}}function tt(e){if(e!=null)return typeof e==`string`?e:void 0}function nt(e){return e.data?Array.isArray(e.data)?{provider:`value`,items:e.data}:e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function rt(e){if(!(!e||e.length===0))return typeof e[0]==`object`&&e[0],e}var it=({schema:e,dataSource:t,onEdit:n,onDelete:r,onRowSelect:a,onRowClick:c,onCellChange:u,onRowSave:h,onBatchSave:ee,onAddRecord:v,...te})=>{let[y,re]=(0,B.useState)([]),[x,S]=(0,B.useState)(!0),[C,se]=(0,B.useState)(null),{t:w}=et(),{fieldLabel:T,translateOptions:E}=p(),[D,O]=(0,B.useState)(null),[A,de]=(0,B.useState)(!1),[fe,pe]=(0,B.useState)(0),[me,M]=(0,B.useState)(!1),[be,Ce]=(0,B.useState)(!1),P=b({dataSource:t}),[F,Ee]=(0,B.useState)(e.rowHeight??`compact`),[De,Ae]=(0,B.useState)([]),Me=B.useMemo(()=>e.id?`grid-columns-${e.objectName}-${e.id}`:`grid-columns-${e.objectName}`,[e.objectName,e.id]),[I,Ne]=(0,B.useState)(()=>{try{let e=localStorage.getItem(Me);return e?JSON.parse(e):{}}catch{return{}}}),Pe=(0,B.useCallback)(e=>{Ne(e);try{localStorage.setItem(Me,JSON.stringify(e))}catch(e){console.warn(`Failed to persist column state:`,e)}},[Me]),{ref:Fe,isRefreshing:Ie,pullDistance:Le}=ze({onRefresh:(0,B.useCallback)(async()=>{pe(e=>e+1)},[]),enabled:!!t&&!!e.objectName});(0,B.useEffect)(()=>{let e=()=>de(window.innerWidth<480);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let R=te.data,z=d(e.bind),Re=nt(e),V=B.useMemo(()=>R&&Array.isArray(R)?{provider:`value`,items:R}:z&&Array.isArray(z)?{provider:`value`,items:z}:Re,[JSON.stringify(Re),z,R]),H=V?.provider===`value`,U=V?.provider===`object`&&V&&`object`in V?V.object:e.objectName,G=e.fields,K=e.columns,Be=e.filter,q=e.sort,He=e.pagination,Ue=e.pageSize;(0,B.useEffect)(()=>{H&&V?.provider===`value`&&(re(e=>{let t=V.items;return JSON.stringify(e)===JSON.stringify(t)?e:t}),S(!1))},[H,V]),(0,B.useEffect)(()=>{if(!H||!U||!t)return;let e=!1;return(async()=>{try{if(typeof t.getObjectSchema!=`function`)return;let n=await t.getObjectSchema(U);e||O(n)}catch(e){console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${U}):`,e)}})(),()=>{e=!0}},[H,U,t]),(0,B.useEffect)(()=>{if(H)return;let n=!1;return(async()=>{S(!0),se(null);try{let r=null,i=rt(K)||G;if(U&&t)if(typeof t.getObjectSchema==`function`){let e=await t.getObjectSchema(U);if(n)return;r=e}else r={name:U,fields:{}};else if(i&&U)r={name:U,fields:{}};else if(U)throw Error(`DataSource required`);else throw Error(`Object name required for data fetching`);if(n||O(r),t&&U){let i={$select:(()=>{if(G)return G;if(K&&Array.isArray(K))return K.map(e=>typeof e==`string`?e:e.field)})(),$top:He?.pageSize||Ue||50};Be&&Array.isArray(Be)?i.$filter=Be:e.defaultFilters&&(i.$filter=e.defaultFilters),q?typeof q==`string`?i.$orderby=q:Array.isArray(q)&&(i.$orderby=q.map(e=>`${e.field} ${e.order}`).join(`, `)):e.defaultSort&&(i.$orderby=`${e.defaultSort.field} ${e.defaultSort.order}`);let a=s(r?.fields,K??G);a.length>0&&(i.$expand=a);let o=await t.find(U,i);if(n)return;re(o.data||[])}}catch(e){n||se(e)}finally{n||S(!1)}})(),()=>{n=!0}},[U,G,K,Be,q,He,Ue,t,H,V,fe]);let J=f({navigation:e.navigation,objectName:e.objectName,onNavigate:e.onNavigate,onRowClick:c}),{execute:Y}=l(),Ke=Ve(e.rowColor),qe=(0,B.useCallback)(t=>{let n=e.conditionalFormatting;if(!(!n||n.length===0))for(let e of n){let n=!1,r=(`condition`in e?e.condition:void 0)||(`expression`in e?e.expression:void 0)||void 0;if(r)n=o(r,t);else if(`field`in e&&`operator`in e&&e.field&&e.operator){let r=e,i=t[r.field];switch(r.operator){case`equals`:n=i===r.value;break;case`not_equals`:n=i!==r.value;break;case`contains`:n=typeof i==`string`&&typeof r.value==`string`&&i.includes(r.value);break;case`greater_than`:n=typeof i==`number`&&typeof r.value==`number`&&i>r.value;break;case`less_than`:n=typeof i==`number`&&typeof r.value==`number`&&i<r.value;break;case`in`:n=Array.isArray(r.value)&&r.value.includes(i);break}}if(n){let t={};return`style`in e&&e.style&&Object.assign(t,e.style),`backgroundColor`in e&&e.backgroundColor&&(t.backgroundColor=e.backgroundColor),`textColor`in e&&e.textColor&&(t.color=e.textColor),`borderColor`in e&&e.borderColor&&(t.borderColor=e.borderColor),t}}},[e.conditionalFormatting]),{groups:Je,isGrouped:$e,toggleGroup:it}=We(e.grouping,y),{summaries:at,hasSummary:X}=Ye(B.useMemo(()=>{let t=rt(e.columns);if(t&&t.length>0&&typeof t[0]==`object`)return t},[e.columns]),y),Z=(0,B.useCallback)(()=>{let t=e=>e&&{text:(0,W.jsx)(g,{className:`h-3.5 w-3.5`}),number:(0,W.jsx)(ue,{className:`h-3.5 w-3.5`}),currency:(0,W.jsx)(ue,{className:`h-3.5 w-3.5`}),percent:(0,W.jsx)(ue,{className:`h-3.5 w-3.5`}),date:(0,W.jsx)(Te,{className:`h-3.5 w-3.5`}),datetime:(0,W.jsx)(xe,{className:`h-3.5 w-3.5`}),boolean:(0,W.jsx)(oe,{className:`h-3.5 w-3.5`}),user:(0,W.jsx)(ye,{className:`h-3.5 w-3.5`}),select:(0,W.jsx)(ie,{className:`h-3.5 w-3.5`})}[e]||(0,W.jsx)(g,{className:`h-3.5 w-3.5`}),n=e=>{if(e.type)return e.type;let t=e.field.toLowerCase();if([`completed`,`is_completed`,`done`,`active`,`enabled`,`archived`].some(e=>t===e||t===`is_${e}`))return`boolean`;if([`created_time`,`modified_time`,`updated_time`,`created_at`,`updated_at`,`modified_at`,`last_login`,`logged_at`].some(e=>t===e||t.endsWith(`_${e}`)))return`datetime`;if([`date`,`due`,`created`,`updated`,`deadline`,`start`,`end`,`expires`].some(e=>t.includes(e))){if(y.length>0){let t=y.find(t=>t[e.field]!=null)?.[e.field];if(typeof t==`string`&&!isNaN(Date.parse(t)))return`date`}return`date`}if([`probability`,`percent`,`percentage`,`completion`,`progress`,`rate`].some(e=>t.includes(e))&&y.length>0&&typeof y.find(t=>t[e.field]!=null)?.[e.field]==`number`)return`percent`;if([`status`,`priority`,`category`,`stage`,`type`,`severity`,`level`].some(e=>t.includes(e))&&y.length>0){let t=new Set(y.map(t=>t[e.field]).filter(Boolean));if(t.size>0&&t.size<=10)return`select`}if([`assignee`,`owner`,`author`,`reporter`,`creator`,`user`].some(e=>t.includes(e)))return`user`;if([`amount`,`price`,`total`,`revenue`,`cost`,`budget`,`salary`].some(e=>t.includes(e))&&y.length>0&&typeof y.find(t=>t[e.field]!=null)?.[e.field]==`number`)return`currency`;if(y.length>0){let t=y.find(t=>t[e.field]!=null)?.[e.field];if(typeof t==`string`&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(t))return`datetime`}return null},r=rt(K);if(r){if(r.length>0&&typeof r[0]==`object`&&r[0]!==null){let i=r[0];if(`accessorKey`in i)return r.map(r=>{if(r.cell)return r;let i=n({field:r.accessorKey,label:r.header,type:r.type});if(!i)return r;let a=j(i),o={name:r.accessorKey,type:i};return i===`select`&&(o.options=Array.from(new Set(y.map(e=>e[r.accessorKey]).filter(Boolean))).map(e=>({value:e,label:N(String(e))}))),{...r,...e.showColumnTypeIcons&&{headerIcon:t(i)},cell:e=>(0,W.jsx)(a,{value:e,field:o})}});if(`field`in i)return r.filter(e=>e?.field&&typeof e.field==`string`&&!e.hidden).map((r,i)=>{let a=tt(r.label)||r.field.charAt(0).toUpperCase()+r.field.slice(1).replace(/_/g,` `),o=e.objectName?T(e.objectName,r.field,a):a,s,c=D?.fields?.[r.field],l=r.type||c?.type||n({field:r.field})||null,u=l?j(l):null,d={name:r.field,type:l||`text`};c&&(c.label&&(d.label=c.label),c.currency&&(d.currency=c.currency),c.precision!==void 0&&(d.precision=c.precision),c.format&&(d.format=c.format),c.options&&(d.options=E(e.objectName,r.field,c.options))),l===`select`&&!d.options&&(d.options=Array.from(new Set(y.map(e=>e[r.field]).filter(Boolean))).map(e=>({value:e,label:N(String(e))}))),r.options&&(d.options=E(e.objectName,r.field,r.options));let f=i===0&&!r.link&&!r.action,p=r.link||f;s=r.link&&r.action||f&&r.action||p?(e,t)=>(0,W.jsx)(`button`,{type:`button`,className:`text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit`,"data-testid":f?`primary-field-link`:`link-cell`,onClick:e=>{e.stopPropagation(),J.handleClick(t)},children:u?(0,W.jsx)(u,{value:e,field:d}):e!=null&&e!==``?String(e):(0,W.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`})}):r.action?(e,t)=>(0,W.jsx)(L,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,"data-testid":`action-cell`,onClick:n=>{n.stopPropagation(),Y({type:r.action,params:{record:t,field:r.field,value:e}})},children:Xe(r.action)}):u?e=>(0,W.jsx)(u,{value:e,field:d}):e=>e!=null&&e!==``?(0,W.jsx)(`span`,{children:String(e)}):(0,W.jsx)(we,{});let m=r.prefix;if(m?.field){let e=s,t=m.type===`badge`?j(`select`):null;s=(n,r)=>{let i=r[m.field];return(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[i!=null&&i!==``?t?(0,W.jsx)(t,{value:i,field:{name:m.field,type:`select`}}):(0,W.jsx)(`span`,{className:`text-muted-foreground text-xs mr-1.5`,children:String(i)}):null,e(n,r)]})}}let h=[`number`,`currency`,`percent`],g=l||r.type,ee=r.align||(g&&h.includes(g)?`right`:void 0),_=i===0||r.essential===!0;return{header:o,accessorKey:r.field,...e.showColumnTypeIcons&&{headerIcon:t(l)},...!_&&{className:`hidden sm:table-cell`},...r.width&&{width:r.width},...ee&&{align:ee},sortable:r.sortable!==!1,...r.resizable!==void 0&&{resizable:r.resizable},...r.wrap!==void 0&&{wrap:r.wrap},...s&&{cell:s},...r.pinned&&{pinned:r.pinned}}})}return r.filter(e=>typeof e==`string`&&e.trim().length>0).map((r,i)=>{let a=D?.fields?.[r],o=a?.label||r.charAt(0).toUpperCase()+r.slice(1).replace(/_/g,` `),s=e.objectName?T(e.objectName,r,o):o,c=a?.type||n({field:r})||null,l=c?j(c):null,u={name:r,type:c||`text`};a&&(a.label&&(u.label=a.label),a.currency&&(u.currency=a.currency),a.precision!==void 0&&(u.precision=a.precision),a.format&&(u.format=a.format),a.options&&(u.options=E(e.objectName,r,a.options))),c===`select`&&!u.options&&(u.options=Array.from(new Set(y.map(e=>e[r]).filter(Boolean))).map(e=>({value:e,label:N(String(e))})));let d=c&&[`number`,`currency`,`percent`].includes(c)?`right`:void 0,f=i===0,p;return f&&l?p=(e,t)=>(0,W.jsx)(`button`,{type:`button`,className:`text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit`,"data-testid":`primary-field-link`,onClick:e=>{e.stopPropagation(),J.handleClick(t)},children:(0,W.jsx)(l,{value:e,field:u})}):f?p=(e,t)=>(0,W.jsx)(`button`,{type:`button`,className:`text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit`,"data-testid":`primary-field-link`,onClick:e=>{e.stopPropagation(),J.handleClick(t)},children:e!=null&&e!==``?String(e):(0,W.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`})}):l&&(p=e=>(0,W.jsx)(l,{value:e,field:u})),{header:s,accessorKey:r,...e.showColumnTypeIcons&&c&&{headerIcon:t(c)},...d&&{align:d},...p&&{cell:p},sortable:a?.sortable!==!1}})}if(H){let r=V?.provider===`value`?V.items:[];if(r.length>0)return(G||Object.keys(r[0])).map(r=>{let i=D?.fields?.[r],a=i?.type||n({field:r})||null,o=a?j(a):null,s=i?.label||r.charAt(0).toUpperCase()+r.slice(1).replace(/_/g,` `),c={name:r,type:a||`text`};i&&(i.label&&(c.label=i.label),i.currency&&(c.currency=i.currency),i.precision!==void 0&&(c.precision=i.precision),i.format&&(c.format=i.format),i.options&&(c.options=E(e.objectName,r,i.options))),a===`select`&&!c.options&&(c.options=Array.from(new Set(y.map(e=>e[r]).filter(Boolean))).map(e=>({value:e,label:N(String(e))})));let l=a&&[`number`,`currency`,`percent`].includes(a)?`right`:void 0;return{header:s,accessorKey:r,...e.showColumnTypeIcons&&a&&{headerIcon:t(a)},...l&&{align:l},...o&&{cell:e=>(0,W.jsx)(o,{value:e,field:c})},sortable:i?.sortable!==!1}})}if(!D)return[];let i=[],a=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]),o=D?.compactLayout,s=Object.keys(D.fields||{}),c;if(G)c=G;else if(o?.length)c=o.filter(e=>D.fields?.[e]);else{let e=s.filter(e=>{let t=D.fields?.[e];return!(!t||t.hidden||t.readonly&&a.has(e))});c=[...e.filter(e=>!a.has(e)),...e.filter(e=>a.has(e))]}return c.forEach(t=>{let n=D.fields?.[t];if(!n||n.permissions&&n.permissions.read===!1)return;let r=j(n.type),a=[`number`,`currency`,`percent`],o=n.options?{...n,options:E(e.objectName,t,n.options)}:n;i.push({header:e.objectName?T(e.objectName,t,n.label||t):n.label||t,accessorKey:t,...a.includes(n.type)&&{align:`right`},cell:e=>(0,W.jsx)(r,{value:e,field:o}),sortable:n.sortable!==!1})}),i},[D,G,K,V,H,J.handleClick,Y,y,T,E,e.objectName]),ot=(0,B.useCallback)(t=>{let n=e.exportOptions,r=n?.maxRecords||0,i=n?.includeHeaders!==!1,a=n?.fileNamePrefix||e.objectName||`export`;if((t===`csv`||t===`xlsx`||t===`json`)&&P.isSupported&&e.objectName&&!H&&n?.streaming!==!1){let n=Z().filter(e=>e.accessorKey!==`_actions`).map(e=>e.accessorKey).filter(Boolean);M(!1),Ce(!0),P.start(e.objectName,{format:t===`json`?`json`:t,fields:n.length?n:void 0,includeHeaders:i,limit:r>0?r:void 0});return}let o=r>0?y.slice(0,r):y,s=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)},c=e=>{let t=e==null?``:String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
|
|
2
|
+
`)||t.includes(`\r`)?`"${t.replace(/"/g,`""`)}"`:t};if(t===`csv`){let e=Z().filter(e=>e.accessorKey!==`_actions`),t=e.map(e=>e.accessorKey),n=e.map(e=>e.header),r=[];i&&r.push(n.join(`,`)),o.forEach(e=>{r.push(t.map(t=>c(e[t])).join(`,`))}),s(new Blob([r.join(`
|
|
3
|
+
`)],{type:`text/csv;charset=utf-8;`}),`${a}.csv`)}else t===`json`&&s(new Blob([JSON.stringify(o,null,2)],{type:`application/json`}),`${a}.json`);M(!1)},[y,e.exportOptions,e.objectName,Z,P,H]);if(C)return(0,W.jsxs)(`div`,{className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,W.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:w(`grid.errorLoading`)}),(0,W.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:C.message})]});if(x&&y.length===0)return A?(0,W.jsx)(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>(0,W.jsxs)(`div`,{className:`border rounded-lg p-3 bg-card animate-pulse`,children:[(0,W.jsx)(`div`,{className:`h-5 bg-muted rounded w-3/4 mb-3`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,W.jsx)(`div`,{className:`h-4 bg-muted rounded w-1/4`}),(0,W.jsx)(`div`,{className:`h-5 bg-muted rounded-full w-20`})]}),(0,W.jsx)(`div`,{className:`h-3 bg-muted rounded w-1/3`})]},e))}):(0,W.jsxs)(`div`,{className:`p-4 sm:p-8 text-center`,children:[(0,W.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground`}),(0,W.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:w(`grid.loading`)})]});let Q=[...Z()];if(I.widths&&(Q=Q.map(e=>{let t=I.widths?.[e.accessorKey];return t?{...e,size:t}:e})),I.order&&I.order.length>0){let e=new Map(I.order.map((e,t)=>[e,t]));Q.sort((t,n)=>(e.get(t.accessorKey)??1/0)-(e.get(n.accessorKey)??1/0))}let $=`operations`in e?e.operations:void 0,st=$&&($.update||$.delete),ct=e.rowActions&&e.rowActions.length>0,lt=st||ct?[...Q,{header:w(`grid.actions`),accessorKey:`_actions`,cell:(t,i)=>(0,W.jsx)(Ze,{row:i,rowActions:e.rowActions,canEdit:!!($?.update&&n),canDelete:!!($?.delete&&r),onEdit:n,onDelete:r,onAction:(e,t)=>Y({type:e,params:{record:t}})}),sortable:!1}]:Q,ut=lt.filter(e=>e.pinned===`left`),dt=lt.filter(e=>e.pinned===`right`),ft=lt.filter(e=>!e.pinned),pt=ut.length>0||dt.length>0,mt=`sticky right-0 z-10 bg-background border-l border-border`,ht=pt?[...ut,...ft,...dt.map(e=>({...e,className:[e.className,mt].filter(Boolean).join(` `),cellClassName:[e.cellClassName,mt].filter(Boolean).join(` `)}))]:lt,gt=pt?ut.length:e.frozenColumns??1,_t=e.batchActions??e.bulkActions,vt=_t&&_t.length>0,yt=!1;e.selection?.type?yt=e.selection.type===`none`?!1:e.selection.type:e.selectable===void 0?vt&&(yt=`multiple`):yt=e.selectable;let bt=e.pagination===void 0?e.showPagination===void 0?!0:e.showPagination:!0,xt=e.pagination?.pageSize||e.pageSize||10,St=e.searchableFields===void 0?e.showSearch===void 0?!0:e.showSearch:e.searchableFields.length>0,Ct={type:`data-table`,caption:e.label||e.title,columns:ht,data:y,pagination:bt,pageSize:xt,searchable:St,selectable:yt,sortable:!0,exportable:$?.export,rowActions:!!(e.editable&&st),resizableColumns:e.resizable??e.resizableColumns??!0,reorderableColumns:e.reorderableColumns??!1,editable:e.editable??!1,singleClickEdit:e.singleClickEdit??!0,className:e.className,cellClassName:F===`compact`?`px-3 py-1 text-[13px] leading-tight`:F===`short`?`px-3 py-1 text-[13px] leading-normal`:F===`tall`?`px-3 py-2.5 text-sm`:F===`extra_tall`?`px-3 py-3.5 text-sm leading-relaxed`:`px-3 py-1.5 text-[13px] leading-normal`,showRowNumbers:!0,showAddRow:!!$?.create,onAddRecord:v,rowClassName:e.rowColor?(e,t)=>Ke(e):void 0,rowStyle:e.conditionalFormatting?.length?(e,t)=>qe(e):void 0,frozenColumns:gt,onSelectionChange:e=>{Ae(e),a?.(e)},onRowClick:J.handleClick,onCellChange:u,onRowSave:h,onBatchSave:ee,onColumnResize:(e,t)=>{Pe({...I,widths:{...I.widths,[e]:t}})},onColumnReorder:e=>{Pe({...I,order:e})}},wt=e=>({...Ct,caption:void 0,data:e,pagination:!1,searchable:!1}),Tt=e.label?`${e.label} Detail`:e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1)} Detail`:`Record Detail`;if(A&&y.length>0&&!$e){let e=Z().filter(e=>e.accessorKey!==`_actions`),t=new Map;e.forEach(e=>t.set(e.accessorKey,e));let n=e[0],r=[`amount`,`price`,`total`,`revenue`,`cost`,`value`,`budget`,`salary`],i=[`stage`,`status`,`priority`,`category`,`severity`,`level`],a=[`date`,`due`,`created`,`updated`,`deadline`,`start`,`end`,`expires`],o=[`probability`,`percent`,`rate`,`ratio`,`confidence`,`score`],s=e=>{let t=(e||``).toLowerCase();return t.includes(`won`)||t.includes(`completed`)||t.includes(`done`)||t.includes(`active`)||t===`activated`||t===`success`||t===`approved`||t===`paid`?`bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60`:t.includes(`lost`)||t.includes(`cancelled`)||t.includes(`rejected`)||t.includes(`closed lost`)||t===`expired`||t===`terminated`||t===`failed`||t===`overdue`?`bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60`:t.includes(`negotiation`)||t.includes(`review`)||t.includes(`in progress`)||t.includes(`approval`)||t===`in_approval`||t===`pending_approval`?`bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60`:t.includes(`proposal`)||t.includes(`pending`)?`bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60`:t.includes(`qualification`)||t.includes(`qualified`)?`bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60`:t.includes(`prospecting`)||t.includes(`new`)||t.includes(`open`)?`bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60`:t===`draft`||t.includes(`draft`)?`bg-slate-50 text-slate-700 border-slate-200 dark:bg-slate-950/40 dark:text-slate-300 dark:border-slate-900/60`:`bg-muted text-muted-foreground border-border`},c=e=>{let t=(e||``).toLowerCase();return t.includes(`won`)||t.includes(`completed`)||t.includes(`done`)||t.includes(`active`)||t===`activated`?`border-l-green-500`:t.includes(`lost`)||t.includes(`cancelled`)||t.includes(`rejected`)||t===`expired`||t===`terminated`?`border-l-red-500`:t.includes(`negotiation`)||t.includes(`review`)||t.includes(`in progress`)||t.includes(`approval`)?`border-l-yellow-500`:t.includes(`proposal`)||t.includes(`pending`)?`border-l-blue-500`:t.includes(`qualification`)||t.includes(`qualified`)?`border-l-indigo-500`:t.includes(`prospecting`)||t.includes(`new`)||t.includes(`open`)?`border-l-purple-500`:t===`draft`||t.includes(`draft`)?`border-l-slate-400`:`border-l-gray-300`},l=e=>{let t=e.toLowerCase();return r.some(e=>t.includes(e))?`amount`:i.some(e=>t.includes(e))?`stage`:a.some(e=>t.includes(e))?`date`:o.some(e=>t.includes(e))?`percent`:`other`};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`space-y-2 p-2`,children:y.map((t,r)=>{let i=e.slice(1,5),a=i.find(e=>l(e.accessorKey)===`amount`),o=i.find(e=>l(e.accessorKey)===`stage`),u=i.filter(e=>l(e.accessorKey)===`date`),d=i.filter(e=>l(e.accessorKey)===`percent`),f=i.filter(e=>e!==a&&e!==o&&!u.includes(e)&&!d.includes(e)),p=o?String(t[o.accessorKey]??``):``,m=p?c(p):``;return(0,W.jsxs)(`div`,{className:[`border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation`,m?`border-l-[3px] ${m}`:``].filter(Boolean).join(` `),onClick:()=>J.handleClick(t),children:[n&&(0,W.jsx)(`div`,{className:`font-semibold text-sm truncate mb-1`,children:t[n.accessorKey]!=null&&typeof t[n.accessorKey]==`object`?String(t[n.accessorKey]):t[n.accessorKey]??`—`}),(a||o)&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[a&&(0,W.jsx)(`span`,{className:`text-sm tabular-nums font-medium`,children:typeof t[a.accessorKey]==`number`?Oe(t[a.accessorKey]):t[a.accessorKey]!=null&&typeof t[a.accessorKey]==`object`?String(t[a.accessorKey]):t[a.accessorKey]??`—`}),o&&t[o.accessorKey]&&(0,W.jsx)(ge,{variant:`outline`,className:`text-xs shrink-0 max-w-[140px] truncate ${s(String(t[o.accessorKey]))}`,children:String(t[o.accessorKey])})]}),(u.length>0||d.length>0)&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between py-0.5 text-xs text-muted-foreground`,children:[u[0]&&(0,W.jsx)(`span`,{className:`tabular-nums`,children:t[u[0].accessorKey]?k(t[u[0].accessorKey],`short`):`—`}),d[0]&&t[d[0].accessorKey]!=null&&(0,W.jsx)(`span`,{className:`tabular-nums`,children:ke(Number(t[d[0].accessorKey]))})]}),u.slice(1).map(e=>(0,W.jsxs)(`div`,{className:`flex justify-between items-center py-0.5`,children:[(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.header}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t[e.accessorKey]?k(t[e.accessorKey],`short`):`—`})]},e.accessorKey)),f.map(e=>{let n=t[e.accessorKey];return n==null||n===``?null:(0,W.jsxs)(`div`,{className:`flex justify-between items-center py-0.5`,children:[(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.header}),(0,W.jsx)(`span`,{className:`text-xs font-medium truncate ml-2 text-right`,children:e.cell?e.cell(n,t):String(n)})]},e.accessorKey)})]},t.id||t._id||r)})}),J.isOverlay&&(0,W.jsx)(Se,{...J,title:Tt,children:e=>(0,W.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,W.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})}let Et=()=>{Ee(e=>e===`compact`?`short`:e===`short`?`medium`:e===`medium`?`tall`:e===`tall`?`extra_tall`:`compact`)},Dt={compact:ae,short:_,medium:_e,tall:le,extra_tall:le}[F],Ot=e.rowHeight!==void 0,kt=e.exportOptions||Ot?(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1`,children:[Ot&&(0,W.jsxs)(L,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs`,onClick:Et,title:`Row height: ${F}`,children:[(0,W.jsx)(Dt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline capitalize`,children:F})]}),e.exportOptions&&(0,W.jsxs)(je,{open:me,onOpenChange:M,children:[(0,W.jsx)(ve,{asChild:!0,children:(0,W.jsxs)(L,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs`,children:[(0,W.jsx)(ne,{className:`h-3.5 w-3.5 mr-1.5`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:w(`grid.export`)})]})}),(0,W.jsx)(ce,{align:`end`,className:`w-48 p-2`,children:(0,W.jsx)(`div`,{className:`space-y-1`,children:(e.exportOptions.formats||[`csv`,`json`]).map(e=>(0,W.jsxs)(L,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>ot(e),children:[(0,W.jsx)(ne,{className:`h-3.5 w-3.5 mr-2`}),w(`grid.exportAs`,{format:e.toUpperCase()})]},e))})})]})]}):null,At=e=>{let t=[`_id`,`id`,`created_at`,`updated_at`,`created_by`,`updated_by`],n=Object.entries(e),r=n.filter(([e])=>!t.includes(e)),i=n.filter(([e])=>t.includes(e)&&e!==`_id`&&e!==`id`),a=e=>e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `),o=(e,t)=>{if(t==null||t===``)return(0,W.jsx)(`span`,{className:`text-muted-foreground/50 text-sm italic`,children:`Empty`});let n=D?.fields?.[e];if(n?.type){let e=j(n.type);if(e)return(0,W.jsx)(e,{value:t,field:n})}return typeof t==`boolean`?(0,W.jsx)(ge,{variant:t?`default`:`outline`,children:t?`Yes`:`No`}):typeof t==`string`&&!isNaN(Date.parse(t))&&(e.includes(`date`)||e.includes(`_at`)||e.includes(`time`))?(0,W.jsx)(`span`,{className:`text-sm tabular-nums`,children:k(t)}):typeof t==`number`&&[`amount`,`price`,`total`,`revenue`,`cost`,`value`,`budget`,`salary`].some(t=>e.toLowerCase().includes(t))?(0,W.jsx)(`span`,{className:`text-sm tabular-nums font-medium`,children:he(t)}):(0,W.jsx)(`span`,{className:`text-sm break-words`,children:String(t)})};return(0,W.jsxs)(`div`,{className:`space-y-4`,"data-testid":`record-detail-panel`,children:[(0,W.jsx)(`div`,{className:`rounded-lg border bg-card`,children:(0,W.jsx)(`div`,{className:`divide-y`,children:r.map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0`,children:a(e)}),(0,W.jsx)(`div`,{className:`flex-1 min-w-0`,children:o(e,t)})]},e))})}),i.length>0&&(0,W.jsxs)(`div`,{className:`rounded-lg border bg-muted/30`,children:[(0,W.jsx)(`div`,{className:`px-4 py-2 border-b`,children:(0,W.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`System`})}),(0,W.jsx)(`div`,{className:`divide-y divide-border/50`,children:i.map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-2`,children:[(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground w-1/3 text-right shrink-0`,children:a(e)}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1 min-w-0 break-words`,children:String(t??``)})]},e))})]})]})},jt=X?(0,W.jsx)(`div`,{className:`border-t bg-muted/30 px-2 py-1.5`,"data-testid":`column-summary-footer`,children:(0,W.jsx)(`div`,{className:`flex gap-4 text-xs text-muted-foreground font-medium`,children:ht.filter(e=>at.has(e.accessorKey)).map(e=>{let t=at.get(e.accessorKey);return(0,W.jsxs)(`span`,{"data-testid":`summary-${e.accessorKey}`,children:[e.header,`: `,t.label]},e.accessorKey)})})}):null,Mt=$e?(0,W.jsx)(`div`,{className:`space-y-2`,children:Je.map(e=>(0,W.jsx)(Ge,{groupKey:e.key,label:e.label,count:e.rows.length,collapsed:e.collapsed,aggregations:e.aggregations,onToggle:it,children:(0,W.jsx)(i,{schema:wt(e.rows)})},e.key))}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(i,{schema:Ct}),jt]}),Nt=(0,W.jsx)(m,{open:be,onOpenChange:Ce,job:P,filename:`${e.exportOptions?.fileNamePrefix||e.objectName||`export`}.${P.progress?.format||`csv`}`,closeAfterDownloadMs:400});return J.isOverlay&&J.mode===`split`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Se,{...J,title:Tt,mainContent:(0,W.jsxs)(W.Fragment,{children:[kt,Mt,(0,W.jsx)(Qe,{selectedRows:De,actions:_t??[],onAction:(e,t)=>Y({type:e,params:{records:t}}),onClearSelection:()=>Ae([])})]}),children:e=>At(e)}),Nt]}):(0,W.jsxs)(`div`,{ref:Fe,className:`relative h-full`,children:[Le>0&&(0,W.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Le},children:w(Ie?`grid.refreshing`:`grid.pullToRefresh`)}),kt,Mt,(0,W.jsx)(Qe,{selectedRows:De,actions:_t??[],onAction:(e,t)=>Y({type:e,params:{records:t}}),onClearSelection:()=>Ae([])}),J.isOverlay&&(0,W.jsx)(Se,{...J,title:Tt,children:e=>At(e)}),Nt]})},at=e(n(),1);function X(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
4
|
+
font-size: .6rem;
|
|
5
|
+
font-weight: bold;
|
|
6
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function Z(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ot=(e,t)=>Math.abs(e-t)<1.01,Q=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},$=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},st=e=>e,ct=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},lt=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i($(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i($(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},ut={passive:!0},dt=typeof window>`u`?!0:`onscrollend`in window,ft=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&dt?()=>void 0:Q(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,ut);let l=e.options.useScrollendEvent&&dt;return l&&n.addEventListener(`scrollend`,c,ut),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},pt=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},mt=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},ht=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:st,rangeExtractor:ct,onChange:()=>{},measureElement:pt,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=X(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=X(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=X(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=X(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?_t({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=X(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=X(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return Z(t[gt(0,t.length-1,e=>Z(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&ot(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},gt=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function _t({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=gt(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var vt=typeof document<`u`?B.useLayoutEffect:B.useEffect;function yt({useFlushSync:e=!0,...t}){let n=B.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,at.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=B.useState(()=>new ht(r));return i.setOptions(r),vt(()=>i._didMount(),[]),vt(()=>i._willUpdate()),i}function bt(e){return yt({observeElementRect:lt,observeElementOffset:ft,scrollToFn:mt,...e})}var xt=10;function St(e){let t=[],n=[],r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1];i?o===`"`&&s===`"`?(r+=`"`,a++):o===`"`?i=!1:r+=o:o===`"`?i=!0:o===`,`?(n.push(r.trim()),r=``):o===`
|
|
7
|
+
`||o===`\r`&&s===`
|
|
8
|
+
`?(n.push(r.trim()),n.some(e=>e!==``)&&t.push(n),n=[],r=``,o===`\r`&&a++):r+=o}return n.push(r.trim()),n.some(e=>e!==``)&&t.push(n),t}function Ct(e,t){if(!e)return!0;switch(t){case`number`:case`currency`:case`percent`:return!isNaN(Number(e));case`boolean`:return[`true`,`false`,`1`,`0`,`yes`,`no`].includes(e.toLowerCase());case`date`:case`datetime`:return!isNaN(Date.parse(e));default:return!0}}function wt(e,t){let n={};return e.forEach((e,r)=>{let i=e.toLowerCase().replace(/[_\s-]/g,``),a=t.find(e=>{let t=e.name.toLowerCase().replace(/[_\s-]/g,``),n=e.label.toLowerCase().replace(/[_\s-]/g,``);return t===i||n===i});a&&(n[r]=a.name)}),n}function Tt(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Et(e,t){if(!e)return[];try{let n=e.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r.filter(e=>e&&e.id&&e.name&&e.mapping):[]}catch{return[]}}function Dt(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch{}}function Ot(e,t){let n={};return Object.entries(t).forEach(([t,r])=>{let i=e[Number(t)];i&&(n[i.trim().toLowerCase()]=r)}),n}function kt(e,t,n){let r=new Set(n.map(e=>e.name)),i={};return t.forEach((t,n)=>{let a=e.mapping[t.trim().toLowerCase()];a&&r.has(a)&&(i[n]=a)}),i}function At(e,t,n){let r=[],i={};for(let a of t){let t=e[a.csvIdx]??``;if(a.field.required&&!t){r.push({row:n,field:a.field.name,message:`Required field is empty`});continue}if(t&&!Ct(t,a.field.type)){r.push({row:n,field:a.field.name,message:`Invalid ${a.field.type} value: "${t}"`});continue}i[a.field.name]=t}return{record:i,errors:r}}var jt=({onFileLoaded:e})=>{let[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(null),a=(0,B.useCallback)(t=>{if(i(null),!t.name.endsWith(`.csv`)){i(`Only CSV files are supported.`);return}let n=new FileReader;n.onload=t=>{let n=St(t.target?.result);if(n.length<2){i(`File must contain a header row and at least one data row.`);return}e(n[0],n.slice(1))},n.readAsText(t)},[e]);return(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,W.jsxs)(`div`,{className:x(`flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors`,t?`border-primary bg-primary/5`:`border-muted-foreground/25`),onDragOver:e=>{e.preventDefault(),n(!0)},onDragLeave:()=>n(!1),onDrop:e=>{e.preventDefault(),n(!1);let t=e.dataTransfer.files[0];t&&a(t)},children:[(0,W.jsx)(Ie,{className:`h-10 w-10 text-muted-foreground`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Drag & drop a CSV file here, or click to browse`}),(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`file`,accept:`.csv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&a(t)}}),(0,W.jsx)(L,{variant:`outline`,size:`sm`,asChild:!0,children:(0,W.jsx)(`span`,{children:`Browse Files`})})]})]}),r&&(0,W.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-destructive`,children:[(0,W.jsx)(v,{className:`h-4 w-4`}),` `,r]})]})},Mt=({templates:e,selectedId:t,onSelect:n,onSaveAs:r,onDelete:i,disabled:a})=>{let[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1);return(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border bg-muted/30 p-2`,"data-testid":`import-template-bar`,children:[(0,W.jsx)(de,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Mapping template:`}),(0,W.jsxs)(D,{value:t??`__none__`,onValueChange:e=>e!==`__none__`&&n(e),children:[(0,W.jsx)(pe,{className:`h-7 w-48 text-xs`,"data-testid":`import-template-select`,children:(0,W.jsx)(Me,{placeholder:e.length?`Choose template…`:`No saved templates`})}),(0,W.jsxs)(S,{children:[(0,W.jsx)(h,{value:`__none__`,disabled:e.length===0,children:e.length?`— None —`:`No saved templates`}),e.map(e=>(0,W.jsx)(h,{value:e.id,children:e.name},e.id))]})]}),c?(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(I,{value:o,onChange:e=>s(e.target.value),placeholder:`Template name`,className:`h-7 w-40 text-xs`,"data-testid":`import-template-name-input`,autoFocus:!0}),(0,W.jsx)(L,{type:`button`,size:`sm`,onClick:()=>{o.trim()&&(r(o.trim()),s(``),l(!1))},disabled:!o.trim()||a,"data-testid":`import-template-confirm-save`,children:`Save`}),(0,W.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{l(!1),s(``)},children:`Cancel`})]}):(0,W.jsx)(L,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>l(!0),disabled:a,"data-testid":`import-template-save-btn`,children:`Save current`}),t&&(0,W.jsx)(L,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,"aria-label":`Delete template`,"data-testid":`import-template-delete-btn`,children:(0,W.jsx)(Ee,{className:`h-3.5 w-3.5`})})]})},Nt=({headers:e,fields:t,mapping:n,onMappingChange:r,templates:i,selectedTemplateId:a,onSelectTemplate:o,onSaveTemplate:s,onDeleteTemplate:c})=>{let l=(0,B.useMemo)(()=>new Set(Object.values(n)),[n]),u=(0,B.useCallback)((e,t)=>{let i={...n};t===`__skip__`?delete i[e]:i[e]=t,r(i)},[n,r]);return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Mt,{templates:i,selectedId:a,onSelect:o,onSaveAs:s,onDelete:c,disabled:Object.keys(n).length===0}),(0,W.jsx)(`div`,{className:`max-h-[320px] overflow-auto`,children:(0,W.jsxs)(O,{children:[(0,W.jsx)(R,{children:(0,W.jsxs)(C,{children:[(0,W.jsx)(A,{children:`CSV Column`}),(0,W.jsx)(A,{children:`Maps To`}),(0,W.jsx)(A,{className:`w-24 text-center`,children:`Status`})]})}),(0,W.jsx)(Ne,{children:e.map((e,r)=>(0,W.jsxs)(C,{children:[(0,W.jsx)(z,{className:`font-medium`,children:e}),(0,W.jsx)(z,{children:(0,W.jsxs)(D,{value:n[r]??`__skip__`,onValueChange:e=>u(r,e),children:[(0,W.jsx)(pe,{className:`h-8 w-56`,children:(0,W.jsx)(Me,{placeholder:`Skip column`})}),(0,W.jsxs)(S,{children:[(0,W.jsx)(h,{value:`__skip__`,children:`— Skip —`}),t.map(e=>(0,W.jsxs)(h,{value:e.name,disabled:l.has(e.name)&&n[r]!==e.name,children:[e.label,e.required?` *`:``]},e.name))]})]})}),(0,W.jsx)(z,{className:`text-center`,children:n[r]?(0,W.jsx)(ge,{variant:`default`,className:`text-xs`,children:`Mapped`}):(0,W.jsx)(ge,{variant:`secondary`,className:`text-xs`,children:`Skipped`})})]},r))})]})})]})},Pt=({headers:e,rows:t,mapping:n,fields:r,corrections:i,onCorrect:a})=>{let o=(0,B.useMemo)(()=>Object.entries(n).map(([t,n])=>({csvIdx:Number(t),header:e[Number(t)],field:r.find(e=>e.name===n)})),[n,e,r]),s=t.slice(0,xt),c=(0,B.useCallback)((e,t)=>{let n=i[e]?.[t];return n===void 0?s[e]?.[t]??``:n},[i,s]),l=(0,B.useMemo)(()=>s.map((e,t)=>{let n={};for(let e of o){let r=c(t,e.csvIdx);e.field.required&&!r?n[e.csvIdx]=`Required`:r&&!Ct(r,e.field.type)&&(n[e.csvIdx]=`Invalid ${e.field.type}`)}return n}),[s,o,c]),u=l.filter(e=>Object.keys(e).length>0).length,d=Object.keys(i).length;return(0,W.jsxs)(`div`,{className:`max-h-[360px] overflow-auto`,children:[(u>0||d>0)&&(0,W.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 text-xs`,"data-testid":`import-preview-status`,children:[u>0&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,W.jsx)(v,{className:`h-3.5 w-3.5`}),` `,u,` row(s) with errors`]}),d>0&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1 text-emerald-600`,children:[(0,W.jsx)(Pe,{className:`h-3.5 w-3.5`}),` `,d,` row(s) corrected`]}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`— click a highlighted cell to fix it inline.`})]}),(0,W.jsxs)(O,{children:[(0,W.jsx)(R,{children:(0,W.jsxs)(C,{children:[(0,W.jsx)(A,{className:`w-12`,children:`#`}),o.map(e=>(0,W.jsx)(A,{children:e.field.label},e.csvIdx))]})}),(0,W.jsx)(Ne,{children:s.map((e,t)=>{let n=l[t],r=Object.keys(n).length>0,s=i[t]!==void 0;return(0,W.jsxs)(C,{className:x(r&&`bg-destructive/5`,!r&&s&&`bg-emerald-50 dark:bg-emerald-950/20`),"data-testid":`import-preview-row-${t}`,children:[(0,W.jsx)(z,{className:`text-xs text-muted-foreground`,children:t+1}),o.map(e=>{let r=c(t,e.csvIdx),o=n[e.csvIdx],s=i[t]?.[e.csvIdx]!==void 0;return(0,W.jsx)(z,{className:x(o&&`text-destructive`,s&&!o&&`text-emerald-600`),title:o,children:(0,W.jsx)(I,{value:r,onChange:n=>a(t,e.csvIdx,n.target.value),className:x(`h-7 px-1 text-xs`,o&&`border-destructive`,s&&!o&&`border-emerald-500`),"data-testid":`import-preview-cell-${t}-${e.csvIdx}`,"aria-invalid":o?`true`:`false`,"aria-label":`${e.field.label} for row ${t+1}`})},e.csvIdx)})]},t)})})]}),(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Showing `,s.length,` of `,t.length,` rows`]})]})},Ft=({objectName:e,objectLabel:t,fields:n,dataSource:r,onComplete:i,onCancel:a,open:o,onOpenChange:s,onErrorMode:c=`skip`,templateStorageKey:l,templateStorage:u})=>{let[d,f]=(0,B.useState)(`upload`),[p,m]=(0,B.useState)([]),[h,g]=(0,B.useState)([]),[_,v]=(0,B.useState)({}),[b,ne]=(0,B.useState)(!1),[ie,S]=(0,B.useState)(0),[C,ae]=(0,B.useState)(null),[oe,T]=(0,B.useState)({}),E=t??e,D=(0,B.useMemo)(()=>u===void 0?Tt():u,[u]),O=l??`objectui:import-templates:${e}`,[k,A]=(0,B.useState)(()=>Et(D,O)),[j,ce]=(0,B.useState)(null);(0,B.useEffect)(()=>{A(Et(D,O))},[D,O]);let le=(0,B.useCallback)(e=>{let t=k.find(t=>t.id===e);t&&(ce(e),v(kt(t,p,n)))},[k,p,n]),ue=(0,B.useCallback)(e=>{let t={id:`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,name:e,mapping:Ot(p,_),updatedAt:Date.now()},n=[...k,t];A(n),ce(t.id),Dt(D,O,n)},[k,p,_,D,O]),de=(0,B.useCallback)(()=>{if(!j)return;let e=k.filter(e=>e.id!==j);A(e),ce(null),Dt(D,O,e)},[k,j,D,O]),pe=(0,B.useCallback)((e,t,n)=>{T(r=>{let i={...r},a={...i[e]??{}};return n===(h[e]?.[t]??``)?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,i})},[h]),me=(0,B.useMemo)(()=>{let e=new Set(Object.values(_));return n.filter(t=>t.required&&!e.has(t.name))},[n,_]),M=(0,B.useCallback)((e,t)=>{m(e),g(t),v(wt(e,n)),T({}),f(`mapping`)},[n]),he=(0,B.useCallback)(async()=>{ne(!0),S(0);let t=[],a=0,o=0,s=Object.entries(_).map(([e,t])=>({csvIdx:Number(e),field:n.find(e=>e.name===t)}));for(let n=0;n<h.length;n++){let i=h[n],l=oe[n],{record:u,errors:d}=At(l?i.map((e,t)=>l[t]===void 0?e:l[t]):i,s,n+1);if(d.length>0){if(o++,t.push(...d),c===`stop`)break}else try{r?.create&&await r.create(e,u),a++}catch(e){o++;let r=e instanceof Error?e.message:`Failed to create record`;if(t.push({row:n+1,field:``,message:r}),c===`stop`)break}S(Math.round((n+1)/h.length*100))}let l={totalRows:h.length,importedRows:a,skippedRows:o,errors:t};ae(l),ne(!1),i?.(l)},[h,_,n,r,e,i,c,oe]),_e=(0,B.useCallback)(()=>{f(`upload`),m([]),g([]),v({}),S(0),ae(null),T({}),ce(null)},[]),N=(0,B.useCallback)(()=>{_e(),s?.(!1),a?.()},[_e,s,a]);return(0,W.jsx)(y,{open:o,onOpenChange:e=>{e?s?.(e):N()},children:(0,W.jsxs)(se,{className:`sm:max-w-2xl`,children:[(0,W.jsxs)(re,{children:[(0,W.jsxs)(De,{className:`flex items-center gap-2`,children:[(0,W.jsx)(P,{className:`h-5 w-5`}),` Import `,E]}),(0,W.jsxs)(w,{children:[d===`upload`&&`Upload a CSV file to get started.`,d===`mapping`&&`Map CSV columns to object fields.`,d===`preview`&&`Review data before importing.`]})]}),(0,W.jsx)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[`upload`,`mapping`,`preview`].map((e,t)=>(0,W.jsxs)(B.Fragment,{children:[t>0&&(0,W.jsx)(fe,{className:`h-3 w-3`}),(0,W.jsxs)(`span`,{className:x(`rounded-full px-3 py-1`,d===e?`bg-primary text-primary-foreground`:`bg-muted`),children:[t+1,`. `,e===`upload`?`Upload`:e===`mapping`?`Mapping`:`Preview`]})]},e))}),C?(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-4`,children:[(0,W.jsx)(Pe,{className:`h-10 w-10 text-green-500`}),(0,W.jsx)(`p`,{className:`text-lg font-semibold`,children:`Import Complete`}),(0,W.jsxs)(`div`,{className:`flex gap-3`,children:[(0,W.jsxs)(ge,{variant:`default`,children:[C.importedRows,` imported`]}),C.skippedRows>0&&(0,W.jsxs)(ge,{variant:`destructive`,children:[C.skippedRows,` skipped`]})]}),C.errors.length>0&&(0,W.jsxs)(`div`,{className:`max-h-32 w-full overflow-auto rounded border p-2 text-xs`,children:[C.errors.slice(0,10).map((e,t)=>(0,W.jsxs)(`p`,{className:`text-destructive`,children:[`Row `,e.row,e.field?` (${e.field})`:``,`: `,e.message]},t)),C.errors.length>10&&(0,W.jsxs)(`p`,{className:`text-muted-foreground`,children:[`…and `,C.errors.length-10,` more errors`]})]})]}):(0,W.jsxs)(W.Fragment,{children:[d===`upload`&&(0,W.jsx)(jt,{onFileLoaded:M}),d===`mapping`&&(0,W.jsx)(Nt,{headers:p,fields:n,mapping:_,onMappingChange:v,templates:k,selectedTemplateId:j,onSelectTemplate:le,onSaveTemplate:ue,onDeleteTemplate:de}),d===`preview`&&(0,W.jsx)(Pt,{headers:p,rows:h,mapping:_,fields:n,corrections:oe,onCorrect:pe}),b&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(Ce,{value:ie,className:`h-2`}),(0,W.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[`Importing… `,ie,`%`]})]})]}),(0,W.jsx)(te,{className:`gap-2 sm:gap-0`,children:C?(0,W.jsx)(L,{onClick:N,children:`Close`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(L,{variant:`ghost`,onClick:N,disabled:b,children:[(0,W.jsx)(ee,{className:`mr-1 h-4 w-4`}),` Cancel`]}),(d===`mapping`||d===`preview`)&&(0,W.jsxs)(L,{variant:`outline`,onClick:()=>f(d===`mapping`?`upload`:`mapping`),disabled:b,children:[(0,W.jsx)(Ae,{className:`mr-1 h-4 w-4`}),` Back`]}),d===`mapping`&&(0,W.jsxs)(L,{onClick:()=>f(`preview`),disabled:Object.keys(_).length===0||me.length>0,children:[`Next `,(0,W.jsx)(fe,{className:`ml-1 h-4 w-4`})]}),d===`preview`&&(0,W.jsx)(L,{onClick:he,disabled:b,children:b?`Importing…`:`Import ${h.length} Rows`})]})})]})})},It=({schema:e,...t})=>{let{dataSource:n}=c()||{};return(0,W.jsx)(it,{schema:e,dataSource:n,...t})};a.register(`object-grid`,It,{namespace:`plugin-grid`,label:`Object Grid`,category:`plugin`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filters`,type:`array`,label:`Filters`}]}),a.register(`grid`,It,{namespace:`view`,label:`Data Grid`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filters`,type:`array`,label:`Filters`}]}),a.register(`import-wizard`,({schema:e,...t})=>{let{dataSource:n}=c()||{};return(0,W.jsx)(Ft,{objectName:e.objectName,objectLabel:e.objectLabel,fields:e.fields??[],dataSource:n,...t})},{namespace:`plugin-grid`,label:`Import Wizard`,category:`plugin`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`,required:!0}]});export{ze as i,it as n,K as r,bt as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as n,m as r,t as i}from"./vendor-react-B1k2FF9f.js";import{H as a,L as o,M as s,R as c,h as l,j as u,m as d,w as f}from"./framework-CoXA0nY6.js";import{$n as p,Br as m,Ht as h,Qn as g,XA as _,Y as v,er as y,fj as b,ir as x,lm as S,nj as C,nn as w,nr as T,nt as E,sT as D,to as O,tr as k,un as A,vr as j}from"./ui-components-BCmPcwhR.js";import{a as M,c as N,d as ee,g as P,h as te,m as F,n as I,o as L,p as R,s as z,t as B,u as ne}from"./vendor-dndkit-BGB4qgc3.js";import{t as re}from"./plugin-grid-DwpWK0E8.js";var ie=e({KanbanEnhanced:()=>G,default:()=>G}),V=t(n(),1),H=i(),U=(...e)=>e.filter(Boolean).join(` `);function ae(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function W({card:e,conditionalFormatting:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=M({id:e.id}),c={transform:P.Transform.toString(a),transition:o,opacity:s?.5:void 0},l=ae(e,t);return(0,H.jsx)(`div`,{ref:i,style:c,...n,...r,children:(0,H.jsxs)(g,{className:`mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group`,style:l,children:[e.coverImage&&(0,H.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,H.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,H.jsxs)(k,{className:`p-4`,children:[(0,H.jsx)(T,{className:`text-sm font-medium tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,H.jsx)(y,{className:`text-xs text-muted-foreground`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,H.jsx)(p,{className:`p-4 pt-0`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,H.jsx)(x,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function oe({cards:e,parentRef:t,conditionalFormatting:n}){let r=re({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>120,overscan:5});return(0,H.jsx)(`div`,{style:{height:`${r.getTotalSize()}px`,width:`100%`,position:`relative`},children:r.getVirtualItems().map(t=>{let r=e[t.index];return(0,H.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${t.start}px)`},children:(0,H.jsx)(W,{card:r,conditionalFormatting:n})},r.id)})})}function se({columnId:e,onAdd:t}){let[n,r]=V.useState(!1),[i,a]=V.useState(``),o=V.useRef(null),s=()=>{let n=i.trim();n&&(t(e,n),a(``)),r(!1)};return n?(0,H.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,H.jsx)(A,{ref:o,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(a(``),r(!1))},onBlur:s,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,H.jsxs)(j,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>o.current?.focus(),0)},children:[(0,H.jsx)(S,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function ce({column:e,cards:t,onToggle:n,enableVirtual:r,quickAdd:i,onQuickAdd:a,conditionalFormatting:o}){let s=t||[],c=V.useRef(null),{setNodeRef:l}=M({id:e.id,data:{type:`column`}}),u=e.limit&&s.length>=e.limit,d=e.limit&&s.length>=e.limit*.8;return(0,H.jsxs)(`div`,{ref:l,className:U(`flex flex-col flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl transition-all`,e.collapsed?`w-16`:`w-80`,e.className),children:[(0,H.jsxs)(`div`,{className:`p-4 border-b border-border/50 bg-muted/20 flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,H.jsx)(j,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>n(!e.collapsed),children:e.collapsed?(0,H.jsx)(_,{className:`h-4 w-4`}):(0,H.jsx)(C,{className:`h-4 w-4`})}),!e.collapsed&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h3`,{className:` text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:U(` text-xs`,u?`text-destructive`:d?`text-yellow-500`:`text-muted-foreground`),children:[s.length,e.limit&&` / ${e.limit}`]}),u&&(0,H.jsx)(x,{variant:`destructive`,className:`text-xs`,children:`Full`}),d&&!u&&(0,H.jsx)(O,{className:`h-3 w-3 text-yellow-500`})]})]})]}),e.collapsed&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,H.jsx)(`span`,{className:` text-xs font-bold text-primary/90 [writing-mode:vertical-rl] rotate-180`,children:e.title}),(0,H.jsx)(x,{variant:`secondary`,className:`text-xs`,children:s.length})]})]}),!e.collapsed&&(0,H.jsxs)(`div`,{ref:c,className:`flex-1 p-4 overflow-y-auto`,style:{maxHeight:`600px`},children:[(0,H.jsx)(B,{items:s.map(e=>e.id),strategy:L,children:r?(0,H.jsx)(oe,{cards:s,parentRef:c,conditionalFormatting:o}):(0,H.jsx)(`div`,{className:`space-y-2`,children:s.map(e=>(0,H.jsx)(W,{card:e,conditionalFormatting:o},e.id))})}),i&&a&&(0,H.jsx)(se,{columnId:e.id,onAdd:a})]})]})}function G({columns:e,onCardMove:t,onColumnToggle:n,enableVirtualScrolling:r=!1,virtualScrollThreshold:i=50,className:a,quickAdd:o,onQuickAdd:s,conditionalFormatting:c}){let[l,u]=V.useState(null),d=V.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[f,p]=V.useState(d);V.useEffect(()=>{p(d)},[d]);let m=te(F(ne,{activationConstraint:{distance:8}})),h=e=>{let{active:t}=e;u(_(t.id))},g=e=>{let{active:n,over:r}=e;if(u(null),!r)return;let i=n.id,a=r.id;if(i===a)return;let o=v(i),s=v(a)||y(a);if(!(!o||!s))if(o.id===s.id){let e=[...o.cards],t=I(e,e.findIndex(e=>e.id===i),e.findIndex(e=>e.id===a));p(e=>e.map(e=>e.id===o.id?{...e,cards:t}:e))}else{let e=[...o.cards],n=[...s.cards],r=e.findIndex(e=>e.id===i),c=a===s.id?n.length:n.findIndex(e=>e.id===a),[l]=e.splice(r,1);n.splice(c,0,l),p(t=>t.map(t=>t.id===o.id?{...t,cards:e}:t.id===s.id?{...t,cards:n}:t)),t&&t(i,o.id,s.id,c)}},_=V.useCallback(e=>{for(let t of f){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[f]),v=V.useCallback(e=>f.find(t=>t.cards.some(t=>t.id===e))||null,[f]),y=V.useCallback(e=>f.find(t=>t.id===e)||null,[f]),b=V.useCallback((e,t)=>{p(n=>n.map(n=>n.id===e?{...n,collapsed:t}:n)),n?.(e,t)},[n]);return(0,H.jsxs)(z,{sensors:m,collisionDetection:R,onDragStart:h,onDragEnd:g,children:[(0,H.jsx)(`div`,{className:U(`flex gap-4 overflow-x-auto p-4`,a),children:f.map(e=>{let t=r&&e.cards.length>i;return(0,H.jsx)(ce,{column:e,cards:e.cards,onToggle:t=>b(e.id,t),enableVirtual:t,quickAdd:o,onQuickAdd:s,conditionalFormatting:c},e.id)})}),(0,H.jsx)(N,{children:l?(0,H.jsx)(W,{card:l,conditionalFormatting:c}):null})]})}var K=e({default:()=>pe}),q=(...e)=>e.filter(Boolean).join(` `),J=`Uncategorized`;function le(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function Y({card:e,onCardClick:t,conditionalFormatting:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=M({id:e.id}),l={transform:P.Transform.toString(o),transition:s,opacity:c?.5:void 0},u=le(e,n);return(0,H.jsx)(`div`,{ref:a,style:l,...r,...i,role:`listitem`,"aria-label":e.title,onClick:()=>t?.(e),children:(0,H.jsxs)(g,{className:`mb-2 cursor-grab active:cursor-grabbing border-border border-l-4 border-l-primary/40 bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group touch-manipulation`,style:u,children:[e.coverImage&&(0,H.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,H.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,H.jsxs)(k,{className:`p-2 sm:p-4`,children:[(0,H.jsx)(T,{className:`text-xs sm:text-sm font-medium tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,H.jsx)(y,{className:`text-xs text-muted-foreground line-clamp-2 sm:line-clamp-none`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,H.jsx)(p,{className:`p-2 sm:p-4 pt-0`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,H.jsx)(x,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function ue({columnId:e,onAdd:t}){let[n,r]=V.useState(!1),[i,a]=V.useState(``),o=V.useRef(null),s=()=>{let n=i.trim();n&&(t(e,n),a(``)),r(!1)};return n?(0,H.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,H.jsx)(A,{ref:o,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(a(``),r(!1))},onBlur:s,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,H.jsxs)(j,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>o.current?.focus(),0)},children:[(0,H.jsx)(S,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function de({column:e,cards:t,onCardClick:n,quickAdd:r,onQuickAdd:i,conditionalFormatting:a,columnStyle:o}){let s=t||[],{setNodeRef:c}=M({id:e.id,data:{type:`column`}}),l=e.limit&&s.length>=e.limit,u=o&&o.width!=null?`flex-shrink-0`:`w-[85vw] sm:w-80 flex-shrink-0`;return(0,H.jsxs)(`div`,{ref:c,role:`group`,"aria-label":e.title,style:o,className:q(`flex flex-col rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl snap-start max-h-full min-h-0`,u,e.className),children:[(0,H.jsx)(`div`,{className:`p-3 sm:p-4 border-b border-border/50 bg-muted/30 rounded-t-lg`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`h3`,{id:`kanban-col-${e.id}`,className:` text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(x,{variant:`secondary`,className:`text-xs tabular-nums`,children:[s.length,e.limit&&` / ${e.limit}`]}),l&&(0,H.jsx)(x,{variant:`destructive`,className:`text-xs`,children:`Full`})]})]})}),(0,H.jsxs)(w,{className:`flex-1 p-4`,children:[(0,H.jsx)(B,{items:s.map(e=>e.id),strategy:L,children:(0,H.jsxs)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${e.title} cards`,children:[s.length===0&&(0,H.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground/50`,children:(0,H.jsx)(`span`,{className:`text-xs`,children:`No cards`})}),s.map(e=>(0,H.jsx)(Y,{card:e,onCardClick:n,conditionalFormatting:a},e.id))]})}),r&&i&&(0,H.jsx)(ue,{columnId:e.id,onAdd:i})]})]})}function fe({children:e}){return(0,H.jsx)(H.Fragment,{children:e(d())})}function pe({columns:e,onCardMove:t,onCardClick:n,className:r,quickAdd:i,onQuickAdd:a,coverImageField:o,conditionalFormatting:s,swimlaneField:c}){return l()?(0,H.jsx)(fe,{children:l=>(0,H.jsx)(X,{columns:e,onCardMove:t,onCardClick:n,className:r,dnd:l,quickAdd:i,onQuickAdd:a,coverImageField:o,conditionalFormatting:s,swimlaneField:c})}):(0,H.jsx)(X,{columns:e,onCardMove:t,onCardClick:n,className:r,dnd:null,quickAdd:i,onQuickAdd:a,coverImageField:o,conditionalFormatting:s,swimlaneField:c})}function X({columns:e,onCardMove:t,onCardClick:n,className:r,dnd:i,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l}){let[u,d]=V.useState(null),f=V.useRef(null),{width:p}=v(f),m=V.useMemo(()=>p?p<480?{width:Math.max(p-32,220)}:p<720?{width:280}:{width:320}:{},[p]),h=l?`objectui:kanban-collapsed:${l}`:null,[g,_]=V.useState(()=>{if(!h)return new Set;try{let e=localStorage.getItem(h);if(e){let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}}catch{}return new Set}),y=V.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[b,x]=V.useState(y);V.useEffect(()=>{x(y)},[y]);let S=V.useMemo(()=>{if(!l)return null;let e=b.flatMap(e=>e.cards),t=new Set;return e.forEach(e=>{let n=e[l];t.add(n==null?J:String(n))}),Array.from(t).sort()},[b,l]),C=V.useCallback(e=>{_(t=>{let n=new Set(t);if(n.has(e)?n.delete(e):n.add(e),h)try{localStorage.setItem(h,JSON.stringify([...n]))}catch{}return n})},[h]),w=te(F(ne,{activationConstraint:{distance:5}}),F(ee,{activationConstraint:{delay:200,tolerance:5}})),T=e=>{let{active:t}=e,n=D(t.id);if(d(n),i&&n){let e=O(n.id);e&&i.startDrag({id:n.id,type:`kanban-card`,data:n,sourceId:e.id})}},E=e=>{let{active:n,over:r}=e;if(d(null),!r){i&&i.endDrag();return}let a=n.id,o=r.id;if(a===o){i&&i.endDrag();return}let s=O(a),c=O(o)||k(o);if(!s||!c){i&&i.endDrag();return}if(s.id===c.id){let e=[...s.cards],t=I(e,e.findIndex(e=>e.id===a),e.findIndex(e=>e.id===o));x(e=>e.map(e=>e.id===s.id?{...e,cards:t}:e))}else{let e=[...s.cards],n=[...c.cards],r=e.findIndex(e=>e.id===a),i=o===c.id?n.length:n.findIndex(e=>e.id===o),[l]=e.splice(r,1);n.splice(i,0,l),x(t=>t.map(t=>t.id===s.id?{...t,cards:e}:t.id===c.id?{...t,cards:n}:t)),t&&t(a,s.id,c.id,i)}i&&i.endDrag(c.id)},D=V.useCallback(e=>{for(let t of b){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[b]),O=V.useCallback(e=>b.find(t=>t.cards.some(t=>t.id===e))||null,[b]),k=V.useCallback(e=>b.find(t=>t.id===e)||null,[b]);return(0,H.jsxs)(z,{sensors:w,collisionDetection:R,onDragStart:T,onDragEnd:E,children:[(0,H.jsxs)(`div`,{ref:f,className:`flex flex-col min-w-0 min-h-0 h-full`,children:[(0,H.jsxs)(`div`,{className:`flex sm:hidden items-center justify-between px-3 pb-2 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{children:[b.length,` columns`]}),(0,H.jsx)(`span`,{children:`← Swipe to navigate →`})]}),S?(0,H.jsxs)(`div`,{className:q(`flex flex-col gap-1 p-2 sm:p-4 min-w-0 overflow-hidden`,r),role:`region`,"aria-label":`Kanban board with swimlanes`,children:[(0,H.jsx)(`div`,{className:`flex gap-3 sm:gap-4 pl-36 sm:pl-44 overflow-x-auto`,children:b.map(e=>(0,H.jsxs)(`div`,{className:`w-[85vw] sm:w-80 flex-shrink-0 text-center`,children:[(0,H.jsx)(`span`,{className:` text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase`,children:e.title}),(0,H.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,e.cards.length,`)`]})]},e.id))}),S.map(e=>{let t=g.has(e),r=b.reduce((t,n)=>t+n.cards.filter(t=>(t[l]==null?J:String(t[l]))===e).length,0);return(0,H.jsxs)(`div`,{className:`border rounded-lg bg-muted/10`,children:[(0,H.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/30 transition-colors`,onClick:()=>C(e),"aria-expanded":!t,children:[(0,H.jsx)(`span`,{className:q(`transition-transform text-xs`,t?``:`rotate-90`),children:`▶`}),(0,H.jsx)(`span`,{className:` text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e}),(0,H.jsxs)(`span`,{className:` text-xs text-muted-foreground`,children:[`(`,r,`)`]})]}),!t&&(0,H.jsx)(`div`,{className:`flex gap-3 sm:gap-4 overflow-x-auto px-2 pb-3 pl-36 sm:pl-44`,children:b.map(t=>{let r=t.cards.filter(t=>(t[l]==null?J:String(t[l]))===e);return(0,H.jsx)(`div`,{className:`w-[85vw] sm:w-80 flex-shrink-0 min-h-[60px] rounded-md bg-card/20 p-2`,children:(0,H.jsx)(B,{items:r.map(e=>e.id),strategy:L,children:(0,H.jsx)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${t.title} - ${e} cards`,children:r.map(e=>(0,H.jsx)(Y,{card:e,onCardClick:n,conditionalFormatting:c},e.id))})})},t.id)})})]},e)})]}):(0,H.jsx)(`div`,{className:q(`flex gap-3 sm:gap-4 overflow-x-auto snap-x snap-mandatory p-2 sm:p-4 bg-muted/10 rounded-lg [-webkit-overflow-scrolling:touch] min-w-0 min-h-0 h-full`,r),role:`region`,"aria-label":`Kanban board`,children:b.map(e=>(0,H.jsx)(de,{column:e,cards:e.cards,onCardClick:n,quickAdd:a,onQuickAdd:o,conditionalFormatting:c,columnStyle:m},e.id))})]}),(0,H.jsx)(N,{children:(0,H.jsx)(`div`,{"aria-live":`assertive`,"aria-label":u?`Dragging ${u.title}`:void 0,children:u?(0,H.jsx)(Y,{card:u,conditionalFormatting:c}):null})})]})}var Z=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:a,onCardClick:s,...l})=>{let d=Array.isArray(r),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(d?i??!1:!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(0),C=u(e.bind);(0,V.useEffect)(()=>{if(!d&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&S(e=>e+1)})},[t,e.objectName,d]),(0,V.useEffect)(()=>{d&&i!==void 0&&v(i)},[i,d]),(0,V.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&g(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,V.useEffect)(()=>{if(d)return;let n=!0;return e.objectName&&!C&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&v(!0);try{let r=o(h?.fields),i=c(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&m(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&b(e)}finally{n&&v(!1)}}})(),()=>{n=!1}},[e.objectName,t,C,e.data,e.filter,d,h,x]);let w=(d?r:void 0)||C||e.data||p,T=(0,V.useMemo)(()=>{if(!Array.isArray(w))return[];let t=e.cardTitle||e.titleField,n=[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`],r=h?.titleFormat,i=h?.NAME_FIELD_KEY,a=(e,t)=>{let n=!1,r=e.replace(/\{(.+?)\}/g,(e,r)=>{let i=t[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):``}).replace(/\s+-\s+(?=$|\s*$)/,``).trim();return n?r:``};return w.map(e=>{let o;if(t&&(o=e[t],typeof o==`string`&&(o=o.trim())),!o&&r){let t=a(r,e);t&&(o=t)}if(!o&&i){let t=e[i];typeof t==`string`?o=t.trim():t&&(o=t)}if(!o)for(let t of n){let n=e[t],r=typeof n==`string`?n.trim():n;if(r){o=r;break}}let s=e=>e>=1e6?`$${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e}`,c=[],l=[`amount`,`value`,`deal_value`,`expected_value`,`opportunity_value`].find(t=>typeof e[t]==`number`);l&&c.push(s(e[l]));let u=[`company`,`company_name`,`account`,`account_name`,`organization`].find(t=>typeof e[t]==`string`&&e[t]);u&&(!o||!String(o).includes(e[u]))&&c.push(e[u]);let d=[`owner`,`owner_name`,`assignee`,`assignee_name`].find(t=>typeof e[t]==`string`&&e[t]);d&&c.push(`@${e[d]}`);let f=[`priority`,`severity`,`industry`,`rating`],p=[];for(let t of f){let n=e[t];if(n!=null&&n!==``&&(p.push({label:String(n),variant:`secondary`}),p.length>=2))break}return{...e,id:e.id||e._id,title:o||`Untitled`,...e.description==null&&c.length>0?{description:c.join(` · `)}:{},...!Array.isArray(e.badges)&&p.length>0?{badges:p}:{}}})},[w,e,h]),D=(0,V.useMemo)(()=>{if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns;if(e.groupBy&&h?.fields?.[e.groupBy]?.options)return h.fields[e.groupBy].options.map(e=>({id:e.value,title:e.label}));if(e.groupBy&&T.length>0){let t=new Set(T.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,T,h]),O=e.swimlaneField||e.grouping?.fields?.[0]?.field,k={...e,data:T,columns:D,className:n||e.className,...O?{swimlaneField:O}:{}},A=f({navigation:e.navigation,objectName:e.objectName,onRowClick:a??s});if(y)return(0,H.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,y.message]});let j=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Q,{schema:{...k,onCardClick:e=>{A.handleClick(e),s?.(e)}}}),A.isOverlay&&(0,H.jsx)(E,{...A,title:j,children:e=>(0,H.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,H.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},me=(...e)=>e.filter(Boolean).join(` `),he=({columnId:e,fields:t,onSubmit:n,onCancel:r,defaultValues:i})=>{let[a,o]=V.useState(()=>{let e={};for(let n of t)e[n.name]=i?.[n.name]??n.defaultValue??``;return e}),s=V.useRef(null);V.useEffect(()=>{let e=setTimeout(()=>s.current?.focus(),0);return()=>clearTimeout(e)},[]);let c=V.useCallback((e,t)=>{o(n=>({...n,[e]:t}))},[]),l=V.useCallback(()=>{Object.values(a).some(e=>typeof e==`string`?e.trim().length>0:e!=null)&&n(e,a)},[e,a,n]);return(0,H.jsxs)(`div`,{className:`mt-2 rounded-lg border border-primary/30 bg-card p-3 space-y-2 shadow-sm`,onKeyDown:V.useCallback(e=>{e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(e.preventDefault(),r())},[l,r]),role:`form`,"aria-label":`Quick add card`,children:[t.map((t,n)=>(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`label`,{htmlFor:`qa-${e}-${t.name}`,className:`text-xs text-muted-foreground`,children:t.label??t.name}),ge(t,a[t.name],c,n===0?s:void 0,`qa-${e}-${t.name}`)]},t.name)),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,H.jsxs)(j,{type:`button`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:l,children:[(0,H.jsx)(b,{className:`h-3 w-3`}),`Save`]}),(0,H.jsxs)(j,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:r,children:[(0,H.jsx)(m,{className:`h-3 w-3`}),`Cancel`]})]})]})};function ge(e,t,n,r,i){let a=`text-sm h-8`;switch(e.type){case`select`:return(0,H.jsxs)(`select`,{ref:r,id:i,value:t??``,onChange:t=>n(e.name,t.target.value),className:me(a,`w-full rounded-md border border-input bg-background px-2 py-1 text-sm ring-offset-background`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,H.jsx)(`option`,{value:``,children:e.placeholder??`Select ${e.label??e.name}...`}),(e.options??[]).map(e=>(0,H.jsx)(`option`,{value:e.value,children:e.label},e.value))]});case`number`:return(0,H.jsx)(A,{ref:r,id:i,type:`number`,value:t??``,onChange:t=>n(e.name,t.target.value===``?``:Number(t.target.value)),placeholder:e.placeholder??`Enter ${e.label??e.name}...`,className:a});default:return(0,H.jsx)(A,{ref:r,id:i,type:`text`,value:t??``,onChange:t=>n(e.name,t.target.value),placeholder:e.placeholder??`Enter ${e.label??e.name}...`,className:a})}}var _e=(...e)=>e.filter(Boolean).join(` `),ve=({templates:e,onSelect:t,columnId:n})=>{let[r,i]=V.useState(!1),a=V.useRef(null);return V.useEffect(()=>{if(!r)return;let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),(0,H.jsxs)(`div`,{ref:a,className:`relative`,onKeyDown:V.useCallback(e=>{e.key===`Escape`&&i(!1)},[]),children:[(0,H.jsxs)(j,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground gap-1`,onClick:()=>i(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":r,"aria-label":`Add card to ${n}`,children:[(0,H.jsx)(S,{className:`h-4 w-4`}),`Add Card`,(0,H.jsx)(C,{className:_e(`h-3 w-3 transition-transform`,r?`rotate-180`:``)})]}),r&&(0,H.jsxs)(`div`,{className:`absolute z-50 mt-1 w-full rounded-md border border-border bg-popover p-1 shadow-md`,role:`listbox`,"aria-label":`Card templates`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors`,role:`option`,"aria-selected":!1,onClick:()=>{t(null),i(!1)},children:[(0,H.jsx)(S,{className:`h-4 w-4 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`Custom`})]}),e.length>0&&(0,H.jsx)(`div`,{className:`my-1 h-px bg-border`,role:`separator`}),e.map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors`,role:`option`,"aria-selected":!1,onClick:()=>{t(e),i(!1)},children:[(0,H.jsx)(D,{className:`h-4 w-4 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`font-mono text-xs truncate`,children:e.name})]},e.id))]})]})},ye=`objectui:kanban-column-widths`;function be(e){try{let t=localStorage.getItem(e);if(t){let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}}catch{}return{}}function xe(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function Se({columns:e,defaultWidth:t=320,minWidth:n=200,maxWidth:r=600,storageKey:i}){let a=i?`${ye}:${i}`:ye,[o,s]=(0,V.useState)(()=>be(a)),c=(0,V.useCallback)(e=>Math.max(n,Math.min(r,e)),[n,r]);return{getColumnWidth:(0,V.useCallback)(e=>{let n=o[e];return n==null?t:c(n)},[o,t,c]),setColumnWidth:(0,V.useCallback)((e,t)=>{let n=c(t);s(t=>{let r={...t,[e]:n};return xe(a,r),r})},[c,a]),resetWidths:(0,V.useCallback)(()=>{s({});try{localStorage.removeItem(a)}catch{}},[a]),config:(0,V.useMemo)(()=>({defaultWidth:t,minWidth:n,maxWidth:r,overrides:{...o}}),[t,n,r,o])}}function Ce({swimlanes:e,onCardMove:t}){let[n,r]=(0,V.useState)(null),i=(0,V.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.id,n);return t},[e]),a=(0,V.useCallback)((e,t)=>{if(e===t)return!0;let n=i.get(t);return n?n.acceptFrom?n.acceptFrom.includes(e):!0:!1},[i]),o=(0,V.useCallback)((e,n,i,o)=>a(n,i)?(t?.({cardId:e,fromSwimlane:n,toSwimlane:i,columnId:o}),r(null),!0):!1,[a,t]),s=(0,V.useCallback)(e=>{r(e)},[]),c=(0,V.useCallback)(()=>{r(null)},[]);return{handleCrossSwimlaneMove:o,isDraggingAcrossSwimlanes:n!==null,startCrossSwimlaneDrag:s,endCrossSwimlaneDrag:c,canMoveTo:a}}function we({cards:e,onReorderComplete:t}){let[n,r]=(0,V.useState)(e),[i,a]=(0,V.useState)(!1);!Te(n,e)&&!i&&r(e);let o=(0,V.useCallback)(()=>{r(e),a(!1)},[e]);return{reorderedCards:n,onReorder:(0,V.useCallback)((e,t)=>{r(n=>{if(e<0||t<0||e>=n.length||t>=n.length)return n;let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})},[]),isDragging:i,startDrag:(0,V.useCallback)(()=>{a(!0)},[]),endDrag:(0,V.useCallback)(()=>{a(!1),r(e=>(t?.(e),e))},[t]),reset:o}}function Te(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].id!==t[n].id)return!1;return!0}var Ee=e({CardTemplates:()=>ve,InlineQuickAdd:()=>he,KanbanRenderer:()=>Q,ObjectKanban:()=>Z,ObjectKanbanRenderer:()=>$,kanbanComponents:()=>ke,useColumnWidths:()=>Se,useCrossSwimlaneMove:()=>Ce,useQuickAddReorder:()=>we}),De=V.lazy(()=>r(()=>Promise.resolve().then(()=>K),void 0)),Oe=V.lazy(()=>r(()=>Promise.resolve().then(()=>ie),void 0)),Q=({schema:e})=>{let t=V.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(h,{className:`w-full h-[600px]`}),children:(0,H.jsx)(De,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};a.register(`kanban-ui`,Q,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}});var ke={kanban:Q,"kanban-enhanced":Oe,"object-kanban":Z};a.register(`kanban-enhanced`,({schema:e})=>{let t=V.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(h,{className:`w-full h-[600px]`}),children:(0,H.jsx)(Oe,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var $=({schema:e,...t})=>{let{dataSource:n}=s()||{};return(0,H.jsx)(Z,{schema:e,dataSource:n,...t})};a.register(`object-kanban`,$,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),a.register(`kanban`,$,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});export{K as n,ie as r,Ee as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as n,g as r,m as i,t as a}from"./vendor-react-B1k2FF9f.js";import{H as o,L as s,M as c,R as l,w as u}from"./framework-CoXA0nY6.js";import{_ as d,f,g as p,p as m}from"./vendor-zod-Dfb8LXKF.js";import{NL as h,Ut as g,nt as ee}from"./ui-components-BCmPcwhR.js";var _=t(n(),1),v=_.createContext(null);function y(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 b(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(!b(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)||!b(e[r],t[r]))return!1;return!0}return!1}function x(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function S(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&&!b(n.padding,e.padding)&&(r.padding=n.padding),r}var C=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function w(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 C)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var T={version:8,sources:{},layers:[]},E={minZoom:0,maxZoom:22,minPitch:0,maxPitch:85,maxBounds:[-180,-85.051129,180,85.051129],projection:`mercator`,renderWorldCopies:!0},D={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`},O={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`},k={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`},A=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],j=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],M=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[k[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||x(this._map.transform);let t=this.props[O[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=x(e),S(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[D[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=T}=t,r={...t,...t.initialViewState,container:e,style:w(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 D)a.on(e,this._onPointerEvent);for(let e in O)a.on(e,this._onCameraEvent);for(let e in k)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=S(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 A)if((i in e||i in t)&&!b(e[i],t[i])){r=!0;let t=i in e?e[i]:E[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=T,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(w(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style?._loaded&&(e&&!b(e,a.light)&&(a.light=e,i.setLight(e)),t&&!b(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!b(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!b(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 j){let i=e[r]??!0;b(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}};M.savedMaps=[];var N=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function P(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of F(t))!(e in n)&&!N.includes(e)&&(n[e]=t[e].bind(t));return n}function F(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 I=typeof document<`u`?_.useLayoutEffect:_.useEffect;function L(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 R=_.createContext(null);function z(e,n){let r=(0,_.useContext)(v),[a,o]=(0,_.useState)(null),s=(0,_.useRef)(),{current:c}=(0,_.useRef)({mapLib:null,map:null});(0,_.useEffect)(()=>{let n=e.mapLib,a=!0,l;return Promise.resolve(n||i(()=>import(`./maplibre-gl-ChgVR8ni.js`).then(e=>t(e.default,1)),[])).then(t=>{if(!a)return;if(!t)throw Error(`Invalid mapLib`);let n=`Map`in t?t:t.default;if(!n.Map)throw Error(`Invalid mapLib`);L(n,e),e.reuseMaps&&(l=M.reuse(e,s.current)),l||=new M(n.Map,e,s.current),c.map=P(l),c.mapLib=n,o(l),r?.onMapMount(c.map,e.id)}).catch(t=>{let{onError:n}=e;n?n({type:`error`,target:null,originalEvent:null,error:t}):console.error(t)}),()=>{a=!1,l&&(r?.onMapUnmount(e.id),e.reuseMaps?l.recycle():l.destroy())}},[]),I(()=>{a&&a.setProps(e)}),(0,_.useImperativeHandle)(n,()=>c.map,[a]);let l=(0,_.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...e.style}),[e.style]);return _.createElement(`div`,{id:e.id,ref:s,style:l},a&&_.createElement(R.Provider,{value:c},_.createElement(`div`,{"mapboxgl-children":``,style:{height:`100%`}},e.children)))}var te=_.forwardRef(z),B=t(r(),1),V=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function H(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!V.test(e)?n[e]=`${r}px`:n[e]=r}}function U(e,t){if(e===t)return null;let n=W(e),r=W(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 W(e){return new Set(e?e.trim().split(/\s+/):[])}var G=(0,_.memo)((0,_.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,_.useContext)(R),i=(0,_.useRef)({props:e}),a=(0,_.useMemo)(()=>{let t=!1;_.Children.forEach(e.children,e=>{e&&(t=!0)});let n={...e,element:t?document.createElement(`div`):void 0},o=new r.Marker(n);return o.setLngLat([e.longitude,e.latitude]),o.getElement().addEventListener(`click`,e=>{i.current.props.onClick?.({type:`click`,target:o,originalEvent:e})}),o.on(`dragstart`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragStart?.(t)}),o.on(`drag`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDrag?.(t)}),o.on(`dragend`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragEnd?.(t)}),o},[]);(0,_.useEffect)(()=>(a.addTo(n.getMap()),()=>{a.remove()}),[]);let{longitude:o,latitude:s,offset:c,style:l,draggable:u=!1,popup:d=null,rotation:f=0,rotationAlignment:p=`auto`,pitchAlignment:m=`auto`}=e;(0,_.useEffect)(()=>{H(a.getElement(),l)},[l]),(0,_.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!y(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=U(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,B.createPortal)(e.children,a.getElement())})),ne=(0,_.memo)((0,_.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,_.useContext)(R),i=(0,_.useMemo)(()=>document.createElement(`div`),[]),a=(0,_.useRef)({props:e}),o=(0,_.useMemo)(()=>{let t={...e},n=new r.Popup(t);return n.setLngLat([e.longitude,e.latitude]),n.once(`open`,e=>{a.current.props.onOpen?.(e)}),n},[]);if((0,_.useEffect)(()=>{let e=e=>{a.current.props.onClose?.(e)};return o.on(`close`,e),o.setDOMContent(i).addTo(n.getMap()),()=>{o.off(`close`,e),o.isOpen()&&o.remove()}},[]),(0,_.useEffect)(()=>{H(o.getElement(),e.style)},[e.style]),(0,_.useImperativeHandle)(t,()=>o,[]),o.isOpen()){let t=a.current.props;(o.getLngLat().lng!==e.longitude||o.getLngLat().lat!==e.latitude)&&o.setLngLat([e.longitude,e.latitude]),e.offset&&!b(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=U(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,B.createPortal)(e.children,i)}));function K(e,t,n,r){let i=(0,_.useContext)(R),a=(0,_.useMemo)(()=>e(i),[]);return(0,_.useEffect)(()=>{let e=r||n||t,o=typeof t==`function`&&typeof n==`function`?t:null,s=typeof n==`function`?n:typeof t==`function`?t:null,{map:c}=i;return c.hasControl(a)||(c.addControl(a,e?.position),o&&o(i)),()=>{s&&s(i),c.hasControl(a)&&c.removeControl(a)}},[]),a}function q(e){let t=K(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}(0,_.memo)(q);function J(e){let t=K(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,_.useEffect)(()=>{H(t._controlContainer,e.style)},[e.style]),null}(0,_.memo)(J);function Y(e,t){let n=(0,_.useRef)({props:e}),r=K(({mapLib:t})=>{let r=new t.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on(`geolocate`,e=>{n.current.props.onGeolocate?.(e)}),r.on(`error`,e=>{n.current.props.onError?.(e)}),r.on(`outofmaxbounds`,e=>{n.current.props.onOutOfMaxBounds?.(e)}),r.on(`trackuserlocationstart`,e=>{n.current.props.onTrackUserLocationStart?.(e)}),r.on(`trackuserlocationend`,e=>{n.current.props.onTrackUserLocationEnd?.(e)}),r},{position:e.position});return n.current.props=e,(0,_.useImperativeHandle)(t,()=>r,[]),(0,_.useEffect)(()=>{H(r._container,e.style)},[e.style]),null}(0,_.memo)((0,_.forwardRef)(Y));function X(e){let t=K(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}var re=(0,_.memo)(X);function ie(e){let t=K(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,_.useRef)(e),r=n.current;n.current=e;let{style:i}=e;return e.maxWidth!==void 0&&e.maxWidth!==r.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==r.unit&&t.setUnit(e.unit),(0,_.useEffect)(()=>{H(t._container,i)},[i]),null}(0,_.memo)(ie);function ae(e){let t=K(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}(0,_.memo)(ae);function oe(e){let t=K(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}(0,_.memo)(oe);var Z=a(),se=m({latitudeField:p().optional(),longitudeField:p().optional(),locationField:p().optional(),titleField:p().optional(),descriptionField:p().optional(),zoom:f().optional(),center:d([f(),f()]).optional()});function ce(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function le(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function ue(e){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=se.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 de(e,t){if(t.latitudeField&&t.longitudeField){let n=e[t.latitudeField],r=e[t.longitudeField];if(typeof n==`number`&&typeof r==`number`)return[n,r]}if(t.locationField){let n=e[t.locationField];if(typeof n==`object`&&n){let e=n.lat||n.latitude,t=n.lng||n.lon||n.longitude;if(typeof e==`number`&&typeof t==`number`)return[e,t]}if(typeof n==`string`){let e=n.split(`,`).map(e=>parseFloat(e.trim()));if(e.length===2&&!isNaN(e[0])&&!isNaN(e[1]))return[e[0],e[1]]}if(Array.isArray(n)&&n.length===2){let e=parseFloat(n[0]),t=parseFloat(n[1]);if(!isNaN(e)&&!isNaN(t))return[e,t]}}return null}function fe(e,t,n=50){if(e.length<=1||t>=15)return e.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1}));let r=n/2**t,i=new Map;e.forEach(e=>{let t=`${Math.floor(e.coordinates[0]/r)}:${Math.floor(e.coordinates[1]/r)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)});let a=[];return i.forEach((e,t)=>{if(e.length===1)a.push({id:e[0].id,coordinates:e[0].coordinates,markers:e,isCluster:!1});else{let n=e.reduce((e,t)=>e+t.coordinates[0],0)/e.length,r=e.reduce((e,t)=>e+t.coordinates[1],0)/e.length;a.push({id:`cluster-${t}`,coordinates:[n,r],markers:e,isCluster:!0})}}),a}var Q=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:a,onDelete:o,enableClustering:c,clusterRadius:d=50,...f})=>{let[p,m]=(0,_.useState)([]),[v,y]=(0,_.useState)(!0),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(``),O=g(),k=(0,_.useRef)(null),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(null),[P,F]=(0,_.useState)(!1),I=(0,_.useCallback)(()=>{if(typeof navigator>`u`||!navigator.geolocation){N(`Geolocation is not available in this browser.`);return}F(!0),N(null),navigator.geolocation.getCurrentPosition(e=>{let{longitude:t,latitude:n}=e.coords;j({lng:t,lat:n}),F(!1);try{k.current?.flyTo({center:[t,n],zoom:12,duration:800})}catch{}},e=>{F(!1),N(e.message||`Unable to retrieve location.`)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:6e4})},[]),L=ce(e),R=(0,_.useMemo)(()=>L,[JSON.stringify(L)]),z=ue(e),B=R?.provider===`value`;(0,_.useEffect)(()=>{(async()=>{try{if(y(!0),f.data){let e=f.data;if(Array.isArray(e)){m(e),y(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),y(!1);return}}if(B&&R?.provider===`value`){m(R.items),y(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(R?.provider===`object`){let n=R.object,r=s(S?.fields);m(l(await t.find(n,{$filter:e.filter,$orderby:le(e.sort),...r.length>0?{$expand:r}:{}})))}else R?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));y(!1)}catch(e){x(e),y(!1)}})()},[R,t,B,e.filter,e.sort,S]),(0,_.useEffect)(()=>{!B&&t&&(async()=>{try{if(!t)return;let n=R?.provider===`object`?R.object:e.objectName;if(!n)return;C(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,B,R]);let{markers:V,invalidCount:H}=(0,_.useMemo)(()=>{let e=0;return{markers:p.map((t,n)=>{let r=de(t,z);if(!r)return e++,null;let i=z.titleField?t[z.titleField]:`Marker`,a=z.descriptionField?t[z.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,z]),U=(0,_.useMemo)(()=>V.find(e=>e.id===w),[V,w]),[W,K]=(0,_.useState)(z.zoom||3),q=u({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),J=(0,_.useMemo)(()=>{if(!E.trim())return V;let e=E.toLowerCase();return V.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[V,E]),Y=(0,_.useMemo)(()=>c??(e.enableClustering||J.length>100)?fe(J,W,d):J.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[J,W,c,d,e]),X=(0,_.useMemo)(()=>{if(!J.length)return{longitude:z.center?.[1]||0,latitude:z.center?.[0]||0,zoom:z.zoom||2};let e=J.map(e=>e.coordinates[0]),t=J.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:z.zoom||3}},[J,z]);return v?(0,Z.jsx)(`div`,{className:h(`min-w-0 overflow-hidden`,n),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Z.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading map...`})})}):b?(0,Z.jsx)(`div`,{className:h(`min-w-0 overflow-hidden`,n),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Z.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,b.message]})})}):(0,Z.jsxs)(`div`,{className:h(`min-w-0 overflow-hidden`,n),children:[H>0&&(0,Z.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${H} record${H===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),V.length>0&&(0,Z.jsx)(`div`,{className:`mb-2`,children:(0,Z.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(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,Z.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,Z.jsxs)(te,{ref:e=>{k.current=e},initialViewState:X,style:{width:`100%`,height:`100%`},mapStyle:`https://demotiles.maplibre.org/style.json`,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>K(Math.round(e.viewState.zoom)),children:[(0,Z.jsx)(re,{position:`top-right`,showCompass:!0,showZoom:!0}),(0,Z.jsx)(`button`,{type:`button`,onClick:I,disabled:P,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,Z.jsx)(`span`,{"aria-hidden":`true`,children:P?`⏳`:`🧭`})}),A&&(0,Z.jsx)(G,{longitude:A.lng,latitude:A.lat,anchor:`center`,children:(0,Z.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`})}),Y.map(e=>e.isCluster?(0,Z.jsx)(G,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,onClick:t=>{t.originalEvent.stopPropagation();try{let t=Math.min(20,Math.max(W+2,8));k.current?.flyTo({center:[e.coordinates[0],e.coordinates[1]],zoom:t,duration:600})}catch{}},children:(0,Z.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,Z.jsx)(G,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];T(n.id),q.handleClick(n.data),r?.(n.data)},children:(0,Z.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),U&&!O&&(0,Z.jsx)(ne,{longitude:U.coordinates[0],latitude:U.coordinates[1],anchor:`top`,onClose:()=>T(null),closeOnClick:!1,children:(0,Z.jsxs)(`div`,{className:`p-2 min-w-[150px] sm:min-w-[200px]`,children:[(0,Z.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:U.title}),U.description&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:U.description}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs flex gap-2`,children:[a&&(0,Z.jsx)(`button`,{className:`text-blue-500 hover:underline`,onClick:()=>a(U.data),children:`Edit`}),o&&(0,Z.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>o(U.data),children:`Delete`})]})]})})]}),U&&O&&(0,Z.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,Z.jsx)(`div`,{className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:U.title}),U.description&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground line-clamp-3`,children:U.description})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>T(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,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[a&&(0,Z.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border bg-card hover:bg-accent`,onClick:()=>a(U.data),children:`Edit`}),o&&(0,Z.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border border-destructive/30 text-destructive hover:bg-destructive/10`,onClick:()=>o(U.data),children:`Delete`})]})]}),M&&(0,Z.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:M})]}),q.isOverlay&&(0,Z.jsx)(ee,{...q,title:`Location Details`,children:e=>(0,Z.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Z.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},pe=e({ObjectMap:()=>Q,ObjectMapRenderer:()=>$}),$=({schema:e,...t})=>{let{dataSource:n}=c()||{};return(0,Z.jsx)(Q,{schema:e,dataSource:n,...t})};console.log(`Registering object-map...`),o.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`}]}),o.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};
|