@warkypublic/oranguru 0.0.47 → 0.0.48
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/lib.cjs.js +2 -2
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.es.js +12 -6
- package/dist/lib.es.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.cjs.js
CHANGED
|
@@ -18,10 +18,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
18
18
|
d="M15 17.5a.5.5 0 0 1-1 0V3.707l-2.146 2.147a.5.5 0 0 1-.708-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L15 3.707zM2.5 16a.5.5 0 0 1 0-1h9a.5.5 0 0 1 0 1zM5 12.5a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 0-1h-6a.5.5 0 0 0-.5.5M8.5 10a.5.5 0 0 1 0-1h3a.5.5 0 0 1 0 1z"
|
|
19
19
|
></path>
|
|
20
20
|
</svg>
|
|
21
|
-
`,fe=r=>d.jsx("img",{alt:r.alt??"Sprite Image",src:`data:image/svg+xml;utf8,${r.sprite({...r,sprite:void 0})}`}),{Provider:Xn,useStore:H}=pe.createSyncStore((r,o)=>({_events:new EventTarget,_loadingList:V.CompactSelection.empty(),_page_data:{},_refresh:async()=>{const e=o();await e.loadPage(0,"all"),await e.refreshCells(),await e.reload?.()},_visibleArea:{height:1e4,width:1e3,x:0,y:0},_visiblePages:{height:0,width:0,x:0,y:0},addError:(e,...t)=>{const n=o();console.log("Gridler Error",n.uniqueid,e,t),r(W.produce(s=>{s.errors=[...s.errors,e]}))},errors:[],get:()=>o(),getCellContent:e=>{const t=o(),[n,s]=e,i=t.getRowBuffer(s);return i!==void 0?t.toCell(i,n):{allowOverlay:!1,kind:V.GridCellKind.Loading}},getCellsForSelection:(e,t)=>async()=>{const n=o();await n.setStateFN("_visibleArea",i=>e);const s=[];for(let i=e.y;i<e.y+e.height;i++){const l=[];for(let a=e.x;a<e.x+e.width;a++)l.push(n.getCellContent([a,i]));s.push(l)}return s},getGridSelectedRows:()=>{const e=o(),t=[],n=e._page_data,s=e.pageSize;if(e._gridSelectionRows)for(const i of e._gridSelectionRows){let l;for(const a in n)for(const f in n[a]){const u=Number(a)*s+Number(f);if(!isNaN(u)){if(Number(n[a][f]?._rownumber)===i+1){l=n[a][f];break}else if(u===i+1){l=n[a][f];break}}}l!==void 0&&t.push(l)}return t},getRowBuffer:e=>{const t=o();if(t.data&&t.data.length>0)return t.data[e]===void 0?{allowOverlay:!1,kind:V.GridCellKind.Loading}:t.data[e];const n=Math.max(0,Math.floor(e/t.pageSize)),s=t.pageSize*n,i=e-s;return t._page_data?.[n]?.[i]},getRowIndexByKey:async e=>{const t=o();if(e==null)return;let n=-1;if(t.ready){const s=t._page_data,i=t.pageSize,l=t.keyField??"id";for(const a in s){for(const f in s[a]){const u=Number(a)*i+Number(f);if(String(s[a][f]?.[l])===String(e)){n=s[a][f]?._rownumber>0?s[a][f]?._rownumber:u>=0?u:-1;break}}if(n>=0)return n}if(n>=0)return n;if(typeof t.askAPIRowNumber=="function"){const a=await t.askAPIRowNumber(String(e));if(a&&a>=0)return a}}},getState:e=>o()[e],hasLocalData:!1,isEmpty:!0,isValuesInPages:()=>{const e=o();if(e.values&&Object.keys(e._page_data).length>0){let t=!1;for(const n in e._page_data){const s=e._page_data[Number(n)];for(const i of s){const l=e.keyField??"id",a=i?.[l];if(a!==void 0&&e.values.find(u=>String(u?.[l])===String(a))){t=!0;break}}if(t)return!0}}return!1},keyField:"id",loadPage:async(e,t)=>{const n=o(),s=e<0?0:e;if(!n._events.dispatchEvent(new CustomEvent("before_loadPage",{detail:{clearMode:t,page:e,state:n}})))return;const l=[],a=Object.keys(n.renderColumns??[1,2,3]).length,f=n.pageSize*s,u=n._page_data?.[s]?.length>0;if(t==="all"){n._active_requests?.forEach(c=>{c.controller?.abort?.()}),n.setState("_page_data",{}),n.setState("_active_requests",[]),n.loadPage(s);return}if(!n.useAPIQuery){console.warn("No useAPIQuery function defined, cannot load page",s);return}!u&&t!=="page"&&n.useAPIQuery?.(s).then(c=>{n.setStateFN("_page_data",m=>({...m,[s]:c}));for(let m=s;m<=f+n.pageSize;m++)for(let g=0;g<=a;g++)l.push({cell:[g,m]});n._glideref?.updateCells(l),n._events.dispatchEvent(new CustomEvent("loadPage",{detail:{clearMode:t,data:c,page:e,state:n}}))}).catch(c=>{console.error("loadPage Error: ",s,c),n._events.dispatchEvent(new CustomEvent("loadPage_error",{detail:{clearMode:t,error:c,page:e,state:n}}))})},maxConcurrency:1,mounted:!1,onCellActivated:e=>{const t=o(),[n,s]=e;t._events.dispatchEvent(new CustomEvent("onCellActivated",{detail:{cell:e,col:n,row:s,state:t}})),t.glideProps?.onCellActivated?.(e)},onCellClicked:(e,t)=>{const n=o(),[s,i]=e,l=n.getRowBuffer(i);n.glideProps?.onCellClicked&&n.glideProps?.onCellClicked?.(e,t),n.values?.length&&n.values?.length>0?n.onChange&&n.onChange(n.values):l&&n.onChange&&n.onChange([l]),n._events.dispatchEvent(new CustomEvent("onCellClicked",{detail:{cell:e,col:s,row:i,state:n}}))},onCellEdited:(e,t)=>{const n=o(),[,s]=e;n._events.dispatchEvent(new CustomEvent("onCellEdited",{detail:{cell:e,newVal:t,row:s,state:n}})),n.glideProps?.onCellEdited?.(e,t)},onColumnMoved:(e,t)=>{const n=o(),s=n.renderColumns?.[e],i=n.renderColumns?.[t];s?.disableMove||i?.disableMove||n.setStateFN("colOrder",l=>{const a=l??n.renderColumns?.map((f,u)=>[f.id,u]).reduce((f,[u,c])=>({...f,[u]:c}),{});return!s?.id||!i?.id?a:{...a,[s?.id]:t,[i?.id]:e}})},onColumnProposeMove:(e,t)=>{const n=o(),s=n.renderColumns?.[e],i=n.renderColumns?.[t];return!(s?.disableMove||i?.disableMove)},onColumnResize:(e,t,n,s)=>{const i=o(),l=i.renderColumns?.find(a=>a.id===e.id);l?.disableResize||l?.maxWidth&&t<l?.maxWidth||l&&i.setStateFN("colSize",a=>a&&l&&a[l.id]===t?a:{...a,[l.id]:t})},onContextClick:(e,t,n,s)=>{const i=o(),l=i.renderColumns?.[n??-1],a=e==="menu"?[{leftSection:d.jsx(G.IconGrid4x4,{size:16}),title:i.title??"Grid"}]:l?[{leftSection:d.jsx(G.IconGrid4x4,{size:16}),title:i.title??"Grid"},{items:[{label:"Sort Ascending",leftSection:d.jsx(fe,{sprite:je}),onClick:()=>{i.setStateFN("colSort",f=>{const u=[...f??[]],c=u.findIndex(g=>g.id===l.id),m="asc";if(c<0){const g={direction:m,id:l.id,order:u?.length};u.push(g)}else c>=0&&(u[c].direction=m);return u})}},{label:"Sort Descending",leftSection:d.jsx(fe,{sprite:Ae}),onClick:()=>{i.setStateFN("colSort",f=>{const u=[...f??[]],c=u.findIndex(g=>g.id===l.id),m="desc";if(c<0){const g={direction:m,id:l.id,order:u?.length};u.push(g)}else c>=0&&(u[c].direction=m);return u})}},{label:`Filter ${l?.title??l?.id}`},{renderer:d.jsx(ke,{column:l,storeState:o()})}],label:`Column Settings for ${l?.title??l?.id}`,leftSection:d.jsx(G.IconGrid4x4,{size:16})}]:[];i.hideMenu?.(e),i.showMenu?.(e,{items:l?.getMenuItems?.(e,i,n&&s?i.getRowBuffer(s):void 0,l,a)??i.getMenuItems?.(e,i,n&&s?i.getRowBuffer(s):void 0,l,a)??a,x:t.clientX??t.bounds?.x,y:t.clientY??t.bounds?.y})},onHeaderClicked:(e,t)=>{const n=o();t.preventDefault();const s=n.renderColumns?.[e];s&&(s.disableSort||n.setStateFN("colSort",i=>{const l=[...i??[]],a=l.findIndex(f=>f.id===s.id);if(a<0){const f={direction:"asc",id:s.id,order:l?.length};l.push(f)}else a>=0&&l[a].direction==="asc"?l[a].direction="desc":a>=0&&l[a].direction==="desc"&&l.splice(a,1);return l}))},onHeaderMenuClick:(e,t)=>{const n=o(),s=n.renderColumns?.[e];if(!s)return;const i=[{label:`Sort ${s?.title??s?.id}`},{label:"Sort Ascending",leftSection:d.jsx(fe,{sprite:je}),onClick:()=>{n.setStateFN("colSort",a=>{const f=[...a??[]],u=f.findIndex(m=>m.id===s.id),c="asc";if(u<0){const m={direction:c,id:s.id,order:f?.length};f.push(m)}else u>=0&&(f[u].direction=c);return f})}},{label:"Sort Descending",leftSection:d.jsx(fe,{sprite:Ae}),onClick:()=>{n.setStateFN("colSort",a=>{const f=[...a??[]],u=f.findIndex(m=>m.id===s.id),c="desc";if(u<0){const m={direction:c,id:s.id,order:f?.length};f.push(m)}else u>=0&&(f[u].direction=c);return f})}},{isDivider:!0}],l=[...s.disableSort?[]:i,{label:`Filter ${s?.title??s?.id}`},{renderer:d.jsx(ke,{column:s,storeState:o()})},{isDivider:!0},{id:"refesh",label:"Refresh",onClick:()=>{o()._refresh?.()}}];n.hideMenu?.("header-menu"),n.showMenu?.("header-menu",{items:s?.getMenuItems?.("header-menu",n,void 0,s,l)??n.getMenuItems?.("header-menu",n,void 0,s,l),x:t.x,y:t.y})},onItemHovered:e=>{const t=o();if(t.setState("_activeTooltip",void 0),e.kind==="cell"){const n=t.renderColumns?.[e.location[0]];if(n?.tooltip&&typeof n?.tooltip=="string")t.setState("_activeTooltip",n?.tooltip);else if(n?.tooltip&&typeof n?.tooltip=="function"){const s=t.getRowBuffer(e.location[1]);t.setState("_activeTooltip",n?.tooltip(s,e.location[1],e.location[0]))}}},onVisibleRegionChanged:(e,t,n,s)=>{const i=o();i._scrollTimeout&&clearTimeout(i._scrollTimeout);const l=()=>{const a=o(),f=Math.max(0,Math.floor(e.y/a.pageSize)),u=Math.max(0,Math.floor(a._visiblePages.y/a.pageSize)),c=f-u;if(a.progressiveScroll&&c>1){const m=o(),g=(u+2)*m.pageSize*(m.rowHeight??22);m._glideref?.scrollTo(0,{amount:g,unit:"px"},"vertical");return}a.setState("_visiblePages",e)};i.setState("_scrollTimeout",setTimeout(()=>{l()},100))},pageSize:50,ready:!1,refreshCells:(e,t,n)=>{const s=o(),i=[],l=Object.keys(s.renderColumns??[1,2,3]).length,a=e&&e>0?e:0,f=t&&t>=a?t:a+s.pageSize;for(let u=a;u<=f;u++)if(n&&n>0)i.push({cell:[n,u]});else for(let c=0;c<=l;c++)i.push({cell:[c,u]});s._glideref?.updateCells(i)},setState:(e,t)=>{r(W.produce(n=>{n[e]=t}))},setStateFN:(e,t)=>new Promise((s,i)=>{r(W.produce(l=>{if(typeof t=="function")l[e]=t(l[e]);else throw i(new Error(`Not a function ${t}`)),Error(`Not a function ${t}`)})),s()}),toCell:(e,t)=>{const n=o(),i=n.renderColumns?.[t],l=i?.id??i?.title??String(t);if(l==null||e===void 0||e===null)return i?.Cell?i?.Cell(e,t,l,void 0,n):n.RenderCell?n.RenderCell(e,t,l,void 0,n):{allowOverlay:!1,kind:V.GridCellKind.Loading};try{const a=String(l).includes(".")?Un(l,e)??"":e?.[l];return i?.Cell?{kind:V.GridCellKind.Text,...i?.Cell(e,t,l,a,n)}:n.RenderCell?n.RenderCell(e,t,l,a,n):{allowOverlay:!0,data:a??"",displayData:String(a??""),kind:V.GridCellKind.Text}}catch{return n.RenderCell?n.RenderCell(e,t,l,e?.[l??""],n):{allowOverlay:!1,kind:V.GridCellKind.Loading,skeletonWidthVariability:50}}},total_rows:1e3,uniqueid:Te.getUUID()}),r=>{const[o,e]=r.useStore(n=>[n.setState,n.getState]),t=Fe();return p.useEffect(()=>{const n=e("onMounted");if(typeof n=="function"&&n(e,o),o("mounted",!0),window&&window.document&&!window.document.getElementById("portal")){const i=window.document.createElement("div");i.id="portal",i.setAttribute("data-gridler-portal",r.uniqueid),window.document.body.appendChild(i)}return e("_events").dispatchEvent(new CustomEvent("mounted",{detail:{}})),()=>{const s=e("onUnMounted");o("mounted",!1),e("_events").dispatchEvent(new CustomEvent("unmounted",{detail:{}})),typeof s=="function"&&s()}},[o,e]),e("_events").addEventListener("reload",n=>{e("_refresh")?.()}),{...r,colSort:r.defaultSort??e("colSort")??[],hideMenu:r.hideMenu??t.hide,scrollToRowKey:r.scrollToRowKey??r.selectedRowKey??e("scrollToRowKey"),showMenu:r.showMenu??t.show,total_rows:e("total_rows")??r.total_rows}});function Qn(r){const[o,e,t,n,s]=H(a=>[a.setStateFN,a.setState,a.getState,a.addError,a.mounted]),i=p.useCallback(async a=>{const f=t("columns"),u=t("colSort"),c=t("pageSize"),m=t("colFilters"),g=t("searchStr"),S=t("searchFields"),b=t("_active_requests"),E=t("keyField");e("loadingData",!0);try{if(r&&r.url){const R=new Headers;R.set("Authorization",`Token ${r.authtoken}`);const _=[{type:"limit",value:String(c??50)},{type:"offset",value:String((c??50)*a)}];u?.length&&u.length>0&&_.push({type:"sort",value:u?.map(v=>`${v.id} ${v.direction}`).reduce((v,O)=>`${v},${O}`)}),m?.filter(v=>v.value?.length>0)?.forEach(v=>{v.value&&v.value!==""&&_.push({name:`${v.id}`,op:v.operator,type:"searchop",value:v.value})}),g&&g!==""&&f?.filter(v=>!v.disableFilter&&!v.disableSearch&&!v.virtual&&v.id&&((S??[]).length==0||S?.includes(v.id)))?.forEach(v=>{_.push({name:`${v.id??""}`,op:"contains",type:"searchor",value:g})}),r.filter&&r.filter!==""&&_.push({name:"sql_filter",type:"custom-sql-w",value:r.filter}),(r.options??[]).length>0&&_.push(...r.options??[]);const I=f?.filter(v=>!v.virtual)?.map(v=>v.id)??[];if(r.hotfields&&r.hotfields.length>0&&I?.push(r.hotfields.join(",")),E&&(I.includes(E)||I.push(E)),I&&I.length>0&&_.push({type:"select-fields",value:I.join(",")}),_&&_.length>0){const v=re(_);for(const O in re(_))R.set(O,v[O])}const k=b?.findIndex(v=>v.page===a)??-1;if(b?.forEach(v=>{(v.page>=0&&v.page<a-2||a>=0&&v.page>a+2)&&v.controller?.abort?.()}),b&&k>=0&&b[k]){e("loadingData",!1);return}const B=new AbortController;await o("_active_requests",v=>[...v??[],{controller:B,page:a}]);const x=await fetch(`${r.url}?x-limit=${String(c??50)}&x-offset=${String((c??50)*a)}`,{headers:R,method:"GET",signal:B?.signal});if(x.ok){const v=x.headers.get("Content-Range")?.split("/");v?.[1]&&parseInt(v[1],10)>0&&e("total_rows",parseInt(v[1],10));const O=await x.json();return e("loadingData",!1),O??[]}n(`${x.status} ${x.statusText}`,"api",r.url),await o("_active_requests",v=>[...(v??[]).filter(O=>O.page!==a)])}}catch{}return e("loadingData",!1),[]},[t,r.authtoken,r.url,r.filter,JSON.stringify(r.options),e,o,n]),l=p.useCallback(async a=>{const f=t("colFilters");if(!a||a===""||!r.url)return null;if(r&&r.url){const u=new Headers,c=[{type:"limit",value:String(10)},{type:"fetch-rownumber",value:a}];if(u.set("Authorization",`Token ${r.authtoken}`),f?.length&&f.length>0&&f?.filter(S=>S.value?.length>0)?.forEach(S=>{S.value&&S.value!==""&&u.set(`x-searchop-${S.operator}-${S.id}`,`${S.value}`)}),r.filter&&r.filter!==""&&c.push({name:"sql_filter",type:"custom-sql-w",value:`(${r.filter})`}),r.options&&r.options.length>0){const S=re(r.options);for(const b in S)u.set(b,S[b])}if(c&&c.length>0){const S=re(c);for(const b in re(c))u.set(b,S[b])}const m=new AbortController,g=await fetch(`${r.url}?x-fetch-rownumber=${a}`,{headers:u,method:"GET",signal:m?.signal});if(g.ok){const S=await g.json();return S?.[0]?._rownumber??S?._rownumber??0}n(`${g.status} ${g.statusText}`,"api",r.url)}return[]},[r.url,r.authtoken,r.filter,r.options,t,n]);return p.useEffect(()=>{e("useAPIQuery",i),e("askAPIRowNumber",l);const a=t("isValuesInPages"),f=t("_refresh");a||e("values",[]),f?.().then(()=>{const u=t("onChange"),c=t("getGridSelectedRows");if(u&&typeof u=="function"){const m=c?.();u(m)}})},[r.url,r.authtoken,r.filter,JSON.stringify(r.options),s,e]),d.jsx(d.Fragment,{})}const bt=p.memo(Qn);bt.displayName="Gridler-GlidlerAPIAdaptorForGoLangv2";function wt(r){const[o,e,t,n]=H(i=>[i.getState,i.mounted,i.setState,i._events]);p.useEffect(()=>{if(e&&r.changeOnActiveClick){const i=l=>{const{row:a,state:f}=l.detail,u=f.getRowBuffer;if(u){const c=u(a);if(!c)return;r.onRequestForm("change",c)}};return n?.addEventListener("onCellActivated",i),()=>{i&&n?.removeEventListener("onCellActivated",i)}}},[r.changeOnActiveClick,e,n]);const s=p.useCallback((i,l,a,f,u)=>{if(i==="header-menu")return u||[];const c=[];c.push(...u);const m=o("_gridSelection")?.rows.toArray()??[],g=m.length>1;if(!a){const E=m[0];E!==void 0&&(a=l.getRowBuffer(E))}const S=typeof r.descriptionField=="string"?a?.[r.descriptionField]:typeof r.descriptionField=="function"&&a?r.descriptionField(a):void 0;(i==="other"||i==="cell"&&!a)&&c.push({c:"blue",label:"Add",onClick:()=>{r.onRequestForm("insert",a)}}),i==="cell"&&a||i==="menu"&&a?(c.push({c:"teal",label:"Add",leftSection:d.jsx(G.IconSquarePlus,{color:"teal",size:16}),onClick:()=>{r.onRequestForm("insert",a)}}),g?(c.push({c:"green",label:`Modify All Selected (${m.length})`,leftSection:d.jsx(G.IconEdit,{color:"green",size:16}),onClick:()=>{r.onRequestForm("change",m.map(E=>l.getRowBuffer(E)))}}),c.push({c:"red",label:`Remove All Selected (${m.length})`,leftSection:d.jsx(G.IconTrashX,{color:"maroon",size:16}),onClick:()=>{r.onRequestForm("delete",m.map(E=>l.getRowBuffer(E)))}})):(c.push({c:"green",label:`Modify${S&&r.showDescriptionInMenu?` (${S})`:""}`,leftSection:d.jsx(G.IconEdit,{color:"green",size:16}),onClick:()=>{r.onRequestForm("change",a)}}),c.push({c:"red",label:`Remove${S&&r.showDescriptionInMenu?` (${S})`:""}`,leftSection:d.jsx(G.IconTrashX,{color:"maroon",size:16}),onClick:()=>{r.onRequestForm("delete",a)}})),c.push({isDivider:!0})):(i==="cell"&&!a||i==="menu"&&!a)&&c.push({c:"red",label:"Nothing Selected",leftSection:d.jsx(G.IconExclamationMark,{color:"yellow",size:16})}),c.push({c:"orange",label:"Refresh",leftSection:d.jsx(G.IconRefresh,{color:"orange",size:16}),onClickAsync:async()=>{await o("_refresh")?.()}});const b=r.getMenuItems?r.getMenuItems(i,l,a,f,c):c;return!c||c.length===0?u||[]:b},[r.onRequestForm,o]);return p.useEffect(()=>(e&&typeof t=="function"&&o("getMenuItems")!==s&&t("getMenuItems",s),()=>{}),[r.getMenuItems,e]),d.jsx(d.Fragment,{})}function Zn(r){const[o,e,t]=H(u=>[u.setState,u.getState,u.mounted]),{colFilters:n,colSort:s,columns:i,searchStr:l}=H(u=>({colFilters:u.colFilters,colOrder:u.colOrder,colSize:u.colSize,colSort:u.colSort,columns:u.columns,searchStr:u.searchStr})),a=p.useRef({colFilters:n,colSort:s,searchStr:l}),f=async u=>{const c=e("pageSize");return r.data&&Array.isArray(r.data)?(o("total_rows",r.data.length),r.data.slice(u*(c??50),(u+1)*(c??50))):[]};return p.useEffect(()=>{o("useAPIQuery",f)},[t,o]),p.useEffect(()=>{if(r.onColumnSort&&s!==a?.current?.colSort){const u=r.onColumnSort(s,i,r.data);o("total_rows",u.length),o("data",u),a.current.colSort=s,e("refreshCells")?.()}},[s,r.onColumnSort]),p.useEffect(()=>{if(r.onColumnFilter&&n!==a?.current?.colFilters){const u=r.onColumnFilter(n,i,r.data);o("total_rows",u.length),o("data",u),a.current.colFilters=n,e("refreshCells")?.()}},[n,r.onColumnFilter]),p.useEffect(()=>{if(r.onSearch&&l!==a?.current?.searchStr){const u=r.onSearch(l,i,r.data);o("total_rows",u.length),o("data",u),a.current.colFilters=n,e("refreshCells")?.()}},[l,r.onSearch]),d.jsx(d.Fragment,{})}const Me=p.memo(Zn);Me.displayName="Gridler-GlidlerLocalDataAdaptor";function xt(){const{loadingData:r,onContextClick:o}=H(e=>({loadingData:e.loadingData,onContextClick:e.onContextClick}));return d.jsx(w.ActionIcon,{loading:r,mr:"xs",mt:"2px",onClick:e=>o("menu",e),variant:"subtle",children:d.jsx(G.IconMenu2,{})})}function er(r,o){const[e,t]=H(n=>[n.setStateFN,n.getState]);return p.useImperativeHandle(o,()=>({getGlideRef:()=>t("_glideref"),getState:t,isEmpty:()=>t("isEmpty"),refresh:async n=>{const s=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{s?.()})},reload:async n=>{const s=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{s?.()})},reloadRow:async n=>{const s=t("refreshCells"),l=await t("getRowIndexByKey")?.(String(n));l&&l>=0&&s?.(l,l+1)},scrollToRow:async n=>{n&&Number(n)>=0&&e("scrollToRowKey",s=>Number(n??s))},selectRow:async n=>{n&&Number(n)>=0&&e("selectedRowKey",s=>Number(n??s))},setStateFN:e}),[]),d.jsx(d.Fragment,{children:r.children})}const tr=p.forwardRef(er);function nr(){const{_activeTooltip:r,tooltipBarProps:o}=H(e=>({_activeTooltip:e._activeTooltip,tooltipBarProps:e.tooltipBarProps}));return d.jsx("div",{"data-tooltip-bar":!0,style:{minHeight:"24px"},...o,children:r})}const Ct=p.memo(()=>{const r=p.useRef(0),o=p.useRef(""),e=p.useRef(null),{_glideref:t,_gridSelectionRows:n,colFilters:s,colOrder:i,colSize:l,colSort:a,columns:f,getRowIndexByKey:u,getState:c,loadPage:m,ready:g,scrollToRowKey:S,searchStr:b,selectedRowKey:E,selectFirstRowOnMount:R,setState:_,setStateFN:I,values:k}=H(x=>({_glideref:x._glideref,_gridSelectionRows:x._gridSelectionRows,colFilters:x.colFilters,colOrder:x.colOrder,colSize:x.colSize,colSort:x.colSort,columns:x.columns,getRowIndexByKey:x.getRowIndexByKey,getState:x.getState,loadPage:x.loadPage,ready:x.ready,scrollToRowKey:x.scrollToRowKey,searchStr:x.searchStr,selectedRowKey:x.selectedRowKey,selectFirstRowOnMount:x.selectFirstRowOnMount,setState:x.setState,setStateFN:x.setStateFN,uniqueid:x.uniqueid,values:x.values})),B=ie.useDebouncedCallback(x=>{m(0,"all").then(()=>{c("refreshCells")?.(),c("_events")?.dispatchEvent?.(new CustomEvent("onSearched",{detail:{search:x}}))})},{delay:300,leading:!1});return p.useEffect(()=>{k&&(async v=>{const O=c("keyField")??"id",P=[];for(const N in v){const z=String(typeof v?.[N]=="object"?v?.[N]?.[O]:typeof v?.[N]=="string"?v?.[N]:void 0);if(!z)continue;const D=await u(z);D!=null&&P.push(D)}return P})(k).then(v=>{let O=V.CompactSelection.empty();v.forEach(P=>{P!==void 0&&(O=O.add(P))}),I("_gridSelectionRows",()=>O),I("_gridSelection",P=>({columns:P?.columns??V.CompactSelection.empty(),...P,rows:O}))})},[k]),p.useEffect(()=>{const x=c("onChange");if(x&&typeof x=="function"){const O=c("getGridSelectedRows")(),P=c("values");JSON.stringify(P)!==JSON.stringify(O)&&x(O)}},[n,n?.length,c]),p.useEffect(()=>{_("renderColumns",f?.map(x=>({...x,hasMenu:x?.hasMenu??!0,icon:"sort"})))},[f]),p.useEffect(()=>{if(b==null){o.current="";return}o.current!==b&&(B(b),o.current=b)},[b]),p.useEffect(()=>{a&&(_("_gridSelection",{columns:V.CompactSelection.empty(),current:void 0,rows:V.CompactSelection.empty()}),_("_gridSelectionRows",V.CompactSelection.empty()),I("renderColumns",x=>x?.map(v=>({...v,icon:v.id&&a?.find(O=>O.id===v.id)?.direction?a?.find(O=>O.id===v.id)?.direction==="asc"?"sortup":"sortdown":v.defaultIcon??"sort"}))).then(()=>{m(0,"all").then(()=>{c("refreshCells")?.(),c("_events")?.dispatchEvent?.(new CustomEvent("onColumnSorted",{detail:{cols:a}}))})}))},[a]),p.useEffect(()=>{s&&JSON.stringify(e.current)!==JSON.stringify(s)&&(m(0,"all").then(()=>{c("refreshCells")?.(),c("_events")?.dispatchEvent?.(new CustomEvent("onColumnFiltered",{detail:{filters:s}}))}),e.current=s)},[s]),p.useEffect(()=>{l&&I("renderColumns",x=>x?.map(v=>({...v,width:v.id&&l?.[v.id]?l?.[v.id]:v.width}))).then(()=>{c("refreshCells")?.()})},[l]),p.useEffect(()=>{i&&I("renderColumns",x=>x?.sort((O,P)=>i[O.id]>i[P.id]?1:-1)).then(()=>{c("refreshCells")?.()})},[i]),p.useEffect(()=>{t&&(r.current>0||(r.current=1,m(0).then(()=>{c("refreshCells")?.()})))},[g,m]),p.useEffect(()=>{const x=c("_events"),v=()=>{const O=c("selectFirstRowOnMount");if(c("ready")&&O){const N=c("scrollToRowKey");if(N&&N>=0)return;const z=c("keyField")??"id",F=c("_page_data")?.[0]?.[0],U=F?.[z]??-1,q=c("values")??[];if(!F)return;if(U&&U>0&&(q.length??0)===0){const j=[F],J=c("onChange");J?J(j):_("values",j),_("scrollToRowKey",U)}}};return x?.addEventListener("loadPage",v),()=>{x?.removeEventListener("loadPage",v)}},[g,R,k]),p.useEffect(()=>{const x=c("ready"),v=c("_glideref"),O=c("getRowIndexByKey"),P=E??S;P&&v&&x&&O?.(P).then(N=>{if(N!==void 0){if(E){const z=c("onChange"),D=[{[c("keyField")??"id"]:E}];JSON.stringify(c("values"))!==JSON.stringify(D)&&(z?z(D):_("values",D))}v.scrollTo(0,N),c("_events").dispatchEvent(new CustomEvent("scrollToRowKeyFound",{detail:{rowNumber:N,scrollToRowKey:S,selectedRowKey:E}}))}})},[S,E]),d.jsx(d.Fragment,{})});Ct.displayName="Gridler-Computer";function rr(r,o,e=1){let t;if(o===void 0?(t=0,o=r):t=r,e===0)throw new Error("Step cannot be zero");const n=[];if(e>0)for(let s=t;s<o;s+=e)n.push(s);else for(let s=t;s>o;s+=e)n.push(s);return n}const _t=p.memo(()=>{const[r,o,e,t,n,s,i,l]=H(a=>[a.setState,a.getState,a._glideref,a._visiblePages,a.pageSize,a.loadPage,a._loadingList,a.hasLocalData]);return p.useEffect(()=>{e&&r("mounted",!0)},[r]),p.useEffect(()=>{if(!e)return;const a=Math.max(0,Math.floor(t.y/n)),f=Math.floor((t.y+t.height)/n);for(const u of rr(a,f+1,1))s(u).then(()=>{const c=o("_page_data")?.[0]??{};r("isEmpty",c&&c.length>0)})},[s,n,t,e,i,l]),d.jsx(d.Fragment,{})});_t.displayName="Gridler-Pager";const or=r=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none">
|
|
21
|
+
`,fe=r=>d.jsx("img",{alt:r.alt??"Sprite Image",src:`data:image/svg+xml;utf8,${r.sprite({...r,sprite:void 0})}`}),{Provider:Xn,useStore:H}=pe.createSyncStore((r,o)=>({_events:new EventTarget,_loadingList:V.CompactSelection.empty(),_page_data:{},_refresh:async()=>{const e=o();await e.loadPage(0,"all"),await e.refreshCells(),await e.reload?.()},_visibleArea:{height:1e4,width:1e3,x:0,y:0},_visiblePages:{height:0,width:0,x:0,y:0},addError:(e,...t)=>{const n=o();console.log("Gridler Error",n.uniqueid,e,t),r(W.produce(s=>{s.errors=[...s.errors,e]}))},errors:[],get:()=>o(),getCellContent:e=>{const t=o(),[n,s]=e,i=t.getRowBuffer(s);return i!==void 0?t.toCell(i,n):{allowOverlay:!1,kind:V.GridCellKind.Loading}},getCellsForSelection:(e,t)=>async()=>{const n=o();await n.setStateFN("_visibleArea",i=>e);const s=[];for(let i=e.y;i<e.y+e.height;i++){const l=[];for(let a=e.x;a<e.x+e.width;a++)l.push(n.getCellContent([a,i]));s.push(l)}return s},getGridSelectedRows:()=>{const e=o(),t=[],n=e._page_data,s=e.pageSize;if(e._gridSelectionRows)for(const i of e._gridSelectionRows){let l;for(const a in n)for(const f in n[a]){const u=Number(a)*s+Number(f);if(!isNaN(u)){if(Number(n[a][f]?._rownumber)===i+1){l=n[a][f];break}else if(u===i+1){l=n[a][f];break}}}l!==void 0&&t.push(l)}return t},getRowBuffer:e=>{const t=o();if(t.data&&t.data.length>0)return t.data[e]===void 0?{allowOverlay:!1,kind:V.GridCellKind.Loading}:t.data[e];const n=Math.max(0,Math.floor(e/t.pageSize)),s=t.pageSize*n,i=e-s;return t._page_data?.[n]?.[i]},getRowIndexByKey:async e=>{const t=o();if(e==null)return;let n=-1;if(t.ready){const s=t._page_data,i=t.pageSize,l=t.keyField??"id";for(const a in s){for(const f in s[a]){const u=Number(a)*i+Number(f);if(String(s[a][f]?.[l])===String(e)){n=s[a][f]?._rownumber>0?s[a][f]?._rownumber:u>=0?u:-1;break}}if(n>=0)return n}if(n>=0)return n;if(typeof t.askAPIRowNumber=="function"){const a=await t.askAPIRowNumber(String(e));if(a&&a>=0)return a}}},getState:e=>o()[e],hasLocalData:!1,isEmpty:!0,isValuesInPages:()=>{const e=o();if(e.values&&Object.keys(e._page_data).length>0){let t=!1;for(const n in e._page_data){const s=e._page_data[Number(n)];for(const i of s){const l=e.keyField??"id",a=i?.[l];if(a!==void 0&&e.values.find(u=>String(u?.[l])===String(a))){t=!0;break}}if(t)return!0}}return!1},keyField:"id",loadPage:async(e,t)=>{const n=o(),s=e<0?0:e;if(!n._events.dispatchEvent(new CustomEvent("before_loadPage",{detail:{clearMode:t,page:e,state:n}})))return;const l=[],a=Object.keys(n.renderColumns??[1,2,3]).length,f=n.pageSize*s,u=n._page_data?.[s]?.length>0;if(t==="all"){n._active_requests?.forEach(c=>{c.controller?.abort?.()}),n.setState("_page_data",{}),n.setState("_active_requests",[]),n.loadPage(s);return}if(!n.useAPIQuery){console.warn("No useAPIQuery function defined, cannot load page",s);return}!u&&t!=="page"&&n.useAPIQuery?.(s).then(c=>{n.setStateFN("_page_data",m=>({...m,[s]:c}));for(let m=s;m<=f+n.pageSize;m++)for(let g=0;g<=a;g++)l.push({cell:[g,m]});n._glideref?.updateCells(l),n._events.dispatchEvent(new CustomEvent("loadPage",{detail:{clearMode:t,data:c,page:e,state:n}}))}).catch(c=>{console.error("loadPage Error: ",s,c),n._events.dispatchEvent(new CustomEvent("loadPage_error",{detail:{clearMode:t,error:c,page:e,state:n}}))})},maxConcurrency:1,mounted:!1,onCellActivated:e=>{const t=o(),[n,s]=e;t._events.dispatchEvent(new CustomEvent("onCellActivated",{detail:{cell:e,col:n,row:s,state:t}})),t.glideProps?.onCellActivated?.(e)},onCellClicked:(e,t)=>{const n=o(),[s,i]=e,l=n.getRowBuffer(i);n.glideProps?.onCellClicked&&n.glideProps?.onCellClicked?.(e,t),n.values?.length&&n.values?.length>0?n.onChange&&n.onChange(n.values):l&&n.onChange&&n.onChange([l]),n._events.dispatchEvent(new CustomEvent("onCellClicked",{detail:{cell:e,col:s,row:i,state:n}}))},onCellEdited:(e,t)=>{const n=o(),[,s]=e;n._events.dispatchEvent(new CustomEvent("onCellEdited",{detail:{cell:e,newVal:t,row:s,state:n}})),n.glideProps?.onCellEdited?.(e,t)},onColumnMoved:(e,t)=>{const n=o(),s=n.renderColumns?.[e],i=n.renderColumns?.[t];s?.disableMove||i?.disableMove||n.setStateFN("colOrder",l=>{const a=l??n.renderColumns?.map((f,u)=>[f.id,u]).reduce((f,[u,c])=>({...f,[u]:c}),{});return!s?.id||!i?.id?a:{...a,[s?.id]:t,[i?.id]:e}})},onColumnProposeMove:(e,t)=>{const n=o(),s=n.renderColumns?.[e],i=n.renderColumns?.[t];return!(s?.disableMove||i?.disableMove)},onColumnResize:(e,t,n,s)=>{const i=o(),l=i.renderColumns?.find(a=>a.id===e.id);l?.disableResize||l?.maxWidth&&t<l?.maxWidth||l&&i.setStateFN("colSize",a=>a&&l&&a[l.id]===t?a:{...a,[l.id]:t})},onContextClick:(e,t,n,s)=>{const i=o(),l=i.renderColumns?.[n??-1],a=e==="menu"?[{leftSection:d.jsx(G.IconGrid4x4,{size:16}),title:i.title??"Grid"}]:l?[{leftSection:d.jsx(G.IconGrid4x4,{size:16}),title:i.title??"Grid"},{items:[{label:"Sort Ascending",leftSection:d.jsx(fe,{sprite:je}),onClick:()=>{i.setStateFN("colSort",f=>{const u=[...f??[]],c=u.findIndex(g=>g.id===l.id),m="asc";if(c<0){const g={direction:m,id:l.id,order:u?.length};u.push(g)}else c>=0&&(u[c].direction=m);return u})}},{label:"Sort Descending",leftSection:d.jsx(fe,{sprite:Ae}),onClick:()=>{i.setStateFN("colSort",f=>{const u=[...f??[]],c=u.findIndex(g=>g.id===l.id),m="desc";if(c<0){const g={direction:m,id:l.id,order:u?.length};u.push(g)}else c>=0&&(u[c].direction=m);return u})}},{label:`Filter ${l?.title??l?.id}`},{renderer:d.jsx(ke,{column:l,storeState:o()})}],label:`Column Settings for ${l?.title??l?.id}`,leftSection:d.jsx(G.IconGrid4x4,{size:16})}]:[];i.hideMenu?.(e),i.showMenu?.(e,{items:l?.getMenuItems?.(e,i,n&&s?i.getRowBuffer(s):void 0,l,a)??i.getMenuItems?.(e,i,n&&s?i.getRowBuffer(s):void 0,l,a)??a,x:t.clientX??t.bounds?.x,y:t.clientY??t.bounds?.y})},onHeaderClicked:(e,t)=>{const n=o();t.preventDefault();const s=n.renderColumns?.[e];s&&(s.disableSort||n.setStateFN("colSort",i=>{const l=[...i??[]],a=l.findIndex(f=>f.id===s.id);if(a<0){const f={direction:"asc",id:s.id,order:l?.length};l.push(f)}else a>=0&&l[a].direction==="asc"?l[a].direction="desc":a>=0&&l[a].direction==="desc"&&l.splice(a,1);return l}))},onHeaderMenuClick:(e,t)=>{const n=o(),s=n.renderColumns?.[e];if(!s)return;const i=[{label:`Sort ${s?.title??s?.id}`},{label:"Sort Ascending",leftSection:d.jsx(fe,{sprite:je}),onClick:()=>{n.setStateFN("colSort",a=>{const f=[...a??[]],u=f.findIndex(m=>m.id===s.id),c="asc";if(u<0){const m={direction:c,id:s.id,order:f?.length};f.push(m)}else u>=0&&(f[u].direction=c);return f})}},{label:"Sort Descending",leftSection:d.jsx(fe,{sprite:Ae}),onClick:()=>{n.setStateFN("colSort",a=>{const f=[...a??[]],u=f.findIndex(m=>m.id===s.id),c="desc";if(u<0){const m={direction:c,id:s.id,order:f?.length};f.push(m)}else u>=0&&(f[u].direction=c);return f})}},{isDivider:!0}],l=[...s.disableSort?[]:i,{label:`Filter ${s?.title??s?.id}`},{renderer:d.jsx(ke,{column:s,storeState:o()})},{isDivider:!0},{id:"refesh",label:"Refresh",onClick:()=>{o()._refresh?.()}}];n.hideMenu?.("header-menu"),n.showMenu?.("header-menu",{items:s?.getMenuItems?.("header-menu",n,void 0,s,l)??n.getMenuItems?.("header-menu",n,void 0,s,l),x:t.x,y:t.y})},onItemHovered:e=>{const t=o();if(t.setState("_activeTooltip",void 0),e.kind==="cell"){const n=t.renderColumns?.[e.location[0]];if(n?.tooltip&&typeof n?.tooltip=="string")t.setState("_activeTooltip",n?.tooltip);else if(n?.tooltip&&typeof n?.tooltip=="function"){const s=t.getRowBuffer(e.location[1]);t.setState("_activeTooltip",n?.tooltip(s,e.location[1],e.location[0]))}}},onVisibleRegionChanged:(e,t,n,s)=>{const i=o();i._scrollTimeout&&clearTimeout(i._scrollTimeout);const l=()=>{const a=o(),f=Math.max(0,Math.floor(e.y/a.pageSize)),u=Math.max(0,Math.floor(a._visiblePages.y/a.pageSize)),c=f-u;if(a.progressiveScroll&&c>1){const m=o(),g=(u+2)*m.pageSize*(m.rowHeight??22);m._glideref?.scrollTo(0,{amount:g,unit:"px"},"vertical");return}a.setState("_visiblePages",e)};i.setState("_scrollTimeout",setTimeout(()=>{l()},100))},pageSize:50,ready:!1,refreshCells:(e,t,n)=>{const s=o(),i=[],l=Object.keys(s.renderColumns??[1,2,3]).length,a=e&&e>0?e:0,f=t&&t>=a?t:a+s.pageSize;for(let u=a;u<=f;u++)if(n&&n>0)i.push({cell:[n,u]});else for(let c=0;c<=l;c++)i.push({cell:[c,u]});s._glideref?.updateCells(i)},setState:(e,t)=>{r(W.produce(n=>{n[e]=t}))},setStateFN:(e,t)=>new Promise((s,i)=>{r(W.produce(l=>{if(typeof t=="function")l[e]=t(l[e]);else throw i(new Error(`Not a function ${t}`)),Error(`Not a function ${t}`)})),s()}),toCell:(e,t)=>{const n=o(),i=n.renderColumns?.[t],l=i?.id??i?.title??String(t);if(l==null||e===void 0||e===null)return i?.Cell?i?.Cell(e,t,l,void 0,n):n.RenderCell?n.RenderCell(e,t,l,void 0,n):{allowOverlay:!1,kind:V.GridCellKind.Loading};try{const a=String(l).includes(".")?Un(l,e)??"":e?.[l];return i?.Cell?{kind:V.GridCellKind.Text,...i?.Cell(e,t,l,a,n)}:n.RenderCell?n.RenderCell(e,t,l,a,n):{allowOverlay:!0,data:a??"",displayData:String(a??""),kind:V.GridCellKind.Text}}catch{return n.RenderCell?n.RenderCell(e,t,l,e?.[l??""],n):{allowOverlay:!1,kind:V.GridCellKind.Loading,skeletonWidthVariability:50}}},total_rows:1e3,uniqueid:Te.getUUID()}),r=>{const[o,e]=r.useStore(n=>[n.setState,n.getState]),t=Fe();return p.useEffect(()=>{const n=e("onMounted");if(typeof n=="function"&&n(e,o),o("mounted",!0),window&&window.document&&!window.document.getElementById("portal")){const i=window.document.createElement("div");i.id="portal",i.setAttribute("data-gridler-portal",r.uniqueid),window.document.body.appendChild(i)}return e("_events").dispatchEvent(new CustomEvent("mounted",{detail:{}})),()=>{const s=e("onUnMounted");o("mounted",!1),e("_events").dispatchEvent(new CustomEvent("unmounted",{detail:{}})),typeof s=="function"&&s()}},[o,e]),e("_events").addEventListener("reload",n=>{e("_refresh")?.()}),{...r,colSort:r.defaultSort??e("colSort")??[],hideMenu:r.hideMenu??t.hide,scrollToRowKey:r.scrollToRowKey??r.selectedRowKey??e("scrollToRowKey"),showMenu:r.showMenu??t.show,total_rows:e("total_rows")??r.total_rows}});function Qn(r){const[o,e,t,n,s]=H(a=>[a.setStateFN,a.setState,a.getState,a.addError,a.mounted]),i=p.useCallback(async a=>{const f=t("columns"),u=t("colSort"),c=t("pageSize"),m=t("colFilters"),g=t("searchStr"),S=t("searchFields"),b=t("_active_requests"),E=t("keyField");e("loadingData",!0);try{if(r&&r.url){const R=new Headers;R.set("Authorization",`Token ${r.authtoken}`);const _=[{type:"limit",value:String(c??50)},{type:"offset",value:String((c??50)*a)}];u?.length&&u.length>0&&_.push({type:"sort",value:u?.map(v=>`${v.id} ${v.direction}`).reduce((v,O)=>`${v},${O}`)}),m?.filter(v=>v.value?.length>0)?.forEach(v=>{v.value&&v.value!==""&&_.push({name:`${v.id}`,op:v.operator,type:"searchop",value:v.value})}),g&&g!==""&&f?.filter(v=>!v.disableFilter&&!v.disableSearch&&!v.virtual&&v.id&&((S??[]).length==0||S?.includes(v.id)))?.forEach(v=>{_.push({name:`${v.id??""}`,op:"contains",type:"searchor",value:g})}),r.filter&&r.filter!==""&&_.push({name:"sql_filter",type:"custom-sql-w",value:r.filter}),(r.options??[]).length>0&&_.push(...r.options??[]);const I=f?.filter(v=>!v.virtual)?.map(v=>v.id)??[];if(r.hotfields&&r.hotfields.length>0&&I?.push(r.hotfields.join(",")),E&&(I.includes(E)||I.push(E)),I&&I.length>0&&_.push({type:"select-fields",value:I.join(",")}),_&&_.length>0){const v=re(_);for(const O in re(_))R.set(O,v[O])}const k=b?.findIndex(v=>v.page===a)??-1;if(b?.forEach(v=>{(v.page>=0&&v.page<a-2||a>=0&&v.page>a+2)&&v.controller?.abort?.()}),b&&k>=0&&b[k]){e("loadingData",!1);return}const B=new AbortController;await o("_active_requests",v=>[...v??[],{controller:B,page:a}]);const x=await fetch(`${r.url}?x-limit=${String(c??50)}&x-offset=${String((c??50)*a)}`,{headers:R,method:"GET",signal:B?.signal});if(x.ok){const v=x.headers.get("Content-Range")?.split("/");v?.[1]&&parseInt(v[1],10)>0&&e("total_rows",parseInt(v[1],10));const O=await x.json();return e("loadingData",!1),O??[]}n(`${x.status} ${x.statusText}`,"api",r.url),await o("_active_requests",v=>[...(v??[]).filter(O=>O.page!==a)])}}catch{}return e("loadingData",!1),[]},[t,r.authtoken,r.url,r.filter,JSON.stringify(r.options),e,o,n]),l=p.useCallback(async a=>{const f=t("colFilters");if(!a||a===""||!r.url)return null;if(r&&r.url){const u=new Headers,c=[{type:"limit",value:String(10)},{type:"fetch-rownumber",value:a}];if(u.set("Authorization",`Token ${r.authtoken}`),f?.length&&f.length>0&&f?.filter(S=>S.value?.length>0)?.forEach(S=>{S.value&&S.value!==""&&u.set(`x-searchop-${S.operator}-${S.id}`,`${S.value}`)}),r.filter&&r.filter!==""&&c.push({name:"sql_filter",type:"custom-sql-w",value:`(${r.filter})`}),r.options&&r.options.length>0){const S=re(r.options);for(const b in S)u.set(b,S[b])}if(c&&c.length>0){const S=re(c);for(const b in re(c))u.set(b,S[b])}const m=new AbortController,g=await fetch(`${r.url}?x-fetch-rownumber=${a}`,{headers:u,method:"GET",signal:m?.signal});if(g.ok){const S=await g.json();return S?.[0]?._rownumber??S?._rownumber??0}n(`${g.status} ${g.statusText}`,"api",r.url)}return[]},[r.url,r.authtoken,r.filter,JSON.stringify(r.options),t,n]);return p.useEffect(()=>{e("useAPIQuery",i),e("askAPIRowNumber",l);const a=t("isValuesInPages"),f=t("_refresh");a||e("values",[]),f?.().then(()=>{const u=t("onChange"),c=t("getGridSelectedRows");if(u&&typeof u=="function"){const m=c?.();u(m)}})},[r.url,r.authtoken,r.filter,JSON.stringify(r.options),s,e]),d.jsx(d.Fragment,{})}const bt=p.memo(Qn);bt.displayName="Gridler-GlidlerAPIAdaptorForGoLangv2";function wt(r){const[o,e,t,n]=H(i=>[i.getState,i.mounted,i.setState,i._events]);p.useEffect(()=>{if(e&&r.changeOnActiveClick){const i=l=>{const{row:a,state:f}=l.detail,u=f.getRowBuffer;if(u){const c=u(a);if(!c)return;r.onRequestForm("change",c)}};return n?.addEventListener("onCellActivated",i),()=>{i&&n?.removeEventListener("onCellActivated",i)}}},[r.changeOnActiveClick,e,n]);const s=p.useCallback((i,l,a,f,u)=>{if(i==="header-menu")return u||[];const c=[];c.push(...u);const m=o("_gridSelection")?.rows.toArray()??[],g=m.length>1;if(!a){const E=m[0];E!==void 0&&(a=l.getRowBuffer(E))}const S=typeof r.descriptionField=="string"?a?.[r.descriptionField]:typeof r.descriptionField=="function"&&a?r.descriptionField(a):void 0;(i==="other"||i==="cell"&&!a)&&c.push({c:"blue",label:"Add",onClick:()=>{r.onRequestForm("insert",a)}}),i==="cell"&&a||i==="menu"&&a?(c.push({c:"teal",label:"Add",leftSection:d.jsx(G.IconSquarePlus,{color:"teal",size:16}),onClick:()=>{r.onRequestForm("insert",a)}}),g?(c.push({c:"green",label:`Modify All Selected (${m.length})`,leftSection:d.jsx(G.IconEdit,{color:"green",size:16}),onClick:()=>{r.onRequestForm("change",m.map(E=>l.getRowBuffer(E)))}}),c.push({c:"red",label:`Remove All Selected (${m.length})`,leftSection:d.jsx(G.IconTrashX,{color:"maroon",size:16}),onClick:()=>{r.onRequestForm("delete",m.map(E=>l.getRowBuffer(E)))}})):(c.push({c:"green",label:`Modify${S&&r.showDescriptionInMenu?` (${S})`:""}`,leftSection:d.jsx(G.IconEdit,{color:"green",size:16}),onClick:()=>{r.onRequestForm("change",a)}}),c.push({c:"red",label:`Remove${S&&r.showDescriptionInMenu?` (${S})`:""}`,leftSection:d.jsx(G.IconTrashX,{color:"maroon",size:16}),onClick:()=>{r.onRequestForm("delete",a)}})),c.push({isDivider:!0})):(i==="cell"&&!a||i==="menu"&&!a)&&c.push({c:"red",label:"Nothing Selected",leftSection:d.jsx(G.IconExclamationMark,{color:"yellow",size:16})}),c.push({c:"orange",label:"Refresh",leftSection:d.jsx(G.IconRefresh,{color:"orange",size:16}),onClickAsync:async()=>{await o("_refresh")?.()}});const b=r.getMenuItems?r.getMenuItems(i,l,a,f,c):c;return!c||c.length===0?u||[]:b},[r.onRequestForm,o]);return p.useEffect(()=>(e&&typeof t=="function"&&o("getMenuItems")!==s&&t("getMenuItems",s),()=>{}),[r.getMenuItems,e]),d.jsx(d.Fragment,{})}function Zn(r){const[o,e,t]=H(u=>[u.setState,u.getState,u.mounted]),{colFilters:n,colSort:s,columns:i,searchStr:l}=H(u=>({colFilters:u.colFilters,colOrder:u.colOrder,colSize:u.colSize,colSort:u.colSort,columns:u.columns,searchStr:u.searchStr})),a=p.useRef({colFilters:n,colSort:s,searchStr:l}),f=async u=>{const c=e("pageSize");return r.data&&Array.isArray(r.data)?(o("total_rows",r.data.length),r.data.slice(u*(c??50),(u+1)*(c??50))):[]};return p.useEffect(()=>{o("useAPIQuery",f)},[t,o]),p.useEffect(()=>{if(r.onColumnSort&&s!==a?.current?.colSort){const u=r.onColumnSort(s,i,r.data);o("total_rows",u.length),o("data",u),a.current.colSort=s,e("refreshCells")?.()}},[s,r.onColumnSort]),p.useEffect(()=>{if(r.onColumnFilter&&n!==a?.current?.colFilters){const u=r.onColumnFilter(n,i,r.data);o("total_rows",u.length),o("data",u),a.current.colFilters=n,e("refreshCells")?.()}},[n,r.onColumnFilter]),p.useEffect(()=>{if(r.onSearch&&l!==a?.current?.searchStr){const u=r.onSearch(l,i,r.data);o("total_rows",u.length),o("data",u),a.current.colFilters=n,e("refreshCells")?.()}},[l,r.onSearch]),d.jsx(d.Fragment,{})}const Me=p.memo(Zn);Me.displayName="Gridler-GlidlerLocalDataAdaptor";function xt(){const{loadingData:r,onContextClick:o}=H(e=>({loadingData:e.loadingData,onContextClick:e.onContextClick}));return d.jsx(w.ActionIcon,{loading:r,mr:"xs",mt:"2px",onClick:e=>o("menu",e),variant:"subtle",children:d.jsx(G.IconMenu2,{})})}function er(r,o){const[e,t]=H(n=>[n.setStateFN,n.getState]);return p.useImperativeHandle(o,()=>({getGlideRef:()=>t("_glideref"),getState:t,isEmpty:()=>t("isEmpty"),refresh:async n=>{const s=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{s?.()})},reload:async n=>{const s=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{s?.()})},reloadRow:async n=>{const s=t("refreshCells"),l=await t("getRowIndexByKey")?.(String(n));l&&l>=0&&s?.(l,l+1)},scrollToRow:async n=>{n&&Number(n)>=0&&e("scrollToRowKey",s=>Number(n??s))},selectRow:async n=>{n&&Number(n)>=0&&e("selectedRowKey",s=>Number(n??s))},setStateFN:e}),[]),d.jsx(d.Fragment,{children:r.children})}const tr=p.forwardRef(er);function nr(){const{_activeTooltip:r,tooltipBarProps:o}=H(e=>({_activeTooltip:e._activeTooltip,tooltipBarProps:e.tooltipBarProps}));return d.jsx("div",{"data-tooltip-bar":!0,style:{minHeight:"24px"},...o,children:r})}const Ct=p.memo(()=>{const r=p.useRef(0),o=p.useRef(""),e=p.useRef(null),{_glideref:t,_gridSelectionRows:n,colFilters:s,colOrder:i,colSize:l,colSort:a,columns:f,getRowIndexByKey:u,getState:c,loadPage:m,ready:g,scrollToRowKey:S,searchStr:b,selectedRowKey:E,selectFirstRowOnMount:R,setState:_,setStateFN:I,values:k}=H(x=>({_glideref:x._glideref,_gridSelectionRows:x._gridSelectionRows,colFilters:x.colFilters,colOrder:x.colOrder,colSize:x.colSize,colSort:x.colSort,columns:x.columns,getRowIndexByKey:x.getRowIndexByKey,getState:x.getState,loadPage:x.loadPage,ready:x.ready,scrollToRowKey:x.scrollToRowKey,searchStr:x.searchStr,selectedRowKey:x.selectedRowKey,selectFirstRowOnMount:x.selectFirstRowOnMount,setState:x.setState,setStateFN:x.setStateFN,uniqueid:x.uniqueid,values:x.values})),B=ie.useDebouncedCallback(x=>{m(0,"all").then(()=>{c("refreshCells")?.(),c("_events")?.dispatchEvent?.(new CustomEvent("onSearched",{detail:{search:x}}))})},{delay:300,leading:!1});return p.useEffect(()=>{k&&(async v=>{const O=c("keyField")??"id",P=[];for(const N in v){const z=String(typeof v?.[N]=="object"?v?.[N]?.[O]:typeof v?.[N]=="string"?v?.[N]:void 0);if(!z)continue;const D=await u(z);D!=null&&P.push(D)}return P})(k).then(v=>{let O=V.CompactSelection.empty();v.forEach(P=>{P!==void 0&&(O=O.add(P))}),I("_gridSelectionRows",()=>O),I("_gridSelection",P=>({columns:P?.columns??V.CompactSelection.empty(),...P,rows:O}))})},[k]),p.useEffect(()=>{const x=c("onChange");if(x&&typeof x=="function"){const O=c("getGridSelectedRows")(),P=c("values");JSON.stringify(P)!==JSON.stringify(O)&&x(O)}},[n,n?.length,c]),p.useEffect(()=>{_("renderColumns",f?.map(x=>({...x,hasMenu:x?.hasMenu??!0,icon:"sort"})))},[f]),p.useEffect(()=>{if(b==null){o.current="";return}o.current!==b&&(B(b),o.current=b)},[b]),p.useEffect(()=>{a&&(_("_gridSelection",{columns:V.CompactSelection.empty(),current:void 0,rows:V.CompactSelection.empty()}),_("_gridSelectionRows",V.CompactSelection.empty()),I("renderColumns",x=>x?.map(v=>({...v,icon:v.id&&a?.find(O=>O.id===v.id)?.direction?a?.find(O=>O.id===v.id)?.direction==="asc"?"sortup":"sortdown":v.defaultIcon??"sort"}))).then(()=>{m(0,"all").then(()=>{c("refreshCells")?.(),c("_events")?.dispatchEvent?.(new CustomEvent("onColumnSorted",{detail:{cols:a}}))})}))},[a]),p.useEffect(()=>{s&&JSON.stringify(e.current)!==JSON.stringify(s)&&(m(0,"all").then(()=>{c("refreshCells")?.(),c("_events")?.dispatchEvent?.(new CustomEvent("onColumnFiltered",{detail:{filters:s}}))}),e.current=s)},[s]),p.useEffect(()=>{l&&I("renderColumns",x=>x?.map(v=>({...v,width:v.id&&l?.[v.id]?l?.[v.id]:v.width}))).then(()=>{c("refreshCells")?.()})},[l]),p.useEffect(()=>{i&&I("renderColumns",x=>x?.sort((O,P)=>i[O.id]>i[P.id]?1:-1)).then(()=>{c("refreshCells")?.()})},[i]),p.useEffect(()=>{if(t){if(r.current>0){c("refreshCells")?.();return}r.current=1,m(0).then(()=>{c("refreshCells")?.()})}},[g,m]),p.useEffect(()=>{const x=c("_events"),v=()=>{const O=c("selectFirstRowOnMount");if(c("ready")&&O){const N=c("scrollToRowKey");if(N&&N>=0)return;const z=c("keyField")??"id",F=c("_page_data")?.[0]?.[0],U=F?.[z]??-1,q=c("values")??[];if(!F)return;if(U&&U>0&&(q.length??0)===0){const j=[F],J=c("onChange");J?J(j):_("values",j),_("scrollToRowKey",U)}}};return x?.addEventListener("loadPage",v),()=>{x?.removeEventListener("loadPage",v)}},[g,R,k]),p.useEffect(()=>{const x=c("ready"),v=c("_glideref"),O=c("getRowIndexByKey"),P=E??S;P&&v&&x&&O?.(P).then(N=>{if(N!==void 0){if(E){const z=c("onChange"),D=[{[c("keyField")??"id"]:E}];JSON.stringify(c("values"))!==JSON.stringify(D)&&(z?z(D):_("values",D))}v.scrollTo(0,N),c("_events").dispatchEvent(new CustomEvent("scrollToRowKeyFound",{detail:{rowNumber:N,scrollToRowKey:S,selectedRowKey:E}}))}})},[S,E]),d.jsx(d.Fragment,{})});Ct.displayName="Gridler-Computer";function rr(r,o,e=1){let t;if(o===void 0?(t=0,o=r):t=r,e===0)throw new Error("Step cannot be zero");const n=[];if(e>0)for(let s=t;s<o;s+=e)n.push(s);else for(let s=t;s>o;s+=e)n.push(s);return n}const _t=p.memo(()=>{const[r,o,e,t,n,s,i,l]=H(a=>[a.setState,a.getState,a._glideref,a._visiblePages,a.pageSize,a.loadPage,a._loadingList,a.hasLocalData]);return p.useEffect(()=>{e&&r("mounted",!0)},[r]),p.useEffect(()=>{if(!e)return;const a=Math.max(0,Math.floor(t.y/n)),f=Math.floor((t.y+t.height)/n);for(const u of rr(a,f+1,1))s(u).then(()=>{const c=o("_page_data")?.[0]??{};r("isEmpty",c&&c.length>0)})},[s,n,t,e,i,l]),d.jsx(d.Fragment,{})});_t.displayName="Gridler-Pager";const or=r=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none">
|
|
22
22
|
<path
|
|
23
23
|
fill="${r.fgColor??"currentColor"}"
|
|
24
24
|
d="M2.22 9.967L7.97 4.22l.085-.074l.058-.038l.072-.039l.105-.04l.105-.022l.052-.005L8.5 4l.057.002l.092.013l.107.03l.085.037l.054.03l.063.044l.072.064l5.75 5.747a.75.75 0 0 1-.976 1.133l-.084-.072L9.25 6.56v16.69a.75.75 0 0 1-1.493.102l-.007-.102V6.56l-4.47 4.468a.75.75 0 0 1-.976.072l-.084-.072a.75.75 0 0 1-.073-.977zM19.5 4a.75.75 0 0 1 .743.648l.007.102v16.687l4.47-4.467l.084-.073a.75.75 0 0 1 1.049 1.05l-.073.083l-5.728 5.727a.75.75 0 0 1-1.031.07l-.073-.07l-5.728-5.727l-.073-.084a.75.75 0 0 1-.007-.882l.08-.094l.084-.073a.75.75 0 0 1 .882-.007l.094.08l4.47 4.469V4.75l.007-.102A.75.75 0 0 1 19.5 4"
|
|
25
25
|
></path>
|
|
26
|
-
</svg>`,sr="_container_1nbyf_1",ir={container:sr},lr=r=>o=>o%2===0?void 0:{bgCell:r==="dark"?"#303030":"#e1effc"},ar=()=>{const r=w.useMantineTheme(),{colorScheme:o}=w.useMantineColorScheme(),{enableOddEvenRowColor:e,focused:t}=H(c=>({enableOddEvenRowColor:c.enableOddEvenRowColor,focused:c.focused})),n={auto:t?w.lighten(r.colors.blue[4],.9):"#ffffff",dark:t?w.darken("#bacfe0",.2):r.colors.dark[7],light:t?w.lighten(r.colors.blue[4],.8):"#ffffff"}[o],s={accentColor:"none",accentLight:r.colors.blue[9],baseFontStyle:"13px",bgBubble:"#212121",bgBubbleSelected:"#000000",bgCell:n,bgCellMedium:"#202027",bgHeader:"#2A2A2A",bgHeaderHasFocus:"#181818",bgHeaderHovered:"#404040",bgIconHeader:"#b8b8b8",bgSearchResult:"#423c24",borderColor:"#eee1",drilldownBorder:"rgba(225,225,225,0.4)",fgIconHeader:"#000000",fontFamily:"Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif",headerFontStyle:"500 13px",linkColor:r.colors.blue[4],textBubble:"#ffffff",textDark:"#dedede",textGroupHeader:"#dedede",textHeader:"#a1a1a1",textHeaderSelected:"#000000",textLight:"#a0a0a0",textMedium:"#b8b8b8"},l=o==="dark"?s:{bgCell:n,textGroupHeader:"#2c5491"},[a,f]=p.useState(l);return p.useEffect(()=>{f(l)},[o,t]),{getRowThemeOverride:c=>e?lr(o)(c):void 0,gridTheme:a}},cr=()=>{const r=p.useRef(null),o=p.useRef(!1),{height:e,ref:t,width:n}=ie.useElementSize({box:"content-box"}),{_gridSelection:s,allowMultiSelect:i,focused:l,getCellContent:a,getCellsForSelection:f,getState:u,glideProps:c,hasLocalData:m,headerHeight:g,heightProp:S,mounted:b,onCellActivated:E,onCellClicked:R,onCellEdited:_,onColumnMoved:I,onColumnProposeMove:k,onColumnResize:B,onContextClick:x,onHeaderClicked:v,onHeaderMenuClick:O,onItemHovered:P,onVisibleRegionChanged:N,renderColumns:z,rowHeight:D,sections:F,selectMode:U,setState:q,setStateFN:j,total_rows:J,widthProp:Y}=H(h=>({_gridSelection:h._gridSelection,allowMultiSelect:h.allowMultiSelect,focused:h.focused,getCellContent:h.getCellContent,getCellsForSelection:h.getCellsForSelection,getState:h.getState,glideProps:h.glideProps,hasLocalData:h.hasLocalData,headerHeight:h.headerHeight,heightProp:h.height,mounted:h.mounted,onCellActivated:h.onCellActivated,onCellClicked:h.onCellClicked,onCellEdited:h.onCellEdited,onColumnMoved:h.onColumnMoved,onColumnProposeMove:h.onColumnProposeMove,onColumnResize:h.onColumnResize,onContextClick:h.onContextClick,onHeaderClicked:h.onHeaderClicked,onHeaderMenuClick:h.onHeaderMenuClick,onItemHovered:h.onItemHovered,onVisibleRegionChanged:h.onVisibleRegionChanged,renderColumns:h.renderColumns,rowHeight:h.rowHeight,sections:h.sections,selectMode:h.selectMode,setState:h.setState,setStateFN:h.setStateFN,total_rows:h.total_rows,widthProp:h.width})),Q=ie.useMergedRef(r,h=>{j("_glideref",()=>h??void 0)});p.useEffect(()=>{r.current&&b?u("ready")||q("ready",!0):u("ready")&&q("ready",!1)},[b,u,q]);const K=ar();return d.jsxs(w.Stack,{align:"stretch",gap:0,h:S??"100%",justify:"stretch",w:Y??"100%",children:[F?.top,d.jsxs("div",{className:ir.container,"data-focused":l,onContextMenu:h=>{h.preventDefault(),o.current||(o.current=!0,x("other",h),setTimeout(()=>{o.current=!1},100))},ref:t,style:{display:"flex",height:"100%",minHeight:"64px",minWidth:"32px",width:"100%"},children:[F?.left,n&&n>0&&e&&e>0&&d.jsx(V.DataEditor,{cellActivationBehavior:"double-click",columns:z??[],columnSelect:"none",drawFocusRing:!0,height:e
|
|
26
|
+
</svg>`,sr="_container_1nbyf_1",ir={container:sr},lr=r=>o=>o%2===0?void 0:{bgCell:r==="dark"?"#303030":"#e1effc"},ar=()=>{const r=w.useMantineTheme(),{colorScheme:o}=w.useMantineColorScheme(),{enableOddEvenRowColor:e,focused:t}=H(c=>({enableOddEvenRowColor:c.enableOddEvenRowColor,focused:c.focused})),n={auto:t?w.lighten(r.colors.blue[4],.9):"#ffffff",dark:t?w.darken("#bacfe0",.2):r.colors.dark[7],light:t?w.lighten(r.colors.blue[4],.8):"#ffffff"}[o],s={accentColor:"none",accentLight:r.colors.blue[9],baseFontStyle:"13px",bgBubble:"#212121",bgBubbleSelected:"#000000",bgCell:n,bgCellMedium:"#202027",bgHeader:"#2A2A2A",bgHeaderHasFocus:"#181818",bgHeaderHovered:"#404040",bgIconHeader:"#b8b8b8",bgSearchResult:"#423c24",borderColor:"#eee1",drilldownBorder:"rgba(225,225,225,0.4)",fgIconHeader:"#000000",fontFamily:"Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif",headerFontStyle:"500 13px",linkColor:r.colors.blue[4],textBubble:"#ffffff",textDark:"#dedede",textGroupHeader:"#dedede",textHeader:"#a1a1a1",textHeaderSelected:"#000000",textLight:"#a0a0a0",textMedium:"#b8b8b8"},l=o==="dark"?s:{bgCell:n,textGroupHeader:"#2c5491"},[a,f]=p.useState(l);return p.useEffect(()=>{f(l)},[o,t]),{getRowThemeOverride:c=>e?lr(o)(c):void 0,gridTheme:a}},cr=()=>{const r=p.useRef(null),o=p.useRef(!1),{height:e,ref:t,width:n}=ie.useElementSize({box:"content-box"}),{_gridSelection:s,allowMultiSelect:i,focused:l,getCellContent:a,getCellsForSelection:f,getState:u,glideProps:c,hasLocalData:m,headerHeight:g,heightProp:S,mounted:b,onCellActivated:E,onCellClicked:R,onCellEdited:_,onColumnMoved:I,onColumnProposeMove:k,onColumnResize:B,onContextClick:x,onHeaderClicked:v,onHeaderMenuClick:O,onItemHovered:P,onVisibleRegionChanged:N,renderColumns:z,rowHeight:D,sections:F,selectMode:U,setState:q,setStateFN:j,total_rows:J,widthProp:Y}=H(h=>({_gridSelection:h._gridSelection,allowMultiSelect:h.allowMultiSelect,focused:h.focused,getCellContent:h.getCellContent,getCellsForSelection:h.getCellsForSelection,getState:h.getState,glideProps:h.glideProps,hasLocalData:h.hasLocalData,headerHeight:h.headerHeight,heightProp:h.height,mounted:h.mounted,onCellActivated:h.onCellActivated,onCellClicked:h.onCellClicked,onCellEdited:h.onCellEdited,onColumnMoved:h.onColumnMoved,onColumnProposeMove:h.onColumnProposeMove,onColumnResize:h.onColumnResize,onContextClick:h.onContextClick,onHeaderClicked:h.onHeaderClicked,onHeaderMenuClick:h.onHeaderMenuClick,onItemHovered:h.onItemHovered,onVisibleRegionChanged:h.onVisibleRegionChanged,renderColumns:h.renderColumns,rowHeight:h.rowHeight,sections:h.sections,selectMode:h.selectMode,setState:h.setState,setStateFN:h.setStateFN,total_rows:h.total_rows,widthProp:h.width})),Q=ie.useMergedRef(r,h=>{j("_glideref",()=>h??void 0)});p.useEffect(()=>{r.current&&b?u("ready")||q("ready",!0):u("ready")&&q("ready",!1)},[b,u,q]);const K=ar();return d.jsxs(w.Stack,{align:"stretch",gap:0,h:S??"100%",justify:"stretch",w:Y??"100%",children:[F?.top,d.jsxs("div",{className:ir.container,"data-focused":l,onContextMenu:h=>{h.preventDefault(),o.current||(o.current=!0,x("other",h),setTimeout(()=>{o.current=!1},100))},ref:t,style:{display:"flex",height:"100%",minHeight:"64px",minWidth:"32px",width:"100%"},children:[F?.left,n&&n>0&&e&&e>0&&d.jsx(V.DataEditor,{cellActivationBehavior:"double-click",columns:z??[],columnSelect:"none",drawFocusRing:!0,height:e||400,overscrollX:16,overscrollY:32,rangeSelect:i?"multi-rect":"cell",rightElementProps:{fill:!1,sticky:!0},rowMarkers:{checkboxStyle:"square",kind:i?"both":"clickable-number"},rowSelect:i?"multi":"single",rowSelectionMode:"auto",spanRangeBehavior:"default",...c,getCellContent:a,getCellsForSelection:f,getRowThemeOverride:K.getRowThemeOverride,gridSelection:s,headerHeight:g??32,headerIcons:{sort:or,sortdown:Ae,sortup:je},onCellActivated:E,onCellClicked:R,onCellContextMenu:(h,C)=>{C.preventDefault(),c?.onCellContextMenu?.(h,C),o.current||(o.current=!0,x("cell",C,h[0],h[1]),setTimeout(()=>{o.current=!1},100))},onCellEdited:_,onColumnMoved:I,onColumnProposeMove:k,onColumnResize:B,onGridSelectionChange:h=>{let C=V.CompactSelection.empty();const A=u("_gridSelection"),y=u("keyField")??"id",$=u("getRowBuffer");for(const M of h.rows)$&&$(M)?.[y]&&(C=C.hasIndex(M)?C:C.add(M));if(U==="row"&&h.current?.range)for(let M=h.current.range.y;M<h.current.range.y+h.current.range.height;M++)$&&$(M)?.[y]&&(C=C.hasIndex(M)?C:C.add(M));if(C.length===0)for(const M of A?.rows??[])$&&$(M)?.[y]&&(C=C.hasIndex(M)?C:C.add(M));(JSON.stringify(A?.columns)!==JSON.stringify(h.columns)||JSON.stringify(A?.rows)!==JSON.stringify(C)||JSON.stringify(A?.current)!==JSON.stringify(h.current))&&(q("_gridSelection",{...h,rows:C}),q("_gridSelectionRows",C))},onHeaderClicked:v,onHeaderContextMenu:(h,C)=>{C.preventDefault(),o.current||(o.current=!0,x("header",C,h),setTimeout(()=>{o.current=!1},100))},onHeaderMenuClick:O,onItemHovered:P,onVisibleRegionChanged:N,ref:Q,rightElement:F?.rightElementDisabled?void 0:d.jsxs(w.Group,{children:[F?.rightElementStart,d.jsx(xt,{}),F?.rightElementEnd]}),rowHeight:D??22,rows:J??0,theme:K.gridTheme,width:n||200}),d.jsx(Ct,{}),!m&&d.jsx(_t,{}),F?.right]}),d.jsxs("div",{style:{flexGrow:0},children:[d.jsx(nr,{}),F?.bottom]})]})},ur=(r,o)=>d.jsx(pt,{children:d.jsxs(Xn,{...r,persist:{name:`Gridler_${r.uniqueid}`,partialize:e=>({colOrder:e.colOrder,colSize:e.colSize}),version:1},children:[d.jsx(cr,{}),d.jsx(tr,{ref:o}),r.children]})}),Pe=p.forwardRef(ur);Pe.FormAdaptor=wt;Pe.LocalDataAdaptor=Me;exports.Boxer=ct;exports.BoxerProvider=st;exports.ButtonCtrl=on;exports.ColumnFilterInput=vt;exports.ColumnFilterInputOperator=yt;exports.ColumnFilterSet=ke;exports.FilterOperators=St;exports.Former=Se;exports.FormerButtonArea=le;exports.FormerDialog=en;exports.FormerModel=tn;exports.FormerPopover=nn;exports.FormerResolveSpecAPI=Qt;exports.FormerRestHeadSpecAPI=Zt;exports.GetGlobalState=ht;exports.GlidlerAPIAdaptorForGoLangv2=bt;exports.GlidlerFormAdaptor=wt;exports.GlidlerLocalDataAdaptor=Me;exports.GlobalStateStore=L;exports.GlobalStateStoreProvider=qn;exports.GoAPIHeaders=re;exports.Gridler=Pe;exports.GridlerRightMenuIcon=xt;exports.IconButtonCtrl=sn;exports.MantineBetterMenusProvider=pt;exports.NativeSelectCtrl=ln;exports.PasswordInputCtrl=an;exports.ReactBasicErrorBoundary=Ht;exports.ReactErrorBoundary=Wt;exports.SwitchCtrl=cn;exports.TextAreaCtrl=un;exports.TextInputCtrl=dn;exports.errorManager=me;exports.getApiURL=Bn;exports.getAuthToken=Nn;exports.isLoggedIn=Ln;exports.setApiURL=$n;exports.setAuthToken=Gn;exports.useBoxerStore=it;exports.useFormerState=rn;exports.useGlobalStateStore=zn;exports.useGlobalStateStoreContext=Vn;exports.useGridlerStore=H;exports.useMantineBetterMenus=Fe;
|
|
27
27
|
//# sourceMappingURL=lib.cjs.js.map
|