@nyaruka/temba-components 0.43.6 → 0.43.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.
- package/CHANGELOG.md +6 -0
- package/dist/{4182f77e.js → f13cada5.js} +16 -1
- package/dist/index.js +16 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/dist/templates/components-body.html +1 -1
- package/dist/templates/components-head.html +1 -1
- package/out-tsc/src/date/TembaDate.js +18 -3
- package/out-tsc/src/date/TembaDate.js.map +1 -1
- package/package.json +1 -1
- package/src/date/TembaDate.ts +18 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.43.7](https://github.com/nyaruka/temba-components/compare/v0.43.6...v0.43.7)
|
|
8
|
+
|
|
9
|
+
- Add full date format on mouseover for temba-date [`#294`](https://github.com/nyaruka/temba-components/pull/294)
|
|
10
|
+
|
|
7
11
|
#### [v0.43.6](https://github.com/nyaruka/temba-components/compare/v0.43.5...v0.43.6)
|
|
8
12
|
|
|
13
|
+
> 17 March 2023
|
|
14
|
+
|
|
9
15
|
- Add refresh globals option and icon [`#293`](https://github.com/nyaruka/temba-components/pull/293)
|
|
10
16
|
|
|
11
17
|
#### [v0.43.5](https://github.com/nyaruka/temba-components/compare/v0.43.4...v0.43.5)
|
|
@@ -5910,7 +5910,22 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
|
|
|
5910
5910
|
text-overflow: ellipsis;
|
|
5911
5911
|
white-space: nowrap;
|
|
5912
5912
|
}
|
|
5913
|
-
`}firstUpdated(t){super.firstUpdated(t),t.has("value")&&(this.datetime=Ss.fromISO(this.value),this.store=document.querySelector("temba-store"))}connectedCallback(){super.connectedCallback()}render(){if(this.datetime&&this.store){this.datetime.setLocale(this.store.getLocale());let t="";if(this.display===Pl.timedate){const e=Math.abs(this.datetime.diffNow().milliseconds/1e3/60/60);t=e<24?this.datetime.toLocaleString(Pl.time):e<8760?this.datetime.toFormat(Pl.day):this.datetime.toLocaleString(Pl.date)}else if(this.display===Pl.relative){if(Math.abs(this.datetime.diffNow().milliseconds/1e3/60)<1)return D`<div
|
|
5913
|
+
`}firstUpdated(t){super.firstUpdated(t),t.has("value")&&(this.datetime=Ss.fromISO(this.value),this.store=document.querySelector("temba-store"))}connectedCallback(){super.connectedCallback()}render(){if(this.datetime&&this.store){this.datetime.setLocale(this.store.getLocale());let t="";if(this.display===Pl.timedate){const e=Math.abs(this.datetime.diffNow().milliseconds/1e3/60/60);t=e<24?this.datetime.toLocaleString(Pl.time):e<8760?this.datetime.toFormat(Pl.day):this.datetime.toLocaleString(Pl.date)}else if(this.display===Pl.relative){if(Math.abs(this.datetime.diffNow().milliseconds/1e3/60)<1)return D`<div
|
|
5914
|
+
class="date"
|
|
5915
|
+
title="${this.datetime.toLocaleString(Pl.datetime)}"
|
|
5916
|
+
>
|
|
5917
|
+
just now
|
|
5918
|
+
</div>`;t=this.store.getShortDuration(this.datetime)}else if(this.display===Pl.duration){if(Math.abs(this.datetime.diffNow().milliseconds/1e3/60)<1)return D`<div
|
|
5919
|
+
class="date"
|
|
5920
|
+
title="${this.datetime.toLocaleString(Pl.datetime)}"
|
|
5921
|
+
>
|
|
5922
|
+
just now
|
|
5923
|
+
</div>`;t=this.store.getShortDuration(this.datetime)}else t=this.display===Pl.day?this.datetime.toLocaleString(Pl.day):this.datetime.toLocaleString(Pl[this.display]);return D`<div
|
|
5924
|
+
class="date"
|
|
5925
|
+
title="${this.datetime.toLocaleString(Pl.datetime)}"
|
|
5926
|
+
>
|
|
5927
|
+
${t}
|
|
5928
|
+
</div>`}}}t([st({type:String})],Il.prototype,"value",void 0),t([st({type:String})],Il.prototype,"display",void 0),t([st({type:Object,attribute:!1})],Il.prototype,"datetime",void 0);let Dl=class extends nt{constructor(){super(...arguments),this.body=D`<temba-loading></temba-loading>`}static get styles(){return r``}updated(t){super.updated(t),t.has("endpoint")&&ee(this.endpoint).then((t=>{console.log(t),this.body=Ls(t.body)}))}render(){return D`${this.body}`}};t([st({type:String})],Dl.prototype,"endpoint",void 0),t([st({attribute:!1})],Dl.prototype,"body",void 0),Dl=t([(t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){customElements.define(t,e)}}})(t,e))("temba-remote")],Dl);var Nl=Dl;class Rl extends nt{constructor(){super(...arguments),this.animationTime=300,this.show=!1,this.zoom=!1,this.zoomPct=.9,this.scale=1,this.xTrans="0px",this.yTrans="0px"}static get styles(){return r`
|
|
5914
5929
|
:host {
|
|
5915
5930
|
position: absolute;
|
|
5916
5931
|
}
|
package/dist/index.js
CHANGED
|
@@ -5910,7 +5910,22 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
|
|
|
5910
5910
|
text-overflow: ellipsis;
|
|
5911
5911
|
white-space: nowrap;
|
|
5912
5912
|
}
|
|
5913
|
-
`}firstUpdated(t){super.firstUpdated(t),t.has("value")&&(this.datetime=Ss.fromISO(this.value),this.store=document.querySelector("temba-store"))}connectedCallback(){super.connectedCallback()}render(){if(this.datetime&&this.store){this.datetime.setLocale(this.store.getLocale());let t="";if(this.display===Pl.timedate){const e=Math.abs(this.datetime.diffNow().milliseconds/1e3/60/60);t=e<24?this.datetime.toLocaleString(Pl.time):e<8760?this.datetime.toFormat(Pl.day):this.datetime.toLocaleString(Pl.date)}else if(this.display===Pl.relative){if(Math.abs(this.datetime.diffNow().milliseconds/1e3/60)<1)return D`<div
|
|
5913
|
+
`}firstUpdated(t){super.firstUpdated(t),t.has("value")&&(this.datetime=Ss.fromISO(this.value),this.store=document.querySelector("temba-store"))}connectedCallback(){super.connectedCallback()}render(){if(this.datetime&&this.store){this.datetime.setLocale(this.store.getLocale());let t="";if(this.display===Pl.timedate){const e=Math.abs(this.datetime.diffNow().milliseconds/1e3/60/60);t=e<24?this.datetime.toLocaleString(Pl.time):e<8760?this.datetime.toFormat(Pl.day):this.datetime.toLocaleString(Pl.date)}else if(this.display===Pl.relative){if(Math.abs(this.datetime.diffNow().milliseconds/1e3/60)<1)return D`<div
|
|
5914
|
+
class="date"
|
|
5915
|
+
title="${this.datetime.toLocaleString(Pl.datetime)}"
|
|
5916
|
+
>
|
|
5917
|
+
just now
|
|
5918
|
+
</div>`;t=this.store.getShortDuration(this.datetime)}else if(this.display===Pl.duration){if(Math.abs(this.datetime.diffNow().milliseconds/1e3/60)<1)return D`<div
|
|
5919
|
+
class="date"
|
|
5920
|
+
title="${this.datetime.toLocaleString(Pl.datetime)}"
|
|
5921
|
+
>
|
|
5922
|
+
just now
|
|
5923
|
+
</div>`;t=this.store.getShortDuration(this.datetime)}else t=this.display===Pl.day?this.datetime.toLocaleString(Pl.day):this.datetime.toLocaleString(Pl[this.display]);return D`<div
|
|
5924
|
+
class="date"
|
|
5925
|
+
title="${this.datetime.toLocaleString(Pl.datetime)}"
|
|
5926
|
+
>
|
|
5927
|
+
${t}
|
|
5928
|
+
</div>`}}}t([st({type:String})],Il.prototype,"value",void 0),t([st({type:String})],Il.prototype,"display",void 0),t([st({type:Object,attribute:!1})],Il.prototype,"datetime",void 0);let Dl=class extends nt{constructor(){super(...arguments),this.body=D`<temba-loading></temba-loading>`}static get styles(){return r``}updated(t){super.updated(t),t.has("endpoint")&&ee(this.endpoint).then((t=>{console.log(t),this.body=Ls(t.body)}))}render(){return D`${this.body}`}};t([st({type:String})],Dl.prototype,"endpoint",void 0),t([st({attribute:!1})],Dl.prototype,"body",void 0),Dl=t([(t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){customElements.define(t,e)}}})(t,e))("temba-remote")],Dl);var Nl=Dl;class Rl extends nt{constructor(){super(...arguments),this.animationTime=300,this.show=!1,this.zoom=!1,this.zoomPct=.9,this.scale=1,this.xTrans="0px",this.yTrans="0px"}static get styles(){return r`
|
|
5914
5929
|
:host {
|
|
5915
5930
|
position: absolute;
|
|
5916
5931
|
}
|
package/dist/sw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
if(!self.define){let e,t={};const o=(o,n)=>(o=new URL(o+".js",n).href,t[o]||new Promise((t=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=t,document.head.appendChild(e)}else e=o,importScripts(o),t()})).then((()=>{let e=t[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e})));self.define=(n,s)=>{const
|
|
1
|
+
if(!self.define){let e,t={};const o=(o,n)=>(o=new URL(o+".js",n).href,t[o]||new Promise((t=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=t,document.head.appendChild(e)}else e=o,importScripts(o),t()})).then((()=>{let e=t[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e})));self.define=(n,s)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(t[i])return;let r={};const c=e=>o(e,i),l={module:{uri:i},exports:r,require:c};t[i]=Promise.all(n.map((e=>l[e]||c(e)))).then((e=>(s(...e),r)))}}define(["./workbox-919adfb7"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"f13cada5.js",revision:"98fc8f9b904e0444d49dc8a4c81cd98b"},{url:"templates/components-body.html",revision:"0cc53cf19557cb39b466d6fa0031242c"},{url:"templates/components-head.html",revision:"511100d95e67eebf86ad38a087725a3a"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute("polyfills/*.js",new e.CacheFirst,"GET")}));
|
|
2
2
|
//# sourceMappingURL=sw.js.map
|
package/dist/sw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw.js","sources":["../../../../../tmp/
|
|
1
|
+
{"version":3,"file":"sw.js","sources":["../../../../../tmp/68689c294ccdd1983079a0b4887c7bb9/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"f13cada5.js\",\n \"revision\": \"98fc8f9b904e0444d49dc8a4c81cd98b\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"0cc53cf19557cb39b466d6fa0031242c\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"511100d95e67eebf86ad38a087725a3a\"\n }\n], {});\n\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"/index.html\")));\n\n\nworkbox_routing_registerRoute(\"polyfills/*.js\", new workbox_strategies_CacheFirst(), 'GET');\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","url","revision","workbox","registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","workbox_strategies_CacheFirst"],"mappings":"0nBAwBAA,KAAKC,cAELC,EAAAA,eAQAC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,cACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,qCAEb,CAAE,GAEwBC,EAAAC,cAAC,IAAIC,EAAAA,gBAAgCC,EAAAA,wBAA2C,iBAGhFH,EAAAC,cAAC,iBAAkB,IAAIG,aAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/
|
|
1
|
+
<script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/f13cada5.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.43.7"</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/
|
|
1
|
+
<link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/f13cada5.js" crossorigin="anonymous">
|
|
@@ -56,14 +56,24 @@ export class TembaDate extends RapidElement {
|
|
|
56
56
|
else if (this.display === Display.relative) {
|
|
57
57
|
const minutes = Math.abs(this.datetime.diffNow().milliseconds / 1000 / 60);
|
|
58
58
|
if (minutes < 1) {
|
|
59
|
-
return html `<div
|
|
59
|
+
return html `<div
|
|
60
|
+
class="date"
|
|
61
|
+
title="${this.datetime.toLocaleString(Display.datetime)}"
|
|
62
|
+
>
|
|
63
|
+
just now
|
|
64
|
+
</div>`;
|
|
60
65
|
}
|
|
61
66
|
formatted = this.store.getShortDuration(this.datetime);
|
|
62
67
|
}
|
|
63
68
|
else if (this.display === Display.duration) {
|
|
64
69
|
const minutes = Math.abs(this.datetime.diffNow().milliseconds / 1000 / 60);
|
|
65
70
|
if (minutes < 1) {
|
|
66
|
-
return html `<div
|
|
71
|
+
return html `<div
|
|
72
|
+
class="date"
|
|
73
|
+
title="${this.datetime.toLocaleString(Display.datetime)}"
|
|
74
|
+
>
|
|
75
|
+
just now
|
|
76
|
+
</div>`;
|
|
67
77
|
}
|
|
68
78
|
formatted = this.store.getShortDuration(this.datetime);
|
|
69
79
|
}
|
|
@@ -73,7 +83,12 @@ export class TembaDate extends RapidElement {
|
|
|
73
83
|
else {
|
|
74
84
|
formatted = this.datetime.toLocaleString(Display[this.display]);
|
|
75
85
|
}
|
|
76
|
-
return html `<div
|
|
86
|
+
return html `<div
|
|
87
|
+
class="date"
|
|
88
|
+
title="${this.datetime.toLocaleString(Display.datetime)}"
|
|
89
|
+
>
|
|
90
|
+
${formatted}
|
|
91
|
+
</div>`;
|
|
77
92
|
}
|
|
78
93
|
}
|
|
79
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TembaDate.js","sourceRoot":"","sources":["../../../src/date/TembaDate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoC,MAAM,KAAK,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,QAAQ,CAAC,UAAU;IACzB,QAAQ,EAAE,QAAQ,CAAC,cAAc;IACjC,IAAI,EAAE,QAAQ,CAAC,WAAW;IAC1B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,OAAO;CACb,CAAC;AAEF,MAAM,OAAO,SAAU,SAAQ,YAAY;IAA3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,GAAG,IAAI,CAAC,GAAG,CACtB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CACjD,CAAC;gBACF,IAAI,OAAO,GAAG,CAAC,EAAE;oBACf,OAAO,IAAI,CAAA;;qBAEA,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;;;iBAGlD,CAAC;iBACT;gBACD,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACxD;iBAAM,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,GAAG,EAAE;gBACvC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;aACvD;iBAAM;gBACL,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACjE;YACD,OAAO,IAAI,CAAA;;iBAEA,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;;UAErD,SAAS;aACN,CAAC;SACT;IACH,CAAC;CACF;AAhFC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACb;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAC1B","sourcesContent":["import { css, html, PropertyValueMap, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { Store } from '../store/Store';\nimport { DateTime } from 'luxon';\n\nexport const Display = {\n date: DateTime.DATE_SHORT,\n datetime: DateTime.DATETIME_SHORT,\n time: DateTime.TIME_SIMPLE,\n timedate: 'timedate',\n duration: 'duration',\n relative: 'relative',\n day: 'LLL d',\n};\n\nexport class TembaDate extends RapidElement {\n static get styles() {\n return css`\n .date {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n `;\n }\n\n @property({ type: String })\n value: string;\n\n @property({ type: String })\n display = 'date';\n\n @property({ type: Object, attribute: false })\n datetime: DateTime;\n\n store: Store;\n\n protected firstUpdated(\n changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.firstUpdated(changedProperties);\n if (changedProperties.has('value')) {\n this.datetime = DateTime.fromISO(this.value);\n this.store = document.querySelector('temba-store');\n }\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n }\n\n public render(): TemplateResult {\n if (this.datetime && this.store) {\n this.datetime.setLocale(this.store.getLocale());\n\n let formatted = '';\n if (this.display === Display.timedate) {\n const hours = Math.abs(\n this.datetime.diffNow().milliseconds / 1000 / 60 / 60\n );\n if (hours < 24) {\n formatted = this.datetime.toLocaleString(Display.time);\n } else if (hours < 24 * 365) {\n formatted = this.datetime.toFormat(Display.day);\n } else {\n formatted = this.datetime.toLocaleString(Display.date);\n }\n } else if (this.display === Display.relative) {\n const minutes = Math.abs(\n this.datetime.diffNow().milliseconds / 1000 / 60\n );\n if (minutes < 1) {\n return html`<div\n class=\"date\"\n title=\"${this.datetime.toLocaleString(Display.datetime)}\"\n >\n just now\n </div>`;\n }\n\n formatted = this.store.getShortDuration(this.datetime);\n } else if (this.display === Display.duration) {\n const minutes = Math.abs(\n this.datetime.diffNow().milliseconds / 1000 / 60\n );\n if (minutes < 1) {\n return html`<div\n class=\"date\"\n title=\"${this.datetime.toLocaleString(Display.datetime)}\"\n >\n just now\n </div>`;\n }\n formatted = this.store.getShortDuration(this.datetime);\n } else if (this.display === Display.day) {\n formatted = this.datetime.toLocaleString(Display.day);\n } else {\n formatted = this.datetime.toLocaleString(Display[this.display]);\n }\n return html`<div\n class=\"date\"\n title=\"${this.datetime.toLocaleString(Display.datetime)}\"\n >\n ${formatted}\n </div>`;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
package/src/date/TembaDate.ts
CHANGED
|
@@ -72,7 +72,12 @@ export class TembaDate extends RapidElement {
|
|
|
72
72
|
this.datetime.diffNow().milliseconds / 1000 / 60
|
|
73
73
|
);
|
|
74
74
|
if (minutes < 1) {
|
|
75
|
-
return html`<div
|
|
75
|
+
return html`<div
|
|
76
|
+
class="date"
|
|
77
|
+
title="${this.datetime.toLocaleString(Display.datetime)}"
|
|
78
|
+
>
|
|
79
|
+
just now
|
|
80
|
+
</div>`;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
formatted = this.store.getShortDuration(this.datetime);
|
|
@@ -81,7 +86,12 @@ export class TembaDate extends RapidElement {
|
|
|
81
86
|
this.datetime.diffNow().milliseconds / 1000 / 60
|
|
82
87
|
);
|
|
83
88
|
if (minutes < 1) {
|
|
84
|
-
return html`<div
|
|
89
|
+
return html`<div
|
|
90
|
+
class="date"
|
|
91
|
+
title="${this.datetime.toLocaleString(Display.datetime)}"
|
|
92
|
+
>
|
|
93
|
+
just now
|
|
94
|
+
</div>`;
|
|
85
95
|
}
|
|
86
96
|
formatted = this.store.getShortDuration(this.datetime);
|
|
87
97
|
} else if (this.display === Display.day) {
|
|
@@ -89,7 +99,12 @@ export class TembaDate extends RapidElement {
|
|
|
89
99
|
} else {
|
|
90
100
|
formatted = this.datetime.toLocaleString(Display[this.display]);
|
|
91
101
|
}
|
|
92
|
-
return html`<div
|
|
102
|
+
return html`<div
|
|
103
|
+
class="date"
|
|
104
|
+
title="${this.datetime.toLocaleString(Display.datetime)}"
|
|
105
|
+
>
|
|
106
|
+
${formatted}
|
|
107
|
+
</div>`;
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
110
|
}
|