Comparing version 0.3.1 to 0.3.2
@@ -980,16 +980,23 @@ import * as c from "react"; | ||
function Sr(e) { | ||
const { className: t, data: r, children: n, caption: i, defaultLayout: o, rowAttributes: s, ...a } = e, u = dt({ rowAttributes: s, defaultLayout: o, ...e }), f = c.useMemo( | ||
() => Q(mr(u.state.currentLayout || { style: {}, columns: [] })), | ||
[u.state.currentLayout] | ||
const { | ||
"data-testid": t, | ||
className: r, | ||
data: n, | ||
children: i, | ||
caption: o, | ||
...s | ||
} = e, a = dt(e), u = c.useMemo( | ||
() => Q(mr(a.state.currentLayout || { style: {}, columns: [] })), | ||
[a.state.currentLayout] | ||
); | ||
return /* @__PURE__ */ c.createElement(st, { value: u }, i && i, /* @__PURE__ */ c.createElement( | ||
return /* @__PURE__ */ c.createElement(st, { value: a }, o && o, /* @__PURE__ */ c.createElement( | ||
"div", | ||
{ | ||
role: "table", | ||
className: D("gridley", f, t, u.state.layoutId), | ||
...a | ||
"data-testid": t, | ||
className: D("gridley", u, r, a.state.layoutId) | ||
}, | ||
/* @__PURE__ */ c.createElement(yr, null), | ||
/* @__PURE__ */ c.createElement(fr, { data: r }), | ||
n | ||
/* @__PURE__ */ c.createElement(fr, { data: n }), | ||
i | ||
)); | ||
@@ -996,0 +1003,0 @@ } |
@@ -1,2 +0,2 @@ | ||
(function(f,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("react"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react","@emotion/css"],A):(f=typeof globalThis<"u"?globalThis:f||self,A(f.Gridley={},f.react,f.emotionCss))})(this,function(f,A,_){"use strict";function Ge(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=Ge(A);var se=Symbol.for("immer-nothing"),ce=Symbol.for("immer-draftable"),y=Symbol.for("immer-state"),He=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function d(e,...t){if(process.env.NODE_ENV!=="production"){const r=He[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var E=Object.getPrototypeOf;function C(e){return!!e&&!!e[y]}function b(e){var t;return e?ue(e)||Array.isArray(e)||!!e[ce]||!!((t=e.constructor)!=null&&t[ce])||R(e)||x(e):!1}var Ue=Object.prototype.constructor.toString();function ue(e){if(!e||typeof e!="object")return!1;const t=E(e);if(t===null)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Ue}function T(e,t){F(e)===0?Object.entries(e).forEach(([r,n])=>{t(r,n,e)}):e.forEach((r,n)=>t(n,r,e))}function F(e){const t=e[y];return t?t.type_:Array.isArray(e)?1:R(e)?2:x(e)?3:0}function K(e,t){return F(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function fe(e,t,r){const n=F(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function ke(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function R(e){return e instanceof Map}function x(e){return e instanceof Set}function g(e){return e.copy_||e.base_}function Y(e,t){if(R(e))return new Map(e);if(x(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ue(e))return E(e)?{...e}:Object.assign(Object.create(null),e);const r=Object.getOwnPropertyDescriptors(e);delete r[y];let n=Reflect.ownKeys(r);for(let i=0;i<n.length;i++){const o=n[i],a=r[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(E(e),r)}function W(e,t=!1){return L(e)||C(e)||!b(e)||(F(e)>1&&(e.set=e.add=e.clear=e.delete=Be),Object.freeze(e),t&&T(e,(r,n)=>W(n,!0))),e}function Be(){d(2)}function L(e){return Object.isFrozen(e)}var Ke={};function w(e){const t=Ke[e];return t||d(0,e),t}var M;function le(){return M}function Ye(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function de(e,t){t&&(w("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function X(e){J(e),e.drafts_.forEach(We),e.drafts_=null}function J(e){e===M&&(M=e.parent_)}function ye(e){return M=Ye(M,e)}function We(e){const t=e[y];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function pe(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[y].modified_&&(X(t),d(4)),b(e)&&(e=G(t,e),t.parent_||H(t,e)),t.patches_&&w("Patches").generateReplacementPatches_(r[y].base_,e,t.patches_,t.inversePatches_)):e=G(t,r,[]),X(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==se?e:void 0}function G(e,t,r){if(L(t))return t;const n=t[y];if(!n)return T(t,(i,o)=>he(e,n,t,i,o,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return H(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let o=i,a=!1;n.type_===3&&(o=new Set(i),i.clear(),a=!0),T(o,(s,u)=>he(e,n,i,s,u,r,a)),H(e,i,!1),r&&e.patches_&&w("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function he(e,t,r,n,i,o,a){if(process.env.NODE_ENV!=="production"&&i===r&&d(5),C(i)){const s=o&&t&&t.type_!==3&&!K(t.assigned_,n)?o.concat(n):void 0,u=G(e,i,s);if(fe(r,n,u),C(u))e.canAutoFreeze_=!1;else return}else a&&r.add(i);if(b(i)&&!L(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;G(e,i),(!t||!t.scope_.parent_)&&H(e,i)}}function H(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&W(t,r)}function Xe(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:le(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,o=q;r&&(i=[n],o=N);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return n.draft_=s,n.revoke_=a,s}var q={get(e,t){if(t===y)return e;const r=g(e);if(!K(r,t))return Je(e,r,t);const n=r[t];return e.finalized_||!b(n)?n:n===V(e.base_,t)?(Z(e),e.copy_[t]=ee(n,e)):n},has(e,t){return t in g(e)},ownKeys(e){return Reflect.ownKeys(g(e))},set(e,t,r){const n=me(g(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=V(g(e),t),o=i==null?void 0:i[y];if(o&&o.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(ke(r,i)&&(r!==void 0||K(e.base_,t)))return!0;Z(e),Q(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return V(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Z(e),Q(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=g(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){d(11)},getPrototypeOf(e){return E(e.base_)},setPrototypeOf(){d(12)}},N={};T(q,(e,t)=>{N[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),N.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&d(13),N.set.call(this,e,t,void 0)},N.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&d(14),q.set.call(this,e[0],t,r,e[0])};function V(e,t){const r=e[y];return(r?g(r):e)[t]}function Je(e,t,r){var i;const n=me(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function me(e,t){if(!(t in e))return;let r=E(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=E(r)}}function Q(e){e.modified_||(e.modified_=!0,e.parent_&&Q(e.parent_))}function Z(e){e.copy_||(e.copy_=Y(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var qe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const o=r;r=t;const a=this;return function(u=o,...l){return a.produce(u,h=>r.call(this,h,...l))}}typeof r!="function"&&d(6),n!==void 0&&typeof n!="function"&&d(7);let i;if(b(t)){const o=ye(this),a=ee(t,void 0);let s=!0;try{i=r(a),s=!1}finally{s?X(o):J(o)}return de(o,n),pe(i,o)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===se&&(i=void 0),this.autoFreeze_&&W(i,!0),n){const o=[],a=[];w("Patches").generateReplacementPatches_(t,i,o,a),n(o,a)}return i}else d(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(a,...s)=>this.produceWithPatches(a,u=>t(u,...s));let n,i;return[this.produce(t,r,(a,s)=>{n=a,i=s}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){b(e)||d(8),C(e)&&(e=Ve(e));const t=ye(this),r=ee(e,void 0);return r[y].isManual_=!0,J(t),r}finishDraft(e,t){const r=e&&e[y];(!r||!r.isManual_)&&d(9);const{scope_:n}=r;return de(n,t),pe(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=w("Patches").applyPatches_;return C(e)?n(e,t):this.produce(e,i=>n(i,t))}};function ee(e,t){const r=R(e)?w("MapSet").proxyMap_(e,t):x(e)?w("MapSet").proxySet_(e,t):Xe(e,t);return(t?t.scope_:le()).drafts_.push(r),r}function Ve(e){return C(e)||d(10,e),_e(e)}function _e(e){if(!b(e)||L(e))return e;const t=e[y];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Y(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Y(e,!0);return T(r,(n,i)=>{fe(r,n,_e(i))}),t&&(t.finalized_=!1),r}var p=new qe,Qe=p.produce;p.produceWithPatches.bind(p),p.setAutoFreeze.bind(p),p.setUseStrictShallowCopy.bind(p),p.applyPatches.bind(p),p.createDraft.bind(p),p.finishDraft.bind(p);var U=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ze=function(t){return et(t)&&!tt(t)};function et(e){return!!e&&typeof e=="object"}function tt(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||it(e)}var rt=typeof Symbol=="function"&&Symbol.for,nt=rt?Symbol.for("react.element"):60103;function it(e){return e.$$typeof===nt}function ot(e){return Array.isArray(e)?[]:{}}function D(e,t){return t.clone!==!1&&t.isMergeableObject(e)?P(ot(e),e,t):e}function at(e,t,r){return e.concat(t).map(function(n){return D(n,r)})}function st(e,t){if(!t.customMerge)return P;var r=t.customMerge(e);return typeof r=="function"?r:P}function ct(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function be(e){return Object.keys(e).concat(ct(e))}function ge(e,t){try{return t in e}catch{return!1}}function ut(e,t){return ge(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function ft(e,t,r){var n={};return r.isMergeableObject(e)&&be(e).forEach(function(i){n[i]=D(e[i],r)}),be(t).forEach(function(i){ut(e,i)||(ge(e,i)&&r.isMergeableObject(t[i])?n[i]=st(i,r)(e[i],t[i],r):n[i]=D(t[i],r))}),n}function P(e,t,r){r=r||{},r.arrayMerge=r.arrayMerge||at,r.isMergeableObject=r.isMergeableObject||Ze,r.cloneUnlessOtherwiseSpecified=D;var n=Array.isArray(t),i=Array.isArray(e),o=n===i;return o?n?r.arrayMerge(e,t,r):ft(e,t,r):D(t,r)}P.all=function(t,r){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(n,i){return P(n,i,r)},{})};var lt=P,dt=lt;const we={around:"space-around",between:"space-between",center:"center",end:"flex-end",start:"flex-start",stretch:"stretch"},I=c.createContext(null);I.displayName="GridContext";const Se=I.Provider,m=(e,t="5px")=>e===!1?"0":e===!0||e==null?t:typeof e=="string"?e:`${e}px`;function Oe(e,t=100){let r;return()=>{clearTimeout(r),r=window.setTimeout(e,t)}}function Ee(e,t,r){const n=c.useCallback(()=>r||Object.keys(e).find(a=>{var h;const{min:s,max:u}=e[a],l=(h=window.matchMedia)==null?void 0:h.call(window,`(min-width: ${m(s)}) and (max-width: ${m(u)})`);return l==null?void 0:l.matches}),[e,r]),[i,o]=c.useState("default");return c.useEffect(()=>{o(n()||"default")},[e,n]),c.useEffect(()=>{if(r)return;const a=Oe(()=>{const s=n();o(s||"default")});return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[n,r]),c.useMemo(()=>{let a=t;return r?[r,e[r]]:i==="default"?(a||(a=Object.keys(e)[0]),[t||"unknown",e[a||"default"]]):[i,e[i]]},[r,t,i,e])}function yt(){const e=z();return e?e.currentLayout:null}const Ce=e=>{const t=z();return t?e==null||e===t.layoutId:!1};function z(){const e=c.useContext(I);return(e==null?void 0:e.state)||null}function te(){const e=c.useContext(I);return(e==null?void 0:e.dispatch)||null}const pt=(e,t,r)=>t,ht=Qe((e,t)=>{switch(t.type){case"ADD_LAYOUT":{const{layout:r}=t;e.layouts[r.id]=dt(e.layouts[r.id]||{},r,{arrayMerge:pt});return}case"SET_RENDERERS":{e.renderers=t.renderers;return}}});function mt(e){const[t,r]=c.useReducer(ht,{layouts:{},renderers:{},props:e}),[n,i]=Ee(t.layouts,e.defaultLayout,e.forceLayout);return c.useMemo(()=>({state:{...t,layoutId:n,currentLayout:i},dispatch:r}),[t,r,n,i])}var _t="Expected a function",Pe="__lodash_hash_undefined__",ve=1/0,bt="[object Function]",gt="[object GeneratorFunction]",wt="[object Symbol]",St=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ot=/^\w*$/,Et=/^\./,Ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,vt=/\\(\\)?/g,jt=/^\[object .+?Constructor\]$/,At=typeof U=="object"&&U&&U.Object===Object&&U,Tt=typeof self=="object"&&self&&self.Object===Object&&self,re=At||Tt||Function("return this")();function Mt(e,t){return e==null?void 0:e[t]}function Nt(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Dt=Array.prototype,It=Function.prototype,je=Object.prototype,ne=re["__core-js_shared__"],Ae=function(){var e=/[^.]+$/.exec(ne&&ne.keys&&ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Te=It.toString,ie=je.hasOwnProperty,Me=je.toString,zt=RegExp("^"+Te.call(ie).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ne=re.Symbol,$t=Dt.splice,Ft=ze(re,"Map"),$=ze(Object,"create"),De=Ne?Ne.prototype:void 0,Ie=De?De.toString:void 0;function S(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Rt(){this.__data__=$?$(null):{}}function xt(e){return this.has(e)&&delete this.__data__[e]}function Lt(e){var t=this.__data__;if($){var r=t[e];return r===Pe?void 0:r}return ie.call(t,e)?t[e]:void 0}function Gt(e){var t=this.__data__;return $?t[e]!==void 0:ie.call(t,e)}function Ht(e,t){var r=this.__data__;return r[e]=$&&t===void 0?Pe:t,this}S.prototype.clear=Rt,S.prototype.delete=xt,S.prototype.get=Lt,S.prototype.has=Gt,S.prototype.set=Ht;function v(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ut(){this.__data__=[]}function kt(e){var t=this.__data__,r=k(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():$t.call(t,r,1),!0}function Bt(e){var t=this.__data__,r=k(t,e);return r<0?void 0:t[r][1]}function Kt(e){return k(this.__data__,e)>-1}function Yt(e,t){var r=this.__data__,n=k(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}v.prototype.clear=Ut,v.prototype.delete=kt,v.prototype.get=Bt,v.prototype.has=Kt,v.prototype.set=Yt;function O(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Wt(){this.__data__={hash:new S,map:new(Ft||v),string:new S}}function Xt(e){return B(this,e).delete(e)}function Jt(e){return B(this,e).get(e)}function qt(e){return B(this,e).has(e)}function Vt(e,t){return B(this,e).set(e,t),this}O.prototype.clear=Wt,O.prototype.delete=Xt,O.prototype.get=Jt,O.prototype.has=qt,O.prototype.set=Vt;function k(e,t){for(var r=e.length;r--;)if(cr(e[r][0],t))return r;return-1}function Qt(e,t){t=rr(t,e)?[t]:tr(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[ar(t[r++])];return r&&r==n?e:void 0}function Zt(e){if(!Fe(e)||ir(e))return!1;var t=ur(e)||Nt(e)?zt:jt;return t.test(sr(e))}function er(e){if(typeof e=="string")return e;if(ae(e))return Ie?Ie.call(e):"";var t=e+"";return t=="0"&&1/e==-ve?"-0":t}function tr(e){return $e(e)?e:or(e)}function B(e,t){var r=e.__data__;return nr(t)?r[typeof t=="string"?"string":"hash"]:r.map}function ze(e,t){var r=Mt(e,t);return Zt(r)?r:void 0}function rr(e,t){if($e(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ae(e)?!0:Ot.test(e)||!St.test(e)||t!=null&&e in Object(t)}function nr(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ir(e){return!!Ae&&Ae in e}var or=oe(function(e){e=lr(e);var t=[];return Et.test(e)&&t.push(""),e.replace(Ct,function(r,n,i,o){t.push(i?o.replace(vt,"$1"):n||r)}),t});function ar(e){if(typeof e=="string"||ae(e))return e;var t=e+"";return t=="0"&&1/e==-ve?"-0":t}function sr(e){if(e!=null){try{return Te.call(e)}catch{}try{return e+""}catch{}}return""}function oe(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(_t);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a),a};return r.cache=new(oe.Cache||O),r}oe.Cache=O;function cr(e,t){return e===t||e!==e&&t!==t}var $e=Array.isArray;function ur(e){var t=Fe(e)?Me.call(e):"";return t==bt||t==gt}function Fe(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function fr(e){return!!e&&typeof e=="object"}function ae(e){return typeof e=="symbol"||fr(e)&&Me.call(e)==wt}function lr(e){return e==null?"":er(e)}function dr(e,t,r){var n=e==null?void 0:Qt(e,t);return n===void 0?r:n}var yr=dr;function Re({data:e}){const t=z(),r=c.useMemo(()=>{if(!t||!t.currentLayout)return[];const{renderers:n,currentLayout:i}=t,o=i.columns||[];return e.map((a,s)=>{let u={};return t.props.rowAttributes&&(typeof t.props.rowAttributes=="function"?u=t.props.rowAttributes(a,i):u=t.props.rowAttributes),c.createElement("div",{role:"row",key:s,...u,className:_.cx("grid-row",u.className)},o.map(l=>{const h=n[l.id];if(!h)throw new Error(`Missing renderer for column ${l.id}`);const{body:Le,dataPath:jr}=h;return Le?c.cloneElement(Le,{id:l.id,key:l.id,data:e,rowData:a,role:"cell",layout:i,column:l,value:yr(a,jr||l.id)}):c.createElement("span",null,"missing column ",l.id)}))})},[t,e]);return c.createElement("div",{className:"grid-body"},r)}function pr(e){if(e)return _.css({position:"sticky",boxSizing:"border-box",background:e.background,top:`calc(((var(--row-offset) - 1) * ${m(e.rowHeight)}) + ${m(e.top)})`,minHeight:m(e.rowHeight)})}function hr(e){return _.css({"> *":{zIndex:"calc(var(--last-row-offset) - var(--row-offset) + 2)",borderBottomColor:e==null?void 0:e.headerSeparator.color,borderBottomStyle:e==null?void 0:e.headerSeparator.style,borderBottomWidth:`calc(${m(e==null?void 0:e.headerSeparator.width)} * var(--is-last-row))`}})}const mr=({id:e})=>c.createElement("span",null,"Missing Renderer for column ",e),xe=()=>{var i;const e=z(),t=c.useMemo(()=>{var a;if(!(e!=null&&e.currentLayout))return[];const{renderers:o}=e;return(((a=e.currentLayout)==null?void 0:a.columns)||[]).map(s=>{var l;const u=(l=o[s.id])==null?void 0:l.header;if(!u)throw new Error(`Missing Renderer for header column ${s.id}`);return u?c.cloneElement(u,{role:"columnheader",key:s.id,id:s.id,column:s}):c.createElement(mr,{id:s.id,key:s.id})})},[e]),r=c.useMemo(()=>hr(e==null?void 0:e.currentLayout),[e==null?void 0:e.currentLayout]),n=c.useMemo(()=>{var o;return pr((o=e==null?void 0:e.currentLayout)==null?void 0:o.stickyHeader)},[(i=e==null?void 0:e.currentLayout)==null?void 0:i.stickyHeader]);return c.createElement("div",{role:"rowheader",className:_.cx("grid-header",r,n)},t)},_r=e=>{if(e.row!==1)return"";let t="";return e.width?t=m(e.width):e.min||e.max?t=`minmax(${m(e.min||"auto")}, ${m(e.max||"auto")})`:t="auto",e.colSpan&&(t=Array(e.colSpan).fill(t).join(" ")),t},j={wrappers:"> .grid-header, > .grid-body, .grid-body > .grid-row",nonEmpty:"*:not(:empty)",header:".grid-header",body:".grid-body",row:".grid-row"},br=e=>{const t=m(e.cellPadding),r={};for(const i of e.columns)r[`> [data-column-id="${i.id}"]`]={"--row-offset":i.row,"--is-last-row":e.lastRowOffset===i.row+(i.rowSpan-1)?1:0,gridColumn:`auto /span ${i.colSpan||1}`,gridRow:`auto /span ${i.rowSpan||1}`,justifyContent:we[i.justify||"start"]};return{display:"grid",gridTemplateColumns:e.columns.map(_r).join(" "),"--last-row-offset":e.lastRowOffset,[`${j.wrappers}`]:{display:"contents",">[data-column-id]":{display:"flex",alignItems:"center"},[`>${j.nonEmpty}`]:e.cellPadding===!1?void 0:{padding:`${t} calc(${t} / 2)`}},[`> ${j.header}`]:r,[`> ${j.body}`]:{[` > ${j.row}`]:{"&:nth-of-type(2n + 1) > *":e.stripe===!1?void 0:{backgroundColor:typeof e.stripe=="string"?e.stripe:"#e8e8e8"},...r}},...e.style}};function gr(e){const{className:t,data:r,children:n,caption:i,defaultLayout:o,rowAttributes:a,...s}=e,u=mt({rowAttributes:a,defaultLayout:o,...e}),l=c.useMemo(()=>_.css(br(u.state.currentLayout||{style:{},columns:[]})),[u.state.currentLayout]);return c.createElement(Se,{value:u},i&&i,c.createElement("div",{role:"table",className:_.cx("gridley",l,t,u.state.layoutId),...s},c.createElement(xe,null),c.createElement(Re,{data:r}),n))}const wr=({className:e,children:t,layout:r})=>Ce(r)?c.createElement("div",{className:_.cx("caption",e)},t):null,Sr=({id:e,column:t,className:r,children:n,render:i,hidden:o,Component:a,role:s="cell",...u})=>{if(o)return null;let l="";const h=u;return i?l=i(h.value,h.rowData,h.allData,{...u}):a?l=c.createElement(a,{value:h.value,...u}):l=n||h.value,c.createElement("div",{role:s,"data-column-id":t==null?void 0:t.id,className:_.cx("grid-cell",e,r)},l)},Or=()=>null;function Er({children:e}){const t=te();return c.useEffect(()=>{if(!t)return;const r={};c.Children.forEach(e,n=>{if(c.isValidElement(n)){const i=n.props;r[i.id]=i}}),t({type:"SET_RENDERERS",renderers:r})},[t,e]),null}const Cr={lastRowOffset:1,headerSeparator:{width:"1px",color:"black",style:"solid"}},Pr={rowSpan:1,row:1};function vr(e){const t=te();return c.useEffect(()=>{var a;if(!t)return;const{children:r,...n}=e,i=((a=c.Children.map(r,s=>s&&c.isValidElement(s)?{...Pr,...s.props}:!1))==null?void 0:a.filter(Boolean))||[],o={...Cr,...n,columns:i};o.lastRowOffset=o.columns.reduce((s,u)=>u.row>s?u.row:s,0),t({type:"ADD_LAYOUT",layout:o})},[t,e]),null}f.Body=Re,f.Caption=wr,f.Cell=Sr,f.Column=Or,f.Columns=Er,f.GridContextProvider=Se,f.Gridley=gr,f.Header=xe,f.JUSTIFY_CONTENT=we,f.Layout=vr,f.Selectors=j,f.debounce=Oe,f.gridContext=I,f.toPX=m,f.useCurrentLayout=yt,f.useCurrentLayoutMatch=Ee,f.useGridContextDispatch=te,f.useGridContextState=z,f.useIsLayoutActive=Ce,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}); | ||
(function(f,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("react"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react","@emotion/css"],A):(f=typeof globalThis<"u"?globalThis:f||self,A(f.Gridley={},f.react,f.emotionCss))})(this,function(f,A,_){"use strict";function Ge(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=Ge(A);var se=Symbol.for("immer-nothing"),ce=Symbol.for("immer-draftable"),y=Symbol.for("immer-state"),He=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function d(e,...t){if(process.env.NODE_ENV!=="production"){const r=He[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var E=Object.getPrototypeOf;function C(e){return!!e&&!!e[y]}function b(e){var t;return e?ue(e)||Array.isArray(e)||!!e[ce]||!!((t=e.constructor)!=null&&t[ce])||R(e)||x(e):!1}var Ue=Object.prototype.constructor.toString();function ue(e){if(!e||typeof e!="object")return!1;const t=E(e);if(t===null)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Ue}function T(e,t){F(e)===0?Object.entries(e).forEach(([r,n])=>{t(r,n,e)}):e.forEach((r,n)=>t(n,r,e))}function F(e){const t=e[y];return t?t.type_:Array.isArray(e)?1:R(e)?2:x(e)?3:0}function K(e,t){return F(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function fe(e,t,r){const n=F(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function ke(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function R(e){return e instanceof Map}function x(e){return e instanceof Set}function g(e){return e.copy_||e.base_}function Y(e,t){if(R(e))return new Map(e);if(x(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ue(e))return E(e)?{...e}:Object.assign(Object.create(null),e);const r=Object.getOwnPropertyDescriptors(e);delete r[y];let n=Reflect.ownKeys(r);for(let i=0;i<n.length;i++){const o=n[i],a=r[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(E(e),r)}function W(e,t=!1){return L(e)||C(e)||!b(e)||(F(e)>1&&(e.set=e.add=e.clear=e.delete=Be),Object.freeze(e),t&&T(e,(r,n)=>W(n,!0))),e}function Be(){d(2)}function L(e){return Object.isFrozen(e)}var Ke={};function w(e){const t=Ke[e];return t||d(0,e),t}var M;function le(){return M}function Ye(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function de(e,t){t&&(w("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function X(e){J(e),e.drafts_.forEach(We),e.drafts_=null}function J(e){e===M&&(M=e.parent_)}function ye(e){return M=Ye(M,e)}function We(e){const t=e[y];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function pe(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[y].modified_&&(X(t),d(4)),b(e)&&(e=G(t,e),t.parent_||H(t,e)),t.patches_&&w("Patches").generateReplacementPatches_(r[y].base_,e,t.patches_,t.inversePatches_)):e=G(t,r,[]),X(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==se?e:void 0}function G(e,t,r){if(L(t))return t;const n=t[y];if(!n)return T(t,(i,o)=>he(e,n,t,i,o,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return H(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let o=i,a=!1;n.type_===3&&(o=new Set(i),i.clear(),a=!0),T(o,(s,u)=>he(e,n,i,s,u,r,a)),H(e,i,!1),r&&e.patches_&&w("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function he(e,t,r,n,i,o,a){if(process.env.NODE_ENV!=="production"&&i===r&&d(5),C(i)){const s=o&&t&&t.type_!==3&&!K(t.assigned_,n)?o.concat(n):void 0,u=G(e,i,s);if(fe(r,n,u),C(u))e.canAutoFreeze_=!1;else return}else a&&r.add(i);if(b(i)&&!L(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;G(e,i),(!t||!t.scope_.parent_)&&H(e,i)}}function H(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&W(t,r)}function Xe(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:le(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,o=q;r&&(i=[n],o=N);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return n.draft_=s,n.revoke_=a,s}var q={get(e,t){if(t===y)return e;const r=g(e);if(!K(r,t))return Je(e,r,t);const n=r[t];return e.finalized_||!b(n)?n:n===V(e.base_,t)?(Z(e),e.copy_[t]=ee(n,e)):n},has(e,t){return t in g(e)},ownKeys(e){return Reflect.ownKeys(g(e))},set(e,t,r){const n=me(g(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=V(g(e),t),o=i==null?void 0:i[y];if(o&&o.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(ke(r,i)&&(r!==void 0||K(e.base_,t)))return!0;Z(e),Q(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return V(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Z(e),Q(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=g(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){d(11)},getPrototypeOf(e){return E(e.base_)},setPrototypeOf(){d(12)}},N={};T(q,(e,t)=>{N[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),N.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&d(13),N.set.call(this,e,t,void 0)},N.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&d(14),q.set.call(this,e[0],t,r,e[0])};function V(e,t){const r=e[y];return(r?g(r):e)[t]}function Je(e,t,r){var i;const n=me(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function me(e,t){if(!(t in e))return;let r=E(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=E(r)}}function Q(e){e.modified_||(e.modified_=!0,e.parent_&&Q(e.parent_))}function Z(e){e.copy_||(e.copy_=Y(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var qe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const o=r;r=t;const a=this;return function(u=o,...l){return a.produce(u,h=>r.call(this,h,...l))}}typeof r!="function"&&d(6),n!==void 0&&typeof n!="function"&&d(7);let i;if(b(t)){const o=ye(this),a=ee(t,void 0);let s=!0;try{i=r(a),s=!1}finally{s?X(o):J(o)}return de(o,n),pe(i,o)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===se&&(i=void 0),this.autoFreeze_&&W(i,!0),n){const o=[],a=[];w("Patches").generateReplacementPatches_(t,i,o,a),n(o,a)}return i}else d(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(a,...s)=>this.produceWithPatches(a,u=>t(u,...s));let n,i;return[this.produce(t,r,(a,s)=>{n=a,i=s}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){b(e)||d(8),C(e)&&(e=Ve(e));const t=ye(this),r=ee(e,void 0);return r[y].isManual_=!0,J(t),r}finishDraft(e,t){const r=e&&e[y];(!r||!r.isManual_)&&d(9);const{scope_:n}=r;return de(n,t),pe(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=w("Patches").applyPatches_;return C(e)?n(e,t):this.produce(e,i=>n(i,t))}};function ee(e,t){const r=R(e)?w("MapSet").proxyMap_(e,t):x(e)?w("MapSet").proxySet_(e,t):Xe(e,t);return(t?t.scope_:le()).drafts_.push(r),r}function Ve(e){return C(e)||d(10,e),_e(e)}function _e(e){if(!b(e)||L(e))return e;const t=e[y];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Y(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Y(e,!0);return T(r,(n,i)=>{fe(r,n,_e(i))}),t&&(t.finalized_=!1),r}var p=new qe,Qe=p.produce;p.produceWithPatches.bind(p),p.setAutoFreeze.bind(p),p.setUseStrictShallowCopy.bind(p),p.applyPatches.bind(p),p.createDraft.bind(p),p.finishDraft.bind(p);var U=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ze=function(t){return et(t)&&!tt(t)};function et(e){return!!e&&typeof e=="object"}function tt(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||it(e)}var rt=typeof Symbol=="function"&&Symbol.for,nt=rt?Symbol.for("react.element"):60103;function it(e){return e.$$typeof===nt}function ot(e){return Array.isArray(e)?[]:{}}function D(e,t){return t.clone!==!1&&t.isMergeableObject(e)?P(ot(e),e,t):e}function at(e,t,r){return e.concat(t).map(function(n){return D(n,r)})}function st(e,t){if(!t.customMerge)return P;var r=t.customMerge(e);return typeof r=="function"?r:P}function ct(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function be(e){return Object.keys(e).concat(ct(e))}function ge(e,t){try{return t in e}catch{return!1}}function ut(e,t){return ge(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function ft(e,t,r){var n={};return r.isMergeableObject(e)&&be(e).forEach(function(i){n[i]=D(e[i],r)}),be(t).forEach(function(i){ut(e,i)||(ge(e,i)&&r.isMergeableObject(t[i])?n[i]=st(i,r)(e[i],t[i],r):n[i]=D(t[i],r))}),n}function P(e,t,r){r=r||{},r.arrayMerge=r.arrayMerge||at,r.isMergeableObject=r.isMergeableObject||Ze,r.cloneUnlessOtherwiseSpecified=D;var n=Array.isArray(t),i=Array.isArray(e),o=n===i;return o?n?r.arrayMerge(e,t,r):ft(e,t,r):D(t,r)}P.all=function(t,r){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(n,i){return P(n,i,r)},{})};var lt=P,dt=lt;const we={around:"space-around",between:"space-between",center:"center",end:"flex-end",start:"flex-start",stretch:"stretch"},I=c.createContext(null);I.displayName="GridContext";const Se=I.Provider,m=(e,t="5px")=>e===!1?"0":e===!0||e==null?t:typeof e=="string"?e:`${e}px`;function Oe(e,t=100){let r;return()=>{clearTimeout(r),r=window.setTimeout(e,t)}}function Ee(e,t,r){const n=c.useCallback(()=>r||Object.keys(e).find(a=>{var h;const{min:s,max:u}=e[a],l=(h=window.matchMedia)==null?void 0:h.call(window,`(min-width: ${m(s)}) and (max-width: ${m(u)})`);return l==null?void 0:l.matches}),[e,r]),[i,o]=c.useState("default");return c.useEffect(()=>{o(n()||"default")},[e,n]),c.useEffect(()=>{if(r)return;const a=Oe(()=>{const s=n();o(s||"default")});return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[n,r]),c.useMemo(()=>{let a=t;return r?[r,e[r]]:i==="default"?(a||(a=Object.keys(e)[0]),[t||"unknown",e[a||"default"]]):[i,e[i]]},[r,t,i,e])}function yt(){const e=z();return e?e.currentLayout:null}const Ce=e=>{const t=z();return t?e==null||e===t.layoutId:!1};function z(){const e=c.useContext(I);return(e==null?void 0:e.state)||null}function te(){const e=c.useContext(I);return(e==null?void 0:e.dispatch)||null}const pt=(e,t,r)=>t,ht=Qe((e,t)=>{switch(t.type){case"ADD_LAYOUT":{const{layout:r}=t;e.layouts[r.id]=dt(e.layouts[r.id]||{},r,{arrayMerge:pt});return}case"SET_RENDERERS":{e.renderers=t.renderers;return}}});function mt(e){const[t,r]=c.useReducer(ht,{layouts:{},renderers:{},props:e}),[n,i]=Ee(t.layouts,e.defaultLayout,e.forceLayout);return c.useMemo(()=>({state:{...t,layoutId:n,currentLayout:i},dispatch:r}),[t,r,n,i])}var _t="Expected a function",Pe="__lodash_hash_undefined__",ve=1/0,bt="[object Function]",gt="[object GeneratorFunction]",wt="[object Symbol]",St=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ot=/^\w*$/,Et=/^\./,Ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,vt=/\\(\\)?/g,jt=/^\[object .+?Constructor\]$/,At=typeof U=="object"&&U&&U.Object===Object&&U,Tt=typeof self=="object"&&self&&self.Object===Object&&self,re=At||Tt||Function("return this")();function Mt(e,t){return e==null?void 0:e[t]}function Nt(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Dt=Array.prototype,It=Function.prototype,je=Object.prototype,ne=re["__core-js_shared__"],Ae=function(){var e=/[^.]+$/.exec(ne&&ne.keys&&ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Te=It.toString,ie=je.hasOwnProperty,Me=je.toString,zt=RegExp("^"+Te.call(ie).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ne=re.Symbol,$t=Dt.splice,Ft=ze(re,"Map"),$=ze(Object,"create"),De=Ne?Ne.prototype:void 0,Ie=De?De.toString:void 0;function S(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Rt(){this.__data__=$?$(null):{}}function xt(e){return this.has(e)&&delete this.__data__[e]}function Lt(e){var t=this.__data__;if($){var r=t[e];return r===Pe?void 0:r}return ie.call(t,e)?t[e]:void 0}function Gt(e){var t=this.__data__;return $?t[e]!==void 0:ie.call(t,e)}function Ht(e,t){var r=this.__data__;return r[e]=$&&t===void 0?Pe:t,this}S.prototype.clear=Rt,S.prototype.delete=xt,S.prototype.get=Lt,S.prototype.has=Gt,S.prototype.set=Ht;function v(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ut(){this.__data__=[]}function kt(e){var t=this.__data__,r=k(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():$t.call(t,r,1),!0}function Bt(e){var t=this.__data__,r=k(t,e);return r<0?void 0:t[r][1]}function Kt(e){return k(this.__data__,e)>-1}function Yt(e,t){var r=this.__data__,n=k(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}v.prototype.clear=Ut,v.prototype.delete=kt,v.prototype.get=Bt,v.prototype.has=Kt,v.prototype.set=Yt;function O(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Wt(){this.__data__={hash:new S,map:new(Ft||v),string:new S}}function Xt(e){return B(this,e).delete(e)}function Jt(e){return B(this,e).get(e)}function qt(e){return B(this,e).has(e)}function Vt(e,t){return B(this,e).set(e,t),this}O.prototype.clear=Wt,O.prototype.delete=Xt,O.prototype.get=Jt,O.prototype.has=qt,O.prototype.set=Vt;function k(e,t){for(var r=e.length;r--;)if(cr(e[r][0],t))return r;return-1}function Qt(e,t){t=rr(t,e)?[t]:tr(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[ar(t[r++])];return r&&r==n?e:void 0}function Zt(e){if(!Fe(e)||ir(e))return!1;var t=ur(e)||Nt(e)?zt:jt;return t.test(sr(e))}function er(e){if(typeof e=="string")return e;if(ae(e))return Ie?Ie.call(e):"";var t=e+"";return t=="0"&&1/e==-ve?"-0":t}function tr(e){return $e(e)?e:or(e)}function B(e,t){var r=e.__data__;return nr(t)?r[typeof t=="string"?"string":"hash"]:r.map}function ze(e,t){var r=Mt(e,t);return Zt(r)?r:void 0}function rr(e,t){if($e(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ae(e)?!0:Ot.test(e)||!St.test(e)||t!=null&&e in Object(t)}function nr(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ir(e){return!!Ae&&Ae in e}var or=oe(function(e){e=lr(e);var t=[];return Et.test(e)&&t.push(""),e.replace(Ct,function(r,n,i,o){t.push(i?o.replace(vt,"$1"):n||r)}),t});function ar(e){if(typeof e=="string"||ae(e))return e;var t=e+"";return t=="0"&&1/e==-ve?"-0":t}function sr(e){if(e!=null){try{return Te.call(e)}catch{}try{return e+""}catch{}}return""}function oe(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(_t);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a),a};return r.cache=new(oe.Cache||O),r}oe.Cache=O;function cr(e,t){return e===t||e!==e&&t!==t}var $e=Array.isArray;function ur(e){var t=Fe(e)?Me.call(e):"";return t==bt||t==gt}function Fe(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function fr(e){return!!e&&typeof e=="object"}function ae(e){return typeof e=="symbol"||fr(e)&&Me.call(e)==wt}function lr(e){return e==null?"":er(e)}function dr(e,t,r){var n=e==null?void 0:Qt(e,t);return n===void 0?r:n}var yr=dr;function Re({data:e}){const t=z(),r=c.useMemo(()=>{if(!t||!t.currentLayout)return[];const{renderers:n,currentLayout:i}=t,o=i.columns||[];return e.map((a,s)=>{let u={};return t.props.rowAttributes&&(typeof t.props.rowAttributes=="function"?u=t.props.rowAttributes(a,i):u=t.props.rowAttributes),c.createElement("div",{role:"row",key:s,...u,className:_.cx("grid-row",u.className)},o.map(l=>{const h=n[l.id];if(!h)throw new Error(`Missing renderer for column ${l.id}`);const{body:Le,dataPath:jr}=h;return Le?c.cloneElement(Le,{id:l.id,key:l.id,data:e,rowData:a,role:"cell",layout:i,column:l,value:yr(a,jr||l.id)}):c.createElement("span",null,"missing column ",l.id)}))})},[t,e]);return c.createElement("div",{className:"grid-body"},r)}function pr(e){if(e)return _.css({position:"sticky",boxSizing:"border-box",background:e.background,top:`calc(((var(--row-offset) - 1) * ${m(e.rowHeight)}) + ${m(e.top)})`,minHeight:m(e.rowHeight)})}function hr(e){return _.css({"> *":{zIndex:"calc(var(--last-row-offset) - var(--row-offset) + 2)",borderBottomColor:e==null?void 0:e.headerSeparator.color,borderBottomStyle:e==null?void 0:e.headerSeparator.style,borderBottomWidth:`calc(${m(e==null?void 0:e.headerSeparator.width)} * var(--is-last-row))`}})}const mr=({id:e})=>c.createElement("span",null,"Missing Renderer for column ",e),xe=()=>{var i;const e=z(),t=c.useMemo(()=>{var a;if(!(e!=null&&e.currentLayout))return[];const{renderers:o}=e;return(((a=e.currentLayout)==null?void 0:a.columns)||[]).map(s=>{var l;const u=(l=o[s.id])==null?void 0:l.header;if(!u)throw new Error(`Missing Renderer for header column ${s.id}`);return u?c.cloneElement(u,{role:"columnheader",key:s.id,id:s.id,column:s}):c.createElement(mr,{id:s.id,key:s.id})})},[e]),r=c.useMemo(()=>hr(e==null?void 0:e.currentLayout),[e==null?void 0:e.currentLayout]),n=c.useMemo(()=>{var o;return pr((o=e==null?void 0:e.currentLayout)==null?void 0:o.stickyHeader)},[(i=e==null?void 0:e.currentLayout)==null?void 0:i.stickyHeader]);return c.createElement("div",{role:"rowheader",className:_.cx("grid-header",r,n)},t)},_r=e=>{if(e.row!==1)return"";let t="";return e.width?t=m(e.width):e.min||e.max?t=`minmax(${m(e.min||"auto")}, ${m(e.max||"auto")})`:t="auto",e.colSpan&&(t=Array(e.colSpan).fill(t).join(" ")),t},j={wrappers:"> .grid-header, > .grid-body, .grid-body > .grid-row",nonEmpty:"*:not(:empty)",header:".grid-header",body:".grid-body",row:".grid-row"},br=e=>{const t=m(e.cellPadding),r={};for(const i of e.columns)r[`> [data-column-id="${i.id}"]`]={"--row-offset":i.row,"--is-last-row":e.lastRowOffset===i.row+(i.rowSpan-1)?1:0,gridColumn:`auto /span ${i.colSpan||1}`,gridRow:`auto /span ${i.rowSpan||1}`,justifyContent:we[i.justify||"start"]};return{display:"grid",gridTemplateColumns:e.columns.map(_r).join(" "),"--last-row-offset":e.lastRowOffset,[`${j.wrappers}`]:{display:"contents",">[data-column-id]":{display:"flex",alignItems:"center"},[`>${j.nonEmpty}`]:e.cellPadding===!1?void 0:{padding:`${t} calc(${t} / 2)`}},[`> ${j.header}`]:r,[`> ${j.body}`]:{[` > ${j.row}`]:{"&:nth-of-type(2n + 1) > *":e.stripe===!1?void 0:{backgroundColor:typeof e.stripe=="string"?e.stripe:"#e8e8e8"},...r}},...e.style}};function gr(e){const{"data-testid":t,className:r,data:n,children:i,caption:o,...a}=e,s=mt(e),u=c.useMemo(()=>_.css(br(s.state.currentLayout||{style:{},columns:[]})),[s.state.currentLayout]);return c.createElement(Se,{value:s},o&&o,c.createElement("div",{role:"table","data-testid":t,className:_.cx("gridley",u,r,s.state.layoutId)},c.createElement(xe,null),c.createElement(Re,{data:n}),i))}const wr=({className:e,children:t,layout:r})=>Ce(r)?c.createElement("div",{className:_.cx("caption",e)},t):null,Sr=({id:e,column:t,className:r,children:n,render:i,hidden:o,Component:a,role:s="cell",...u})=>{if(o)return null;let l="";const h=u;return i?l=i(h.value,h.rowData,h.allData,{...u}):a?l=c.createElement(a,{value:h.value,...u}):l=n||h.value,c.createElement("div",{role:s,"data-column-id":t==null?void 0:t.id,className:_.cx("grid-cell",e,r)},l)},Or=()=>null;function Er({children:e}){const t=te();return c.useEffect(()=>{if(!t)return;const r={};c.Children.forEach(e,n=>{if(c.isValidElement(n)){const i=n.props;r[i.id]=i}}),t({type:"SET_RENDERERS",renderers:r})},[t,e]),null}const Cr={lastRowOffset:1,headerSeparator:{width:"1px",color:"black",style:"solid"}},Pr={rowSpan:1,row:1};function vr(e){const t=te();return c.useEffect(()=>{var a;if(!t)return;const{children:r,...n}=e,i=((a=c.Children.map(r,s=>s&&c.isValidElement(s)?{...Pr,...s.props}:!1))==null?void 0:a.filter(Boolean))||[],o={...Cr,...n,columns:i};o.lastRowOffset=o.columns.reduce((s,u)=>u.row>s?u.row:s,0),t({type:"ADD_LAYOUT",layout:o})},[t,e]),null}f.Body=Re,f.Caption=wr,f.Cell=Sr,f.Column=Or,f.Columns=Er,f.GridContextProvider=Se,f.Gridley=gr,f.Header=xe,f.JUSTIFY_CONTENT=we,f.Layout=vr,f.Selectors=j,f.debounce=Oe,f.gridContext=I,f.toPX=m,f.useCurrentLayout=yt,f.useCurrentLayoutMatch=Ee,f.useGridContextDispatch=te,f.useGridContextState=z,f.useIsLayoutActive=Ce,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}); | ||
//# sourceMappingURL=gridley.umd.js.map |
@@ -11,3 +11,3 @@ { | ||
"typings": "dist/index.d.ts", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"scripts": { | ||
@@ -14,0 +14,0 @@ "start": "vite", |
@@ -18,3 +18,3 @@ # Gridley | ||
For an usable example of the screenshots above, try | ||
[the sandbox example](https://codesandbox.io/s/gridley-demo-s3g710?module=/example.tsx) | ||
[the sandbox example](https://codesandbox.io/s/gridley-demo-pzo7z2?module=/example.tsx) | ||
as well as the source in [demo/demo.tsx](demo/demo.tsx) | ||
@@ -21,0 +21,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2176
345168