@warkypublic/oranguru 0.0.21 → 0.0.22
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 +4 -4
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.es.js +49 -49
- package/dist/lib.es.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.cjs.js
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ge;function Te(){return ge||(ge=1,process.env.NODE_ENV!=="production"&&(function(){function o(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===
|
|
17
|
+
*/var ge;function Te(){return ge||(ge=1,process.env.NODE_ENV!=="production"&&(function(){function o(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===j?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case x:return"Fragment";case N:return"Profiler";case I:return"StrictMode";case f:return"Suspense";case y:return"SuspenseList";case $:return"Activity"}if(typeof l=="object")switch(typeof l.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),l.$$typeof){case R:return"Portal";case B:return l.displayName||"Context";case P:return(l._context.displayName||"Context")+".Consumer";case v:var m=l.render;return l=l.displayName,l||(l=m.displayName||m.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case F:return m=l.displayName||null,m!==null?m:o(l.type)||"Memo";case M:m=l._payload,l=l._init;try{return o(l(m))}catch{}}return null}function c(l){return""+l}function e(l){try{c(l);var m=!1}catch{m=!0}if(m){m=console;var b=m.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&l[Symbol.toStringTag]||l.constructor.name||"Object";return b.call(m,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),c(l)}}function t(l){if(l===x)return"<>";if(typeof l=="object"&&l!==null&&l.$$typeof===M)return"<...>";try{var m=o(l);return m?"<"+m+">":"<...>"}catch{return"<...>"}}function n(){var l=D.A;return l===null?null:l.getOwner()}function r(){return Error("react-stack-top-frame")}function i(l){if(T.call(l,"key")){var m=Object.getOwnPropertyDescriptor(l,"key").get;if(m&&m.isReactWarning)return!1}return l.key!==void 0}function s(l,m){function b(){Z||(Z=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",m))}b.isReactWarning=!0,Object.defineProperty(l,"key",{get:b,configurable:!0})}function a(){var l=o(this.type);return ee[l]||(ee[l]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),l=this.props.ref,l!==void 0?l:null}function g(l,m,b,p,q,A){var k=b.ref;return l={$$typeof:w,type:l,key:m,props:b,_owner:p},(k!==void 0?k:null)!==null?Object.defineProperty(l,"ref",{enumerable:!1,get:a}):Object.defineProperty(l,"ref",{enumerable:!1,value:null}),l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(l,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(l,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.defineProperty(l,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}function d(l,m,b,p,q,A){var k=m.children;if(k!==void 0)if(p)if(H(k)){for(p=0;p<k.length;p++)u(k[p]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u(k);if(T.call(m,"key")){k=o(l);var W=Object.keys(m).filter(function(Ie){return Ie!=="key"});p=0<W.length?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}",Y[k+p]||(W=0<W.length?"{"+W.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,p,k,W,k),Y[k+p]=!0)}if(k=null,b!==void 0&&(e(b),k=""+b),i(m)&&(e(m.key),k=""+m.key),"key"in m){b={};for(var le in m)le!=="key"&&(b[le]=m[le])}else b=m;return k&&s(b,typeof l=="function"?l.displayName||l.name||"Unknown":l),g(l,k,b,n(),q,A)}function u(l){_(l)?l._store&&(l._store.validated=1):typeof l=="object"&&l!==null&&l.$$typeof===
|
|
22
|
+
<%s key={someKey} {...props} />`,p,k,W,k),Y[k+p]=!0)}if(k=null,b!==void 0&&(e(b),k=""+b),i(m)&&(e(m.key),k=""+m.key),"key"in m){b={};for(var le in m)le!=="key"&&(b[le]=m[le])}else b=m;return k&&s(b,typeof l=="function"?l.displayName||l.name||"Unknown":l),g(l,k,b,n(),q,A)}function u(l){_(l)?l._store&&(l._store.validated=1):typeof l=="object"&&l!==null&&l.$$typeof===M&&(l._payload.status==="fulfilled"?_(l._payload.value)&&l._payload.value._store&&(l._payload.value._store.validated=1):l._store&&(l._store.validated=1))}function _(l){return typeof l=="object"&&l!==null&&l.$$typeof===w}var C=S,w=Symbol.for("react.transitional.element"),R=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),B=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),D=C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=Object.prototype.hasOwnProperty,H=Array.isArray,G=console.createTask?console.createTask:function(){return null};C={react_stack_bottom_frame:function(l){return l()}};var Z,ee={},te=C.react_stack_bottom_frame.bind(C,r)(),ne=G(t(r)),Y={};X.Fragment=x,X.jsx=function(l,m,b){var p=1e4>D.recentlyCreatedOwnerStacks++;return d(l,m,b,!1,p?Error("react-stack-top-frame"):te,p?G(t(l)):ne)},X.jsxs=function(l,m,b){var p=1e4>D.recentlyCreatedOwnerStacks++;return d(l,m,b,!0,p?Error("react-stack-top-frame"):te,p?G(t(l)):ne)}})()),X}var he;function Ae(){return he||(he=1,process.env.NODE_ENV==="production"?oe.exports=Fe():oe.exports=Te()),oe.exports}var h=Ae();function K(o){return btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(c,e)=>String.fromCharCode(Number.parseInt(e,16))))}const Pe="gridler_golang_restapi_v2_token",Me=(o,c)=>{const e=[...o.filter(t=>t!==void 0&&t.type!==void 0)];for(let t=0;t<e.length;t++)(!e[t].name||e[t].name==="")&&(e[t].name=""),e[t].type==="files"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="advsql"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="custom-sql-or"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="custom-sql-join"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="not-select-fields"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="custom-sql-w"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="select-fields"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),e[t].type==="cql-sel"&&!e[t].value.startsWith("__")&&(e[t].value=`__${K(e[t].value)}__`),c&&((!e||e.length===0)&&c.set("x-limit","10"),e[t].type==="association_autoupdate"&&c.set("association_autoupdate",e[t].value??"1"),e[t].type==="association_autocreate"&&c.set("association_autocreate",e[t].value??"1"),e[t].type==="searchop"||e[t].type==="searchor"||e[t].type==="searchand"?c.set(encodeURIComponent(`x-${e[t].type}-${e[t].op}-${e[t].name}`),String(e[t].value)):c.set(encodeURIComponent(`x-${e[t].type}${e[t].name&&e[t].name!==""?"-"+e[t].name:""}`),String(e[t].value)));return e},V=(o,c)=>{const e=new Headers,t={},n=me?.();if(n&&n!=="")e.set("Authorization",`Token ${n}`);else{const i=me();i&&e.set("Authorization",`Token ${i}`)}c&&c.forEach((i,s)=>{e.set(s,i)});const r=[];for(const i of o?.filter(s=>!!s)??[]){const s=r.findIndex(a=>a.name===i.name&&a.type===i.type);s===-1?r.push(i):r[s]=i}if(Me(r,e),e?.forEach((i,s)=>{t[s]=i}),c)for(const i of Object.keys(t))c.set(i,t[i]);return t},je={getAuthToken:()=>{if(localStorage){const o=localStorage.getItem(Pe);if(o)return o}}},me=()=>je?.getAuthToken?.();function Ne(o,c){if(!o||!c||o.includes("..")||o.includes("[]")||/\[\s*\]/.test(o))return;const e=o.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);if(e.length!==0)return e.reduce((t,n)=>{if(t!=null&&typeof t=="object")return t[n]},c)}const{Provider:Oe,useStore:ce}=Se.createSyncStore((o,c)=>({hide:e=>{c().setInstanceState(e,"visible",!1)},menus:[],setInstanceState:(e,t,n)=>{o(J.produce(r=>{const i=r?.menus?.findIndex(s=>s.id===e);i>=0&&(r.menus[i][t]=n)}))},setState:(e,t)=>{o(J.produce(n=>{n[e]=t}))},show:(e,t)=>{const n=c(),r=n.menus.findIndex(s=>s.id===e),i=n.menus[r]?{...n.menus[r]}:{};Object.assign(i,t),i.id=i.id??e,i.visible=!(i.visible??!1),r<0?n.setState("menus",[...n.menus,i]):o(J.produce(s=>{s.menus||(s.menus=[]),s.menus[r]={...s.menus[r],...i}}))}}),o=>({providerID:o.providerID??`MenuStore-${ve.getUUID()}`}));function $e(){const{menus:o,providerID:c,setInstanceState:e,width:t}=ce(n=>({menus:n.menus,providerID:n.providerID,setInstanceState:n.setInstanceState,setState:n.setState,width:n.width}));return h.jsx(E.Portal,{id:`bmm_portal_${c}`,children:S.Children.toArray(o?.map((n,r)=>S.createElement(E.Menu,{shadow:"md",width:t??"300",...n.menuProps,key:`bmm_menu_${c}_${r}`,onClose:()=>{e(n.id,"visible",!1),n.menuProps?.onClose?.()},opened:n.visible},h.jsx(E.Menu.Target,{children:h.jsx("div",{id:`bmm_${c}_${r}_target`,style:{left:n.x,position:"fixed",top:n.y,visibility:"hidden"}})}),h.jsx(E.Menu.Dropdown,{children:n.renderer?n.renderer:S.Children.toArray(n.items?.map((i,s)=>h.jsx(_e,{...i},`bmm_${c}_${r}_item${s}`)))}))))},`bmm_portal_${c}`)}const _e=({children:o,label:c,...e})=>{const[t,n]=S.useState(!1);return typeof e.renderer=="function"?e.renderer({...e,loading:t,renderer:void 0,setLoading:n}):typeof e.renderer=="object"?e.renderer:e.isDivider?h.jsx(E.Menu.Divider,{}):e.items&&e.items.length>0?h.jsxs(E.Menu.Sub,{children:[h.jsx(E.Menu.Sub.Target,{children:h.jsx(E.Menu.Sub.Item,{...e,disabled:t,onClick:r=>{e.onClick?.(r),e.onClickAsync&&(n(!0),e.onClickAsync(r).finally(()=>n(!1)))},styles:{itemLabel:{overflow:"auto",wordWrap:"break-word"},...e.styles},children:o??c})}),h.jsx(E.Menu.Sub.Dropdown,{children:S.Children.toArray(e.items.map((r,i)=>h.jsx(_e,{...r},`bmm_subitem_${r?.id??""}${i}`)))})]}):!e.onClick&&!e.onClickAsync?h.jsxs(E.Menu.Label,{...e,children:[" ",o??c]}):h.jsx(E.Menu.Item,{...e,disabled:t,onClick:r=>{e.onClick?.(r),e.onClickAsync&&(n(!0),e.onClickAsync(r).finally(()=>n(!1)))},styles:{itemLabel:{overflow:"auto",wordWrap:"break-word"},...e.styles},children:o??c})};function Ce(o){return h.jsxs(Oe,{...o,children:[h.jsx($e,{}),o.children]})}const we=[{label:"Contains",value:"contains"},{label:"Equal",value:"eq"},{label:"Not Equal",value:"neq"},{label:"Greater Than",value:"gt"},{label:"Greater Than or Equal",value:"gte"},{label:"Less Than",value:"lt"},{label:"Less Than or Equal",value:"lte"}],ye=o=>{const c=o.storeState?.colFilters?.findIndex(i=>i.id===o.column.id)??-1,e=o.storeState?.colFilters?.[c]??{id:o.column.id,value:""},[t,n]=S.useState(e?.value??""),[r]=Q.useDebouncedValue(t,900);return S.useEffect(()=>{o.storeState.setStateFN("colFilters",i=>{const s=i?.findIndex(g=>g.id===o.column.id)??-1,a=i??[];return s>=0?a[s]={...a[s],...o.options,id:o.column.id,value:r}:a.push({operator:"contains",...o.options,id:o.column.id,value:r}),a})},[r,o.column.id,o.options,o.storeState]),h.jsx(E.TextInput,{onChange:i=>n(i.target.value),rightSection:h.jsx(E.ActionIcon,{color:"gray",onClick:()=>n(""),variant:"filled",children:h.jsx(z.IconX,{color:"red"})}),value:t??e?.value})},be=o=>{const c=o.storeState?.colFilters?.findIndex(i=>i.id===o.column.id)??-1,e=o.storeState?.colFilters?.[c]??{id:o.column.id,operator:"contains"},[t,n]=S.useState(e?.operator??"contains"),[r]=Q.useDebouncedValue(t,900);return S.useEffect(()=>{o.storeState.setStateFN("colFilters",i=>{const s=i?.findIndex(g=>g.id===o.column.id)??-1,a=i??[];return s>=0?a[s]={...a[s],...o.options,id:o.column.id,operator:r}:a.push({...o.options,id:o.column.id,operator:r,value:""}),a})},[r,o.column.id,o.options,o.storeState]),h.jsx(E.Select,{comboboxProps:{withinPortal:!1},data:we,maxDropdownHeight:150,onChange:i=>n(i),placeholder:"Operator",searchable:!0,value:t??e?.operator,withScrollArea:!0})},ie=o=>h.jsxs(E.Stack,{onClick:c=>c.stopPropagation(),children:[h.jsx(be,{...o}),h.jsx(ye,{...o})]}),ae=o=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none">
|
|
23
23
|
<path
|
|
24
24
|
fill="${o.fgColor??"currentColor"}"
|
|
25
25
|
d="M15 2.5a.5.5 0 0 0-1 0v13.793l-2.146-2.147a.5.5 0 0 0-.708.708l3 3a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L15 16.293zM2.5 4a.5.5 0 0 0 0 1h9a.5.5 0 0 0 0-1zM5 7.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5M8.5 10a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z"
|
|
@@ -31,10 +31,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
31
31
|
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"
|
|
32
32
|
></path>
|
|
33
33
|
</svg>
|
|
34
|
-
`,re=o=>h.jsx("img",{alt:o.alt??"Sprite Image",src:`data:image/svg+xml;utf8,${o.sprite({...o,sprite:void 0})}`}),{Provider:De,useStore:L}=Se.createSyncStore((o,c)=>({_events:new EventTarget,_loadingList:O.CompactSelection.empty(),_page_data:{},_refresh:async()=>{const e=c();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=c();console.log("Gridler Error",n.uniqueid,e,t),o(J.produce(r=>{r.errors=[...r.errors,e]}))},errors:[],get:()=>c(),getCellContent:e=>{const t=c(),[n,r]=e,i=t.getRowBuffer(r);return i!==void 0?t.toCell(i,n):{allowOverlay:!1,kind:O.GridCellKind.Loading}},getCellsForSelection:(e,t)=>async()=>{const n=c();await n.setStateFN("_visibleArea",i=>e);const r=[];for(let i=e.y;i<e.y+e.height;i++){const s=[];for(let a=e.x;a<e.x+e.width;a++)s.push(n.getCellContent([a,i]));r.push(s)}return r},getGridSelectedRows:()=>{const e=c(),t=[],n=e._page_data,r=e.pageSize;if(e._gridSelectionRows)for(const i of e._gridSelectionRows){let s;for(const a in n)for(const g in n[a]){const d=Number(a)*r+Number(g);if(!isNaN(d)){if(Number(n[a][g]?._rownumber)===i+1){s=n[a][g];break}else if(d===i+1){s=n[a][g];break}}}s!==void 0&&t.push(s)}return t},getRowBuffer:e=>{const t=c();if(t.data&&t.data.length>0)return t.data[e]===void 0?{allowOverlay:!1,kind:O.GridCellKind.Loading}:t.data[e];const n=Math.max(0,Math.floor(e/t.pageSize)),r=t.pageSize*n,i=e-r;return t._page_data?.[n]?.[i]},getRowIndexByKey:async e=>{const t=c();let n=-1;if(t.ready){const r=t._page_data,i=t.pageSize,s=t.keyField??"id";for(const a in r){for(const g in r[a]){const d=Number(a)*i+Number(g);if(String(r[a][g]?.[s])===String(e)){n=r[a][g]?._rownumber>0?r[a][g]?._rownumber:d>0?d:-1;break}}if(n>0)return console.log("Local row index",n,e),n}if(n>0)return n;if(typeof t.askAPIRowNumber=="function"){const a=await t.askAPIRowNumber(String(e));if(a&&a>=0)return console.log("Remote row index",n,e),a}}},getState:e=>c()[e],hasLocalData:!1,isEmpty:!0,keyField:"id",loadPage:async(e,t)=>{const n=c(),r=e<0?0:e;if(!n._events.dispatchEvent(new CustomEvent("before_loadPage",{detail:{clearMode:t,page:e,state:n}})))return;const s=[],a=Object.keys(n.renderColumns??[1,2,3]).length,g=n.pageSize*r,d=n._page_data?.[r]?.length>0;if(t==="all"){n._active_requests?.forEach(u=>{u.controller?.abort?.()}),n.setState("_page_data",{}),n.setState("_active_requests",[]),n.loadPage(r);return}if(!n.useAPIQuery){console.warn("No useAPIQuery function defined, cannot load page",r);return}!d&&t!=="page"&&n.useAPIQuery?.(r).then(u=>{n.setStateFN("_page_data",_=>({..._,[r]:u}));for(let _=r;_<=g+n.pageSize;_++)for(let C=0;C<=a;C++)s.push({cell:[C,_]});n._glideref?.updateCells(s),n._events.dispatchEvent(new CustomEvent("loadPage",{detail:{clearMode:t,data:u,page:e,state:n}}))}).catch(u=>{console.error("loadPage Error: ",r,u),n._events.dispatchEvent(new CustomEvent("loadPage_error",{detail:{clearMode:t,error:u,page:e,state:n}}))})},maxConcurrency:1,mounted:!1,onCellActivated:e=>{const t=c(),[n,r]=e;t._events.dispatchEvent(new CustomEvent("onCellActivated",{detail:{cell:e,col:n,row:r,state:t}})),t.glideProps?.onCellActivated?.(e)},onCellClicked:(e,t)=>{const n=c(),[r,i]=e;n.glideProps?.onCellClicked?n.glideProps?.onCellClicked?.(e,t):n.values?.length&&(n.onChange?n.onChange(n.values):n.setState("values",n.values)),n._events.dispatchEvent(new CustomEvent("onCellClicked",{detail:{cell:e,col:r,row:i,state:n}}))},onCellEdited:(e,t)=>{const n=c(),[,r]=e;n._events.dispatchEvent(new CustomEvent("onCellEdited",{detail:{cell:e,newVal:t,row:r,state:n}})),n.glideProps?.onCellEdited?.(e,t)},onColumnMoved:(e,t)=>{const n=c(),r=n.renderColumns?.[e],i=n.renderColumns?.[t];r?.disableMove||i?.disableMove||n.setStateFN("colOrder",s=>{const a=s??n.renderColumns?.map((g,d)=>[g.id,d]).reduce((g,[d,u])=>({...g,[d]:u}),{});return!r?.id||!i?.id?a:{...a,[r?.id]:t,[i?.id]:e}})},onColumnProposeMove:(e,t)=>{const n=c(),r=n.renderColumns?.[e],i=n.renderColumns?.[t];return!(r?.disableMove||i?.disableMove)},onColumnResize:(e,t,n,r)=>{const i=c(),s=i.renderColumns?.find(a=>a.id===e.id);s?.disableResize||s?.maxWidth&&t<s?.maxWidth||s&&i.setStateFN("colSize",a=>a&&s&&a[s.id]===t?a:{...a,[s.id]:t})},onContextClick:(e,t,n,r)=>{const i=c(),s=i.renderColumns?.[n??-1],a=e==="menu"?[{leftSection:h.jsx(z.IconGrid4x4,{size:16}),title:i.title??"Grid"}]:s?[{leftSection:h.jsx(z.IconGrid4x4,{size:16}),title:i.title??"Grid"},{items:[{label:"Sort Ascending",leftSection:h.jsx(re,{sprite:se}),onClick:()=>{i.setStateFN("colSort",g=>{const d=[...g??[]],u=d.findIndex(C=>C.id===s.id),_="asc";if(u<0){const C={direction:_,id:s.id,order:d?.length};d.push(C)}else u>=0&&(d[u].direction=_);return d})}},{label:"Sort Descending",leftSection:h.jsx(re,{sprite:ae}),onClick:()=>{i.setStateFN("colSort",g=>{const d=[...g??[]],u=d.findIndex(C=>C.id===s.id),_="desc";if(u<0){const C={direction:_,id:s.id,order:d?.length};d.push(C)}else u>=0&&(d[u].direction=_);return d})}},{label:`Filter ${s?.title??s?.id}`},{renderer:h.jsx(ie,{column:s,storeState:c()})}],label:`Column Settings for ${s?.title??s?.id}`,leftSection:h.jsx(z.IconGrid4x4,{size:16})}]:[];i.hideMenu?.(e),i.showMenu?.(e,{items:s?.getMenuItems?.(e,i,n&&r?i.getRowBuffer(r):void 0,s,a)??i.getMenuItems?.(e,i,n&&r?i.getRowBuffer(r):void 0,s,a)??a,x:t.clientX??t.bounds?.x,y:t.clientY??t.bounds?.y})},onHeaderClicked:(e,t)=>{const n=c();t.preventDefault();const r=n.renderColumns?.[e];r&&(r.disableSort||n.setStateFN("colSort",i=>{const s=[...i??[]],a=s.findIndex(g=>g.id===r.id);if(a<0){const g={direction:"asc",id:r.id,order:s?.length};s.push(g)}else a>=0&&s[a].direction==="asc"?s[a].direction="desc":a>=0&&s[a].direction==="desc"&&s.splice(a,1);return s}))},onHeaderMenuClick:(e,t)=>{const n=c(),r=n.renderColumns?.[e];if(!r)return;const i=[{label:`Sort ${r?.title??r?.id}`},{label:"Sort Ascending",leftSection:h.jsx(re,{sprite:se}),onClick:()=>{n.setStateFN("colSort",a=>{const g=[...a??[]],d=g.findIndex(_=>_.id===r.id),u="asc";if(d<0){const _={direction:u,id:r.id,order:g?.length};g.push(_)}else d>=0&&(g[d].direction=u);return g})}},{label:"Sort Descending",leftSection:h.jsx(re,{sprite:ae}),onClick:()=>{n.setStateFN("colSort",a=>{const g=[...a??[]],d=g.findIndex(_=>_.id===r.id),u="desc";if(d<0){const _={direction:u,id:r.id,order:g?.length};g.push(_)}else d>=0&&(g[d].direction=u);return g})}},{isDivider:!0}],s=[...r.disableSort?[]:i,{label:`Filter ${r?.title??r?.id}`},{renderer:h.jsx(ie,{column:r,storeState:c()})},{isDivider:!0},{id:"refesh",label:"Refresh",onClick:()=>{c()._refresh?.()}}];n.hideMenu?.("header-menu"),n.showMenu?.("header-menu",{items:r?.getMenuItems?.("header-menu",n,void 0,r,s)??n.getMenuItems?.("header-menu",n,void 0,r,s),x:t.x,y:t.y})},onItemHovered:e=>{const t=c();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 r=t.getRowBuffer(e.location[1]);t.setState("_activeTooltip",n?.tooltip(r,e.location[1],e.location[0]))}}},onVisibleRegionChanged:(e,t,n,r)=>{const i=c();i._scrollTimeout&&clearTimeout(i._scrollTimeout);const s=()=>{const a=c(),g=Math.max(0,Math.floor(e.y/a.pageSize)),d=Math.max(0,Math.floor(a._visiblePages.y/a.pageSize)),u=g-d;if(a.progressiveScroll&&u>1){const _=c(),C=(d+2)*_.pageSize*(_.rowHeight??22);_._glideref?.scrollTo(0,{amount:C,unit:"px"},"vertical");return}a.setState("_visiblePages",e)};i.setState("_scrollTimeout",setTimeout(()=>{s()},100))},pageSize:50,ready:!1,refreshCells:(e,t,n)=>{const r=c(),i=[],s=Object.keys(r.renderColumns??[1,2,3]).length,a=e&&e>0?e:0,g=t&&t>=a?t:a+r.pageSize;for(let d=a;d<=g;d++)if(n&&n>0)i.push({cell:[n,d]});else for(let u=0;u<=s;u++)i.push({cell:[u,d]});r._glideref?.updateCells(i)},setState:(e,t)=>{o(J.produce(n=>{n[e]=t}))},setStateFN:(e,t)=>new Promise((r,i)=>{o(J.produce(s=>{if(typeof t=="function")s[e]=t(s[e]);else throw i(new Error(`Not a function ${t}`)),Error(`Not a function ${t}`)})),r()}),toCell:(e,t)=>{const n=c(),i=n.renderColumns?.[t],s=i?.id??i?.title??String(t);if(s==null||e===void 0||e===null)return i?.Cell?i?.Cell(e,t,s,void 0,n):n.RenderCell?n.RenderCell(e,t,s,void 0,n):{allowOverlay:!1,kind:O.GridCellKind.Loading};try{const a=String(s).includes(".")?Ne(s,e)??"":e?.[s];return i?.Cell?{kind:O.GridCellKind.Text,...i?.Cell(e,t,s,a,n)}:n.RenderCell?n.RenderCell(e,t,s,a,n):{allowOverlay:!0,data:a??"",displayData:String(a??""),kind:O.GridCellKind.Text}}catch{return n.RenderCell?n.RenderCell(e,t,s,e?.[s??""],n):{allowOverlay:!1,kind:O.GridCellKind.Loading,skeletonWidthVariability:50}}},total_rows:1e3,uniqueid:ve.getUUID()}),o=>{const[c,e]=o.useStore(n=>[n.setState,n.getState]),t=ce();return S.useEffect(()=>{const n=e("onMounted");if(typeof n=="function"&&n(e,c),c("mounted",!0),window&&window.document&&!window.document.getElementById("portal")){const i=window.document.createElement("div");i.id="portal",i.setAttribute("data-gridler-portal",o.uniqueid),window.document.body.appendChild(i)}return e("_events").dispatchEvent(new CustomEvent("mounted",{detail:{}})),()=>{const r=e("onUnMounted");c("mounted",!1),e("_events").dispatchEvent(new CustomEvent("unmounted",{detail:{}})),typeof r=="function"&&r()}},[c,e]),e("_events").addEventListener("reload",n=>{e("_refresh")?.()}),{...o,colSort:o.defaultSort??e("colSort")??[],hideMenu:o.hideMenu??t.hide,scrollToRowKey:o.scrollToRowKey??o.selectedRowKey??e("scrollToRowKey"),showMenu:o.showMenu??t.show,total_rows:e("total_rows")??o.total_rows}});function Ge(o){const[c,e,t,n,r]=L(a=>[a.setStateFN,a.setState,a.getState,a.addError,a.mounted]),i=S.useCallback(async a=>{const g=t("columns"),d=t("colSort"),u=t("pageSize"),_=t("colFilters"),C=t("searchStr"),w=t("searchFields"),R=t("_active_requests");e("loadingData",!0);try{if(o&&o.url){const x=new Headers;x.set("Authorization",`Token ${o.authtoken}`);const I=[{type:"limit",value:String(u??50)},{type:"offset",value:String((u??50)*a)}];d?.length&&d.length>0&&I.push({type:"sort",value:d?.map(f=>`${f.id} ${f.direction}`).reduce((f,y)=>`${f},${y}`)}),_?.filter(f=>f.value?.length>0)?.forEach(f=>{f.value&&f.value!==""&&I.push({name:`${f.id}`,op:f.operator,type:"searchop",value:f.value})}),C&&C!==""&&g?.filter(f=>!f.disableFilter&&!f.disableSearch&&!f.virtual&&((w??[]).length==0||w?.includes(f.id)))?.forEach(f=>{I.push({name:`${f.id}`,op:"contains",type:"searchor",value:C})}),o.filter&&o.filter!==""&&I.push({name:"sql_filter",type:"custom-sql-w",value:o.filter}),(o.options??[]).length>0&&I.push(...o.options??[]);const M=g?.filter(f=>!f.virtual)?.map(f=>f.id)??[];if(o.hotfields&&o.hotfields.length>0&&M?.push(o.hotfields.join(",")),M&&M.length>0&&I.push({type:"select-fields",value:M.join(",")}),I&&I.length>0){const f=V(I);for(const y in V(I))x.set(y,f[y])}const j=R?.findIndex(f=>f.page===a)??-1;if(R?.forEach(f=>{(f.page>=0&&f.page<a-2||a>=0&&f.page>a+2)&&f.controller?.abort?.()}),R&&j>=0&&R[j]){e("loadingData",!1);return}const B=new AbortController;await c("_active_requests",f=>[...f??[],{controller:B,page:a}]);const v=await fetch(`${o.url}?x-limit=${String(u??50)}&x-offset=${String((u??50)*a)}`,{headers:x,method:"GET",signal:B?.signal});if(v.ok){const f=v.headers.get("Content-Range")?.split("/");f?.[1]&&parseInt(f[1],10)>0&&e("total_rows",parseInt(f[1],10));const y=await v.json();return e("loadingData",!1),y??[]}n(`${v.status} ${v.statusText}`,"api",o.url),await c("_active_requests",f=>[...(f??[]).filter(y=>y.page!==a)])}}catch{}return e("loadingData",!1),[]},[t,o.authtoken,o.url,o.filter,JSON.stringify(o.options),e,c,n]),s=S.useCallback(async a=>{const g=t("colFilters");if(o&&o.url){const d=new Headers,u=[{type:"limit",value:String(10)},{type:"fetch-rownumber",value:a}];if(d.set("Authorization",`Token ${o.authtoken}`),g?.length&&g.length>0&&g?.filter(w=>w.value?.length>0)?.forEach(w=>{w.value&&w.value!==""&&d.set(`x-searchop-${w.operator}-${w.id}`,`${w.value}`)}),o.filter&&o.filter!==""&&u.push({name:"sql_filter",type:"custom-sql-w",value:o.filter}),o.options&&o.options.length>0){const w=V(o.options);for(const R in w)d.set(R,w[R])}if(u&&u.length>0){const w=V(u);for(const R in V(u))d.set(R,w[R])}const _=new AbortController,C=await fetch(`${o.url}?x-fetch-rownumber=${a}}`,{headers:d,method:"GET",signal:_?.signal});if(C.ok){const w=await C.json();return w?.[0]?._rownumber??w?._rownumber??0}n(`${C.status} ${C.statusText}`,"api",o.url)}return[]},[o.url,o.authtoken,o.filter,o.options,t,n]);return S.useEffect(()=>{e("useAPIQuery",i),e("askAPIRowNumber",s),t("_refresh")?.().then(()=>{const g=t("onChange"),d=t("getGridSelectedRows");if(g&&typeof g=="function"){const u=d?.();g(u)}})},[o.url,o.authtoken,o.filter,JSON.stringify(o.options),r,e]),h.jsx(h.Fragment,{})}const xe=S.memo(Ge);xe.displayName="Gridler-GlidlerAPIAdaptorForGoLangv2";function Re(o){const[c,e,t,n]=L(i=>[i.getState,i.mounted,i.setState,i._events]);S.useEffect(()=>{if(e&&o.changeOnActiveClick){const i=s=>{const{row:a,state:g}=s.detail,d=g.getRowBuffer;if(d){const u=d(a);if(!u)return;o.onRequestForm("change",u)}};return n?.addEventListener("onCellActivated",i),()=>{i&&n?.removeEventListener("onCellActivated",i)}}},[o.changeOnActiveClick,e,n]);const r=S.useCallback((i,s,a,g,d)=>{if(i==="header-menu")return d||[];const u=[];u.push(...d);const _=c("_gridSelection")?.rows.toArray()??[],C=_.length>1;if(!a){const x=_[0];x!==void 0&&(a=s.getRowBuffer(x))}const w=typeof o.descriptionField=="string"?a?.[o.descriptionField]:typeof o.descriptionField=="function"&&a?o.descriptionField(a):void 0;i==="other"&&u.push({c:"blue",label:"Add",onClick:()=>{o.onRequestForm("insert",a)}}),i==="cell"&&a||i==="menu"&&a?(u.push({c:"teal",label:"Add",leftSection:h.jsx(z.IconSquarePlus,{color:"teal",size:16}),onClick:()=>{o.onRequestForm("insert",a)}}),C?(u.push({c:"green",label:`Modify All Selected (${_.length})`,leftSection:h.jsx(z.IconEdit,{color:"green",size:16}),onClick:()=>{o.onRequestForm("change",_.map(x=>s.getRowBuffer(x)))}}),u.push({c:"red",label:`Remove All Selected (${_.length})`,leftSection:h.jsx(z.IconTrashX,{color:"maroon",size:16}),onClick:()=>{o.onRequestForm("delete",_.map(x=>s.getRowBuffer(x)))}})):(u.push({c:"green",label:`Modify${w&&o.showDescriptionInMenu?` (${w})`:""}`,leftSection:h.jsx(z.IconEdit,{color:"green",size:16}),onClick:()=>{o.onRequestForm("change",a)}}),u.push({c:"red",label:`Remove${w&&o.showDescriptionInMenu?` (${w})`:""}`,leftSection:h.jsx(z.IconTrashX,{color:"maroon",size:16}),onClick:()=>{o.onRequestForm("delete",a)}})),u.push({isDivider:!0})):(i==="cell"&&!a||i==="menu"&&!a)&&u.push({c:"red",label:"Nothing Selected",leftSection:h.jsx(z.IconExclamationMark,{color:"yellow",size:16})}),u.push({c:"orange",label:"Refresh",leftSection:h.jsx(z.IconRefresh,{color:"orange",size:16}),onClickAsync:async()=>{await c("_refresh")?.()}});const R=o.getMenuItems?o.getMenuItems(i,s,a,g,u):u;return!u||u.length===0?d||[]:R},[o.onRequestForm,c]);return S.useEffect(()=>(e&&typeof t=="function"&&c("getMenuItems")!==r&&t("getMenuItems",r),()=>{}),[o.getMenuItems,e]),h.jsx(h.Fragment,{})}function ze(o){const[c,e,t]=L(d=>[d.setState,d.getState,d.mounted]),{colFilters:n,colSort:r,columns:i,searchStr:s}=L(d=>({colFilters:d.colFilters,colOrder:d.colOrder,colSize:d.colSize,colSort:d.colSort,columns:d.columns,searchStr:d.searchStr})),a=S.useRef({colFilters:n,colSort:r,searchStr:s}),g=async d=>{const u=e("pageSize");return o.data&&Array.isArray(o.data)?(c("total_rows",o.data.length),o.data.slice(d*(u??50),(d+1)*(u??50))):[]};return S.useEffect(()=>{c("useAPIQuery",g)},[t,c]),S.useEffect(()=>{if(o.onColumnSort&&r!==a?.current?.colSort){const d=o.onColumnSort(r,i,o.data);c("total_rows",d.length),c("data",d),a.current.colSort=r,e("refreshCells")?.()}},[r,o.onColumnSort]),S.useEffect(()=>{if(o.onColumnFilter&&n!==a?.current?.colFilters){const d=o.onColumnFilter(n,i,o.data);c("total_rows",d.length),c("data",d),a.current.colFilters=n,e("refreshCells")?.()}},[n,o.onColumnFilter]),S.useEffect(()=>{if(o.onSearch&&s!==a?.current?.searchStr){const d=o.onSearch(s,i,o.data);c("total_rows",d.length),c("data",d),a.current.colFilters=n,e("refreshCells")?.()}},[s,o.onSearch]),h.jsx(h.Fragment,{})}const ue=S.memo(ze);ue.displayName="Gridler-GlidlerLocalDataAdaptor";function pe(){const{loadingData:o,onContextClick:c}=L(e=>({loadingData:e.loadingData,onContextClick:e.onContextClick}));return h.jsx(E.ActionIcon,{loading:o,mr:"xs",mt:"2px",onClick:e=>c("menu",e),variant:"subtle",children:h.jsx(z.IconMenu2,{})})}function Le(o,c){const[e,t]=L(n=>[n.setStateFN,n.getState]);return S.useImperativeHandle(c,()=>({getGlideRef:()=>t("_glideref"),getState:t,isEmpty:()=>t("isEmpty"),refresh:async n=>{const r=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{r?.()})},reload:async n=>{const r=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{r?.()})},reloadRow:async n=>{const r=t("refreshCells"),s=await t("getRowIndexByKey")?.(String(n));s&&s>=0&&r?.(s,s+1)},scrollToRow:async n=>{n&&Number(n)>=0&&e("scrollToRowKey",r=>Number(n??r))},selectRow:async n=>{n&&Number(n)>=0&&e("selectedRowKey",r=>Number(n??r))},setStateFN:e}),[]),h.jsx(h.Fragment,{children:o.children})}const qe=S.forwardRef(Le);function He(){const{_activeTooltip:o,tooltipBarProps:c}=L(e=>({_activeTooltip:e._activeTooltip,tooltipBarProps:e.tooltipBarProps}));return h.jsx("div",{"data-tooltip-bar":!0,style:{minHeight:"24px"},...c,children:o})}const Ee=S.memo(()=>{const o=S.useRef(0),c=S.useRef(""),e=S.useRef(null),{_glideref:t,_gridSelectionRows:n,colFilters:r,colOrder:i,colSize:s,colSort:a,columns:g,getRowIndexByKey:d,getState:u,loadPage:_,ready:C,scrollToRowKey:w,searchStr:R,selectedRowKey:x,setState:I,setStateFN:M,values:j}=L(v=>({_glideref:v._glideref,_gridSelectionRows:v._gridSelectionRows,colFilters:v.colFilters,colOrder:v.colOrder,colSize:v.colSize,colSort:v.colSort,columns:v.columns,getRowIndexByKey:v.getRowIndexByKey,getState:v.getState,loadPage:v.loadPage,ready:v.ready,scrollToRowKey:v.scrollToRowKey,searchStr:v.searchStr,selectedRowKey:v.selectedRowKey,setState:v.setState,setStateFN:v.setStateFN,uniqueid:v.uniqueid,values:v.values})),B=Q.useDebouncedCallback(v=>{_(0,"all").then(()=>{u("refreshCells")?.(),u("_events")?.dispatchEvent?.(new CustomEvent("onSearched",{detail:{search:v}}))})},{delay:300,leading:!1});return S.useEffect(()=>{j&&(async()=>{const f=u("_page_data"),y=u("pageSize"),F=u("keyField")??"id",P=[];for(const $ in j){let N=-1;const D=String(typeof j?.[$]=="object"?j?.[$]?.[F]:typeof j?.[$]=="string"?j?.[$]:void 0);for(const T in f){for(const H in f[T]){const G=Number(T)*y+Number(H);if(String(f[T][H]?.[F])===D){N=G;break}}if(N>=0){P.push(N);break}}if(!(N>=0)){const T=await d(D);T&&P.push(T)}}return P})().then(f=>{let y=O.CompactSelection.empty();f.forEach(F=>{y=y.add(F)}),M("_gridSelectionRows",()=>y),M("_gridSelection",F=>({columns:F?.columns??O.CompactSelection.empty(),...F,rows:y}))})},[j]),S.useEffect(()=>{const v=u("onChange");if(v&&typeof v=="function"){const y=u("getGridSelectedRows")(),F=u("values");JSON.stringify(F)!==JSON.stringify(y)&&v(y)}},[JSON.stringify(n),u]),S.useEffect(()=>{I("renderColumns",g?.map(v=>({...v,hasMenu:v?.hasMenu??!0,icon:"sort"})))},[g]),S.useEffect(()=>{if(R==null){c.current="";return}c.current!==R&&(B(R),c.current=R)},[R]),S.useEffect(()=>{a&&(I("_gridSelection",{columns:O.CompactSelection.empty(),current:void 0,rows:O.CompactSelection.empty()}),I("_gridSelectionRows",O.CompactSelection.empty()),M("renderColumns",v=>v?.map(f=>({...f,icon:f.id&&a?.find(y=>y.id===f.id)?.direction?a?.find(y=>y.id===f.id)?.direction==="asc"?"sortup":"sortdown":f.defaultIcon??"sort"}))).then(()=>{_(0,"all").then(()=>{u("refreshCells")?.(),u("_events")?.dispatchEvent?.(new CustomEvent("onColumnSorted",{detail:{cols:a}}))})}))},[a]),S.useEffect(()=>{r&&JSON.stringify(e.current)!==JSON.stringify(r)&&(_(0,"all").then(()=>{u("refreshCells")?.(),u("_events")?.dispatchEvent?.(new CustomEvent("onColumnFiltered",{detail:{filters:r}}))}),e.current=r)},[r]),S.useEffect(()=>{s&&M("renderColumns",v=>v?.map(f=>({...f,width:f.id&&s?.[f.id]?s?.[f.id]:f.width}))).then(()=>{u("refreshCells")?.()})},[s]),S.useEffect(()=>{i&&M("renderColumns",v=>v?.sort((y,F)=>i[y.id]>i[F.id]?1:-1)).then(()=>{u("refreshCells")?.()})},[i]),S.useEffect(()=>{t&&(o.current>0||(o.current=1,_(0).then(()=>{u("refreshCells")?.()})))},[C,_]),S.useEffect(()=>{const v=u("_events"),f=()=>{const y=u("selectFirstRowOnMount");if(C&&y){const F=u("scrollToRowKey");if(F&&F>=0)return;const P=u("keyField")??"id",N=u("_page_data")?.[0]?.[0],D=N?.[P],T=u("values")??[];if(D&&D>0&&(T.length??0)===0){const H=[N,...T],G=u("onChange");G?G(H):I("values",H),I("scrollToRowKey",D)}}};return v?.addEventListener("loadPage",f),()=>{v?.removeEventListener("loadPage",f)}},[C]),S.useEffect(()=>{const v=u("ready"),f=u("_glideref"),y=u("getRowIndexByKey"),F=x??w;F&&f&&v&&y?.(F).then(P=>{if(P!==void 0){if(x){const $=u("onChange"),N=[{[u("keyField")??"id"]:x}];$?$(N):I("values",N)}f.scrollTo(0,P),u("_events").dispatchEvent(new CustomEvent("scrollToRowKeyFound",{detail:{rowNumber:P,scrollToRowKey:w,selectedRowKey:x}}))}})},[w,x]),h.jsx(h.Fragment,{})});Ee.displayName="Gridler-Computer";function Be(o,c,e=1){let t;if(c===void 0?(t=0,c=o):t=o,e===0)throw new Error("Step cannot be zero");const n=[];if(e>0)for(let r=t;r<c;r+=e)n.push(r);else for(let r=t;r>c;r+=e)n.push(r);return n}const ke=S.memo(()=>{const[o,c,e,t,n,r,i,s]=L(a=>[a.setState,a.getState,a._glideref,a._visiblePages,a.pageSize,a.loadPage,a._loadingList,a.hasLocalData]);return S.useEffect(()=>{e&&o("mounted",!0)},[o]),S.useEffect(()=>{if(!e)return;const a=Math.max(0,Math.floor(t.y/n)),g=Math.floor((t.y+t.height)/n);for(const d of Be(a,g+1,1))r(d).then(()=>{const u=c("_page_data")?.[0]??{};o("isEmpty",u&&u.length>0)})},[r,n,t,e,i,s]),h.jsx(h.Fragment,{})});ke.displayName="Gridler-Pager";const Ke=o=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none">
|
|
34
|
+
`,re=o=>h.jsx("img",{alt:o.alt??"Sprite Image",src:`data:image/svg+xml;utf8,${o.sprite({...o,sprite:void 0})}`}),{Provider:De,useStore:L}=Se.createSyncStore((o,c)=>({_events:new EventTarget,_loadingList:O.CompactSelection.empty(),_page_data:{},_refresh:async()=>{const e=c();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=c();console.log("Gridler Error",n.uniqueid,e,t),o(J.produce(r=>{r.errors=[...r.errors,e]}))},errors:[],get:()=>c(),getCellContent:e=>{const t=c(),[n,r]=e,i=t.getRowBuffer(r);return i!==void 0?t.toCell(i,n):{allowOverlay:!1,kind:O.GridCellKind.Loading}},getCellsForSelection:(e,t)=>async()=>{const n=c();await n.setStateFN("_visibleArea",i=>e);const r=[];for(let i=e.y;i<e.y+e.height;i++){const s=[];for(let a=e.x;a<e.x+e.width;a++)s.push(n.getCellContent([a,i]));r.push(s)}return r},getGridSelectedRows:()=>{const e=c(),t=[],n=e._page_data,r=e.pageSize;if(e._gridSelectionRows)for(const i of e._gridSelectionRows){let s;for(const a in n)for(const g in n[a]){const d=Number(a)*r+Number(g);if(!isNaN(d)){if(Number(n[a][g]?._rownumber)===i+1){s=n[a][g];break}else if(d===i+1){s=n[a][g];break}}}s!==void 0&&t.push(s)}return t},getRowBuffer:e=>{const t=c();if(t.data&&t.data.length>0)return t.data[e]===void 0?{allowOverlay:!1,kind:O.GridCellKind.Loading}:t.data[e];const n=Math.max(0,Math.floor(e/t.pageSize)),r=t.pageSize*n,i=e-r;return t._page_data?.[n]?.[i]},getRowIndexByKey:async e=>{const t=c();let n=-1;if(t.ready){const r=t._page_data,i=t.pageSize,s=t.keyField??"id";for(const a in r){for(const g in r[a]){const d=Number(a)*i+Number(g);if(String(r[a][g]?.[s])===String(e)){n=r[a][g]?._rownumber>0?r[a][g]?._rownumber:d>0?d:-1;break}}if(n>0)return console.log("Local row index",n,e),n}if(n>0)return n;if(typeof t.askAPIRowNumber=="function"){const a=await t.askAPIRowNumber(String(e));if(a&&a>=0)return console.log("Remote row index",n,e),a}}},getState:e=>c()[e],hasLocalData:!1,isEmpty:!0,keyField:"id",loadPage:async(e,t)=>{const n=c(),r=e<0?0:e;if(!n._events.dispatchEvent(new CustomEvent("before_loadPage",{detail:{clearMode:t,page:e,state:n}})))return;const s=[],a=Object.keys(n.renderColumns??[1,2,3]).length,g=n.pageSize*r,d=n._page_data?.[r]?.length>0;if(t==="all"){n._active_requests?.forEach(u=>{u.controller?.abort?.()}),n.setState("_page_data",{}),n.setState("_active_requests",[]),n.loadPage(r);return}if(!n.useAPIQuery){console.warn("No useAPIQuery function defined, cannot load page",r);return}!d&&t!=="page"&&n.useAPIQuery?.(r).then(u=>{n.setStateFN("_page_data",_=>({..._,[r]:u}));for(let _=r;_<=g+n.pageSize;_++)for(let C=0;C<=a;C++)s.push({cell:[C,_]});n._glideref?.updateCells(s),n._events.dispatchEvent(new CustomEvent("loadPage",{detail:{clearMode:t,data:u,page:e,state:n}}))}).catch(u=>{console.error("loadPage Error: ",r,u),n._events.dispatchEvent(new CustomEvent("loadPage_error",{detail:{clearMode:t,error:u,page:e,state:n}}))})},maxConcurrency:1,mounted:!1,onCellActivated:e=>{const t=c(),[n,r]=e;t._events.dispatchEvent(new CustomEvent("onCellActivated",{detail:{cell:e,col:n,row:r,state:t}})),t.glideProps?.onCellActivated?.(e)},onCellClicked:(e,t)=>{const n=c(),[r,i]=e;n.glideProps?.onCellClicked&&n.glideProps?.onCellClicked?.(e,t),n.values?.length&&n.onChange&&n.onChange(n.values),n._events.dispatchEvent(new CustomEvent("onCellClicked",{detail:{cell:e,col:r,row:i,state:n}}))},onCellEdited:(e,t)=>{const n=c(),[,r]=e;n._events.dispatchEvent(new CustomEvent("onCellEdited",{detail:{cell:e,newVal:t,row:r,state:n}})),n.glideProps?.onCellEdited?.(e,t)},onColumnMoved:(e,t)=>{const n=c(),r=n.renderColumns?.[e],i=n.renderColumns?.[t];r?.disableMove||i?.disableMove||n.setStateFN("colOrder",s=>{const a=s??n.renderColumns?.map((g,d)=>[g.id,d]).reduce((g,[d,u])=>({...g,[d]:u}),{});return!r?.id||!i?.id?a:{...a,[r?.id]:t,[i?.id]:e}})},onColumnProposeMove:(e,t)=>{const n=c(),r=n.renderColumns?.[e],i=n.renderColumns?.[t];return!(r?.disableMove||i?.disableMove)},onColumnResize:(e,t,n,r)=>{const i=c(),s=i.renderColumns?.find(a=>a.id===e.id);s?.disableResize||s?.maxWidth&&t<s?.maxWidth||s&&i.setStateFN("colSize",a=>a&&s&&a[s.id]===t?a:{...a,[s.id]:t})},onContextClick:(e,t,n,r)=>{const i=c(),s=i.renderColumns?.[n??-1],a=e==="menu"?[{leftSection:h.jsx(z.IconGrid4x4,{size:16}),title:i.title??"Grid"}]:s?[{leftSection:h.jsx(z.IconGrid4x4,{size:16}),title:i.title??"Grid"},{items:[{label:"Sort Ascending",leftSection:h.jsx(re,{sprite:se}),onClick:()=>{i.setStateFN("colSort",g=>{const d=[...g??[]],u=d.findIndex(C=>C.id===s.id),_="asc";if(u<0){const C={direction:_,id:s.id,order:d?.length};d.push(C)}else u>=0&&(d[u].direction=_);return d})}},{label:"Sort Descending",leftSection:h.jsx(re,{sprite:ae}),onClick:()=>{i.setStateFN("colSort",g=>{const d=[...g??[]],u=d.findIndex(C=>C.id===s.id),_="desc";if(u<0){const C={direction:_,id:s.id,order:d?.length};d.push(C)}else u>=0&&(d[u].direction=_);return d})}},{label:`Filter ${s?.title??s?.id}`},{renderer:h.jsx(ie,{column:s,storeState:c()})}],label:`Column Settings for ${s?.title??s?.id}`,leftSection:h.jsx(z.IconGrid4x4,{size:16})}]:[];i.hideMenu?.(e),i.showMenu?.(e,{items:s?.getMenuItems?.(e,i,n&&r?i.getRowBuffer(r):void 0,s,a)??i.getMenuItems?.(e,i,n&&r?i.getRowBuffer(r):void 0,s,a)??a,x:t.clientX??t.bounds?.x,y:t.clientY??t.bounds?.y})},onHeaderClicked:(e,t)=>{const n=c();t.preventDefault();const r=n.renderColumns?.[e];r&&(r.disableSort||n.setStateFN("colSort",i=>{const s=[...i??[]],a=s.findIndex(g=>g.id===r.id);if(a<0){const g={direction:"asc",id:r.id,order:s?.length};s.push(g)}else a>=0&&s[a].direction==="asc"?s[a].direction="desc":a>=0&&s[a].direction==="desc"&&s.splice(a,1);return s}))},onHeaderMenuClick:(e,t)=>{const n=c(),r=n.renderColumns?.[e];if(!r)return;const i=[{label:`Sort ${r?.title??r?.id}`},{label:"Sort Ascending",leftSection:h.jsx(re,{sprite:se}),onClick:()=>{n.setStateFN("colSort",a=>{const g=[...a??[]],d=g.findIndex(_=>_.id===r.id),u="asc";if(d<0){const _={direction:u,id:r.id,order:g?.length};g.push(_)}else d>=0&&(g[d].direction=u);return g})}},{label:"Sort Descending",leftSection:h.jsx(re,{sprite:ae}),onClick:()=>{n.setStateFN("colSort",a=>{const g=[...a??[]],d=g.findIndex(_=>_.id===r.id),u="desc";if(d<0){const _={direction:u,id:r.id,order:g?.length};g.push(_)}else d>=0&&(g[d].direction=u);return g})}},{isDivider:!0}],s=[...r.disableSort?[]:i,{label:`Filter ${r?.title??r?.id}`},{renderer:h.jsx(ie,{column:r,storeState:c()})},{isDivider:!0},{id:"refesh",label:"Refresh",onClick:()=>{c()._refresh?.()}}];n.hideMenu?.("header-menu"),n.showMenu?.("header-menu",{items:r?.getMenuItems?.("header-menu",n,void 0,r,s)??n.getMenuItems?.("header-menu",n,void 0,r,s),x:t.x,y:t.y})},onItemHovered:e=>{const t=c();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 r=t.getRowBuffer(e.location[1]);t.setState("_activeTooltip",n?.tooltip(r,e.location[1],e.location[0]))}}},onVisibleRegionChanged:(e,t,n,r)=>{const i=c();i._scrollTimeout&&clearTimeout(i._scrollTimeout);const s=()=>{const a=c(),g=Math.max(0,Math.floor(e.y/a.pageSize)),d=Math.max(0,Math.floor(a._visiblePages.y/a.pageSize)),u=g-d;if(a.progressiveScroll&&u>1){const _=c(),C=(d+2)*_.pageSize*(_.rowHeight??22);_._glideref?.scrollTo(0,{amount:C,unit:"px"},"vertical");return}a.setState("_visiblePages",e)};i.setState("_scrollTimeout",setTimeout(()=>{s()},100))},pageSize:50,ready:!1,refreshCells:(e,t,n)=>{const r=c(),i=[],s=Object.keys(r.renderColumns??[1,2,3]).length,a=e&&e>0?e:0,g=t&&t>=a?t:a+r.pageSize;for(let d=a;d<=g;d++)if(n&&n>0)i.push({cell:[n,d]});else for(let u=0;u<=s;u++)i.push({cell:[u,d]});r._glideref?.updateCells(i)},setState:(e,t)=>{o(J.produce(n=>{n[e]=t}))},setStateFN:(e,t)=>new Promise((r,i)=>{o(J.produce(s=>{if(typeof t=="function")s[e]=t(s[e]);else throw i(new Error(`Not a function ${t}`)),Error(`Not a function ${t}`)})),r()}),toCell:(e,t)=>{const n=c(),i=n.renderColumns?.[t],s=i?.id??i?.title??String(t);if(s==null||e===void 0||e===null)return i?.Cell?i?.Cell(e,t,s,void 0,n):n.RenderCell?n.RenderCell(e,t,s,void 0,n):{allowOverlay:!1,kind:O.GridCellKind.Loading};try{const a=String(s).includes(".")?Ne(s,e)??"":e?.[s];return i?.Cell?{kind:O.GridCellKind.Text,...i?.Cell(e,t,s,a,n)}:n.RenderCell?n.RenderCell(e,t,s,a,n):{allowOverlay:!0,data:a??"",displayData:String(a??""),kind:O.GridCellKind.Text}}catch{return n.RenderCell?n.RenderCell(e,t,s,e?.[s??""],n):{allowOverlay:!1,kind:O.GridCellKind.Loading,skeletonWidthVariability:50}}},total_rows:1e3,uniqueid:ve.getUUID()}),o=>{const[c,e]=o.useStore(n=>[n.setState,n.getState]),t=ce();return S.useEffect(()=>{const n=e("onMounted");if(typeof n=="function"&&n(e,c),c("mounted",!0),window&&window.document&&!window.document.getElementById("portal")){const i=window.document.createElement("div");i.id="portal",i.setAttribute("data-gridler-portal",o.uniqueid),window.document.body.appendChild(i)}return e("_events").dispatchEvent(new CustomEvent("mounted",{detail:{}})),()=>{const r=e("onUnMounted");c("mounted",!1),e("_events").dispatchEvent(new CustomEvent("unmounted",{detail:{}})),typeof r=="function"&&r()}},[c,e]),e("_events").addEventListener("reload",n=>{e("_refresh")?.()}),{...o,colSort:o.defaultSort??e("colSort")??[],hideMenu:o.hideMenu??t.hide,scrollToRowKey:o.scrollToRowKey??o.selectedRowKey??e("scrollToRowKey"),showMenu:o.showMenu??t.show,total_rows:e("total_rows")??o.total_rows}});function Ge(o){const[c,e,t,n,r]=L(a=>[a.setStateFN,a.setState,a.getState,a.addError,a.mounted]),i=S.useCallback(async a=>{const g=t("columns"),d=t("colSort"),u=t("pageSize"),_=t("colFilters"),C=t("searchStr"),w=t("searchFields"),R=t("_active_requests");e("loadingData",!0);try{if(o&&o.url){const x=new Headers;x.set("Authorization",`Token ${o.authtoken}`);const I=[{type:"limit",value:String(u??50)},{type:"offset",value:String((u??50)*a)}];d?.length&&d.length>0&&I.push({type:"sort",value:d?.map(f=>`${f.id} ${f.direction}`).reduce((f,y)=>`${f},${y}`)}),_?.filter(f=>f.value?.length>0)?.forEach(f=>{f.value&&f.value!==""&&I.push({name:`${f.id}`,op:f.operator,type:"searchop",value:f.value})}),C&&C!==""&&g?.filter(f=>!f.disableFilter&&!f.disableSearch&&!f.virtual&&((w??[]).length==0||w?.includes(f.id)))?.forEach(f=>{I.push({name:`${f.id}`,op:"contains",type:"searchor",value:C})}),o.filter&&o.filter!==""&&I.push({name:"sql_filter",type:"custom-sql-w",value:o.filter}),(o.options??[]).length>0&&I.push(...o.options??[]);const N=g?.filter(f=>!f.virtual)?.map(f=>f.id)??[];if(o.hotfields&&o.hotfields.length>0&&N?.push(o.hotfields.join(",")),N&&N.length>0&&I.push({type:"select-fields",value:N.join(",")}),I&&I.length>0){const f=V(I);for(const y in V(I))x.set(y,f[y])}const P=R?.findIndex(f=>f.page===a)??-1;if(R?.forEach(f=>{(f.page>=0&&f.page<a-2||a>=0&&f.page>a+2)&&f.controller?.abort?.()}),R&&P>=0&&R[P]){e("loadingData",!1);return}const B=new AbortController;await c("_active_requests",f=>[...f??[],{controller:B,page:a}]);const v=await fetch(`${o.url}?x-limit=${String(u??50)}&x-offset=${String((u??50)*a)}`,{headers:x,method:"GET",signal:B?.signal});if(v.ok){const f=v.headers.get("Content-Range")?.split("/");f?.[1]&&parseInt(f[1],10)>0&&e("total_rows",parseInt(f[1],10));const y=await v.json();return e("loadingData",!1),y??[]}n(`${v.status} ${v.statusText}`,"api",o.url),await c("_active_requests",f=>[...(f??[]).filter(y=>y.page!==a)])}}catch{}return e("loadingData",!1),[]},[t,o.authtoken,o.url,o.filter,JSON.stringify(o.options),e,c,n]),s=S.useCallback(async a=>{const g=t("colFilters");if(o&&o.url){const d=new Headers,u=[{type:"limit",value:String(10)},{type:"fetch-rownumber",value:a}];if(d.set("Authorization",`Token ${o.authtoken}`),g?.length&&g.length>0&&g?.filter(w=>w.value?.length>0)?.forEach(w=>{w.value&&w.value!==""&&d.set(`x-searchop-${w.operator}-${w.id}`,`${w.value}`)}),o.filter&&o.filter!==""&&u.push({name:"sql_filter",type:"custom-sql-w",value:o.filter}),o.options&&o.options.length>0){const w=V(o.options);for(const R in w)d.set(R,w[R])}if(u&&u.length>0){const w=V(u);for(const R in V(u))d.set(R,w[R])}const _=new AbortController,C=await fetch(`${o.url}?x-fetch-rownumber=${a}}`,{headers:d,method:"GET",signal:_?.signal});if(C.ok){const w=await C.json();return w?.[0]?._rownumber??w?._rownumber??0}n(`${C.status} ${C.statusText}`,"api",o.url)}return[]},[o.url,o.authtoken,o.filter,o.options,t,n]);return S.useEffect(()=>{e("useAPIQuery",i),e("askAPIRowNumber",s),t("_refresh")?.().then(()=>{const g=t("onChange"),d=t("getGridSelectedRows");if(g&&typeof g=="function"){const u=d?.();g(u)}})},[o.url,o.authtoken,o.filter,JSON.stringify(o.options),r,e]),h.jsx(h.Fragment,{})}const xe=S.memo(Ge);xe.displayName="Gridler-GlidlerAPIAdaptorForGoLangv2";function Re(o){const[c,e,t,n]=L(i=>[i.getState,i.mounted,i.setState,i._events]);S.useEffect(()=>{if(e&&o.changeOnActiveClick){const i=s=>{const{row:a,state:g}=s.detail,d=g.getRowBuffer;if(d){const u=d(a);if(!u)return;o.onRequestForm("change",u)}};return n?.addEventListener("onCellActivated",i),()=>{i&&n?.removeEventListener("onCellActivated",i)}}},[o.changeOnActiveClick,e,n]);const r=S.useCallback((i,s,a,g,d)=>{if(i==="header-menu")return d||[];const u=[];u.push(...d);const _=c("_gridSelection")?.rows.toArray()??[],C=_.length>1;if(!a){const x=_[0];x!==void 0&&(a=s.getRowBuffer(x))}const w=typeof o.descriptionField=="string"?a?.[o.descriptionField]:typeof o.descriptionField=="function"&&a?o.descriptionField(a):void 0;i==="other"&&u.push({c:"blue",label:"Add",onClick:()=>{o.onRequestForm("insert",a)}}),i==="cell"&&a||i==="menu"&&a?(u.push({c:"teal",label:"Add",leftSection:h.jsx(z.IconSquarePlus,{color:"teal",size:16}),onClick:()=>{o.onRequestForm("insert",a)}}),C?(u.push({c:"green",label:`Modify All Selected (${_.length})`,leftSection:h.jsx(z.IconEdit,{color:"green",size:16}),onClick:()=>{o.onRequestForm("change",_.map(x=>s.getRowBuffer(x)))}}),u.push({c:"red",label:`Remove All Selected (${_.length})`,leftSection:h.jsx(z.IconTrashX,{color:"maroon",size:16}),onClick:()=>{o.onRequestForm("delete",_.map(x=>s.getRowBuffer(x)))}})):(u.push({c:"green",label:`Modify${w&&o.showDescriptionInMenu?` (${w})`:""}`,leftSection:h.jsx(z.IconEdit,{color:"green",size:16}),onClick:()=>{o.onRequestForm("change",a)}}),u.push({c:"red",label:`Remove${w&&o.showDescriptionInMenu?` (${w})`:""}`,leftSection:h.jsx(z.IconTrashX,{color:"maroon",size:16}),onClick:()=>{o.onRequestForm("delete",a)}})),u.push({isDivider:!0})):(i==="cell"&&!a||i==="menu"&&!a)&&u.push({c:"red",label:"Nothing Selected",leftSection:h.jsx(z.IconExclamationMark,{color:"yellow",size:16})}),u.push({c:"orange",label:"Refresh",leftSection:h.jsx(z.IconRefresh,{color:"orange",size:16}),onClickAsync:async()=>{await c("_refresh")?.()}});const R=o.getMenuItems?o.getMenuItems(i,s,a,g,u):u;return!u||u.length===0?d||[]:R},[o.onRequestForm,c]);return S.useEffect(()=>(e&&typeof t=="function"&&c("getMenuItems")!==r&&t("getMenuItems",r),()=>{}),[o.getMenuItems,e]),h.jsx(h.Fragment,{})}function ze(o){const[c,e,t]=L(d=>[d.setState,d.getState,d.mounted]),{colFilters:n,colSort:r,columns:i,searchStr:s}=L(d=>({colFilters:d.colFilters,colOrder:d.colOrder,colSize:d.colSize,colSort:d.colSort,columns:d.columns,searchStr:d.searchStr})),a=S.useRef({colFilters:n,colSort:r,searchStr:s}),g=async d=>{const u=e("pageSize");return o.data&&Array.isArray(o.data)?(c("total_rows",o.data.length),o.data.slice(d*(u??50),(d+1)*(u??50))):[]};return S.useEffect(()=>{c("useAPIQuery",g)},[t,c]),S.useEffect(()=>{if(o.onColumnSort&&r!==a?.current?.colSort){const d=o.onColumnSort(r,i,o.data);c("total_rows",d.length),c("data",d),a.current.colSort=r,e("refreshCells")?.()}},[r,o.onColumnSort]),S.useEffect(()=>{if(o.onColumnFilter&&n!==a?.current?.colFilters){const d=o.onColumnFilter(n,i,o.data);c("total_rows",d.length),c("data",d),a.current.colFilters=n,e("refreshCells")?.()}},[n,o.onColumnFilter]),S.useEffect(()=>{if(o.onSearch&&s!==a?.current?.searchStr){const d=o.onSearch(s,i,o.data);c("total_rows",d.length),c("data",d),a.current.colFilters=n,e("refreshCells")?.()}},[s,o.onSearch]),h.jsx(h.Fragment,{})}const ue=S.memo(ze);ue.displayName="Gridler-GlidlerLocalDataAdaptor";function pe(){const{loadingData:o,onContextClick:c}=L(e=>({loadingData:e.loadingData,onContextClick:e.onContextClick}));return h.jsx(E.ActionIcon,{loading:o,mr:"xs",mt:"2px",onClick:e=>c("menu",e),variant:"subtle",children:h.jsx(z.IconMenu2,{})})}function Le(o,c){const[e,t]=L(n=>[n.setStateFN,n.getState]);return S.useImperativeHandle(c,()=>({getGlideRef:()=>t("_glideref"),getState:t,isEmpty:()=>t("isEmpty"),refresh:async n=>{const r=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{r?.()})},reload:async n=>{const r=t("refreshCells");t("loadPage")?.(n?.pageIndex??0,"all").then(()=>{r?.()})},reloadRow:async n=>{const r=t("refreshCells"),s=await t("getRowIndexByKey")?.(String(n));s&&s>=0&&r?.(s,s+1)},scrollToRow:async n=>{n&&Number(n)>=0&&e("scrollToRowKey",r=>Number(n??r))},selectRow:async n=>{n&&Number(n)>=0&&e("selectedRowKey",r=>Number(n??r))},setStateFN:e}),[]),h.jsx(h.Fragment,{children:o.children})}const qe=S.forwardRef(Le);function He(){const{_activeTooltip:o,tooltipBarProps:c}=L(e=>({_activeTooltip:e._activeTooltip,tooltipBarProps:e.tooltipBarProps}));return h.jsx("div",{"data-tooltip-bar":!0,style:{minHeight:"24px"},...c,children:o})}const Ee=S.memo(()=>{const o=S.useRef(0),c=S.useRef(""),e=S.useRef(null),{_glideref:t,_gridSelectionRows:n,colFilters:r,colOrder:i,colSize:s,colSort:a,columns:g,getRowIndexByKey:d,getState:u,loadPage:_,ready:C,scrollToRowKey:w,searchStr:R,selectedRowKey:x,setState:I,setStateFN:N,values:P}=L(v=>({_glideref:v._glideref,_gridSelectionRows:v._gridSelectionRows,colFilters:v.colFilters,colOrder:v.colOrder,colSize:v.colSize,colSort:v.colSort,columns:v.columns,getRowIndexByKey:v.getRowIndexByKey,getState:v.getState,loadPage:v.loadPage,ready:v.ready,scrollToRowKey:v.scrollToRowKey,searchStr:v.searchStr,selectedRowKey:v.selectedRowKey,setState:v.setState,setStateFN:v.setStateFN,uniqueid:v.uniqueid,values:v.values})),B=Q.useDebouncedCallback(v=>{_(0,"all").then(()=>{u("refreshCells")?.(),u("_events")?.dispatchEvent?.(new CustomEvent("onSearched",{detail:{search:v}}))})},{delay:300,leading:!1});return S.useEffect(()=>{P&&(async()=>{const f=u("_page_data"),y=u("pageSize"),F=u("keyField")??"id",M=[];for(const $ in P){let j=-1;const D=String(typeof P?.[$]=="object"?P?.[$]?.[F]:typeof P?.[$]=="string"?P?.[$]:void 0);for(const T in f){for(const H in f[T]){const G=Number(T)*y+Number(H);if(String(f[T][H]?.[F])===D){j=G;break}}if(j>=0){M.push(j);break}}if(!(j>=0)){const T=await d(D);T&&M.push(T)}}return M})().then(f=>{let y=O.CompactSelection.empty();f.forEach(F=>{y=y.add(F)}),N("_gridSelectionRows",()=>y),N("_gridSelection",F=>({columns:F?.columns??O.CompactSelection.empty(),...F,rows:y}))})},[P]),S.useEffect(()=>{const v=u("onChange");if(v&&typeof v=="function"){const y=u("getGridSelectedRows")(),F=u("values");JSON.stringify(F)!==JSON.stringify(y)&&v(y)}},[JSON.stringify(n),u]),S.useEffect(()=>{I("renderColumns",g?.map(v=>({...v,hasMenu:v?.hasMenu??!0,icon:"sort"})))},[g]),S.useEffect(()=>{if(R==null){c.current="";return}c.current!==R&&(B(R),c.current=R)},[R]),S.useEffect(()=>{a&&(I("_gridSelection",{columns:O.CompactSelection.empty(),current:void 0,rows:O.CompactSelection.empty()}),I("_gridSelectionRows",O.CompactSelection.empty()),N("renderColumns",v=>v?.map(f=>({...f,icon:f.id&&a?.find(y=>y.id===f.id)?.direction?a?.find(y=>y.id===f.id)?.direction==="asc"?"sortup":"sortdown":f.defaultIcon??"sort"}))).then(()=>{_(0,"all").then(()=>{u("refreshCells")?.(),u("_events")?.dispatchEvent?.(new CustomEvent("onColumnSorted",{detail:{cols:a}}))})}))},[a]),S.useEffect(()=>{r&&JSON.stringify(e.current)!==JSON.stringify(r)&&(_(0,"all").then(()=>{u("refreshCells")?.(),u("_events")?.dispatchEvent?.(new CustomEvent("onColumnFiltered",{detail:{filters:r}}))}),e.current=r)},[r]),S.useEffect(()=>{s&&N("renderColumns",v=>v?.map(f=>({...f,width:f.id&&s?.[f.id]?s?.[f.id]:f.width}))).then(()=>{u("refreshCells")?.()})},[s]),S.useEffect(()=>{i&&N("renderColumns",v=>v?.sort((y,F)=>i[y.id]>i[F.id]?1:-1)).then(()=>{u("refreshCells")?.()})},[i]),S.useEffect(()=>{t&&(o.current>0||(o.current=1,_(0).then(()=>{u("refreshCells")?.()})))},[C,_]),S.useEffect(()=>{const v=u("_events"),f=()=>{const y=u("selectFirstRowOnMount");if(C&&y){const F=u("scrollToRowKey");if(F&&F>=0)return;const M=u("keyField")??"id",j=u("_page_data")?.[0]?.[0],D=j?.[M],T=u("values")??[];if(!(P&&P.length>0)&&D&&D>0&&(T.length??0)===0){const H=[j,...T],G=u("onChange");G?G(H):I("values",H),I("scrollToRowKey",D)}}};return v?.addEventListener("loadPage",f),()=>{v?.removeEventListener("loadPage",f)}},[C]),S.useEffect(()=>{const v=u("ready"),f=u("_glideref"),y=u("getRowIndexByKey"),F=x??w;F&&f&&v&&y?.(F).then(M=>{if(M!==void 0){if(x){const $=u("onChange"),j=[{[u("keyField")??"id"]:x}];JSON.stringify(u("values"))!==JSON.stringify(j)&&($?$(j):I("values",j))}f.scrollTo(0,M),u("_events").dispatchEvent(new CustomEvent("scrollToRowKeyFound",{detail:{rowNumber:M,scrollToRowKey:w,selectedRowKey:x}}))}})},[w,x]),h.jsx(h.Fragment,{})});Ee.displayName="Gridler-Computer";function Be(o,c,e=1){let t;if(c===void 0?(t=0,c=o):t=o,e===0)throw new Error("Step cannot be zero");const n=[];if(e>0)for(let r=t;r<c;r+=e)n.push(r);else for(let r=t;r>c;r+=e)n.push(r);return n}const ke=S.memo(()=>{const[o,c,e,t,n,r,i,s]=L(a=>[a.setState,a.getState,a._glideref,a._visiblePages,a.pageSize,a.loadPage,a._loadingList,a.hasLocalData]);return S.useEffect(()=>{e&&o("mounted",!0)},[o]),S.useEffect(()=>{if(!e)return;const a=Math.max(0,Math.floor(t.y/n)),g=Math.floor((t.y+t.height)/n);for(const d of Be(a,g+1,1))r(d).then(()=>{const u=c("_page_data")?.[0]??{};o("isEmpty",u&&u.length>0)})},[r,n,t,e,i,s]),h.jsx(h.Fragment,{})});ke.displayName="Gridler-Pager";const Ke=o=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none">
|
|
35
35
|
<path
|
|
36
36
|
fill="${o.fgColor??"currentColor"}"
|
|
37
37
|
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"
|
|
38
38
|
></path>
|
|
39
|
-
</svg>`,We="_container_1nbyf_1",Ve={container:We},Je=o=>c=>c%2===0?void 0:{bgCell:o==="dark"?"#303030":"#e1effc"},Ye=()=>{const o=E.useMantineTheme(),{colorScheme:c}=E.useMantineColorScheme(),{enableOddEvenRowColor:e,focused:t}=L(u=>({enableOddEvenRowColor:u.enableOddEvenRowColor,focused:u.focused})),n={auto:t?E.lighten(o.colors.blue[4],.9):"#ffffff",dark:t?E.darken("#bacfe0",.2):o.colors.dark[7],light:t?E.lighten(o.colors.blue[4],.8):"#ffffff"}[c],r={accentColor:"none",accentLight:o.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:o.colors.blue[4],textBubble:"#ffffff",textDark:"#dedede",textGroupHeader:"#dedede",textHeader:"#a1a1a1",textHeaderSelected:"#000000",textLight:"#a0a0a0",textMedium:"#b8b8b8"},s=c==="dark"?r:{bgCell:n,textGroupHeader:"#2c5491"},[a,g]=S.useState(s);return S.useEffect(()=>{g(s)},[c,t]),{getRowThemeOverride:u=>e?Je(c)(u):void 0,gridTheme:a}},Ue=()=>{const o=S.useRef(null),c=S.useRef(!1),{height:e,ref:t,width:n}=Q.useElementSize({box:"content-box"}),{_gridSelection:r,allowMultiSelect:i,focused:s,getCellContent:a,getCellsForSelection:g,getState:d,glideProps:u,hasLocalData:_,headerHeight:C,heightProp:w,mounted:R,onCellActivated:x,onCellClicked:I,onCellEdited:
|
|
39
|
+
</svg>`,We="_container_1nbyf_1",Ve={container:We},Je=o=>c=>c%2===0?void 0:{bgCell:o==="dark"?"#303030":"#e1effc"},Ye=()=>{const o=E.useMantineTheme(),{colorScheme:c}=E.useMantineColorScheme(),{enableOddEvenRowColor:e,focused:t}=L(u=>({enableOddEvenRowColor:u.enableOddEvenRowColor,focused:u.focused})),n={auto:t?E.lighten(o.colors.blue[4],.9):"#ffffff",dark:t?E.darken("#bacfe0",.2):o.colors.dark[7],light:t?E.lighten(o.colors.blue[4],.8):"#ffffff"}[c],r={accentColor:"none",accentLight:o.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:o.colors.blue[4],textBubble:"#ffffff",textDark:"#dedede",textGroupHeader:"#dedede",textHeader:"#a1a1a1",textHeaderSelected:"#000000",textLight:"#a0a0a0",textMedium:"#b8b8b8"},s=c==="dark"?r:{bgCell:n,textGroupHeader:"#2c5491"},[a,g]=S.useState(s);return S.useEffect(()=>{g(s)},[c,t]),{getRowThemeOverride:u=>e?Je(c)(u):void 0,gridTheme:a}},Ue=()=>{const o=S.useRef(null),c=S.useRef(!1),{height:e,ref:t,width:n}=Q.useElementSize({box:"content-box"}),{_gridSelection:r,allowMultiSelect:i,focused:s,getCellContent:a,getCellsForSelection:g,getState:d,glideProps:u,hasLocalData:_,headerHeight:C,heightProp:w,mounted:R,onCellActivated:x,onCellClicked:I,onCellEdited:N,onColumnMoved:P,onColumnProposeMove:B,onColumnResize:v,onContextClick:f,onHeaderClicked:y,onHeaderMenuClick:F,onItemHovered:M,onVisibleRegionChanged:$,renderColumns:j,rowHeight:D,sections:T,selectMode:H,setState:G,setStateFN:Z,total_rows:ee,widthProp:te}=L(l=>({_gridSelection:l._gridSelection,allowMultiSelect:l.allowMultiSelect,focused:l.focused,getCellContent:l.getCellContent,getCellsForSelection:l.getCellsForSelection,getState:l.getState,glideProps:l.glideProps,hasLocalData:l.hasLocalData,headerHeight:l.headerHeight,heightProp:l.height,mounted:l.mounted,onCellActivated:l.onCellActivated,onCellClicked:l.onCellClicked,onCellEdited:l.onCellEdited,onColumnMoved:l.onColumnMoved,onColumnProposeMove:l.onColumnProposeMove,onColumnResize:l.onColumnResize,onContextClick:l.onContextClick,onHeaderClicked:l.onHeaderClicked,onHeaderMenuClick:l.onHeaderMenuClick,onItemHovered:l.onItemHovered,onVisibleRegionChanged:l.onVisibleRegionChanged,renderColumns:l.renderColumns,rowHeight:l.rowHeight,sections:l.sections,selectMode:l.selectMode,setState:l.setState,setStateFN:l.setStateFN,total_rows:l.total_rows,widthProp:l.width})),ne=Q.useMergedRef(o,l=>{Z("_glideref",()=>l??void 0);const m=d("ready"),b=!!(l&&R);m!==b&&G("ready",b)}),Y=Ye();return h.jsxs(E.Stack,{align:"stretch",gap:0,h:w??"100%",justify:"stretch",w:te??"100%",children:[T?.top,h.jsxs("div",{className:Ve.container,"data-focused":s,onContextMenu:l=>{l.preventDefault(),c.current||(c.current=!0,f("other",l),setTimeout(()=>{c.current=!1},100))},ref:t,style:{display:"flex",height:"100%",minHeight:"64px",minWidth:"32px",width:"100%"},children:[T?.left,n&&n>0&&e&&e>0&&h.jsx(O.DataEditor,{cellActivationBehavior:"double-click",columns:j??[],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",...u,getCellContent:a,getCellsForSelection:g,getRowThemeOverride:Y.getRowThemeOverride,gridSelection:r,headerHeight:C??32,headerIcons:{sort:Ke,sortdown:ae,sortup:se},onCellActivated:x,onCellClicked:I,onCellContextMenu:(l,m)=>{m.preventDefault(),u?.onCellContextMenu?.(l,m),c.current||(c.current=!0,f("cell",m,l[0],l[1]),setTimeout(()=>{c.current=!1},100))},onCellEdited:N,onColumnMoved:P,onColumnProposeMove:B,onColumnResize:v,onGridSelectionChange:l=>{let m=O.CompactSelection.empty();const b=d("_gridSelection"),p=d("keyField")??"id",q=d("getRowBuffer");for(const A of l.rows)q&&q(A)?.[p]&&(m=m.hasIndex(A)?m:m.add(A));if(H==="row"&&l.current?.range)for(let A=l.current.range.y;A<l.current.range.y+l.current.range.height;A++)q&&q(A)?.[p]&&(m=m.hasIndex(A)?m:m.add(A));if(m.length===0)for(const A of b?.rows??[])q&&q(A)?.[p]&&(m=m.hasIndex(A)?m:m.add(A));(JSON.stringify(b?.columns)!==JSON.stringify(l.columns)||JSON.stringify(b?.rows)!==JSON.stringify(m)||JSON.stringify(b?.current)!==JSON.stringify(l.current))&&(G("_gridSelection",{...l,rows:m}),G("_gridSelectionRows",m))},onHeaderClicked:y,onHeaderContextMenu:(l,m)=>{m.preventDefault(),c.current||(c.current=!0,f("header",m,l),setTimeout(()=>{c.current=!1},100))},onHeaderMenuClick:F,onItemHovered:M,onVisibleRegionChanged:$,ref:ne,rightElement:T?.rightElementDisabled?void 0:h.jsxs(E.Group,{children:[T?.rightElementStart,h.jsx(pe,{}),T?.rightElementEnd]}),rowHeight:D??22,rows:ee??0,theme:Y.gridTheme,width:n??200}),h.jsx(Ee,{}),!_&&h.jsx(ke,{}),T?.right]}),h.jsxs("div",{style:{flexGrow:0},children:[h.jsx(He,{}),T?.bottom]})]})},Xe=(o,c)=>h.jsx(Ce,{children:h.jsxs(De,{...o,persist:{name:`Gridler_${o.uniqueid}`,partialize:e=>({colOrder:e.colOrder,colSize:e.colSize}),version:1},children:[h.jsx(Ue,{}),h.jsx(qe,{ref:c}),o.children]})}),de=S.forwardRef(Xe);de.FormAdaptor=Re;de.LocalDataAdaptor=ue;exports.ColumnFilterInput=ye;exports.ColumnFilterInputOperator=be;exports.ColumnFilterSet=ie;exports.FilterOperators=we;exports.GlidlerAPIAdaptorForGoLangv2=xe;exports.GlidlerFormAdaptor=Re;exports.GlidlerLocalDataAdaptor=ue;exports.GoAPIHeaders=V;exports.Gridler=de;exports.GridlerRightMenuIcon=pe;exports.MantineBetterMenusProvider=Ce;exports.useGridlerStore=L;exports.useMantineBetterMenus=ce;
|
|
40
40
|
//# sourceMappingURL=lib.cjs.js.map
|