@internetarchive/ads-table 0.0.1

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.
Files changed (34) hide show
  1. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/ads-table-storybook.d.ts +6 -0
  2. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/ads-table-storybook.js +88 -0
  3. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/ads-table-storybook.js.map +1 -0
  4. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/ads-table.d.ts +53 -0
  5. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/ads-table.js +425 -0
  6. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/ads-table.js.map +1 -0
  7. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/index.d.ts +2 -0
  8. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/index.js +3 -0
  9. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/index.js.map +1 -0
  10. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/types.d.ts +27 -0
  11. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/types.js +88 -0
  12. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/dist/types.js.map +1 -0
  13. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/ads-table/tsconfig.tsbuildinfo +1 -0
  14. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/dist/index.d.ts +1 -0
  15. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/dist/index.js +2 -0
  16. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/dist/index.js.map +1 -0
  17. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/dist/sample-component.d.ts +7 -0
  18. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/dist/sample-component.js +43 -0
  19. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/dist/sample-component.js.map +1 -0
  20. package/.rollup.cache/Users/jeffwklein/work/archive/ads-common/packages/sample-package/tsconfig.tsbuildinfo +1 -0
  21. package/dist/ads-table-storybook.d.ts +6 -0
  22. package/dist/ads-table.d.ts +53 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +659 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/types.d.ts +27 -0
  27. package/package.json +38 -0
  28. package/rollup.config.cjs +17 -0
  29. package/src/ads-table-storybook.ts +104 -0
  30. package/src/ads-table.ts +473 -0
  31. package/src/index.ts +14 -0
  32. package/src/types.ts +129 -0
  33. package/tsconfig.json +31 -0
  34. package/tsconfig.tsbuildinfo +1 -0
package/dist/index.js ADDED
@@ -0,0 +1,659 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise, SuppressedError, Symbol */
16
+
17
+
18
+ function __decorate(decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ 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;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ }
24
+
25
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
26
+ var e = new Error(message);
27
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
28
+ };
29
+
30
+ /**
31
+ * @license
32
+ * Copyright 2019 Google LLC
33
+ * SPDX-License-Identifier: BSD-3-Clause
34
+ */
35
+ const t$2=globalThis,e$4=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$3=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$4&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$3.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$3.set(s,t));}return t}toString(){return this.cssText}};const r$5=t=>new n$3("string"==typeof t?t:t+"",void 0,s$2),i$2=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$3(o,t,s$2)},S$1=(s,o)=>{if(e$4)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$4?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
36
+
37
+ /**
38
+ * @license
39
+ * Copyright 2017 Google LLC
40
+ * SPDX-License-Identifier: BSD-3-Clause
41
+ */const{is:i$1,defineProperty:e$3,getOwnPropertyDescriptor:r$4,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$2,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$1(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$3(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$4(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$2(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return !0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}}b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[d$1("elementProperties")]=new Map,b[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
42
+
43
+ /**
44
+ * @license
45
+ * Copyright 2017 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */
48
+ const t$1=globalThis,i=t$1.trustedTypes,s$1=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$2="$lit$",h=`lit$${(Math.random()+"").slice(9)}$`,o$1="?"+h,n$1=`<${o$1}>`,r$3=document,l=()=>r$3.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),w=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),A=new WeakMap,E=r$3.createTreeWalker(r$3,129);function C(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const P=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$2+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [C(t,l+(t[s]||"<?>")+(2===i?"</svg>":"")),o]};class V{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=P(t,s);if(this.el=V.createElement(f,n),E.currentNode=this.el.content,2===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=E.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$2)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?k:"?"===e[1]?H:"@"===e[1]?I:R}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),E.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$1)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$3.createElement("template");return s.innerHTML=t,s}}function N(t,i,s=t,e){if(i===w)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=N(t,h._$AS(t,i.values),h,e)),i}class S{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$3).importNode(i,!0);E.currentNode=e;let h=E.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new M(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new L(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=E.nextNode(),o++);}return E.currentNode=r$3,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=T,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=N(this,t,i),c(t)?t===T||null==t||""===t?(this._$AH!==T&&this._$AR(),this._$AH=T):t!==this._$AH&&t!==w&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t));}_(t){this._$AH!==T&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=V.createElement(C(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new S(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new V(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new M(this.S(l()),this.S(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class R{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=T,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=T;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=N(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=N(this,e[s+n],i,n),r===w&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===T?t=T:t!==T&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class k extends R{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===T?void 0:t;}}class H extends R{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==T);}}class I extends R{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=N(this,t,i,0)??T)===w)return;const s=this._$AH,e=t===T&&s!==T||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==T&&(s===T||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class L{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){N(this,t);}}const Z=t$1.litHtmlPolyfillSupport;Z?.(V,M),(t$1.litHtmlVersions??=[]).push("3.1.2");const j=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new M(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
49
+
50
+ /**
51
+ * @license
52
+ * Copyright 2017 Google LLC
53
+ * SPDX-License-Identifier: BSD-3-Clause
54
+ */class s extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=j(i,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return w}}s._$litElement$=!0,s[("finalized")]=!0,globalThis.litElementHydrateSupport?.({LitElement:s});const r$2=globalThis.litElementPolyfillSupport;r$2?.({LitElement:s});(globalThis.litElementVersions??=[]).push("4.0.4");
55
+
56
+ /**
57
+ * @license
58
+ * Copyright 2017 Google LLC
59
+ * SPDX-License-Identifier: BSD-3-Clause
60
+ */
61
+ const t=t=>(e,o)=>{void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
62
+
63
+ /**
64
+ * @license
65
+ * Copyright 2017 Google LLC
66
+ * SPDX-License-Identifier: BSD-3-Clause
67
+ */const o={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$1=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
68
+
69
+ /**
70
+ * @license
71
+ * Copyright 2017 Google LLC
72
+ * SPDX-License-Identifier: BSD-3-Clause
73
+ */function r(r){return n({...r,state:!0,attribute:!1})}
74
+
75
+ /**
76
+ * @license
77
+ * Copyright 2017 Google LLC
78
+ * SPDX-License-Identifier: BSD-3-Clause
79
+ */
80
+ const e$1=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
81
+
82
+ /**
83
+ * @license
84
+ * Copyright 2017 Google LLC
85
+ * SPDX-License-Identifier: BSD-3-Clause
86
+ */function e(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$1(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$1(n,s,{get(){return o(this)}})}}
87
+
88
+ // static class that encapsulates shorthands and utilities for emitting events.
89
+ class EventHelpers {
90
+ // returns event object with default options applied, overridden
91
+ // and extended by additional options the caller passes
92
+ static createEvent(eventName, options = {}) {
93
+ return new CustomEvent(eventName, {
94
+ ...EventHelpers.defaultEventOptions,
95
+ ...options,
96
+ });
97
+ }
98
+ }
99
+ EventHelpers.defaultEventOptions = {
100
+ composed: true,
101
+ bubbles: true,
102
+ };
103
+
104
+ // browser-related utility functions
105
+ var UserOperatingSystem;
106
+ (function (UserOperatingSystem) {
107
+ UserOperatingSystem["MAC"] = "MAC";
108
+ UserOperatingSystem["WINDOWS"] = "WINDOWS";
109
+ UserOperatingSystem["LINUX"] = "LINUX";
110
+ UserOperatingSystem["OTHER"] = "OTHER";
111
+ })(UserOperatingSystem || (UserOperatingSystem = {}));
112
+ function getUserOS() {
113
+ const userAgent = window.navigator.userAgent.toLowerCase();
114
+ if (userAgent.includes("mac")) {
115
+ return UserOperatingSystem.MAC;
116
+ }
117
+ else if (userAgent.includes("win")) {
118
+ return UserOperatingSystem.WINDOWS;
119
+ }
120
+ else if (userAgent.includes("linux")) {
121
+ return UserOperatingSystem.LINUX;
122
+ }
123
+ else {
124
+ return UserOperatingSystem.OTHER;
125
+ }
126
+ }
127
+
128
+ // map from binary exponents to the corresponding binary data volume unit suffix
129
+ const _EXP_UNITS = Object.fromEntries(["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"].map((unit, idx) => [idx * 10, unit]));
130
+ /**
131
+ * Gets a human-friendly representation of numBytes, expressed in binary units.
132
+ *
133
+ * @param numBytes whole number expressing the count of bytes to represent
134
+ * @return the formatted friendly representation of the number of bytes
135
+ */
136
+ function humanBytes(numBytes) {
137
+ switch (numBytes) {
138
+ case -1:
139
+ return "-1 Byte";
140
+ case 0:
141
+ return "0 Bytes";
142
+ case 1:
143
+ return "1 Byte";
144
+ }
145
+ const exp = Math.floor(Math.log2(Math.abs(numBytes)) / 10) * 10.0;
146
+ const precision = exp > 0 ? 1 : 0;
147
+ return `${(numBytes / Math.pow(2, exp)).toFixed(precision)} ${_EXP_UNITS[exp]}`;
148
+ }
149
+ function isoStringToDateString(timestamp, includeTime = false) {
150
+ const dayConfig = {
151
+ month: "short",
152
+ day: "numeric",
153
+ year: "numeric",
154
+ };
155
+ const timeConfig = {
156
+ hour: "numeric",
157
+ minute: "2-digit",
158
+ timeZoneName: "short",
159
+ };
160
+ return includeTime
161
+ ? new Date(timestamp).toLocaleTimeString(navigator.language, {
162
+ ...dayConfig,
163
+ ...timeConfig,
164
+ })
165
+ : new Date(timestamp).toLocaleDateString(navigator.language, dayConfig);
166
+ }
167
+ function formatDate(date, includeTime = true) {
168
+ const _formattedDate = isoStringToDateString(date, includeTime);
169
+ return _formattedDate === "Invalid Date" ? "" : _formattedDate;
170
+ }
171
+
172
+ class AdsTable extends s {
173
+ constructor() {
174
+ super(...arguments);
175
+ // base list of data that this class sorts
176
+ this.rows = [];
177
+ this.noDataText = "No items found";
178
+ this.defaultSortDirection = "ascending";
179
+ this.sortDirection = this.defaultSortDirection;
180
+ // list of selected rows in order of least to most recently added
181
+ this.selectedRowIds = [];
182
+ this.isLoading = false;
183
+ }
184
+ updated(changedProperties) {
185
+ super.updated(changedProperties);
186
+ if (changedProperties.has("selectedRowIds")) {
187
+ // report selected rows to parent via an event
188
+ this.emitEvent("row-select", { selectedRows: this.selectedRows });
189
+ }
190
+ // if rows change, re-ensure selected rows exist in table
191
+ if (this.rowsDidUpdate(changedProperties)) {
192
+ this.filterSelectedRowsToExistingRows();
193
+ }
194
+ }
195
+ // rather than compare references, determine if 'this.rows' has updated. an update occurs if:
196
+ // - row list is a different size
197
+ // - any elements in the sorted list may have changed place
198
+ rowsDidUpdate(changedProperties) {
199
+ // if the sort properties change, assume the elements have rearranged
200
+ if (changedProperties.has("sortKey") ||
201
+ changedProperties.has("sortDirection")) {
202
+ return true;
203
+ }
204
+ if (!changedProperties.has("rows") || !changedProperties.get("rows")) {
205
+ return false;
206
+ }
207
+ const oldRowIds = changedProperties.get("rows").map((row) => row.id);
208
+ // first check length. if list length changes, rows have changed.
209
+ if (oldRowIds.length !== this.rows.length) {
210
+ return true;
211
+ }
212
+ // otherwise, if they're the same size, compare individual items and ensure they're the same set of items
213
+ const newRowsIdsSet = new Set(this.rows.map((row) => row.id));
214
+ return !oldRowIds.every((id) => newRowsIdsSet.has(id));
215
+ }
216
+ emitEvent(eventName, detail = {}) {
217
+ this.dispatchEvent(EventHelpers.createEvent(eventName, detail ? { detail } : {}));
218
+ }
219
+ get visibleColumns() {
220
+ return this.columns.filter(({ isHidden }) => !isHidden);
221
+ }
222
+ get rowsById() {
223
+ return Object.fromEntries(this.rows.map((row) => [row.id, row]));
224
+ }
225
+ get sortedRows() {
226
+ var _a;
227
+ const sortByPrimaryKey = this.getSortFunction(this.sortColumnDataType, this.sortDirection);
228
+ const sortBySecondaryKey = this.getSortFunction(this.secondarySortDataType, ((_a = this.secondarySortDataType) === null || _a === void 0 ? void 0 : _a.defaultSortDirection) || this.sortDirection);
229
+ return this.rows.sort((rowA, rowB) => {
230
+ // sort by primary key: the selected column and direction
231
+ const sortResult = (sortByPrimaryKey === null || sortByPrimaryKey === void 0 ? void 0 : sortByPrimaryKey(rowA.data, rowB.data)) || 0;
232
+ // if sort result on primary sort key is inconclusive, use secondary sort data type
233
+ if (sortResult === 0) {
234
+ return (sortBySecondaryKey === null || sortBySecondaryKey === void 0 ? void 0 : sortBySecondaryKey(rowA.data, rowB.data)) || 0;
235
+ }
236
+ else {
237
+ return sortResult;
238
+ }
239
+ });
240
+ }
241
+ get selectedRows() {
242
+ return this.selectedRowIds.map((id) => this.rowsById[id]).filter((x) => x);
243
+ }
244
+ // handler for when a user clicks on a column header
245
+ onColumnClick(column, defaultSortDirection = this
246
+ .defaultSortDirection) {
247
+ if (this.sortKey === column.key) {
248
+ // toggle the sort direction if the column you are clicking is already sorted
249
+ this.sortDirection =
250
+ this.sortDirection === "ascending" ? "descending" : "ascending";
251
+ }
252
+ else {
253
+ // otherwise, sort by the column you clicked on, and in the default sort direction
254
+ this.sortKey = column.key;
255
+ this.sortDirection =
256
+ column.dataType.defaultSortDirection || defaultSortDirection;
257
+ }
258
+ }
259
+ // a map of column keys to their respective data types so we don't have to call .find everywhere
260
+ get columnKeyToDataType() {
261
+ return Object.fromEntries(this.columns.map((col) => [col.key, col.dataType]));
262
+ }
263
+ // data type of the currently sorted column
264
+ get sortColumnDataType() {
265
+ if (this.sortKey) {
266
+ return this.columnKeyToDataType[this.sortKey];
267
+ }
268
+ else {
269
+ return undefined;
270
+ }
271
+ }
272
+ // data type of the secondary sort column
273
+ get secondarySortDataType() {
274
+ if (this.secondarySortKey) {
275
+ return this.columnKeyToDataType[this.secondarySortKey];
276
+ }
277
+ else {
278
+ return undefined;
279
+ }
280
+ }
281
+ // swaps the parameters of the sort function to reverse the sort direction
282
+ getSortFunction(dataType, sortDirection) {
283
+ if (!dataType) {
284
+ return undefined;
285
+ }
286
+ if (sortDirection === "ascending") {
287
+ // return the original comparison function
288
+ return dataType.compare;
289
+ }
290
+ else if (dataType.compare !== undefined) {
291
+ // swap compare function parameters for descending
292
+ return (a, b) => { var _a; return ((_a = dataType.compare) === null || _a === void 0 ? void 0 : _a.call(dataType, b, a)) || 0; };
293
+ }
294
+ else {
295
+ return undefined;
296
+ }
297
+ }
298
+ renderArrowIcon(columnKey) {
299
+ if (columnKey !== this.sortKey) {
300
+ return x ``;
301
+ }
302
+ else if (this.sortDirection === "ascending") {
303
+ return x `▲`;
304
+ }
305
+ else {
306
+ return x `▼`;
307
+ }
308
+ }
309
+ get selectedRowIdsSet() {
310
+ return new Set(this.selectedRowIds);
311
+ }
312
+ get rowIdsSet() {
313
+ return new Set(this.rows.map((row) => row.id));
314
+ }
315
+ isSelected(row) {
316
+ return this.selectedRowIdsSet.has(row.id);
317
+ }
318
+ toggleRowSelected(rowId) {
319
+ if (this.selectedRowIdsSet.has(rowId)) {
320
+ // row is already selected: filter out clicked id
321
+ this.selectedRowIds = this.selectedRowIds.filter((id) => id !== rowId);
322
+ }
323
+ else {
324
+ // row is not yet selected: append clicked id
325
+ this.selectedRowIds = [...this.selectedRowIds, rowId];
326
+ }
327
+ }
328
+ get lastSelectedRowId() {
329
+ return this.selectedRowIds[this.selectedRowIds.length - 1];
330
+ }
331
+ get indexOfLastSelectedRow() {
332
+ return this.rows.findIndex((row) => row.id === this.lastSelectedRowId);
333
+ }
334
+ // select rows in order from the last selected element up til the given index
335
+ groupRowSelect(rowIndex) {
336
+ const getRowsToAdd = () => {
337
+ // get rows between index of last selected until index of selected row
338
+ if (rowIndex > this.indexOfLastSelectedRow) {
339
+ return this.rows.filter((_, i) => rowIndex >= i && i >= this.indexOfLastSelectedRow);
340
+ }
341
+ else {
342
+ // reverse order of adding rows since clicked index is lower than last selected
343
+ return this.rows
344
+ .filter((_, i) => this.indexOfLastSelectedRow >= i && i >= rowIndex)
345
+ .reverse();
346
+ }
347
+ };
348
+ const rowIdsToAdd = getRowsToAdd().map((row) => row.id);
349
+ const rowIdsSet = new Set(rowIdsToAdd);
350
+ // first remove ids you are about to re-add, so they'll be in renewed order
351
+ this.selectedRowIds = this.selectedRowIds.filter((id) => !rowIdsSet.has(id));
352
+ // finally, add the new rows
353
+ this.selectedRowIds = [...this.selectedRowIds, ...rowIdsToAdd];
354
+ }
355
+ onRowClick(event, clickedRow, rowIndex) {
356
+ const userOs = getUserOS();
357
+ // meta (cmd) key for mac, control key for non-mac
358
+ const macHoldingHotKey = userOs === UserOperatingSystem.MAC && event.metaKey;
359
+ const nonMacHoldingHotKey = userOs !== UserOperatingSystem.MAC && event.ctrlKey;
360
+ // if holding meta on mac or ctrl on windows/linux, toggle individual row selection
361
+ if (macHoldingHotKey || nonMacHoldingHotKey) {
362
+ this.toggleRowSelected(clickedRow.id);
363
+ }
364
+ else if (event.shiftKey) {
365
+ // if holding shift, select rows between this selection and the last selection
366
+ this.groupRowSelect(rowIndex);
367
+ }
368
+ else {
369
+ // clicking a row will select just that row.
370
+ this.selectedRowIds = [clickedRow.id];
371
+ }
372
+ this.filterSelectedRowsToExistingRows();
373
+ // emit event so users can hook into this action
374
+ this.emitEvent("row-click", { row: clickedRow });
375
+ }
376
+ // filter selected down to rows that actually exist in the table
377
+ filterSelectedRowsToExistingRows() {
378
+ this.selectedRowIds = this.selectedRowIds.filter((id) => this.rowIdsSet.has(id));
379
+ }
380
+ onRowDoubleClick(clickedRow) {
381
+ // emit event so users can hook into this event
382
+ this.emitEvent("row-double-click", { row: clickedRow });
383
+ }
384
+ // All keyboard events implemented through this method.
385
+ onKeyDown(event) {
386
+ var _a;
387
+ switch (event.key) {
388
+ case "ArrowUp":
389
+ case "ArrowDown":
390
+ event.preventDefault();
391
+ // shift focus to table element when navigating with arrow keys
392
+ (_a = this.tableElement) === null || _a === void 0 ? void 0 : _a.focus();
393
+ return this.onUpDownArrowKey(event.key);
394
+ }
395
+ }
396
+ onUpDownArrowKey(key) {
397
+ if (this.selectedRowIds.length === 0) {
398
+ // select the first row if none are selected
399
+ this.selectedRowIds = [this.rows[0].id];
400
+ return;
401
+ }
402
+ // offset in the proper direction of the arrow
403
+ const indexOffset = key === "ArrowUp" ? -1 : 1;
404
+ const newSelectedRowIndex = this.constrainIndex(this.indexOfLastSelectedRow + indexOffset);
405
+ const newSelectedRowId = this.rows[newSelectedRowIndex].id;
406
+ this.selectedRowIds = [newSelectedRowId];
407
+ }
408
+ // ensures index values are kept to the closest in-bounds index
409
+ constrainIndex(index) {
410
+ return Math.max(Math.min(index, this.rows.length - 1), 0);
411
+ }
412
+ connectedCallback() {
413
+ super.connectedCallback();
414
+ // attach keyboard listener
415
+ window.addEventListener("keydown", (e) => this.onKeyDown(e));
416
+ }
417
+ render() {
418
+ return x `
419
+ <table id="main-table" tabindex="0">
420
+ <thead>
421
+ <tr>
422
+ ${this.visibleColumns.map((column) => x `
423
+ <th
424
+ @click=${() => this.onColumnClick(column)}
425
+ class=${column.dataType.compare ? "sortable" : ""}
426
+ style=${`flex: ${column.flexRatio}`}
427
+ >
428
+ ${column.label}
429
+ ${column.dataType.compare
430
+ ? x `<span>${this.renderArrowIcon(column.key)}</span>`
431
+ : ""}
432
+ </th>
433
+ `)}
434
+ </tr>
435
+ </thead>
436
+ <tbody>
437
+ ${!this.isLoading
438
+ ? this.sortedRows.map((row, index) => x `
439
+ <tr
440
+ @click=${(e) => this.onRowClick(e, row, index)}
441
+ @dblclick=${() => this.onRowDoubleClick(row)}
442
+ class=${this.isSelected(row) ? "row-selected" : ""}
443
+ data-row-selected=${this.isSelected(row)}
444
+ data-id=${row.id}
445
+ >
446
+ ${this.visibleColumns.map((column) => x `
447
+ <td style=${`flex: ${column.flexRatio}`}>
448
+ ${column.dataType.format(row.data)}
449
+ </td>
450
+ `)}
451
+ </tr>
452
+ `)
453
+ : x `
454
+ <tr>
455
+ <td class="no-data">Loading...</td>
456
+ </tr>
457
+ `}
458
+ ${!this.isLoading && this.sortedRows.length === 0
459
+ ? x `
460
+ <tr>
461
+ <td class="no-data">${this.noDataText}</td>
462
+ </tr>
463
+ `
464
+ : null}
465
+ </tbody>
466
+ </table>
467
+ `;
468
+ }
469
+ }
470
+ AdsTable.styles = i$2 `
471
+ table {
472
+ display: flex;
473
+ flex-direction: column;
474
+ user-select: none;
475
+ border-collapse: collapse;
476
+ }
477
+
478
+ thead,
479
+ tbody {
480
+ display: flex;
481
+ flex-direction: column;
482
+ }
483
+
484
+ thead {
485
+ background: #2a282c;
486
+ }
487
+
488
+ tbody {
489
+ scrollbar-gutter: stable;
490
+ }
491
+
492
+ tr {
493
+ display: flex;
494
+ width: 100%;
495
+ min-height: 40px;
496
+ flex-shrink: 0;
497
+ }
498
+
499
+ tr.row-selected {
500
+ background: #ccddf2;
501
+ }
502
+
503
+ td.no-data {
504
+ font-style: italic;
505
+ justify-content: center;
506
+ }
507
+
508
+ td,
509
+ th {
510
+ display: flex;
511
+ flex: 1;
512
+ justify-content: flex-start;
513
+ align-items: center;
514
+ padding: 0 12px;
515
+ height: 40px;
516
+
517
+ overflow: hidden;
518
+ text-overflow: ellipsis;
519
+ white-space: nowrap;
520
+ min-width: 0;
521
+ }
522
+
523
+ th {
524
+ color: white;
525
+ }
526
+
527
+ th.sortable {
528
+ cursor: pointer;
529
+ }
530
+
531
+ th.sortable:hover {
532
+ background: #525252;
533
+ }
534
+
535
+ th span {
536
+ padding-left: 5px;
537
+ }
538
+
539
+ td {
540
+ border-bottom: 1px solid #bbbbbb;
541
+ }
542
+ `;
543
+ __decorate([
544
+ e("#main-table")
545
+ ], AdsTable.prototype, "tableElement", void 0);
546
+ __decorate([
547
+ n({ type: Array })
548
+ ], AdsTable.prototype, "rows", void 0);
549
+ __decorate([
550
+ r()
551
+ ], AdsTable.prototype, "sortDirection", void 0);
552
+ __decorate([
553
+ r()
554
+ ], AdsTable.prototype, "selectedRowIds", void 0);
555
+ __decorate([
556
+ r()
557
+ ], AdsTable.prototype, "isLoading", void 0);
558
+ // a simple, generic, out-of-the box implementation of AdsTable
559
+ let AdsSimpleTable = class AdsSimpleTable extends AdsTable {
560
+ constructor() {
561
+ var _a;
562
+ super(...arguments);
563
+ // columns are exposed as a parameter like rows, not a class member to implement
564
+ this.columns = [];
565
+ this.secondarySortKey = undefined;
566
+ // sort key is automatically held in state
567
+ this.sortKey = (_a = this.columns[0]) === null || _a === void 0 ? void 0 : _a.key;
568
+ }
569
+ updated(changedProperties) {
570
+ var _a;
571
+ super.updated(changedProperties);
572
+ if (changedProperties.has("columns")) {
573
+ this.sortKey = (_a = this.columns[0]) === null || _a === void 0 ? void 0 : _a.key;
574
+ }
575
+ }
576
+ };
577
+ __decorate([
578
+ n({ type: Array })
579
+ ], AdsSimpleTable.prototype, "columns", void 0);
580
+ __decorate([
581
+ n({ type: String })
582
+ ], AdsSimpleTable.prototype, "secondarySortKey", void 0);
583
+ __decorate([
584
+ r()
585
+ ], AdsSimpleTable.prototype, "sortKey", void 0);
586
+ AdsSimpleTable = __decorate([
587
+ t("ads-simple-table")
588
+ ], AdsSimpleTable);
589
+
590
+ // for basic string comparison
591
+ const StringDataType = {
592
+ compare: (a, b) => {
593
+ if (a.toLowerCase() === b.toLowerCase()) {
594
+ return 0;
595
+ }
596
+ return a.toLowerCase() > b.toLowerCase() ? 1 : -1;
597
+ },
598
+ format(value) {
599
+ return value;
600
+ },
601
+ };
602
+ // for basic number comparison
603
+ const NumberDataType = {
604
+ compare: (a, b) => {
605
+ if (a === b) {
606
+ return 0;
607
+ }
608
+ return a > b ? 1 : -1;
609
+ },
610
+ format(value) {
611
+ return value.toFixed(0);
612
+ },
613
+ defaultSortDirection: "descending",
614
+ };
615
+ // for comparing and formatting dates
616
+ const DateDataType = {
617
+ compare: (a, b) => {
618
+ var _a;
619
+ return ((_a = NumberDataType.compare) === null || _a === void 0 ? void 0 : _a.call(NumberDataType, a.getTime(), b.getTime())) || 0;
620
+ },
621
+ format: formatDate,
622
+ defaultSortDirection: "descending",
623
+ };
624
+ // for comparing and formatting numbers that represent bytes
625
+ const BytesDataType = {
626
+ compare: NumberDataType.compare,
627
+ format: humanBytes,
628
+ };
629
+ // will return a DataType that extends the given DataType to handle undefined values
630
+ const UndefinedHelpers = (dataType) => {
631
+ // if a compare function exists, extend it to handle potentially undefined inputs
632
+ return {
633
+ compare: dataType.compare
634
+ ? (a, b) => {
635
+ var _a;
636
+ if (a && b) {
637
+ return ((_a = dataType.compare) === null || _a === void 0 ? void 0 : _a.call(dataType, a, b)) || 0;
638
+ }
639
+ else if (a === b) {
640
+ // both are undefined
641
+ return 0;
642
+ }
643
+ // if a is defined, it's first, if not, b is defined and first
644
+ return a ? 1 : -1;
645
+ }
646
+ : undefined,
647
+ format(value) {
648
+ return value ? dataType.format(value) : "–";
649
+ },
650
+ };
651
+ };
652
+ // will return a DataType to have an undefined comparison function, turning sorting off for this data type
653
+ const NonSortable = (dataType) => ({
654
+ ...dataType,
655
+ compare: undefined,
656
+ });
657
+
658
+ export { AdsSimpleTable, AdsTable, BytesDataType, DateDataType, NonSortable, NumberDataType, StringDataType, UndefinedHelpers };
659
+ //# sourceMappingURL=index.js.map