@nyaruka/temba-components 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/{8356cc91.js → 30636513.js} +2 -2
- package/dist/index.js +2 -2
- 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 +3 -3
- package/out-tsc/src/date/TembaDate.js.map +1 -1
- package/out-tsc/test/temba-date.test.js +3 -3
- package/out-tsc/test/temba-date.test.js.map +1 -1
- package/package.json +1 -1
- package/src/date/TembaDate.ts +3 -3
- package/test/temba-date.test.ts +3 -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.35.0](https://github.com/nyaruka/temba-components/compare/v0.34.0...v0.35.0)
|
|
8
|
+
|
|
9
|
+
- Switch isodate property to value [`#224`](https://github.com/nyaruka/temba-components/pull/224)
|
|
10
|
+
|
|
7
11
|
#### [v0.34.0](https://github.com/nyaruka/temba-components/compare/v0.33.5...v0.34.0)
|
|
8
12
|
|
|
13
|
+
> 2 December 2022
|
|
14
|
+
|
|
9
15
|
- Add temba-date component [`#223`](https://github.com/nyaruka/temba-components/pull/223)
|
|
10
16
|
- Bump decode-uri-component from 0.2.0 to 0.2.2 [`#222`](https://github.com/nyaruka/temba-components/pull/222)
|
|
11
17
|
- Update sample date [`320dd1a`](https://github.com/nyaruka/temba-components/commit/320dd1a9df0efb06177d837670469bbf9126d5ac)
|
|
@@ -5395,13 +5395,13 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
|
|
|
5395
5395
|
text-overflow: ellipsis;
|
|
5396
5396
|
white-space: nowrap;
|
|
5397
5397
|
}
|
|
5398
|
-
`}firstUpdated(t){super.firstUpdated(t),t.has("
|
|
5398
|
+
`}firstUpdated(t){super.firstUpdated(t),t.has("value")&&(this.datetime=Po.fromISO(this.value),this.store=document.querySelector("temba-store"))}connectedCallback(){super.connectedCallback()}render(){return this.datetime?this.display===Na.duration?P`<div class="date">
|
|
5399
5399
|
${this.store.getShortDuration(this.datetime)}
|
|
5400
5400
|
</div>`:P`
|
|
5401
5401
|
<div class="date">
|
|
5402
5402
|
${this.datetime.toLocaleString(Na[this.display])}
|
|
5403
5403
|
</div>
|
|
5404
|
-
`:null}}function Ba(t,e){window.customElements.get(t)||window.customElements.define(t,e)}t([it({type:String})],Ra.prototype,"
|
|
5404
|
+
`:null}}function Ba(t,e){window.customElements.get(t)||window.customElements.define(t,e)}t([it({type:String})],Ra.prototype,"value",void 0),t([it({type:String})],Ra.prototype,"display",void 0),t([it({type:Object,attribute:!1})],Ra.prototype,"datetime",void 0),Ba("temba-anchor",fa),Ba("temba-alert",oa),Ba("temba-store",Io),Ba("temba-textinput",pt),Ba("temba-datepicker",Ma),Ba("temba-date",Ra),Ba("temba-completion",Sr),Ba("temba-checkbox",rt),Ba("temba-select",kr),Ba("temba-options",Do),Ba("temba-loading",Lr),Ba("temba-button",Tr),Ba("temba-omnibox",ca),Ba("temba-tip",ua),Ba("temba-contact-name",_a),Ba("temba-contact-name-fetch",Aa),Ba("temba-contact-field",ka),Ba("temba-contact-fields",wa),Ba("temba-field-manager",Ia),Ba("temba-urn",xa),Ba("temba-field",$r),Ba("temba-dialog",Er),Ba("temba-modax",Cr),Ba("temba-charcount",Rr),Ba("temba-contact-history",ta),Ba("temba-contact-chat",Fr),Ba("temba-contact-details",na),Ba("temba-ticket-list",ia),Ba("temba-list",ea),Ba("temba-sortable-list",Da),Ba("temba-run-list",La),Ba("temba-flow-details",Oa),Ba("temba-label",ba),Ba("temba-menu",ma),Ba("temba-contact-search",sa),Ba("temba-icon",ra),Ba("temba-dropdown",ga),Ba("temba-tabs",va),Ba("temba-tab",ya),Ba("temba-contact-badges",class extends qr{static get styles(){return s`
|
|
5405
5405
|
temba-label {
|
|
5406
5406
|
margin: 0.3em;
|
|
5407
5407
|
}
|
package/dist/index.js
CHANGED
|
@@ -5395,13 +5395,13 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
|
|
|
5395
5395
|
text-overflow: ellipsis;
|
|
5396
5396
|
white-space: nowrap;
|
|
5397
5397
|
}
|
|
5398
|
-
`}firstUpdated(t){super.firstUpdated(t),t.has("
|
|
5398
|
+
`}firstUpdated(t){super.firstUpdated(t),t.has("value")&&(this.datetime=Po.fromISO(this.value),this.store=document.querySelector("temba-store"))}connectedCallback(){super.connectedCallback()}render(){return this.datetime?this.display===Na.duration?P`<div class="date">
|
|
5399
5399
|
${this.store.getShortDuration(this.datetime)}
|
|
5400
5400
|
</div>`:P`
|
|
5401
5401
|
<div class="date">
|
|
5402
5402
|
${this.datetime.toLocaleString(Na[this.display])}
|
|
5403
5403
|
</div>
|
|
5404
|
-
`:null}}function Ba(t,e){window.customElements.get(t)||window.customElements.define(t,e)}t([it({type:String})],Ra.prototype,"
|
|
5404
|
+
`:null}}function Ba(t,e){window.customElements.get(t)||window.customElements.define(t,e)}t([it({type:String})],Ra.prototype,"value",void 0),t([it({type:String})],Ra.prototype,"display",void 0),t([it({type:Object,attribute:!1})],Ra.prototype,"datetime",void 0),Ba("temba-anchor",fa),Ba("temba-alert",oa),Ba("temba-store",Io),Ba("temba-textinput",pt),Ba("temba-datepicker",Ma),Ba("temba-date",Ra),Ba("temba-completion",Sr),Ba("temba-checkbox",rt),Ba("temba-select",kr),Ba("temba-options",Do),Ba("temba-loading",Lr),Ba("temba-button",Tr),Ba("temba-omnibox",ca),Ba("temba-tip",ua),Ba("temba-contact-name",_a),Ba("temba-contact-name-fetch",Aa),Ba("temba-contact-field",ka),Ba("temba-contact-fields",wa),Ba("temba-field-manager",Ia),Ba("temba-urn",xa),Ba("temba-field",$r),Ba("temba-dialog",Er),Ba("temba-modax",Cr),Ba("temba-charcount",Rr),Ba("temba-contact-history",ta),Ba("temba-contact-chat",Fr),Ba("temba-contact-details",na),Ba("temba-ticket-list",ia),Ba("temba-list",ea),Ba("temba-sortable-list",Da),Ba("temba-run-list",La),Ba("temba-flow-details",Oa),Ba("temba-label",ba),Ba("temba-menu",ma),Ba("temba-contact-search",sa),Ba("temba-icon",ra),Ba("temba-dropdown",ga),Ba("temba-tabs",va),Ba("temba-tab",ya),Ba("temba-contact-badges",class extends qr{static get styles(){return s`
|
|
5405
5405
|
temba-label {
|
|
5406
5406
|
margin: 0.3em;
|
|
5407
5407
|
}
|
package/dist/sw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
if(!self.define){const e=e=>{"require"!==e&&(e+=".js");let r=Promise.resolve();return t[e]||(r=new Promise(async r=>{if("document"in self){const t=document.createElement("script");t.src=e,document.head.appendChild(t),t.onload=r}else importScripts(e),r()})),r.then(()=>{if(!t[e])throw new Error(`Module ${e} didn’t register its module`);return t[e]})},r=(r,t)=>{Promise.all(r.map(e)).then(e=>t(1===e.length?e[0]:e))},t={require:Promise.resolve(r)};self.define=(r,s,o)=>{t[r]||(t[r]=Promise.resolve().then(()=>{let t={};const n={uri:location.origin+r.slice(1)};return Promise.all(s.map(r=>{switch(r){case"exports":return t;case"module":return n;default:return e(r)}})).then(e=>{const r=o(...e);return t.default||(t.default=r),t})}))}}define("./sw.js",["./workbox-80efdfd1"],(function(e){"use strict";e.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"
|
|
1
|
+
if(!self.define){const e=e=>{"require"!==e&&(e+=".js");let r=Promise.resolve();return t[e]||(r=new Promise(async r=>{if("document"in self){const t=document.createElement("script");t.src=e,document.head.appendChild(t),t.onload=r}else importScripts(e),r()})),r.then(()=>{if(!t[e])throw new Error(`Module ${e} didn’t register its module`);return t[e]})},r=(r,t)=>{Promise.all(r.map(e)).then(e=>t(1===e.length?e[0]:e))},t={require:Promise.resolve(r)};self.define=(r,s,o)=>{t[r]||(t[r]=Promise.resolve().then(()=>{let t={};const n={uri:location.origin+r.slice(1)};return Promise.all(s.map(r=>{switch(r){case"exports":return t;case"module":return n;default:return e(r)}})).then(e=>{const r=o(...e);return t.default||(t.default=r),t})}))}}define("./sw.js",["./workbox-80efdfd1"],(function(e){"use strict";e.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"30636513.js",revision:"f0228dea8e39ca60c84fd2515a2e7a0f"},{url:"templates/components-body.html",revision:"b847e68b5d5ac399344547345ee0f983"},{url:"templates/components-head.html",revision:"c9ad0856fe13b2c1566ba69edc379e7a"}],{}),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/93e60788f1f21f76af846e5a456458b5/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 {skipWaiting as workbox_core_skipWaiting} from '/home/runner/work/temba-components/temba-components/node_modules/workbox-core/skipWaiting.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\nworkbox_core_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\": \"30636513.js\",\n \"revision\": \"f0228dea8e39ca60c84fd2515a2e7a0f\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"b847e68b5d5ac399344547345ee0f983\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"c9ad0856fe13b2c1566ba69edc379e7a\"\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":["url","revision","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","workbox_strategies_CacheFirst"],"mappings":"k1BAmCoC,CAClC,CACEA,IAAO,cACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,oCAEd,CACED,IAAO,iCACPC,SAAY,qCAEb,oBAE2B,IAAIC,kBAAgCC,0BAA2C,iCAG/E,iBAAkB,IAAIC,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/30636513.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.35.0"</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/30636513.js" crossorigin="anonymous">
|
|
@@ -25,8 +25,8 @@ export class TembaDate extends RapidElement {
|
|
|
25
25
|
}
|
|
26
26
|
firstUpdated(changedProperties) {
|
|
27
27
|
super.firstUpdated(changedProperties);
|
|
28
|
-
if (changedProperties.has('
|
|
29
|
-
this.datetime = DateTime.fromISO(this.
|
|
28
|
+
if (changedProperties.has('value')) {
|
|
29
|
+
this.datetime = DateTime.fromISO(this.value);
|
|
30
30
|
this.store = document.querySelector('temba-store');
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -53,7 +53,7 @@ export class TembaDate extends RapidElement {
|
|
|
53
53
|
}
|
|
54
54
|
__decorate([
|
|
55
55
|
property({ type: String })
|
|
56
|
-
], TembaDate.prototype, "
|
|
56
|
+
], TembaDate.prototype, "value", void 0);
|
|
57
57
|
__decorate([
|
|
58
58
|
property({ type: String })
|
|
59
59
|
], TembaDate.prototype, "display", void 0);
|
|
@@ -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,gBAAgB,CAAC;AAC1C,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,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,OAAO,SAAU,SAAQ,YAAY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AC;IAC5B,CAAC;IAEM,MAAM;QACX,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,QAAQ,EAAE;gBACrC,OAAO,IAAI,CAAA;YACP,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;eACvC,CAAC;aACT;iBAAM;gBACL,OAAO,IAAI,CAAA;;cAEL,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;;SAExD,CAAC;aACH;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxCC;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';\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 duration: 'duration',\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) {\n if (this.display === Display.duration) {\n return html`<div class=\"date\">\n ${this.store.getShortDuration(this.datetime)}\n </div>`;\n } else {\n return html`\n <div class=\"date\">\n ${this.datetime.toLocaleString(Display[this.display])}\n </div>\n `;\n }\n }\n return null;\n }\n}\n"]}
|
|
@@ -17,14 +17,14 @@ describe('temba-date', () => {
|
|
|
17
17
|
loadStore();
|
|
18
18
|
});
|
|
19
19
|
it('renders default', async () => {
|
|
20
|
-
const date = await getDate({
|
|
20
|
+
const date = await getDate({ value: '1978-11-18T02:22:00.000000-07:00' });
|
|
21
21
|
const dateString = date.shadowRoot.querySelector('.date').innerText;
|
|
22
22
|
await assertScreenshot('date/date', getClip(date));
|
|
23
23
|
expect(dateString).to.equal('11/18/1978');
|
|
24
24
|
});
|
|
25
25
|
it('renders duration', async () => {
|
|
26
26
|
const date = await getDate({
|
|
27
|
-
|
|
27
|
+
value: '1978-11-18T02:22:00.000000-07:00',
|
|
28
28
|
display: 'duration',
|
|
29
29
|
});
|
|
30
30
|
const dateString = date.shadowRoot.querySelector('.date').innerText;
|
|
@@ -33,7 +33,7 @@ describe('temba-date', () => {
|
|
|
33
33
|
});
|
|
34
34
|
it('renders datetime', async () => {
|
|
35
35
|
const date = await getDate({
|
|
36
|
-
|
|
36
|
+
value: '1978-11-18T02:22:00.000000-07:00',
|
|
37
37
|
display: 'datetime',
|
|
38
38
|
});
|
|
39
39
|
const dateString = date.shadowRoot.querySelector('.date').innerText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temba-date.test.js","sourceRoot":"","sources":["../../test/temba-date.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,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E;QAChC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;YACzB,KAAK,EAAE,kCAAkC;YACzC,OAAO,EAAE,UAAU;SACpB,CAAC,CAAC;QACH,MAAM,UAAU,GACd,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CACtC,CAAC,SAAS,CAAC;QAEZ,MAAM,gBAAgB,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as sinon from 'sinon';\nimport { TembaDate } from '../src/date/TembaDate';\nimport {\n assertScreenshot,\n getClip,\n getComponent,\n loadStore,\n} from './utils.test';\nimport { DateTime } from 'luxon';\nimport { expect } from '@open-wc/testing';\n\nconst TAG = 'temba-date';\n\nexport const getDate = async (attrs: any = {}) => {\n attrs['width'] = 100;\n return (await getComponent(TAG, attrs)) as TembaDate;\n};\n\n// mock the current time\nconst now = DateTime.fromISO('2022-12-02T21:00:00.000000-07:00');\nsinon.replace(DateTime, 'now', () => {\n return now;\n});\n\ndescribe('temba-date', () => {\n beforeEach(() => {\n loadStore();\n });\n\n it('renders default', async () => {\n const date = await getDate({ value: '1978-11-18T02:22:00.000000-07:00' });\n const dateString = (\n date.shadowRoot.querySelector('.date') as HTMLDivElement\n ).innerText;\n\n await assertScreenshot('date/date', getClip(date));\n expect(dateString).to.equal('11/18/1978');\n });\n\n it('renders duration', async () => {\n const date = await getDate({\n value: '1978-11-18T02:22:00.000000-07:00',\n display: 'duration',\n });\n const dateString = (\n date.shadowRoot.querySelector('.date') as HTMLDivElement\n ).innerText;\n\n await assertScreenshot('date/duration', getClip(date));\n expect(dateString).to.equal('44 years');\n });\n\n it('renders datetime', async () => {\n const date = await getDate({\n value: '1978-11-18T02:22:00.000000-07:00',\n display: 'datetime',\n });\n const dateString = (\n date.shadowRoot.querySelector('.date') as HTMLDivElement\n ).innerText;\n\n await assertScreenshot('date/datetime', getClip(date));\n expect(dateString).to.equal('11/18/1978, 9:22 AM');\n });\n});\n"]}
|
package/package.json
CHANGED
package/src/date/TembaDate.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class TembaDate extends RapidElement {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
@property({ type: String })
|
|
26
|
-
|
|
26
|
+
value: string;
|
|
27
27
|
|
|
28
28
|
@property({ type: String })
|
|
29
29
|
display = 'date';
|
|
@@ -37,8 +37,8 @@ export class TembaDate extends RapidElement {
|
|
|
37
37
|
changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>
|
|
38
38
|
): void {
|
|
39
39
|
super.firstUpdated(changedProperties);
|
|
40
|
-
if (changedProperties.has('
|
|
41
|
-
this.datetime = DateTime.fromISO(this.
|
|
40
|
+
if (changedProperties.has('value')) {
|
|
41
|
+
this.datetime = DateTime.fromISO(this.value);
|
|
42
42
|
this.store = document.querySelector('temba-store');
|
|
43
43
|
}
|
|
44
44
|
}
|
package/test/temba-date.test.ts
CHANGED
|
@@ -28,7 +28,7 @@ describe('temba-date', () => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('renders default', async () => {
|
|
31
|
-
const date = await getDate({
|
|
31
|
+
const date = await getDate({ value: '1978-11-18T02:22:00.000000-07:00' });
|
|
32
32
|
const dateString = (
|
|
33
33
|
date.shadowRoot.querySelector('.date') as HTMLDivElement
|
|
34
34
|
).innerText;
|
|
@@ -39,7 +39,7 @@ describe('temba-date', () => {
|
|
|
39
39
|
|
|
40
40
|
it('renders duration', async () => {
|
|
41
41
|
const date = await getDate({
|
|
42
|
-
|
|
42
|
+
value: '1978-11-18T02:22:00.000000-07:00',
|
|
43
43
|
display: 'duration',
|
|
44
44
|
});
|
|
45
45
|
const dateString = (
|
|
@@ -52,7 +52,7 @@ describe('temba-date', () => {
|
|
|
52
52
|
|
|
53
53
|
it('renders datetime', async () => {
|
|
54
54
|
const date = await getDate({
|
|
55
|
-
|
|
55
|
+
value: '1978-11-18T02:22:00.000000-07:00',
|
|
56
56
|
display: 'datetime',
|
|
57
57
|
});
|
|
58
58
|
const dateString = (
|