chordia-ui 3.5.0 → 3.5.2
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/UpdatedInteractionRecording.cjs.js +1 -1
- package/dist/UpdatedInteractionRecording.cjs.js.map +1 -1
- package/dist/UpdatedInteractionRecording.es.js +165 -162
- package/dist/UpdatedInteractionRecording.es.js.map +1 -1
- package/dist/components/UpdatedInteractionDetails.cjs.js +4 -4
- package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
- package/dist/components/UpdatedInteractionDetails.es.js +1304 -979
- package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
- package/dist/components/data.cjs.js +1 -1
- package/dist/components/data.cjs.js.map +1 -1
- package/dist/components/data.es.js +355 -366
- package/dist/components/data.es.js.map +1 -1
- package/package.json +1 -1
- package/src/components/UpdatedInteractionDetails/UpdatedCompassScore.jsx +8 -24
- package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +9 -43
- package/src/components/UpdatedInteractionDetails/UpdatedInteractionRecording.jsx +13 -1
- package/src/components/UpdatedInteractionDetails/UpdatedThreads.jsx +515 -152
- package/src/components/data/DataTable.jsx +0 -18
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),m=require("../sortable.esm.cjs.js"),v=require("lucide-react"),nt=require("react-dom"),ze=require("../CustomFilterChips.cjs.js");require("../TourGuideTooltip.cjs.js");function Ee({dateRangePicker:p,onWeekToDate:d,exportConfig:b,filterChipsConfig:x,trailingActions:k}){const[I,P]=a.useState(!1),w=a.useRef(null),L=a.useRef(null);a.useEffect(()=>{const f=z=>{L.current&&!L.current.contains(z.target)&&w.current&&!w.current.contains(z.target)&&P(!1)};if(I)return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[I]);const U=()=>{P(f=>!f)},Y=f=>{P(!1),b!=null&&b.onExport&&b.onExport(f)},S=(()=>{if(!(x!=null&&x.filters))return!1;const f=x.filters,z=x.customFilters||[],E=Object.entries(f).some(([h,j])=>!!(Array.isArray(j)&&j.length||typeof j=="string"&&j.trim()!==""||j&&typeof j=="object"&&(j.min!=null||j.max!=null))),q=z.some(h=>h.active);return E||q})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d&&t.jsxs("button",{onClick:d,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900",style:{fontFamily:"var(--font-sans)"},children:[t.jsx(v.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),p&&t.jsx(a.Suspense,{fallback:t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-400",children:[t.jsx(v.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:p}),b&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:w,onClick:U,disabled:b.isExporting,className:"inline-flex items-center justify-between gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px]",style:{fontFamily:"var(--font-sans)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v.Download,{size:16}),t.jsx("span",{children:b.isExporting?"Exporting...":"Export"})]}),t.jsx(v.ChevronDown,{size:16})]}),I&&t.jsx("div",{ref:L,className:"absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[120px]",children:(b.types||["csv"]).map(f=>t.jsxs("button",{onClick:()=>Y(f),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors",style:{fontFamily:"var(--font-sans)"},children:["Export ",f.toUpperCase()]},f))})]}),(S||k)&&t.jsxs(t.Fragment,{children:[S&&t.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[S&&x&&t.jsx(ze.CustomFilterChips,{filters:x.filters,onChange:x.onChange,onClear:x.onClear,customFilters:x.customFilters||[],fieldOptions:x.fieldOptions||{}}),k&&t.jsx("div",{className:"flex-shrink-0",children:k})]})]})]})}function me(){return t.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}const st=()=>({userData:{email:"anonymous"}}),ot=p=>t.jsx("img",{...p});function at({children:p}){return p}function lt({data:p=[],columns:d=[],initialPageSize:b=10,onRowClick:x,totalCount:k=null,page:I=null,pageSize:P=null,onPageChange:w=null,onPageSizeChange:L=null,onFilterChange:U=null,onMaxColumnsError:Y=null,onSort:X=null,sortFields:S=[],tableId:f=null,isLoading:z=!1,filtersConfig:E=null}){var Oe;const{userData:q}=st(),h=(q==null?void 0:q.email)||"anonymous",j=a.memo(({children:e,content:r,className:n=""})=>{const s=a.useRef(null),[l,o]=a.useState(!1);a.useEffect(()=>{const c=()=>{if(s.current){const T=s.current.scrollWidth>s.current.clientWidth;o(T)}};c();const M=setTimeout(c,0);return window.addEventListener("resize",c),()=>{clearTimeout(M),window.removeEventListener("resize",c)}},[e,r]);const i=t.jsx("span",{className:`truncate block ${n}`,ref:s,children:e});return l&&r?t.jsx(at,{content:r,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:i}):i});j.displayName="TruncatedCell";const Q=k!==null&&w!==null,de=U!==null,B=X!==null,[Me,ue]=a.useState(1),[Te,Le]=a.useState(b),fe=I!==null?I:Me,Z=P!==null?P:Te,ee=e=>{w?w(e):ue(e)},he=e=>{L?L(e):Le(e)},D=9,g="action",R=a.useRef(!1),W=a.useMemo(()=>f?`dataTable_columns_${f}:${h}`:`dataTable_columns_${d.map(r=>r.id||r.key).sort().join("_")}:${h}`,[f,d,h]),V=a.useMemo(()=>f?`dataTable_manual_change_${f}:${h}`:null,[f,h]);a.useCallback((e,r)=>{if(typeof window>"u"||!e||!r||r.length===0)return null;try{const n=localStorage.getItem(e);if(n){const l=JSON.parse(n).filter(o=>r.some(i=>(i.id||i.key)===o));if(l.length>0)return l}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}return null},[]);const[$,Re]=a.useState({}),[ye,$e]=a.useState(null),[be,ve]=a.useState("asc");a.useCallback((e,r)=>e==="csat_score"&&r==="evaluation.csat_score"?r:e,[]);const J=B&&S.length>0?S[0][0]:ye,te=B&&S.length>0?S[0][1]:be,[ct,we]=a.useState(()=>d.map(e=>e.id||e.key)),N=a.useCallback(e=>{if(!e||e.length===0)return e;let r=Array.from(new Set(e));r.length>D&&(r=r.slice(0,D));const s=d.map(i=>i.id||i.key).includes(g);return!r.includes(g)&&s&&(r.length>=D?r=[...r.slice(0,D-1),g]:r=[...r,g]),[...r.filter(i=>i!==g),g]},[d]),[u,A]=a.useState(()=>{if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${h}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${f}:${h}`);if(s){const l=JSON.parse(s);if(Array.isArray(l)&&l.length>0){R.current=!0;const o=l.filter(i=>d.some(c=>(c.id||c.key)===i));if(o.length>0)return o.slice(0,D)}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const r=d.map(n=>n.id||n.key).slice(0,D);return N(r)}),[C,je]=a.useState(!1),[xe,Ae]=a.useState({top:0,left:0,width:0}),[_e,Se]=a.useState(new Set),[Ce,ke]=a.useState(new Set),[F,re]=a.useState(null),[Ie,G]=a.useState(null),H=a.useRef(null),pe=a.useRef(null),K=a.useRef(null),[De,ne]=a.useState(null),Pe=a.useRef(null),y=e=>e.id||e.key,Be=m.useSensors(m.useSensor(m.PointerSensor),m.useSensor(m.KeyboardSensor,{coordinateGetter:m.sortableKeyboardCoordinates})),We=e=>{const{active:r,over:n}=e;if(n&&r.id!==n.id){const s=u.indexOf(g),l=u.indexOf(n.id);if(r.id===g||n.id===g){le("Cannot drop columns on the Action column"),ne(null);return}if(s>0&&l===s-1){le("Cannot drop columns next to the Action column"),ne(null);return}R.current=!0,A(o=>{const i=o.indexOf(r.id),c=o.indexOf(n.id);if(i!==-1&&c!==-1){const M=m.arrayMove(o,i,c),T=N(M);return ie(T),T}return o}),we(o=>{const i=o.indexOf(r.id),c=o.indexOf(n.id);return m.arrayMove(o,i,c)})}ne(null)},Ve=e=>{ne(e.active.id)},se=a.useMemo(()=>de?p||[]:!p||p.length===0?[]:p.filter(e=>Object.keys($).every(r=>{const n=$[r];if(!n||n.trim()==="")return!0;const s=e[r];if(s==null)return!1;const l=String(s).toLowerCase();return n.toLowerCase().trim().split(/\s+/).filter(c=>c.length>0).every(c=>l.includes(c))})),[p,$,de]),oe=a.useMemo(()=>B||!J?se:[...se].sort((e,r)=>{const n=e[J],s=r[J];if(n==null)return 1;if(s==null)return-1;if(typeof n=="number"&&typeof s=="number")return te==="asc"?n-s:s-n;const l=String(n).toLowerCase(),o=String(s).toLowerCase();return te==="asc"?l.localeCompare(o):o.localeCompare(l)}),[se,J,te,B]),ae=a.useMemo(()=>{if(Q)return p||[];{const e=(fe-1)*Z,r=e+Z;return oe.slice(e,r)}},[p,oe,fe,Z,Q]),He=e=>{B&&X?(X(e),w?w(1):ue(1)):(ye===e?ve(be==="asc"?"desc":"asc"):($e(e),ve("asc")),ee(1))},Ne=(e,r)=>{const n=r&&r.trim()!==""?{...$,[e]:r}:Object.fromEntries(Object.entries($).filter(([s])=>s!==e));Re(n),de&&U&&U(n),w?w(1):ue(1)},le=e=>{K.current||(typeof Y=="function"&&Y(e),K.current=setTimeout(()=>{K.current=null},3e3))},ie=a.useCallback(e=>{if(typeof window<"u"&&W&&e.length>0&&R.current)try{localStorage.setItem(W,JSON.stringify(e)),V&&localStorage.setItem(V,"true")}catch(r){console.warn("Failed to save columns to localStorage:",r)}},[W,V]),ge=e=>{e!==g&&(R.current=!0,A(r=>r.includes(e)?(K.current&&(clearTimeout(K.current),K.current=null),r.length===1||(ke(n=>new Set(n).add(e)),setTimeout(()=>{A(n=>{const s=n.filter(o=>o!==e),l=N(s);return ie(l),l}),ke(n=>{const s=new Set(n);return s.delete(e),s})},200)),r):r.length>=D?(le("Maximum 9 column selection allowed"),r):(Se(n=>new Set(n).add(e)),setTimeout(()=>{A(n=>{const s=n.includes(e)?n:[...n,e],l=N(s);return ie(l),l}),Se(n=>{const s=new Set(n);return s.delete(e),s})},200),r)))},Ke=(e,r)=>{u[r]!==g&&re(r)},Ue=()=>{re(null),G(null)},qe=(e,r)=>{e.preventDefault(),F!==null&&F!==r&&G(r)},Je=()=>{G(null)},Ge=(e,r)=>{e.preventDefault();const n=u.indexOf(g);if(n>0&&r===n-1){le("Cannot drop columns next to the Action column"),re(null),G(null);return}F!==null&&F!==r&&u[r]!==g&&u[F]!==g&&(R.current=!0,A(s=>{const l=m.arrayMove(s,F,r),o=N(l);return ie(o),o})),re(null),G(null)};a.useEffect(()=>{we(e=>{const r=u.filter(l=>e.includes(l)),n=u.filter(l=>!e.includes(l)),s=e.filter(l=>!u.includes(l));return[...r,...n,...s]})},[u]),a.useEffect(()=>{if(typeof window<"u"&&W&&u.length>0&&R.current)try{const e=N(u);localStorage.setItem(W,JSON.stringify(e)),V&&localStorage.setItem(V,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[u,W,V]),a.useEffect(()=>{if(d.length>0&&u.length===0){if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${h}`)==="true"){const n=localStorage.getItem(`dataTable_columns_${f}:${h}`);if(n){const s=JSON.parse(n);if(Array.isArray(s)&&s.length>0){const l=s.filter(o=>d.some(i=>(i.id||i.key)===o));if(l.length>0){R.current=!0,A(l.slice(0,D));return}}}}}catch(r){console.warn("Failed to load saved columns from localStorage:",r)}const e=d.map(r=>r.id||r.key);A(N(e.slice(0,D)))}},[d,f,h,N]);const _=a.useMemo(()=>{const e=u.map(r=>d.find(n=>y(n)===r)).filter(Boolean);return N(e.map(y)).map(r=>d.find(n=>y(n)===r)).filter(Boolean)},[d,u]),Ye=a.useMemo(()=>_.some(e=>e.filterable===!0),[_]);a.useEffect(()=>{if(!C||!H.current)return;const e=()=>{if(H.current){const r=H.current.getBoundingClientRect();Ae({top:r.bottom,left:r.left,width:Math.max(r.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[C]),a.useEffect(()=>{const e=r=>{C&&H.current&&!H.current.contains(r.target)&&pe.current&&!pe.current.contains(r.target)&&je(!1)};if(C)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[C]);const Xe=u.length===1?((Oe=d.find(e=>(e.id||e.key)===u[0]))==null?void 0:Oe.label)||"1 selected":`${u.length} selected`;function Qe({column:e,isHeaderRow:r=!0}){const n=y(e),s=n===g,{attributes:l,listeners:o,setNodeRef:i,transform:c,transition:M,isDragging:T}=m.useSortable({id:n}),et={transform:m.CSS.Transform.toString(c),transition:M,opacity:T?.5:1,width:e.width||"auto",minWidth:e.width||"auto"};let ce=!1;if(B&&S.length>0){const O=S[0][0];(O===n||O==="csat_score"&&n==="evaluation.csat_score")&&(ce=!0)}else ce=J===n;const tt=te==="asc",rt=e.filterable===!0;return r?t.jsx("th",{ref:i,style:{...et,padding:"12px 14px",textAlign:s?"center":"left",fontWeight:650,fontSize:"11px",letterSpacing:"0.14em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.62)",cursor:e.sortable!==!1?"pointer":"default",width:e.width||"auto",borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:s?"center":"flex-start"},children:[!s&&t.jsx("div",{...l,...o,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:t.jsx(v.GripVertical,{size:12})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&He(n),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&ce&&t.jsx("span",{children:tt?t.jsx(v.ChevronUp,{size:12}):t.jsx(v.ChevronDown,{size:12})})]})}):t.jsx("th",{style:{width:e.width||"auto",minWidth:e.width||"auto",backgroundColor:"var(--primary-foreground)"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:rt?t.jsxs("div",{className:"relative",children:[t.jsx(v.Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),t.jsx("input",{type:"text",placeholder:"Filter...",value:$[n]||"",onChange:O=>{O.stopPropagation(),Ne(n,O.target.value)},onKeyDown:O=>O.stopPropagation(),onMouseDown:O=>O.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded text-[var(--text-ink)] placeholder:text-[var(--text-faint)] focus:outline-none focus:border-[var(--border-hover)] focus:ring-1 focus:ring-[var(--focus)] transition-colors",style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)"},autoComplete:"off"})]}):t.jsx("div",{className:"h-[34px]"})})}const Fe=De?d.find(e=>y(e)===De):null,Ze=C?t.jsxs("div",{ref:pe,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${xe.top}px`,left:`${xe.left}px`,width:xe.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:"0 0 8px 8px",boxShadow:"4px 4px 6px 0px #6D70681A, -4px 0px 6px 0px #6D70681A",border:"1px solid rgba(52, 58, 64, 0.12)",borderTop:"none"},children:[u.map((e,r)=>{const n=d.find(c=>y(c)===e);if(!n)return null;const s=u.indexOf(e),l=F===s,o=Ie===s,i=e===g;return t.jsxs(a.Fragment,{children:[t.jsxs("div",{draggable:!i,onDragStart:i?void 0:c=>Ke(c,s),onDragEnd:i?void 0:Ue,onDragOver:i?void 0:c=>qe(c,s),onDragLeave:i?void 0:Je,onDrop:i?void 0:c=>Ge(c,s),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${i?"cursor-default opacity-100":"cursor-move"} ${!i&&l?"opacity-50":""} ${!i&&o&&F!==null&&F!==s?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!i&&t.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),t.jsx("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),i||ge(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${i?"bg-green-2 border-green-2 cursor-default":Ce.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!Ce.has(e)&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:n.label})]}),r<u.length-1&&t.jsx(me,{})]},`selected-${e}-${r}`)}),d.filter(e=>!u.includes(y(e))).map((e,r)=>{const n=y(e),s=_e.has(n),l=d.filter(o=>!u.includes(y(o))).indexOf(e);return t.jsxs(a.Fragment,{children:[u.length>0&&l===0&&t.jsx(me,{}),t.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 rounded cursor-pointer transition-colors",onClick:o=>{o.preventDefault(),ge(n)},children:[t.jsx("button",{type:"button",onClick:o=>{o.preventDefault(),o.stopPropagation(),ge(n)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${s?"bg-green-2 border-green-2":"bg-white border-gray-300"}`,children:s&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),l<d.filter(o=>!u.includes(y(o))).length-1&&t.jsx(me,{})]},`unselected-${n}`)})]}):null;return t.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:[d.length>0&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("div",{className:"flex-shrink-0",children:[t.jsx("div",{className:"mb-1 ml-1.5",children:t.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),t.jsxs("div",{ref:H,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 cursor-pointer transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>je(!C),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:C?"8px 8px 0 0":"8px"},children:[t.jsx("span",{children:Xe}),C?t.jsx(v.ChevronUp,{size:16}):t.jsx(v.ChevronDown,{size:16})]}),C&&nt.createPortal(Ze,document.body)]}),E&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),t.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:t.jsx(Ee,{dateRangePicker:E.dateRangePicker,onWeekToDate:E.onWeekToDate,exportConfig:E.exportConfig,filterChipsConfig:E.filterChipsConfig,trailingActions:E.trailingActions})})]})]})}),d.length>0&&_.length>0?t.jsxs(m.DndContext,{sensors:Be,collisionDetection:m.closestCenter,onDragStart:Ve,onDragEnd:We,children:[t.jsxs("div",{className:"rounded-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[z&&t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(2px)",zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"14px"},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[t.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),t.jsx(ot,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),t.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:Pe,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[t.jsxs("thead",{children:[t.jsx("tr",{children:t.jsx(m.SortableContext,{items:u,strategy:m.horizontalListSortingStrategy,children:_.map(e=>t.jsx(Qe,{column:e,isHeaderRow:!0},`header-${y(e)}`))})}),Ye&&t.jsx("tr",{children:_.map(e=>{const r=y(e),n=e.filterable===!0;return t.jsx("th",{style:{padding:"8px 14px",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:e.width||"auto",fontFamily:"var(--font-sans)"},children:n?t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",placeholder:"Filter...",value:$[r]||"",onChange:s=>{s.stopPropagation(),Ne(r,s.target.value)},onKeyDown:s=>s.stopPropagation(),onMouseDown:s=>s.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"var(--primary-foreground)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:s=>{s.target.style.borderColor="rgba(231, 212, 162, 0.65)",s.target.style.background="var(--primary-foreground)"},onBlur:s=>{s.target.style.borderColor="rgba(52, 58, 64, 0.16)",s.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),t.jsx(v.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):t.jsx("div",{className:"h-[34px]"})},`filter-${r}`)})})]}),t.jsx("tbody",{children:!z&&ae.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:_.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!z&&ae.length>0?ae.map((e,r)=>t.jsx("tr",{"data-row-id":e.id||r,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:x?"pointer":"default",transition:"background 0.15s ease"},onClick:x?n=>{n.stopPropagation(),x(e,r)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:_.map(n=>{const s=y(n),l=e[s],o=n.render?n.render(l,e):l,i=n.width&&n.width!=="auto",c=typeof o=="string"&&o.trim()!=="",M=i&&c,T=M?t.jsx(j,{content:o,children:o}):o;return t.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid rgba(52, 58, 64, 0.04)",width:n.width||"auto",fontFamily:"var(--font-sans)",...M&&{maxWidth:n.width||"200px",overflow:"hidden"}},children:T},s)})},r)):null})]})})]}),t.jsx(m.DragOverlay,{children:Fe?t.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:Fe.label})]})}):null})]}):null,(Q?k>0:oe.length>0)&&t.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:t.jsx(ze.Pagination,{page:fe,pageSizeOptions:[5,10,20,50,100],pageSize:Z,totalCount:Q?k:oe.length,currentDataLength:ae.length,onPageChange:ee,onPageSizeChange:L?e=>{he(e),ee(1)}:e=>{he(e),ee(1)},showPageSizeSelector:!0})})]})}function it({title:p="Summary stats",stats:d=[],columns:b=2}){return t.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[t.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:p}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gap:"10px"},children:d.map((x,k)=>t.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:x.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[x.accentColor&&t.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:x.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),t.jsx("div",{className:"text-[10px] tracking-[0.14em] uppercase",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650,lineHeight:1.1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x.label}),t.jsx("div",{style:{fontSize:"13px",color:x.valueStyle==="muted"?"rgba(30, 33, 37, 0.56)":"rgba(30, 33, 37, 0.78)",fontWeight:700,lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:x.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:x.value}),x.subtext&&t.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x.subtext})]},k))})]})}exports.DataTable=lt;exports.DataTableFilters=Ee;exports.SummaryStatsPanel=it;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),g=require("../sortable.esm.cjs.js"),v=require("lucide-react"),nt=require("react-dom"),ze=require("../CustomFilterChips.cjs.js");require("../TourGuideTooltip.cjs.js");function Ee({dateRangePicker:x,onWeekToDate:d,exportConfig:b,filterChipsConfig:f,trailingActions:k}){const[_,A]=a.useState(!1),w=a.useRef(null),M=a.useRef(null);a.useEffect(()=>{const u=z=>{M.current&&!M.current.contains(z.target)&&w.current&&!w.current.contains(z.target)&&A(!1)};if(_)return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[_]);const K=()=>{A(u=>!u)},G=u=>{A(!1),b!=null&&b.onExport&&b.onExport(u)},S=(()=>{if(!(f!=null&&f.filters))return!1;const u=f.filters,z=f.customFilters||[],E=Object.entries(u).some(([h,j])=>!!(Array.isArray(j)&&j.length||typeof j=="string"&&j.trim()!==""||j&&typeof j=="object"&&(j.min!=null||j.max!=null))),U=z.some(h=>h.active);return E||U})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d&&t.jsxs("button",{onClick:d,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900",style:{fontFamily:"var(--font-sans)"},children:[t.jsx(v.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),x&&t.jsx(a.Suspense,{fallback:t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-400",children:[t.jsx(v.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:x}),b&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:w,onClick:K,disabled:b.isExporting,className:"inline-flex items-center justify-between gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px]",style:{fontFamily:"var(--font-sans)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v.Download,{size:16}),t.jsx("span",{children:b.isExporting?"Exporting...":"Export"})]}),t.jsx(v.ChevronDown,{size:16})]}),_&&t.jsx("div",{ref:M,className:"absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[120px]",children:(b.types||["csv"]).map(u=>t.jsxs("button",{onClick:()=>G(u),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors",style:{fontFamily:"var(--font-sans)"},children:["Export ",u.toUpperCase()]},u))})]}),(S||k)&&t.jsxs(t.Fragment,{children:[S&&t.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[S&&f&&t.jsx(ze.CustomFilterChips,{filters:f.filters,onChange:f.onChange,onClear:f.onClear,customFilters:f.customFilters||[],fieldOptions:f.fieldOptions||{}}),k&&t.jsx("div",{className:"flex-shrink-0",children:k})]})]})]})}function ge(){return t.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}const st=()=>({userData:{email:"anonymous"}}),ot=x=>t.jsx("img",{...x});function at({children:x}){return x}function lt({data:x=[],columns:d=[],initialPageSize:b=10,onRowClick:f,totalCount:k=null,page:_=null,pageSize:A=null,onPageChange:w=null,onPageSizeChange:M=null,onFilterChange:K=null,onMaxColumnsError:G=null,onSort:Y=null,sortFields:S=[],tableId:u=null,isLoading:z=!1,filtersConfig:E=null}){var Oe;const{userData:U}=st(),h=(U==null?void 0:U.email)||"anonymous",j=a.memo(({children:e,content:r,className:n=""})=>{const s=a.useRef(null),[o,l]=a.useState(!1);a.useEffect(()=>{const c=()=>{if(s.current){const J=s.current.scrollWidth>s.current.clientWidth;l(J)}};c();const H=setTimeout(c,0);return window.addEventListener("resize",c),()=>{clearTimeout(H),window.removeEventListener("resize",c)}},[e,r]);const i=t.jsx("span",{className:`truncate block ${n}`,ref:s,children:e});return o&&r?t.jsx(at,{content:r,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:i}):i});j.displayName="TruncatedCell";const X=k!==null&&w!==null,le=K!==null,I=Y!==null,[Me,ie]=a.useState(1),[Te,Le]=a.useState(b),ce=_!==null?_:Me,Q=A!==null?A:Te,Z=e=>{w?w(e):ie(e)},me=e=>{M?M(e):Le(e)},D=9,m="action",T=a.useRef(!1),P=a.useMemo(()=>u?`dataTable_columns_${u}:${h}`:`dataTable_columns_${d.map(r=>r.id||r.key).sort().join("_")}:${h}`,[u,d,h]),B=a.useMemo(()=>u?`dataTable_manual_change_${u}:${h}`:null,[u,h]);a.useCallback((e,r)=>{if(typeof window>"u"||!e||!r||r.length===0)return null;try{const n=localStorage.getItem(e);if(n){const o=JSON.parse(n).filter(l=>r.some(i=>(i.id||i.key)===l));if(o.length>0)return o}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}return null},[]);const[L,Re]=a.useState({}),[he,$e]=a.useState(null),[ye,be]=a.useState("asc");a.useCallback((e,r)=>e==="csat_score"&&r==="evaluation.csat_score"?r:e,[]);const q=I&&S.length>0?S[0][0]:he,ee=I&&S.length>0?S[0][1]:ye,[ct,ve]=a.useState(()=>d.map(e=>e.id||e.key)),N=a.useCallback(e=>{if(!e||e.length===0)return e;let r=Array.from(new Set(e));r.length>D&&(r=r.slice(0,D));const s=d.map(i=>i.id||i.key).includes(m);return!r.includes(m)&&s&&(r.length>=D?r=[...r.slice(0,D-1),m]:r=[...r,m]),[...r.filter(i=>i!==m),m]},[d]),[p,R]=a.useState(()=>{if(typeof window<"u"&&u)try{if(localStorage.getItem(`dataTable_manual_change_${u}:${h}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${u}:${h}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){T.current=!0;const l=o.filter(i=>d.some(c=>(c.id||c.key)===i));if(l.length>0)return l.slice(0,D)}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const r=d.map(n=>n.id||n.key).slice(0,D);return N(r)}),[C,we]=a.useState(!1),[de,_e]=a.useState({top:0,left:0,width:0}),[Ae,je]=a.useState(new Set),[Se,Ce]=a.useState(new Set),[F,ue]=a.useState(null),[Ie,te]=a.useState(null),W=a.useRef(null),fe=a.useRef(null),V=a.useRef(null),[ke,pe]=a.useState(null),Pe=a.useRef(null),y=e=>e.id||e.key,Be=g.useSensors(g.useSensor(g.PointerSensor),g.useSensor(g.KeyboardSensor,{coordinateGetter:g.sortableKeyboardCoordinates})),We=e=>{const{active:r,over:n}=e;if(n&&r.id!==n.id){if(r.id===m||n.id===m){Ne("Cannot drop columns on the Action column"),pe(null);return}T.current=!0,R(s=>{const o=s.indexOf(r.id),l=s.indexOf(n.id);if(o!==-1&&l!==-1){const i=g.arrayMove(s,o,l),c=N(i);return oe(c),c}return s}),ve(s=>{const o=s.indexOf(r.id),l=s.indexOf(n.id);return g.arrayMove(s,o,l)})}pe(null)},Ve=e=>{pe(e.active.id)},re=a.useMemo(()=>le?x||[]:!x||x.length===0?[]:x.filter(e=>Object.keys(L).every(r=>{const n=L[r];if(!n||n.trim()==="")return!0;const s=e[r];if(s==null)return!1;const o=String(s).toLowerCase();return n.toLowerCase().trim().split(/\s+/).filter(c=>c.length>0).every(c=>o.includes(c))})),[x,L,le]),ne=a.useMemo(()=>I||!q?re:[...re].sort((e,r)=>{const n=e[q],s=r[q];if(n==null)return 1;if(s==null)return-1;if(typeof n=="number"&&typeof s=="number")return ee==="asc"?n-s:s-n;const o=String(n).toLowerCase(),l=String(s).toLowerCase();return ee==="asc"?o.localeCompare(l):l.localeCompare(o)}),[re,q,ee,I]),se=a.useMemo(()=>{if(X)return x||[];{const e=(ce-1)*Q,r=e+Q;return ne.slice(e,r)}},[x,ne,ce,Q,X]),He=e=>{I&&Y?(Y(e),w?w(1):ie(1)):(he===e?be(ye==="asc"?"desc":"asc"):($e(e),be("asc")),Z(1))},De=(e,r)=>{const n=r&&r.trim()!==""?{...L,[e]:r}:Object.fromEntries(Object.entries(L).filter(([s])=>s!==e));Re(n),le&&K&&K(n),w?w(1):ie(1)},Ne=e=>{V.current||(typeof G=="function"&&G(e),V.current=setTimeout(()=>{V.current=null},3e3))},oe=a.useCallback(e=>{if(typeof window<"u"&&P&&e.length>0&&T.current)try{localStorage.setItem(P,JSON.stringify(e)),B&&localStorage.setItem(B,"true")}catch(r){console.warn("Failed to save columns to localStorage:",r)}},[P,B]),xe=e=>{e!==m&&(T.current=!0,R(r=>r.includes(e)?(V.current&&(clearTimeout(V.current),V.current=null),r.length===1||(Ce(n=>new Set(n).add(e)),setTimeout(()=>{R(n=>{const s=n.filter(l=>l!==e),o=N(s);return oe(o),o}),Ce(n=>{const s=new Set(n);return s.delete(e),s})},200)),r):r.length>=D?(Ne("Maximum 9 column selection allowed"),r):(je(n=>new Set(n).add(e)),setTimeout(()=>{R(n=>{const s=n.includes(e)?n:[...n,e],o=N(s);return oe(o),o}),je(n=>{const s=new Set(n);return s.delete(e),s})},200),r)))},Ke=(e,r)=>{p[r]!==m&&ue(r)},Ue=()=>{ue(null),te(null)},qe=(e,r)=>{e.preventDefault(),F!==null&&F!==r&&te(r)},Je=()=>{te(null)},Ge=(e,r)=>{e.preventDefault(),F!==null&&F!==r&&p[r]!==m&&p[F]!==m&&(T.current=!0,R(n=>{const s=g.arrayMove(n,F,r),o=N(s);return oe(o),o})),ue(null),te(null)};a.useEffect(()=>{ve(e=>{const r=p.filter(o=>e.includes(o)),n=p.filter(o=>!e.includes(o)),s=e.filter(o=>!p.includes(o));return[...r,...n,...s]})},[p]),a.useEffect(()=>{if(typeof window<"u"&&P&&p.length>0&&T.current)try{const e=N(p);localStorage.setItem(P,JSON.stringify(e)),B&&localStorage.setItem(B,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[p,P,B]),a.useEffect(()=>{if(d.length>0&&p.length===0){if(typeof window<"u"&&u)try{if(localStorage.getItem(`dataTable_manual_change_${u}:${h}`)==="true"){const n=localStorage.getItem(`dataTable_columns_${u}:${h}`);if(n){const s=JSON.parse(n);if(Array.isArray(s)&&s.length>0){const o=s.filter(l=>d.some(i=>(i.id||i.key)===l));if(o.length>0){T.current=!0,R(o.slice(0,D));return}}}}}catch(r){console.warn("Failed to load saved columns from localStorage:",r)}const e=d.map(r=>r.id||r.key);R(N(e.slice(0,D)))}},[d,u,h,N]);const $=a.useMemo(()=>{const e=p.map(r=>d.find(n=>y(n)===r)).filter(Boolean);return N(e.map(y)).map(r=>d.find(n=>y(n)===r)).filter(Boolean)},[d,p]),Ye=a.useMemo(()=>$.some(e=>e.filterable===!0),[$]);a.useEffect(()=>{if(!C||!W.current)return;const e=()=>{if(W.current){const r=W.current.getBoundingClientRect();_e({top:r.bottom,left:r.left,width:Math.max(r.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[C]),a.useEffect(()=>{const e=r=>{C&&W.current&&!W.current.contains(r.target)&&fe.current&&!fe.current.contains(r.target)&&we(!1)};if(C)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[C]);const Xe=p.length===1?((Oe=d.find(e=>(e.id||e.key)===p[0]))==null?void 0:Oe.label)||"1 selected":`${p.length} selected`;function Qe({column:e,isHeaderRow:r=!0}){const n=y(e),s=n===m,{attributes:o,listeners:l,setNodeRef:i,transform:c,transition:H,isDragging:J}=g.useSortable({id:n}),et={transform:g.CSS.Transform.toString(c),transition:H,opacity:J?.5:1,width:e.width||"auto",minWidth:e.width||"auto"};let ae=!1;if(I&&S.length>0){const O=S[0][0];(O===n||O==="csat_score"&&n==="evaluation.csat_score")&&(ae=!0)}else ae=q===n;const tt=ee==="asc",rt=e.filterable===!0;return r?t.jsx("th",{ref:i,style:{...et,padding:"12px 14px",textAlign:s?"center":"left",fontWeight:650,fontSize:"11px",letterSpacing:"0.14em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.62)",cursor:e.sortable!==!1?"pointer":"default",width:e.width||"auto",borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:s?"center":"flex-start"},children:[!s&&t.jsx("div",{...o,...l,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:t.jsx(v.GripVertical,{size:12})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&He(n),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&ae&&t.jsx("span",{children:tt?t.jsx(v.ChevronUp,{size:12}):t.jsx(v.ChevronDown,{size:12})})]})}):t.jsx("th",{style:{width:e.width||"auto",minWidth:e.width||"auto",backgroundColor:"var(--primary-foreground)"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:rt?t.jsxs("div",{className:"relative",children:[t.jsx(v.Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),t.jsx("input",{type:"text",placeholder:"Filter...",value:L[n]||"",onChange:O=>{O.stopPropagation(),De(n,O.target.value)},onKeyDown:O=>O.stopPropagation(),onMouseDown:O=>O.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded text-[var(--text-ink)] placeholder:text-[var(--text-faint)] focus:outline-none focus:border-[var(--border-hover)] focus:ring-1 focus:ring-[var(--focus)] transition-colors",style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)"},autoComplete:"off"})]}):t.jsx("div",{className:"h-[34px]"})})}const Fe=ke?d.find(e=>y(e)===ke):null,Ze=C?t.jsxs("div",{ref:fe,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${de.top}px`,left:`${de.left}px`,width:de.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:"0 0 8px 8px",boxShadow:"4px 4px 6px 0px #6D70681A, -4px 0px 6px 0px #6D70681A",border:"1px solid rgba(52, 58, 64, 0.12)",borderTop:"none"},children:[p.map((e,r)=>{const n=d.find(c=>y(c)===e);if(!n)return null;const s=p.indexOf(e),o=F===s,l=Ie===s,i=e===m;return t.jsxs(a.Fragment,{children:[t.jsxs("div",{draggable:!i,onDragStart:i?void 0:c=>Ke(c,s),onDragEnd:i?void 0:Ue,onDragOver:i?void 0:c=>qe(c,s),onDragLeave:i?void 0:Je,onDrop:i?void 0:c=>Ge(c,s),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${i?"cursor-default opacity-100":"cursor-move"} ${!i&&o?"opacity-50":""} ${!i&&l&&F!==null&&F!==s?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!i&&t.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),t.jsx("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),i||xe(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${i?"bg-green-2 border-green-2 cursor-default":Se.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!Se.has(e)&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:n.label})]}),r<p.length-1&&t.jsx(ge,{})]},`selected-${e}-${r}`)}),d.filter(e=>!p.includes(y(e))).map((e,r)=>{const n=y(e),s=Ae.has(n),o=d.filter(l=>!p.includes(y(l))).indexOf(e);return t.jsxs(a.Fragment,{children:[p.length>0&&o===0&&t.jsx(ge,{}),t.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 rounded cursor-pointer transition-colors",onClick:l=>{l.preventDefault(),xe(n)},children:[t.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),xe(n)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${s?"bg-green-2 border-green-2":"bg-white border-gray-300"}`,children:s&&t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),o<d.filter(l=>!p.includes(y(l))).length-1&&t.jsx(ge,{})]},`unselected-${n}`)})]}):null;return t.jsxs("div",{className:"w-full",style:{top:"130px",position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:[d.length>0&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("div",{className:"flex-shrink-0",children:[t.jsx("div",{className:"mb-1 ml-1.5",children:t.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),t.jsxs("div",{ref:W,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 cursor-pointer transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>we(!C),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:C?"8px 8px 0 0":"8px"},children:[t.jsx("span",{children:Xe}),C?t.jsx(v.ChevronUp,{size:16}):t.jsx(v.ChevronDown,{size:16})]}),C&&nt.createPortal(Ze,document.body)]}),E&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),t.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:t.jsx(Ee,{dateRangePicker:E.dateRangePicker,onWeekToDate:E.onWeekToDate,exportConfig:E.exportConfig,filterChipsConfig:E.filterChipsConfig,trailingActions:E.trailingActions})})]})]})}),d.length>0&&$.length>0?t.jsxs(g.DndContext,{sensors:Be,collisionDetection:g.closestCenter,onDragStart:Ve,onDragEnd:We,children:[t.jsxs("div",{className:"rounded-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[z&&t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(2px)",zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"14px"},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[t.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),t.jsx(ot,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),t.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:Pe,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[t.jsxs("thead",{children:[t.jsx("tr",{children:t.jsx(g.SortableContext,{items:p,strategy:g.horizontalListSortingStrategy,children:$.map(e=>t.jsx(Qe,{column:e,isHeaderRow:!0},`header-${y(e)}`))})}),Ye&&t.jsx("tr",{children:$.map(e=>{const r=y(e),n=e.filterable===!0;return t.jsx("th",{style:{padding:"8px 14px",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:e.width||"auto",fontFamily:"var(--font-sans)"},children:n?t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",placeholder:"Filter...",value:L[r]||"",onChange:s=>{s.stopPropagation(),De(r,s.target.value)},onKeyDown:s=>s.stopPropagation(),onMouseDown:s=>s.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"var(--primary-foreground)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:s=>{s.target.style.borderColor="rgba(231, 212, 162, 0.65)",s.target.style.background="var(--primary-foreground)"},onBlur:s=>{s.target.style.borderColor="rgba(52, 58, 64, 0.16)",s.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),t.jsx(v.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):t.jsx("div",{className:"h-[34px]"})},`filter-${r}`)})})]}),t.jsx("tbody",{children:!z&&se.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:$.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!z&&se.length>0?se.map((e,r)=>t.jsx("tr",{"data-row-id":e.id||r,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:f?"pointer":"default",transition:"background 0.15s ease"},onClick:f?n=>{n.stopPropagation(),f(e,r)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:$.map(n=>{const s=y(n),o=e[s],l=n.render?n.render(o,e):o,i=n.width&&n.width!=="auto",c=typeof l=="string"&&l.trim()!=="",H=i&&c,J=H?t.jsx(j,{content:l,children:l}):l;return t.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid rgba(52, 58, 64, 0.04)",width:n.width||"auto",fontFamily:"var(--font-sans)",...H&&{maxWidth:n.width||"200px",overflow:"hidden"}},children:J},s)})},r)):null})]})})]}),t.jsx(g.DragOverlay,{children:Fe?t.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:Fe.label})]})}):null})]}):null,(X?k>0:ne.length>0)&&t.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:t.jsx(ze.Pagination,{page:ce,pageSizeOptions:[5,10,20,50,100],pageSize:Q,totalCount:X?k:ne.length,currentDataLength:se.length,onPageChange:Z,onPageSizeChange:M?e=>{me(e),Z(1)}:e=>{me(e),Z(1)},showPageSizeSelector:!0})})]})}function it({title:x="Summary stats",stats:d=[],columns:b=2}){return t.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[t.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:x}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gap:"10px"},children:d.map((f,k)=>t.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:f.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[f.accentColor&&t.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:f.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),t.jsx("div",{className:"text-[10px] tracking-[0.14em] uppercase",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650,lineHeight:1.1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.label}),t.jsx("div",{style:{fontSize:"13px",color:f.valueStyle==="muted"?"rgba(30, 33, 37, 0.56)":"rgba(30, 33, 37, 0.78)",fontWeight:700,lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:f.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:f.value}),f.subtext&&t.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.subtext})]},k))})]})}exports.DataTable=lt;exports.DataTableFilters=Ee;exports.SummaryStatsPanel=it;
|
|
2
2
|
//# sourceMappingURL=data.cjs.js.map
|