@hpcc-js/dgrid2 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.es6.js +3254 -0
- package/dist/index.es6.js.map +1 -0
- package/dist/index.js +3265 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
- package/src/__package__.ts +3 -0
- package/src/index.ts +2 -0
- package/src/table.css +10 -0
- package/src/table.md +57 -0
- package/src/table.tsx +165 -0
- package/src/test.ts +41 -0
- package/types/__package__.d.ts +4 -0
- package/types/__package__.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/table.d.ts +20 -0
- package/types/table.d.ts.map +1 -0
- package/types/test.d.ts +6 -0
- package/types/test.d.ts.map +1 -0
- package/types-3.4/__package__.d.ts +4 -0
- package/types-3.4/index.d.ts +3 -0
- package/types-3.4/table.d.ts +20 -0
- package/types-3.4/test.d.ts +6 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3265 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@hpcc-js/common')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@hpcc-js/common'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@hpcc-js/dgrid2"] = {}, global["@hpcc-js/common"]));
|
|
5
|
+
})(this, (function (exports, common) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var PKG_NAME = "@hpcc-js/dgrid2";
|
|
8
|
+
var PKG_VERSION = "0.0.0";
|
|
9
|
+
var BUILD_VERSION = "2.102.11";
|
|
10
|
+
|
|
11
|
+
/*! *****************************************************************************
|
|
12
|
+
Copyright (c) Microsoft Corporation.
|
|
13
|
+
|
|
14
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
+
purpose with or without fee is hereby granted.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
18
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
20
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
21
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
22
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
24
|
+
***************************************************************************** */
|
|
25
|
+
/* global Reflect, Promise */
|
|
26
|
+
|
|
27
|
+
var extendStatics = function(d, b) {
|
|
28
|
+
extendStatics = Object.setPrototypeOf ||
|
|
29
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
30
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
31
|
+
return extendStatics(d, b);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function __extends(d, b) {
|
|
35
|
+
if (typeof b !== "function" && b !== null)
|
|
36
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
37
|
+
extendStatics(d, b);
|
|
38
|
+
function __() { this.constructor = d; }
|
|
39
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function __decorate(decorators, target, key, desc) {
|
|
43
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
44
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
45
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
46
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function __metadata(metadataKey, metadataValue) {
|
|
50
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function __spreadArray(to, from, pack) {
|
|
54
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
+
if (ar || !(i in from)) {
|
|
56
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
+
ar[i] = from[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var n,l$1,u$1,t$1,o$2,r$1,f$1,e$2={},c$1=[],s$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function a$1(n,l){for(var u in l)n[u]=l[u];return n}function h$1(n){var l=n.parentNode;l&&l.removeChild(n);}function v$1(l,u,i){var t,o,r,f={};for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return y$1(l,f,t,o,null)}function y$1(n,i,t,o,r){var f={type:n,props:i,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==r?++u$1:r};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function d$1(n){return n.children}function _$1(n,l){this.props=n,this.context=l;}function k$1(n,l){if(null==l)return n.__?k$1(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?k$1(n):null}function b$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return b$1(n)}}function m$1(n){(!n.__d&&(n.__d=!0)&&t$1.push(n)&&!g$2.__r++||r$1!==l$1.debounceRendering)&&((r$1=l$1.debounceRendering)||o$2)(g$2);}function g$2(){for(var n;g$2.__r=t$1.length;)n=t$1.sort(function(n,l){return n.__v.__b-l.__v.__b}),t$1=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=a$1({},t)).__v=t.__v+1,j$2(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?k$1(t):o,t.__h),z$1(u,t),t.__e!=o&&b$1(t)));});}function w$2(n,l,u,i,t,o,r,f,s,a){var h,v,p,_,b,m,g,w=i&&i.__k||c$1,A=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(_=u.__k[h]=null==(_=l[h])||"boolean"==typeof _?null:"string"==typeof _||"number"==typeof _||"bigint"==typeof _?y$1(null,_,null,null,_):Array.isArray(_)?y$1(d$1,{children:_},null,null,null):_.__b>0?y$1(_.type,_.props,_.key,null,_.__v):_)){if(_.__=u,_.__b=u.__b+1,null===(p=w[h])||p&&_.key==p.key&&_.type===p.type)w[h]=void 0;else for(v=0;v<A;v++){if((p=w[v])&&_.key==p.key&&_.type===p.type){w[v]=void 0;break}p=null;}j$2(n,_,p=p||e$2,t,o,r,f,s,a),b=_.__e,(v=_.ref)&&p.ref!=v&&(g||(g=[]),p.ref&&g.push(p.ref,null,_),g.push(v,_.__c||b,_)),null!=b?(null==m&&(m=b),"function"==typeof _.type&&_.__k===p.__k?_.__d=s=x$2(_,s,n):s=P$1(n,_,p,w,b,s),"function"==typeof u.type&&(u.__d=s)):s&&p.__e==s&&s.parentNode!=n&&(s=k$1(p));}for(u.__e=m,h=A;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=k$1(i,h+1)),N(w[h],w[h]));if(g)for(h=0;h<g.length;h++)M$1(g[h],g[++h],g[++h]);}function x$2(n,l,u){for(var i,t=n.__k,o=0;t&&o<t.length;o++)(i=t[o])&&(i.__=n,l="function"==typeof i.type?x$2(i,l,u):P$1(u,i,i,t,i.__e,l));return l}function A$2(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){A$2(n,l);}):l.push(n)),l}function P$1(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function C$1(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||H$1(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||H$1(n,o,l[o],u[o],i);}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||s$1.test(l)?u:u+"px";}function H$1(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?T$1:I,o):n.removeEventListener(l,o?T$1:I,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function I(n){this.l[n.type+!1](l$1.event?l$1.event(n):n);}function T$1(n){this.l[n.type+!0](l$1.event?l$1.event(n):n);}function j$2(n,u,i,t,o,r,f,e,c){var s,h,v,y,p,k,b,m,g,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(s=l$1.__b)&&s(u);try{n:if("function"==typeof P){if(m=u.props,g=(s=P.contextType)&&t[s.__c],x=s?g?g.props.value:s.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in P&&P.prototype.render?u.__c=h=new P(m,x):(u.__c=h=new _$1(m,x),h.constructor=P,h.render=O$1),g&&g.sub(h),h.props=m,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=P.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=a$1({},h.__s)),a$1(h.__s,P.getDerivedStateFromProps(m,h.__s))),y=h.props,p=h.state,v)null==P.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else {if(null==P.getDerivedStateFromProps&&m!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,x)||u.__v===i.__v){h.props=m,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,p,k);});}h.context=x,h.props=m,h.state=h.__s,(s=l$1.__r)&&s(u),h.__d=!1,h.__v=u,h.__P=n,s=h.render(h.props,h.state,h.context),h.state=h.__s,null!=h.getChildContext&&(t=a$1(a$1({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,p)),A=null!=s&&s.type===d$1&&null==s.key?s.props.children:s,w$2(n,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L$1(i.__e,u,i,t,o,r,f,c);(s=l$1.diffed)&&s(u);}catch(n){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),l$1.__e(n,u,i);}}function z$1(n,u){l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function L$1(l,u,i,t,o,r,f,c){var s,a,v,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(o=!0),null!=r)for(;_<r.length;_++)if((s=r[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,r[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=o?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),r=null,c=!1;}if(null===d)y===p||c&&l.data===p||(l.data=p);else {if(r=r&&n.call(l.childNodes),a=(y=i.props||e$2).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=r)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(v||a)&&(v&&(a&&v.__html==a.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""));}if(C$1(l,p,y,o,c),v)u.__k=[];else if(_=u.props.children,w$2(l,Array.isArray(_)?_:[_],u,i,t,o&&"foreignObject"!==d,r,f,r?r[0]:i.__k&&k$1(i,0),c),null!=r)for(_=r.length;_--;)null!=r[_]&&h$1(r[_]);c||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&H$1(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&H$1(l,"checked",_,y.checked,!1));}return l}function M$1(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,i);}}function N(n,u,i){var t,o;if(l$1.unmount&&l$1.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M$1(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l$1.__e(n,u);}t.base=t.__P=null;}if(t=n.__k)for(o=0;o<t.length;o++)t[o]&&N(t[o],u,"function"!=typeof n.type);i||null==n.__e||h$1(n.__e),n.__e=n.__d=void 0;}function O$1(n,l,u){return this.constructor(n,u)}function S$1(u,i,t){var o,r,f;l$1.__&&l$1.__(u,i),r=(o="function"==typeof t)?null:t&&t.__k||i.__k,f=[],j$2(i,u=(!o&&t||i).__k=v$1(d$1,null,[u]),r||e$2,e$2,void 0!==i.ownerSVGElement,!o&&t?[t]:r?null:i.firstChild?n.call(i.childNodes):null,f,!o&&t?t:r?r.__e:i.firstChild,o),z$1(f,u);}function D(n,l){var u={__c:l="__cC"+f$1++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(m$1);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=c$1.slice,l$1={__e:function(n,l,u,i){for(var t,o,r;l=l.__;)if((t=l.__c)&&!t.__)try{if((o=t.constructor)&&null!=o.getDerivedStateFromError&&(t.setState(o.getDerivedStateFromError(n)),r=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),r=t.__d),r)return t.__E=t}catch(l){n=l;}throw n}},u$1=0,_$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=a$1({},this.state),"function"==typeof n&&(n=n(a$1({},u),this.props)),n&&a$1(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),m$1(this));},_$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),m$1(this));},_$1.prototype.render=d$1,t$1=[],o$2="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g$2.__r=0,f$1=0;
|
|
64
|
+
|
|
65
|
+
var o$1=0;function e$1(_,e,n,t,f){var l,s,u={};for(s in e)"ref"==s?l=e[s]:u[s]=e[s];var a={type:_,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--o$1,__source:f,__self:t};if("function"==typeof _&&(l=_.defaultProps))for(s in l)void 0===u[s]&&(u[s]=l[s]);return l$1.vnode&&l$1.vnode(a),a}
|
|
66
|
+
|
|
67
|
+
var t,u,r,o=0,i=[],c=l$1.__b,f=l$1.__r,e=l$1.diffed,a=l$1.__c,v=l$1.unmount;function l(t,r){l$1.__h&&l$1.__h(u,t,o||r),o=0;var i=u.__H||(u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function m(n){return o=1,p(w$1,n)}function p(n,r,o){var i=l(t++,2);return i.t=n,i.__c||(i.__=[o?o(r):w$1(void 0,r),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}));}],i.__c=u),i.__}function y(r,o){var i=l(t++,3);!l$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__H.__h.push(i));}function d(r,o){var i=l(t++,4);!l$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__h.push(i));}function h(n){return o=5,_(function(){return {current:n}},[])}function s(n,t,u){o=6,d(function(){return "function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==u?u:u.concat(n));}function _(n,u){var r=l(t++,7);return k(r.__H,u)&&(r.__=n(),r.__H=u,r.__h=n),r.__}function A$1(n,t){return o=8,_(function(){return n},t)}function F(n){var r=u.context[n.__c],o=l(t++,9);return o.c=n,r?(null==o.__&&(o.__=!0,r.sub(u)),r.props.value):n.__}function x$1(){for(var t;t=i.shift();)if(t.__P)try{t.__H.__h.forEach(g$1),t.__H.__h.forEach(j$1),t.__H.__h=[];}catch(u){t.__H.__h=[],l$1.__e(u,t.__v);}}l$1.__b=function(n){u=null,c&&c(n);},l$1.__r=function(n){f&&f(n),t=0;var r=(u=n.__c).__H;r&&(r.__h.forEach(g$1),r.__h.forEach(j$1),r.__h=[]);},l$1.diffed=function(t){e&&e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===l$1.requestAnimationFrame||((r=l$1.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x$1)),u=null;},l$1.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g$1),t.__h=t.__h.filter(function(n){return !n.__||j$1(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],l$1.__e(r,t.__v);}}),a&&a(t,u);},l$1.unmount=function(t){v&&v(t);var u,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{g$1(n);}catch(n){u=n;}}),u&&l$1.__e(u,r.__v));};var b="function"==typeof requestAnimationFrame;function g$1(n){var t=u,r=n.__c;"function"==typeof r&&(n.__c=void 0,r()),u=t;}function j$1(n){var t=u;n.__c=n.__(),u=t;}function k(n,t){return !n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function w$1(n,t){return "function"==typeof t?t(n):t}
|
|
68
|
+
|
|
69
|
+
function C(n,t){for(var e in t)n[e]=t[e];return n}function S(n,t){for(var e in n)if("__source"!==e&&!(e in t))return !0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return !0;return !1}function E(n){this.props=n;}function g(n,t){function e(n){var e=this.props.ref,r=e==n.ref;return !r&&e&&(e.call?e(null):e.current=null),t?!t(this.props,n)||!r:S(this.props,n)}function r(t){return this.shouldComponentUpdate=e,v$1(n,t)}return r.displayName="Memo("+(n.displayName||n.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r}(E.prototype=new _$1).isPureReactComponent=!0,E.prototype.shouldComponentUpdate=function(n,t){return S(this.props,n)||S(this.state,t)};var w=l$1.__b;l$1.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),w&&w(n);};var R="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function x(n){function t(t){var e=C({},t);return delete e.ref,n(e,t.ref||null)}return t.$$typeof=R,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(n.displayName||n.name)+")",t}var A=l$1.__e;l$1.__e=function(n,t,e,r){if(n.then)for(var u,o=t;o=o.__;)if((u=o.__c)&&u.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),u.__c(n,t);A(n,t,e,r);};var O=l$1.unmount;function L(){this.__u=0,this.t=null,this.__b=null;}function U(n){var t=n.__.__c;return t&&t.__e&&t.__e(n)}function M(){this.u=null,this.o=null;}l$1.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&!0===n.__h&&(n.type=null),O&&O(n);},(L.prototype=new _$1).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=U(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l());};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__e){var n=r.state.__e;r.__v.__k[0]=function n(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(n,n.__c.__P,n.__c.__O);}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate();}},f=!0===t.__h;r.__u++||f||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(i,i);},L.prototype.componentWillUnmount=function(){this.t=[];},L.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var e=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function n(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c();}),t.__c.__H=null),null!=(t=C({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)})),t}(this.__b,e,r.__O=r.__P);}this.__b=null;}var u=t.__e&&v$1(d$1,null,n.fallback);return u&&(u.__h=null),[v$1(d$1,null,t.__e?null:n.children),u]};var T=function(n,t,e){if(++e[1]===e[0]&&n.o.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.o.size))for(e=n.u;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.u=e=e[2];}};(M.prototype=new _$1).__e=function(n){var t=this,e=U(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),T(t,n,r)):u();};e?e(o):o();}},M.prototype.render=function(n){this.u=null,this.o=new Map;var t=A$2(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},M.prototype.componentDidUpdate=M.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){T(n,e,t);});};var P="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,V=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,j="undefined"!=typeof document,z=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};function B(n,t,e){return null==t.__k&&(t.textContent=""),S$1(n,t),"function"==typeof e&&e(),n?n.__c:null}_$1.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(_$1.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t});}});});var H=l$1.event;function Z(){}function Y(){return this.cancelBubble}function q(){return this.defaultPrevented}l$1.event=function(n){return H&&(n=H(n)),n.persist=Z,n.isPropagationStopped=Y,n.isDefaultPrevented=q,n.nativeEvent=n};var J={configurable:!0,get:function(){return this.class}},K=l$1.vnode;l$1.vnode=function(n){var t=n.type,e=n.props,r=e;if("string"==typeof t){var u=-1===t.indexOf("-");for(var o in r={},e){var i=e[o];j&&"children"===o&&"noscript"===t||"value"===o&&"defaultValue"in e&&null==i||("defaultValue"===o&&"value"in e&&null==e.value?o="value":"download"===o&&!0===i?i="":/ondoubleclick/i.test(o)?o="ondblclick":/^onchange(textarea|input)/i.test(o+t)&&!z(e.type)?o="oninput":/^onfocus$/i.test(o)?o="onfocusin":/^onblur$/i.test(o)?o="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o)?o=o.toLowerCase():u&&V.test(o)?o=o.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===i&&(i=void 0),r[o]=i);}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=A$2(e.children).forEach(function(n){n.props.selected=-1!=r.value.indexOf(n.props.value);})),"select"==t&&null!=r.defaultValue&&(r.value=A$2(e.children).forEach(function(n){n.props.selected=r.multiple?-1!=r.defaultValue.indexOf(n.props.value):r.defaultValue==n.props.value;})),n.props=r,e.class!=e.className&&(J.enumerable="className"in e,null!=e.className&&(r.class=e.className),Object.defineProperty(r,"className",J));}n.$$typeof=P,K&&K(n);};var Q=l$1.__r;l$1.__r=function(n){Q&&Q(n);};function un(n){return !!n.__k&&(S$1(null,n),!0)}
|
|
70
|
+
|
|
71
|
+
function toVal(mix) {
|
|
72
|
+
var k, y, str='';
|
|
73
|
+
|
|
74
|
+
if (typeof mix === 'string' || typeof mix === 'number') {
|
|
75
|
+
str += mix;
|
|
76
|
+
} else if (typeof mix === 'object') {
|
|
77
|
+
if (Array.isArray(mix)) {
|
|
78
|
+
for (k=0; k < mix.length; k++) {
|
|
79
|
+
if (mix[k]) {
|
|
80
|
+
if (y = toVal(mix[k])) {
|
|
81
|
+
str && (str += ' ');
|
|
82
|
+
str += y;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
for (k in mix) {
|
|
88
|
+
if (mix[k]) {
|
|
89
|
+
str && (str += ' ');
|
|
90
|
+
str += k;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return str;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function clsx () {
|
|
100
|
+
var i=0, tmp, x, str='';
|
|
101
|
+
while (i < arguments.length) {
|
|
102
|
+
if (tmp = arguments[i++]) {
|
|
103
|
+
if (x = toVal(tmp)) {
|
|
104
|
+
str && (str += ' ');
|
|
105
|
+
str += x;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return str;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function styleInject$1(css, ref) {
|
|
113
|
+
if ( ref === void 0 ) ref = {};
|
|
114
|
+
var insertAt = ref.insertAt;
|
|
115
|
+
|
|
116
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
117
|
+
|
|
118
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
119
|
+
var style = document.createElement('style');
|
|
120
|
+
style.type = 'text/css';
|
|
121
|
+
|
|
122
|
+
if (insertAt === 'top') {
|
|
123
|
+
if (head.firstChild) {
|
|
124
|
+
head.insertBefore(style, head.firstChild);
|
|
125
|
+
} else {
|
|
126
|
+
head.appendChild(style);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
head.appendChild(style);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (style.styleSheet) {
|
|
133
|
+
style.styleSheet.cssText = css;
|
|
134
|
+
} else {
|
|
135
|
+
style.appendChild(document.createTextNode(css));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var css_248z$f = ".c1wupbe700-beta11{background-color:inherit;border-block-end:1px solid var(--rdg-border-color);border-inline-end:1px solid var(--rdg-border-color);contain:strict;contain:size layout style paint;grid-row-start:var(--rdg-grid-row-start);outline:none;overflow:hidden;overflow:clip;padding-block:0;padding-inline:8px;text-overflow:ellipsis;white-space:nowrap}.c1wupbe700-beta11[aria-selected=true]{box-shadow:inset 0 0 0 2px var(--rdg-selection-color)}.cd0kgiy700-beta11 .c1wupbe700-beta11{contain:content}.c1730fa4700-beta11{position:sticky;z-index:1}.c9dpaye700-beta11{box-shadow:var(--rdg-frozen-cell-box-shadow)}";
|
|
140
|
+
styleInject$1(css_248z$f,{"insertAt":"top"});
|
|
141
|
+
|
|
142
|
+
const cell = "c1wupbe700-beta11";
|
|
143
|
+
const cellClassname = `rdg-cell ${cell}`;
|
|
144
|
+
const cellAutoResizeClassname = "cd0kgiy700-beta11";
|
|
145
|
+
const cellFrozen = "c1730fa4700-beta11";
|
|
146
|
+
const cellFrozenClassname = `rdg-cell-frozen ${cellFrozen}`;
|
|
147
|
+
const cellFrozenLast = "c9dpaye700-beta11";
|
|
148
|
+
const cellFrozenLastClassname = `rdg-cell-frozen-last ${cellFrozenLast}`;
|
|
149
|
+
|
|
150
|
+
var css_248z$e = ".r104f42s700-beta11{--rdg-color:#000;--rdg-border-color:#ddd;--rdg-summary-border-color:#aaa;--rdg-background-color:#fff;--rdg-header-background-color:#f9f9f9;--rdg-row-hover-background-color:#f5f5f5;--rdg-row-selected-background-color:#dbecfa;--row-selected-hover-background-color:#c9e3f8;--rdg-checkbox-color:#005194;--rdg-checkbox-focus-color:#61b8ff;--rdg-checkbox-disabled-border-color:#ccc;--rdg-checkbox-disabled-background-color:#ddd;--rdg-selection-color:#66afe9;--rdg-frozen-cell-box-shadow:calc(2px*var(--rdg-sign)) 0 5px -2px hsla(0,0%,53%,.3);--rdg-font-size:14px;content-visibility:auto;background-color:var(--rdg-background-color);block-size:350px;border:1px solid var(--rdg-border-color);box-sizing:border-box;color:var(--rdg-color);color-scheme:var(--rdg-color-scheme,light dark);contain:strict;contain:size layout style paint;display:grid;font-size:var(--rdg-font-size);overflow:auto;user-select:none}@supports not (contain:strict){.r104f42s700-beta11{position:relative;z-index:0}}.r104f42s700-beta11 *,.r104f42s700-beta11 :after,.r104f42s700-beta11 :before{box-sizing:inherit}.r104f42s700-beta11:before{block-size:var(--rdg-grid-block-size);content:\"\";inline-size:var(--rdg-grid-inline-size);inset-block-start:0;inset-inline-start:0;position:absolute}.r104f42s700-beta11.rdg-dark{--rdg-color-scheme:dark;--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}.r104f42s700-beta11.rdg-light{--rdg-color-scheme:light}@media (prefers-color-scheme:dark){.r104f42s700-beta11:not(.rdg-light){--rdg-color:#ddd;--rdg-border-color:#444;--rdg-summary-border-color:#555;--rdg-background-color:#212121;--rdg-header-background-color:#1b1b1b;--rdg-row-hover-background-color:#171717;--rdg-row-selected-background-color:#1a73bc;--row-selected-hover-background-color:#1768ab;--rdg-checkbox-color:#94cfff;--rdg-checkbox-focus-color:#c7e6ff;--rdg-checkbox-disabled-border-color:#000;--rdg-checkbox-disabled-background-color:#333}}.v7ly7s700-beta11.r1otpg64700-beta11{cursor:move}.fc4f4zb700-beta11{grid-column-start:1;inset-inline-start:0;position:sticky}";
|
|
151
|
+
styleInject$1(css_248z$e,{"insertAt":"top"});
|
|
152
|
+
|
|
153
|
+
const root = "r104f42s700-beta11";
|
|
154
|
+
const rootClassname = `rdg ${root}`;
|
|
155
|
+
const viewportDragging = "v7ly7s700-beta11";
|
|
156
|
+
const viewportDraggingClassname = `rdg-viewport-dragging ${viewportDragging}`;
|
|
157
|
+
const focusSinkClassname = "fc4f4zb700-beta11";
|
|
158
|
+
|
|
159
|
+
var css_248z$d = ".r1otpg64700-beta11{background-color:var(--rdg-background-color);display:contents;line-height:var(--rdg-row-height)}.r1otpg64700-beta11:hover{background-color:var(--rdg-row-hover-background-color)}.r1otpg64700-beta11[aria-selected=true]{background-color:var(--rdg-row-selected-background-color)}.r1otpg64700-beta11[aria-selected=true]:hover{background-color:var(--row-selected-hover-background-color)}.rel5gk2700-beta11{outline:none}.rel5gk2700-beta11>.c1wupbe700-beta11{box-shadow:inset 0 2px 0 0 var(--rdg-selection-color),inset 0 -2px 0 0 var(--rdg-selection-color)}.rel5gk2700-beta11>.c1wupbe700-beta11:first-child{box-shadow:inset 0 2px 0 0 var(--rdg-selection-color),inset 0 -2px 0 0 var(--rdg-selection-color),inset calc(2px*var(--rdg-sign)) 0 0 0 var(--rdg-selection-color)}.rel5gk2700-beta11>.c1wupbe700-beta11:last-child{box-shadow:inset 0 2px 0 0 var(--rdg-selection-color),inset 0 -2px 0 0 var(--rdg-selection-color),inset calc(-2px*var(--rdg-sign)) 0 0 0 var(--rdg-selection-color)}.rel5gk2700-beta11>.c9dpaye700-beta11{box-shadow:inset 0 2px 0 0 var(--rdg-selection-color),inset 0 -2px 0 0 var(--rdg-selection-color),var(--rdg-frozen-cell-box-shadow)}";
|
|
160
|
+
styleInject$1(css_248z$d,{"insertAt":"top"});
|
|
161
|
+
|
|
162
|
+
const row = "r1otpg64700-beta11";
|
|
163
|
+
const rowClassname = `rdg-row ${row}`;
|
|
164
|
+
const rowSelected = "rel5gk2700-beta11";
|
|
165
|
+
const rowSelectedClassname = `rdg-row-selected ${rowSelected}`;
|
|
166
|
+
|
|
167
|
+
var css_248z$c = ".cd9l4jz700-beta11{align-items:center;cursor:pointer;display:flex;inset:0;justify-content:center;margin-inline-end:1px;position:absolute}.c1noyk41700-beta11{all:unset}.cdwjxv8700-beta11{background-color:var(--rdg-background-color);block-size:20px;border:2px solid var(--rdg-border-color);content:\"\";inline-size:20px}.c1noyk41700-beta11:checked+.cdwjxv8700-beta11{background-color:var(--rdg-checkbox-color);box-shadow:inset 0 0 0 4px var(--rdg-background-color)}.c1noyk41700-beta11:focus+.cdwjxv8700-beta11{border-color:var(--rdg-checkbox-focus-color)}.cca4mwn700-beta11{cursor:default}.cca4mwn700-beta11 .cdwjxv8700-beta11{background-color:var(--rdg-checkbox-disabled-background-color);border-color:var(--rdg-checkbox-disabled-border-color)}";
|
|
168
|
+
styleInject$1(css_248z$c,{"insertAt":"top"});
|
|
169
|
+
|
|
170
|
+
const checkboxLabel = "cd9l4jz700-beta11";
|
|
171
|
+
const checkboxLabelClassname = `rdg-checkbox-label ${checkboxLabel}`;
|
|
172
|
+
const checkboxInput = "c1noyk41700-beta11";
|
|
173
|
+
const checkboxInputClassname = `rdg-checkbox-input ${checkboxInput}`;
|
|
174
|
+
const checkbox = "cdwjxv8700-beta11";
|
|
175
|
+
const checkboxClassname = `rdg-checkbox ${checkbox}`;
|
|
176
|
+
const checkboxLabelDisabled = "cca4mwn700-beta11";
|
|
177
|
+
const checkboxLabelDisabledClassname = `rdg-checkbox-label-disabled ${checkboxLabelDisabled}`;
|
|
178
|
+
const CheckboxFormatter = /*#__PURE__*/x(function CheckboxFormatter({
|
|
179
|
+
onChange,
|
|
180
|
+
...props
|
|
181
|
+
}, ref) {
|
|
182
|
+
function handleChange(e) {
|
|
183
|
+
onChange(e.target.checked, e.nativeEvent.shiftKey);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return /*#__PURE__*/e$1("label", {
|
|
187
|
+
className: clsx(checkboxLabelClassname, props.disabled && checkboxLabelDisabledClassname),
|
|
188
|
+
children: [/*#__PURE__*/e$1("input", {
|
|
189
|
+
type: "checkbox",
|
|
190
|
+
ref: ref,
|
|
191
|
+
...props,
|
|
192
|
+
className: checkboxInputClassname,
|
|
193
|
+
onChange: handleChange
|
|
194
|
+
}), /*#__PURE__*/e$1("div", {
|
|
195
|
+
className: checkboxClassname
|
|
196
|
+
})]
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const useLayoutEffect = typeof window === 'undefined' ? y : d;
|
|
201
|
+
|
|
202
|
+
function useFocusRef(isSelected) {
|
|
203
|
+
const ref = h(null);
|
|
204
|
+
useLayoutEffect(() => {
|
|
205
|
+
var _ref$current;
|
|
206
|
+
|
|
207
|
+
if (!isSelected) return;
|
|
208
|
+
(_ref$current = ref.current) == null ? void 0 : _ref$current.focus({
|
|
209
|
+
preventScroll: true
|
|
210
|
+
});
|
|
211
|
+
}, [isSelected]);
|
|
212
|
+
return {
|
|
213
|
+
ref,
|
|
214
|
+
tabIndex: isSelected ? 0 : -1
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const DataGridDefaultComponentsContext = /*#__PURE__*/D(undefined);
|
|
219
|
+
const DataGridDefaultComponentsProvider = DataGridDefaultComponentsContext.Provider;
|
|
220
|
+
function useDefaultComponents() {
|
|
221
|
+
return F(DataGridDefaultComponentsContext);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function SelectCellFormatter({
|
|
225
|
+
value,
|
|
226
|
+
isCellSelected,
|
|
227
|
+
disabled,
|
|
228
|
+
onChange,
|
|
229
|
+
'aria-label': ariaLabel,
|
|
230
|
+
'aria-labelledby': ariaLabelledBy
|
|
231
|
+
}) {
|
|
232
|
+
const {
|
|
233
|
+
ref,
|
|
234
|
+
tabIndex
|
|
235
|
+
} = useFocusRef(isCellSelected);
|
|
236
|
+
const Formatter = useDefaultComponents().checkboxFormatter;
|
|
237
|
+
return /*#__PURE__*/e$1(Formatter, {
|
|
238
|
+
"aria-label": ariaLabel,
|
|
239
|
+
"aria-labelledby": ariaLabelledBy,
|
|
240
|
+
ref: ref,
|
|
241
|
+
tabIndex: tabIndex,
|
|
242
|
+
disabled: disabled,
|
|
243
|
+
checked: value,
|
|
244
|
+
onChange: onChange
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function ValueFormatter(props) {
|
|
249
|
+
try {
|
|
250
|
+
return /*#__PURE__*/e$1(d$1, {
|
|
251
|
+
children: props.row[props.column.key]
|
|
252
|
+
});
|
|
253
|
+
} catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
var css_248z$b = ".gch972y700-beta11{outline:none}.cz2qf0d700-beta11{stroke:currentColor;stroke-width:1.5px;fill:transparent;margin-inline-start:4px;vertical-align:middle}.cz2qf0d700-beta11>path{transition:d .1s}";
|
|
259
|
+
styleInject$1(css_248z$b,{"insertAt":"top"});
|
|
260
|
+
|
|
261
|
+
const groupCellContent = "gch972y700-beta11";
|
|
262
|
+
const groupCellContentClassname = `rdg-group-cell-content ${groupCellContent}`;
|
|
263
|
+
const caret = "cz2qf0d700-beta11";
|
|
264
|
+
const caretClassname = `rdg-caret ${caret}`;
|
|
265
|
+
function ToggleGroupFormatter({
|
|
266
|
+
groupKey,
|
|
267
|
+
isExpanded,
|
|
268
|
+
isCellSelected,
|
|
269
|
+
toggleGroup
|
|
270
|
+
}) {
|
|
271
|
+
const {
|
|
272
|
+
ref,
|
|
273
|
+
tabIndex
|
|
274
|
+
} = useFocusRef(isCellSelected);
|
|
275
|
+
|
|
276
|
+
function handleKeyDown({
|
|
277
|
+
key
|
|
278
|
+
}) {
|
|
279
|
+
if (key === 'Enter') {
|
|
280
|
+
toggleGroup();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const d = isExpanded ? 'M1 1 L 7 7 L 13 1' : 'M1 7 L 7 1 L 13 7';
|
|
285
|
+
return /*#__PURE__*/e$1("span", {
|
|
286
|
+
ref: ref,
|
|
287
|
+
className: groupCellContentClassname,
|
|
288
|
+
tabIndex: tabIndex,
|
|
289
|
+
onKeyDown: handleKeyDown,
|
|
290
|
+
children: [groupKey, /*#__PURE__*/e$1("svg", {
|
|
291
|
+
viewBox: "0 0 14 8",
|
|
292
|
+
width: "14",
|
|
293
|
+
height: "8",
|
|
294
|
+
className: caretClassname,
|
|
295
|
+
"aria-hidden": true,
|
|
296
|
+
children: /*#__PURE__*/e$1("path", {
|
|
297
|
+
d: d
|
|
298
|
+
})
|
|
299
|
+
})]
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const RowSelectionContext = /*#__PURE__*/D(undefined);
|
|
304
|
+
const RowSelectionProvider = RowSelectionContext.Provider;
|
|
305
|
+
const RowSelectionChangeContext = /*#__PURE__*/D(undefined);
|
|
306
|
+
const RowSelectionChangeProvider = RowSelectionChangeContext.Provider;
|
|
307
|
+
function useRowSelection() {
|
|
308
|
+
const rowSelectionContext = F(RowSelectionContext);
|
|
309
|
+
const rowSelectionChangeContext = F(RowSelectionChangeContext);
|
|
310
|
+
|
|
311
|
+
if (rowSelectionContext === undefined || rowSelectionChangeContext === undefined) {
|
|
312
|
+
throw new Error('useRowSelection must be used within DataGrid cells');
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return [rowSelectionContext, rowSelectionChangeContext];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const SELECT_COLUMN_KEY = 'select-row';
|
|
319
|
+
|
|
320
|
+
function SelectFormatter(props) {
|
|
321
|
+
const [isRowSelected, onRowSelectionChange] = useRowSelection();
|
|
322
|
+
return /*#__PURE__*/e$1(SelectCellFormatter, {
|
|
323
|
+
"aria-label": "Select",
|
|
324
|
+
isCellSelected: props.isCellSelected,
|
|
325
|
+
value: isRowSelected,
|
|
326
|
+
onChange: (checked, isShiftClick) => {
|
|
327
|
+
onRowSelectionChange({
|
|
328
|
+
row: props.row,
|
|
329
|
+
checked,
|
|
330
|
+
isShiftClick
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function SelectGroupFormatter(props) {
|
|
337
|
+
const [isRowSelected, onRowSelectionChange] = useRowSelection();
|
|
338
|
+
return /*#__PURE__*/e$1(SelectCellFormatter, {
|
|
339
|
+
"aria-label": "Select Group",
|
|
340
|
+
isCellSelected: props.isCellSelected,
|
|
341
|
+
value: isRowSelected,
|
|
342
|
+
onChange: checked => {
|
|
343
|
+
onRowSelectionChange({
|
|
344
|
+
row: props.row,
|
|
345
|
+
checked,
|
|
346
|
+
isShiftClick: false
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const SelectColumn = {
|
|
353
|
+
key: SELECT_COLUMN_KEY,
|
|
354
|
+
name: '',
|
|
355
|
+
width: 35,
|
|
356
|
+
maxWidth: 35,
|
|
357
|
+
resizable: false,
|
|
358
|
+
sortable: false,
|
|
359
|
+
frozen: true,
|
|
360
|
+
|
|
361
|
+
headerRenderer(props) {
|
|
362
|
+
return /*#__PURE__*/e$1(SelectCellFormatter, {
|
|
363
|
+
"aria-label": "Select All",
|
|
364
|
+
isCellSelected: props.isCellSelected,
|
|
365
|
+
value: props.allRowsSelected,
|
|
366
|
+
onChange: props.onAllRowsSelectionChange
|
|
367
|
+
});
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
formatter: SelectFormatter,
|
|
371
|
+
groupFormatter: SelectGroupFormatter
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
function getColSpan(column, lastFrozenColumnIndex, args) {
|
|
375
|
+
const colSpan = typeof column.colSpan === 'function' ? column.colSpan(args) : 1;
|
|
376
|
+
|
|
377
|
+
if (Number.isInteger(colSpan) && colSpan > 1 && (!column.frozen || column.idx + colSpan - 1 <= lastFrozenColumnIndex)) {
|
|
378
|
+
return colSpan;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const nonInputKeys = new Set(['Unidentified', 'Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'FnLock', 'Meta', 'NumLock', 'ScrollLock', 'Shift', 'Tab', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'End', 'Home', 'PageDown', 'PageUp', 'Insert', 'ContextMenu', 'Escape', 'Pause', 'Play', 'PrintScreen', 'F1', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12']);
|
|
385
|
+
function isCtrlKeyHeldDown(e) {
|
|
386
|
+
return (e.ctrlKey || e.metaKey) && e.key !== 'Control';
|
|
387
|
+
}
|
|
388
|
+
function isDefaultCellInput(event) {
|
|
389
|
+
return !nonInputKeys.has(event.key);
|
|
390
|
+
}
|
|
391
|
+
function onEditorNavigation({
|
|
392
|
+
key,
|
|
393
|
+
target
|
|
394
|
+
}) {
|
|
395
|
+
if (key === 'Tab' && (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement)) {
|
|
396
|
+
return target.matches('.rdg-editor-container > :only-child, .rdg-editor-container > label:only-child > :only-child');
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function isSelectedCellEditable({
|
|
403
|
+
selectedPosition,
|
|
404
|
+
columns,
|
|
405
|
+
rows,
|
|
406
|
+
isGroupRow
|
|
407
|
+
}) {
|
|
408
|
+
const column = columns[selectedPosition.idx];
|
|
409
|
+
const row = rows[selectedPosition.rowIdx];
|
|
410
|
+
return !isGroupRow(row) && isCellEditable(column, row);
|
|
411
|
+
}
|
|
412
|
+
function isCellEditable(column, row) {
|
|
413
|
+
return column.editor != null && !column.rowGroup && (typeof column.editable === 'function' ? column.editable(row) : column.editable) !== false;
|
|
414
|
+
}
|
|
415
|
+
function getSelectedCellColSpan({
|
|
416
|
+
rows,
|
|
417
|
+
summaryRows,
|
|
418
|
+
rowIdx,
|
|
419
|
+
lastFrozenColumnIndex,
|
|
420
|
+
column,
|
|
421
|
+
isGroupRow
|
|
422
|
+
}) {
|
|
423
|
+
if (rowIdx === -1) {
|
|
424
|
+
return getColSpan(column, lastFrozenColumnIndex, {
|
|
425
|
+
type: 'HEADER'
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (rowIdx >= 0 && rowIdx < rows.length) {
|
|
430
|
+
const row = rows[rowIdx];
|
|
431
|
+
|
|
432
|
+
if (!isGroupRow(row)) {
|
|
433
|
+
return getColSpan(column, lastFrozenColumnIndex, {
|
|
434
|
+
type: 'ROW',
|
|
435
|
+
row
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (summaryRows) {
|
|
443
|
+
return getColSpan(column, lastFrozenColumnIndex, {
|
|
444
|
+
type: 'SUMMARY',
|
|
445
|
+
row: summaryRows[rowIdx - rows.length]
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
function getNextSelectedCellPosition({
|
|
452
|
+
cellNavigationMode,
|
|
453
|
+
columns,
|
|
454
|
+
colSpanColumns,
|
|
455
|
+
rows,
|
|
456
|
+
summaryRows,
|
|
457
|
+
minRowIdx,
|
|
458
|
+
maxRowIdx,
|
|
459
|
+
currentPosition: {
|
|
460
|
+
idx: currentIdx
|
|
461
|
+
},
|
|
462
|
+
nextPosition,
|
|
463
|
+
lastFrozenColumnIndex,
|
|
464
|
+
isCellWithinBounds,
|
|
465
|
+
isGroupRow
|
|
466
|
+
}) {
|
|
467
|
+
let {
|
|
468
|
+
idx: nextIdx,
|
|
469
|
+
rowIdx: nextRowIdx
|
|
470
|
+
} = nextPosition;
|
|
471
|
+
|
|
472
|
+
const setColSpan = moveRight => {
|
|
473
|
+
if (nextRowIdx >= 0 && nextRowIdx < rows.length) {
|
|
474
|
+
const row = rows[nextRowIdx];
|
|
475
|
+
if (isGroupRow(row)) return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
for (const column of colSpanColumns) {
|
|
479
|
+
const colIdx = column.idx;
|
|
480
|
+
if (colIdx > nextIdx) break;
|
|
481
|
+
const colSpan = getSelectedCellColSpan({
|
|
482
|
+
rows,
|
|
483
|
+
summaryRows,
|
|
484
|
+
rowIdx: nextRowIdx,
|
|
485
|
+
lastFrozenColumnIndex,
|
|
486
|
+
column,
|
|
487
|
+
isGroupRow
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
if (colSpan && nextIdx > colIdx && nextIdx < colSpan + colIdx) {
|
|
491
|
+
nextIdx = colIdx + (moveRight ? colSpan : 0);
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
if (isCellWithinBounds(nextPosition)) {
|
|
498
|
+
setColSpan(nextIdx - currentIdx > 0);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (cellNavigationMode !== 'NONE') {
|
|
502
|
+
const columnsCount = columns.length;
|
|
503
|
+
const isAfterLastColumn = nextIdx === columnsCount;
|
|
504
|
+
const isBeforeFirstColumn = nextIdx === -1;
|
|
505
|
+
|
|
506
|
+
if (isAfterLastColumn) {
|
|
507
|
+
if (cellNavigationMode === 'CHANGE_ROW') {
|
|
508
|
+
const isLastRow = nextRowIdx === maxRowIdx;
|
|
509
|
+
|
|
510
|
+
if (!isLastRow) {
|
|
511
|
+
nextIdx = 0;
|
|
512
|
+
nextRowIdx += 1;
|
|
513
|
+
}
|
|
514
|
+
} else {
|
|
515
|
+
nextIdx = 0;
|
|
516
|
+
}
|
|
517
|
+
} else if (isBeforeFirstColumn) {
|
|
518
|
+
if (cellNavigationMode === 'CHANGE_ROW') {
|
|
519
|
+
const isFirstRow = nextRowIdx === minRowIdx;
|
|
520
|
+
|
|
521
|
+
if (!isFirstRow) {
|
|
522
|
+
nextRowIdx -= 1;
|
|
523
|
+
nextIdx = columnsCount - 1;
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
nextIdx = columnsCount - 1;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
setColSpan(false);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return {
|
|
534
|
+
idx: nextIdx,
|
|
535
|
+
rowIdx: nextRowIdx
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function canExitGrid({
|
|
539
|
+
cellNavigationMode,
|
|
540
|
+
maxColIdx,
|
|
541
|
+
minRowIdx,
|
|
542
|
+
maxRowIdx,
|
|
543
|
+
selectedPosition: {
|
|
544
|
+
rowIdx,
|
|
545
|
+
idx
|
|
546
|
+
},
|
|
547
|
+
shiftKey
|
|
548
|
+
}) {
|
|
549
|
+
if (cellNavigationMode === 'NONE' || cellNavigationMode === 'CHANGE_ROW') {
|
|
550
|
+
const atLastCellInRow = idx === maxColIdx;
|
|
551
|
+
const atFirstCellInRow = idx === 0;
|
|
552
|
+
const atLastRow = rowIdx === maxRowIdx;
|
|
553
|
+
const atFirstRow = rowIdx === minRowIdx;
|
|
554
|
+
return shiftKey ? atFirstCellInRow && atFirstRow : atLastCellInRow && atLastRow;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const {
|
|
561
|
+
min,
|
|
562
|
+
max,
|
|
563
|
+
round,
|
|
564
|
+
floor,
|
|
565
|
+
sign,
|
|
566
|
+
abs
|
|
567
|
+
} = Math;
|
|
568
|
+
function assertIsValidKeyGetter(keyGetter) {
|
|
569
|
+
if (typeof keyGetter !== 'function') {
|
|
570
|
+
throw new Error('Please specify the rowKeyGetter prop to use selection');
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function getRowStyle(rowIdx, height) {
|
|
574
|
+
if (height !== undefined) {
|
|
575
|
+
return {
|
|
576
|
+
'--rdg-grid-row-start': rowIdx,
|
|
577
|
+
'--rdg-row-height': `${height}px`
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return {
|
|
582
|
+
'--rdg-grid-row-start': rowIdx
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function getCellStyle(column, colSpan) {
|
|
586
|
+
return {
|
|
587
|
+
gridColumnStart: column.idx + 1,
|
|
588
|
+
gridColumnEnd: colSpan !== undefined ? `span ${colSpan}` : undefined,
|
|
589
|
+
insetInlineStart: column.frozen ? `var(--rdg-frozen-left-${column.idx})` : undefined
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function getCellClassname(column, ...extraClasses) {
|
|
593
|
+
return clsx(cellClassname, ...extraClasses, column.frozen && cellFrozenClassname, column.isLastFrozenColumn && cellFrozenLastClassname);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function useCalculatedColumns({
|
|
597
|
+
rawColumns,
|
|
598
|
+
columnWidths,
|
|
599
|
+
viewportWidth,
|
|
600
|
+
scrollLeft,
|
|
601
|
+
defaultColumnOptions,
|
|
602
|
+
rawGroupBy,
|
|
603
|
+
enableVirtualization
|
|
604
|
+
}) {
|
|
605
|
+
var _defaultColumnOptions, _defaultColumnOptions2, _defaultColumnOptions3, _defaultColumnOptions4;
|
|
606
|
+
|
|
607
|
+
const minColumnWidth = (_defaultColumnOptions = defaultColumnOptions == null ? void 0 : defaultColumnOptions.minWidth) != null ? _defaultColumnOptions : 80;
|
|
608
|
+
const defaultFormatter = (_defaultColumnOptions2 = defaultColumnOptions == null ? void 0 : defaultColumnOptions.formatter) != null ? _defaultColumnOptions2 : ValueFormatter;
|
|
609
|
+
const defaultSortable = (_defaultColumnOptions3 = defaultColumnOptions == null ? void 0 : defaultColumnOptions.sortable) != null ? _defaultColumnOptions3 : false;
|
|
610
|
+
const defaultResizable = (_defaultColumnOptions4 = defaultColumnOptions == null ? void 0 : defaultColumnOptions.resizable) != null ? _defaultColumnOptions4 : false;
|
|
611
|
+
const {
|
|
612
|
+
columns,
|
|
613
|
+
colSpanColumns,
|
|
614
|
+
lastFrozenColumnIndex,
|
|
615
|
+
groupBy
|
|
616
|
+
} = _(() => {
|
|
617
|
+
const groupBy = [];
|
|
618
|
+
let lastFrozenColumnIndex = -1;
|
|
619
|
+
const columns = rawColumns.map(rawColumn => {
|
|
620
|
+
var _rawGroupBy$includes, _rawColumn$sortable, _rawColumn$resizable, _rawColumn$formatter;
|
|
621
|
+
|
|
622
|
+
const rowGroup = (_rawGroupBy$includes = rawGroupBy == null ? void 0 : rawGroupBy.includes(rawColumn.key)) != null ? _rawGroupBy$includes : false;
|
|
623
|
+
const frozen = rowGroup || rawColumn.frozen || false;
|
|
624
|
+
const column = { ...rawColumn,
|
|
625
|
+
idx: 0,
|
|
626
|
+
frozen,
|
|
627
|
+
isLastFrozenColumn: false,
|
|
628
|
+
rowGroup,
|
|
629
|
+
sortable: (_rawColumn$sortable = rawColumn.sortable) != null ? _rawColumn$sortable : defaultSortable,
|
|
630
|
+
resizable: (_rawColumn$resizable = rawColumn.resizable) != null ? _rawColumn$resizable : defaultResizable,
|
|
631
|
+
formatter: (_rawColumn$formatter = rawColumn.formatter) != null ? _rawColumn$formatter : defaultFormatter
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
if (rowGroup) {
|
|
635
|
+
var _column$groupFormatte;
|
|
636
|
+
|
|
637
|
+
(_column$groupFormatte = column.groupFormatter) != null ? _column$groupFormatte : column.groupFormatter = ToggleGroupFormatter;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (frozen) {
|
|
641
|
+
lastFrozenColumnIndex++;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return column;
|
|
645
|
+
});
|
|
646
|
+
columns.sort(({
|
|
647
|
+
key: aKey,
|
|
648
|
+
frozen: frozenA
|
|
649
|
+
}, {
|
|
650
|
+
key: bKey,
|
|
651
|
+
frozen: frozenB
|
|
652
|
+
}) => {
|
|
653
|
+
if (aKey === SELECT_COLUMN_KEY) return -1;
|
|
654
|
+
if (bKey === SELECT_COLUMN_KEY) return 1;
|
|
655
|
+
|
|
656
|
+
if (rawGroupBy != null && rawGroupBy.includes(aKey)) {
|
|
657
|
+
if (rawGroupBy.includes(bKey)) {
|
|
658
|
+
return rawGroupBy.indexOf(aKey) - rawGroupBy.indexOf(bKey);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
return -1;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
if (rawGroupBy != null && rawGroupBy.includes(bKey)) return 1;
|
|
665
|
+
|
|
666
|
+
if (frozenA) {
|
|
667
|
+
if (frozenB) return 0;
|
|
668
|
+
return -1;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (frozenB) return 1;
|
|
672
|
+
return 0;
|
|
673
|
+
});
|
|
674
|
+
const colSpanColumns = [];
|
|
675
|
+
columns.forEach((column, idx) => {
|
|
676
|
+
column.idx = idx;
|
|
677
|
+
|
|
678
|
+
if (column.rowGroup) {
|
|
679
|
+
groupBy.push(column.key);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (column.colSpan != null) {
|
|
683
|
+
colSpanColumns.push(column);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
if (lastFrozenColumnIndex !== -1) {
|
|
688
|
+
columns[lastFrozenColumnIndex].isLastFrozenColumn = true;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
return {
|
|
692
|
+
columns,
|
|
693
|
+
colSpanColumns,
|
|
694
|
+
lastFrozenColumnIndex,
|
|
695
|
+
groupBy
|
|
696
|
+
};
|
|
697
|
+
}, [rawColumns, defaultFormatter, defaultResizable, defaultSortable, rawGroupBy]);
|
|
698
|
+
const {
|
|
699
|
+
layoutCssVars,
|
|
700
|
+
totalColumnWidth,
|
|
701
|
+
totalFrozenColumnWidth,
|
|
702
|
+
columnMetrics
|
|
703
|
+
} = _(() => {
|
|
704
|
+
const columnMetrics = new Map();
|
|
705
|
+
let left = 0;
|
|
706
|
+
let totalColumnWidth = 0;
|
|
707
|
+
let totalFrozenColumnWidth = 0;
|
|
708
|
+
let templateColumns = '';
|
|
709
|
+
let allocatedWidth = 0;
|
|
710
|
+
let unassignedColumnsCount = 0;
|
|
711
|
+
|
|
712
|
+
for (const column of columns) {
|
|
713
|
+
let width = getSpecifiedWidth(column, columnWidths, viewportWidth);
|
|
714
|
+
|
|
715
|
+
if (width === undefined) {
|
|
716
|
+
unassignedColumnsCount++;
|
|
717
|
+
} else {
|
|
718
|
+
width = clampColumnWidth(width, column, minColumnWidth);
|
|
719
|
+
allocatedWidth += width;
|
|
720
|
+
columnMetrics.set(column, {
|
|
721
|
+
width,
|
|
722
|
+
left: 0
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
for (const column of columns) {
|
|
728
|
+
let width;
|
|
729
|
+
|
|
730
|
+
if (columnMetrics.has(column)) {
|
|
731
|
+
const columnMetric = columnMetrics.get(column);
|
|
732
|
+
columnMetric.left = left;
|
|
733
|
+
({
|
|
734
|
+
width
|
|
735
|
+
} = columnMetric);
|
|
736
|
+
} else {
|
|
737
|
+
const unallocatedWidth = viewportWidth - allocatedWidth;
|
|
738
|
+
const unallocatedColumnWidth = round(unallocatedWidth / unassignedColumnsCount);
|
|
739
|
+
width = clampColumnWidth(unallocatedColumnWidth, column, minColumnWidth);
|
|
740
|
+
allocatedWidth += width;
|
|
741
|
+
unassignedColumnsCount--;
|
|
742
|
+
columnMetrics.set(column, {
|
|
743
|
+
width,
|
|
744
|
+
left
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
totalColumnWidth += width;
|
|
749
|
+
left += width;
|
|
750
|
+
templateColumns += `${width}px `;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (lastFrozenColumnIndex !== -1) {
|
|
754
|
+
const columnMetric = columnMetrics.get(columns[lastFrozenColumnIndex]);
|
|
755
|
+
totalFrozenColumnWidth = columnMetric.left + columnMetric.width;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const layoutCssVars = {
|
|
759
|
+
gridTemplateColumns: templateColumns
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
for (let i = 0; i <= lastFrozenColumnIndex; i++) {
|
|
763
|
+
const column = columns[i];
|
|
764
|
+
layoutCssVars[`--rdg-frozen-left-${column.idx}`] = `${columnMetrics.get(column).left}px`;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
return {
|
|
768
|
+
layoutCssVars,
|
|
769
|
+
totalColumnWidth,
|
|
770
|
+
totalFrozenColumnWidth,
|
|
771
|
+
columnMetrics
|
|
772
|
+
};
|
|
773
|
+
}, [columnWidths, columns, viewportWidth, minColumnWidth, lastFrozenColumnIndex]);
|
|
774
|
+
const [colOverscanStartIdx, colOverscanEndIdx] = _(() => {
|
|
775
|
+
if (!enableVirtualization) {
|
|
776
|
+
return [0, columns.length - 1];
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
const viewportLeft = scrollLeft + totalFrozenColumnWidth;
|
|
780
|
+
const viewportRight = scrollLeft + viewportWidth;
|
|
781
|
+
const lastColIdx = columns.length - 1;
|
|
782
|
+
const firstUnfrozenColumnIdx = min(lastFrozenColumnIndex + 1, lastColIdx);
|
|
783
|
+
|
|
784
|
+
if (viewportLeft >= viewportRight) {
|
|
785
|
+
return [firstUnfrozenColumnIdx, firstUnfrozenColumnIdx];
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
let colVisibleStartIdx = firstUnfrozenColumnIdx;
|
|
789
|
+
|
|
790
|
+
while (colVisibleStartIdx < lastColIdx) {
|
|
791
|
+
const {
|
|
792
|
+
left,
|
|
793
|
+
width
|
|
794
|
+
} = columnMetrics.get(columns[colVisibleStartIdx]);
|
|
795
|
+
|
|
796
|
+
if (left + width > viewportLeft) {
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
colVisibleStartIdx++;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
let colVisibleEndIdx = colVisibleStartIdx;
|
|
804
|
+
|
|
805
|
+
while (colVisibleEndIdx < lastColIdx) {
|
|
806
|
+
const {
|
|
807
|
+
left,
|
|
808
|
+
width
|
|
809
|
+
} = columnMetrics.get(columns[colVisibleEndIdx]);
|
|
810
|
+
|
|
811
|
+
if (left + width >= viewportRight) {
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
colVisibleEndIdx++;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const colOverscanStartIdx = max(firstUnfrozenColumnIdx, colVisibleStartIdx - 1);
|
|
819
|
+
const colOverscanEndIdx = min(lastColIdx, colVisibleEndIdx + 1);
|
|
820
|
+
return [colOverscanStartIdx, colOverscanEndIdx];
|
|
821
|
+
}, [columnMetrics, columns, lastFrozenColumnIndex, scrollLeft, totalFrozenColumnWidth, viewportWidth, enableVirtualization]);
|
|
822
|
+
return {
|
|
823
|
+
columns,
|
|
824
|
+
colSpanColumns,
|
|
825
|
+
colOverscanStartIdx,
|
|
826
|
+
colOverscanEndIdx,
|
|
827
|
+
layoutCssVars,
|
|
828
|
+
columnMetrics,
|
|
829
|
+
totalColumnWidth,
|
|
830
|
+
lastFrozenColumnIndex,
|
|
831
|
+
totalFrozenColumnWidth,
|
|
832
|
+
groupBy
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function getSpecifiedWidth({
|
|
837
|
+
key,
|
|
838
|
+
width
|
|
839
|
+
}, columnWidths, viewportWidth) {
|
|
840
|
+
if (columnWidths.has(key)) {
|
|
841
|
+
return columnWidths.get(key);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
if (typeof width === 'number') {
|
|
845
|
+
return width;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
if (typeof width === 'string' && /^\d+%$/.test(width)) {
|
|
849
|
+
return floor(viewportWidth * parseInt(width, 10) / 100);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
return undefined;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function clampColumnWidth(width, {
|
|
856
|
+
minWidth,
|
|
857
|
+
maxWidth
|
|
858
|
+
}, minColumnWidth) {
|
|
859
|
+
width = max(width, minWidth != null ? minWidth : minColumnWidth);
|
|
860
|
+
|
|
861
|
+
if (typeof maxWidth === 'number') {
|
|
862
|
+
return min(width, maxWidth);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
return width;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
function useGridDimensions() {
|
|
869
|
+
const gridRef = h(null);
|
|
870
|
+
const [gridWidth, setGridWidth] = m(1);
|
|
871
|
+
const [gridHeight, setGridHeight] = m(1);
|
|
872
|
+
useLayoutEffect(() => {
|
|
873
|
+
const {
|
|
874
|
+
ResizeObserver
|
|
875
|
+
} = window;
|
|
876
|
+
if (ResizeObserver == null) return;
|
|
877
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
878
|
+
const {
|
|
879
|
+
clientWidth,
|
|
880
|
+
clientHeight
|
|
881
|
+
} = gridRef.current;
|
|
882
|
+
setGridWidth(clientWidth - (devicePixelRatio % 1 === 0 ? 0 : 1));
|
|
883
|
+
setGridHeight(clientHeight);
|
|
884
|
+
});
|
|
885
|
+
resizeObserver.observe(gridRef.current);
|
|
886
|
+
return () => {
|
|
887
|
+
resizeObserver.disconnect();
|
|
888
|
+
};
|
|
889
|
+
}, []);
|
|
890
|
+
return [gridRef, gridWidth, gridHeight];
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
function useLatestFunc(fn) {
|
|
894
|
+
const ref = h(fn);
|
|
895
|
+
y(() => {
|
|
896
|
+
ref.current = fn;
|
|
897
|
+
});
|
|
898
|
+
return A$1((...args) => {
|
|
899
|
+
ref.current(...args);
|
|
900
|
+
}, []);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function useRovingCellRef(isSelected) {
|
|
904
|
+
const ref = h(null);
|
|
905
|
+
const isChildFocused = h(false);
|
|
906
|
+
const [, forceRender] = m({});
|
|
907
|
+
useLayoutEffect(() => {
|
|
908
|
+
var _ref$current;
|
|
909
|
+
|
|
910
|
+
if (!isSelected) {
|
|
911
|
+
isChildFocused.current = false;
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
if (isChildFocused.current) {
|
|
916
|
+
forceRender({});
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
(_ref$current = ref.current) == null ? void 0 : _ref$current.focus({
|
|
921
|
+
preventScroll: true
|
|
922
|
+
});
|
|
923
|
+
}, [isSelected]);
|
|
924
|
+
|
|
925
|
+
function onFocus(event) {
|
|
926
|
+
if (event.target !== ref.current) {
|
|
927
|
+
isChildFocused.current = true;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
const isFocused = isSelected && !isChildFocused.current;
|
|
932
|
+
return {
|
|
933
|
+
ref,
|
|
934
|
+
tabIndex: isFocused ? 0 : -1,
|
|
935
|
+
onFocus
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
function useViewportColumns({
|
|
940
|
+
columns,
|
|
941
|
+
colSpanColumns,
|
|
942
|
+
rows,
|
|
943
|
+
summaryRows,
|
|
944
|
+
colOverscanStartIdx,
|
|
945
|
+
colOverscanEndIdx,
|
|
946
|
+
lastFrozenColumnIndex,
|
|
947
|
+
rowOverscanStartIdx,
|
|
948
|
+
rowOverscanEndIdx,
|
|
949
|
+
isGroupRow
|
|
950
|
+
}) {
|
|
951
|
+
const startIdx = _(() => {
|
|
952
|
+
if (colOverscanStartIdx === 0) return 0;
|
|
953
|
+
let startIdx = colOverscanStartIdx;
|
|
954
|
+
|
|
955
|
+
const updateStartIdx = (colIdx, colSpan) => {
|
|
956
|
+
if (colSpan !== undefined && colIdx + colSpan > colOverscanStartIdx) {
|
|
957
|
+
startIdx = colIdx;
|
|
958
|
+
return true;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
return false;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
for (const column of colSpanColumns) {
|
|
965
|
+
const colIdx = column.idx;
|
|
966
|
+
if (colIdx >= startIdx) break;
|
|
967
|
+
|
|
968
|
+
if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
|
|
969
|
+
type: 'HEADER'
|
|
970
|
+
}))) {
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
for (let rowIdx = rowOverscanStartIdx; rowIdx <= rowOverscanEndIdx; rowIdx++) {
|
|
975
|
+
const row = rows[rowIdx];
|
|
976
|
+
if (isGroupRow(row)) continue;
|
|
977
|
+
|
|
978
|
+
if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
|
|
979
|
+
type: 'ROW',
|
|
980
|
+
row
|
|
981
|
+
}))) {
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (summaryRows != null) {
|
|
987
|
+
for (const row of summaryRows) {
|
|
988
|
+
if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, {
|
|
989
|
+
type: 'SUMMARY',
|
|
990
|
+
row
|
|
991
|
+
}))) {
|
|
992
|
+
break;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return startIdx;
|
|
999
|
+
}, [rowOverscanStartIdx, rowOverscanEndIdx, rows, summaryRows, colOverscanStartIdx, lastFrozenColumnIndex, colSpanColumns, isGroupRow]);
|
|
1000
|
+
return _(() => {
|
|
1001
|
+
const viewportColumns = [];
|
|
1002
|
+
|
|
1003
|
+
for (let colIdx = 0; colIdx <= colOverscanEndIdx; colIdx++) {
|
|
1004
|
+
const column = columns[colIdx];
|
|
1005
|
+
if (colIdx < startIdx && !column.frozen) continue;
|
|
1006
|
+
viewportColumns.push(column);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
return viewportColumns;
|
|
1010
|
+
}, [startIdx, colOverscanEndIdx, columns]);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
function isReadonlyArray(arr) {
|
|
1014
|
+
return Array.isArray(arr);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function useViewportRows({
|
|
1018
|
+
rawRows,
|
|
1019
|
+
rowHeight,
|
|
1020
|
+
clientHeight,
|
|
1021
|
+
scrollTop,
|
|
1022
|
+
groupBy,
|
|
1023
|
+
rowGrouper,
|
|
1024
|
+
expandedGroupIds,
|
|
1025
|
+
enableVirtualization
|
|
1026
|
+
}) {
|
|
1027
|
+
const [groupedRows, rowsCount] = _(() => {
|
|
1028
|
+
if (groupBy.length === 0 || rowGrouper == null) return [undefined, rawRows.length];
|
|
1029
|
+
|
|
1030
|
+
const groupRows = (rows, [groupByKey, ...remainingGroupByKeys], startRowIndex) => {
|
|
1031
|
+
let groupRowsCount = 0;
|
|
1032
|
+
const groups = {};
|
|
1033
|
+
|
|
1034
|
+
for (const [key, childRows] of Object.entries(rowGrouper(rows, groupByKey))) {
|
|
1035
|
+
const [childGroups, childRowsCount] = remainingGroupByKeys.length === 0 ? [childRows, childRows.length] : groupRows(childRows, remainingGroupByKeys, startRowIndex + groupRowsCount + 1);
|
|
1036
|
+
groups[key] = {
|
|
1037
|
+
childRows,
|
|
1038
|
+
childGroups,
|
|
1039
|
+
startRowIndex: startRowIndex + groupRowsCount
|
|
1040
|
+
};
|
|
1041
|
+
groupRowsCount += childRowsCount + 1;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
return [groups, groupRowsCount];
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
return groupRows(rawRows, groupBy, 0);
|
|
1048
|
+
}, [groupBy, rowGrouper, rawRows]);
|
|
1049
|
+
const [rows, isGroupRow] = _(() => {
|
|
1050
|
+
const allGroupRows = new Set();
|
|
1051
|
+
if (!groupedRows) return [rawRows, isGroupRow];
|
|
1052
|
+
const flattenedRows = [];
|
|
1053
|
+
|
|
1054
|
+
const expandGroup = (rows, parentId, level) => {
|
|
1055
|
+
if (isReadonlyArray(rows)) {
|
|
1056
|
+
flattenedRows.push(...rows);
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
Object.keys(rows).forEach((groupKey, posInSet, keys) => {
|
|
1061
|
+
var _expandedGroupIds$has;
|
|
1062
|
+
|
|
1063
|
+
const id = parentId !== undefined ? `${parentId}__${groupKey}` : groupKey;
|
|
1064
|
+
const isExpanded = (_expandedGroupIds$has = expandedGroupIds == null ? void 0 : expandedGroupIds.has(id)) != null ? _expandedGroupIds$has : false;
|
|
1065
|
+
const {
|
|
1066
|
+
childRows,
|
|
1067
|
+
childGroups,
|
|
1068
|
+
startRowIndex
|
|
1069
|
+
} = rows[groupKey];
|
|
1070
|
+
const groupRow = {
|
|
1071
|
+
id,
|
|
1072
|
+
parentId,
|
|
1073
|
+
groupKey,
|
|
1074
|
+
isExpanded,
|
|
1075
|
+
childRows,
|
|
1076
|
+
level,
|
|
1077
|
+
posInSet,
|
|
1078
|
+
startRowIndex,
|
|
1079
|
+
setSize: keys.length
|
|
1080
|
+
};
|
|
1081
|
+
flattenedRows.push(groupRow);
|
|
1082
|
+
allGroupRows.add(groupRow);
|
|
1083
|
+
|
|
1084
|
+
if (isExpanded) {
|
|
1085
|
+
expandGroup(childGroups, id, level + 1);
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
expandGroup(groupedRows, undefined, 0);
|
|
1091
|
+
return [flattenedRows, isGroupRow];
|
|
1092
|
+
|
|
1093
|
+
function isGroupRow(row) {
|
|
1094
|
+
return allGroupRows.has(row);
|
|
1095
|
+
}
|
|
1096
|
+
}, [expandedGroupIds, groupedRows, rawRows]);
|
|
1097
|
+
const {
|
|
1098
|
+
totalRowHeight,
|
|
1099
|
+
gridTemplateRows,
|
|
1100
|
+
getRowTop,
|
|
1101
|
+
getRowHeight,
|
|
1102
|
+
findRowIdx
|
|
1103
|
+
} = _(() => {
|
|
1104
|
+
if (typeof rowHeight === 'number') {
|
|
1105
|
+
return {
|
|
1106
|
+
totalRowHeight: rowHeight * rows.length,
|
|
1107
|
+
gridTemplateRows: ` repeat(${rows.length}, ${rowHeight}px)`,
|
|
1108
|
+
getRowTop: rowIdx => rowIdx * rowHeight,
|
|
1109
|
+
getRowHeight: () => rowHeight,
|
|
1110
|
+
findRowIdx: offset => floor(offset / rowHeight)
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
let totalRowHeight = 0;
|
|
1115
|
+
let gridTemplateRows = ' ';
|
|
1116
|
+
const rowPositions = rows.map(row => {
|
|
1117
|
+
const currentRowHeight = isGroupRow(row) ? rowHeight({
|
|
1118
|
+
type: 'GROUP',
|
|
1119
|
+
row
|
|
1120
|
+
}) : rowHeight({
|
|
1121
|
+
type: 'ROW',
|
|
1122
|
+
row
|
|
1123
|
+
});
|
|
1124
|
+
const position = {
|
|
1125
|
+
top: totalRowHeight,
|
|
1126
|
+
height: currentRowHeight
|
|
1127
|
+
};
|
|
1128
|
+
gridTemplateRows += `${currentRowHeight}px `;
|
|
1129
|
+
totalRowHeight += currentRowHeight;
|
|
1130
|
+
return position;
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
const validateRowIdx = rowIdx => {
|
|
1134
|
+
return max(0, min(rows.length - 1, rowIdx));
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
return {
|
|
1138
|
+
totalRowHeight,
|
|
1139
|
+
gridTemplateRows,
|
|
1140
|
+
getRowTop: rowIdx => rowPositions[validateRowIdx(rowIdx)].top,
|
|
1141
|
+
getRowHeight: rowIdx => rowPositions[validateRowIdx(rowIdx)].height,
|
|
1142
|
+
|
|
1143
|
+
findRowIdx(offset) {
|
|
1144
|
+
let start = 0;
|
|
1145
|
+
let end = rowPositions.length - 1;
|
|
1146
|
+
|
|
1147
|
+
while (start <= end) {
|
|
1148
|
+
const middle = start + floor((end - start) / 2);
|
|
1149
|
+
const currentOffset = rowPositions[middle].top;
|
|
1150
|
+
if (currentOffset === offset) return middle;
|
|
1151
|
+
|
|
1152
|
+
if (currentOffset < offset) {
|
|
1153
|
+
start = middle + 1;
|
|
1154
|
+
} else if (currentOffset > offset) {
|
|
1155
|
+
end = middle - 1;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
if (start > end) return end;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
return 0;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
};
|
|
1165
|
+
}, [isGroupRow, rowHeight, rows]);
|
|
1166
|
+
let rowOverscanStartIdx = 0;
|
|
1167
|
+
let rowOverscanEndIdx = rows.length - 1;
|
|
1168
|
+
|
|
1169
|
+
if (enableVirtualization) {
|
|
1170
|
+
const overscanThreshold = 4;
|
|
1171
|
+
const rowVisibleStartIdx = findRowIdx(scrollTop);
|
|
1172
|
+
const rowVisibleEndIdx = findRowIdx(scrollTop + clientHeight);
|
|
1173
|
+
rowOverscanStartIdx = max(0, rowVisibleStartIdx - overscanThreshold);
|
|
1174
|
+
rowOverscanEndIdx = min(rows.length - 1, rowVisibleEndIdx + overscanThreshold);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
return {
|
|
1178
|
+
rowOverscanStartIdx,
|
|
1179
|
+
rowOverscanEndIdx,
|
|
1180
|
+
rows,
|
|
1181
|
+
rowsCount,
|
|
1182
|
+
totalRowHeight,
|
|
1183
|
+
gridTemplateRows,
|
|
1184
|
+
isGroupRow,
|
|
1185
|
+
getRowTop,
|
|
1186
|
+
getRowHeight,
|
|
1187
|
+
findRowIdx
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
var css_248z$a = ".h1tr5c9i700-beta11{cursor:pointer;display:flex}.h1tr5c9i700-beta11:focus{outline:none}.h19r0msv700-beta11{flex-grow:1;overflow:hidden;overflow:clip;text-overflow:ellipsis}";
|
|
1192
|
+
styleInject$1(css_248z$a,{"insertAt":"top"});
|
|
1193
|
+
|
|
1194
|
+
const headerSortCell = "h1tr5c9i700-beta11";
|
|
1195
|
+
const headerSortCellClassname = `rdg-header-sort-cell ${headerSortCell}`;
|
|
1196
|
+
const headerSortName = "h19r0msv700-beta11";
|
|
1197
|
+
const headerSortNameClassname = `rdg-header-sort-name ${headerSortName}`;
|
|
1198
|
+
function HeaderRenderer({
|
|
1199
|
+
column,
|
|
1200
|
+
sortDirection,
|
|
1201
|
+
priority,
|
|
1202
|
+
onSort,
|
|
1203
|
+
isCellSelected
|
|
1204
|
+
}) {
|
|
1205
|
+
if (!column.sortable) return /*#__PURE__*/e$1(d$1, {
|
|
1206
|
+
children: column.name
|
|
1207
|
+
});
|
|
1208
|
+
return /*#__PURE__*/e$1(SortableHeaderCell, {
|
|
1209
|
+
onSort: onSort,
|
|
1210
|
+
sortDirection: sortDirection,
|
|
1211
|
+
priority: priority,
|
|
1212
|
+
isCellSelected: isCellSelected,
|
|
1213
|
+
children: column.name
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function SortableHeaderCell({
|
|
1218
|
+
onSort,
|
|
1219
|
+
sortDirection,
|
|
1220
|
+
priority,
|
|
1221
|
+
children,
|
|
1222
|
+
isCellSelected
|
|
1223
|
+
}) {
|
|
1224
|
+
const SortIcon = useDefaultComponents().sortIcon;
|
|
1225
|
+
const {
|
|
1226
|
+
ref,
|
|
1227
|
+
tabIndex
|
|
1228
|
+
} = useFocusRef(isCellSelected);
|
|
1229
|
+
|
|
1230
|
+
function handleKeyDown(event) {
|
|
1231
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
1232
|
+
event.preventDefault();
|
|
1233
|
+
onSort(event.ctrlKey || event.metaKey);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
function handleClick(event) {
|
|
1238
|
+
onSort(event.ctrlKey || event.metaKey);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
return /*#__PURE__*/e$1("span", {
|
|
1242
|
+
ref: ref,
|
|
1243
|
+
tabIndex: tabIndex,
|
|
1244
|
+
className: headerSortCellClassname,
|
|
1245
|
+
onClick: handleClick,
|
|
1246
|
+
onKeyDown: handleKeyDown,
|
|
1247
|
+
children: [/*#__PURE__*/e$1("span", {
|
|
1248
|
+
className: headerSortNameClassname,
|
|
1249
|
+
children: children
|
|
1250
|
+
}), /*#__PURE__*/e$1("span", {
|
|
1251
|
+
children: [/*#__PURE__*/e$1(SortIcon, {
|
|
1252
|
+
sortDirection: sortDirection
|
|
1253
|
+
}), priority]
|
|
1254
|
+
})]
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
var css_248z$9 = ".celq7o9700-beta11{touch-action:none}.celq7o9700-beta11:after{content:\"\";cursor:col-resize;inline-size:10px;inset-block-end:0;inset-block-start:0;inset-inline-end:0;position:absolute}";
|
|
1259
|
+
styleInject$1(css_248z$9,{"insertAt":"top"});
|
|
1260
|
+
|
|
1261
|
+
const cellResizable = "celq7o9700-beta11";
|
|
1262
|
+
const cellResizableClassname = `rdg-cell-resizable ${cellResizable}`;
|
|
1263
|
+
function HeaderCell({
|
|
1264
|
+
column,
|
|
1265
|
+
colSpan,
|
|
1266
|
+
isCellSelected,
|
|
1267
|
+
onColumnResize,
|
|
1268
|
+
allRowsSelected,
|
|
1269
|
+
onAllRowsSelectionChange,
|
|
1270
|
+
sortColumns,
|
|
1271
|
+
onSortColumnsChange,
|
|
1272
|
+
selectCell,
|
|
1273
|
+
shouldFocusGrid,
|
|
1274
|
+
direction
|
|
1275
|
+
}) {
|
|
1276
|
+
var _column$headerRendere, _column$minWidth, _column$maxWidth;
|
|
1277
|
+
|
|
1278
|
+
const isRtl = direction === 'rtl';
|
|
1279
|
+
const {
|
|
1280
|
+
ref,
|
|
1281
|
+
tabIndex,
|
|
1282
|
+
onFocus
|
|
1283
|
+
} = useRovingCellRef(isCellSelected);
|
|
1284
|
+
const sortIndex = sortColumns == null ? void 0 : sortColumns.findIndex(sort => sort.columnKey === column.key);
|
|
1285
|
+
const sortColumn = sortIndex !== undefined && sortIndex > -1 ? sortColumns[sortIndex] : undefined;
|
|
1286
|
+
const sortDirection = sortColumn == null ? void 0 : sortColumn.direction;
|
|
1287
|
+
const priority = sortColumn !== undefined && sortColumns.length > 1 ? sortIndex + 1 : undefined;
|
|
1288
|
+
const ariaSort = sortDirection && !priority ? sortDirection === 'ASC' ? 'ascending' : 'descending' : undefined;
|
|
1289
|
+
const className = getCellClassname(column, column.headerCellClass, column.resizable && cellResizableClassname);
|
|
1290
|
+
const HeaderRenderer$1 = (_column$headerRendere = column.headerRenderer) != null ? _column$headerRendere : HeaderRenderer;
|
|
1291
|
+
|
|
1292
|
+
function onPointerDown(event) {
|
|
1293
|
+
if (event.pointerType === 'mouse' && event.buttons !== 1) {
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
const {
|
|
1298
|
+
currentTarget,
|
|
1299
|
+
pointerId
|
|
1300
|
+
} = event;
|
|
1301
|
+
const {
|
|
1302
|
+
right,
|
|
1303
|
+
left
|
|
1304
|
+
} = currentTarget.getBoundingClientRect();
|
|
1305
|
+
const offset = isRtl ? event.clientX - left : right - event.clientX;
|
|
1306
|
+
|
|
1307
|
+
if (offset > 11) {
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function onPointerMove(event) {
|
|
1312
|
+
const {
|
|
1313
|
+
right,
|
|
1314
|
+
left
|
|
1315
|
+
} = currentTarget.getBoundingClientRect();
|
|
1316
|
+
const width = isRtl ? right + offset - event.clientX : event.clientX + offset - left;
|
|
1317
|
+
|
|
1318
|
+
if (width > 0) {
|
|
1319
|
+
onColumnResize(column, width);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
function onLostPointerCapture() {
|
|
1324
|
+
currentTarget.removeEventListener('pointermove', onPointerMove);
|
|
1325
|
+
currentTarget.removeEventListener('lostpointercapture', onLostPointerCapture);
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
currentTarget.setPointerCapture(pointerId);
|
|
1329
|
+
currentTarget.addEventListener('pointermove', onPointerMove);
|
|
1330
|
+
currentTarget.addEventListener('lostpointercapture', onLostPointerCapture);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
function onSort(ctrlClick) {
|
|
1334
|
+
if (onSortColumnsChange == null) return;
|
|
1335
|
+
const {
|
|
1336
|
+
sortDescendingFirst
|
|
1337
|
+
} = column;
|
|
1338
|
+
|
|
1339
|
+
if (sortColumn === undefined) {
|
|
1340
|
+
const nextSort = {
|
|
1341
|
+
columnKey: column.key,
|
|
1342
|
+
direction: sortDescendingFirst ? 'DESC' : 'ASC'
|
|
1343
|
+
};
|
|
1344
|
+
onSortColumnsChange(sortColumns && ctrlClick ? [...sortColumns, nextSort] : [nextSort]);
|
|
1345
|
+
} else {
|
|
1346
|
+
let nextSortColumn;
|
|
1347
|
+
|
|
1348
|
+
if (sortDescendingFirst && sortDirection === 'DESC' || !sortDescendingFirst && sortDirection === 'ASC') {
|
|
1349
|
+
nextSortColumn = {
|
|
1350
|
+
columnKey: column.key,
|
|
1351
|
+
direction: sortDirection === 'ASC' ? 'DESC' : 'ASC'
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
if (ctrlClick) {
|
|
1356
|
+
const nextSortColumns = [...sortColumns];
|
|
1357
|
+
|
|
1358
|
+
if (nextSortColumn) {
|
|
1359
|
+
nextSortColumns[sortIndex] = nextSortColumn;
|
|
1360
|
+
} else {
|
|
1361
|
+
nextSortColumns.splice(sortIndex, 1);
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
onSortColumnsChange(nextSortColumns);
|
|
1365
|
+
} else {
|
|
1366
|
+
onSortColumnsChange(nextSortColumn ? [nextSortColumn] : []);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function onClick() {
|
|
1372
|
+
selectCell(column.idx);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
function onDoubleClick(event) {
|
|
1376
|
+
const {
|
|
1377
|
+
right,
|
|
1378
|
+
left
|
|
1379
|
+
} = event.currentTarget.getBoundingClientRect();
|
|
1380
|
+
const offset = isRtl ? event.clientX - left : right - event.clientX;
|
|
1381
|
+
|
|
1382
|
+
if (offset > 11) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
onColumnResize(column, 'auto');
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
function handleFocus(event) {
|
|
1390
|
+
onFocus(event);
|
|
1391
|
+
|
|
1392
|
+
if (shouldFocusGrid) {
|
|
1393
|
+
selectCell(0);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
return /*#__PURE__*/e$1("div", {
|
|
1398
|
+
role: "columnheader",
|
|
1399
|
+
"aria-colindex": column.idx + 1,
|
|
1400
|
+
"aria-selected": isCellSelected,
|
|
1401
|
+
"aria-sort": ariaSort,
|
|
1402
|
+
"aria-colspan": colSpan,
|
|
1403
|
+
ref: ref,
|
|
1404
|
+
tabIndex: shouldFocusGrid ? 0 : tabIndex,
|
|
1405
|
+
className: className,
|
|
1406
|
+
style: { ...getCellStyle(column, colSpan),
|
|
1407
|
+
minWidth: (_column$minWidth = column.minWidth) != null ? _column$minWidth : undefined,
|
|
1408
|
+
maxWidth: (_column$maxWidth = column.maxWidth) != null ? _column$maxWidth : undefined
|
|
1409
|
+
},
|
|
1410
|
+
onFocus: handleFocus,
|
|
1411
|
+
onClick: onClick,
|
|
1412
|
+
onDoubleClick: column.resizable ? onDoubleClick : undefined,
|
|
1413
|
+
onPointerDown: column.resizable ? onPointerDown : undefined,
|
|
1414
|
+
children: /*#__PURE__*/e$1(HeaderRenderer$1, {
|
|
1415
|
+
column: column,
|
|
1416
|
+
sortDirection: sortDirection,
|
|
1417
|
+
priority: priority,
|
|
1418
|
+
onSort: onSort,
|
|
1419
|
+
allRowsSelected: allRowsSelected,
|
|
1420
|
+
onAllRowsSelectionChange: onAllRowsSelectionChange,
|
|
1421
|
+
isCellSelected: isCellSelected
|
|
1422
|
+
})
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
var css_248z$8 = ".h197vzie700-beta11{background-color:var(--rdg-header-background-color);display:contents;font-weight:700;line-height:var(--rdg-header-row-height)}.h197vzie700-beta11>.c1wupbe700-beta11{inset-block-start:0;position:sticky;z-index:2}.h197vzie700-beta11>.c1730fa4700-beta11{z-index:3}";
|
|
1427
|
+
styleInject$1(css_248z$8,{"insertAt":"top"});
|
|
1428
|
+
|
|
1429
|
+
const headerRow = "h197vzie700-beta11";
|
|
1430
|
+
const headerRowClassname = `rdg-header-row ${headerRow}`;
|
|
1431
|
+
|
|
1432
|
+
function HeaderRow({
|
|
1433
|
+
columns,
|
|
1434
|
+
allRowsSelected,
|
|
1435
|
+
onAllRowsSelectionChange,
|
|
1436
|
+
onColumnResize,
|
|
1437
|
+
sortColumns,
|
|
1438
|
+
onSortColumnsChange,
|
|
1439
|
+
lastFrozenColumnIndex,
|
|
1440
|
+
selectedCellIdx,
|
|
1441
|
+
selectCell,
|
|
1442
|
+
shouldFocusGrid,
|
|
1443
|
+
direction
|
|
1444
|
+
}) {
|
|
1445
|
+
const cells = [];
|
|
1446
|
+
|
|
1447
|
+
for (let index = 0; index < columns.length; index++) {
|
|
1448
|
+
const column = columns[index];
|
|
1449
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
1450
|
+
type: 'HEADER'
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
if (colSpan !== undefined) {
|
|
1454
|
+
index += colSpan - 1;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
cells.push( /*#__PURE__*/e$1(HeaderCell, {
|
|
1458
|
+
column: column,
|
|
1459
|
+
colSpan: colSpan,
|
|
1460
|
+
isCellSelected: selectedCellIdx === column.idx,
|
|
1461
|
+
onColumnResize: onColumnResize,
|
|
1462
|
+
allRowsSelected: allRowsSelected,
|
|
1463
|
+
onAllRowsSelectionChange: onAllRowsSelectionChange,
|
|
1464
|
+
onSortColumnsChange: onSortColumnsChange,
|
|
1465
|
+
sortColumns: sortColumns,
|
|
1466
|
+
selectCell: selectCell,
|
|
1467
|
+
shouldFocusGrid: shouldFocusGrid && index === 0,
|
|
1468
|
+
direction: direction
|
|
1469
|
+
}, column.key));
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
return /*#__PURE__*/e$1("div", {
|
|
1473
|
+
role: "row",
|
|
1474
|
+
"aria-rowindex": 1,
|
|
1475
|
+
className: clsx(headerRowClassname, selectedCellIdx === -1 && rowSelectedClassname),
|
|
1476
|
+
style: getRowStyle(1),
|
|
1477
|
+
children: cells
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const HeaderRow$1 = /*#__PURE__*/g(HeaderRow);
|
|
1482
|
+
|
|
1483
|
+
var css_248z$7 = ".c1bmg16t700-beta11,.ccpfvsn700-beta11{background-color:#ccf}.c1bmg16t700-beta11.ccpfvsn700-beta11{background-color:#99f}";
|
|
1484
|
+
styleInject$1(css_248z$7,{"insertAt":"top"});
|
|
1485
|
+
|
|
1486
|
+
const cellCopied = "ccpfvsn700-beta11";
|
|
1487
|
+
const cellCopiedClassname = `rdg-cell-copied ${cellCopied}`;
|
|
1488
|
+
const cellDraggedOver = "c1bmg16t700-beta11";
|
|
1489
|
+
const cellDraggedOverClassname = `rdg-cell-dragged-over ${cellDraggedOver}`;
|
|
1490
|
+
|
|
1491
|
+
function Cell({
|
|
1492
|
+
column,
|
|
1493
|
+
colSpan,
|
|
1494
|
+
isCellSelected,
|
|
1495
|
+
isCopied,
|
|
1496
|
+
isDraggedOver,
|
|
1497
|
+
row,
|
|
1498
|
+
dragHandle,
|
|
1499
|
+
onRowClick,
|
|
1500
|
+
onRowDoubleClick,
|
|
1501
|
+
onRowChange,
|
|
1502
|
+
selectCell,
|
|
1503
|
+
...props
|
|
1504
|
+
}) {
|
|
1505
|
+
const {
|
|
1506
|
+
ref,
|
|
1507
|
+
tabIndex,
|
|
1508
|
+
onFocus
|
|
1509
|
+
} = useRovingCellRef(isCellSelected);
|
|
1510
|
+
const {
|
|
1511
|
+
cellClass
|
|
1512
|
+
} = column;
|
|
1513
|
+
const className = getCellClassname(column, typeof cellClass === 'function' ? cellClass(row) : cellClass, isCopied && cellCopiedClassname, isDraggedOver && cellDraggedOverClassname);
|
|
1514
|
+
|
|
1515
|
+
function selectCellWrapper(openEditor) {
|
|
1516
|
+
selectCell(row, column, openEditor);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
function handleClick() {
|
|
1520
|
+
var _column$editorOptions;
|
|
1521
|
+
|
|
1522
|
+
selectCellWrapper((_column$editorOptions = column.editorOptions) == null ? void 0 : _column$editorOptions.editOnClick);
|
|
1523
|
+
onRowClick == null ? void 0 : onRowClick(row, column);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
function handleContextMenu() {
|
|
1527
|
+
selectCellWrapper();
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
function handleDoubleClick() {
|
|
1531
|
+
selectCellWrapper(true);
|
|
1532
|
+
onRowDoubleClick == null ? void 0 : onRowDoubleClick(row, column);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
return /*#__PURE__*/e$1("div", {
|
|
1536
|
+
role: "gridcell",
|
|
1537
|
+
"aria-colindex": column.idx + 1,
|
|
1538
|
+
"aria-selected": isCellSelected,
|
|
1539
|
+
"aria-colspan": colSpan,
|
|
1540
|
+
"aria-readonly": !isCellEditable(column, row) || undefined,
|
|
1541
|
+
ref: ref,
|
|
1542
|
+
tabIndex: tabIndex,
|
|
1543
|
+
className: className,
|
|
1544
|
+
style: getCellStyle(column, colSpan),
|
|
1545
|
+
onClick: handleClick,
|
|
1546
|
+
onDoubleClick: handleDoubleClick,
|
|
1547
|
+
onContextMenu: handleContextMenu,
|
|
1548
|
+
onFocus: onFocus,
|
|
1549
|
+
...props,
|
|
1550
|
+
children: !column.rowGroup && /*#__PURE__*/e$1(d$1, {
|
|
1551
|
+
children: [/*#__PURE__*/e$1(column.formatter, {
|
|
1552
|
+
column: column,
|
|
1553
|
+
row: row,
|
|
1554
|
+
isCellSelected: isCellSelected,
|
|
1555
|
+
onRowChange: onRowChange
|
|
1556
|
+
}), dragHandle]
|
|
1557
|
+
})
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
const Cell$1 = /*#__PURE__*/g(Cell);
|
|
1562
|
+
|
|
1563
|
+
function Row({
|
|
1564
|
+
className,
|
|
1565
|
+
rowIdx,
|
|
1566
|
+
gridRowStart,
|
|
1567
|
+
height,
|
|
1568
|
+
selectedCellIdx,
|
|
1569
|
+
isRowSelected,
|
|
1570
|
+
copiedCellIdx,
|
|
1571
|
+
draggedOverCellIdx,
|
|
1572
|
+
lastFrozenColumnIndex,
|
|
1573
|
+
row,
|
|
1574
|
+
viewportColumns,
|
|
1575
|
+
selectedCellEditor,
|
|
1576
|
+
selectedCellDragHandle,
|
|
1577
|
+
onRowClick,
|
|
1578
|
+
onRowDoubleClick,
|
|
1579
|
+
rowClass,
|
|
1580
|
+
setDraggedOverRowIdx,
|
|
1581
|
+
onMouseEnter,
|
|
1582
|
+
onRowChange,
|
|
1583
|
+
selectCell,
|
|
1584
|
+
...props
|
|
1585
|
+
}, ref) {
|
|
1586
|
+
const handleRowChange = useLatestFunc(newRow => {
|
|
1587
|
+
onRowChange(rowIdx, newRow);
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
function handleDragEnter(event) {
|
|
1591
|
+
setDraggedOverRowIdx == null ? void 0 : setDraggedOverRowIdx(rowIdx);
|
|
1592
|
+
onMouseEnter == null ? void 0 : onMouseEnter(event);
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
className = clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`, rowClass == null ? void 0 : rowClass(row), className, selectedCellIdx === -1 && rowSelectedClassname);
|
|
1596
|
+
const cells = [];
|
|
1597
|
+
|
|
1598
|
+
for (let index = 0; index < viewportColumns.length; index++) {
|
|
1599
|
+
const column = viewportColumns[index];
|
|
1600
|
+
const {
|
|
1601
|
+
idx
|
|
1602
|
+
} = column;
|
|
1603
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
1604
|
+
type: 'ROW',
|
|
1605
|
+
row
|
|
1606
|
+
});
|
|
1607
|
+
|
|
1608
|
+
if (colSpan !== undefined) {
|
|
1609
|
+
index += colSpan - 1;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
const isCellSelected = selectedCellIdx === idx;
|
|
1613
|
+
|
|
1614
|
+
if (isCellSelected && selectedCellEditor) {
|
|
1615
|
+
cells.push(selectedCellEditor);
|
|
1616
|
+
} else {
|
|
1617
|
+
cells.push( /*#__PURE__*/e$1(Cell$1, {
|
|
1618
|
+
column: column,
|
|
1619
|
+
colSpan: colSpan,
|
|
1620
|
+
row: row,
|
|
1621
|
+
isCopied: copiedCellIdx === idx,
|
|
1622
|
+
isDraggedOver: draggedOverCellIdx === idx,
|
|
1623
|
+
isCellSelected: isCellSelected,
|
|
1624
|
+
dragHandle: isCellSelected ? selectedCellDragHandle : undefined,
|
|
1625
|
+
onRowClick: onRowClick,
|
|
1626
|
+
onRowDoubleClick: onRowDoubleClick,
|
|
1627
|
+
onRowChange: handleRowChange,
|
|
1628
|
+
selectCell: selectCell
|
|
1629
|
+
}, column.key));
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
return /*#__PURE__*/e$1(RowSelectionProvider, {
|
|
1634
|
+
value: isRowSelected,
|
|
1635
|
+
children: /*#__PURE__*/e$1("div", {
|
|
1636
|
+
role: "row",
|
|
1637
|
+
ref: ref,
|
|
1638
|
+
className: className,
|
|
1639
|
+
onMouseEnter: handleDragEnter,
|
|
1640
|
+
style: getRowStyle(gridRowStart, height),
|
|
1641
|
+
...props,
|
|
1642
|
+
children: cells
|
|
1643
|
+
})
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
const Row$1 = /*#__PURE__*/g( /*#__PURE__*/x(Row));
|
|
1648
|
+
|
|
1649
|
+
function GroupCell({
|
|
1650
|
+
id,
|
|
1651
|
+
groupKey,
|
|
1652
|
+
childRows,
|
|
1653
|
+
isExpanded,
|
|
1654
|
+
isCellSelected,
|
|
1655
|
+
column,
|
|
1656
|
+
row,
|
|
1657
|
+
groupColumnIndex,
|
|
1658
|
+
toggleGroup: toggleGroupWrapper
|
|
1659
|
+
}) {
|
|
1660
|
+
const {
|
|
1661
|
+
ref,
|
|
1662
|
+
tabIndex,
|
|
1663
|
+
onFocus
|
|
1664
|
+
} = useRovingCellRef(isCellSelected);
|
|
1665
|
+
|
|
1666
|
+
function toggleGroup() {
|
|
1667
|
+
toggleGroupWrapper(id);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
const isLevelMatching = column.rowGroup && groupColumnIndex === column.idx;
|
|
1671
|
+
return /*#__PURE__*/e$1("div", {
|
|
1672
|
+
role: "gridcell",
|
|
1673
|
+
"aria-colindex": column.idx + 1,
|
|
1674
|
+
"aria-selected": isCellSelected,
|
|
1675
|
+
ref: ref,
|
|
1676
|
+
tabIndex: tabIndex,
|
|
1677
|
+
className: getCellClassname(column),
|
|
1678
|
+
style: { ...getCellStyle(column),
|
|
1679
|
+
cursor: isLevelMatching ? 'pointer' : 'default'
|
|
1680
|
+
},
|
|
1681
|
+
onClick: isLevelMatching ? toggleGroup : undefined,
|
|
1682
|
+
onFocus: onFocus,
|
|
1683
|
+
children: (!column.rowGroup || groupColumnIndex === column.idx) && column.groupFormatter && /*#__PURE__*/e$1(column.groupFormatter, {
|
|
1684
|
+
groupKey: groupKey,
|
|
1685
|
+
childRows: childRows,
|
|
1686
|
+
column: column,
|
|
1687
|
+
row: row,
|
|
1688
|
+
isExpanded: isExpanded,
|
|
1689
|
+
isCellSelected: isCellSelected,
|
|
1690
|
+
toggleGroup: toggleGroup
|
|
1691
|
+
})
|
|
1692
|
+
}, column.key);
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
const GroupCell$1 = /*#__PURE__*/g(GroupCell);
|
|
1696
|
+
|
|
1697
|
+
var css_248z$6 = ".gyxx7e9700-beta11:not([aria-selected=true]){background-color:var(--rdg-header-background-color)}.gyxx7e9700-beta11>.c1wupbe700-beta11:not(:last-child):not(.c9dpaye700-beta11){border-inline-end:none}";
|
|
1698
|
+
styleInject$1(css_248z$6,{"insertAt":"top"});
|
|
1699
|
+
|
|
1700
|
+
const groupRow = "gyxx7e9700-beta11";
|
|
1701
|
+
const groupRowClassname = `rdg-group-row ${groupRow}`;
|
|
1702
|
+
|
|
1703
|
+
function GroupedRow({
|
|
1704
|
+
id,
|
|
1705
|
+
groupKey,
|
|
1706
|
+
viewportColumns,
|
|
1707
|
+
childRows,
|
|
1708
|
+
rowIdx,
|
|
1709
|
+
row,
|
|
1710
|
+
gridRowStart,
|
|
1711
|
+
height,
|
|
1712
|
+
level,
|
|
1713
|
+
isExpanded,
|
|
1714
|
+
selectedCellIdx,
|
|
1715
|
+
isRowSelected,
|
|
1716
|
+
selectGroup,
|
|
1717
|
+
toggleGroup,
|
|
1718
|
+
...props
|
|
1719
|
+
}) {
|
|
1720
|
+
const idx = viewportColumns[0].key === SELECT_COLUMN_KEY ? level + 1 : level;
|
|
1721
|
+
|
|
1722
|
+
function handleSelectGroup() {
|
|
1723
|
+
selectGroup(rowIdx);
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
return /*#__PURE__*/e$1(RowSelectionProvider, {
|
|
1727
|
+
value: isRowSelected,
|
|
1728
|
+
children: /*#__PURE__*/e$1("div", {
|
|
1729
|
+
role: "row",
|
|
1730
|
+
"aria-level": level,
|
|
1731
|
+
"aria-expanded": isExpanded,
|
|
1732
|
+
className: clsx(rowClassname, groupRowClassname, `rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`, selectedCellIdx === -1 && rowSelectedClassname),
|
|
1733
|
+
onClick: handleSelectGroup,
|
|
1734
|
+
style: getRowStyle(gridRowStart, height),
|
|
1735
|
+
...props,
|
|
1736
|
+
children: viewportColumns.map(column => /*#__PURE__*/e$1(GroupCell$1, {
|
|
1737
|
+
id: id,
|
|
1738
|
+
groupKey: groupKey,
|
|
1739
|
+
childRows: childRows,
|
|
1740
|
+
isExpanded: isExpanded,
|
|
1741
|
+
isCellSelected: selectedCellIdx === column.idx,
|
|
1742
|
+
column: column,
|
|
1743
|
+
row: row,
|
|
1744
|
+
groupColumnIndex: idx,
|
|
1745
|
+
toggleGroup: toggleGroup
|
|
1746
|
+
}, column.key))
|
|
1747
|
+
})
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
const GroupRowRenderer = /*#__PURE__*/g(GroupedRow);
|
|
1752
|
+
|
|
1753
|
+
var css_248z$5 = ".s1n3hxke700-beta11{inset-block-end:var(--rdg-summary-row-bottom);inset-block-start:var(--rdg-summary-row-top)}";
|
|
1754
|
+
styleInject$1(css_248z$5,{"insertAt":"top"});
|
|
1755
|
+
|
|
1756
|
+
const summaryCellClassname = "s1n3hxke700-beta11";
|
|
1757
|
+
|
|
1758
|
+
function SummaryCell({
|
|
1759
|
+
column,
|
|
1760
|
+
colSpan,
|
|
1761
|
+
row,
|
|
1762
|
+
isCellSelected,
|
|
1763
|
+
selectCell
|
|
1764
|
+
}) {
|
|
1765
|
+
const {
|
|
1766
|
+
ref,
|
|
1767
|
+
tabIndex,
|
|
1768
|
+
onFocus
|
|
1769
|
+
} = useRovingCellRef(isCellSelected);
|
|
1770
|
+
const {
|
|
1771
|
+
summaryFormatter: SummaryFormatter,
|
|
1772
|
+
summaryCellClass
|
|
1773
|
+
} = column;
|
|
1774
|
+
const className = getCellClassname(column, summaryCellClassname, typeof summaryCellClass === 'function' ? summaryCellClass(row) : summaryCellClass);
|
|
1775
|
+
|
|
1776
|
+
function onClick() {
|
|
1777
|
+
selectCell(row, column);
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
return /*#__PURE__*/e$1("div", {
|
|
1781
|
+
role: "gridcell",
|
|
1782
|
+
"aria-colindex": column.idx + 1,
|
|
1783
|
+
"aria-colspan": colSpan,
|
|
1784
|
+
"aria-selected": isCellSelected,
|
|
1785
|
+
ref: ref,
|
|
1786
|
+
tabIndex: tabIndex,
|
|
1787
|
+
className: className,
|
|
1788
|
+
style: getCellStyle(column, colSpan),
|
|
1789
|
+
onClick: onClick,
|
|
1790
|
+
onFocus: onFocus,
|
|
1791
|
+
children: SummaryFormatter && /*#__PURE__*/e$1(SummaryFormatter, {
|
|
1792
|
+
column: column,
|
|
1793
|
+
row: row,
|
|
1794
|
+
isCellSelected: isCellSelected
|
|
1795
|
+
})
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
const SummaryCell$1 = /*#__PURE__*/g(SummaryCell);
|
|
1800
|
+
|
|
1801
|
+
var css_248z$4 = ".snfqesz700-beta11.r1otpg64700-beta11{line-height:var(--rdg-summary-row-height)}.snfqesz700-beta11.r1otpg64700-beta11>.c1wupbe700-beta11{position:sticky}.s1jijrjz700-beta11>.c1wupbe700-beta11{border-block-start:2px solid var(--rdg-summary-border-color)}";
|
|
1802
|
+
styleInject$1(css_248z$4,{"insertAt":"top"});
|
|
1803
|
+
|
|
1804
|
+
const summaryRow = "snfqesz700-beta11";
|
|
1805
|
+
const summaryRowBorderClassname = "s1jijrjz700-beta11";
|
|
1806
|
+
const summaryRowClassname = `rdg-summary-row ${summaryRow}`;
|
|
1807
|
+
|
|
1808
|
+
function SummaryRow({
|
|
1809
|
+
rowIdx,
|
|
1810
|
+
gridRowStart,
|
|
1811
|
+
row,
|
|
1812
|
+
viewportColumns,
|
|
1813
|
+
top,
|
|
1814
|
+
bottom,
|
|
1815
|
+
lastFrozenColumnIndex,
|
|
1816
|
+
selectedCellIdx,
|
|
1817
|
+
selectCell,
|
|
1818
|
+
'aria-rowindex': ariaRowIndex
|
|
1819
|
+
}) {
|
|
1820
|
+
const cells = [];
|
|
1821
|
+
|
|
1822
|
+
for (let index = 0; index < viewportColumns.length; index++) {
|
|
1823
|
+
const column = viewportColumns[index];
|
|
1824
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
1825
|
+
type: 'SUMMARY',
|
|
1826
|
+
row
|
|
1827
|
+
});
|
|
1828
|
+
|
|
1829
|
+
if (colSpan !== undefined) {
|
|
1830
|
+
index += colSpan - 1;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
const isCellSelected = selectedCellIdx === column.idx;
|
|
1834
|
+
cells.push( /*#__PURE__*/e$1(SummaryCell$1, {
|
|
1835
|
+
column: column,
|
|
1836
|
+
colSpan: colSpan,
|
|
1837
|
+
row: row,
|
|
1838
|
+
isCellSelected: isCellSelected,
|
|
1839
|
+
selectCell: selectCell
|
|
1840
|
+
}, column.key));
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
return /*#__PURE__*/e$1("div", {
|
|
1844
|
+
role: "row",
|
|
1845
|
+
"aria-rowindex": ariaRowIndex,
|
|
1846
|
+
className: clsx(rowClassname, `rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`, summaryRowClassname, rowIdx === 0 && summaryRowBorderClassname, selectedCellIdx === -1 && rowSelectedClassname),
|
|
1847
|
+
style: { ...getRowStyle(gridRowStart),
|
|
1848
|
+
'--rdg-summary-row-top': top !== undefined ? `${top}px` : undefined,
|
|
1849
|
+
'--rdg-summary-row-bottom': bottom !== undefined ? `${bottom}px` : undefined
|
|
1850
|
+
},
|
|
1851
|
+
children: cells
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
const SummaryRow$1 = /*#__PURE__*/g(SummaryRow);
|
|
1856
|
+
|
|
1857
|
+
var css_248z$3 = ".c1tngyp1700-beta11.rdg-cell{padding:0}";
|
|
1858
|
+
styleInject$1(css_248z$3,{"insertAt":"top"});
|
|
1859
|
+
|
|
1860
|
+
const cellEditing = "c1tngyp1700-beta11";
|
|
1861
|
+
function EditCell({
|
|
1862
|
+
column,
|
|
1863
|
+
colSpan,
|
|
1864
|
+
row,
|
|
1865
|
+
onRowChange,
|
|
1866
|
+
closeEditor,
|
|
1867
|
+
scrollToCell
|
|
1868
|
+
}) {
|
|
1869
|
+
var _column$editorOptions, _column$editorOptions4, _column$editorOptions5;
|
|
1870
|
+
|
|
1871
|
+
const frameRequestRef = h();
|
|
1872
|
+
const commitOnOutsideClick = ((_column$editorOptions = column.editorOptions) == null ? void 0 : _column$editorOptions.commitOnOutsideClick) !== false;
|
|
1873
|
+
const commitOnOutsideMouseDown = useLatestFunc(() => {
|
|
1874
|
+
onClose(true);
|
|
1875
|
+
});
|
|
1876
|
+
y(() => {
|
|
1877
|
+
if (!commitOnOutsideClick) return;
|
|
1878
|
+
|
|
1879
|
+
function onWindowCaptureMouseDown() {
|
|
1880
|
+
frameRequestRef.current = requestAnimationFrame(commitOnOutsideMouseDown);
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
addEventListener('mousedown', onWindowCaptureMouseDown, {
|
|
1884
|
+
capture: true
|
|
1885
|
+
});
|
|
1886
|
+
return () => {
|
|
1887
|
+
removeEventListener('mousedown', onWindowCaptureMouseDown, {
|
|
1888
|
+
capture: true
|
|
1889
|
+
});
|
|
1890
|
+
cancelFrameRequest();
|
|
1891
|
+
};
|
|
1892
|
+
}, [commitOnOutsideClick, commitOnOutsideMouseDown]);
|
|
1893
|
+
|
|
1894
|
+
function cancelFrameRequest() {
|
|
1895
|
+
cancelAnimationFrame(frameRequestRef.current);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
function onKeyDown(event) {
|
|
1899
|
+
if (event.key === 'Escape') {
|
|
1900
|
+
event.stopPropagation();
|
|
1901
|
+
onClose();
|
|
1902
|
+
} else if (event.key === 'Enter') {
|
|
1903
|
+
event.stopPropagation();
|
|
1904
|
+
onClose(true);
|
|
1905
|
+
scrollToCell();
|
|
1906
|
+
} else {
|
|
1907
|
+
var _column$editorOptions2, _column$editorOptions3;
|
|
1908
|
+
|
|
1909
|
+
const onNavigation = (_column$editorOptions2 = (_column$editorOptions3 = column.editorOptions) == null ? void 0 : _column$editorOptions3.onNavigation) != null ? _column$editorOptions2 : onEditorNavigation;
|
|
1910
|
+
|
|
1911
|
+
if (!onNavigation(event)) {
|
|
1912
|
+
event.stopPropagation();
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
function onClose(commitChanges) {
|
|
1918
|
+
if (commitChanges) {
|
|
1919
|
+
onRowChange(row, true);
|
|
1920
|
+
} else {
|
|
1921
|
+
closeEditor();
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
const {
|
|
1926
|
+
cellClass
|
|
1927
|
+
} = column;
|
|
1928
|
+
const className = getCellClassname(column, 'rdg-editor-container', typeof cellClass === 'function' ? cellClass(row) : cellClass, !((_column$editorOptions4 = column.editorOptions) != null && _column$editorOptions4.renderFormatter) && cellEditing);
|
|
1929
|
+
return /*#__PURE__*/e$1("div", {
|
|
1930
|
+
role: "gridcell",
|
|
1931
|
+
"aria-colindex": column.idx + 1,
|
|
1932
|
+
"aria-colspan": colSpan,
|
|
1933
|
+
"aria-selected": true,
|
|
1934
|
+
className: className,
|
|
1935
|
+
style: getCellStyle(column, colSpan),
|
|
1936
|
+
onKeyDown: onKeyDown,
|
|
1937
|
+
onMouseDownCapture: commitOnOutsideClick ? cancelFrameRequest : undefined,
|
|
1938
|
+
children: column.editor != null && /*#__PURE__*/e$1(d$1, {
|
|
1939
|
+
children: [/*#__PURE__*/e$1(column.editor, {
|
|
1940
|
+
column: column,
|
|
1941
|
+
row: row,
|
|
1942
|
+
onRowChange: onRowChange,
|
|
1943
|
+
onClose: onClose
|
|
1944
|
+
}), ((_column$editorOptions5 = column.editorOptions) == null ? void 0 : _column$editorOptions5.renderFormatter) && /*#__PURE__*/e$1(column.formatter, {
|
|
1945
|
+
column: column,
|
|
1946
|
+
row: row,
|
|
1947
|
+
isCellSelected: true,
|
|
1948
|
+
onRowChange: onRowChange
|
|
1949
|
+
})]
|
|
1950
|
+
})
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
var css_248z$2 = ".cadd3bp700-beta11{background-color:var(--rdg-selection-color);block-size:8px;cursor:move;inline-size:8px;inset-block-end:0;inset-inline-end:0;position:absolute}.cadd3bp700-beta11:hover{background-color:var(--rdg-background-color);block-size:16px;border:2px solid var(--rdg-selection-color);inline-size:16px}";
|
|
1955
|
+
styleInject$1(css_248z$2,{"insertAt":"top"});
|
|
1956
|
+
|
|
1957
|
+
const cellDragHandle = "cadd3bp700-beta11";
|
|
1958
|
+
const cellDragHandleClassname = `rdg-cell-drag-handle ${cellDragHandle}`;
|
|
1959
|
+
function DragHandle({
|
|
1960
|
+
rows,
|
|
1961
|
+
columns,
|
|
1962
|
+
selectedPosition,
|
|
1963
|
+
latestDraggedOverRowIdx,
|
|
1964
|
+
isCellEditable,
|
|
1965
|
+
onRowsChange,
|
|
1966
|
+
onFill,
|
|
1967
|
+
setDragging,
|
|
1968
|
+
setDraggedOverRowIdx
|
|
1969
|
+
}) {
|
|
1970
|
+
function handleMouseDown(event) {
|
|
1971
|
+
if (event.buttons !== 1) return;
|
|
1972
|
+
setDragging(true);
|
|
1973
|
+
window.addEventListener('mouseover', onMouseOver);
|
|
1974
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
1975
|
+
|
|
1976
|
+
function onMouseOver(event) {
|
|
1977
|
+
if (event.buttons !== 1) onMouseUp();
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
function onMouseUp() {
|
|
1981
|
+
window.removeEventListener('mouseover', onMouseOver);
|
|
1982
|
+
window.removeEventListener('mouseup', onMouseUp);
|
|
1983
|
+
setDragging(false);
|
|
1984
|
+
handleDragEnd();
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
function handleDragEnd() {
|
|
1989
|
+
const overRowIdx = latestDraggedOverRowIdx.current;
|
|
1990
|
+
if (overRowIdx === undefined) return;
|
|
1991
|
+
const {
|
|
1992
|
+
rowIdx
|
|
1993
|
+
} = selectedPosition;
|
|
1994
|
+
const startRowIndex = rowIdx < overRowIdx ? rowIdx + 1 : overRowIdx;
|
|
1995
|
+
const endRowIndex = rowIdx < overRowIdx ? overRowIdx + 1 : rowIdx;
|
|
1996
|
+
updateRows(startRowIndex, endRowIndex);
|
|
1997
|
+
setDraggedOverRowIdx(undefined);
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
function handleDoubleClick(event) {
|
|
2001
|
+
event.stopPropagation();
|
|
2002
|
+
updateRows(selectedPosition.rowIdx + 1, rows.length);
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
function updateRows(startRowIdx, endRowIdx) {
|
|
2006
|
+
const {
|
|
2007
|
+
idx,
|
|
2008
|
+
rowIdx
|
|
2009
|
+
} = selectedPosition;
|
|
2010
|
+
const column = columns[idx];
|
|
2011
|
+
const sourceRow = rows[rowIdx];
|
|
2012
|
+
const updatedRows = [...rows];
|
|
2013
|
+
const indexes = [];
|
|
2014
|
+
|
|
2015
|
+
for (let i = startRowIdx; i < endRowIdx; i++) {
|
|
2016
|
+
if (isCellEditable({
|
|
2017
|
+
rowIdx: i,
|
|
2018
|
+
idx
|
|
2019
|
+
})) {
|
|
2020
|
+
const updatedRow = onFill({
|
|
2021
|
+
columnKey: column.key,
|
|
2022
|
+
sourceRow,
|
|
2023
|
+
targetRow: rows[i]
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
if (updatedRow !== rows[i]) {
|
|
2027
|
+
updatedRows[i] = updatedRow;
|
|
2028
|
+
indexes.push(i);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
if (indexes.length > 0) {
|
|
2034
|
+
onRowsChange == null ? void 0 : onRowsChange(updatedRows, {
|
|
2035
|
+
indexes,
|
|
2036
|
+
column
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
return /*#__PURE__*/e$1("div", {
|
|
2042
|
+
className: cellDragHandleClassname,
|
|
2043
|
+
onMouseDown: handleMouseDown,
|
|
2044
|
+
onDoubleClick: handleDoubleClick
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
var css_248z$1 = ".a888944700-beta11{fill:currentColor}.a888944700-beta11>path{transition:d .1s}";
|
|
2049
|
+
styleInject$1(css_248z$1,{"insertAt":"top"});
|
|
2050
|
+
|
|
2051
|
+
const arrow = "a888944700-beta11";
|
|
2052
|
+
const arrowClassname = `rdg-sort-arrow ${arrow}`;
|
|
2053
|
+
function SortIcon({
|
|
2054
|
+
sortDirection
|
|
2055
|
+
}) {
|
|
2056
|
+
return sortDirection !== undefined ? /*#__PURE__*/e$1("svg", {
|
|
2057
|
+
viewBox: "0 0 12 8",
|
|
2058
|
+
width: "12",
|
|
2059
|
+
height: "8",
|
|
2060
|
+
className: arrowClassname,
|
|
2061
|
+
"aria-hidden": true,
|
|
2062
|
+
children: /*#__PURE__*/e$1("path", {
|
|
2063
|
+
d: sortDirection === 'ASC' ? 'M0 8 6 0 12 8' : 'M0 0 6 8 12 0'
|
|
2064
|
+
})
|
|
2065
|
+
}) : null;
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
const initialPosition = {
|
|
2069
|
+
idx: -1,
|
|
2070
|
+
rowIdx: -2,
|
|
2071
|
+
mode: 'SELECT'
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
function DataGrid({
|
|
2075
|
+
columns: rawColumns,
|
|
2076
|
+
rows: rawRows,
|
|
2077
|
+
summaryRows,
|
|
2078
|
+
rowKeyGetter,
|
|
2079
|
+
onRowsChange,
|
|
2080
|
+
rowHeight,
|
|
2081
|
+
headerRowHeight: rawHeaderRowHeight,
|
|
2082
|
+
summaryRowHeight: rawSummaryRowHeight,
|
|
2083
|
+
selectedRows,
|
|
2084
|
+
onSelectedRowsChange,
|
|
2085
|
+
sortColumns,
|
|
2086
|
+
onSortColumnsChange,
|
|
2087
|
+
defaultColumnOptions,
|
|
2088
|
+
groupBy: rawGroupBy,
|
|
2089
|
+
rowGrouper,
|
|
2090
|
+
expandedGroupIds,
|
|
2091
|
+
onExpandedGroupIdsChange,
|
|
2092
|
+
onRowClick,
|
|
2093
|
+
onRowDoubleClick,
|
|
2094
|
+
onScroll,
|
|
2095
|
+
onColumnResize,
|
|
2096
|
+
onFill,
|
|
2097
|
+
onCopy,
|
|
2098
|
+
onPaste,
|
|
2099
|
+
cellNavigationMode: rawCellNavigationMode,
|
|
2100
|
+
enableVirtualization,
|
|
2101
|
+
components,
|
|
2102
|
+
className,
|
|
2103
|
+
style,
|
|
2104
|
+
rowClass,
|
|
2105
|
+
direction,
|
|
2106
|
+
'aria-label': ariaLabel,
|
|
2107
|
+
'aria-labelledby': ariaLabelledBy,
|
|
2108
|
+
'aria-describedby': ariaDescribedBy,
|
|
2109
|
+
'data-testid': testId
|
|
2110
|
+
}, ref) {
|
|
2111
|
+
var _rowHeight, _ref, _components$rowRender, _ref2, _components$sortIcon, _ref3, _components$checkboxF, _components$noRowsFal, _enableVirtualization, _direction, _summaryRows$length;
|
|
2112
|
+
|
|
2113
|
+
const defaultComponents = useDefaultComponents();
|
|
2114
|
+
(_rowHeight = rowHeight) != null ? _rowHeight : rowHeight = 35;
|
|
2115
|
+
const headerRowHeight = rawHeaderRowHeight != null ? rawHeaderRowHeight : typeof rowHeight === 'number' ? rowHeight : 35;
|
|
2116
|
+
const summaryRowHeight = rawSummaryRowHeight != null ? rawSummaryRowHeight : typeof rowHeight === 'number' ? rowHeight : 35;
|
|
2117
|
+
const RowRenderer = (_ref = (_components$rowRender = components == null ? void 0 : components.rowRenderer) != null ? _components$rowRender : defaultComponents == null ? void 0 : defaultComponents.rowRenderer) != null ? _ref : Row$1;
|
|
2118
|
+
const sortIcon = (_ref2 = (_components$sortIcon = components == null ? void 0 : components.sortIcon) != null ? _components$sortIcon : defaultComponents == null ? void 0 : defaultComponents.sortIcon) != null ? _ref2 : SortIcon;
|
|
2119
|
+
const checkboxFormatter = (_ref3 = (_components$checkboxF = components == null ? void 0 : components.checkboxFormatter) != null ? _components$checkboxF : defaultComponents == null ? void 0 : defaultComponents.checkboxFormatter) != null ? _ref3 : CheckboxFormatter;
|
|
2120
|
+
const noRowsFallback = (_components$noRowsFal = components == null ? void 0 : components.noRowsFallback) != null ? _components$noRowsFal : defaultComponents == null ? void 0 : defaultComponents.noRowsFallback;
|
|
2121
|
+
const cellNavigationMode = rawCellNavigationMode != null ? rawCellNavigationMode : 'NONE';
|
|
2122
|
+
(_enableVirtualization = enableVirtualization) != null ? _enableVirtualization : enableVirtualization = true;
|
|
2123
|
+
(_direction = direction) != null ? _direction : direction = 'ltr';
|
|
2124
|
+
const [scrollTop, setScrollTop] = m(0);
|
|
2125
|
+
const [scrollLeft, setScrollLeft] = m(0);
|
|
2126
|
+
const [columnWidths, setColumnWidths] = m(() => new Map());
|
|
2127
|
+
const [selectedPosition, setSelectedPosition] = m(initialPosition);
|
|
2128
|
+
const [copiedCell, setCopiedCell] = m(null);
|
|
2129
|
+
const [isDragging, setDragging] = m(false);
|
|
2130
|
+
const [draggedOverRowIdx, setOverRowIdx] = m(undefined);
|
|
2131
|
+
const [autoResizeColumn, setAutoResizeColumn] = m(null);
|
|
2132
|
+
const prevSelectedPosition = h(selectedPosition);
|
|
2133
|
+
const latestDraggedOverRowIdx = h(draggedOverRowIdx);
|
|
2134
|
+
const lastSelectedRowIdx = h(-1);
|
|
2135
|
+
const rowRef = h(null);
|
|
2136
|
+
const [gridRef, gridWidth, gridHeight] = useGridDimensions();
|
|
2137
|
+
const headerRowsCount = 1;
|
|
2138
|
+
const summaryRowsCount = (_summaryRows$length = summaryRows == null ? void 0 : summaryRows.length) != null ? _summaryRows$length : 0;
|
|
2139
|
+
const clientHeight = gridHeight - headerRowHeight - summaryRowsCount * summaryRowHeight;
|
|
2140
|
+
const isSelectable = selectedRows != null && onSelectedRowsChange != null;
|
|
2141
|
+
const isHeaderRowSelected = selectedPosition.rowIdx === -1;
|
|
2142
|
+
const isRtl = direction === 'rtl';
|
|
2143
|
+
const leftKey = isRtl ? 'ArrowRight' : 'ArrowLeft';
|
|
2144
|
+
const rightKey = isRtl ? 'ArrowLeft' : 'ArrowRight';
|
|
2145
|
+
const defaultGridComponents = _(() => ({
|
|
2146
|
+
sortIcon,
|
|
2147
|
+
checkboxFormatter
|
|
2148
|
+
}), [sortIcon, checkboxFormatter]);
|
|
2149
|
+
const allRowsSelected = _(() => {
|
|
2150
|
+
const {
|
|
2151
|
+
length
|
|
2152
|
+
} = rawRows;
|
|
2153
|
+
return length !== 0 && selectedRows != null && rowKeyGetter != null && selectedRows.size >= length && rawRows.every(row => selectedRows.has(rowKeyGetter(row)));
|
|
2154
|
+
}, [rawRows, selectedRows, rowKeyGetter]);
|
|
2155
|
+
const {
|
|
2156
|
+
columns,
|
|
2157
|
+
colSpanColumns,
|
|
2158
|
+
colOverscanStartIdx,
|
|
2159
|
+
colOverscanEndIdx,
|
|
2160
|
+
layoutCssVars,
|
|
2161
|
+
columnMetrics,
|
|
2162
|
+
totalColumnWidth,
|
|
2163
|
+
lastFrozenColumnIndex,
|
|
2164
|
+
totalFrozenColumnWidth,
|
|
2165
|
+
groupBy
|
|
2166
|
+
} = useCalculatedColumns({
|
|
2167
|
+
rawColumns,
|
|
2168
|
+
columnWidths,
|
|
2169
|
+
scrollLeft,
|
|
2170
|
+
viewportWidth: gridWidth,
|
|
2171
|
+
defaultColumnOptions,
|
|
2172
|
+
rawGroupBy: rowGrouper ? rawGroupBy : undefined,
|
|
2173
|
+
enableVirtualization
|
|
2174
|
+
});
|
|
2175
|
+
const {
|
|
2176
|
+
rowOverscanStartIdx,
|
|
2177
|
+
rowOverscanEndIdx,
|
|
2178
|
+
rows,
|
|
2179
|
+
rowsCount,
|
|
2180
|
+
totalRowHeight,
|
|
2181
|
+
gridTemplateRows,
|
|
2182
|
+
isGroupRow,
|
|
2183
|
+
getRowTop,
|
|
2184
|
+
getRowHeight,
|
|
2185
|
+
findRowIdx
|
|
2186
|
+
} = useViewportRows({
|
|
2187
|
+
rawRows,
|
|
2188
|
+
groupBy,
|
|
2189
|
+
rowGrouper,
|
|
2190
|
+
rowHeight,
|
|
2191
|
+
clientHeight,
|
|
2192
|
+
scrollTop,
|
|
2193
|
+
expandedGroupIds,
|
|
2194
|
+
enableVirtualization
|
|
2195
|
+
});
|
|
2196
|
+
const viewportColumns = useViewportColumns({
|
|
2197
|
+
columns,
|
|
2198
|
+
colSpanColumns,
|
|
2199
|
+
colOverscanStartIdx,
|
|
2200
|
+
colOverscanEndIdx,
|
|
2201
|
+
lastFrozenColumnIndex,
|
|
2202
|
+
rowOverscanStartIdx,
|
|
2203
|
+
rowOverscanEndIdx,
|
|
2204
|
+
rows,
|
|
2205
|
+
summaryRows,
|
|
2206
|
+
isGroupRow
|
|
2207
|
+
});
|
|
2208
|
+
const hasGroups = groupBy.length > 0 && typeof rowGrouper === 'function';
|
|
2209
|
+
const minColIdx = hasGroups ? -1 : 0;
|
|
2210
|
+
const maxColIdx = columns.length - 1;
|
|
2211
|
+
const minRowIdx = -1;
|
|
2212
|
+
const maxRowIdx = headerRowsCount + rows.length + summaryRowsCount - 2;
|
|
2213
|
+
const selectedCellIsWithinSelectionBounds = isCellWithinSelectionBounds(selectedPosition);
|
|
2214
|
+
const selectedCellIsWithinViewportBounds = isCellWithinViewportBounds(selectedPosition);
|
|
2215
|
+
const selectRowLatest = useLatestFunc(selectRow);
|
|
2216
|
+
const selectAllRowsLatest = useLatestFunc(selectAllRows);
|
|
2217
|
+
const handleFormatterRowChangeLatest = useLatestFunc(updateRow);
|
|
2218
|
+
const selectViewportCellLatest = useLatestFunc((row, column, enableEditor) => {
|
|
2219
|
+
const rowIdx = rows.indexOf(row);
|
|
2220
|
+
selectCell({
|
|
2221
|
+
rowIdx,
|
|
2222
|
+
idx: column.idx
|
|
2223
|
+
}, enableEditor);
|
|
2224
|
+
});
|
|
2225
|
+
const selectGroupLatest = useLatestFunc(rowIdx => {
|
|
2226
|
+
selectCell({
|
|
2227
|
+
rowIdx,
|
|
2228
|
+
idx: -1
|
|
2229
|
+
});
|
|
2230
|
+
});
|
|
2231
|
+
const selectHeaderCellLatest = useLatestFunc(idx => {
|
|
2232
|
+
selectCell({
|
|
2233
|
+
rowIdx: -1,
|
|
2234
|
+
idx
|
|
2235
|
+
});
|
|
2236
|
+
});
|
|
2237
|
+
const selectSummaryCellLatest = useLatestFunc((summaryRow, column) => {
|
|
2238
|
+
const rowIdx = summaryRows.indexOf(summaryRow) + headerRowsCount + rows.length - 1;
|
|
2239
|
+
selectCell({
|
|
2240
|
+
rowIdx,
|
|
2241
|
+
idx: column.idx
|
|
2242
|
+
});
|
|
2243
|
+
});
|
|
2244
|
+
const toggleGroupLatest = useLatestFunc(toggleGroup);
|
|
2245
|
+
useLayoutEffect(() => {
|
|
2246
|
+
if (!selectedCellIsWithinSelectionBounds || isSamePosition(selectedPosition, prevSelectedPosition.current)) {
|
|
2247
|
+
prevSelectedPosition.current = selectedPosition;
|
|
2248
|
+
return;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
prevSelectedPosition.current = selectedPosition;
|
|
2252
|
+
scrollToCell(selectedPosition);
|
|
2253
|
+
|
|
2254
|
+
if (selectedPosition.idx === -1) {
|
|
2255
|
+
rowRef.current.focus({
|
|
2256
|
+
preventScroll: true
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2259
|
+
});
|
|
2260
|
+
useLayoutEffect(() => {
|
|
2261
|
+
if (autoResizeColumn === null) return;
|
|
2262
|
+
const columnElement = gridRef.current.querySelector(`[aria-colindex="${autoResizeColumn.idx + 1}"]`);
|
|
2263
|
+
const width = columnElement.clientWidth + 2;
|
|
2264
|
+
setColumnWidths(columnWidths => {
|
|
2265
|
+
const newColumnWidths = new Map(columnWidths);
|
|
2266
|
+
newColumnWidths.set(autoResizeColumn.key, width);
|
|
2267
|
+
return newColumnWidths;
|
|
2268
|
+
});
|
|
2269
|
+
setAutoResizeColumn(null);
|
|
2270
|
+
onColumnResize == null ? void 0 : onColumnResize(autoResizeColumn.idx, width);
|
|
2271
|
+
}, [autoResizeColumn, gridRef, onColumnResize]);
|
|
2272
|
+
s(ref, () => ({
|
|
2273
|
+
element: gridRef.current,
|
|
2274
|
+
|
|
2275
|
+
scrollToColumn(idx) {
|
|
2276
|
+
scrollToCell({
|
|
2277
|
+
idx
|
|
2278
|
+
});
|
|
2279
|
+
},
|
|
2280
|
+
|
|
2281
|
+
scrollToRow(rowIdx) {
|
|
2282
|
+
const {
|
|
2283
|
+
current
|
|
2284
|
+
} = gridRef;
|
|
2285
|
+
if (!current) return;
|
|
2286
|
+
current.scrollTo({
|
|
2287
|
+
top: getRowTop(rowIdx),
|
|
2288
|
+
behavior: 'smooth'
|
|
2289
|
+
});
|
|
2290
|
+
},
|
|
2291
|
+
|
|
2292
|
+
selectCell
|
|
2293
|
+
}));
|
|
2294
|
+
const handleColumnResize = A$1((column, width) => {
|
|
2295
|
+
if (width === 'auto') {
|
|
2296
|
+
setAutoResizeColumn(column);
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
setColumnWidths(columnWidths => {
|
|
2301
|
+
const newColumnWidths = new Map(columnWidths);
|
|
2302
|
+
newColumnWidths.set(column.key, width);
|
|
2303
|
+
return newColumnWidths;
|
|
2304
|
+
});
|
|
2305
|
+
onColumnResize == null ? void 0 : onColumnResize(column.idx, width);
|
|
2306
|
+
}, [onColumnResize]);
|
|
2307
|
+
const setDraggedOverRowIdx = A$1(rowIdx => {
|
|
2308
|
+
setOverRowIdx(rowIdx);
|
|
2309
|
+
latestDraggedOverRowIdx.current = rowIdx;
|
|
2310
|
+
}, []);
|
|
2311
|
+
|
|
2312
|
+
function selectRow({
|
|
2313
|
+
row,
|
|
2314
|
+
checked,
|
|
2315
|
+
isShiftClick
|
|
2316
|
+
}) {
|
|
2317
|
+
if (!onSelectedRowsChange) return;
|
|
2318
|
+
assertIsValidKeyGetter(rowKeyGetter);
|
|
2319
|
+
const newSelectedRows = new Set(selectedRows);
|
|
2320
|
+
|
|
2321
|
+
if (isGroupRow(row)) {
|
|
2322
|
+
for (const childRow of row.childRows) {
|
|
2323
|
+
const rowKey = rowKeyGetter(childRow);
|
|
2324
|
+
|
|
2325
|
+
if (checked) {
|
|
2326
|
+
newSelectedRows.add(rowKey);
|
|
2327
|
+
} else {
|
|
2328
|
+
newSelectedRows.delete(rowKey);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
onSelectedRowsChange(newSelectedRows);
|
|
2333
|
+
return;
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
const rowKey = rowKeyGetter(row);
|
|
2337
|
+
|
|
2338
|
+
if (checked) {
|
|
2339
|
+
newSelectedRows.add(rowKey);
|
|
2340
|
+
const previousRowIdx = lastSelectedRowIdx.current;
|
|
2341
|
+
const rowIdx = rows.indexOf(row);
|
|
2342
|
+
lastSelectedRowIdx.current = rowIdx;
|
|
2343
|
+
|
|
2344
|
+
if (isShiftClick && previousRowIdx !== -1 && previousRowIdx !== rowIdx) {
|
|
2345
|
+
const step = sign(rowIdx - previousRowIdx);
|
|
2346
|
+
|
|
2347
|
+
for (let i = previousRowIdx + step; i !== rowIdx; i += step) {
|
|
2348
|
+
const row = rows[i];
|
|
2349
|
+
if (isGroupRow(row)) continue;
|
|
2350
|
+
newSelectedRows.add(rowKeyGetter(row));
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
} else {
|
|
2354
|
+
newSelectedRows.delete(rowKey);
|
|
2355
|
+
lastSelectedRowIdx.current = -1;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
onSelectedRowsChange(newSelectedRows);
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
function selectAllRows(checked) {
|
|
2362
|
+
if (!onSelectedRowsChange) return;
|
|
2363
|
+
assertIsValidKeyGetter(rowKeyGetter);
|
|
2364
|
+
const newSelectedRows = new Set(selectedRows);
|
|
2365
|
+
|
|
2366
|
+
for (const row of rawRows) {
|
|
2367
|
+
const rowKey = rowKeyGetter(row);
|
|
2368
|
+
|
|
2369
|
+
if (checked) {
|
|
2370
|
+
newSelectedRows.add(rowKey);
|
|
2371
|
+
} else {
|
|
2372
|
+
newSelectedRows.delete(rowKey);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
onSelectedRowsChange(newSelectedRows);
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
function toggleGroup(expandedGroupId) {
|
|
2380
|
+
if (!onExpandedGroupIdsChange) return;
|
|
2381
|
+
const newExpandedGroupIds = new Set(expandedGroupIds);
|
|
2382
|
+
|
|
2383
|
+
if (newExpandedGroupIds.has(expandedGroupId)) {
|
|
2384
|
+
newExpandedGroupIds.delete(expandedGroupId);
|
|
2385
|
+
} else {
|
|
2386
|
+
newExpandedGroupIds.add(expandedGroupId);
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
onExpandedGroupIdsChange(newExpandedGroupIds);
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
function handleKeyDown(event) {
|
|
2393
|
+
if (!(event.target instanceof Element)) return;
|
|
2394
|
+
const isCellEvent = event.target.closest('.rdg-cell') !== null;
|
|
2395
|
+
const isRowEvent = hasGroups && event.target === rowRef.current;
|
|
2396
|
+
if (!isCellEvent && !isRowEvent) return;
|
|
2397
|
+
const {
|
|
2398
|
+
key,
|
|
2399
|
+
keyCode
|
|
2400
|
+
} = event;
|
|
2401
|
+
const {
|
|
2402
|
+
rowIdx
|
|
2403
|
+
} = selectedPosition;
|
|
2404
|
+
|
|
2405
|
+
if (selectedCellIsWithinViewportBounds && (onPaste != null || onCopy != null) && isCtrlKeyHeldDown(event) && !isGroupRow(rows[rowIdx]) && selectedPosition.mode === 'SELECT') {
|
|
2406
|
+
const cKey = 67;
|
|
2407
|
+
const vKey = 86;
|
|
2408
|
+
|
|
2409
|
+
if (keyCode === cKey) {
|
|
2410
|
+
handleCopy();
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
if (keyCode === vKey) {
|
|
2415
|
+
handlePaste();
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
if (isRowIdxWithinViewportBounds(rowIdx)) {
|
|
2421
|
+
const row = rows[rowIdx];
|
|
2422
|
+
|
|
2423
|
+
if (isGroupRow(row) && selectedPosition.idx === -1 && (key === leftKey && row.isExpanded || key === rightKey && !row.isExpanded)) {
|
|
2424
|
+
event.preventDefault();
|
|
2425
|
+
toggleGroup(row.id);
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
switch (event.key) {
|
|
2431
|
+
case 'Escape':
|
|
2432
|
+
setCopiedCell(null);
|
|
2433
|
+
return;
|
|
2434
|
+
|
|
2435
|
+
case 'ArrowUp':
|
|
2436
|
+
case 'ArrowDown':
|
|
2437
|
+
case 'ArrowLeft':
|
|
2438
|
+
case 'ArrowRight':
|
|
2439
|
+
case 'Tab':
|
|
2440
|
+
case 'Home':
|
|
2441
|
+
case 'End':
|
|
2442
|
+
case 'PageUp':
|
|
2443
|
+
case 'PageDown':
|
|
2444
|
+
navigate(event);
|
|
2445
|
+
break;
|
|
2446
|
+
|
|
2447
|
+
default:
|
|
2448
|
+
handleCellInput(event);
|
|
2449
|
+
break;
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
function handleScroll(event) {
|
|
2454
|
+
const {
|
|
2455
|
+
scrollTop,
|
|
2456
|
+
scrollLeft
|
|
2457
|
+
} = event.currentTarget;
|
|
2458
|
+
setScrollTop(scrollTop);
|
|
2459
|
+
setScrollLeft(abs(scrollLeft));
|
|
2460
|
+
onScroll == null ? void 0 : onScroll(event);
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
function getRawRowIdx(rowIdx) {
|
|
2464
|
+
return hasGroups ? rawRows.indexOf(rows[rowIdx]) : rowIdx;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
function updateRow(rowIdx, row) {
|
|
2468
|
+
if (typeof onRowsChange !== 'function') return;
|
|
2469
|
+
const rawRowIdx = getRawRowIdx(rowIdx);
|
|
2470
|
+
if (row === rawRows[rawRowIdx]) return;
|
|
2471
|
+
const updatedRows = [...rawRows];
|
|
2472
|
+
updatedRows[rawRowIdx] = row;
|
|
2473
|
+
onRowsChange(updatedRows, {
|
|
2474
|
+
indexes: [rawRowIdx],
|
|
2475
|
+
column: columns[selectedPosition.idx]
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
function commitEditorChanges() {
|
|
2480
|
+
if (selectedPosition.mode !== 'EDIT') return;
|
|
2481
|
+
updateRow(selectedPosition.rowIdx, selectedPosition.row);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
function handleCopy() {
|
|
2485
|
+
const {
|
|
2486
|
+
idx,
|
|
2487
|
+
rowIdx
|
|
2488
|
+
} = selectedPosition;
|
|
2489
|
+
const sourceRow = rawRows[getRawRowIdx(rowIdx)];
|
|
2490
|
+
const sourceColumnKey = columns[idx].key;
|
|
2491
|
+
setCopiedCell({
|
|
2492
|
+
row: sourceRow,
|
|
2493
|
+
columnKey: sourceColumnKey
|
|
2494
|
+
});
|
|
2495
|
+
onCopy == null ? void 0 : onCopy({
|
|
2496
|
+
sourceRow,
|
|
2497
|
+
sourceColumnKey
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
function handlePaste() {
|
|
2502
|
+
if (!onPaste || !onRowsChange || copiedCell === null || !isCellEditable(selectedPosition)) {
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
const {
|
|
2507
|
+
idx,
|
|
2508
|
+
rowIdx
|
|
2509
|
+
} = selectedPosition;
|
|
2510
|
+
const targetRow = rawRows[getRawRowIdx(rowIdx)];
|
|
2511
|
+
const updatedTargetRow = onPaste({
|
|
2512
|
+
sourceRow: copiedCell.row,
|
|
2513
|
+
sourceColumnKey: copiedCell.columnKey,
|
|
2514
|
+
targetRow,
|
|
2515
|
+
targetColumnKey: columns[idx].key
|
|
2516
|
+
});
|
|
2517
|
+
updateRow(rowIdx, updatedTargetRow);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
function handleCellInput(event) {
|
|
2521
|
+
var _column$editorOptions;
|
|
2522
|
+
|
|
2523
|
+
if (!selectedCellIsWithinViewportBounds) return;
|
|
2524
|
+
const row = rows[selectedPosition.rowIdx];
|
|
2525
|
+
if (isGroupRow(row)) return;
|
|
2526
|
+
const {
|
|
2527
|
+
key,
|
|
2528
|
+
shiftKey
|
|
2529
|
+
} = event;
|
|
2530
|
+
|
|
2531
|
+
if (isSelectable && shiftKey && key === ' ') {
|
|
2532
|
+
assertIsValidKeyGetter(rowKeyGetter);
|
|
2533
|
+
const rowKey = rowKeyGetter(row);
|
|
2534
|
+
selectRow({
|
|
2535
|
+
row,
|
|
2536
|
+
checked: !selectedRows.has(rowKey),
|
|
2537
|
+
isShiftClick: false
|
|
2538
|
+
});
|
|
2539
|
+
event.preventDefault();
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
const column = columns[selectedPosition.idx];
|
|
2544
|
+
(_column$editorOptions = column.editorOptions) == null ? void 0 : _column$editorOptions.onCellKeyDown == null ? void 0 : _column$editorOptions.onCellKeyDown(event);
|
|
2545
|
+
if (event.isDefaultPrevented()) return;
|
|
2546
|
+
|
|
2547
|
+
if (isCellEditable(selectedPosition) && isDefaultCellInput(event)) {
|
|
2548
|
+
setSelectedPosition(({
|
|
2549
|
+
idx,
|
|
2550
|
+
rowIdx
|
|
2551
|
+
}) => ({
|
|
2552
|
+
idx,
|
|
2553
|
+
rowIdx,
|
|
2554
|
+
mode: 'EDIT',
|
|
2555
|
+
row,
|
|
2556
|
+
originalRow: row
|
|
2557
|
+
}));
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
function isColIdxWithinSelectionBounds(idx) {
|
|
2562
|
+
return idx >= minColIdx && idx <= maxColIdx;
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
function isRowIdxWithinViewportBounds(rowIdx) {
|
|
2566
|
+
return rowIdx >= 0 && rowIdx < rows.length;
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
function isCellWithinSelectionBounds({
|
|
2570
|
+
idx,
|
|
2571
|
+
rowIdx
|
|
2572
|
+
}) {
|
|
2573
|
+
return rowIdx >= minRowIdx && rowIdx <= maxRowIdx && isColIdxWithinSelectionBounds(idx);
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
function isCellWithinViewportBounds({
|
|
2577
|
+
idx,
|
|
2578
|
+
rowIdx
|
|
2579
|
+
}) {
|
|
2580
|
+
return isRowIdxWithinViewportBounds(rowIdx) && isColIdxWithinSelectionBounds(idx);
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
function isCellEditable(position) {
|
|
2584
|
+
return isCellWithinViewportBounds(position) && isSelectedCellEditable({
|
|
2585
|
+
columns,
|
|
2586
|
+
rows,
|
|
2587
|
+
selectedPosition: position,
|
|
2588
|
+
isGroupRow
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
function selectCell(position, enableEditor) {
|
|
2593
|
+
if (!isCellWithinSelectionBounds(position)) return;
|
|
2594
|
+
commitEditorChanges();
|
|
2595
|
+
|
|
2596
|
+
if (enableEditor && isCellEditable(position)) {
|
|
2597
|
+
const row = rows[position.rowIdx];
|
|
2598
|
+
setSelectedPosition({ ...position,
|
|
2599
|
+
mode: 'EDIT',
|
|
2600
|
+
row,
|
|
2601
|
+
originalRow: row
|
|
2602
|
+
});
|
|
2603
|
+
} else if (isSamePosition(selectedPosition, position)) {
|
|
2604
|
+
scrollToCell(position);
|
|
2605
|
+
} else {
|
|
2606
|
+
setSelectedPosition({ ...position,
|
|
2607
|
+
mode: 'SELECT'
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
function scrollToCell({
|
|
2613
|
+
idx,
|
|
2614
|
+
rowIdx
|
|
2615
|
+
}) {
|
|
2616
|
+
const {
|
|
2617
|
+
current
|
|
2618
|
+
} = gridRef;
|
|
2619
|
+
if (!current) return;
|
|
2620
|
+
|
|
2621
|
+
if (typeof idx === 'number' && idx > lastFrozenColumnIndex) {
|
|
2622
|
+
var _rowIdx;
|
|
2623
|
+
|
|
2624
|
+
(_rowIdx = rowIdx) != null ? _rowIdx : rowIdx = selectedPosition.rowIdx;
|
|
2625
|
+
if (!isCellWithinSelectionBounds({
|
|
2626
|
+
rowIdx,
|
|
2627
|
+
idx
|
|
2628
|
+
})) return;
|
|
2629
|
+
const {
|
|
2630
|
+
clientWidth
|
|
2631
|
+
} = current;
|
|
2632
|
+
const column = columns[idx];
|
|
2633
|
+
const {
|
|
2634
|
+
left,
|
|
2635
|
+
width
|
|
2636
|
+
} = columnMetrics.get(column);
|
|
2637
|
+
let right = left + width;
|
|
2638
|
+
const colSpan = getSelectedCellColSpan({
|
|
2639
|
+
rows,
|
|
2640
|
+
summaryRows,
|
|
2641
|
+
rowIdx,
|
|
2642
|
+
lastFrozenColumnIndex,
|
|
2643
|
+
column,
|
|
2644
|
+
isGroupRow
|
|
2645
|
+
});
|
|
2646
|
+
|
|
2647
|
+
if (colSpan !== undefined) {
|
|
2648
|
+
const {
|
|
2649
|
+
left,
|
|
2650
|
+
width
|
|
2651
|
+
} = columnMetrics.get(columns[column.idx + colSpan - 1]);
|
|
2652
|
+
right = left + width;
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
const isCellAtLeftBoundary = left < scrollLeft + totalFrozenColumnWidth;
|
|
2656
|
+
const isCellAtRightBoundary = right > clientWidth + scrollLeft;
|
|
2657
|
+
const sign = isRtl ? -1 : 1;
|
|
2658
|
+
|
|
2659
|
+
if (isCellAtLeftBoundary) {
|
|
2660
|
+
current.scrollLeft = (left - totalFrozenColumnWidth) * sign;
|
|
2661
|
+
} else if (isCellAtRightBoundary) {
|
|
2662
|
+
current.scrollLeft = (right - clientWidth) * sign;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
if (typeof rowIdx === 'number' && isRowIdxWithinViewportBounds(rowIdx)) {
|
|
2667
|
+
const rowTop = getRowTop(rowIdx);
|
|
2668
|
+
const rowHeight = getRowHeight(rowIdx);
|
|
2669
|
+
|
|
2670
|
+
if (rowTop < scrollTop) {
|
|
2671
|
+
current.scrollTop = rowTop;
|
|
2672
|
+
} else if (rowTop + rowHeight > scrollTop + clientHeight) {
|
|
2673
|
+
current.scrollTop = rowTop + rowHeight - clientHeight;
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
function getNextPosition(key, ctrlKey, shiftKey) {
|
|
2679
|
+
const {
|
|
2680
|
+
idx,
|
|
2681
|
+
rowIdx
|
|
2682
|
+
} = selectedPosition;
|
|
2683
|
+
const row = rows[rowIdx];
|
|
2684
|
+
const isRowSelected = selectedCellIsWithinSelectionBounds && idx === -1;
|
|
2685
|
+
|
|
2686
|
+
if (key === leftKey && isRowSelected && isGroupRow(row) && !row.isExpanded && row.level !== 0) {
|
|
2687
|
+
let parentRowIdx = -1;
|
|
2688
|
+
|
|
2689
|
+
for (let i = selectedPosition.rowIdx - 1; i >= 0; i--) {
|
|
2690
|
+
const parentRow = rows[i];
|
|
2691
|
+
|
|
2692
|
+
if (isGroupRow(parentRow) && parentRow.id === row.parentId) {
|
|
2693
|
+
parentRowIdx = i;
|
|
2694
|
+
break;
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
if (parentRowIdx !== -1) {
|
|
2699
|
+
return {
|
|
2700
|
+
idx,
|
|
2701
|
+
rowIdx: parentRowIdx
|
|
2702
|
+
};
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
switch (key) {
|
|
2707
|
+
case 'ArrowUp':
|
|
2708
|
+
return {
|
|
2709
|
+
idx,
|
|
2710
|
+
rowIdx: rowIdx - 1
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2713
|
+
case 'ArrowDown':
|
|
2714
|
+
return {
|
|
2715
|
+
idx,
|
|
2716
|
+
rowIdx: rowIdx + 1
|
|
2717
|
+
};
|
|
2718
|
+
|
|
2719
|
+
case 'ArrowLeft':
|
|
2720
|
+
return isRtl ? {
|
|
2721
|
+
idx: idx + 1,
|
|
2722
|
+
rowIdx
|
|
2723
|
+
} : {
|
|
2724
|
+
idx: idx - 1,
|
|
2725
|
+
rowIdx
|
|
2726
|
+
};
|
|
2727
|
+
|
|
2728
|
+
case 'ArrowRight':
|
|
2729
|
+
return isRtl ? {
|
|
2730
|
+
idx: idx - 1,
|
|
2731
|
+
rowIdx
|
|
2732
|
+
} : {
|
|
2733
|
+
idx: idx + 1,
|
|
2734
|
+
rowIdx
|
|
2735
|
+
};
|
|
2736
|
+
|
|
2737
|
+
case 'Tab':
|
|
2738
|
+
return {
|
|
2739
|
+
idx: idx + (shiftKey ? -1 : 1),
|
|
2740
|
+
rowIdx
|
|
2741
|
+
};
|
|
2742
|
+
|
|
2743
|
+
case 'Home':
|
|
2744
|
+
if (isRowSelected) return {
|
|
2745
|
+
idx,
|
|
2746
|
+
rowIdx: 0
|
|
2747
|
+
};
|
|
2748
|
+
return {
|
|
2749
|
+
idx: 0,
|
|
2750
|
+
rowIdx: ctrlKey ? minRowIdx : rowIdx
|
|
2751
|
+
};
|
|
2752
|
+
|
|
2753
|
+
case 'End':
|
|
2754
|
+
if (isRowSelected) return {
|
|
2755
|
+
idx,
|
|
2756
|
+
rowIdx: rows.length - 1
|
|
2757
|
+
};
|
|
2758
|
+
return {
|
|
2759
|
+
idx: maxColIdx,
|
|
2760
|
+
rowIdx: ctrlKey ? maxRowIdx : rowIdx
|
|
2761
|
+
};
|
|
2762
|
+
|
|
2763
|
+
case 'PageUp':
|
|
2764
|
+
{
|
|
2765
|
+
if (selectedPosition.rowIdx === minRowIdx) return selectedPosition;
|
|
2766
|
+
const nextRowY = getRowTop(rowIdx) + getRowHeight(rowIdx) - clientHeight;
|
|
2767
|
+
return {
|
|
2768
|
+
idx,
|
|
2769
|
+
rowIdx: nextRowY > 0 ? findRowIdx(nextRowY) : 0
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
case 'PageDown':
|
|
2774
|
+
{
|
|
2775
|
+
if (selectedPosition.rowIdx >= rows.length) return selectedPosition;
|
|
2776
|
+
const nextRowY = getRowTop(rowIdx) + clientHeight;
|
|
2777
|
+
return {
|
|
2778
|
+
idx,
|
|
2779
|
+
rowIdx: nextRowY < totalRowHeight ? findRowIdx(nextRowY) : rows.length - 1
|
|
2780
|
+
};
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
default:
|
|
2784
|
+
return selectedPosition;
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
function navigate(event) {
|
|
2789
|
+
const {
|
|
2790
|
+
key,
|
|
2791
|
+
shiftKey
|
|
2792
|
+
} = event;
|
|
2793
|
+
let mode = cellNavigationMode;
|
|
2794
|
+
|
|
2795
|
+
if (key === 'Tab') {
|
|
2796
|
+
if (canExitGrid({
|
|
2797
|
+
shiftKey,
|
|
2798
|
+
cellNavigationMode,
|
|
2799
|
+
maxColIdx,
|
|
2800
|
+
minRowIdx,
|
|
2801
|
+
maxRowIdx,
|
|
2802
|
+
selectedPosition
|
|
2803
|
+
})) {
|
|
2804
|
+
commitEditorChanges();
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
mode = cellNavigationMode === 'NONE' ? 'CHANGE_ROW' : cellNavigationMode;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
event.preventDefault();
|
|
2812
|
+
const ctrlKey = isCtrlKeyHeldDown(event);
|
|
2813
|
+
const nextPosition = getNextPosition(key, ctrlKey, shiftKey);
|
|
2814
|
+
if (isSamePosition(selectedPosition, nextPosition)) return;
|
|
2815
|
+
const nextSelectedCellPosition = getNextSelectedCellPosition({
|
|
2816
|
+
columns,
|
|
2817
|
+
colSpanColumns,
|
|
2818
|
+
rows,
|
|
2819
|
+
summaryRows,
|
|
2820
|
+
minRowIdx,
|
|
2821
|
+
maxRowIdx,
|
|
2822
|
+
lastFrozenColumnIndex,
|
|
2823
|
+
cellNavigationMode: mode,
|
|
2824
|
+
currentPosition: selectedPosition,
|
|
2825
|
+
nextPosition,
|
|
2826
|
+
isCellWithinBounds: isCellWithinSelectionBounds,
|
|
2827
|
+
isGroupRow
|
|
2828
|
+
});
|
|
2829
|
+
selectCell(nextSelectedCellPosition);
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
function getDraggedOverCellIdx(currentRowIdx) {
|
|
2833
|
+
if (draggedOverRowIdx === undefined) return;
|
|
2834
|
+
const {
|
|
2835
|
+
rowIdx
|
|
2836
|
+
} = selectedPosition;
|
|
2837
|
+
const isDraggedOver = rowIdx < draggedOverRowIdx ? rowIdx < currentRowIdx && currentRowIdx <= draggedOverRowIdx : rowIdx > currentRowIdx && currentRowIdx >= draggedOverRowIdx;
|
|
2838
|
+
return isDraggedOver ? selectedPosition.idx : undefined;
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
function getLayoutCssVars() {
|
|
2842
|
+
if (autoResizeColumn === null) return layoutCssVars;
|
|
2843
|
+
const {
|
|
2844
|
+
gridTemplateColumns
|
|
2845
|
+
} = layoutCssVars;
|
|
2846
|
+
const newSizes = gridTemplateColumns.split(' ');
|
|
2847
|
+
newSizes[autoResizeColumn.idx] = 'max-content';
|
|
2848
|
+
return { ...layoutCssVars,
|
|
2849
|
+
gridTemplateColumns: newSizes.join(' ')
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
function getDragHandle(rowIdx) {
|
|
2854
|
+
if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === 'EDIT' || hasGroups || onFill == null) {
|
|
2855
|
+
return;
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
return /*#__PURE__*/e$1(DragHandle, {
|
|
2859
|
+
rows: rawRows,
|
|
2860
|
+
columns: columns,
|
|
2861
|
+
selectedPosition: selectedPosition,
|
|
2862
|
+
isCellEditable: isCellEditable,
|
|
2863
|
+
latestDraggedOverRowIdx: latestDraggedOverRowIdx,
|
|
2864
|
+
onRowsChange: onRowsChange,
|
|
2865
|
+
onFill: onFill,
|
|
2866
|
+
setDragging: setDragging,
|
|
2867
|
+
setDraggedOverRowIdx: setDraggedOverRowIdx
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
function getCellEditor(rowIdx) {
|
|
2872
|
+
if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === 'SELECT') return;
|
|
2873
|
+
const {
|
|
2874
|
+
idx,
|
|
2875
|
+
row
|
|
2876
|
+
} = selectedPosition;
|
|
2877
|
+
const column = columns[idx];
|
|
2878
|
+
const colSpan = getColSpan(column, lastFrozenColumnIndex, {
|
|
2879
|
+
type: 'ROW',
|
|
2880
|
+
row
|
|
2881
|
+
});
|
|
2882
|
+
|
|
2883
|
+
const closeEditor = () => {
|
|
2884
|
+
setSelectedPosition(({
|
|
2885
|
+
idx,
|
|
2886
|
+
rowIdx
|
|
2887
|
+
}) => ({
|
|
2888
|
+
idx,
|
|
2889
|
+
rowIdx,
|
|
2890
|
+
mode: 'SELECT'
|
|
2891
|
+
}));
|
|
2892
|
+
};
|
|
2893
|
+
|
|
2894
|
+
const onRowChange = (row, commitChanges) => {
|
|
2895
|
+
if (commitChanges) {
|
|
2896
|
+
updateRow(selectedPosition.rowIdx, row);
|
|
2897
|
+
closeEditor();
|
|
2898
|
+
} else {
|
|
2899
|
+
setSelectedPosition(position => ({ ...position,
|
|
2900
|
+
row
|
|
2901
|
+
}));
|
|
2902
|
+
}
|
|
2903
|
+
};
|
|
2904
|
+
|
|
2905
|
+
if (rows[selectedPosition.rowIdx] !== selectedPosition.originalRow) {
|
|
2906
|
+
closeEditor();
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
return /*#__PURE__*/e$1(EditCell, {
|
|
2910
|
+
column: column,
|
|
2911
|
+
colSpan: colSpan,
|
|
2912
|
+
row: row,
|
|
2913
|
+
onRowChange: onRowChange,
|
|
2914
|
+
closeEditor: closeEditor,
|
|
2915
|
+
scrollToCell: () => {
|
|
2916
|
+
scrollToCell(selectedPosition);
|
|
2917
|
+
}
|
|
2918
|
+
}, column.key);
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
function getViewportRows() {
|
|
2922
|
+
const rowElements = [];
|
|
2923
|
+
let startRowIndex = 0;
|
|
2924
|
+
const {
|
|
2925
|
+
idx: selectedIdx,
|
|
2926
|
+
rowIdx: selectedRowIdx
|
|
2927
|
+
} = selectedPosition;
|
|
2928
|
+
const startRowIdx = selectedCellIsWithinViewportBounds && selectedRowIdx < rowOverscanStartIdx ? rowOverscanStartIdx - 1 : rowOverscanStartIdx;
|
|
2929
|
+
const endRowIdx = selectedCellIsWithinViewportBounds && selectedRowIdx > rowOverscanEndIdx ? rowOverscanEndIdx + 1 : rowOverscanEndIdx;
|
|
2930
|
+
|
|
2931
|
+
for (let viewportRowIdx = startRowIdx; viewportRowIdx <= endRowIdx; viewportRowIdx++) {
|
|
2932
|
+
const isRowOutsideViewport = viewportRowIdx === rowOverscanStartIdx - 1 || viewportRowIdx === rowOverscanEndIdx + 1;
|
|
2933
|
+
const rowIdx = isRowOutsideViewport ? selectedRowIdx : viewportRowIdx;
|
|
2934
|
+
let rowColumns = viewportColumns;
|
|
2935
|
+
const selectedColumn = columns[selectedIdx];
|
|
2936
|
+
|
|
2937
|
+
if (selectedColumn !== undefined) {
|
|
2938
|
+
if (isRowOutsideViewport) {
|
|
2939
|
+
rowColumns = [selectedColumn];
|
|
2940
|
+
} else if (selectedRowIdx === rowIdx && !viewportColumns.includes(selectedColumn)) {
|
|
2941
|
+
rowColumns = selectedIdx > viewportColumns[viewportColumns.length - 1].idx ? [...viewportColumns, selectedColumn] : [...viewportColumns.slice(0, lastFrozenColumnIndex + 1), selectedColumn, ...viewportColumns.slice(lastFrozenColumnIndex + 1)];
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
const row = rows[rowIdx];
|
|
2946
|
+
const gridRowStart = headerRowsCount + rowIdx + 1;
|
|
2947
|
+
|
|
2948
|
+
if (isGroupRow(row)) {
|
|
2949
|
+
({
|
|
2950
|
+
startRowIndex
|
|
2951
|
+
} = row);
|
|
2952
|
+
const isGroupRowSelected = isSelectable && row.childRows.every(cr => selectedRows.has(rowKeyGetter(cr)));
|
|
2953
|
+
rowElements.push( /*#__PURE__*/e$1(GroupRowRenderer, {
|
|
2954
|
+
"aria-level": row.level + 1,
|
|
2955
|
+
"aria-setsize": row.setSize,
|
|
2956
|
+
"aria-posinset": row.posInSet + 1,
|
|
2957
|
+
"aria-rowindex": headerRowsCount + startRowIndex + 1,
|
|
2958
|
+
"aria-selected": isSelectable ? isGroupRowSelected : undefined,
|
|
2959
|
+
id: row.id,
|
|
2960
|
+
groupKey: row.groupKey,
|
|
2961
|
+
viewportColumns: rowColumns,
|
|
2962
|
+
childRows: row.childRows,
|
|
2963
|
+
rowIdx: rowIdx,
|
|
2964
|
+
row: row,
|
|
2965
|
+
gridRowStart: gridRowStart,
|
|
2966
|
+
height: getRowHeight(rowIdx),
|
|
2967
|
+
level: row.level,
|
|
2968
|
+
isExpanded: row.isExpanded,
|
|
2969
|
+
selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : undefined,
|
|
2970
|
+
isRowSelected: isGroupRowSelected,
|
|
2971
|
+
selectGroup: selectGroupLatest,
|
|
2972
|
+
toggleGroup: toggleGroupLatest
|
|
2973
|
+
}, row.id));
|
|
2974
|
+
continue;
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
startRowIndex++;
|
|
2978
|
+
let key;
|
|
2979
|
+
let isRowSelected = false;
|
|
2980
|
+
|
|
2981
|
+
if (typeof rowKeyGetter === 'function') {
|
|
2982
|
+
var _selectedRows$has;
|
|
2983
|
+
|
|
2984
|
+
key = rowKeyGetter(row);
|
|
2985
|
+
isRowSelected = (_selectedRows$has = selectedRows == null ? void 0 : selectedRows.has(key)) != null ? _selectedRows$has : false;
|
|
2986
|
+
} else {
|
|
2987
|
+
key = hasGroups ? startRowIndex : rowIdx;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
rowElements.push( /*#__PURE__*/e$1(RowRenderer, {
|
|
2991
|
+
"aria-rowindex": headerRowsCount + (hasGroups ? startRowIndex : rowIdx) + 1,
|
|
2992
|
+
"aria-selected": isSelectable ? isRowSelected : undefined,
|
|
2993
|
+
rowIdx: rowIdx,
|
|
2994
|
+
row: row,
|
|
2995
|
+
viewportColumns: rowColumns,
|
|
2996
|
+
isRowSelected: isRowSelected,
|
|
2997
|
+
onRowClick: onRowClick,
|
|
2998
|
+
onRowDoubleClick: onRowDoubleClick,
|
|
2999
|
+
rowClass: rowClass,
|
|
3000
|
+
gridRowStart: gridRowStart,
|
|
3001
|
+
height: getRowHeight(rowIdx),
|
|
3002
|
+
copiedCellIdx: copiedCell !== null && copiedCell.row === row ? columns.findIndex(c => c.key === copiedCell.columnKey) : undefined,
|
|
3003
|
+
selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : undefined,
|
|
3004
|
+
draggedOverCellIdx: getDraggedOverCellIdx(rowIdx),
|
|
3005
|
+
setDraggedOverRowIdx: isDragging ? setDraggedOverRowIdx : undefined,
|
|
3006
|
+
lastFrozenColumnIndex: lastFrozenColumnIndex,
|
|
3007
|
+
onRowChange: handleFormatterRowChangeLatest,
|
|
3008
|
+
selectCell: selectViewportCellLatest,
|
|
3009
|
+
selectedCellDragHandle: getDragHandle(rowIdx),
|
|
3010
|
+
selectedCellEditor: getCellEditor(rowIdx)
|
|
3011
|
+
}, key));
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
return rowElements;
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
if (selectedPosition.idx > maxColIdx || selectedPosition.rowIdx > maxRowIdx) {
|
|
3018
|
+
setSelectedPosition(initialPosition);
|
|
3019
|
+
setDraggedOverRowIdx(undefined);
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
let templateRows = `${headerRowHeight}px`;
|
|
3023
|
+
|
|
3024
|
+
if (rows.length > 0) {
|
|
3025
|
+
templateRows += gridTemplateRows;
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
if (summaryRowsCount > 0) {
|
|
3029
|
+
templateRows += ` repeat(${summaryRowsCount}, ${summaryRowHeight}px)`;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
return /*#__PURE__*/e$1("div", {
|
|
3033
|
+
role: hasGroups ? 'treegrid' : 'grid',
|
|
3034
|
+
"aria-label": ariaLabel,
|
|
3035
|
+
"aria-labelledby": ariaLabelledBy,
|
|
3036
|
+
"aria-describedby": ariaDescribedBy,
|
|
3037
|
+
"aria-multiselectable": isSelectable ? true : undefined,
|
|
3038
|
+
"aria-colcount": columns.length,
|
|
3039
|
+
"aria-rowcount": headerRowsCount + rowsCount + summaryRowsCount,
|
|
3040
|
+
className: clsx(rootClassname, className, isDragging && viewportDraggingClassname, autoResizeColumn !== null && cellAutoResizeClassname),
|
|
3041
|
+
style: { ...style,
|
|
3042
|
+
gridTemplateRows: templateRows,
|
|
3043
|
+
'--rdg-header-row-height': `${headerRowHeight}px`,
|
|
3044
|
+
'--rdg-grid-inline-size': `${totalColumnWidth}px`,
|
|
3045
|
+
'--rdg-summary-row-height': `${summaryRowHeight}px`,
|
|
3046
|
+
'--rdg-grid-block-size': `${max(totalRowHeight, clientHeight) + headerRowHeight + summaryRowsCount * summaryRowHeight}px`,
|
|
3047
|
+
'--rdg-sign': isRtl ? -1 : 1,
|
|
3048
|
+
...getLayoutCssVars()
|
|
3049
|
+
},
|
|
3050
|
+
dir: direction,
|
|
3051
|
+
ref: gridRef,
|
|
3052
|
+
onScroll: handleScroll,
|
|
3053
|
+
onKeyDown: handleKeyDown,
|
|
3054
|
+
"data-testid": testId,
|
|
3055
|
+
children: [hasGroups && /*#__PURE__*/e$1("div", {
|
|
3056
|
+
ref: rowRef,
|
|
3057
|
+
tabIndex: selectedPosition.idx === -1 && selectedPosition.rowIdx !== -2 ? 0 : -1,
|
|
3058
|
+
className: focusSinkClassname,
|
|
3059
|
+
style: {
|
|
3060
|
+
gridRowStart: selectedPosition.rowIdx + 2
|
|
3061
|
+
},
|
|
3062
|
+
onKeyDown: handleKeyDown
|
|
3063
|
+
}), /*#__PURE__*/e$1(DataGridDefaultComponentsProvider, {
|
|
3064
|
+
value: defaultGridComponents,
|
|
3065
|
+
children: [/*#__PURE__*/e$1(HeaderRow$1, {
|
|
3066
|
+
columns: viewportColumns,
|
|
3067
|
+
onColumnResize: handleColumnResize,
|
|
3068
|
+
allRowsSelected: allRowsSelected,
|
|
3069
|
+
onAllRowsSelectionChange: selectAllRowsLatest,
|
|
3070
|
+
sortColumns: sortColumns,
|
|
3071
|
+
onSortColumnsChange: onSortColumnsChange,
|
|
3072
|
+
lastFrozenColumnIndex: lastFrozenColumnIndex,
|
|
3073
|
+
selectedCellIdx: isHeaderRowSelected ? selectedPosition.idx : undefined,
|
|
3074
|
+
selectCell: selectHeaderCellLatest,
|
|
3075
|
+
shouldFocusGrid: !selectedCellIsWithinSelectionBounds,
|
|
3076
|
+
direction: direction
|
|
3077
|
+
}), rows.length === 0 && noRowsFallback ? noRowsFallback : /*#__PURE__*/e$1(d$1, {
|
|
3078
|
+
children: [/*#__PURE__*/e$1(RowSelectionChangeProvider, {
|
|
3079
|
+
value: selectRowLatest,
|
|
3080
|
+
children: getViewportRows()
|
|
3081
|
+
}), summaryRows == null ? void 0 : summaryRows.map((row, rowIdx) => {
|
|
3082
|
+
const gridRowStart = headerRowsCount + rows.length + rowIdx + 1;
|
|
3083
|
+
const isSummaryRowSelected = selectedPosition.rowIdx === headerRowsCount + rows.length + rowIdx - 1;
|
|
3084
|
+
const top = clientHeight > totalRowHeight ? gridHeight - summaryRowHeight * (summaryRows.length - rowIdx) : undefined;
|
|
3085
|
+
const bottom = top === undefined ? summaryRowHeight * (summaryRows.length - 1 - rowIdx) : undefined;
|
|
3086
|
+
return /*#__PURE__*/e$1(SummaryRow$1, {
|
|
3087
|
+
"aria-rowindex": headerRowsCount + rowsCount + rowIdx + 1,
|
|
3088
|
+
rowIdx: rowIdx,
|
|
3089
|
+
gridRowStart: gridRowStart,
|
|
3090
|
+
row: row,
|
|
3091
|
+
top: top,
|
|
3092
|
+
bottom: bottom,
|
|
3093
|
+
viewportColumns: viewportColumns,
|
|
3094
|
+
lastFrozenColumnIndex: lastFrozenColumnIndex,
|
|
3095
|
+
selectedCellIdx: isSummaryRowSelected ? selectedPosition.idx : undefined,
|
|
3096
|
+
selectCell: selectSummaryCellLatest
|
|
3097
|
+
}, rowIdx);
|
|
3098
|
+
})]
|
|
3099
|
+
})]
|
|
3100
|
+
})]
|
|
3101
|
+
});
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
function isSamePosition(p1, p2) {
|
|
3105
|
+
return p1.idx === p2.idx && p1.rowIdx === p2.rowIdx;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
const DataGrid$1 = /*#__PURE__*/x(DataGrid);
|
|
3109
|
+
|
|
3110
|
+
var css_248z$g = ".t16y9g8l700-beta11{appearance:none;background-color:var(--rdg-background-color);block-size:100%;border:2px solid #ccc;box-sizing:border-box;color:var(--rdg-color);font-family:inherit;font-size:var(--rdg-font-size);inline-size:100%;padding-block:0;padding-inline:6px;vertical-align:top}.t16y9g8l700-beta11:focus{border-color:var(--rdg-selection-color);outline:none}.t16y9g8l700-beta11::placeholder{color:#999;opacity:1}";
|
|
3111
|
+
styleInject$1(css_248z$g,{"insertAt":"top"});
|
|
3112
|
+
|
|
3113
|
+
function styleInject(css, ref) {
|
|
3114
|
+
if ( ref === void 0 ) ref = {};
|
|
3115
|
+
var insertAt = ref.insertAt;
|
|
3116
|
+
|
|
3117
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
3118
|
+
|
|
3119
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3120
|
+
var style = document.createElement('style');
|
|
3121
|
+
style.type = 'text/css';
|
|
3122
|
+
|
|
3123
|
+
if (insertAt === 'top') {
|
|
3124
|
+
if (head.firstChild) {
|
|
3125
|
+
head.insertBefore(style, head.firstChild);
|
|
3126
|
+
} else {
|
|
3127
|
+
head.appendChild(style);
|
|
3128
|
+
}
|
|
3129
|
+
} else {
|
|
3130
|
+
head.appendChild(style);
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
if (style.styleSheet) {
|
|
3134
|
+
style.styleSheet.cssText = css;
|
|
3135
|
+
} else {
|
|
3136
|
+
style.appendChild(document.createTextNode(css));
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
var css_248z = ".dgrid2_Table .rdg{font-family:monospace,Courier New,Courier}.dgrid2_Table .rdg-checkbox-label .rdg-checkbox{block-size:16px;border-width:2px;box-shadow:inset 0 0 0 3px var(--rdg-background-color);inline-size:16px}";
|
|
3141
|
+
styleInject(css_248z);
|
|
3142
|
+
|
|
3143
|
+
function copyAndSort(items, attribute, descending) {
|
|
3144
|
+
var key = attribute;
|
|
3145
|
+
return __spreadArray([], items, true).sort(function (a, b) {
|
|
3146
|
+
if (a[key] < b[key]) {
|
|
3147
|
+
return descending ? 1 : -1;
|
|
3148
|
+
}
|
|
3149
|
+
else if (a[key] > b[key]) {
|
|
3150
|
+
return descending ? -1 : 1;
|
|
3151
|
+
}
|
|
3152
|
+
return 0;
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3155
|
+
var ReactTable = function (_a) {
|
|
3156
|
+
var columns = _a.columns, data = _a.data, onRowClickCallback = _a.onRowClickCallback, sort = _a.sort, _b = _a.darkMode, darkMode = _b === void 0 ? false : _b, _c = _a.multiSelect, multiSelect = _c === void 0 ? false : _c;
|
|
3157
|
+
var _d = m([]), listColumns = _d[0], setListColumns = _d[1];
|
|
3158
|
+
var _e = m(), sortColumn = _e[0], setSortColumn = _e[1];
|
|
3159
|
+
var _f = m([]), items = _f[0], setItems = _f[1];
|
|
3160
|
+
var _g = m(function () { return new Set(); }), selectedRows = _g[0], setSelectedRows = _g[1];
|
|
3161
|
+
// Columns ---
|
|
3162
|
+
y(function () {
|
|
3163
|
+
setListColumns(__spreadArray(__spreadArray([], multiSelect ? [SelectColumn] : [], true), columns.map(function (column) { return ({
|
|
3164
|
+
key: column,
|
|
3165
|
+
name: column,
|
|
3166
|
+
resizable: true,
|
|
3167
|
+
sortable: true,
|
|
3168
|
+
minWidth: 80,
|
|
3169
|
+
}); }), true));
|
|
3170
|
+
}, [columns, multiSelect]);
|
|
3171
|
+
var onSortColumnsChange = A$1(function (sortColumns) {
|
|
3172
|
+
var futureSortColumn = sortColumns.slice(-1)[0];
|
|
3173
|
+
var sorted = futureSortColumn !== undefined;
|
|
3174
|
+
var isSortedDescending = (futureSortColumn === null || futureSortColumn === void 0 ? void 0 : futureSortColumn.direction) === "DESC";
|
|
3175
|
+
setSortColumn(futureSortColumn);
|
|
3176
|
+
setItems(copyAndSort(items, sorted ? futureSortColumn.columnKey : "key", sorted ? isSortedDescending : false));
|
|
3177
|
+
}, [items]);
|
|
3178
|
+
var rowKeyGetter = A$1(function (row) {
|
|
3179
|
+
return row.key;
|
|
3180
|
+
}, []);
|
|
3181
|
+
var onSelectedRowsChange = A$1(function (selectedRows) {
|
|
3182
|
+
setSelectedRows(selectedRows);
|
|
3183
|
+
onRowClickCallback(items.filter(function (row) { return selectedRows.has(rowKeyGetter(row)); }));
|
|
3184
|
+
}, [items, onRowClickCallback, rowKeyGetter]);
|
|
3185
|
+
var onRowClick = A$1(function (row, column) {
|
|
3186
|
+
onRowClickCallback(items.filter(function (item) { return rowKeyGetter(item) === rowKeyGetter(row); }));
|
|
3187
|
+
}, [items, onRowClickCallback, rowKeyGetter]);
|
|
3188
|
+
// Rows ---
|
|
3189
|
+
y(function () {
|
|
3190
|
+
var items = data.map(function (row, index) {
|
|
3191
|
+
var retVal = {
|
|
3192
|
+
key: index
|
|
3193
|
+
};
|
|
3194
|
+
columns.forEach(function (column, index) {
|
|
3195
|
+
retVal[column] = row[index];
|
|
3196
|
+
});
|
|
3197
|
+
return retVal;
|
|
3198
|
+
});
|
|
3199
|
+
if (sort === null || sort === void 0 ? void 0 : sort.attribute) {
|
|
3200
|
+
items = copyAndSort(items, sort.attribute, sort.descending);
|
|
3201
|
+
}
|
|
3202
|
+
setItems(items);
|
|
3203
|
+
}, [columns, data, sort]);
|
|
3204
|
+
return e$1(DataGrid$1, { columns: listColumns, headerRowHeight: 24, rows: items, rowKeyGetter: rowKeyGetter, rowHeight: 20, className: darkMode ? "rdg-dark" : "rdg-light", sortColumns: sortColumn ? [sortColumn] : [], onSortColumnsChange: onSortColumnsChange, selectedRows: selectedRows, onSelectedRowsChange: multiSelect ? onSelectedRowsChange : undefined, onRowClick: multiSelect ? undefined : onRowClick, "aria-describedby": "", "aria-label": "", "aria-labelledby": "", style: { height: "100%" } });
|
|
3205
|
+
};
|
|
3206
|
+
var Table = /** @class */ (function (_super) {
|
|
3207
|
+
__extends(Table, _super);
|
|
3208
|
+
function Table() {
|
|
3209
|
+
return _super.call(this) || this;
|
|
3210
|
+
}
|
|
3211
|
+
Table.prototype.renderTable = function () {
|
|
3212
|
+
var _this = this;
|
|
3213
|
+
return e$1(ReactTable, { columns: this.columns(), data: this.data(), darkMode: this.darkMode(), onRowClickCallback: function (row, column) {
|
|
3214
|
+
var _a;
|
|
3215
|
+
if (column === void 0) { column = ""; }
|
|
3216
|
+
if (_this._prevRow && JSON.stringify(_this._prevRow) !== JSON.stringify(row)) {
|
|
3217
|
+
_this.click(_this._prevRow, (_a = _this._prevColumn) !== null && _a !== void 0 ? _a : "", false);
|
|
3218
|
+
}
|
|
3219
|
+
if (row) {
|
|
3220
|
+
_this.click(row, column, true);
|
|
3221
|
+
}
|
|
3222
|
+
_this._prevRow = row;
|
|
3223
|
+
_this._prevColumn = column;
|
|
3224
|
+
} });
|
|
3225
|
+
};
|
|
3226
|
+
Table.prototype.enter = function (domNode, element) {
|
|
3227
|
+
_super.prototype.enter.call(this, domNode, element);
|
|
3228
|
+
this._div = element
|
|
3229
|
+
.append("div");
|
|
3230
|
+
};
|
|
3231
|
+
Table.prototype.update = function (domNode, element) {
|
|
3232
|
+
_super.prototype.update.call(this, domNode, element);
|
|
3233
|
+
this._div.style("width", this.width() + "px");
|
|
3234
|
+
this._div.style("height", this.height() + "px");
|
|
3235
|
+
B(this.renderTable(), this._div.node());
|
|
3236
|
+
};
|
|
3237
|
+
Table.prototype.exit = function (domNode, element) {
|
|
3238
|
+
un(this._div.node());
|
|
3239
|
+
this._div.remove();
|
|
3240
|
+
_super.prototype.exit.call(this, domNode, element);
|
|
3241
|
+
};
|
|
3242
|
+
// Events ---
|
|
3243
|
+
Table.prototype.click = function (row, col, sel) {
|
|
3244
|
+
};
|
|
3245
|
+
__decorate([
|
|
3246
|
+
common.publish(false, "boolean", "Dark Mode"),
|
|
3247
|
+
__metadata("design:type", Function)
|
|
3248
|
+
], Table.prototype, "darkMode", void 0);
|
|
3249
|
+
__decorate([
|
|
3250
|
+
common.publish(false, "boolean", "Multiple Selection"),
|
|
3251
|
+
__metadata("design:type", Function)
|
|
3252
|
+
], Table.prototype, "multiSelect", void 0);
|
|
3253
|
+
return Table;
|
|
3254
|
+
}(common.HTMLWidget));
|
|
3255
|
+
Table.prototype._class += " dgrid2_Table";
|
|
3256
|
+
|
|
3257
|
+
exports.BUILD_VERSION = BUILD_VERSION;
|
|
3258
|
+
exports.PKG_NAME = PKG_NAME;
|
|
3259
|
+
exports.PKG_VERSION = PKG_VERSION;
|
|
3260
|
+
exports.Table = Table;
|
|
3261
|
+
|
|
3262
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3263
|
+
|
|
3264
|
+
}));
|
|
3265
|
+
//# sourceMappingURL=index.js.map
|