@fluid-topics/ft-trend 0.1.4 → 0.1.7

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.
@@ -0,0 +1,146 @@
1
+ !function(t,i,e,o){
2
+ /**
3
+ * @license
4
+ * Copyright 2017 Google LLC
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */
7
+ var s;const n=globalThis.trustedTypes,r=n?n.createPolicy("lit-html",{createHTML:t=>t}):void 0,h=`lit$${(Math.random()+"").slice(9)}$`,p="?"+h,l=`<${p}>`,a=document,f=(t="")=>a.createComment(t),y=t=>null===t||"object"!=typeof t&&"function"!=typeof t,g=Array.isArray,c=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,d=/-->/g,u=/>/g,v=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,$=/'/g,m=/"/g,b=/^(?:script|style|textarea|title)$/i,x=(t=>(i,...e)=>({_$litType$:t,strings:i,values:e}))(1),w=Symbol.for("lit-noChange"),z=Symbol.for("lit-nothing"),A=new WeakMap,_=a.createTreeWalker(a,129,null,!1),N=(t,i)=>{const e=t.length-1,o=[];let s,n=2===i?"<svg>":"",p=c;for(let i=0;i<e;i++){const e=t[i];let r,a,f=-1,y=0;for(;y<e.length&&(p.lastIndex=y,a=p.exec(e),null!==a);)y=p.lastIndex,p===c?"!--"===a[1]?p=d:void 0!==a[1]?p=u:void 0!==a[2]?(b.test(a[2])&&(s=RegExp("</"+a[2],"g")),p=v):void 0!==a[3]&&(p=v):p===v?">"===a[0]?(p=null!=s?s:c,f=-1):void 0===a[1]?f=-2:(f=p.lastIndex-a[2].length,r=a[1],p=void 0===a[3]?v:'"'===a[3]?m:$):p===m||p===$?p=v:p===d||p===u?p=c:(p=v,s=void 0);const g=p===v&&t[i+1].startsWith("/>")?" ":"";n+=p===c?e+l:f>=0?(o.push(r),e.slice(0,f)+"$lit$"+e.slice(f)+h+g):e+h+(-2===f?(o.push(void 0),i):g)}const a=n+(t[e]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==r?r.createHTML(a):a,o]};class S{constructor({strings:t,_$litType$:i},e){let o;this.parts=[];let s=0,r=0;const l=t.length-1,a=this.parts,[y,g]=N(t,i);if(this.el=S.createElement(y,e),_.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(o=_.nextNode())&&a.length<l;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const i of o.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(h)){const e=g[r++];if(t.push(i),void 0!==e){const t=o.getAttribute(e.toLowerCase()+"$lit$").split(h),i=/([.?@])?(.*)/.exec(e);a.push({type:1,index:s,name:i[2],strings:t,ctor:"."===i[1]?O:"?"===i[1]?U:"@"===i[1]?C:E})}else a.push({type:6,index:s})}for(const i of t)o.removeAttribute(i)}if(b.test(o.tagName)){const t=o.textContent.split(h),i=t.length-1;if(i>0){o.textContent=n?n.emptyScript:"";for(let e=0;e<i;e++)o.append(t[e],f()),_.nextNode(),a.push({type:2,index:++s});o.append(t[i],f())}}}else if(8===o.nodeType)if(o.data===p)a.push({type:2,index:s});else{let t=-1;for(;-1!==(t=o.data.indexOf(h,t+1));)a.push({type:7,index:s}),t+=h.length-1}s++}}static createElement(t,i){const e=a.createElement("template");return e.innerHTML=t,e}}function T(t,i,e=t,o){var s,n,r,h;if(i===w)return i;let p=void 0!==o?null===(s=e._$Cl)||void 0===s?void 0:s[o]:e._$Cu;const l=y(i)?void 0:i._$litDirective$;return(null==p?void 0:p.constructor)!==l&&(null===(n=null==p?void 0:p._$AO)||void 0===n||n.call(p,!1),void 0===l?p=void 0:(p=new l(t),p._$AT(t,e,o)),void 0!==o?(null!==(r=(h=e)._$Cl)&&void 0!==r?r:h._$Cl=[])[o]=p:e._$Cu=p),void 0!==p&&(i=T(t,p._$AS(t,i.values),p,o)),i}class I{constructor(t,i){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var i;const{el:{content:e},parts:o}=this._$AD,s=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:a).importNode(e,!0);_.currentNode=s;let n=_.nextNode(),r=0,h=0,p=o[0];for(;void 0!==p;){if(r===p.index){let i;2===p.type?i=new M(n,n.nextSibling,this,t):1===p.type?i=new p.ctor(n,p.name,p.strings,this,t):6===p.type&&(i=new Z(n,this,t)),this.v.push(i),p=o[++h]}r!==(null==p?void 0:p.index)&&(n=_.nextNode(),r++)}return s}m(t){let i=0;for(const e of this.v)void 0!==e&&(void 0!==e.strings?(e._$AI(t,e,i),i+=e.strings.length-2):e._$AI(t[i])),i++}}class M{constructor(t,i,e,o){var s;this.type=2,this._$AH=z,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=e,this.options=o,this._$Cg=null===(s=null==o?void 0:o.isConnected)||void 0===s||s}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cg}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=T(this,t,i),y(t)?t===z||null==t||""===t?(this._$AH!==z&&this._$AR(),this._$AH=z):t!==this._$AH&&t!==w&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.S(t):(t=>{var i;return g(t)||"function"==typeof(null===(i=t)||void 0===i?void 0:i[Symbol.iterator])})(t)?this.A(t):this.$(t)}M(t,i=this._$AB){return this._$AA.parentNode.insertBefore(t,i)}S(t){this._$AH!==t&&(this._$AR(),this._$AH=this.M(t))}$(t){this._$AH!==z&&y(this._$AH)?this._$AA.nextSibling.data=t:this.S(a.createTextNode(t)),this._$AH=t}T(t){var i;const{values:e,_$litType$:o}=t,s="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=S.createElement(o.h,this.options)),o);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===s)this._$AH.m(e);else{const t=new I(s,this),i=t.p(this.options);t.m(e),this.S(i),this._$AH=t}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new S(t)),i}A(t){g(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let e,o=0;for(const s of t)o===i.length?i.push(e=new M(this.M(f()),this.M(f()),this,this.options)):e=i[o],e._$AI(s),o++;o<i.length&&(this._$AR(e&&e._$AB.nextSibling,o),i.length=o)}_$AR(t=this._$AA.nextSibling,i){var e;for(null===(e=this._$AP)||void 0===e||e.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cg=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class E{constructor(t,i,e,o,s){this.type=1,this._$AH=z,this._$AN=void 0,this.element=t,this.name=i,this._$AM=o,this.options=s,e.length>2||""!==e[0]||""!==e[1]?(this._$AH=Array(e.length-1).fill(new String),this.strings=e):this._$AH=z}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,e,o){const s=this.strings;let n=!1;if(void 0===s)t=T(this,t,i,0),n=!y(t)||t!==this._$AH&&t!==w,n&&(this._$AH=t);else{const o=t;let r,h;for(t=s[0],r=0;r<s.length-1;r++)h=T(this,o[e+r],i,r),h===w&&(h=this._$AH[r]),n||(n=!y(h)||h!==this._$AH[r]),h===z?t=z:t!==z&&(t+=(null!=h?h:"")+s[r+1]),this._$AH[r]=h}n&&!o&&this.k(t)}k(t){t===z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class O extends E{constructor(){super(...arguments),this.type=3}k(t){this.element[this.name]=t===z?void 0:t}}const j=n?n.emptyScript:"";class U extends E{constructor(){super(...arguments),this.type=4}k(t){t&&t!==z?this.element.setAttribute(this.name,j):this.element.removeAttribute(this.name)}}class C extends E{constructor(t,i,e,o,s){super(t,i,e,o,s),this.type=5}_$AI(t,i=this){var e;if((t=null!==(e=T(this,t,i,0))&&void 0!==e?e:z)===w)return;const o=this._$AH,s=t===z&&o!==z||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,n=t!==z&&(o===z||s);s&&this.element.removeEventListener(this.name,this,o),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,e;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}class Z{constructor(t,i,e){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=e}get _$AU(){return this._$AM._$AU}_$AI(t){T(this,t)}}const k=window.litHtmlPolyfillSupport;null==k||k(S,M),(null!==(s=globalThis.litHtmlVersions)&&void 0!==s?s:globalThis.litHtmlVersions=[]).push("2.1.3");
8
+ /**
9
+ * @license
10
+ * Copyright 2020 Google LLC
11
+ * SPDX-License-Identifier: BSD-3-Clause
12
+ */
13
+ const W=t=>({_$litStatic$:t}),G=new Map,D=(t=>(i,...e)=>{var o;const s=e.length;let n,r;const h=[],p=[];let l,a=0,f=!1;for(;a<s;){for(l=i[a];a<s&&void 0!==(r=e[a],n=null===(o=r)||void 0===o?void 0:o._$litStatic$);)l+=n+i[++a],f=!0;p.push(r),h.push(l),a++}if(a===s&&h.push(i[s]),f){const t=h.join("$$lit$$");void 0===(i=G.get(t))&&(h.raw=h,G.set(t,i=h)),e=p}return t(i,...e)})(x);var H,K=function(t,i,e,o){for(var s,n=arguments.length,r=n<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,h=t.length-1;h>=0;h--)(s=t[h])&&(r=(n<3?s(r):n>3?s(i,e,r):s(i,e))||r);return n>3&&r&&Object.defineProperty(i,e,r),r};!function(t){t.title="title",t.title_dense="title-dense",t.subtitle1="subtitle1",t.subtitle2="subtitle2",t.body1="body1",t.body2="body2",t.caption="caption",t.breadcrumb="breadcrumb",t.overline="overline",t.button="button"}(H||(H={}));const R=o.FtCssVariable.extend("--ft-typography-font-family",o.designSystemVariables.titleFont),V=o.FtCssVariable.extend("--ft-typography-font-family",o.designSystemVariables.contentFont),F={fontFamily:V,fontSize:o.FtCssVariable.create("--ft-typography-font-size","SIZE","16px"),fontWeight:o.FtCssVariable.create("--ft-typography-font-weight","UNKNOWN","normal"),letterSpacing:o.FtCssVariable.create("--ft-typography-letter-spacing","SIZE","0.496px"),lineHeight:o.FtCssVariable.create("--ft-typography-line-height","SIZE","24px"),textTransform:o.FtCssVariable.create("--ft-typography-text-transform","UNKNOWN","inherit")},L=o.FtCssVariable.extend("--ft-typography-title-font-family",R),P=o.FtCssVariable.extend("--ft-typography-title-font-size",F.fontSize,"20px"),q=o.FtCssVariable.extend("--ft-typography-title-font-weight",F.fontWeight,"normal"),B=o.FtCssVariable.extend("--ft-typography-title-letter-spacing",F.letterSpacing,"0.15px"),J=o.FtCssVariable.extend("--ft-typography-title-line-height",F.lineHeight,"24px"),Q=o.FtCssVariable.extend("--ft-typography-title-text-transform",F.textTransform,"inherit"),X=o.FtCssVariable.extend("--ft-typography-title-dense-font-family",R),Y=o.FtCssVariable.extend("--ft-typography-title-dense-font-size",F.fontSize,"14px"),tt=o.FtCssVariable.extend("--ft-typography-title-dense-font-weight",F.fontWeight,"normal"),it=o.FtCssVariable.extend("--ft-typography-title-dense-letter-spacing",F.letterSpacing,"0.105px"),et=o.FtCssVariable.extend("--ft-typography-title-dense-line-height",F.lineHeight,"24px"),ot=o.FtCssVariable.extend("--ft-typography-title-dense-text-transform",F.textTransform,"inherit"),st=o.FtCssVariable.extend("--ft-typography-subtitle1-font-family",V),nt=o.FtCssVariable.extend("--ft-typography-subtitle1-font-size",F.fontSize,"16px"),rt=o.FtCssVariable.extend("--ft-typography-subtitle1-font-weight",F.fontWeight,"600"),ht=o.FtCssVariable.extend("--ft-typography-subtitle1-letter-spacing",F.letterSpacing,"0.144px"),pt=o.FtCssVariable.extend("--ft-typography-subtitle1-line-height",F.lineHeight,"24px"),lt=o.FtCssVariable.extend("--ft-typography-subtitle1-text-transform",F.textTransform,"inherit"),at=o.FtCssVariable.extend("--ft-typography-subtitle2-font-family",V),ft=o.FtCssVariable.extend("--ft-typography-subtitle2-font-size",F.fontSize,"14px"),yt=o.FtCssVariable.extend("--ft-typography-subtitle2-font-weight",F.fontWeight,"normal"),gt=o.FtCssVariable.extend("--ft-typography-subtitle2-letter-spacing",F.letterSpacing,"0.098px"),ct=o.FtCssVariable.extend("--ft-typography-subtitle2-line-height",F.lineHeight,"24px"),dt=o.FtCssVariable.extend("--ft-typography-subtitle2-text-transform",F.textTransform,"inherit"),ut=o.FtCssVariable.extend("--ft-typography-body1-font-family",V),vt=o.FtCssVariable.extend("--ft-typography-body1-font-size",F.fontSize,"16px"),$t=o.FtCssVariable.extend("--ft-typography-body1-font-weight",F.fontWeight,"normal"),mt=o.FtCssVariable.extend("--ft-typography-body1-letter-spacing",F.letterSpacing,"0.496px"),bt=o.FtCssVariable.extend("--ft-typography-body1-line-height",F.lineHeight,"24px"),xt=o.FtCssVariable.extend("--ft-typography-body1-text-transform",F.textTransform,"inherit"),wt=o.FtCssVariable.extend("--ft-typography-body2-font-family",V),zt=o.FtCssVariable.extend("--ft-typography-body2-font-size",F.fontSize,"14px"),At=o.FtCssVariable.extend("--ft-typography-body2-font-weight",F.fontWeight,"normal"),_t=o.FtCssVariable.extend("--ft-typography-body2-letter-spacing",F.letterSpacing,"0.252px"),Nt=o.FtCssVariable.extend("--ft-typography-body2-line-height",F.lineHeight,"20px"),St=o.FtCssVariable.extend("--ft-typography-body2-text-transform",F.textTransform,"inherit"),Tt=o.FtCssVariable.extend("--ft-typography-caption-font-family",V),It=o.FtCssVariable.extend("--ft-typography-caption-font-size",F.fontSize,"12px"),Mt=o.FtCssVariable.extend("--ft-typography-caption-font-weight",F.fontWeight,"normal"),Et=o.FtCssVariable.extend("--ft-typography-caption-letter-spacing",F.letterSpacing,"0.396px"),Ot=o.FtCssVariable.extend("--ft-typography-caption-line-height",F.lineHeight,"16px"),jt=o.FtCssVariable.extend("--ft-typography-caption-text-transform",F.textTransform,"inherit"),Ut=o.FtCssVariable.extend("--ft-typography-breadcrumb-font-family",V),Ct=o.FtCssVariable.extend("--ft-typography-breadcrumb-font-size",F.fontSize,"10px"),Zt=o.FtCssVariable.extend("--ft-typography-breadcrumb-font-weight",F.fontWeight,"normal"),kt=o.FtCssVariable.extend("--ft-typography-breadcrumb-letter-spacing",F.letterSpacing,"0.33px"),Wt=o.FtCssVariable.extend("--ft-typography-breadcrumb-line-height",F.lineHeight,"16px"),Gt=o.FtCssVariable.extend("--ft-typography-breadcrumb-text-transform",F.textTransform,"inherit"),Dt=o.FtCssVariable.extend("--ft-typography-overline-font-family",V),Ht=o.FtCssVariable.extend("--ft-typography-overline-font-size",F.fontSize,"10px"),Kt=o.FtCssVariable.extend("--ft-typography-overline-font-weight",F.fontWeight,"normal"),Rt=o.FtCssVariable.extend("--ft-typography-overline-letter-spacing",F.letterSpacing,"1.5px"),Vt=o.FtCssVariable.extend("--ft-typography-overline-line-height",F.lineHeight,"16px"),Ft=o.FtCssVariable.extend("--ft-typography-overline-text-transform",F.textTransform,"uppercase"),Lt=o.FtCssVariable.extend("--ft-typography-button-font-family",V),Pt=o.FtCssVariable.extend("--ft-typography-button-font-size",F.fontSize,"14px"),qt=o.FtCssVariable.extend("--ft-typography-button-font-weight",F.fontWeight,"600"),Bt=o.FtCssVariable.extend("--ft-typography-button-letter-spacing",F.letterSpacing,"1.246px"),Jt=o.FtCssVariable.extend("--ft-typography-button-line-height",F.lineHeight,"16px"),Qt=o.FtCssVariable.extend("--ft-typography-button-text-transform",F.textTransform,"uppercase"),Xt=i.css`
14
+ .ft-typography--title {
15
+ font-family: ${L};
16
+ font-size: ${P};
17
+ font-weight: ${q};
18
+ letter-spacing: ${B};
19
+ line-height: ${J};
20
+ text-transform: ${Q};
21
+ }
22
+ `,Yt=i.css`
23
+ .ft-typography--title-dense {
24
+ font-family: ${X};
25
+ font-size: ${Y};
26
+ font-weight: ${tt};
27
+ letter-spacing: ${it};
28
+ line-height: ${et};
29
+ text-transform: ${ot};
30
+ }
31
+ `,ti=i.css`
32
+ .ft-typography--subtitle1 {
33
+ font-family: ${st};
34
+ font-size: ${nt};
35
+ font-weight: ${rt};
36
+ letter-spacing: ${ht};
37
+ line-height: ${pt};
38
+ text-transform: ${lt};
39
+ }
40
+ `,ii=i.css`
41
+ .ft-typography--subtitle2 {
42
+ font-family: ${at};
43
+ font-size: ${ft};
44
+ font-weight: ${yt};
45
+ letter-spacing: ${gt};
46
+ line-height: ${ct};
47
+ text-transform: ${dt};
48
+ }
49
+
50
+ `,ei=i.css`
51
+ .ft-typography--body1 {
52
+ font-family: ${ut};
53
+ font-size: ${vt};
54
+ font-weight: ${$t};
55
+ letter-spacing: ${mt};
56
+ line-height: ${bt};
57
+ text-transform: ${xt};
58
+ }
59
+ `,oi=i.css`
60
+ .ft-typography--body2 {
61
+ font-family: ${wt};
62
+ font-size: ${zt};
63
+ font-weight: ${At};
64
+ letter-spacing: ${_t};
65
+ line-height: ${Nt};
66
+ text-transform: ${St};
67
+ }
68
+ `,si=i.css`
69
+ .ft-typography--caption {
70
+ font-family: ${Tt};
71
+ font-size: ${It};
72
+ font-weight: ${Mt};
73
+ letter-spacing: ${Et};
74
+ line-height: ${Ot};
75
+ text-transform: ${jt};
76
+ }
77
+ `,ni=i.css`
78
+ .ft-typography--breadcrumb {
79
+ font-family: ${Ut};
80
+ font-size: ${Ct};
81
+ font-weight: ${Zt};
82
+ letter-spacing: ${kt};
83
+ line-height: ${Wt};
84
+ text-transform: ${Gt};
85
+ }
86
+ `,ri=i.css`
87
+ .ft-typography--overline {
88
+ font-family: ${Dt};
89
+ font-size: ${Ht};
90
+ font-weight: ${Kt};
91
+ letter-spacing: ${Rt};
92
+ line-height: ${Vt};
93
+ text-transform: ${Ft};
94
+ }
95
+ `,hi=i.css`
96
+ .ft-typography--button {
97
+ font-family: ${Lt};
98
+ font-size: ${Pt};
99
+ font-weight: ${qt};
100
+ letter-spacing: ${Bt};
101
+ line-height: ${Jt};
102
+ text-transform: ${Qt};
103
+ }
104
+ `;let pi=class extends o.FtLitElement{constructor(){super(...arguments),this.variant=H.body1}getStyles(){return[Xt,Yt,ti,ii,ei,oi,si,ni,ri,hi]}getTemplate(){return this.element?D`
105
+ <${W(this.element)}
106
+ class="ft-typography ft-typography--${this.variant}">
107
+ <slot></slot>
108
+ </${W(this.element)}>
109
+ `:D`
110
+ <slot class="ft-typography ft-typography--${this.variant}"></slot>
111
+ `}};K([e.property()],pi.prototype,"element",void 0),K([e.property()],pi.prototype,"variant",void 0),pi=K([o.customElement("ft-typography")],pi);var li=function(t,i,e,o){for(var s,n=arguments.length,r=n<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,h=t.length-1;h>=0;h--)(s=t[h])&&(r=(n<3?s(r):n>3?s(i,e,r):s(i,e))||r);return n>3&&r&&Object.defineProperty(i,e,r),r};const ai={textColor:o.FtCssVariable.external(o.designSystemVariables.colorOnSurfaceHigh,"Design system"),titleColor:o.FtCssVariable.external(o.designSystemVariables.colorOnSurfaceMedium,"Design system")};t.FtTrend=class extends o.FtLitElement{constructor(){super(...arguments),this.label="Trend",this.currentValue=3,this.previousValue=2}getStyles(){return i.css`
112
+ .ft-trend {
113
+ text-align: center;
114
+ color: ${ai.textColor};
115
+ }
116
+
117
+ .ft-trend .title {
118
+ color: ${ai.titleColor};
119
+ }
120
+ `}getTrendIcon(){return this.currentValue==this.previousValue?"→":this.currentValue>this.previousValue?"↗":"↘"}getTrendPercentage(){let t=(this.currentValue-this.previousValue)/this.previousValue,i=Math.round(100*t);return`${i>=0?"+":"-"}${Math.abs(i)}%`}getTemplate(){return 0==this.previousValue?i.html`
121
+ <div class="ft-trend">
122
+ <ft-typography variant="subtitle2" class="title">
123
+ ${this.label}
124
+ </ft-typography>
125
+ <div>
126
+ <ft-typography variant="body2">
127
+ No previous value
128
+ </ft-typography>
129
+ </div>
130
+ </div>
131
+ `:i.html`
132
+ <div class="ft-trend">
133
+ <ft-typography variant="subtitle2" class="title">
134
+ ${this.label}
135
+ </ft-typography>
136
+ <div>
137
+ <ft-typography variant="title">
138
+ ${this.currentValue.toLocaleString()}
139
+ </ft-typography>
140
+ <span>${this.getTrendIcon()}</span>
141
+ <ft-typography variant="body2">
142
+ ${this.getTrendPercentage()}
143
+ </ft-typography>
144
+ </div>
145
+ </div>
146
+ `}},t.FtTrend.elementDefinitions={"ft-typography":pi},li([e.property({type:String})],t.FtTrend.prototype,"label",void 0),li([e.property({type:Number})],t.FtTrend.prototype,"currentValue",void 0),li([e.property({type:Number})],t.FtTrend.prototype,"previousValue",void 0),t.FtTrend=li([o.customElement("ft-trend")],t.FtTrend),t.FtTrendCssVariables=ai,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.wcUtils);
@@ -37,7 +37,21 @@ const et=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e
37
37
  * @license
38
38
  * Copyright 2021 Google LLC
39
39
  * SPDX-License-Identifier: BSD-3-Clause
40
- */class at extends(function(t){return class extends t{createRenderRoot(){const t=this.constructor,{registry:e,elementDefinitions:i,shadowRootOptions:o}=t;i&&!e&&(t.registry=new CustomElementRegistry,Object.entries(i).forEach((([e,i])=>t.registry.define(e,i))));const n=this.renderOptions.creationScope=this.attachShadow({...o,customElements:t.registry});return a(n,this.constructor.elementStyles),n}}}(Y)){constructor(){super(),this.constructorName=this.constructor.name,this.proto=this.constructor.prototype}getStyles(){return[]}getTemplate(){return null}render(){let t=this.getStyles();return Array.isArray(t)||(t=[t]),k`${t.map((t=>k`<style>${t}</style>`))} ${this.getTemplate()}`}adoptedCallback(){Object.getPrototypeOf(this)!==this.constructorName&&Object.setPrototypeOf(this,this.proto)}updated(t){super.updated(t),setTimeout((()=>this.contentAvailableCallback(t)),0)}contentAvailableCallback(t){}}var lt,ht;s`.ft-no-text-select{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}`,navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(ht=null===(lt=window.safari)||void 0===lt?void 0:lt.pushNotification)||void 0===ht||ht.toString());
40
+ */class at extends(function(t){return class extends t{createRenderRoot(){const t=this.constructor,{registry:e,elementDefinitions:i,shadowRootOptions:o}=t;i&&!e&&(t.registry=new CustomElementRegistry,Object.entries(i).forEach((([e,i])=>t.registry.define(e,i))));const n=this.renderOptions.creationScope=this.attachShadow({...o,customElements:t.registry});return a(n,this.constructor.elementStyles),n}}}(Y)){constructor(){super(),this.constructorName=this.constructor.name,this.proto=this.constructor.prototype}getStyles(){return[]}getTemplate(){return null}render(){let t=this.getStyles();return Array.isArray(t)||(t=[t]),k`
41
+ ${t.map((t=>k`
42
+ <style>${t}</style>
43
+ `))}
44
+ ${this.getTemplate()}
45
+ `}adoptedCallback(){Object.getPrototypeOf(this)!==this.constructorName&&Object.setPrototypeOf(this,this.proto)}updated(t){super.updated(t),setTimeout((()=>this.contentAvailableCallback(t)),0)}contentAvailableCallback(t){}}var lt,ht;s`
46
+ .ft-no-text-select {
47
+ -webkit-touch-callout: none;
48
+ -webkit-user-select: none;
49
+ -khtml-user-select: none;
50
+ -moz-user-select: none;
51
+ -ms-user-select: none;
52
+ user-select: none;
53
+ }
54
+ `,navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(ht=null===(lt=window.safari)||void 0===lt?void 0:lt.pushNotification)||void 0===ht||ht.toString());
41
55
  /**
42
56
  * @license
43
57
  * Copyright 2020 Google LLC
@@ -141,4 +155,39 @@ const ct=t=>({_$litStatic$:t}),pt=new Map,ft=(t=>(e,...i)=>{var o;const n=i.leng
141
155
  </${ct(this.element)}>
142
156
  `:ft`
143
157
  <slot class="ft-typography ft-typography--${this.variant}"></slot>
144
- `}};dt([it()],ke.prototype,"element",void 0),dt([it()],ke.prototype,"variant",void 0),ke=dt([nt("ft-typography")],ke);var Le=function(t,e,i,o){for(var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};const Ae={textColor:rt.external(st.colorOnSurfaceHigh,"Design system"),titleColor:rt.external(st.colorOnSurfaceMedium,"Design system")};t.FtTrend=class extends at{constructor(){super(...arguments),this.label="Trend",this.currentValue=3,this.previousValue=2}getStyles(){return s`.ft-trend{text-align:center;color:${Ae.textColor}}.ft-trend .title{color:${Ae.titleColor}}`}getTrendIcon(){return this.currentValue==this.previousValue?"→":this.currentValue>this.previousValue?"↗":"↘"}getTrendPercentage(){let t=(this.currentValue-this.previousValue)/this.previousValue,e=Math.round(100*t);return`${e>=0?"+":"-"}${Math.abs(e)}%`}getTemplate(){return 0==this.previousValue?k`<div class="ft-trend"><ft-typography variant="subtitle2" class="title">${this.label}</ft-typography><div><ft-typography variant="body2">No previous value</ft-typography></div></div>`:k`<div class="ft-trend"><ft-typography variant="subtitle2" class="title">${this.label}</ft-typography><div><ft-typography variant="title">${this.currentValue.toLocaleString()}</ft-typography><span>${this.getTrendIcon()}</span><ft-typography variant="body2">${this.getTrendPercentage()}</ft-typography></div></div>`}},t.FtTrend.elementDefinitions={"ft-typography":ke},Le([it({type:String})],t.FtTrend.prototype,"label",void 0),Le([it({type:Number})],t.FtTrend.prototype,"currentValue",void 0),Le([it({type:Number})],t.FtTrend.prototype,"previousValue",void 0),t.FtTrend=Le([nt("ft-trend")],t.FtTrend),t.FtTrendCssVariables=Ae,Object.defineProperty(t,"t",{value:!0})}({});
158
+ `}};dt([it()],ke.prototype,"element",void 0),dt([it()],ke.prototype,"variant",void 0),ke=dt([nt("ft-typography")],ke);var Le=function(t,e,i,o){for(var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};const Ae={textColor:rt.external(st.colorOnSurfaceHigh,"Design system"),titleColor:rt.external(st.colorOnSurfaceMedium,"Design system")};t.FtTrend=class extends at{constructor(){super(...arguments),this.label="Trend",this.currentValue=3,this.previousValue=2}getStyles(){return s`
159
+ .ft-trend {
160
+ text-align: center;
161
+ color: ${Ae.textColor};
162
+ }
163
+
164
+ .ft-trend .title {
165
+ color: ${Ae.titleColor};
166
+ }
167
+ `}getTrendIcon(){return this.currentValue==this.previousValue?"→":this.currentValue>this.previousValue?"↗":"↘"}getTrendPercentage(){let t=(this.currentValue-this.previousValue)/this.previousValue,e=Math.round(100*t);return`${e>=0?"+":"-"}${Math.abs(e)}%`}getTemplate(){return 0==this.previousValue?k`
168
+ <div class="ft-trend">
169
+ <ft-typography variant="subtitle2" class="title">
170
+ ${this.label}
171
+ </ft-typography>
172
+ <div>
173
+ <ft-typography variant="body2">
174
+ No previous value
175
+ </ft-typography>
176
+ </div>
177
+ </div>
178
+ `:k`
179
+ <div class="ft-trend">
180
+ <ft-typography variant="subtitle2" class="title">
181
+ ${this.label}
182
+ </ft-typography>
183
+ <div>
184
+ <ft-typography variant="title">
185
+ ${this.currentValue.toLocaleString()}
186
+ </ft-typography>
187
+ <span>${this.getTrendIcon()}</span>
188
+ <ft-typography variant="body2">
189
+ ${this.getTrendPercentage()}
190
+ </ft-typography>
191
+ </div>
192
+ </div>
193
+ `}},t.FtTrend.elementDefinitions={"ft-typography":ke},Le([it({type:String})],t.FtTrend.prototype,"label",void 0),Le([it({type:Number})],t.FtTrend.prototype,"currentValue",void 0),Le([it({type:Number})],t.FtTrend.prototype,"previousValue",void 0),t.FtTrend=Le([nt("ft-trend")],t.FtTrend),t.FtTrendCssVariables=Ae,Object.defineProperty(t,"t",{value:!0})}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-trend",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "description": "Single stat value with a trend",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,9 +19,9 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-typography": "^0.1.3",
23
- "@fluid-topics/ft-wc-utils": "^0.1.3",
22
+ "@fluid-topics/ft-typography": "^0.1.7",
23
+ "@fluid-topics/ft-wc-utils": "^0.1.7",
24
24
  "lit": "^2.0.2"
25
25
  },
26
- "gitHead": "58ce3aaa713dd7a4a4669f32a080fa51dd452ce9"
26
+ "gitHead": "78397cca67971191c46739cfb6c87481aaa65745"
27
27
  }