@nyaruka/temba-components 0.107.0 → 0.107.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.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,15 @@ 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.107.1](https://github.com/nyaruka/temba-components/compare/v0.107.0...v0.107.1)
8
+
9
+ - Fix widths for large pcts on progress bar [`#454`](https://github.com/nyaruka/temba-components/pull/454)
10
+ - Better handling for empty case [`25bcf3b`](https://github.com/nyaruka/temba-components/commit/25bcf3bdf76cc616f22d9bfc0f66dd6e18d91e5f)
11
+
7
12
  #### [v0.107.0](https://github.com/nyaruka/temba-components/compare/v0.106.0...v0.107.0)
8
13
 
14
+ > 14 September 2024
15
+
9
16
  - Add flow start progress [`#453`](https://github.com/nyaruka/temba-components/pull/453)
10
17
  - Calculate a naiive eta [`fc2d480`](https://github.com/nyaruka/temba-components/commit/fc2d480aba07bf5267844a0d370423893d03d009)
11
18
 
package/demo/index.html CHANGED
@@ -144,8 +144,6 @@
144
144
  </temba-dropdown>
145
145
 
146
146
  <div class="header">temba-components</div>
147
-
148
-
149
147
  <!--temba-image-picker name="avatar" label="Profile Picture" shape="circle"></temba-image-picker-->
150
148
  <!--temba-webchat channel="9e6b37a8-c649-48b3-92d1-dfa7c00b85dc"></temba-webchat-->
151
149
  <!-- temba-template-editor url="/static/api/templates.json" lang="eng" template="580b124f-32cb-4003-b9e5-9eb783e29101"
@@ -154,6 +152,7 @@
154
152
 
155
153
  <temba-tabs collapses index="0">
156
154
  <temba-tab name="Overview" icon="default">
155
+ <temba-progress style="margin-bottom:8px" total="100" current="25" eta="2030-09-17T07:00:00.000Z"></temba-progress>
157
156
  <div style="display:flex;flex-wrap: wrap;">
158
157
  <temba-checkbox label="Check this out" checked></temba-checkbox>
159
158
  <temba-select placeholder="Select a color" clearable>
@@ -7961,33 +7961,42 @@ const{I:gc}=rt,fc=()=>document.createComment(""),vc=(t,e,i)=>{const o=t._$AA.par
7961
7961
  >.
7962
7962
  </div></temba-alert
7963
7963
  >
7964
- </div>`:null}}t([ge({type:Number})],Ec.prototype,"backlogSize",void 0),t([ge({type:String})],Ec.prototype,"endpoint",void 0),t([ge({type:Object})],Ec.prototype,"firstFetch",void 0),t([ge({type:Object})],Ec.prototype,"lastFetch",void 0),t([ge({type:Number})],Ec.prototype,"fetches",void 0),t([ge({type:Number})],Ec.prototype,"msgsPerSecond",void 0),t([ge({type:Object})],Ec.prototype,"estimatedCompletionDate",void 0);class Tc extends ue{constructor(){super(...arguments),this.total=100,this.current=0,this.pct=0,this.done=!1,this.showEstimatedCompletion=!1}updated(t){t.has("eta")&&this.eta&&(this.estimatedCompletionDate=new Date(this.eta),this.showEstimatedCompletion=this.estimatedCompletionDate>new Date),t.has("current")&&(this.pct=Math.floor(Math.min(this.current/this.total*100,100)),this.done=this.pct>=100)}render(){return j`<div class="meter ${this.done?"done":""}">
7965
- <span class="complete" style="width: ${this.pct}%"></span>
7966
- <div class="incomplete"></div>
7967
- ${this.pct>=0||this.estimatedCompletionDate?j` <div class="etc">
7968
- ${this.estimatedCompletionDate?j`<temba-date
7964
+ </div>`:null}}t([ge({type:Number})],Ec.prototype,"backlogSize",void 0),t([ge({type:String})],Ec.prototype,"endpoint",void 0),t([ge({type:Object})],Ec.prototype,"firstFetch",void 0),t([ge({type:Object})],Ec.prototype,"lastFetch",void 0),t([ge({type:Number})],Ec.prototype,"fetches",void 0),t([ge({type:Number})],Ec.prototype,"msgsPerSecond",void 0),t([ge({type:Object})],Ec.prototype,"estimatedCompletionDate",void 0);class Tc extends ue{constructor(){super(...arguments),this.total=100,this.current=0,this.pct=0,this.done=!1,this.showEstimatedCompletion=!1,this.showPercentage=!1}updated(t){if(t.has("eta")&&this.eta&&(this.estimatedCompletionDate=new Date(this.eta),this.showEstimatedCompletion=this.estimatedCompletionDate>new Date),t.has("current")){const t=Math.floor(Math.min(this.current/this.total*100,100));Number.isNaN(t)?this.showPercentage=!1:(this.pct=t,this.showPercentage=!0),this.done=this.pct>=100}}render(){return j`<div class="wrapper">
7965
+ <div class="meter ${this.done?"done":""}">
7966
+ <span class="complete" style="flex-basis: ${this.pct}%"></span>
7967
+ <div class="incomplete"></div>
7968
+ </div>
7969
+
7970
+ ${this.showPercentage||this.showEstimatedCompletion?j`<div class="etc">
7971
+ ${this.estimatedCompletionDate&&this.showEstimatedCompletion&&!this.done?j`<temba-date
7969
7972
  value="${this.estimatedCompletionDate.toISOString()}"
7970
7973
  display="countdown"
7971
7974
  ></temba-date>`:j`${this.pct}%`}
7972
7975
  </div>`:null}
7973
7976
  </div>`}}Tc.styles=r`
7977
+ .wrapper {
7978
+ display: flex;
7979
+ box-sizing: content-box;
7980
+ background: #f1f1f1;
7981
+ border-radius: var(--curvature);
7982
+ box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05);
7983
+ }
7984
+
7974
7985
  .meter {
7986
+ flex-grow: 1;
7975
7987
  display: flex;
7976
7988
  box-sizing: content-box;
7977
- height: 8px;
7978
7989
  position: relative;
7979
- background: #f1f1f1;
7980
7990
  border-radius: var(--curvature);
7991
+ border-top-right-radius: 0;
7992
+ border-bottom-right-radius: 0;
7981
7993
  padding: 4px;
7982
- box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.05);
7994
+ min-height: 6px;
7983
7995
  }
7984
7996
  .meter > span {
7985
7997
  display: block;
7986
7998
  height: 100%;
7987
- border-top-right-radius: var(--curvature);
7988
- border-bottom-right-radius: var(--curvature);
7989
- border-top-left-radius: var(--curvature);
7990
- border-bottom-left-radius: var(--curvature);
7999
+ border-radius: var(--curvature);
7991
8000
  background-color: var(--color-primary-dark);
7992
8001
  background-image: linear-gradient(
7993
8002
  center bottom,
@@ -7997,7 +8006,9 @@ const{I:gc}=rt,fc=()=>document.createComment(""),vc=(t,e,i)=>{const o=t._$AA.par
7997
8006
 
7998
8007
  position: relative;
7999
8008
  overflow: hidden;
8009
+ min-width: 3px;
8000
8010
  }
8011
+
8001
8012
  .meter > span:after,
8002
8013
  .animate > span > span {
8003
8014
  content: '';
@@ -8049,17 +8060,14 @@ const{I:gc}=rt,fc=()=>document.createComment(""),vc=(t,e,i)=>{const o=t._$AA.par
8049
8060
 
8050
8061
  .etc {
8051
8062
  font-size: 0.7em;
8052
- padding: 4px;
8053
- padding-top: 1px;
8054
- padding-left: 8px;
8055
- padding-right: 8px;
8056
- margin-top: -4px;
8057
- margin-bottom: -4px;
8058
- margin-right: -4px;
8059
- margin-left: 0.5em;
8060
8063
  background: rgba(0, 0, 0, 0.07);
8061
8064
  font-weight: bold;
8062
8065
  white-space: nowrap;
8066
+ border-top-right-radius: var(--curvature);
8067
+ border-bottom-right-radius: var(--curvature);
8068
+ color: rgba(0, 0, 0, 0.5);
8069
+ align-self: center;
8070
+ padding: 2px 6px;
8063
8071
  }
8064
8072
 
8065
8073
  .meter.done > span:after,
@@ -8070,7 +8078,7 @@ const{I:gc}=rt,fc=()=>document.createComment(""),vc=(t,e,i)=>{const o=t._$AA.par
8070
8078
  .meter.done > span {
8071
8079
  background: rgb(var(--success-rgb));
8072
8080
  }
8073
- `,t([ge({type:Number})],Tc.prototype,"total",void 0),t([ge({type:Number})],Tc.prototype,"current",void 0),t([ge({type:Number})],Tc.prototype,"pct",void 0),t([ge({type:Boolean})],Tc.prototype,"done",void 0),t([ge({type:String})],Tc.prototype,"eta",void 0),t([ge({type:String,attribute:!1})],Tc.prototype,"estimatedCompletionDate",void 0),t([ge({type:Boolean})],Tc.prototype,"showEstimatedCompletion",void 0);class $c extends ue{constructor(){super(...arguments),this.refreshes=0}updated(t){super.updated(t),t.has("uuid")&&this.refresh()}refresh(){Wt(`/api/v2/flow_starts.json?uuid=${this.uuid}`).then((t=>{if(t.length>0){this.refreshes++;const e=t[0];this.started=e.progress.started,this.total=e.progress.total;const i=(new Date).getTime()-new Date(e.created_on).getTime(),o=this.started/(i/1e3);this.eta=new Date((new Date).getTime()+(this.total-this.started)/o*1e3).toISOString(),this.started<this.total&&setTimeout((()=>{this.refresh()}),Math.min(1e3*this.refreshes,6e4))}}))}render(){return j`<temba-progress
8081
+ `,t([ge({type:Number})],Tc.prototype,"total",void 0),t([ge({type:Number})],Tc.prototype,"current",void 0),t([ge({type:Number})],Tc.prototype,"pct",void 0),t([ge({type:Boolean})],Tc.prototype,"done",void 0),t([ge({type:String})],Tc.prototype,"eta",void 0),t([ge({type:String,attribute:!1})],Tc.prototype,"estimatedCompletionDate",void 0),t([ge({type:Boolean})],Tc.prototype,"showEstimatedCompletion",void 0),t([ge({type:Boolean})],Tc.prototype,"showPercentage",void 0);class $c extends ue{constructor(){super(...arguments),this.refreshes=0}updated(t){super.updated(t),t.has("uuid")&&this.refresh()}refresh(){Wt(`/api/v2/flow_starts.json?uuid=${this.uuid}`).then((t=>{if(t.length>0){this.refreshes++;const e=t[0];this.started=e.progress.started,this.total=e.progress.total;const i=(new Date).getTime()-new Date(e.created_on).getTime(),o=this.started/i,n=new Date((new Date).getTime()+(this.total-this.started)/o),s=new Date;s.setMonth(s.getMonth()+2),this.eta=n>s?null:n.toISOString(),this.started<this.total&&setTimeout((()=>{this.refresh()}),Math.min(1e3*this.refreshes,6e4))}}))}render(){return j`<temba-progress
8074
8082
  total=${this.total}
8075
8083
  current=${this.started}
8076
8084
  eta=${this.eta}