@gp-grid/react 0.10.3 → 0.11.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/index.js +1 -1
- package/dist/styles.css +950 -0
- package/package.json +10 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useCallback as t,useEffect as n,useLayoutEffect as r,useMemo as i,useReducer as a,useRef as o,useState as s}from"react";import{GridCore as c,GridCore as l,applyInstruction as u,buildCellClasses as d,calculateFillHandlePosition as f,calculateFilterPopupPosition as p,calculateScaledColumnPositions as m,createClientDataSource as h,createClientDataSource as g,createDataSourceFromArray as _,createDataSourceFromArray as v,createInitialState as y,createInitialState as b,createMutableClientDataSource as x,createMutableClientDataSource as S,createServerDataSource as C,formatCellValue as w,getFieldValue as T,getFieldValue as E,getTotalWidth as D,injectStyles as O,isCellActive as k,isCellEditing as A,isCellInFillPreview as j,isCellSelected as ee,scrollCellIntoView as M}from"@gp-grid/core";import{Fragment as N,jsx as P,jsxs as F}from"react/jsx-runtime";const I=[{value:`contains`,label:`Contains`},{value:`notContains`,label:`Does not contain`},{value:`equals`,label:`Equals`},{value:`notEquals`,label:`Does not equal`},{value:`startsWith`,label:`Starts with`},{value:`endsWith`,label:`Ends with`},{value:`blank`,label:`Is blank`},{value:`notBlank`,label:`Is not blank`}];function L({distinctValues:e,currentFilter:n,onApply:r,onClose:a}){let o=t(e=>Array.isArray(e)?e.join(`, `):String(e??``),[]),c=i(()=>{let t=e.filter(e=>e!=null&&e!==``&&!(Array.isArray(e)&&e.length===0)).map(e=>o(e));return Array.from(new Set(t)).sort((e,t)=>{let n=parseFloat(e),r=parseFloat(t);return!isNaN(n)&&!isNaN(r)?n-r:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})})},[e,o]),l=c.length>100,[u,d]=s(i(()=>{if(!n?.conditions[0])return l?`condition`:`values`;let e=n.conditions[0];return e.selectedValues&&e.selectedValues.size>0?`values`:`condition`},[n,l])),f=i(()=>n?.conditions[0]?n.conditions[0].selectedValues??new Set:new Set,[n]),p=i(()=>n?.conditions[0]?n.conditions[0].includeBlank??!0:!0,[n]),[m,h]=s(``),[g,_]=s(f),[v,y]=s(p),[b,x]=s(i(()=>{if(!n?.conditions.length)return[{operator:`contains`,value:``,nextOperator:`and`}];let e=n.conditions[0];if(e.selectedValues&&e.selectedValues.size>0)return[{operator:`contains`,value:``,nextOperator:`and`}];let t=n.combination??`and`;return n.conditions.map(e=>{let n=e;return{operator:n.operator,value:n.value??``,nextOperator:n.nextOperator??t}})},[n])),S=i(()=>{if(!m)return c;let e=m.toLowerCase();return c.filter(t=>t.toLowerCase().includes(e))},[c,m]),C=i(()=>e.some(e=>e==null||e===``),[e]),w=i(()=>S.every(e=>g.has(e))&&(!C||v),[S,g,C,v]),T=t(()=>{_(new Set(S)),C&&y(!0)},[S,C]),E=t(()=>{_(new Set),y(!1)},[]),D=t(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),O=t((e,t)=>{x(n=>{let r=[...n];return r[e]={...r[e],...t},r})},[]),k=t(()=>{x(e=>[...e,{operator:`contains`,value:``,nextOperator:`and`}])},[]),A=t(e=>{x(t=>t.filter((t,n)=>n!==e))},[]),j=t(()=>{if(u===`values`){if(c.every(e=>g.has(e))&&(!C||v)){r(null);return}r({conditions:[{type:`text`,operator:`equals`,selectedValues:g,includeBlank:v}],combination:`and`})}else{let e=b.filter(e=>e.operator===`blank`||e.operator===`notBlank`?!0:e.value.trim()!==``);if(e.length===0){r(null);return}r({conditions:e.map(e=>({type:`text`,operator:e.operator,value:e.value,nextOperator:e.nextOperator})),combination:`and`})}},[u,c,g,v,C,b,r]),ee=t(()=>{r(null)},[r]);return F(`div`,{className:`gp-grid-filter-content gp-grid-filter-text`,children:[!l&&F(`div`,{className:`gp-grid-filter-mode-toggle`,children:[P(`button`,{type:`button`,className:u===`values`?`active`:``,onClick:()=>d(`values`),children:`Values`}),P(`button`,{type:`button`,className:u===`condition`?`active`:``,onClick:()=>d(`condition`),children:`Condition`})]}),l&&u===`condition`&&F(`div`,{className:`gp-grid-filter-info`,children:[`Too many unique values (`,c.length,`). Use conditions to filter.`]}),u===`values`&&F(N,{children:[P(`input`,{className:`gp-grid-filter-search`,type:`text`,placeholder:`Search...`,value:m,onChange:e=>h(e.target.value),autoFocus:!0}),F(`div`,{className:`gp-grid-filter-actions`,children:[P(`button`,{type:`button`,onClick:T,disabled:w,children:`Select All`}),P(`button`,{type:`button`,onClick:E,children:`Deselect All`})]}),F(`div`,{className:`gp-grid-filter-list`,children:[C&&F(`label`,{className:`gp-grid-filter-option`,children:[P(`input`,{type:`checkbox`,checked:v,onChange:()=>y(!v)}),P(`span`,{className:`gp-grid-filter-blank`,children:`(Blanks)`})]}),S.map(e=>F(`label`,{className:`gp-grid-filter-option`,children:[P(`input`,{type:`checkbox`,checked:g.has(e),onChange:()=>D(e)}),P(`span`,{children:e})]},e))]})]}),u===`condition`&&F(N,{children:[b.map((e,t)=>F(`div`,{className:`gp-grid-filter-condition`,children:[t>0&&F(`div`,{className:`gp-grid-filter-combination`,children:[P(`button`,{type:`button`,className:b[t-1]?.nextOperator===`and`?`active`:``,onClick:()=>O(t-1,{nextOperator:`and`}),children:`AND`}),P(`button`,{type:`button`,className:b[t-1]?.nextOperator===`or`?`active`:``,onClick:()=>O(t-1,{nextOperator:`or`}),children:`OR`})]}),F(`div`,{className:`gp-grid-filter-row`,children:[P(`select`,{value:e.operator,onChange:e=>O(t,{operator:e.target.value}),autoFocus:t===0,children:I.map(e=>P(`option`,{value:e.value,children:e.label},e.value))}),e.operator!==`blank`&&e.operator!==`notBlank`&&P(`input`,{type:`text`,value:e.value,onChange:e=>O(t,{value:e.target.value}),placeholder:`Value`,className:`gp-grid-filter-text-input`}),b.length>1&&P(`button`,{type:`button`,className:`gp-grid-filter-remove`,onClick:()=>A(t),children:`×`})]})]},t)),P(`button`,{type:`button`,className:`gp-grid-filter-add`,onClick:k,children:`+ Add condition`})]}),F(`div`,{className:`gp-grid-filter-buttons`,children:[P(`button`,{type:`button`,className:`gp-grid-filter-btn-clear`,onClick:ee,children:`Clear`}),P(`button`,{type:`button`,className:`gp-grid-filter-btn-apply`,onClick:j,children:`Apply`})]})]})}const R=[{value:`=`,label:`=`},{value:`!=`,label:`≠`},{value:`>`,label:`>`},{value:`<`,label:`<`},{value:`>=`,label:`≥`},{value:`<=`,label:`≤`},{value:`between`,label:`↔`},{value:`blank`,label:`Is blank`},{value:`notBlank`,label:`Not blank`}];function z({currentFilter:e,onApply:n,onClose:r}){let[a,o]=s(i(()=>{if(!e?.conditions.length)return[{operator:`=`,value:``,valueTo:``,nextOperator:`and`}];let t=e.combination??`and`;return e.conditions.map(e=>{let n=e;return{operator:n.operator,value:n.value==null?``:String(n.value),valueTo:n.valueTo==null?``:String(n.valueTo),nextOperator:n.nextOperator??t}})},[e])),c=t((e,t)=>{o(n=>{let r=[...n];return r[e]={...r[e],...t},r})},[]),l=t(()=>{o(e=>[...e,{operator:`=`,value:``,valueTo:``,nextOperator:`and`}])},[]),u=t(e=>{o(t=>t.filter((t,n)=>n!==e))},[]),d=t(()=>{let e=a.filter(e=>e.operator===`blank`||e.operator===`notBlank`?!0:e.operator===`between`?e.value!==``&&e.valueTo!==``:e.value!==``);if(e.length===0){n(null);return}n({conditions:e.map(e=>({type:`number`,operator:e.operator,value:e.value?parseFloat(e.value):void 0,valueTo:e.valueTo?parseFloat(e.valueTo):void 0,nextOperator:e.nextOperator})),combination:`and`})},[a,n]),f=t(()=>{n(null)},[n]);return F(`div`,{className:`gp-grid-filter-content gp-grid-filter-number`,children:[a.map((e,t)=>F(`div`,{className:`gp-grid-filter-condition`,children:[t>0&&F(`div`,{className:`gp-grid-filter-combination`,children:[P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`and`?`active`:``,onClick:()=>c(t-1,{nextOperator:`and`}),children:`AND`}),P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`or`?`active`:``,onClick:()=>c(t-1,{nextOperator:`or`}),children:`OR`})]}),F(`div`,{className:`gp-grid-filter-row`,children:[P(`select`,{value:e.operator,onChange:e=>c(t,{operator:e.target.value}),children:R.map(e=>P(`option`,{value:e.value,children:e.label},e.value))}),e.operator!==`blank`&&e.operator!==`notBlank`&&P(`input`,{type:`number`,value:e.value,onChange:e=>c(t,{value:e.target.value}),placeholder:`Value`}),e.operator===`between`&&F(N,{children:[P(`span`,{className:`gp-grid-filter-to`,children:`to`}),P(`input`,{type:`number`,value:e.valueTo,onChange:e=>c(t,{valueTo:e.target.value}),placeholder:`Value`})]}),a.length>1&&P(`button`,{type:`button`,className:`gp-grid-filter-remove`,onClick:()=>u(t),children:`×`})]})]},t)),P(`button`,{type:`button`,className:`gp-grid-filter-add`,onClick:l,children:`+ Add condition`}),F(`div`,{className:`gp-grid-filter-buttons`,children:[P(`button`,{type:`button`,className:`gp-grid-filter-btn-clear`,onClick:f,children:`Clear`}),P(`button`,{type:`button`,className:`gp-grid-filter-btn-apply`,onClick:d,children:`Apply`})]})]})}const te=[{value:`=`,label:`=`},{value:`!=`,label:`≠`},{value:`>`,label:`>`},{value:`<`,label:`<`},{value:`between`,label:`↔`},{value:`blank`,label:`Is blank`},{value:`notBlank`,label:`Not blank`}];function ne(e){if(!e)return``;let t=typeof e==`string`?new Date(e):e;return isNaN(t.getTime())?``:t.toISOString().split(`T`)[0]}function re({currentFilter:e,onApply:n,onClose:r}){let[a,o]=s(i(()=>{if(!e?.conditions.length)return[{operator:`=`,value:``,valueTo:``,nextOperator:`and`}];let t=e.combination??`and`;return e.conditions.map(e=>{let n=e;return{operator:n.operator,value:ne(n.value),valueTo:ne(n.valueTo),nextOperator:n.nextOperator??t}})},[e])),c=t((e,t)=>{o(n=>{let r=[...n];return r[e]={...r[e],...t},r})},[]),l=t(()=>{o(e=>[...e,{operator:`=`,value:``,valueTo:``,nextOperator:`and`}])},[]),u=t(e=>{o(t=>t.filter((t,n)=>n!==e))},[]),d=t(()=>{let e=a.filter(e=>e.operator===`blank`||e.operator===`notBlank`?!0:e.operator===`between`?e.value!==``&&e.valueTo!==``:e.value!==``);if(e.length===0){n(null);return}n({conditions:e.map(e=>({type:`date`,operator:e.operator,value:e.value||void 0,valueTo:e.valueTo||void 0,nextOperator:e.nextOperator})),combination:`and`})},[a,n]),f=t(()=>{n(null)},[n]);return F(`div`,{className:`gp-grid-filter-content gp-grid-filter-date`,children:[a.map((e,t)=>F(`div`,{className:`gp-grid-filter-condition`,children:[t>0&&F(`div`,{className:`gp-grid-filter-combination`,children:[P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`and`?`active`:``,onClick:()=>c(t-1,{nextOperator:`and`}),children:`AND`}),P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`or`?`active`:``,onClick:()=>c(t-1,{nextOperator:`or`}),children:`OR`})]}),F(`div`,{className:`gp-grid-filter-row`,children:[P(`select`,{value:e.operator,onChange:e=>c(t,{operator:e.target.value}),children:te.map(e=>P(`option`,{value:e.value,children:e.label},e.value))}),e.operator!==`blank`&&e.operator!==`notBlank`&&P(`input`,{type:`date`,value:e.value,onChange:e=>c(t,{value:e.target.value})}),e.operator===`between`&&F(N,{children:[P(`span`,{className:`gp-grid-filter-to`,children:`to`}),P(`input`,{type:`date`,value:e.valueTo,onChange:e=>c(t,{valueTo:e.target.value})})]}),a.length>1&&P(`button`,{type:`button`,className:`gp-grid-filter-remove`,onClick:()=>u(t),children:`×`})]})]},t)),P(`button`,{type:`button`,className:`gp-grid-filter-add`,onClick:l,children:`+ Add condition`}),F(`div`,{className:`gp-grid-filter-buttons`,children:[P(`button`,{type:`button`,className:`gp-grid-filter-btn-clear`,onClick:f,children:`Clear`}),P(`button`,{type:`button`,className:`gp-grid-filter-btn-apply`,onClick:d,children:`Apply`})]})]})}function ie({column:e,colIndex:r,containerRef:i,distinctValues:a,currentFilter:c,onApply:l,onClose:u}){let d=o(null),[f,m]=s({position:`fixed`,zIndex:1e4,visibility:`hidden`});n(()=>{let e=i.current,t=d.current;if(!e||!t)return;let n=null,a=()=>{let t=e.querySelector(`[data-col-index="${r}"]`);if(!t||!d.current)return;let n=p(t,d.current);m({position:`fixed`,top:n.top,left:n.left,minWidth:n.minWidth,zIndex:1e4,visibility:`visible`})},o=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,a()}))};return requestAnimationFrame(a),e.addEventListener(`scroll`,o,{passive:!0}),window.addEventListener(`resize`,o),()=>{e.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),n!==null&&cancelAnimationFrame(n)}},[i,r]),n(()=>{let e=e=>{let t=e.target;t.closest(`.gp-grid-filter-icon`)||d.current&&!d.current.contains(t)&&u()},t=e=>{e.key===`Escape`&&u()};return requestAnimationFrame(()=>{document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t)}),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[u]);let h=t(t=>{l(e.colId??e.field,t),u()},[e,l,u]),g=e.cellDataType,_=g===`text`||g===`object`,v=g===`number`,y=g===`date`||g===`dateString`||g===`dateTime`||g===`dateTimeString`;return F(`div`,{ref:d,className:`gp-grid-filter-popup`,style:f,children:[F(`div`,{className:`gp-grid-filter-header`,children:[`Filter: `,e.headerName??e.field]}),_&&P(L,{distinctValues:a,currentFilter:c,onApply:h,onClose:u}),v&&P(z,{currentFilter:c,onApply:h,onClose:u}),y&&P(re,{currentFilter:c,onApply:h,onClose:u}),!_&&!v&&!y&&P(L,{distinctValues:a,currentFilter:c,onApply:h,onClose:u})]})}function ae(e){let{column:t,colIndex:n,sortDirection:r,sortIndex:i,sortable:a,filterable:o,hasFilter:s,coreRef:c,containerRef:l,headerRenderers:u,globalHeaderRenderer:d}=e,f=c.current,p={column:t,colIndex:n,sortDirection:r,sortIndex:i,sortable:a,filterable:o,hasFilter:s,onSort:(e,n)=>{f&&a&&f.setSort(t.colId??t.field,e,n)},onFilterClick:()=>{if(f&&o){let e=l.current?.querySelector(`[data-col-index="${n}"]`);if(e){let t=e.getBoundingClientRect();f.openFilterPopup(n,{top:t.top,left:t.left,width:t.width,height:t.height})}}}};if(t.headerRenderer){if(typeof t.headerRenderer==`function`)return t.headerRenderer(p);let e=u[t.headerRenderer];if(e)return e(p)}return d?d(p):F(N,{children:[P(`span`,{className:`gp-grid-header-text`,children:t.headerName??t.field}),F(`span`,{className:`gp-grid-header-icons`,children:[a&&F(`span`,{className:`gp-grid-sort-arrows`,children:[F(`span`,{className:`gp-grid-sort-arrows-stack`,children:[P(`svg`,{className:`gp-grid-sort-arrow-up${r===`asc`?` active`:``}`,width:`8`,height:`6`,viewBox:`0 0 8 6`,children:P(`path`,{d:`M4 0L8 6H0L4 0Z`,fill:`currentColor`})}),P(`svg`,{className:`gp-grid-sort-arrow-down${r===`desc`?` active`:``}`,width:`8`,height:`6`,viewBox:`0 0 8 6`,children:P(`path`,{d:`M4 6L0 0H8L4 6Z`,fill:`currentColor`})})]}),i!==void 0&&i>0&&P(`span`,{className:`gp-grid-sort-index`,children:i})]}),o&&P(`span`,{className:`gp-grid-filter-icon${s?` active`:``}`,onPointerDown:e=>{e.stopPropagation(),e.preventDefault(),p.onFilterClick()},onClick:e=>{e.stopPropagation()},children:P(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`currentColor`,children:P(`path`,{d:`M4 4h16l-6 8v5l-4 2v-7L4 4z`})})})]})]})}const oe=e=>{let{headerHeight:t,scrollLeft:n,contentWidth:r,totalWidth:i,isLoading:a,visibleColumnsWithIndices:o,columnPositions:s,columnWidths:c,headers:l,sortingEnabled:u,onHeaderMouseDown:d,onHeaderResizeMouseDown:f,coreRef:p,outerContainerRef:m,headerRenderers:h,globalHeaderRenderer:g}=e;return P(`div`,{className:`gp-grid-header${a?` gp-grid-header--loading`:``}`,style:{height:t},children:P(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateX(${-n}px)`,width:Math.max(r,i),height:t},children:o.map(({column:e,originalIndex:n},r)=>{let i=l.get(n),a=c[r]??0;return F(`div`,{className:`gp-grid-header-cell`,"data-col-index":n,style:{left:`${s[r]}px`,width:`${a}px`,height:`${t}px`},onPointerDown:e=>d(n,a,t,e),children:[ae({column:e,colIndex:n,sortDirection:i?.sortDirection,sortIndex:i?.sortIndex,sortable:e.sortable!==!1&&u,filterable:e.filterable!==!1,hasFilter:i?.hasFilter??!1,coreRef:p,containerRef:m,headerRenderers:h,globalHeaderRenderer:g}),e.resizable!==!1&&P(`div`,{className:`gp-grid-header-resize-handle`,onPointerDown:e=>{e.stopPropagation(),f(n,a,e)}})]},e.colId??e.field)})})})};function B(e){let{column:t,rowData:n,rowIndex:r,colIndex:i,isActive:a,isSelected:o,isEditing:s,cellRenderers:c,globalCellRenderer:l}=e,u=T(n,t.field),d={value:u,rowData:n,column:t,rowIndex:r,colIndex:i,isActive:a,isSelected:o,isEditing:s};if(t.cellRenderer){if(typeof t.cellRenderer==`function`)return t.cellRenderer(d);let e=c[t.cellRenderer];if(e)return e(d)}return l?l(d):w(u,t.valueFormatter)}function V(e){let{column:t,rowData:n,rowIndex:r,colIndex:i,initialValue:a,coreRef:o,editRenderers:s,globalEditRenderer:c}=e,l=o.current;if(!l)return null;let u={value:E(n,t.field),rowData:n,column:t,rowIndex:r,colIndex:i,isActive:!0,isSelected:!0,isEditing:!0,initialValue:a,onValueChange:e=>l.updateEditValue(e),onCommit:()=>l.commitEdit(),onCancel:()=>l.cancelEdit()};if(t.editRenderer){if(typeof t.editRenderer==`function`)return t.editRenderer(u);let e=s[t.editRenderer];if(e)return e(u)}return c?c(u):P(`input`,{className:`gp-grid-edit-input`,type:`text`,defaultValue:a==null?``:String(a),autoFocus:!0,onFocus:e=>e.target.select(),onChange:e=>l.updateEditValue(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?l.commitEdit():e.key===`Escape`?l.cancelEdit():e.key===`Tab`&&(e.preventDefault(),l.commitEdit(),l.selection.moveFocus(e.shiftKey?`left`:`right`,!1))},onBlur:()=>l.commitEdit()})}const se=e.forwardRef((e,t)=>{let{rowHeight:n,totalHeaderHeight:r,contentWidth:i,contentHeight:a,totalWidth:o,rowsWrapperOffset:s,activeCell:c,selectionRange:l,editingCell:u,error:f,isLoading:p,totalRows:m,slotsArray:h,visibleColumnsWithIndices:g,columnPositions:_,columnWidths:v,fillHandlePosition:y,dragState:b,onScroll:x,onCellMouseDown:S,onCellDoubleClick:C,onCellMouseEnter:w,onCellMouseLeave:T,onFillHandleMouseDown:E,coreRef:D,cellRenderers:O,editRenderers:M,globalCellRenderer:N,globalEditRenderer:I}=e;return F(`div`,{ref:t,style:{flex:1,overflow:`auto`,position:`relative`},onScroll:x,children:[P(`div`,{style:{width:Math.max(i,o),height:Math.max(a-r,0),position:`relative`,minWidth:`100%`},children:F(`div`,{className:`gp-grid-rows-wrapper`,style:{width:`${Math.max(i,o)}px`,transform:`translateY(${s}px)`},children:[h.map(e=>e.rowIndex<0?null:P(`div`,{className:[`gp-grid-row`,...D.current?.highlight?.computeRowClasses(e.rowIndex,e.rowData)??[]].filter(Boolean).join(` `),style:{position:`absolute`,top:0,left:0,transform:`translateY(${e.translateY}px)`,width:`${Math.max(i,o)}px`,height:`${n}px`},children:g.map(({column:t,originalIndex:r},i)=>{let a=A(e.rowIndex,r,u),o=k(e.rowIndex,r,c),s=ee(e.rowIndex,r,l),f=d(o,s,a,j(e.rowIndex,r,b.dragType===`fill`,b.fillSourceRange,b.fillTarget)),p=D.current?.highlight?.computeCombinedCellClasses(e.rowIndex,r,t,e.rowData)??[],m=t.rowDrag===!0;return P(`div`,{className:[f,...p,m?`gp-grid-cell--row-drag-handle`:``].filter(Boolean).join(` `),style:{position:`absolute`,left:`${_[i]}px`,top:0,width:`${v[i]}px`,height:`${n}px`},onPointerDown:t=>S(e.rowIndex,r,t),onDoubleClick:()=>C(e.rowIndex,r),onMouseEnter:()=>w(e.rowIndex,r),onMouseLeave:T,children:a&&u?V({column:t,rowData:e.rowData,rowIndex:e.rowIndex,colIndex:r,initialValue:u.initialValue,coreRef:D,editRenderers:M,globalEditRenderer:I}):B({column:t,rowData:e.rowData,rowIndex:e.rowIndex,colIndex:r,isActive:o,isSelected:s,isEditing:a,cellRenderers:O,globalCellRenderer:N})},`${e.slotId}-${r}`)})},e.slotId)),y&&!u&&P(`div`,{className:`gp-grid-fill-handle`,style:{top:y.top,left:y.left},onPointerDown:E}),b.dragType===`row-drag`&&b.rowDrag?.dropTargetIndex!==null&&P(`div`,{className:`gp-grid-row-drop-indicator`,style:{transform:`translateY(${b.rowDrag.dropIndicatorY}px)`,width:`${Math.max(i,o)}px`}})]})}),f&&F(`div`,{className:`gp-grid-error`,children:[`Error: `,f]}),!p&&!f&&m===0&&P(`div`,{className:`gp-grid-empty`,children:`No data to display`})]})});function ce(e,t){if(t.type===`RESET`)return y();let{instructions:n}=t;if(n.length===0)return e;let r=new Map(e.slots),i=new Map(e.headers),a={pendingScrollTop:null};for(let e of n){let t=u(e,r,i);t&&(a={...a,...t})}return{...e,...a,slots:r,headers:i}}function le(e,r,i,a){let{activeCell:c,selectionRange:l,editingCell:u,filterPopupOpen:d,rowHeight:f,headerHeight:p,columnPositions:m,visibleColumnsWithIndices:h,slots:g,rowsWrapperOffset:_}=a,v=o(null),y=o(null),b=o(null),x=o(null),S=o(null),C=t(e=>{e.preventDefault()},[]),[w,T]=s({isDragging:!1,dragType:null,fillSourceRange:null,fillTarget:null,columnResize:null,columnMove:null,rowDrag:null});n(()=>{let t=e.current;t?.input&&t.input.updateDeps({getHeaderHeight:()=>p,getRowHeight:()=>f,getColumnPositions:()=>m,getColumnCount:()=>h.length,getOriginalColumnIndex:e=>{let t=h[e];return t?t.originalIndex:e}})},[e,p,f,m,h]);let E=t(()=>{let e=r.current;if(!e)return null;let t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}},[r]),D=t((t,n)=>{v.current&&clearInterval(v.current),v.current=setInterval(()=>{let i=r.current,a=e.current;if(i){i.scrollTop+=n,i.scrollLeft+=t;let e=y.current;if(e&&a?.input){let t=E();t&&(a.input.handleDragMove(e,t),T(a.input.getDragState()))}}},16)},[r,e,E]),O=t(()=>{v.current&&=(clearInterval(v.current),null)},[]),k=e=>({clientX:e.clientX,clientY:e.clientY,button:e.button,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,pointerId:e.pointerId,pointerType:e.pointerType}),A=t(()=>{let t=t=>{t.preventDefault();let n=e.current,r=E();if(!n?.input||!r)return;let i=k(t);y.current=i;let a=n.input.handleDragMove(i,r);a&&(a.autoScroll?D(a.autoScroll.dx,a.autoScroll.dy):O(),T(n.input.getDragState()))},n=()=>{let i=e.current;i?.input&&(i.input.handleDragEnd(),T(i.input.getDragState())),y.current=null,O(),document.removeEventListener(`touchmove`,C),S.current!==null&&r.current&&(r.current.style.overflow=S.current,S.current=null),document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n),document.removeEventListener(`pointercancel`,n)};document.addEventListener(`pointermove`,t,{passive:!1}),document.addEventListener(`pointerup`,n),document.addEventListener(`pointercancel`,n)},[e,E,D,O]),j=t(()=>{b.current!==null&&(clearTimeout(b.current),b.current=null,e.current?.input?.cancelPendingRowDrag()),x.current=null},[e]),ee=t((t,n,i)=>{let a=e.current;if(!a?.input)return;let o=a.input.handleCellMouseDown(t,n,k(i));if(o.focusContainer&&r.current?.focus(),o.startDrag===`selection`)a.input.startSelectionDrag(),T(a.input.getDragState()),A();else if(o.startDrag===`row-drag`)T(a.input.getDragState()),A();else if(o.startDrag===`row-drag-pending`){j(),x.current={pointerId:i.pointerId,target:i.currentTarget};let e=i.clientX,t=i.clientY,n=n=>{let r=n.clientX-e,i=n.clientY-t;(Math.abs(r)>10||Math.abs(i)>10)&&(j(),s())},o=()=>{j(),s()},s=()=>{document.removeEventListener(`pointermove`,n),document.removeEventListener(`pointerup`,o),document.removeEventListener(`pointercancel`,o)};document.addEventListener(`pointermove`,n),document.addEventListener(`pointerup`,o,{once:!0}),document.addEventListener(`pointercancel`,o,{once:!0}),b.current=setTimeout(()=>{b.current=null,s();let e=x.current;if(x.current=null,a.input.confirmPendingRowDrag()){if(r.current&&(S.current=r.current.style.overflow,r.current.style.overflow=`hidden`),document.addEventListener(`touchmove`,C,{passive:!1}),e)try{e.target.setPointerCapture(e.pointerId)}catch{}T(a.input.getDragState()),A()}},300)}},[e,r,A,j]),N=t((t,n)=>{let r=e.current;r?.input&&r.input.handleCellDoubleClick(t,n)},[e]),P=t(t=>{let n=e.current;if(!n?.input)return;let r=n.input.handleFillHandleMouseDown(c,l,k(t));if(r.preventDefault&&t.preventDefault(),r.stopPropagation&&t.stopPropagation(),r.startDrag===`fill`){try{t.target.setPointerCapture(t.pointerId)}catch{}T(n.input.getDragState()),A()}},[e,c,l,A]),F=t((t,n)=>{let r=e.current;if(!r?.input)return;let a=i[t];if(!a)return;let o=a.colId??a.field;r.input.handleHeaderClick(o,n.shiftKey)},[e,i]),I=t((t,n,r,i)=>{let a=e.current;if(!a?.input)return;let o=a.input.handleHeaderMouseDown(t,n,r,k(i));if(o.preventDefault&&i.preventDefault(),o.stopPropagation&&i.stopPropagation(),o.startDrag===`column-move`){try{i.target.setPointerCapture(i.pointerId)}catch{}T(a.input.getDragState()),A()}},[e,A]),L=t((t,n,r)=>{let i=e.current;if(!i?.input)return;let a=i.input.handleHeaderResizeMouseDown(t,n,k(r));a.preventDefault&&r.preventDefault(),a.stopPropagation&&r.stopPropagation(),a.startDrag===`column-resize`&&(T(i.input.getDragState()),A())},[e,A]),R=t(t=>{let n=e.current,i=r.current;if(!n?.input)return;let a=n.input.handleKeyDown({key:t.key,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey},c,u,d);a.preventDefault&&t.preventDefault(),a.scrollToCell&&i&&M(n,i,a.scrollToCell.row,f,g,_)},[e,r,c,u,d,f,g,_]),z=t((t,n)=>{let i=e.current,a=r.current;if(!i?.input||!a)return;let o=i.input.handleWheel(t.deltaY,t.deltaX,n);o&&(t.preventDefault(),a.scrollTop+=o.dy,a.scrollLeft+=o.dx)},[e,r]);return n(()=>()=>{O(),j(),document.removeEventListener(`touchmove`,C),S.current!==null&&r.current&&(r.current.style.overflow=S.current,S.current=null)},[O,j,C,r]),{handleCellMouseDown:ee,handleCellDoubleClick:N,handleFillHandleMouseDown:P,handleHeaderClick:F,handleHeaderMouseDown:I,handleHeaderResizeMouseDown:L,handleKeyDown:R,handleWheel:z,dragState:w}}function H(s){O();let{columns:c,dataSource:u,rowData:d,rowHeight:p,headerHeight:h=p,overscan:_=3,sortingEnabled:y=!0,darkMode:x=!1,wheelDampening:S=.1,cellRenderers:C={},editRenderers:w={},headerRenderers:T={},cellRenderer:E,editRenderer:k,headerRenderer:A,initialWidth:j,initialHeight:ee,gridRef:M,highlighting:I,getRowId:L,onCellValueChanged:R,loadingComponent:z,rowDragEntireRow:te=!1,onRowDragEnd:ne,onColumnResized:re,onColumnMoved:ae}=s,B=o(null),V=o(null),H=o(null),U=o(null),ue=o(!1),[W,de]=a(ce,{initialWidth:j,initialHeight:ee},b),G=h,K=o(null),q=K.current;(!q||q.providedDataSource!==u||q.rowData!==d)&&(q&&d&&d.length>1e4&&console.warn(`[gp-grid] rowData prop changed with ${d.length} rows — this triggers a full rebuild. Use useGridData() for efficient updates.`),q?.ownsDataSource&&q.dataSource.destroy?.(),u?K.current={dataSource:u,ownsDataSource:!1,providedDataSource:u,rowData:d}:d?K.current={dataSource:v(d),ownsDataSource:!0,providedDataSource:u,rowData:d}:K.current={dataSource:g([]),ownsDataSource:!0,providedDataSource:u,rowData:d});let{dataSource:J}=K.current;n(()=>()=>{K.current?.ownsDataSource&&(K.current.dataSource.destroy?.(),K.current=null)},[]);let fe=o(L);fe.current=L;let pe=o(R);pe.current=R;let me=o(ne);me.current=ne;let he=o(re);he.current=re;let ge=o(ae);ge.current=ae;let _e=o(I);_e.current=I;let ve=o(J);ve.current=J;let Y=W.columns??c,X=i(()=>Y.map((e,t)=>({column:e,originalIndex:t})).filter(({column:e})=>!e.hidden),[Y]),{positions:Z,widths:ye}=i(()=>m(X.map(e=>e.column),W.viewportWidth),[X,W.viewportWidth]),be=D(Z),{handleCellMouseDown:xe,handleCellDoubleClick:Se,handleFillHandleMouseDown:Ce,handleHeaderMouseDown:we,handleHeaderResizeMouseDown:Te,handleKeyDown:Ee,handleWheel:De,dragState:Q}=le(H,V,Y,{activeCell:W.activeCell,selectionRange:W.selectionRange,editingCell:W.editingCell,filterPopupOpen:W.filterPopup?.isOpen??!1,rowHeight:p,headerHeight:G,columnPositions:Z,visibleColumnsWithIndices:X,slots:W.slots,rowsWrapperOffset:W.rowsWrapperOffset});n(()=>{ue.current&&de({type:`RESET`}),ue.current=!0;let e=new l({columns:c,dataSource:ve.current,rowHeight:p,headerHeight:G,overscan:_,sortingEnabled:y,highlighting:_e.current,getRowId:fe.current,onCellValueChanged:pe.current?e=>pe.current?.(e):void 0,rowDragEntireRow:te,onRowDragEnd:(e,t)=>me.current?.(e,t),onColumnResized:(e,t)=>he.current?.(e,t),onColumnMoved:(e,t)=>ge.current?.(e,t)});H.current=e,e.input.updateDeps({getHeaderHeight:()=>G,getRowHeight:()=>p,getColumnPositions:()=>Z,getColumnCount:()=>X.length,getOriginalColumnIndex:e=>{let t=X[e];return t?t.originalIndex:e}}),M&&(M.current={core:e});let t=e.onBatchInstruction(e=>{de({type:`BATCH_INSTRUCTIONS`,instructions:e})});e.initialize();let n=V.current;return n&&e.setViewport(n.scrollTop,n.scrollLeft,n.clientWidth,n.clientHeight),()=>{t(),e.destroy(),H.current=null,M&&(M.current=null)}},[c,p,G,_,y,M,te]),n(()=>{let e=H.current;if(!e)return;let t=U.current;if(!t||t===J){U.current=J;return}U.current=J,e.setDataSource(J)},[J]),n(()=>{let e=J;if(e.subscribe)return e.subscribe(()=>{H.current?.refreshFromTransaction()})},[J]),n(()=>{let e=H.current;!e?.highlight||!I||e.highlight.updateOptions(I)},[I]);let $=t(()=>{let e=V.current,t=H.current;!e||!t||t.setViewport(e.scrollTop,e.scrollLeft,e.clientWidth,e.clientHeight)},[]);n(()=>{let e=V.current,t=H.current;if(!e||!t)return;if(typeof ResizeObserver>`u`){$();return}let n=new ResizeObserver(()=>{t.setViewport(e.scrollTop,e.scrollLeft,e.clientWidth,e.clientHeight)});return n.observe(e),$(),()=>n.disconnect()},[$]),n(()=>{let e=V.current;if(!e)return;let t=e=>{De(e,S)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[De,S]),r(()=>{if(W.pendingScrollTop!==null){let e=V.current;e&&(e.scrollTop=W.pendingScrollTop)}},[W.pendingScrollTop]);let Oe=t((e,t)=>{let n=H.current;n&&n.setFilter(e,t)},[]),ke=t(()=>{let e=H.current;e&&e.closeFilterPopup()},[]),Ae=t((e,t)=>{H.current?.input.handleCellMouseEnter(e,t)},[]),je=t(()=>{H.current?.input.handleCellMouseLeave()},[]),Me=i(()=>Array.from(W.slots.values()),[W.slots]),Ne=i(()=>f({activeCell:W.activeCell,selectionRange:W.selectionRange,slots:W.slots,columns:Y,visibleColumnsWithIndices:X,columnPositions:Z,columnWidths:ye,rowHeight:p}),[W.activeCell,W.selectionRange,W.slots,p,Z,ye,Y,X]),[Pe,Fe]=e.useState(0),Ie=t(()=>{let e=V.current;e&&(Fe(e.scrollLeft),$())},[$]);return F(`div`,{ref:B,className:`gp-grid-container${x?` gp-grid-container--dark`:``}`,style:{width:`100%`,height:`100%`,position:`relative`,display:`flex`,flexDirection:`column`},onKeyDown:Ee,tabIndex:0,children:[P(oe,{headerHeight:h,scrollLeft:Pe,contentWidth:W.contentWidth,totalWidth:be,isLoading:W.isLoading,visibleColumnsWithIndices:X,columnPositions:Z,columnWidths:ye,headers:W.headers,sortingEnabled:y,onHeaderMouseDown:we,onHeaderResizeMouseDown:Te,coreRef:H,outerContainerRef:B,headerRenderers:T,globalHeaderRenderer:A}),P(se,{ref:V,rowHeight:p,totalHeaderHeight:G,contentWidth:W.contentWidth,contentHeight:W.contentHeight,totalWidth:be,rowsWrapperOffset:W.rowsWrapperOffset,activeCell:W.activeCell,selectionRange:W.selectionRange,editingCell:W.editingCell,error:W.error,isLoading:W.isLoading,totalRows:W.totalRows,slotsArray:Me,visibleColumnsWithIndices:X,columnPositions:Z,columnWidths:ye,fillHandlePosition:Ne,dragState:Q,onScroll:Ie,onCellMouseDown:xe,onCellDoubleClick:Se,onCellMouseEnter:Ae,onCellMouseLeave:je,onFillHandleMouseDown:Ce,coreRef:H,cellRenderers:C,editRenderers:w,globalCellRenderer:E,globalEditRenderer:k}),W.isLoading&&F(`div`,{style:{position:`absolute`,top:h,left:0,right:0,bottom:0,zIndex:50,pointerEvents:`none`},children:[P(`div`,{className:`gp-grid-loading-overlay`}),z?e.createElement(z,{isLoading:!0}):P(`div`,{className:`gp-grid-loading`,children:P(`div`,{className:`gp-grid-loading-spinner`})})]}),W.filterPopup?.isOpen&&W.filterPopup.column&&P(ie,{column:W.filterPopup.column,colIndex:W.filterPopup.colIndex,containerRef:B,distinctValues:W.filterPopup.distinctValues,currentFilter:W.filterPopup.currentFilter,onApply:Oe,onClose:ke}),Q.dragType===`column-resize`&&Q.columnResize&&(()=>{let e=X.findIndex(e=>e.originalIndex===Q.columnResize.colIndex);return e===-1?null:P(`div`,{className:`gp-grid-column-resize-line`,style:{left:(Z[e]??0)+Q.columnResize.currentWidth-Pe}})})(),Q.dragType===`column-move`&&Q.columnMove&&(()=>{let e=Q.columnMove,t=Y[e.sourceColIndex],n=t?.headerName??t?.field??``;return F(N,{children:[P(`div`,{className:`gp-grid-column-move-ghost`,style:{left:e.currentX-e.ghostWidth/2,top:e.currentY-e.ghostHeight/2,width:e.ghostWidth,height:e.ghostHeight},children:n}),e.dropTargetIndex!==null&&P(`div`,{className:`gp-grid-column-drop-indicator`,style:{position:`absolute`,top:0,left:(Z[e.dropTargetIndex]??0)-Pe,height:h}})]})})(),Q.dragType===`row-drag`&&Q.rowDrag&&P(`div`,{className:`gp-grid-row-drag-ghost`,style:{left:Q.rowDrag.currentX+12,top:Q.rowDrag.currentY-p/2,width:Math.min(300,be),height:p}})]})}const U=(e,t)=>{let n=i(()=>S(e,{getRowId:t.getRowId,debounceMs:t.debounceMs??0,useWorker:t.useWorker,parallelSort:t.parallelSort}),[]);return{dataSource:n,updateRow:n.updateRow,addRows:n.addRows,removeRows:n.removeRows,updateCell:n.updateCell,clear:n.clear,getRowById:n.getRowById,getTotalRowCount:n.getTotalRowCount,flushTransactions:n.flushTransactions}};export{H as GpGrid,H as Grid,c as GridCore,h as createClientDataSource,_ as createDataSourceFromArray,x as createMutableClientDataSource,C as createServerDataSource,U as useGridData};
|
|
1
|
+
import e,{useCallback as t,useEffect as n,useLayoutEffect as r,useMemo as i,useReducer as a,useRef as o,useState as s}from"react";import{GridCore as c,GridCore as l,applyInstruction as u,buildCellClasses as d,calculateFillHandlePosition as f,calculateFilterPopupPosition as p,calculateScaledColumnPositions as m,createClientDataSource as h,createClientDataSource as g,createDataSourceFromArray as _,createDataSourceFromArray as v,createInitialState as y,createInitialState as b,createMutableClientDataSource as x,createMutableClientDataSource as S,createServerDataSource as C,formatCellValue as w,getFieldValue as T,getFieldValue as E,getTotalWidth as D,isCellActive as O,isCellEditing as k,isCellInFillPreview as A,isCellSelected as j,scrollCellIntoView as M}from"@gp-grid/core";import{Fragment as N,jsx as P,jsxs as F}from"react/jsx-runtime";const I=[{value:`contains`,label:`Contains`},{value:`notContains`,label:`Does not contain`},{value:`equals`,label:`Equals`},{value:`notEquals`,label:`Does not equal`},{value:`startsWith`,label:`Starts with`},{value:`endsWith`,label:`Ends with`},{value:`blank`,label:`Is blank`},{value:`notBlank`,label:`Is not blank`}];function L({distinctValues:e,currentFilter:n,onApply:r,onClose:a}){let o=t(e=>Array.isArray(e)?e.join(`, `):String(e??``),[]),c=i(()=>{let t=e.filter(e=>e!=null&&e!==``&&!(Array.isArray(e)&&e.length===0)).map(e=>o(e));return Array.from(new Set(t)).sort((e,t)=>{let n=parseFloat(e),r=parseFloat(t);return!isNaN(n)&&!isNaN(r)?n-r:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})})},[e,o]),l=c.length>100,[u,d]=s(i(()=>{if(!n?.conditions[0])return l?`condition`:`values`;let e=n.conditions[0];return e.selectedValues&&e.selectedValues.size>0?`values`:`condition`},[n,l])),f=i(()=>n?.conditions[0]?n.conditions[0].selectedValues??new Set:new Set,[n]),p=i(()=>n?.conditions[0]?n.conditions[0].includeBlank??!0:!0,[n]),[m,h]=s(``),[g,_]=s(f),[v,y]=s(p),[b,x]=s(i(()=>{if(!n?.conditions.length)return[{operator:`contains`,value:``,nextOperator:`and`}];let e=n.conditions[0];if(e.selectedValues&&e.selectedValues.size>0)return[{operator:`contains`,value:``,nextOperator:`and`}];let t=n.combination??`and`;return n.conditions.map(e=>{let n=e;return{operator:n.operator,value:n.value??``,nextOperator:n.nextOperator??t}})},[n])),S=i(()=>{if(!m)return c;let e=m.toLowerCase();return c.filter(t=>t.toLowerCase().includes(e))},[c,m]),C=i(()=>e.some(e=>e==null||e===``),[e]),w=i(()=>S.every(e=>g.has(e))&&(!C||v),[S,g,C,v]),T=t(()=>{_(new Set(S)),C&&y(!0)},[S,C]),E=t(()=>{_(new Set),y(!1)},[]),D=t(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),O=t((e,t)=>{x(n=>{let r=[...n];return r[e]={...r[e],...t},r})},[]),k=t(()=>{x(e=>[...e,{operator:`contains`,value:``,nextOperator:`and`}])},[]),A=t(e=>{x(t=>t.filter((t,n)=>n!==e))},[]),j=t(()=>{if(u===`values`){if(c.every(e=>g.has(e))&&(!C||v)){r(null);return}r({conditions:[{type:`text`,operator:`equals`,selectedValues:g,includeBlank:v}],combination:`and`})}else{let e=b.filter(e=>e.operator===`blank`||e.operator===`notBlank`?!0:e.value.trim()!==``);if(e.length===0){r(null);return}r({conditions:e.map(e=>({type:`text`,operator:e.operator,value:e.value,nextOperator:e.nextOperator})),combination:`and`})}},[u,c,g,v,C,b,r]),M=t(()=>{r(null)},[r]);return F(`div`,{className:`gp-grid-filter-content gp-grid-filter-text`,children:[!l&&F(`div`,{className:`gp-grid-filter-mode-toggle`,children:[P(`button`,{type:`button`,className:u===`values`?`active`:``,onClick:()=>d(`values`),children:`Values`}),P(`button`,{type:`button`,className:u===`condition`?`active`:``,onClick:()=>d(`condition`),children:`Condition`})]}),l&&u===`condition`&&F(`div`,{className:`gp-grid-filter-info`,children:[`Too many unique values (`,c.length,`). Use conditions to filter.`]}),u===`values`&&F(N,{children:[P(`input`,{className:`gp-grid-filter-search`,type:`text`,placeholder:`Search...`,value:m,onChange:e=>h(e.target.value),autoFocus:!0}),F(`div`,{className:`gp-grid-filter-actions`,children:[P(`button`,{type:`button`,onClick:T,disabled:w,children:`Select All`}),P(`button`,{type:`button`,onClick:E,children:`Deselect All`})]}),F(`div`,{className:`gp-grid-filter-list`,children:[C&&F(`label`,{className:`gp-grid-filter-option`,children:[P(`input`,{type:`checkbox`,checked:v,onChange:()=>y(!v)}),P(`span`,{className:`gp-grid-filter-blank`,children:`(Blanks)`})]}),S.map(e=>F(`label`,{className:`gp-grid-filter-option`,children:[P(`input`,{type:`checkbox`,checked:g.has(e),onChange:()=>D(e)}),P(`span`,{children:e})]},e))]})]}),u===`condition`&&F(N,{children:[b.map((e,t)=>F(`div`,{className:`gp-grid-filter-condition`,children:[t>0&&F(`div`,{className:`gp-grid-filter-combination`,children:[P(`button`,{type:`button`,className:b[t-1]?.nextOperator===`and`?`active`:``,onClick:()=>O(t-1,{nextOperator:`and`}),children:`AND`}),P(`button`,{type:`button`,className:b[t-1]?.nextOperator===`or`?`active`:``,onClick:()=>O(t-1,{nextOperator:`or`}),children:`OR`})]}),F(`div`,{className:`gp-grid-filter-row`,children:[P(`select`,{value:e.operator,onChange:e=>O(t,{operator:e.target.value}),autoFocus:t===0,children:I.map(e=>P(`option`,{value:e.value,children:e.label},e.value))}),e.operator!==`blank`&&e.operator!==`notBlank`&&P(`input`,{type:`text`,value:e.value,onChange:e=>O(t,{value:e.target.value}),placeholder:`Value`,className:`gp-grid-filter-text-input`}),b.length>1&&P(`button`,{type:`button`,className:`gp-grid-filter-remove`,onClick:()=>A(t),children:`×`})]})]},t)),P(`button`,{type:`button`,className:`gp-grid-filter-add`,onClick:k,children:`+ Add condition`})]}),F(`div`,{className:`gp-grid-filter-buttons`,children:[P(`button`,{type:`button`,className:`gp-grid-filter-btn-clear`,onClick:M,children:`Clear`}),P(`button`,{type:`button`,className:`gp-grid-filter-btn-apply`,onClick:j,children:`Apply`})]})]})}const ee=[{value:`=`,label:`=`},{value:`!=`,label:`≠`},{value:`>`,label:`>`},{value:`<`,label:`<`},{value:`>=`,label:`≥`},{value:`<=`,label:`≤`},{value:`between`,label:`↔`},{value:`blank`,label:`Is blank`},{value:`notBlank`,label:`Not blank`}];function R({currentFilter:e,onApply:n,onClose:r}){let[a,o]=s(i(()=>{if(!e?.conditions.length)return[{operator:`=`,value:``,valueTo:``,nextOperator:`and`}];let t=e.combination??`and`;return e.conditions.map(e=>{let n=e;return{operator:n.operator,value:n.value==null?``:String(n.value),valueTo:n.valueTo==null?``:String(n.valueTo),nextOperator:n.nextOperator??t}})},[e])),c=t((e,t)=>{o(n=>{let r=[...n];return r[e]={...r[e],...t},r})},[]),l=t(()=>{o(e=>[...e,{operator:`=`,value:``,valueTo:``,nextOperator:`and`}])},[]),u=t(e=>{o(t=>t.filter((t,n)=>n!==e))},[]),d=t(()=>{let e=a.filter(e=>e.operator===`blank`||e.operator===`notBlank`?!0:e.operator===`between`?e.value!==``&&e.valueTo!==``:e.value!==``);if(e.length===0){n(null);return}n({conditions:e.map(e=>({type:`number`,operator:e.operator,value:e.value?parseFloat(e.value):void 0,valueTo:e.valueTo?parseFloat(e.valueTo):void 0,nextOperator:e.nextOperator})),combination:`and`})},[a,n]),f=t(()=>{n(null)},[n]);return F(`div`,{className:`gp-grid-filter-content gp-grid-filter-number`,children:[a.map((e,t)=>F(`div`,{className:`gp-grid-filter-condition`,children:[t>0&&F(`div`,{className:`gp-grid-filter-combination`,children:[P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`and`?`active`:``,onClick:()=>c(t-1,{nextOperator:`and`}),children:`AND`}),P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`or`?`active`:``,onClick:()=>c(t-1,{nextOperator:`or`}),children:`OR`})]}),F(`div`,{className:`gp-grid-filter-row`,children:[P(`select`,{value:e.operator,onChange:e=>c(t,{operator:e.target.value}),children:ee.map(e=>P(`option`,{value:e.value,children:e.label},e.value))}),e.operator!==`blank`&&e.operator!==`notBlank`&&P(`input`,{type:`number`,value:e.value,onChange:e=>c(t,{value:e.target.value}),placeholder:`Value`}),e.operator===`between`&&F(N,{children:[P(`span`,{className:`gp-grid-filter-to`,children:`to`}),P(`input`,{type:`number`,value:e.valueTo,onChange:e=>c(t,{valueTo:e.target.value}),placeholder:`Value`})]}),a.length>1&&P(`button`,{type:`button`,className:`gp-grid-filter-remove`,onClick:()=>u(t),children:`×`})]})]},t)),P(`button`,{type:`button`,className:`gp-grid-filter-add`,onClick:l,children:`+ Add condition`}),F(`div`,{className:`gp-grid-filter-buttons`,children:[P(`button`,{type:`button`,className:`gp-grid-filter-btn-clear`,onClick:f,children:`Clear`}),P(`button`,{type:`button`,className:`gp-grid-filter-btn-apply`,onClick:d,children:`Apply`})]})]})}const z=[{value:`=`,label:`=`},{value:`!=`,label:`≠`},{value:`>`,label:`>`},{value:`<`,label:`<`},{value:`between`,label:`↔`},{value:`blank`,label:`Is blank`},{value:`notBlank`,label:`Not blank`}];function B(e){if(!e)return``;let t=typeof e==`string`?new Date(e):e;return isNaN(t.getTime())?``:t.toISOString().split(`T`)[0]}function te({currentFilter:e,onApply:n,onClose:r}){let[a,o]=s(i(()=>{if(!e?.conditions.length)return[{operator:`=`,value:``,valueTo:``,nextOperator:`and`}];let t=e.combination??`and`;return e.conditions.map(e=>{let n=e;return{operator:n.operator,value:B(n.value),valueTo:B(n.valueTo),nextOperator:n.nextOperator??t}})},[e])),c=t((e,t)=>{o(n=>{let r=[...n];return r[e]={...r[e],...t},r})},[]),l=t(()=>{o(e=>[...e,{operator:`=`,value:``,valueTo:``,nextOperator:`and`}])},[]),u=t(e=>{o(t=>t.filter((t,n)=>n!==e))},[]),d=t(()=>{let e=a.filter(e=>e.operator===`blank`||e.operator===`notBlank`?!0:e.operator===`between`?e.value!==``&&e.valueTo!==``:e.value!==``);if(e.length===0){n(null);return}n({conditions:e.map(e=>({type:`date`,operator:e.operator,value:e.value||void 0,valueTo:e.valueTo||void 0,nextOperator:e.nextOperator})),combination:`and`})},[a,n]),f=t(()=>{n(null)},[n]);return F(`div`,{className:`gp-grid-filter-content gp-grid-filter-date`,children:[a.map((e,t)=>F(`div`,{className:`gp-grid-filter-condition`,children:[t>0&&F(`div`,{className:`gp-grid-filter-combination`,children:[P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`and`?`active`:``,onClick:()=>c(t-1,{nextOperator:`and`}),children:`AND`}),P(`button`,{type:`button`,className:a[t-1]?.nextOperator===`or`?`active`:``,onClick:()=>c(t-1,{nextOperator:`or`}),children:`OR`})]}),F(`div`,{className:`gp-grid-filter-row`,children:[P(`select`,{value:e.operator,onChange:e=>c(t,{operator:e.target.value}),children:z.map(e=>P(`option`,{value:e.value,children:e.label},e.value))}),e.operator!==`blank`&&e.operator!==`notBlank`&&P(`input`,{type:`date`,value:e.value,onChange:e=>c(t,{value:e.target.value})}),e.operator===`between`&&F(N,{children:[P(`span`,{className:`gp-grid-filter-to`,children:`to`}),P(`input`,{type:`date`,value:e.valueTo,onChange:e=>c(t,{valueTo:e.target.value})})]}),a.length>1&&P(`button`,{type:`button`,className:`gp-grid-filter-remove`,onClick:()=>u(t),children:`×`})]})]},t)),P(`button`,{type:`button`,className:`gp-grid-filter-add`,onClick:l,children:`+ Add condition`}),F(`div`,{className:`gp-grid-filter-buttons`,children:[P(`button`,{type:`button`,className:`gp-grid-filter-btn-clear`,onClick:f,children:`Clear`}),P(`button`,{type:`button`,className:`gp-grid-filter-btn-apply`,onClick:d,children:`Apply`})]})]})}function ne({column:e,colIndex:r,containerRef:i,distinctValues:a,currentFilter:c,onApply:l,onClose:u}){let d=o(null),[f,m]=s({position:`fixed`,zIndex:1e4,visibility:`hidden`});n(()=>{let e=i.current,t=d.current;if(!e||!t)return;let n=null,a=()=>{let t=e.querySelector(`[data-col-index="${r}"]`);if(!t||!d.current)return;let n=p(t,d.current);m({position:`fixed`,top:n.top,left:n.left,minWidth:n.minWidth,zIndex:1e4,visibility:`visible`})},o=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,a()}))};return requestAnimationFrame(a),e.addEventListener(`scroll`,o,{passive:!0}),window.addEventListener(`resize`,o),()=>{e.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),n!==null&&cancelAnimationFrame(n)}},[i,r]),n(()=>{let e=e=>{let t=e.target;t.closest(`.gp-grid-filter-icon`)||d.current&&!d.current.contains(t)&&u()},t=e=>{e.key===`Escape`&&u()};return requestAnimationFrame(()=>{document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t)}),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[u]);let h=t(t=>{l(e.colId??e.field,t),u()},[e,l,u]),g=e.cellDataType,_=g===`text`||g===`object`,v=g===`number`,y=g===`date`||g===`dateString`||g===`dateTime`||g===`dateTimeString`;return F(`div`,{ref:d,className:`gp-grid-filter-popup`,style:f,children:[F(`div`,{className:`gp-grid-filter-header`,children:[`Filter: `,e.headerName??e.field]}),_&&P(L,{distinctValues:a,currentFilter:c,onApply:h,onClose:u}),v&&P(R,{currentFilter:c,onApply:h,onClose:u}),y&&P(te,{currentFilter:c,onApply:h,onClose:u}),!_&&!v&&!y&&P(L,{distinctValues:a,currentFilter:c,onApply:h,onClose:u})]})}function re(e){let{column:t,colIndex:n,sortDirection:r,sortIndex:i,sortable:a,filterable:o,hasFilter:s,coreRef:c,containerRef:l,headerRenderers:u,globalHeaderRenderer:d}=e,f=c.current,p={column:t,colIndex:n,sortDirection:r,sortIndex:i,sortable:a,filterable:o,hasFilter:s,onSort:(e,n)=>{f&&a&&f.setSort(t.colId??t.field,e,n)},onFilterClick:()=>{if(f&&o){let e=l.current?.querySelector(`[data-col-index="${n}"]`);if(e){let t=e.getBoundingClientRect();f.openFilterPopup(n,{top:t.top,left:t.left,width:t.width,height:t.height})}}}};if(t.headerRenderer){if(typeof t.headerRenderer==`function`)return t.headerRenderer(p);let e=u[t.headerRenderer];if(e)return e(p)}return d?d(p):F(N,{children:[P(`span`,{className:`gp-grid-header-text`,children:t.headerName??t.field}),F(`span`,{className:`gp-grid-header-icons`,children:[a&&F(`span`,{className:`gp-grid-sort-arrows`,children:[F(`span`,{className:`gp-grid-sort-arrows-stack`,children:[P(`svg`,{className:`gp-grid-sort-arrow-up${r===`asc`?` active`:``}`,width:`8`,height:`6`,viewBox:`0 0 8 6`,children:P(`path`,{d:`M4 0L8 6H0L4 0Z`,fill:`currentColor`})}),P(`svg`,{className:`gp-grid-sort-arrow-down${r===`desc`?` active`:``}`,width:`8`,height:`6`,viewBox:`0 0 8 6`,children:P(`path`,{d:`M4 6L0 0H8L4 6Z`,fill:`currentColor`})})]}),i!==void 0&&i>0&&P(`span`,{className:`gp-grid-sort-index`,children:i})]}),o&&P(`span`,{className:`gp-grid-filter-icon${s?` active`:``}`,onPointerDown:e=>{e.stopPropagation(),e.preventDefault(),p.onFilterClick()},onClick:e=>{e.stopPropagation()},children:P(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`currentColor`,children:P(`path`,{d:`M4 4h16l-6 8v5l-4 2v-7L4 4z`})})})]})]})}const ie=e=>{let{headerHeight:t,scrollLeft:n,contentWidth:r,totalWidth:i,isLoading:a,visibleColumnsWithIndices:o,columnPositions:s,columnWidths:c,headers:l,sortingEnabled:u,onHeaderMouseDown:d,onHeaderResizeMouseDown:f,coreRef:p,outerContainerRef:m,headerRenderers:h,globalHeaderRenderer:g}=e;return P(`div`,{className:`gp-grid-header${a?` gp-grid-header--loading`:``}`,style:{height:t},children:P(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateX(${-n}px)`,width:Math.max(r,i),height:t},children:o.map(({column:e,originalIndex:n},r)=>{let i=l.get(n),a=c[r]??0;return F(`div`,{className:`gp-grid-header-cell`,"data-col-index":n,style:{left:`${s[r]}px`,width:`${a}px`,height:`${t}px`},onPointerDown:e=>d(n,a,t,e),children:[re({column:e,colIndex:n,sortDirection:i?.sortDirection,sortIndex:i?.sortIndex,sortable:e.sortable!==!1&&u,filterable:e.filterable!==!1,hasFilter:i?.hasFilter??!1,coreRef:p,containerRef:m,headerRenderers:h,globalHeaderRenderer:g}),e.resizable!==!1&&P(`div`,{className:`gp-grid-header-resize-handle`,onPointerDown:e=>{e.stopPropagation(),f(n,a,e)}})]},e.colId??e.field)})})})};function V(e){let{column:t,rowData:n,rowIndex:r,colIndex:i,isActive:a,isSelected:o,isEditing:s,cellRenderers:c,globalCellRenderer:l}=e,u=T(n,t.field),d={value:u,rowData:n,column:t,rowIndex:r,colIndex:i,isActive:a,isSelected:o,isEditing:s};if(t.cellRenderer){if(typeof t.cellRenderer==`function`)return t.cellRenderer(d);let e=c[t.cellRenderer];if(e)return e(d)}return l?l(d):w(u,t.valueFormatter)}function H(e){let{column:t,rowData:n,rowIndex:r,colIndex:i,initialValue:a,coreRef:o,editRenderers:s,globalEditRenderer:c}=e,l=o.current;if(!l)return null;let u={value:E(n,t.field),rowData:n,column:t,rowIndex:r,colIndex:i,isActive:!0,isSelected:!0,isEditing:!0,initialValue:a,onValueChange:e=>l.updateEditValue(e),onCommit:()=>l.commitEdit(),onCancel:()=>l.cancelEdit()};if(t.editRenderer){if(typeof t.editRenderer==`function`)return t.editRenderer(u);let e=s[t.editRenderer];if(e)return e(u)}return c?c(u):P(`input`,{className:`gp-grid-edit-input`,type:`text`,defaultValue:a==null?``:String(a),autoFocus:!0,onFocus:e=>e.target.select(),onChange:e=>l.updateEditValue(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?l.commitEdit():e.key===`Escape`?l.cancelEdit():e.key===`Tab`&&(e.preventDefault(),l.commitEdit(),l.selection.moveFocus(e.shiftKey?`left`:`right`,!1))},onBlur:()=>l.commitEdit()})}const ae=e.forwardRef((e,t)=>{let{rowHeight:n,totalHeaderHeight:r,contentWidth:i,contentHeight:a,totalWidth:o,rowsWrapperOffset:s,activeCell:c,selectionRange:l,editingCell:u,error:f,isLoading:p,totalRows:m,slotsArray:h,visibleColumnsWithIndices:g,columnPositions:_,columnWidths:v,fillHandlePosition:y,dragState:b,onScroll:x,onCellMouseDown:S,onCellDoubleClick:C,onCellMouseEnter:w,onCellMouseLeave:T,onFillHandleMouseDown:E,coreRef:D,cellRenderers:M,editRenderers:N,globalCellRenderer:I,globalEditRenderer:L}=e;return F(`div`,{ref:t,style:{flex:1,overflow:`auto`,position:`relative`},onScroll:x,children:[P(`div`,{style:{width:Math.max(i,o),height:Math.max(a-r,0),position:`relative`,minWidth:`100%`},children:F(`div`,{className:`gp-grid-rows-wrapper`,style:{width:`${Math.max(i,o)}px`,transform:`translateY(${s}px)`},children:[h.map(e=>e.rowIndex<0?null:P(`div`,{className:[`gp-grid-row`,...D.current?.highlight?.computeRowClasses(e.rowIndex,e.rowData)??[]].filter(Boolean).join(` `),style:{position:`absolute`,top:0,left:0,transform:`translateY(${e.translateY}px)`,width:`${Math.max(i,o)}px`,height:`${n}px`},children:g.map(({column:t,originalIndex:r},i)=>{let a=k(e.rowIndex,r,u),o=O(e.rowIndex,r,c),s=j(e.rowIndex,r,l),f=d(o,s,a,A(e.rowIndex,r,b.dragType===`fill`,b.fillSourceRange,b.fillTarget)),p=D.current?.highlight?.computeCombinedCellClasses(e.rowIndex,r,t,e.rowData)??[],m=t.rowDrag===!0;return P(`div`,{className:[f,...p,m?`gp-grid-cell--row-drag-handle`:``].filter(Boolean).join(` `),style:{position:`absolute`,left:`${_[i]}px`,top:0,width:`${v[i]}px`,height:`${n}px`},onPointerDown:t=>S(e.rowIndex,r,t),onDoubleClick:()=>C(e.rowIndex,r),onMouseEnter:()=>w(e.rowIndex,r),onMouseLeave:T,children:a&&u?H({column:t,rowData:e.rowData,rowIndex:e.rowIndex,colIndex:r,initialValue:u.initialValue,coreRef:D,editRenderers:N,globalEditRenderer:L}):V({column:t,rowData:e.rowData,rowIndex:e.rowIndex,colIndex:r,isActive:o,isSelected:s,isEditing:a,cellRenderers:M,globalCellRenderer:I})},`${e.slotId}-${r}`)})},e.slotId)),y&&!u&&P(`div`,{className:`gp-grid-fill-handle`,style:{top:y.top,left:y.left},onPointerDown:E}),b.dragType===`row-drag`&&b.rowDrag?.dropTargetIndex!==null&&P(`div`,{className:`gp-grid-row-drop-indicator`,style:{transform:`translateY(${b.rowDrag.dropIndicatorY}px)`,width:`${Math.max(i,o)}px`}})]})}),f&&F(`div`,{className:`gp-grid-error`,children:[`Error: `,f]}),!p&&!f&&m===0&&P(`div`,{className:`gp-grid-empty`,children:`No data to display`})]})});function oe(e,t){if(t.type===`RESET`)return y();let{instructions:n}=t;if(n.length===0)return e;let r=new Map(e.slots),i=new Map(e.headers),a={pendingScrollTop:null};for(let e of n){let t=u(e,r,i);t&&(a={...a,...t})}return{...e,...a,slots:r,headers:i}}function se(e,r,i,a){let{activeCell:c,selectionRange:l,editingCell:u,filterPopupOpen:d,rowHeight:f,headerHeight:p,columnPositions:m,visibleColumnsWithIndices:h,slots:g,rowsWrapperOffset:_}=a,v=o(null),y=o(null),b=o(null),x=o(null),S=o(null),C=t(e=>{e.preventDefault()},[]),[w,T]=s({isDragging:!1,dragType:null,fillSourceRange:null,fillTarget:null,columnResize:null,columnMove:null,rowDrag:null});n(()=>{let t=e.current;t?.input&&t.input.updateDeps({getHeaderHeight:()=>p,getRowHeight:()=>f,getColumnPositions:()=>m,getColumnCount:()=>h.length,getOriginalColumnIndex:e=>{let t=h[e];return t?t.originalIndex:e}})},[e,p,f,m,h]);let E=t(()=>{let e=r.current;if(!e)return null;let t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}},[r]),D=t((t,n)=>{v.current&&clearInterval(v.current),v.current=setInterval(()=>{let i=r.current,a=e.current;if(i){i.scrollTop+=n,i.scrollLeft+=t;let e=y.current;if(e&&a?.input){let t=E();t&&(a.input.handleDragMove(e,t),T(a.input.getDragState()))}}},16)},[r,e,E]),O=t(()=>{v.current&&=(clearInterval(v.current),null)},[]),k=e=>({clientX:e.clientX,clientY:e.clientY,button:e.button,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,pointerId:e.pointerId,pointerType:e.pointerType}),A=t(()=>{let t=t=>{t.preventDefault();let n=e.current,r=E();if(!n?.input||!r)return;let i=k(t);y.current=i;let a=n.input.handleDragMove(i,r);a&&(a.autoScroll?D(a.autoScroll.dx,a.autoScroll.dy):O(),T(n.input.getDragState()))},n=()=>{let i=e.current;i?.input&&(i.input.handleDragEnd(),T(i.input.getDragState())),y.current=null,O(),document.removeEventListener(`touchmove`,C),S.current!==null&&r.current&&(r.current.style.overflow=S.current,S.current=null),document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n),document.removeEventListener(`pointercancel`,n)};document.addEventListener(`pointermove`,t,{passive:!1}),document.addEventListener(`pointerup`,n),document.addEventListener(`pointercancel`,n)},[e,E,D,O]),j=t(()=>{b.current!==null&&(clearTimeout(b.current),b.current=null,e.current?.input?.cancelPendingRowDrag()),x.current=null},[e]),N=t((t,n,i)=>{let a=e.current;if(!a?.input)return;let o=a.input.handleCellMouseDown(t,n,k(i));if(o.focusContainer&&r.current?.focus(),o.startDrag===`selection`)a.input.startSelectionDrag(),T(a.input.getDragState()),A();else if(o.startDrag===`row-drag`)T(a.input.getDragState()),A();else if(o.startDrag===`row-drag-pending`){j(),x.current={pointerId:i.pointerId,target:i.currentTarget};let e=i.clientX,t=i.clientY,n=n=>{let r=n.clientX-e,i=n.clientY-t;(Math.abs(r)>10||Math.abs(i)>10)&&(j(),s())},o=()=>{j(),s()},s=()=>{document.removeEventListener(`pointermove`,n),document.removeEventListener(`pointerup`,o),document.removeEventListener(`pointercancel`,o)};document.addEventListener(`pointermove`,n),document.addEventListener(`pointerup`,o,{once:!0}),document.addEventListener(`pointercancel`,o,{once:!0}),b.current=setTimeout(()=>{b.current=null,s();let e=x.current;if(x.current=null,a.input.confirmPendingRowDrag()){if(r.current&&(S.current=r.current.style.overflow,r.current.style.overflow=`hidden`),document.addEventListener(`touchmove`,C,{passive:!1}),e)try{e.target.setPointerCapture(e.pointerId)}catch{}T(a.input.getDragState()),A()}},300)}},[e,r,A,j]),P=t((t,n)=>{let r=e.current;r?.input&&r.input.handleCellDoubleClick(t,n)},[e]),F=t(t=>{let n=e.current;if(!n?.input)return;let r=n.input.handleFillHandleMouseDown(c,l,k(t));if(r.preventDefault&&t.preventDefault(),r.stopPropagation&&t.stopPropagation(),r.startDrag===`fill`){try{t.target.setPointerCapture(t.pointerId)}catch{}T(n.input.getDragState()),A()}},[e,c,l,A]),I=t((t,n)=>{let r=e.current;if(!r?.input)return;let a=i[t];if(!a)return;let o=a.colId??a.field;r.input.handleHeaderClick(o,n.shiftKey)},[e,i]),L=t((t,n,r,i)=>{let a=e.current;if(!a?.input)return;let o=a.input.handleHeaderMouseDown(t,n,r,k(i));if(o.preventDefault&&i.preventDefault(),o.stopPropagation&&i.stopPropagation(),o.startDrag===`column-move`){try{i.target.setPointerCapture(i.pointerId)}catch{}T(a.input.getDragState()),A()}},[e,A]),ee=t((t,n,r)=>{let i=e.current;if(!i?.input)return;let a=i.input.handleHeaderResizeMouseDown(t,n,k(r));a.preventDefault&&r.preventDefault(),a.stopPropagation&&r.stopPropagation(),a.startDrag===`column-resize`&&(T(i.input.getDragState()),A())},[e,A]),R=t(t=>{let n=e.current,i=r.current;if(!n?.input)return;let a=n.input.handleKeyDown({key:t.key,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey},c,u,d);a.preventDefault&&t.preventDefault(),a.scrollToCell&&i&&M(n,i,a.scrollToCell.row,f,g,_)},[e,r,c,u,d,f,g,_]),z=t((t,n)=>{let i=e.current,a=r.current;if(!i?.input||!a)return;let o=i.input.handleWheel(t.deltaY,t.deltaX,n);o&&(t.preventDefault(),a.scrollTop+=o.dy,a.scrollLeft+=o.dx)},[e,r]);return n(()=>()=>{O(),j(),document.removeEventListener(`touchmove`,C),S.current!==null&&r.current&&(r.current.style.overflow=S.current,S.current=null)},[O,j,C,r]),{handleCellMouseDown:N,handleCellDoubleClick:P,handleFillHandleMouseDown:F,handleHeaderClick:I,handleHeaderMouseDown:L,handleHeaderResizeMouseDown:ee,handleKeyDown:R,handleWheel:z,dragState:w}}function U(s){let{columns:c,dataSource:u,rowData:d,rowHeight:p,headerHeight:h=p,overscan:_=3,sortingEnabled:y=!0,darkMode:x=!1,wheelDampening:S=.1,cellRenderers:C={},editRenderers:w={},headerRenderers:T={},cellRenderer:E,editRenderer:O,headerRenderer:k,initialWidth:A,initialHeight:j,gridRef:M,highlighting:I,getRowId:L,onCellValueChanged:ee,loadingComponent:R,rowDragEntireRow:z=!1,onRowDragEnd:B,onColumnResized:te,onColumnMoved:re}=s,V=o(null),H=o(null),U=o(null),ce=o(null),le=o(!1),[W,ue]=a(oe,{initialWidth:A,initialHeight:j},b),G=h,K=o(null),q=K.current;(!q||q.providedDataSource!==u||q.rowData!==d)&&(q&&d&&d.length>1e4&&console.warn(`[gp-grid] rowData prop changed with ${d.length} rows — this triggers a full rebuild. Use useGridData() for efficient updates.`),q?.ownsDataSource&&q.dataSource.destroy?.(),u?K.current={dataSource:u,ownsDataSource:!1,providedDataSource:u,rowData:d}:d?K.current={dataSource:v(d),ownsDataSource:!0,providedDataSource:u,rowData:d}:K.current={dataSource:g([]),ownsDataSource:!0,providedDataSource:u,rowData:d});let{dataSource:J}=K.current;n(()=>()=>{K.current?.ownsDataSource&&(K.current.dataSource.destroy?.(),K.current=null)},[]);let de=o(L);de.current=L;let fe=o(ee);fe.current=ee;let pe=o(B);pe.current=B;let me=o(te);me.current=te;let he=o(re);he.current=re;let ge=o(I);ge.current=I;let _e=o(J);_e.current=J;let Y=W.columns??c,X=i(()=>Y.map((e,t)=>({column:e,originalIndex:t})).filter(({column:e})=>!e.hidden),[Y]),{positions:Z,widths:ve}=i(()=>m(X.map(e=>e.column),W.viewportWidth),[X,W.viewportWidth]),ye=D(Z),{handleCellMouseDown:be,handleCellDoubleClick:xe,handleFillHandleMouseDown:Se,handleHeaderMouseDown:Ce,handleHeaderResizeMouseDown:we,handleKeyDown:Te,handleWheel:Ee,dragState:Q}=se(U,H,Y,{activeCell:W.activeCell,selectionRange:W.selectionRange,editingCell:W.editingCell,filterPopupOpen:W.filterPopup?.isOpen??!1,rowHeight:p,headerHeight:G,columnPositions:Z,visibleColumnsWithIndices:X,slots:W.slots,rowsWrapperOffset:W.rowsWrapperOffset});n(()=>{le.current&&ue({type:`RESET`}),le.current=!0;let e=new l({columns:c,dataSource:_e.current,rowHeight:p,headerHeight:G,overscan:_,sortingEnabled:y,highlighting:ge.current,getRowId:de.current,onCellValueChanged:fe.current?e=>fe.current?.(e):void 0,rowDragEntireRow:z,onRowDragEnd:(e,t)=>pe.current?.(e,t),onColumnResized:(e,t)=>me.current?.(e,t),onColumnMoved:(e,t)=>he.current?.(e,t)});U.current=e,e.input.updateDeps({getHeaderHeight:()=>G,getRowHeight:()=>p,getColumnPositions:()=>Z,getColumnCount:()=>X.length,getOriginalColumnIndex:e=>{let t=X[e];return t?t.originalIndex:e}}),M&&(M.current={core:e});let t=e.onBatchInstruction(e=>{ue({type:`BATCH_INSTRUCTIONS`,instructions:e})});e.initialize();let n=H.current;return n&&e.setViewport(n.scrollTop,n.scrollLeft,n.clientWidth,n.clientHeight),()=>{t(),e.destroy(),U.current=null,M&&(M.current=null)}},[c,p,G,_,y,M,z]),n(()=>{let e=U.current;if(!e)return;let t=ce.current;if(!t||t===J){ce.current=J;return}ce.current=J,e.setDataSource(J)},[J]),n(()=>{let e=J;if(e.subscribe)return e.subscribe(()=>{U.current?.refreshFromTransaction()})},[J]),n(()=>{let e=U.current;!e?.highlight||!I||e.highlight.updateOptions(I)},[I]);let $=t(()=>{let e=H.current,t=U.current;!e||!t||t.setViewport(e.scrollTop,e.scrollLeft,e.clientWidth,e.clientHeight)},[]);n(()=>{let e=H.current,t=U.current;if(!e||!t)return;if(typeof ResizeObserver>`u`){$();return}let n=new ResizeObserver(()=>{t.setViewport(e.scrollTop,e.scrollLeft,e.clientWidth,e.clientHeight)});return n.observe(e),$(),()=>n.disconnect()},[$]),n(()=>{let e=H.current;if(!e)return;let t=e=>{Ee(e,S)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[Ee,S]),r(()=>{if(W.pendingScrollTop!==null){let e=H.current;e&&(e.scrollTop=W.pendingScrollTop)}},[W.pendingScrollTop]);let De=t((e,t)=>{let n=U.current;n&&n.setFilter(e,t)},[]),Oe=t(()=>{let e=U.current;e&&e.closeFilterPopup()},[]),ke=t((e,t)=>{U.current?.input.handleCellMouseEnter(e,t)},[]),Ae=t(()=>{U.current?.input.handleCellMouseLeave()},[]),je=i(()=>Array.from(W.slots.values()),[W.slots]),Me=i(()=>f({activeCell:W.activeCell,selectionRange:W.selectionRange,slots:W.slots,columns:Y,visibleColumnsWithIndices:X,columnPositions:Z,columnWidths:ve,rowHeight:p}),[W.activeCell,W.selectionRange,W.slots,p,Z,ve,Y,X]),[Ne,Pe]=e.useState(0),Fe=t(()=>{let e=H.current;e&&(Pe(e.scrollLeft),$())},[$]);return F(`div`,{ref:V,className:`gp-grid-container${x?` gp-grid-container--dark`:``}`,style:{width:`100%`,height:`100%`,position:`relative`,display:`flex`,flexDirection:`column`},onKeyDown:Te,tabIndex:0,children:[P(ie,{headerHeight:h,scrollLeft:Ne,contentWidth:W.contentWidth,totalWidth:ye,isLoading:W.isLoading,visibleColumnsWithIndices:X,columnPositions:Z,columnWidths:ve,headers:W.headers,sortingEnabled:y,onHeaderMouseDown:Ce,onHeaderResizeMouseDown:we,coreRef:U,outerContainerRef:V,headerRenderers:T,globalHeaderRenderer:k}),P(ae,{ref:H,rowHeight:p,totalHeaderHeight:G,contentWidth:W.contentWidth,contentHeight:W.contentHeight,totalWidth:ye,rowsWrapperOffset:W.rowsWrapperOffset,activeCell:W.activeCell,selectionRange:W.selectionRange,editingCell:W.editingCell,error:W.error,isLoading:W.isLoading,totalRows:W.totalRows,slotsArray:je,visibleColumnsWithIndices:X,columnPositions:Z,columnWidths:ve,fillHandlePosition:Me,dragState:Q,onScroll:Fe,onCellMouseDown:be,onCellDoubleClick:xe,onCellMouseEnter:ke,onCellMouseLeave:Ae,onFillHandleMouseDown:Se,coreRef:U,cellRenderers:C,editRenderers:w,globalCellRenderer:E,globalEditRenderer:O}),W.isLoading&&F(`div`,{style:{position:`absolute`,top:h,left:0,right:0,bottom:0,zIndex:50,pointerEvents:`none`},children:[P(`div`,{className:`gp-grid-loading-overlay`}),R?e.createElement(R,{isLoading:!0}):P(`div`,{className:`gp-grid-loading`,children:P(`div`,{className:`gp-grid-loading-spinner`})})]}),W.filterPopup?.isOpen&&W.filterPopup.column&&P(ne,{column:W.filterPopup.column,colIndex:W.filterPopup.colIndex,containerRef:V,distinctValues:W.filterPopup.distinctValues,currentFilter:W.filterPopup.currentFilter,onApply:De,onClose:Oe}),Q.dragType===`column-resize`&&Q.columnResize&&(()=>{let e=X.findIndex(e=>e.originalIndex===Q.columnResize.colIndex);return e===-1?null:P(`div`,{className:`gp-grid-column-resize-line`,style:{left:(Z[e]??0)+Q.columnResize.currentWidth-Ne}})})(),Q.dragType===`column-move`&&Q.columnMove&&(()=>{let e=Q.columnMove,t=Y[e.sourceColIndex],n=t?.headerName??t?.field??``;return F(N,{children:[P(`div`,{className:`gp-grid-column-move-ghost`,style:{left:e.currentX-e.ghostWidth/2,top:e.currentY-e.ghostHeight/2,width:e.ghostWidth,height:e.ghostHeight},children:n}),e.dropTargetIndex!==null&&P(`div`,{className:`gp-grid-column-drop-indicator`,style:{position:`absolute`,top:0,left:(Z[e.dropTargetIndex]??0)-Ne,height:h}})]})})(),Q.dragType===`row-drag`&&Q.rowDrag&&P(`div`,{className:`gp-grid-row-drag-ghost`,style:{left:Q.rowDrag.currentX+12,top:Q.rowDrag.currentY-p/2,width:Math.min(300,ye),height:p}})]})}const ce=(e,t)=>{let n=i(()=>S(e,{getRowId:t.getRowId,debounceMs:t.debounceMs??0,useWorker:t.useWorker,parallelSort:t.parallelSort}),[]);return{dataSource:n,updateRow:n.updateRow,addRows:n.addRows,removeRows:n.removeRows,updateCell:n.updateCell,clear:n.clear,getRowById:n.getRowById,getTotalRowCount:n.getTotalRowCount,flushTransactions:n.flushTransactions}};export{U as GpGrid,U as Grid,c as GridCore,h as createClientDataSource,_ as createDataSourceFromArray,x as createMutableClientDataSource,C as createServerDataSource,ce as useGridData};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,950 @@
|
|
|
1
|
+
|
|
2
|
+
/* =============================================================================
|
|
3
|
+
GP Grid - CSS Variables for Theming
|
|
4
|
+
============================================================================= */
|
|
5
|
+
|
|
6
|
+
.gp-grid-container {
|
|
7
|
+
/* Colors - Light Mode (default) */
|
|
8
|
+
--gp-grid-bg: #ffffff;
|
|
9
|
+
--gp-grid-bg-alt: #f8f9fa;
|
|
10
|
+
--gp-grid-text: #212529;
|
|
11
|
+
--gp-grid-text-secondary: #6c757d;
|
|
12
|
+
--gp-grid-text-muted: #adb5bd;
|
|
13
|
+
--gp-grid-border: #dee2e6;
|
|
14
|
+
--gp-grid-border-light: #e9ecef;
|
|
15
|
+
|
|
16
|
+
/* Header */
|
|
17
|
+
--gp-grid-header-bg: #f1f3f5;
|
|
18
|
+
--gp-grid-header-text: #212529;
|
|
19
|
+
--gp-grid-header-z-index: 10;
|
|
20
|
+
|
|
21
|
+
/* Selection */
|
|
22
|
+
--gp-grid-primary: #228be6;
|
|
23
|
+
--gp-grid-primary-light: #e7f5ff;
|
|
24
|
+
--gp-grid-primary-border: #74c0fc;
|
|
25
|
+
--gp-grid-hover: #f1f3f5;
|
|
26
|
+
|
|
27
|
+
/* Filter */
|
|
28
|
+
--gp-grid-filter-bg: #f8f9fa;
|
|
29
|
+
--gp-grid-input-bg: #ffffff;
|
|
30
|
+
--gp-grid-input-border: #ced4da;
|
|
31
|
+
|
|
32
|
+
/* Error */
|
|
33
|
+
--gp-grid-error-bg: #fff5f5;
|
|
34
|
+
--gp-grid-error-text: #c92a2a;
|
|
35
|
+
|
|
36
|
+
/* Loading */
|
|
37
|
+
--gp-grid-loading-bg: rgba(255, 255, 255, 0.95);
|
|
38
|
+
--gp-grid-loading-text: #495057;
|
|
39
|
+
|
|
40
|
+
/* Scrollbar */
|
|
41
|
+
--gp-grid-scrollbar-track: #f1f3f5;
|
|
42
|
+
--gp-grid-scrollbar-thumb: #ced4da;
|
|
43
|
+
--gp-grid-scrollbar-thumb-hover: #adb5bd;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Dark Mode */
|
|
47
|
+
.gp-grid-container--dark {
|
|
48
|
+
--gp-grid-bg: #1a1b1e;
|
|
49
|
+
--gp-grid-bg-alt: #25262b;
|
|
50
|
+
--gp-grid-text: #c1c2c5;
|
|
51
|
+
--gp-grid-text-secondary: #909296;
|
|
52
|
+
--gp-grid-text-muted: #5c5f66;
|
|
53
|
+
--gp-grid-border: #373a40;
|
|
54
|
+
--gp-grid-border-light: #2c2e33;
|
|
55
|
+
|
|
56
|
+
/* Header */
|
|
57
|
+
--gp-grid-header-bg: #25262b;
|
|
58
|
+
--gp-grid-header-text: #c1c2c5;
|
|
59
|
+
--gp-grid-header-z-index: 10;
|
|
60
|
+
|
|
61
|
+
/* Selection */
|
|
62
|
+
--gp-grid-primary: #339af0;
|
|
63
|
+
--gp-grid-primary-light: #1c3d5a;
|
|
64
|
+
--gp-grid-primary-border: #1c7ed6;
|
|
65
|
+
--gp-grid-hover: #2c2e33;
|
|
66
|
+
|
|
67
|
+
/* Filter */
|
|
68
|
+
--gp-grid-filter-bg: #25262b;
|
|
69
|
+
--gp-grid-input-bg: #1a1b1e;
|
|
70
|
+
--gp-grid-input-border: #373a40;
|
|
71
|
+
|
|
72
|
+
/* Error */
|
|
73
|
+
--gp-grid-error-bg: #2c1a1a;
|
|
74
|
+
--gp-grid-error-text: #ff6b6b;
|
|
75
|
+
|
|
76
|
+
/* Loading */
|
|
77
|
+
--gp-grid-loading-bg: rgba(26, 27, 30, 0.95);
|
|
78
|
+
--gp-grid-loading-text: #c1c2c5;
|
|
79
|
+
|
|
80
|
+
/* Scrollbar */
|
|
81
|
+
--gp-grid-scrollbar-track: #25262b;
|
|
82
|
+
--gp-grid-scrollbar-thumb: #373a40;
|
|
83
|
+
--gp-grid-scrollbar-thumb-hover: #4a4d52;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/* =============================================================================
|
|
88
|
+
GP Grid - Clean Flat Design
|
|
89
|
+
============================================================================= */
|
|
90
|
+
|
|
91
|
+
/* Grid Container */
|
|
92
|
+
.gp-grid-container {
|
|
93
|
+
outline: none;
|
|
94
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
95
|
+
font-size: 13px;
|
|
96
|
+
line-height: 1.5;
|
|
97
|
+
color: var(--gp-grid-text);
|
|
98
|
+
background-color: var(--gp-grid-bg);
|
|
99
|
+
border: 1px solid var(--gp-grid-border);
|
|
100
|
+
border-radius: 6px;
|
|
101
|
+
user-select: none;
|
|
102
|
+
-webkit-user-select: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.gp-grid-container:focus {
|
|
106
|
+
outline: none;
|
|
107
|
+
border-color: var(--gp-grid-primary);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
/* =============================================================================
|
|
112
|
+
Header
|
|
113
|
+
============================================================================= */
|
|
114
|
+
|
|
115
|
+
.gp-grid-header {
|
|
116
|
+
position: sticky;
|
|
117
|
+
top: 0;
|
|
118
|
+
left: 0;
|
|
119
|
+
/* z-index set inline (100) to ensure header stays above rows wrapper */
|
|
120
|
+
background-color: var(--gp-grid-header-bg);
|
|
121
|
+
border-bottom: 1px solid var(--gp-grid-border);
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
z-index: 11;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.gp-grid-container .gp-grid-header-cell {
|
|
128
|
+
position: absolute;
|
|
129
|
+
box-sizing: border-box;
|
|
130
|
+
border-right: 1px solid var(--gp-grid-border);
|
|
131
|
+
font-weight: 600;
|
|
132
|
+
font-size: 12px;
|
|
133
|
+
text-transform: uppercase;
|
|
134
|
+
letter-spacing: 0.5px;
|
|
135
|
+
color: var(--gp-grid-header-text);
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
user-select: none;
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
padding: 0 12px;
|
|
141
|
+
background-color: transparent;
|
|
142
|
+
transition: background-color 0.1s ease;
|
|
143
|
+
top: 0;
|
|
144
|
+
background: transparent;
|
|
145
|
+
touch-action: none;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.gp-grid-container .gp-grid-header-cell:hover {
|
|
149
|
+
background-color: var(--gp-grid-hover);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.gp-grid-container .gp-grid-header-cell:active {
|
|
153
|
+
background-color: var(--gp-grid-border-light);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.gp-grid-container .gp-grid-header-text {
|
|
157
|
+
flex: 1;
|
|
158
|
+
overflow: hidden;
|
|
159
|
+
text-overflow: ellipsis;
|
|
160
|
+
white-space: nowrap;
|
|
161
|
+
color: var(--gp-grid-header-text);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Header icons container */
|
|
165
|
+
.gp-grid-header-icons {
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
gap: 4px;
|
|
169
|
+
margin-left: auto;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* Stacked sort arrows */
|
|
173
|
+
.gp-grid-sort-arrows {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: row;
|
|
176
|
+
align-items: center;
|
|
177
|
+
gap: 2px;
|
|
178
|
+
margin-left: 6px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.gp-grid-sort-arrows-stack {
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
align-items: center;
|
|
185
|
+
gap: 2px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.gp-grid-sort-arrow-up,
|
|
189
|
+
.gp-grid-sort-arrow-down {
|
|
190
|
+
opacity: 0.35;
|
|
191
|
+
transition: opacity 0.15s ease, color 0.15s ease;
|
|
192
|
+
color: var(--gp-grid-text);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.gp-grid-sort-arrow-up.active,
|
|
196
|
+
.gp-grid-sort-arrow-down.active {
|
|
197
|
+
opacity: 1;
|
|
198
|
+
color: var(--gp-grid-primary);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.gp-grid-sort-index {
|
|
202
|
+
font-size: 9px;
|
|
203
|
+
color: var(--gp-grid-primary);
|
|
204
|
+
font-weight: 600;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* Filter icon */
|
|
208
|
+
.gp-grid-filter-icon {
|
|
209
|
+
display: flex;
|
|
210
|
+
align-items: center;
|
|
211
|
+
justify-content: center;
|
|
212
|
+
width: 20px;
|
|
213
|
+
height: 20px;
|
|
214
|
+
border-radius: 4px;
|
|
215
|
+
cursor: pointer;
|
|
216
|
+
color: var(--gp-grid-text-secondary);
|
|
217
|
+
transition: background-color 0.15s ease, color 0.15s ease;
|
|
218
|
+
margin-left: 2px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.gp-grid-filter-icon:hover {
|
|
222
|
+
background-color: var(--gp-grid-hover);
|
|
223
|
+
color: var(--gp-grid-primary);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.gp-grid-filter-icon.active {
|
|
227
|
+
color: var(--gp-grid-primary);
|
|
228
|
+
background-color: var(--gp-grid-primary-light);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Touch device: larger tap target for filter icon */
|
|
232
|
+
@media (pointer: coarse) and (hover: none) and (max-width: 768px) {
|
|
233
|
+
.gp-grid-filter-icon {
|
|
234
|
+
min-width: 44px;
|
|
235
|
+
min-height: 44px;
|
|
236
|
+
width: 44px;
|
|
237
|
+
height: 44px;
|
|
238
|
+
margin-left: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.gp-grid-filter-icon svg {
|
|
242
|
+
width: 20px;
|
|
243
|
+
height: 20px;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* Disabled header state during data loading */
|
|
248
|
+
.gp-grid-header--loading .gp-grid-header-cell {
|
|
249
|
+
pointer-events: none;
|
|
250
|
+
opacity: 0.6;
|
|
251
|
+
cursor: default;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* =============================================================================
|
|
255
|
+
Column Resize
|
|
256
|
+
============================================================================= */
|
|
257
|
+
|
|
258
|
+
.gp-grid-header-resize-handle {
|
|
259
|
+
position: absolute;
|
|
260
|
+
right: -3px;
|
|
261
|
+
top: 0;
|
|
262
|
+
width: 6px;
|
|
263
|
+
height: 100%;
|
|
264
|
+
cursor: col-resize;
|
|
265
|
+
z-index: 10;
|
|
266
|
+
touch-action: none;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.gp-grid-header-resize-handle:hover,
|
|
270
|
+
.gp-grid-header-resize-handle--active {
|
|
271
|
+
background-color: var(--gp-grid-primary);
|
|
272
|
+
opacity: 0.4;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* Touch device: wider resize handle hit area */
|
|
276
|
+
@media (pointer: coarse) and (hover: none) and (max-width: 768px) {
|
|
277
|
+
.gp-grid-header-resize-handle {
|
|
278
|
+
width: 24px;
|
|
279
|
+
right: -12px;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.gp-grid-column-resize-line {
|
|
284
|
+
position: absolute;
|
|
285
|
+
top: 0;
|
|
286
|
+
width: 2px;
|
|
287
|
+
height: 100%;
|
|
288
|
+
background-color: var(--gp-grid-primary);
|
|
289
|
+
z-index: 1000;
|
|
290
|
+
pointer-events: none;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* =============================================================================
|
|
294
|
+
Column Move
|
|
295
|
+
============================================================================= */
|
|
296
|
+
|
|
297
|
+
.gp-grid-column-move-ghost {
|
|
298
|
+
position: fixed;
|
|
299
|
+
pointer-events: none;
|
|
300
|
+
opacity: 0.7;
|
|
301
|
+
z-index: 2000;
|
|
302
|
+
background-color: var(--gp-grid-header-bg);
|
|
303
|
+
border: 2px solid var(--gp-grid-primary);
|
|
304
|
+
border-radius: 4px;
|
|
305
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
306
|
+
display: flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
padding: 0 12px;
|
|
309
|
+
font-weight: 600;
|
|
310
|
+
font-size: 12px;
|
|
311
|
+
text-transform: uppercase;
|
|
312
|
+
letter-spacing: 0.5px;
|
|
313
|
+
color: var(--gp-grid-header-text);
|
|
314
|
+
box-sizing: border-box;
|
|
315
|
+
overflow: hidden;
|
|
316
|
+
white-space: nowrap;
|
|
317
|
+
text-overflow: ellipsis;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.gp-grid-column-drop-indicator {
|
|
321
|
+
position: absolute;
|
|
322
|
+
top: 0;
|
|
323
|
+
left: 0;
|
|
324
|
+
width: 3px;
|
|
325
|
+
height: 100%;
|
|
326
|
+
background-color: var(--gp-grid-primary);
|
|
327
|
+
z-index: 1000;
|
|
328
|
+
pointer-events: none;
|
|
329
|
+
border-radius: 2px;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
/* =============================================================================
|
|
334
|
+
Data Cells
|
|
335
|
+
============================================================================= */
|
|
336
|
+
|
|
337
|
+
/* Rows wrapper - positions rows with small translateY values for large datasets */
|
|
338
|
+
.gp-grid-rows-wrapper {
|
|
339
|
+
position: absolute;
|
|
340
|
+
top: 0;
|
|
341
|
+
left: 0;
|
|
342
|
+
/* Keep wrapper below the sticky header (z-index: 10) */
|
|
343
|
+
z-index: 1;
|
|
344
|
+
will-change: transform;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.gp-grid-row {
|
|
348
|
+
position: absolute;
|
|
349
|
+
top: 0;
|
|
350
|
+
left: 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/* Row background - :where() for zero specificity, so user highlight classes always win */
|
|
354
|
+
:where(.gp-grid-row) {
|
|
355
|
+
background-color: var(--gp-grid-bg);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/* Structural properties - required for grid layout */
|
|
359
|
+
.gp-grid-cell {
|
|
360
|
+
position: absolute;
|
|
361
|
+
top: 0;
|
|
362
|
+
box-sizing: border-box;
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
overflow: hidden;
|
|
366
|
+
text-overflow: ellipsis;
|
|
367
|
+
white-space: nowrap;
|
|
368
|
+
user-select: none;
|
|
369
|
+
-webkit-user-select: none;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/* Visual properties - :where() for zero specificity, so user highlight classes always win */
|
|
373
|
+
:where(.gp-grid-cell) {
|
|
374
|
+
padding: 0 12px;
|
|
375
|
+
cursor: cell;
|
|
376
|
+
color: var(--gp-grid-text);
|
|
377
|
+
border-right: 1px solid var(--gp-grid-border-light);
|
|
378
|
+
border-bottom: 1px solid var(--gp-grid-border-light);
|
|
379
|
+
background-color: transparent;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* Active cell (focused) - structural properties stay, visual use :where() */
|
|
383
|
+
.gp-grid-cell--active {
|
|
384
|
+
outline: none;
|
|
385
|
+
z-index: 5;
|
|
386
|
+
}
|
|
387
|
+
:where(.gp-grid-cell--active) {
|
|
388
|
+
background-color: var(--gp-grid-primary-light);
|
|
389
|
+
border: 2px solid var(--gp-grid-primary);
|
|
390
|
+
padding: 0 11px;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/* Selected cells (range selection) */
|
|
394
|
+
:where(.gp-grid-cell--selected) {
|
|
395
|
+
background-color: var(--gp-grid-primary-light);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* Editing cell - structural properties stay, visual use :where() */
|
|
399
|
+
.gp-grid-cell--editing {
|
|
400
|
+
z-index: 10;
|
|
401
|
+
}
|
|
402
|
+
:where(.gp-grid-cell--editing) {
|
|
403
|
+
background-color: var(--gp-grid-bg);
|
|
404
|
+
border: 2px solid var(--gp-grid-primary);
|
|
405
|
+
padding: 0;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/* =============================================================================
|
|
409
|
+
Fill Handle (drag to fill)
|
|
410
|
+
============================================================================= */
|
|
411
|
+
|
|
412
|
+
.gp-grid-fill-handle {
|
|
413
|
+
position: absolute;
|
|
414
|
+
width: 8px;
|
|
415
|
+
height: 8px;
|
|
416
|
+
background-color: var(--gp-grid-primary);
|
|
417
|
+
border: 2px solid var(--gp-grid-bg);
|
|
418
|
+
cursor: crosshair;
|
|
419
|
+
z-index: 11;
|
|
420
|
+
pointer-events: auto;
|
|
421
|
+
box-sizing: border-box;
|
|
422
|
+
border-radius: 1px;
|
|
423
|
+
touch-action: none;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.gp-grid-fill-handle:hover {
|
|
427
|
+
transform: scale(1.2);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
@media (pointer: coarse) and (hover: none) and (max-width: 768px) {
|
|
431
|
+
.gp-grid-fill-handle {
|
|
432
|
+
width: 24px;
|
|
433
|
+
height: 24px;
|
|
434
|
+
border-width: 3px;
|
|
435
|
+
border-radius: 3px;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/* Fill preview (cells being filled) */
|
|
440
|
+
.gp-grid-cell.gp-grid-cell--fill-preview {
|
|
441
|
+
background-color: var(--gp-grid-primary-light);
|
|
442
|
+
border: 1px dashed var(--gp-grid-primary);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/* =============================================================================
|
|
446
|
+
Edit Input
|
|
447
|
+
============================================================================= */
|
|
448
|
+
|
|
449
|
+
.gp-grid-edit-input {
|
|
450
|
+
width: 100%;
|
|
451
|
+
height: 100%;
|
|
452
|
+
padding: 0 11px;
|
|
453
|
+
font-family: inherit;
|
|
454
|
+
font-size: inherit;
|
|
455
|
+
color: var(--gp-grid-text);
|
|
456
|
+
border: none;
|
|
457
|
+
background-color: transparent;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.gp-grid-edit-input:focus {
|
|
461
|
+
outline: none;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
/* =============================================================================
|
|
466
|
+
Loading & Error States
|
|
467
|
+
============================================================================= */
|
|
468
|
+
|
|
469
|
+
/* Sticky wrapper: stays pinned at viewport top, takes no layout space */
|
|
470
|
+
.gp-grid-loading-anchor {
|
|
471
|
+
position: sticky;
|
|
472
|
+
top: 0;
|
|
473
|
+
left: 0;
|
|
474
|
+
height: 0;
|
|
475
|
+
z-index: 900;
|
|
476
|
+
overflow: visible;
|
|
477
|
+
pointer-events: none;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/* Semi-transparent overlay covering the visible viewport area */
|
|
481
|
+
.gp-grid-loading-overlay {
|
|
482
|
+
position: absolute;
|
|
483
|
+
top: 0;
|
|
484
|
+
left: 0;
|
|
485
|
+
width: 100%;
|
|
486
|
+
height: 100%;
|
|
487
|
+
pointer-events: none;
|
|
488
|
+
background-color: var(--gp-grid-loading-overlay-bg, rgba(255, 255, 255, 0.4));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.gp-grid-container--dark .gp-grid-loading-overlay {
|
|
492
|
+
background-color: var(--gp-grid-loading-overlay-bg, rgba(0, 0, 0, 0.3));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/* Loading indicator centered in the visible viewport */
|
|
496
|
+
.gp-grid-loading {
|
|
497
|
+
position: absolute;
|
|
498
|
+
top: 50%;
|
|
499
|
+
left: 50%;
|
|
500
|
+
transform: translate(-50%, -50%);
|
|
501
|
+
padding: 12px 20px;
|
|
502
|
+
background-color: var(--gp-grid-loading-bg);
|
|
503
|
+
color: var(--gp-grid-loading-text);
|
|
504
|
+
border-radius: 6px;
|
|
505
|
+
border: 1px solid var(--gp-grid-border);
|
|
506
|
+
font-weight: 500;
|
|
507
|
+
font-size: 13px;
|
|
508
|
+
z-index: 1000;
|
|
509
|
+
display: flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
gap: 10px;
|
|
512
|
+
pointer-events: auto;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.gp-grid-loading-spinner {
|
|
516
|
+
width: 16px;
|
|
517
|
+
height: 16px;
|
|
518
|
+
border: 2px solid var(--gp-grid-border);
|
|
519
|
+
border-top-color: var(--gp-grid-primary);
|
|
520
|
+
border-radius: 50%;
|
|
521
|
+
animation: gp-grid-spin 0.7s linear infinite;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
@keyframes gp-grid-spin {
|
|
525
|
+
to {
|
|
526
|
+
transform: rotate(360deg);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.gp-grid-error {
|
|
531
|
+
position: absolute;
|
|
532
|
+
top: 50%;
|
|
533
|
+
left: 50%;
|
|
534
|
+
transform: translate(-50%, -50%);
|
|
535
|
+
padding: 12px 20px;
|
|
536
|
+
background-color: var(--gp-grid-error-bg);
|
|
537
|
+
color: var(--gp-grid-error-text);
|
|
538
|
+
border-radius: 6px;
|
|
539
|
+
border: 1px solid var(--gp-grid-error-text);
|
|
540
|
+
font-weight: 500;
|
|
541
|
+
font-size: 13px;
|
|
542
|
+
z-index: 1000;
|
|
543
|
+
max-width: 80%;
|
|
544
|
+
text-align: center;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/* =============================================================================
|
|
548
|
+
Empty State
|
|
549
|
+
============================================================================= */
|
|
550
|
+
|
|
551
|
+
.gp-grid-empty {
|
|
552
|
+
position: absolute;
|
|
553
|
+
top: 50%;
|
|
554
|
+
left: 50%;
|
|
555
|
+
transform: translate(-50%, -50%);
|
|
556
|
+
color: var(--gp-grid-text-muted);
|
|
557
|
+
font-size: 14px;
|
|
558
|
+
text-align: center;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
/* =============================================================================
|
|
563
|
+
Scrollbar Styling
|
|
564
|
+
============================================================================= */
|
|
565
|
+
|
|
566
|
+
.gp-grid-container::-webkit-scrollbar {
|
|
567
|
+
width: 8px;
|
|
568
|
+
height: 8px;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.gp-grid-container::-webkit-scrollbar-track {
|
|
572
|
+
background-color: var(--gp-grid-scrollbar-track);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.gp-grid-container::-webkit-scrollbar-thumb {
|
|
576
|
+
background-color: var(--gp-grid-scrollbar-thumb);
|
|
577
|
+
border-radius: 4px;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.gp-grid-container::-webkit-scrollbar-thumb:hover {
|
|
581
|
+
background-color: var(--gp-grid-scrollbar-thumb-hover);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.gp-grid-container::-webkit-scrollbar-corner {
|
|
585
|
+
background-color: var(--gp-grid-scrollbar-track);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
/* =============================================================================
|
|
590
|
+
Filter Popup
|
|
591
|
+
============================================================================= */
|
|
592
|
+
|
|
593
|
+
.gp-grid-filter-popup {
|
|
594
|
+
background-color: var(--gp-grid-bg);
|
|
595
|
+
border: 1px solid var(--gp-grid-border);
|
|
596
|
+
border-radius: 6px;
|
|
597
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
598
|
+
max-height: 400px;
|
|
599
|
+
display: flex;
|
|
600
|
+
flex-direction: column;
|
|
601
|
+
font-size: 13px;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
.gp-grid-filter-header {
|
|
605
|
+
padding: 10px 12px;
|
|
606
|
+
font-weight: 600;
|
|
607
|
+
border-bottom: 1px solid var(--gp-grid-border-light);
|
|
608
|
+
color: var(--gp-grid-header-text);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.gp-grid-filter-content {
|
|
612
|
+
padding: 10px 12px;
|
|
613
|
+
display: flex;
|
|
614
|
+
flex-direction: column;
|
|
615
|
+
gap: 10px;
|
|
616
|
+
overflow: hidden;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/* Mode toggle (Values / Condition) */
|
|
620
|
+
.gp-grid-filter-mode-toggle {
|
|
621
|
+
display: flex;
|
|
622
|
+
gap: 4px;
|
|
623
|
+
background-color: var(--gp-grid-bg-alt);
|
|
624
|
+
border-radius: 4px;
|
|
625
|
+
padding: 2px;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
.gp-grid-filter-mode-toggle button {
|
|
629
|
+
flex: 1;
|
|
630
|
+
padding: 6px 10px;
|
|
631
|
+
font-size: 11px;
|
|
632
|
+
font-family: inherit;
|
|
633
|
+
border: none;
|
|
634
|
+
border-radius: 3px;
|
|
635
|
+
background-color: transparent;
|
|
636
|
+
color: var(--gp-grid-text-secondary);
|
|
637
|
+
cursor: pointer;
|
|
638
|
+
transition: background-color 0.15s ease, color 0.15s ease;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.gp-grid-filter-mode-toggle button:hover {
|
|
642
|
+
color: var(--gp-grid-text);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.gp-grid-filter-mode-toggle button.active {
|
|
646
|
+
background-color: var(--gp-grid-bg);
|
|
647
|
+
color: var(--gp-grid-text);
|
|
648
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/* Info message for too many values */
|
|
652
|
+
.gp-grid-filter-info {
|
|
653
|
+
font-size: 11px;
|
|
654
|
+
color: var(--gp-grid-text-secondary);
|
|
655
|
+
padding: 6px 8px;
|
|
656
|
+
background-color: var(--gp-grid-bg-alt);
|
|
657
|
+
border-radius: 4px;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/* Search input in filter */
|
|
661
|
+
.gp-grid-filter-search {
|
|
662
|
+
width: 100%;
|
|
663
|
+
height: 30px;
|
|
664
|
+
padding: 0 10px;
|
|
665
|
+
font-family: inherit;
|
|
666
|
+
font-size: 12px;
|
|
667
|
+
border: 1px solid var(--gp-grid-input-border);
|
|
668
|
+
border-radius: 4px;
|
|
669
|
+
background-color: var(--gp-grid-input-bg);
|
|
670
|
+
color: var(--gp-grid-text);
|
|
671
|
+
box-sizing: border-box;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.gp-grid-filter-search:focus {
|
|
675
|
+
outline: none;
|
|
676
|
+
border-color: var(--gp-grid-primary);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/* Select All / Deselect All actions */
|
|
680
|
+
.gp-grid-filter-actions {
|
|
681
|
+
display: flex;
|
|
682
|
+
gap: 8px;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.gp-grid-filter-actions button {
|
|
686
|
+
flex: 1;
|
|
687
|
+
padding: 4px 8px;
|
|
688
|
+
font-size: 11px;
|
|
689
|
+
font-family: inherit;
|
|
690
|
+
border: 1px solid var(--gp-grid-input-border);
|
|
691
|
+
border-radius: 3px;
|
|
692
|
+
background-color: var(--gp-grid-bg);
|
|
693
|
+
color: var(--gp-grid-text);
|
|
694
|
+
cursor: pointer;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.gp-grid-filter-actions button:hover:not(:disabled) {
|
|
698
|
+
background-color: var(--gp-grid-hover);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.gp-grid-filter-actions button:disabled {
|
|
702
|
+
opacity: 0.5;
|
|
703
|
+
cursor: not-allowed;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/* Checkbox list */
|
|
707
|
+
.gp-grid-filter-list {
|
|
708
|
+
max-height: 200px;
|
|
709
|
+
overflow-y: auto;
|
|
710
|
+
display: flex;
|
|
711
|
+
flex-direction: column;
|
|
712
|
+
gap: 4px;
|
|
713
|
+
border: 1px solid var(--gp-grid-border-light);
|
|
714
|
+
border-radius: 4px;
|
|
715
|
+
padding: 6px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.gp-grid-filter-option {
|
|
719
|
+
display: flex;
|
|
720
|
+
align-items: center;
|
|
721
|
+
gap: 8px;
|
|
722
|
+
padding: 4px 6px;
|
|
723
|
+
border-radius: 3px;
|
|
724
|
+
cursor: pointer;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.gp-grid-filter-option:hover {
|
|
728
|
+
background-color: var(--gp-grid-hover);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
.gp-grid-filter-option input[type="checkbox"] {
|
|
732
|
+
margin: 0;
|
|
733
|
+
cursor: pointer;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.gp-grid-filter-option span {
|
|
737
|
+
flex: 1;
|
|
738
|
+
overflow: hidden;
|
|
739
|
+
text-overflow: ellipsis;
|
|
740
|
+
white-space: nowrap;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.gp-grid-filter-blank {
|
|
744
|
+
font-style: italic;
|
|
745
|
+
color: var(--gp-grid-text-muted);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/* Filter condition row (for number/date filters) */
|
|
749
|
+
.gp-grid-filter-condition {
|
|
750
|
+
display: flex;
|
|
751
|
+
flex-direction: column;
|
|
752
|
+
gap: 6px;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.gp-grid-filter-row {
|
|
756
|
+
display: flex;
|
|
757
|
+
align-items: center;
|
|
758
|
+
gap: 6px;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
.gp-grid-filter-row select {
|
|
762
|
+
height: 30px;
|
|
763
|
+
padding: 0 6px;
|
|
764
|
+
font-family: inherit;
|
|
765
|
+
font-size: 12px;
|
|
766
|
+
border: 1px solid var(--gp-grid-input-border);
|
|
767
|
+
border-radius: 4px;
|
|
768
|
+
background-color: var(--gp-grid-input-bg);
|
|
769
|
+
color: var(--gp-grid-text);
|
|
770
|
+
cursor: pointer;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.gp-grid-filter-row input[type="number"],
|
|
774
|
+
.gp-grid-filter-row input[type="date"],
|
|
775
|
+
.gp-grid-filter-row input[type="text"],
|
|
776
|
+
.gp-grid-filter-text-input {
|
|
777
|
+
flex: 1;
|
|
778
|
+
height: 30px;
|
|
779
|
+
padding: 0 8px;
|
|
780
|
+
font-family: inherit;
|
|
781
|
+
font-size: 12px;
|
|
782
|
+
border: 1px solid var(--gp-grid-input-border);
|
|
783
|
+
border-radius: 4px;
|
|
784
|
+
background-color: var(--gp-grid-input-bg);
|
|
785
|
+
color: var(--gp-grid-text);
|
|
786
|
+
min-width: 0;
|
|
787
|
+
box-sizing: border-box;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.gp-grid-filter-row input:focus {
|
|
791
|
+
outline: none;
|
|
792
|
+
border-color: var(--gp-grid-primary);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.gp-grid-filter-to {
|
|
796
|
+
font-size: 11px;
|
|
797
|
+
color: var(--gp-grid-text-secondary);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.gp-grid-filter-remove {
|
|
801
|
+
width: 24px;
|
|
802
|
+
height: 24px;
|
|
803
|
+
padding: 0;
|
|
804
|
+
font-size: 16px;
|
|
805
|
+
line-height: 1;
|
|
806
|
+
border: none;
|
|
807
|
+
border-radius: 3px;
|
|
808
|
+
background-color: transparent;
|
|
809
|
+
color: var(--gp-grid-text-muted);
|
|
810
|
+
cursor: pointer;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.gp-grid-filter-remove:hover {
|
|
814
|
+
background-color: var(--gp-grid-error-bg);
|
|
815
|
+
color: var(--gp-grid-error-text);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/* AND/OR combination toggle */
|
|
819
|
+
.gp-grid-filter-combination {
|
|
820
|
+
display: flex;
|
|
821
|
+
gap: 4px;
|
|
822
|
+
margin-bottom: 4px;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
.gp-grid-filter-combination button {
|
|
826
|
+
flex: 1;
|
|
827
|
+
padding: 4px 8px;
|
|
828
|
+
font-size: 10px;
|
|
829
|
+
font-family: inherit;
|
|
830
|
+
border: 1px solid var(--gp-grid-input-border);
|
|
831
|
+
border-radius: 3px;
|
|
832
|
+
background-color: var(--gp-grid-bg);
|
|
833
|
+
color: var(--gp-grid-text-secondary);
|
|
834
|
+
cursor: pointer;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.gp-grid-filter-combination button.active {
|
|
838
|
+
background-color: var(--gp-grid-primary);
|
|
839
|
+
border-color: var(--gp-grid-primary);
|
|
840
|
+
color: #fff;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/* Add condition button */
|
|
844
|
+
.gp-grid-filter-add {
|
|
845
|
+
width: 100%;
|
|
846
|
+
padding: 6px;
|
|
847
|
+
font-size: 11px;
|
|
848
|
+
font-family: inherit;
|
|
849
|
+
border: 1px dashed var(--gp-grid-border);
|
|
850
|
+
border-radius: 4px;
|
|
851
|
+
background-color: transparent;
|
|
852
|
+
color: var(--gp-grid-text-secondary);
|
|
853
|
+
cursor: pointer;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
.gp-grid-filter-add:hover {
|
|
857
|
+
background-color: var(--gp-grid-hover);
|
|
858
|
+
border-color: var(--gp-grid-primary);
|
|
859
|
+
color: var(--gp-grid-primary);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/* Apply / Clear buttons */
|
|
863
|
+
.gp-grid-filter-buttons {
|
|
864
|
+
display: flex;
|
|
865
|
+
gap: 8px;
|
|
866
|
+
padding-top: 8px;
|
|
867
|
+
border-top: 1px solid var(--gp-grid-border-light);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
.gp-grid-filter-btn-clear,
|
|
871
|
+
.gp-grid-filter-btn-apply {
|
|
872
|
+
flex: 1;
|
|
873
|
+
padding: 8px 12px;
|
|
874
|
+
font-size: 12px;
|
|
875
|
+
font-family: inherit;
|
|
876
|
+
border-radius: 4px;
|
|
877
|
+
cursor: pointer;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.gp-grid-filter-btn-clear {
|
|
881
|
+
border: 1px solid var(--gp-grid-input-border);
|
|
882
|
+
background-color: var(--gp-grid-bg);
|
|
883
|
+
color: var(--gp-grid-text);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
.gp-grid-filter-btn-clear:hover {
|
|
887
|
+
background-color: var(--gp-grid-hover);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
.gp-grid-filter-btn-apply {
|
|
891
|
+
border: 1px solid var(--gp-grid-primary);
|
|
892
|
+
background-color: var(--gp-grid-primary);
|
|
893
|
+
color: #fff;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.gp-grid-filter-btn-apply:hover {
|
|
897
|
+
opacity: 0.9;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
/* =============================================================================
|
|
902
|
+
Row Drag
|
|
903
|
+
============================================================================= */
|
|
904
|
+
|
|
905
|
+
.gp-grid-cell--row-drag-handle {
|
|
906
|
+
cursor: grab;
|
|
907
|
+
touch-action: none;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
.gp-grid-cell--row-drag-handle:active {
|
|
911
|
+
cursor: grabbing;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
.gp-grid-row-drag-icon {
|
|
915
|
+
display: flex;
|
|
916
|
+
align-items: center;
|
|
917
|
+
justify-content: center;
|
|
918
|
+
width: 100%;
|
|
919
|
+
height: 100%;
|
|
920
|
+
color: var(--gp-grid-text-secondary);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
.gp-grid-row-drag-icon svg {
|
|
924
|
+
width: 16px;
|
|
925
|
+
height: 16px;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
.gp-grid-row-drag-ghost {
|
|
929
|
+
position: fixed;
|
|
930
|
+
pointer-events: none;
|
|
931
|
+
opacity: 0.8;
|
|
932
|
+
z-index: 2000;
|
|
933
|
+
background-color: var(--gp-grid-bg, #fff);
|
|
934
|
+
border: 2px solid var(--gp-grid-primary);
|
|
935
|
+
border-radius: 4px;
|
|
936
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
937
|
+
overflow: hidden;
|
|
938
|
+
box-sizing: border-box;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
.gp-grid-row-drop-indicator {
|
|
942
|
+
position: absolute;
|
|
943
|
+
left: 0;
|
|
944
|
+
width: 100%;
|
|
945
|
+
height: 3px;
|
|
946
|
+
background-color: var(--gp-grid-primary);
|
|
947
|
+
z-index: 1000;
|
|
948
|
+
pointer-events: none;
|
|
949
|
+
border-radius: 2px;
|
|
950
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gp-grid/react",
|
|
3
3
|
"description": "A high-performance React data grid component with virtual scrolling, cell selection, sorting, filtering, and Excel-like editing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./dist/styles.css": "./dist/styles.css"
|
|
15
|
+
},
|
|
9
16
|
"repository": {
|
|
10
17
|
"type": "git",
|
|
11
18
|
"url": "git+https://github.com/GioPat/gp-grid.git",
|
|
@@ -45,7 +52,7 @@
|
|
|
45
52
|
"link-workspace-packages": false
|
|
46
53
|
},
|
|
47
54
|
"dependencies": {
|
|
48
|
-
"@gp-grid/core": "0.
|
|
55
|
+
"@gp-grid/core": "0.11.0"
|
|
49
56
|
},
|
|
50
57
|
"peerDependencies": {
|
|
51
58
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -60,7 +67,7 @@
|
|
|
60
67
|
"react": "^19.2.0",
|
|
61
68
|
"react-dom": "^19.2.0",
|
|
62
69
|
"tsdown": "^0.20.3",
|
|
63
|
-
"typescript": "
|
|
70
|
+
"typescript": "~5.9.0"
|
|
64
71
|
},
|
|
65
72
|
"scripts": {
|
|
66
73
|
"dev": "tsdown --watch",
|