@nyaruka/temba-components 0.62.1 → 0.62.2

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.62.2](https://github.com/nyaruka/temba-components/compare/v0.62.1...v0.62.2)
8
+
9
+ - Bump @babel/traverse from 7.20.5 to 7.23.2 [`#375`](https://github.com/nyaruka/temba-components/pull/375)
10
+ - Fix maxlength and focus issues for text controls [`#376`](https://github.com/nyaruka/temba-components/pull/376)
11
+
7
12
  #### [v0.62.1](https://github.com/nyaruka/temba-components/compare/v0.62.0...v0.62.1)
8
13
 
14
+ > 17 October 2023
15
+
9
16
  - Show urns properly for urn change events [`#374`](https://github.com/nyaruka/temba-components/pull/374)
10
17
 
11
18
  #### [v0.62.0](https://github.com/nyaruka/temba-components/compare/v0.61.1...v0.62.0)
@@ -171,7 +171,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
171
171
  .grow-wrap textarea {
172
172
  margin-left: -100%;
173
173
  }
174
- `}constructor(){super(),this.placeholder="",this.loading=!0,this.submitOnEnter=!0,this.autogrow=!1,this.counterElement=null,this.cursorStart=-1,this.cursorEnd=-1}firstUpdated(t){if(super.firstUpdated(t),this.inputElement=this.shadowRoot.querySelector(".textinput"),t.has("counter")){let t=this.getParentModax();t&&(t=t.shadowRoot),t||(t=document),this.counterElement=t.querySelector(this.counter),this.counterElement.text=this.value}}updated(t){if(super.updated(t),t.has("value")){if(this.fireEvent("change"),this.textarea&&this.autogrow){this.shadowRoot.querySelector(".grow-wrap > div").innerText=this.value+String.fromCharCode(10)}this.cursorStart>-1&&this.cursorEnd>-1&&(this.inputElement.setSelectionRange(this.cursorStart,this.cursorEnd),this.cursorStart=-1,this.cursorEnd=-1)}}getDisplayValue(){return this.inputElement.value}handleClear(t){t.stopPropagation(),t.preventDefault(),this.value=null}updateValue(t){const e=this.inputElement.selectionStart,i=this.inputElement.selectionEnd,n=this.sanitizeGSM(t);n!==t&&(this.cursorStart=e,this.cursorEnd=i),this.value=n,this.textarea&&(this.inputElement.value=this.value),this.counterElement&&(this.counterElement.text=t)}sanitizeGSM(t){return this.gsm?(t=>t?t.replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/[\u2013\u2014]/g,"-").replace(/\u2026/g,"...").replace(/\u2002/g," "):t)(t):t}handleChange(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("change"))}handleContainerClick(){this.disabled||this.inputElement&&this.inputElement.click()}handleContainerFocus(){this.disabled||this.inputElement&&(this.inputElement.focus(),this.inputElement.setSelectionRange(this.value.length,this.value.length))}handleInput(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("input"))}serializeValue(t){return t}getParentModax(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("TEMBA-MODAX"==t.tagName)return t}}getParentForm(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("FORM"===t.tagName)return t}}click(){super.click(),this.handleContainerClick()}focus(){super.focus(),this.handleContainerFocus()}render(){const t={height:""+(this.textarea?"100%":"auto")},e=this.clearable&&this.inputElement&&this.inputElement.value?D`<temba-icon
174
+ `}constructor(){super(),this.placeholder="",this.loading=!0,this.submitOnEnter=!0,this.autogrow=!1,this.counterElement=null,this.cursorStart=-1,this.cursorEnd=-1}firstUpdated(t){if(super.firstUpdated(t),this.inputElement=this.shadowRoot.querySelector(".textinput"),t.has("counter")){let t=this.getParentModax();t&&(t=t.shadowRoot),t||(t=document),this.counterElement=t.querySelector(this.counter),this.counterElement.text=this.value}}updated(t){if(super.updated(t),t.has("value")){if(this.fireEvent("change"),this.textarea&&this.autogrow){this.shadowRoot.querySelector(".grow-wrap > div").innerText=this.value+String.fromCharCode(10)}this.cursorStart>-1&&this.cursorEnd>-1&&(this.inputElement.setSelectionRange(this.cursorStart,this.cursorEnd),this.cursorStart=-1,this.cursorEnd=-1)}}getDisplayValue(){return this.inputElement.value}handleClear(t){t.stopPropagation(),t.preventDefault(),this.value=null}updateValue(t){const e=this.inputElement.selectionStart,i=this.inputElement.selectionEnd,n=this.sanitizeGSM(t);n!==t&&(this.cursorStart=e,this.cursorEnd=i),this.value=n,this.textarea&&(this.inputElement.value=this.value),this.counterElement&&(this.counterElement.text=t)}sanitizeGSM(t){return this.gsm?(t=>t?t.replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/[\u2013\u2014]/g,"-").replace(/\u2026/g,"...").replace(/\u2002/g," "):t)(t):t}handleChange(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("change"))}handleContainerClick(){this.disabled||this.inputElement&&this.inputElement.click()}handleContainerFocus(){this.disabled||this.inputElement&&this.inputElement.focus()}handleInput(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("input"))}serializeValue(t){return t}getParentModax(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("TEMBA-MODAX"==t.tagName)return t}}getParentForm(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("FORM"===t.tagName)return t}}click(){super.click(),this.handleContainerClick()}focus(){super.focus(),this.handleContainerFocus()}render(){const t={height:""+(this.textarea?"100%":"auto")},e=this.clearable&&this.inputElement&&this.inputElement.value?D`<temba-icon
175
175
  name="x"
176
176
  class="clear-icon"
177
177
  @click=${this.handleClear}
@@ -890,7 +890,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
890
890
 
891
891
  </temba-field>
892
892
 
893
- `}}t([ct({type:Boolean})],Ra.prototype,"multi",void 0),t([ct({type:Boolean})],Ra.prototype,"searchOnFocus",void 0),t([ct({type:String})],Ra.prototype,"placeholder",void 0),t([ct()],Ra.prototype,"name",void 0),t([ct()],Ra.prototype,"endpoint",void 0),t([ct({type:String})],Ra.prototype,"nameKey",void 0),t([ct({type:String})],Ra.prototype,"valueKey",void 0),t([ct({attribute:!1})],Ra.prototype,"currentFunction",void 0),t([ct({type:String})],Ra.prototype,"queryParam",void 0),t([ct({type:String})],Ra.prototype,"input",void 0),t([ct({type:Array})],Ra.prototype,"visibleOptions",void 0),t([ct({type:Array})],Ra.prototype,"completionOptions",void 0),t([ct({type:Number})],Ra.prototype,"quietMillis",void 0),t([ct({type:Boolean})],Ra.prototype,"fetching",void 0),t([ct({type:Boolean})],Ra.prototype,"searchable",void 0),t([ct({type:String})],Ra.prototype,"expressions",void 0),t([ct({type:Boolean})],Ra.prototype,"cache",void 0),t([ct({type:String})],Ra.prototype,"cacheKey",void 0),t([ct({type:Boolean})],Ra.prototype,"focused",void 0),t([ct({type:Boolean})],Ra.prototype,"disabled",void 0),t([ct({attribute:!1})],Ra.prototype,"selectedIndex",void 0),t([ct({type:Number})],Ra.prototype,"cursorIndex",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorElement",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorExpressions",void 0),t([ct({type:Object})],Ra.prototype,"anchorPosition",void 0),t([ct({type:Boolean})],Ra.prototype,"tags",void 0),t([ct({type:Boolean,attribute:"space_select"})],Ra.prototype,"spaceSelect",void 0),t([ct({type:Boolean})],Ra.prototype,"jsonValue",void 0),t([ct({type:Boolean})],Ra.prototype,"hideErrors",void 0),t([ct({type:Boolean})],Ra.prototype,"clearable",void 0),t([ct({type:String})],Ra.prototype,"flavor",void 0),t([ct({type:String,attribute:"info_text"})],Ra.prototype,"infoText",void 0),t([ct({type:Array})],Ra.prototype,"values",void 0),t([ct({type:Object})],Ra.prototype,"selection",void 0),t([ct({attribute:!1})],Ra.prototype,"getName",void 0),t([ct({attribute:!1})],Ra.prototype,"isMatch",void 0),t([ct({attribute:!1})],Ra.prototype,"getValue",void 0),t([ct({type:Number,attribute:"option-width"})],Ra.prototype,"optionWidth",void 0),t([ct({type:Boolean,attribute:"anchor-right"})],Ra.prototype,"anchorRight",void 0),t([ct({attribute:!1})],Ra.prototype,"shouldExclude",void 0),t([ct({attribute:!1})],Ra.prototype,"sortFunction",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOption",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionName",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionDetail",void 0),t([ct({attribute:!1})],Ra.prototype,"renderSelectedItem",void 0),t([ct({attribute:!1})],Ra.prototype,"createArbitraryOption",void 0),t([ct({attribute:!1})],Ra.prototype,"getOptions",void 0),t([ct({attribute:!1})],Ra.prototype,"isComplete",void 0),t([ct({type:Array,attribute:"options"})],Ra.prototype,"staticOptions",void 0);class Ba extends ut{constructor(){super(...arguments),this.maxLength=10,this.submitOnEnter=!1,this.anchorPosition={left:0,top:0},this.placeholder="",this.options=[],this.name="",this.value="",this.autogrow=!1}static get styles(){return r`
893
+ `}}t([ct({type:Boolean})],Ra.prototype,"multi",void 0),t([ct({type:Boolean})],Ra.prototype,"searchOnFocus",void 0),t([ct({type:String})],Ra.prototype,"placeholder",void 0),t([ct()],Ra.prototype,"name",void 0),t([ct()],Ra.prototype,"endpoint",void 0),t([ct({type:String})],Ra.prototype,"nameKey",void 0),t([ct({type:String})],Ra.prototype,"valueKey",void 0),t([ct({attribute:!1})],Ra.prototype,"currentFunction",void 0),t([ct({type:String})],Ra.prototype,"queryParam",void 0),t([ct({type:String})],Ra.prototype,"input",void 0),t([ct({type:Array})],Ra.prototype,"visibleOptions",void 0),t([ct({type:Array})],Ra.prototype,"completionOptions",void 0),t([ct({type:Number})],Ra.prototype,"quietMillis",void 0),t([ct({type:Boolean})],Ra.prototype,"fetching",void 0),t([ct({type:Boolean})],Ra.prototype,"searchable",void 0),t([ct({type:String})],Ra.prototype,"expressions",void 0),t([ct({type:Boolean})],Ra.prototype,"cache",void 0),t([ct({type:String})],Ra.prototype,"cacheKey",void 0),t([ct({type:Boolean})],Ra.prototype,"focused",void 0),t([ct({type:Boolean})],Ra.prototype,"disabled",void 0),t([ct({attribute:!1})],Ra.prototype,"selectedIndex",void 0),t([ct({type:Number})],Ra.prototype,"cursorIndex",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorElement",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorExpressions",void 0),t([ct({type:Object})],Ra.prototype,"anchorPosition",void 0),t([ct({type:Boolean})],Ra.prototype,"tags",void 0),t([ct({type:Boolean,attribute:"space_select"})],Ra.prototype,"spaceSelect",void 0),t([ct({type:Boolean})],Ra.prototype,"jsonValue",void 0),t([ct({type:Boolean})],Ra.prototype,"hideErrors",void 0),t([ct({type:Boolean})],Ra.prototype,"clearable",void 0),t([ct({type:String})],Ra.prototype,"flavor",void 0),t([ct({type:String,attribute:"info_text"})],Ra.prototype,"infoText",void 0),t([ct({type:Array})],Ra.prototype,"values",void 0),t([ct({type:Object})],Ra.prototype,"selection",void 0),t([ct({attribute:!1})],Ra.prototype,"getName",void 0),t([ct({attribute:!1})],Ra.prototype,"isMatch",void 0),t([ct({attribute:!1})],Ra.prototype,"getValue",void 0),t([ct({type:Number,attribute:"option-width"})],Ra.prototype,"optionWidth",void 0),t([ct({type:Boolean,attribute:"anchor-right"})],Ra.prototype,"anchorRight",void 0),t([ct({attribute:!1})],Ra.prototype,"shouldExclude",void 0),t([ct({attribute:!1})],Ra.prototype,"sortFunction",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOption",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionName",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionDetail",void 0),t([ct({attribute:!1})],Ra.prototype,"renderSelectedItem",void 0),t([ct({attribute:!1})],Ra.prototype,"createArbitraryOption",void 0),t([ct({attribute:!1})],Ra.prototype,"getOptions",void 0),t([ct({attribute:!1})],Ra.prototype,"isComplete",void 0),t([ct({type:Array,attribute:"options"})],Ra.prototype,"staticOptions",void 0);class Ba extends ut{constructor(){super(...arguments),this.submitOnEnter=!1,this.anchorPosition={left:0,top:0},this.placeholder="",this.options=[],this.name="",this.value="",this.autogrow=!1}static get styles(){return r`
894
894
  :host {
895
895
  display: block;
896
896
  }
@@ -964,7 +964,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
964
964
  @click=${this.handleClick}
965
965
  @input=${this.handleInput}
966
966
  @blur=${this.handleOptionCanceled}
967
- maxlength=${this.maxLength}
967
+ maxlength="${ft(this.maxLength)}"
968
968
  .value=${this.value}
969
969
  ?autogrow=${this.autogrow}
970
970
  ?textarea=${this.textarea}
package/dist/index.js CHANGED
@@ -171,7 +171,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
171
171
  .grow-wrap textarea {
172
172
  margin-left: -100%;
173
173
  }
174
- `}constructor(){super(),this.placeholder="",this.loading=!0,this.submitOnEnter=!0,this.autogrow=!1,this.counterElement=null,this.cursorStart=-1,this.cursorEnd=-1}firstUpdated(t){if(super.firstUpdated(t),this.inputElement=this.shadowRoot.querySelector(".textinput"),t.has("counter")){let t=this.getParentModax();t&&(t=t.shadowRoot),t||(t=document),this.counterElement=t.querySelector(this.counter),this.counterElement.text=this.value}}updated(t){if(super.updated(t),t.has("value")){if(this.fireEvent("change"),this.textarea&&this.autogrow){this.shadowRoot.querySelector(".grow-wrap > div").innerText=this.value+String.fromCharCode(10)}this.cursorStart>-1&&this.cursorEnd>-1&&(this.inputElement.setSelectionRange(this.cursorStart,this.cursorEnd),this.cursorStart=-1,this.cursorEnd=-1)}}getDisplayValue(){return this.inputElement.value}handleClear(t){t.stopPropagation(),t.preventDefault(),this.value=null}updateValue(t){const e=this.inputElement.selectionStart,i=this.inputElement.selectionEnd,n=this.sanitizeGSM(t);n!==t&&(this.cursorStart=e,this.cursorEnd=i),this.value=n,this.textarea&&(this.inputElement.value=this.value),this.counterElement&&(this.counterElement.text=t)}sanitizeGSM(t){return this.gsm?(t=>t?t.replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/[\u2013\u2014]/g,"-").replace(/\u2026/g,"...").replace(/\u2002/g," "):t)(t):t}handleChange(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("change"))}handleContainerClick(){this.disabled||this.inputElement&&this.inputElement.click()}handleContainerFocus(){this.disabled||this.inputElement&&(this.inputElement.focus(),this.inputElement.setSelectionRange(this.value.length,this.value.length))}handleInput(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("input"))}serializeValue(t){return t}getParentModax(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("TEMBA-MODAX"==t.tagName)return t}}getParentForm(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("FORM"===t.tagName)return t}}click(){super.click(),this.handleContainerClick()}focus(){super.focus(),this.handleContainerFocus()}render(){const t={height:""+(this.textarea?"100%":"auto")},e=this.clearable&&this.inputElement&&this.inputElement.value?D`<temba-icon
174
+ `}constructor(){super(),this.placeholder="",this.loading=!0,this.submitOnEnter=!0,this.autogrow=!1,this.counterElement=null,this.cursorStart=-1,this.cursorEnd=-1}firstUpdated(t){if(super.firstUpdated(t),this.inputElement=this.shadowRoot.querySelector(".textinput"),t.has("counter")){let t=this.getParentModax();t&&(t=t.shadowRoot),t||(t=document),this.counterElement=t.querySelector(this.counter),this.counterElement.text=this.value}}updated(t){if(super.updated(t),t.has("value")){if(this.fireEvent("change"),this.textarea&&this.autogrow){this.shadowRoot.querySelector(".grow-wrap > div").innerText=this.value+String.fromCharCode(10)}this.cursorStart>-1&&this.cursorEnd>-1&&(this.inputElement.setSelectionRange(this.cursorStart,this.cursorEnd),this.cursorStart=-1,this.cursorEnd=-1)}}getDisplayValue(){return this.inputElement.value}handleClear(t){t.stopPropagation(),t.preventDefault(),this.value=null}updateValue(t){const e=this.inputElement.selectionStart,i=this.inputElement.selectionEnd,n=this.sanitizeGSM(t);n!==t&&(this.cursorStart=e,this.cursorEnd=i),this.value=n,this.textarea&&(this.inputElement.value=this.value),this.counterElement&&(this.counterElement.text=t)}sanitizeGSM(t){return this.gsm?(t=>t?t.replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/[\u2013\u2014]/g,"-").replace(/\u2026/g,"...").replace(/\u2002/g," "):t)(t):t}handleChange(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("change"))}handleContainerClick(){this.disabled||this.inputElement&&this.inputElement.click()}handleContainerFocus(){this.disabled||this.inputElement&&this.inputElement.focus()}handleInput(t){this.disabled||(this.updateValue(t.target.value),this.fireEvent("input"))}serializeValue(t){return t}getParentModax(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("TEMBA-MODAX"==t.tagName)return t}}getParentForm(){let t=this;for(;t;){if(t=t.parentElement?t.parentElement:t.getRootNode().host,!t)return null;if("FORM"===t.tagName)return t}}click(){super.click(),this.handleContainerClick()}focus(){super.focus(),this.handleContainerFocus()}render(){const t={height:""+(this.textarea?"100%":"auto")},e=this.clearable&&this.inputElement&&this.inputElement.value?D`<temba-icon
175
175
  name="x"
176
176
  class="clear-icon"
177
177
  @click=${this.handleClear}
@@ -890,7 +890,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
890
890
 
891
891
  </temba-field>
892
892
 
893
- `}}t([ct({type:Boolean})],Ra.prototype,"multi",void 0),t([ct({type:Boolean})],Ra.prototype,"searchOnFocus",void 0),t([ct({type:String})],Ra.prototype,"placeholder",void 0),t([ct()],Ra.prototype,"name",void 0),t([ct()],Ra.prototype,"endpoint",void 0),t([ct({type:String})],Ra.prototype,"nameKey",void 0),t([ct({type:String})],Ra.prototype,"valueKey",void 0),t([ct({attribute:!1})],Ra.prototype,"currentFunction",void 0),t([ct({type:String})],Ra.prototype,"queryParam",void 0),t([ct({type:String})],Ra.prototype,"input",void 0),t([ct({type:Array})],Ra.prototype,"visibleOptions",void 0),t([ct({type:Array})],Ra.prototype,"completionOptions",void 0),t([ct({type:Number})],Ra.prototype,"quietMillis",void 0),t([ct({type:Boolean})],Ra.prototype,"fetching",void 0),t([ct({type:Boolean})],Ra.prototype,"searchable",void 0),t([ct({type:String})],Ra.prototype,"expressions",void 0),t([ct({type:Boolean})],Ra.prototype,"cache",void 0),t([ct({type:String})],Ra.prototype,"cacheKey",void 0),t([ct({type:Boolean})],Ra.prototype,"focused",void 0),t([ct({type:Boolean})],Ra.prototype,"disabled",void 0),t([ct({attribute:!1})],Ra.prototype,"selectedIndex",void 0),t([ct({type:Number})],Ra.prototype,"cursorIndex",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorElement",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorExpressions",void 0),t([ct({type:Object})],Ra.prototype,"anchorPosition",void 0),t([ct({type:Boolean})],Ra.prototype,"tags",void 0),t([ct({type:Boolean,attribute:"space_select"})],Ra.prototype,"spaceSelect",void 0),t([ct({type:Boolean})],Ra.prototype,"jsonValue",void 0),t([ct({type:Boolean})],Ra.prototype,"hideErrors",void 0),t([ct({type:Boolean})],Ra.prototype,"clearable",void 0),t([ct({type:String})],Ra.prototype,"flavor",void 0),t([ct({type:String,attribute:"info_text"})],Ra.prototype,"infoText",void 0),t([ct({type:Array})],Ra.prototype,"values",void 0),t([ct({type:Object})],Ra.prototype,"selection",void 0),t([ct({attribute:!1})],Ra.prototype,"getName",void 0),t([ct({attribute:!1})],Ra.prototype,"isMatch",void 0),t([ct({attribute:!1})],Ra.prototype,"getValue",void 0),t([ct({type:Number,attribute:"option-width"})],Ra.prototype,"optionWidth",void 0),t([ct({type:Boolean,attribute:"anchor-right"})],Ra.prototype,"anchorRight",void 0),t([ct({attribute:!1})],Ra.prototype,"shouldExclude",void 0),t([ct({attribute:!1})],Ra.prototype,"sortFunction",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOption",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionName",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionDetail",void 0),t([ct({attribute:!1})],Ra.prototype,"renderSelectedItem",void 0),t([ct({attribute:!1})],Ra.prototype,"createArbitraryOption",void 0),t([ct({attribute:!1})],Ra.prototype,"getOptions",void 0),t([ct({attribute:!1})],Ra.prototype,"isComplete",void 0),t([ct({type:Array,attribute:"options"})],Ra.prototype,"staticOptions",void 0);class Ba extends ut{constructor(){super(...arguments),this.maxLength=10,this.submitOnEnter=!1,this.anchorPosition={left:0,top:0},this.placeholder="",this.options=[],this.name="",this.value="",this.autogrow=!1}static get styles(){return r`
893
+ `}}t([ct({type:Boolean})],Ra.prototype,"multi",void 0),t([ct({type:Boolean})],Ra.prototype,"searchOnFocus",void 0),t([ct({type:String})],Ra.prototype,"placeholder",void 0),t([ct()],Ra.prototype,"name",void 0),t([ct()],Ra.prototype,"endpoint",void 0),t([ct({type:String})],Ra.prototype,"nameKey",void 0),t([ct({type:String})],Ra.prototype,"valueKey",void 0),t([ct({attribute:!1})],Ra.prototype,"currentFunction",void 0),t([ct({type:String})],Ra.prototype,"queryParam",void 0),t([ct({type:String})],Ra.prototype,"input",void 0),t([ct({type:Array})],Ra.prototype,"visibleOptions",void 0),t([ct({type:Array})],Ra.prototype,"completionOptions",void 0),t([ct({type:Number})],Ra.prototype,"quietMillis",void 0),t([ct({type:Boolean})],Ra.prototype,"fetching",void 0),t([ct({type:Boolean})],Ra.prototype,"searchable",void 0),t([ct({type:String})],Ra.prototype,"expressions",void 0),t([ct({type:Boolean})],Ra.prototype,"cache",void 0),t([ct({type:String})],Ra.prototype,"cacheKey",void 0),t([ct({type:Boolean})],Ra.prototype,"focused",void 0),t([ct({type:Boolean})],Ra.prototype,"disabled",void 0),t([ct({attribute:!1})],Ra.prototype,"selectedIndex",void 0),t([ct({type:Number})],Ra.prototype,"cursorIndex",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorElement",void 0),t([ct({attribute:!1})],Ra.prototype,"anchorExpressions",void 0),t([ct({type:Object})],Ra.prototype,"anchorPosition",void 0),t([ct({type:Boolean})],Ra.prototype,"tags",void 0),t([ct({type:Boolean,attribute:"space_select"})],Ra.prototype,"spaceSelect",void 0),t([ct({type:Boolean})],Ra.prototype,"jsonValue",void 0),t([ct({type:Boolean})],Ra.prototype,"hideErrors",void 0),t([ct({type:Boolean})],Ra.prototype,"clearable",void 0),t([ct({type:String})],Ra.prototype,"flavor",void 0),t([ct({type:String,attribute:"info_text"})],Ra.prototype,"infoText",void 0),t([ct({type:Array})],Ra.prototype,"values",void 0),t([ct({type:Object})],Ra.prototype,"selection",void 0),t([ct({attribute:!1})],Ra.prototype,"getName",void 0),t([ct({attribute:!1})],Ra.prototype,"isMatch",void 0),t([ct({attribute:!1})],Ra.prototype,"getValue",void 0),t([ct({type:Number,attribute:"option-width"})],Ra.prototype,"optionWidth",void 0),t([ct({type:Boolean,attribute:"anchor-right"})],Ra.prototype,"anchorRight",void 0),t([ct({attribute:!1})],Ra.prototype,"shouldExclude",void 0),t([ct({attribute:!1})],Ra.prototype,"sortFunction",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOption",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionName",void 0),t([ct({attribute:!1})],Ra.prototype,"renderOptionDetail",void 0),t([ct({attribute:!1})],Ra.prototype,"renderSelectedItem",void 0),t([ct({attribute:!1})],Ra.prototype,"createArbitraryOption",void 0),t([ct({attribute:!1})],Ra.prototype,"getOptions",void 0),t([ct({attribute:!1})],Ra.prototype,"isComplete",void 0),t([ct({type:Array,attribute:"options"})],Ra.prototype,"staticOptions",void 0);class Ba extends ut{constructor(){super(...arguments),this.submitOnEnter=!1,this.anchorPosition={left:0,top:0},this.placeholder="",this.options=[],this.name="",this.value="",this.autogrow=!1}static get styles(){return r`
894
894
  :host {
895
895
  display: block;
896
896
  }
@@ -964,7 +964,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro
964
964
  @click=${this.handleClick}
965
965
  @input=${this.handleInput}
966
966
  @blur=${this.handleOptionCanceled}
967
- maxlength=${this.maxLength}
967
+ maxlength="${ft(this.maxLength)}"
968
968
  .value=${this.value}
969
969
  ?autogrow=${this.autogrow}
970
970
  ?textarea=${this.textarea}
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 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:"420b0ee3.js",revision:"def66b91c3c8186112c57a989c277d2e"},{url:"templates/components-body.html",revision:"8fcd994ac0edf4f5a7c78f8efbea8546"},{url:"templates/components-head.html",revision:"2e535e3e376bd4b74f4aa2ce282f0c91"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute("polyfills/*.js",new e.CacheFirst,"GET")}));
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 l=e=>o(e,i),f={module:{uri:i},exports:r,require:l};t[i]=Promise.all(n.map((e=>f[e]||l(e)))).then((e=>(s(...e),r)))}}define(["./workbox-919adfb7"],(function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"ba373419.js",revision:"88421555f5a2222e2fe8514c9ba753f3"},{url:"templates/components-body.html",revision:"d74eb48eabb280da1565480e9f9f44e3"},{url:"templates/components-head.html",revision:"313abaf5a1bfc93de83ca4fbe570cf4d"}],{}),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/585c4ed47428dd52e2fa6fee1265159a/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/workspaces/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/workspaces/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/workspaces/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/workspaces/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/workspaces/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/workspaces/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\": \"420b0ee3.js\",\n \"revision\": \"def66b91c3c8186112c57a989c277d2e\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"8fcd994ac0edf4f5a7c78f8efbea8546\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"2e535e3e376bd4b74f4aa2ce282f0c91\"\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
+ {"version":3,"file":"sw.js","sources":["../../tmp/f59bec91ff2c0df5301807d0456e4162/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/workspaces/temba-components/node_modules/workbox-routing/registerRoute.mjs';\nimport {CacheFirst as workbox_strategies_CacheFirst} from '/workspaces/temba-components/node_modules/workbox-strategies/CacheFirst.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/workspaces/temba-components/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/workspaces/temba-components/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/workspaces/temba-components/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/workspaces/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\": \"ba373419.js\",\n \"revision\": \"88421555f5a2222e2fe8514c9ba753f3\"\n },\n {\n \"url\": \"templates/components-body.html\",\n \"revision\": \"d74eb48eabb280da1565480e9f9f44e3\"\n },\n {\n \"url\": \"templates/components-head.html\",\n \"revision\": \"313abaf5a1bfc93de83ca4fbe570cf4d\"\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/420b0ee3.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.62.1"</script>
1
+ <script type="module" src="{{STATIC_URL}}@nyaruka/temba-components/dist/ba373419.js"></script><script>window.TEMBA_COMPONENTS_VERSION="0.62.2"</script>
@@ -1 +1 @@
1
- <link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/420b0ee3.js" crossorigin="anonymous">
1
+ <link rel="modulepreload" href="{{STATIC_URL}}@nyaruka/temba-components/dist/ba373419.js" crossorigin="anonymous">
@@ -12,7 +12,6 @@ import { msg } from '@lit/localize';
12
12
  export class Completion extends FormElement {
13
13
  constructor() {
14
14
  super(...arguments);
15
- this.maxLength = 10;
16
15
  this.submitOnEnter = false;
17
16
  this.anchorPosition = { left: 0, top: 0 };
18
17
  this.placeholder = '';
@@ -197,7 +196,7 @@ export class Completion extends FormElement {
197
196
  @click=${this.handleClick}
198
197
  @input=${this.handleInput}
199
198
  @blur=${this.handleOptionCanceled}
200
- maxlength=${this.maxLength}
199
+ maxlength="${ifDefined(this.maxLength)}"
201
200
  .value=${this.value}
202
201
  ?autogrow=${this.autogrow}
203
202
  ?textarea=${this.textarea}
@@ -1 +1 @@
1
- {"version":3,"file":"Completion.js","sourceRoot":"","sources":["../../../src/completion/Completion.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MA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AAI,EAAE,OAAO,EAAE,CAAC;4CACX","sourcesContent":["import { TemplateResult, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit-html/directives/if-defined.js';\nimport { TextInput } from '../textinput/TextInput';\nimport {\n renderCompletionOption,\n updateInputElementWithCompletion,\n executeCompletionQuery,\n} from './helpers';\n\nimport { FormElement } from '../FormElement';\nimport { CompletionOption, Position } from '../interfaces';\nimport { Store } from '../store/Store';\nimport { styleMap } from 'lit-html/directives/style-map.js';\nimport { msg } from '@lit/localize';\n\n/**\n * Completion is a text input that handles excellent completion options in a popup\n */\nexport class Completion extends FormElement {\n static get styles() {\n return css`\n :host {\n display: block;\n }\n\n temba-options {\n --widget-box-shadow-focused: 0 0 4px rgba(0, 0, 0, 0.15);\n --color-focus: #e6e6e6;\n }\n\n .comp-container {\n position: relative;\n height: 100%;\n }\n\n #anchor {\n /* background: rgba(132, 40, 158, .1); */\n position: absolute;\n visibility: hidden;\n width: 250px;\n height: 20px;\n }\n\n .fn-marker {\n font-weight: bold;\n font-size: 42px;\n }\n\n .option-slot {\n background: #fff;\n }\n\n .current-fn {\n padding: 10px;\n margin: 5px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n border-radius: var(--curvature-widget);\n font-size: 90%;\n }\n\n .footer {\n padding: 5px 10px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n font-size: 80%;\n border-bottom-left-radius: var(--curvature-widget);\n border-bottom-right-radius: var(--curvature-widget);\n }\n\n code {\n background: rgba(0, 0, 0, 0.1);\n padding: 1px 5px;\n border-radius: var(--curvature);\n }\n `;\n }\n\n @property({ type: Number })\n maxLength = 10;\n\n @property({ type: Boolean })\n session: boolean;\n\n @property({ type: Boolean })\n submitOnEnter = false;\n\n @property({ type: Object })\n anchorPosition: Position = { left: 0, top: 0 };\n\n @property({ attribute: false })\n currentFunction: CompletionOption;\n\n @property({ type: String })\n placeholder = '';\n\n @property({ attribute: false })\n textInputElement: TextInput;\n\n @property({ attribute: false })\n anchorElement: HTMLDivElement;\n\n @property({ type: Array })\n options: any[] = [];\n\n @property({ type: String })\n name = '';\n\n @property({ type: String })\n value = '';\n\n @property({ type: Boolean })\n textarea: boolean;\n\n @property({ type: Boolean })\n gsm: boolean;\n\n @property({ type: String })\n counter: string;\n\n @property({ type: Boolean })\n autogrow = false;\n\n private hiddenElement: HTMLInputElement;\n private query: string;\n\n public firstUpdated() {\n this.textInputElement = this.shadowRoot.querySelector(\n 'temba-textinput'\n ) as TextInput;\n this.anchorElement = this.shadowRoot.querySelector('#anchor');\n\n // create our hidden container so it gets included in our host element's form\n this.hiddenElement = document.createElement('input');\n this.hiddenElement.setAttribute('type', 'hidden');\n this.hiddenElement.setAttribute('name', this.getAttribute('name'));\n this.hiddenElement.setAttribute('value', this.getAttribute('value') || '');\n this.appendChild(this.hiddenElement);\n }\n\n private handleKeyUp(evt: KeyboardEvent) {\n // if we have options, ignore keys that are meant for them\n if (this.options && this.options.length > 0) {\n if (evt.key === 'ArrowUp' || evt.key === 'ArrowDown') {\n return;\n }\n\n if (evt.ctrlKey) {\n if (evt.key === 'n' || evt.key === 'p') {\n return;\n }\n }\n\n if (\n evt.key === 'Enter' ||\n evt.key === 'Escape' ||\n evt.key === 'Tab' ||\n evt.key.startsWith('Control')\n ) {\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n\n this.executeQuery(evt.currentTarget as TextInput);\n }\n }\n\n public hasVisibleOptions() {\n return this.options.length > 0;\n }\n\n private executeQuery(ele: TextInput) {\n const store: Store = document.querySelector('temba-store');\n if (!ele.inputElement) {\n return;\n }\n const result = executeCompletionQuery(\n ele.inputElement,\n store,\n this.session\n );\n\n this.query = result.query;\n this.options = result.options;\n this.anchorPosition = result.anchorPosition;\n }\n\n private handleClick(evt: MouseEvent) {\n this.executeQuery(evt.currentTarget as TextInput);\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if our cursor changed, lets make sure our scrollbox is showing it\n if (changedProperties.has('value')) {\n this.hiddenElement.setAttribute('value', this.value);\n }\n }\n\n private handleInput(evt: KeyboardEvent) {\n const ele = evt.currentTarget as TextInput;\n this.executeQuery(ele);\n this.value = ele.inputElement.value;\n this.fireEvent('change');\n }\n\n private handleOptionCanceled() {\n // delay in case we are actively selecting\n window.setTimeout(() => {\n this.options = [];\n this.query = '';\n }, 100);\n }\n\n private handleOptionSelection(evt: CustomEvent) {\n const option = evt.detail.selected as CompletionOption;\n const tabbed = evt.detail.tabbed;\n\n updateInputElementWithCompletion(\n this.query,\n this.textInputElement.inputElement,\n option\n );\n this.query = '';\n this.options = [];\n\n if (tabbed) {\n this.executeQuery(this.textInputElement);\n }\n }\n\n public click() {\n super.click();\n const input = this.shadowRoot.querySelector('temba-textinput') as TextInput;\n if (input) {\n input.click();\n }\n }\n\n public focus() {\n super.focus();\n const input = this.shadowRoot.querySelector('temba-textinput') as TextInput;\n if (input) {\n input.focus();\n }\n }\n\n public render(): TemplateResult {\n const anchorStyles = this.anchorPosition\n ? {\n top: `${this.anchorPosition.top}px`,\n left: `${this.anchorPosition.left}px`,\n }\n : {};\n\n return html`\n <temba-field\n name=${this.name}\n .label=${this.label}\n .helpText=${this.helpText}\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n >\n <div class=\"comp-container\">\n <div id=\"anchor\" style=${styleMap(anchorStyles)}></div>\n <temba-textinput\n name=${this.name}\n placeholder=${this.placeholder}\n gsm=${this.gsm}\n counter=${ifDefined(this.counter)}\n @keyup=${this.handleKeyUp}\n @click=${this.handleClick}\n @input=${this.handleInput}\n @blur=${this.handleOptionCanceled}\n maxlength=${this.maxLength}\n .value=${this.value}\n ?autogrow=${this.autogrow}\n ?textarea=${this.textarea}\n ?submitOnEnter=${this.submitOnEnter}\n >\n </temba-textinput>\n <temba-options\n @temba-selection=${this.handleOptionSelection}\n @temba-canceled=${this.handleOptionCanceled}\n .renderOption=${renderCompletionOption}\n .anchorTo=${this.anchorElement}\n .options=${this.options}\n ?visible=${this.options && this.options.length > 0}\n >\n ${this.currentFunction\n ? html`\n <div class=\"current-fn\">\n ${renderCompletionOption(this.currentFunction, true)}\n </div>\n `\n : null}\n <div class=\"footer\">${msg('Tab to complete, enter to select')}</div>\n </temba-options>\n </div>\n </temba-field>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"Completion.js","sourceRoot":"","sources":["../../../src/completion/Completion.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IAA3C;;QAmEE,kBAAa,GAAG,KAAK,CAAC;QAGtB,mBAAc,GAAa,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;QAM/C,gBAAW,GAAG,EAAE,CAAC;QASjB,YAAO,GAAU,EAAE,CAAC;QAGpB,SAAI,GAAG,EAAE,CAAC;QAGV,UAAK,GAAG,EAAE,CAAC;QAYX,aAAQ,GAAG,KAAK,CAAC;IAuLnB,CAAC;IA7RC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuDT,CAAC;IACJ,CAAC;IAkDM,YAAY;QACjB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CACnD,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,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDACG;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACV;AAGjB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACH;AAG5B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACD;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CACN;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAChB;AAGX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACX;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACX","sourcesContent":["import { TemplateResult, css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit-html/directives/if-defined.js';\nimport { TextInput } from '../textinput/TextInput';\nimport {\n renderCompletionOption,\n updateInputElementWithCompletion,\n executeCompletionQuery,\n} from './helpers';\n\nimport { FormElement } from '../FormElement';\nimport { CompletionOption, Position } from '../interfaces';\nimport { Store } from '../store/Store';\nimport { styleMap } from 'lit-html/directives/style-map.js';\nimport { msg } from '@lit/localize';\n\n/**\n * Completion is a text input that handles excellent completion options in a popup\n */\nexport class Completion extends FormElement {\n static get styles() {\n return css`\n :host {\n display: block;\n }\n\n temba-options {\n --widget-box-shadow-focused: 0 0 4px rgba(0, 0, 0, 0.15);\n --color-focus: #e6e6e6;\n }\n\n .comp-container {\n position: relative;\n height: 100%;\n }\n\n #anchor {\n /* background: rgba(132, 40, 158, .1); */\n position: absolute;\n visibility: hidden;\n width: 250px;\n height: 20px;\n }\n\n .fn-marker {\n font-weight: bold;\n font-size: 42px;\n }\n\n .option-slot {\n background: #fff;\n }\n\n .current-fn {\n padding: 10px;\n margin: 5px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n border-radius: var(--curvature-widget);\n font-size: 90%;\n }\n\n .footer {\n padding: 5px 10px;\n background: var(--color-primary-light);\n color: rgba(0, 0, 0, 0.5);\n font-size: 80%;\n border-bottom-left-radius: var(--curvature-widget);\n border-bottom-right-radius: var(--curvature-widget);\n }\n\n code {\n background: rgba(0, 0, 0, 0.1);\n padding: 1px 5px;\n border-radius: var(--curvature);\n }\n `;\n }\n\n @property({ type: Number })\n maxLength: number;\n\n @property({ type: Boolean })\n session: boolean;\n\n @property({ type: Boolean })\n submitOnEnter = false;\n\n @property({ type: Object })\n anchorPosition: Position = { left: 0, top: 0 };\n\n @property({ attribute: false })\n currentFunction: CompletionOption;\n\n @property({ type: String })\n placeholder = '';\n\n @property({ attribute: false })\n textInputElement: TextInput;\n\n @property({ attribute: false })\n anchorElement: HTMLDivElement;\n\n @property({ type: Array })\n options: any[] = [];\n\n @property({ type: String })\n name = '';\n\n @property({ type: String })\n value = '';\n\n @property({ type: Boolean })\n textarea: boolean;\n\n @property({ type: Boolean })\n gsm: boolean;\n\n @property({ type: String })\n counter: string;\n\n @property({ type: Boolean })\n autogrow = false;\n\n private hiddenElement: HTMLInputElement;\n private query: string;\n\n public firstUpdated() {\n this.textInputElement = this.shadowRoot.querySelector(\n 'temba-textinput'\n ) as TextInput;\n this.anchorElement = this.shadowRoot.querySelector('#anchor');\n\n // create our hidden container so it gets included in our host element's form\n this.hiddenElement = document.createElement('input');\n this.hiddenElement.setAttribute('type', 'hidden');\n this.hiddenElement.setAttribute('name', this.getAttribute('name'));\n this.hiddenElement.setAttribute('value', this.getAttribute('value') || '');\n this.appendChild(this.hiddenElement);\n }\n\n private handleKeyUp(evt: KeyboardEvent) {\n // if we have options, ignore keys that are meant for them\n if (this.options && this.options.length > 0) {\n if (evt.key === 'ArrowUp' || evt.key === 'ArrowDown') {\n return;\n }\n\n if (evt.ctrlKey) {\n if (evt.key === 'n' || evt.key === 'p') {\n return;\n }\n }\n\n if (\n evt.key === 'Enter' ||\n evt.key === 'Escape' ||\n evt.key === 'Tab' ||\n evt.key.startsWith('Control')\n ) {\n evt.stopPropagation();\n evt.preventDefault();\n return;\n }\n\n this.executeQuery(evt.currentTarget as TextInput);\n }\n }\n\n public hasVisibleOptions() {\n return this.options.length > 0;\n }\n\n private executeQuery(ele: TextInput) {\n const store: Store = document.querySelector('temba-store');\n if (!ele.inputElement) {\n return;\n }\n const result = executeCompletionQuery(\n ele.inputElement,\n store,\n this.session\n );\n\n this.query = result.query;\n this.options = result.options;\n this.anchorPosition = result.anchorPosition;\n }\n\n private handleClick(evt: MouseEvent) {\n this.executeQuery(evt.currentTarget as TextInput);\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n // if our cursor changed, lets make sure our scrollbox is showing it\n if (changedProperties.has('value')) {\n this.hiddenElement.setAttribute('value', this.value);\n }\n }\n\n private handleInput(evt: KeyboardEvent) {\n const ele = evt.currentTarget as TextInput;\n this.executeQuery(ele);\n this.value = ele.inputElement.value;\n this.fireEvent('change');\n }\n\n private handleOptionCanceled() {\n // delay in case we are actively selecting\n window.setTimeout(() => {\n this.options = [];\n this.query = '';\n }, 100);\n }\n\n private handleOptionSelection(evt: CustomEvent) {\n const option = evt.detail.selected as CompletionOption;\n const tabbed = evt.detail.tabbed;\n\n updateInputElementWithCompletion(\n this.query,\n this.textInputElement.inputElement,\n option\n );\n this.query = '';\n this.options = [];\n\n if (tabbed) {\n this.executeQuery(this.textInputElement);\n }\n }\n\n public click() {\n super.click();\n const input = this.shadowRoot.querySelector('temba-textinput') as TextInput;\n if (input) {\n input.click();\n }\n }\n\n public focus() {\n super.focus();\n const input = this.shadowRoot.querySelector('temba-textinput') as TextInput;\n if (input) {\n input.focus();\n }\n }\n\n public render(): TemplateResult {\n const anchorStyles = this.anchorPosition\n ? {\n top: `${this.anchorPosition.top}px`,\n left: `${this.anchorPosition.left}px`,\n }\n : {};\n\n return html`\n <temba-field\n name=${this.name}\n .label=${this.label}\n .helpText=${this.helpText}\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n >\n <div class=\"comp-container\">\n <div id=\"anchor\" style=${styleMap(anchorStyles)}></div>\n <temba-textinput\n name=${this.name}\n placeholder=${this.placeholder}\n gsm=${this.gsm}\n counter=${ifDefined(this.counter)}\n @keyup=${this.handleKeyUp}\n @click=${this.handleClick}\n @input=${this.handleInput}\n @blur=${this.handleOptionCanceled}\n maxlength=\"${ifDefined(this.maxLength)}\"\n .value=${this.value}\n ?autogrow=${this.autogrow}\n ?textarea=${this.textarea}\n ?submitOnEnter=${this.submitOnEnter}\n >\n </temba-textinput>\n <temba-options\n @temba-selection=${this.handleOptionSelection}\n @temba-canceled=${this.handleOptionCanceled}\n .renderOption=${renderCompletionOption}\n .anchorTo=${this.anchorElement}\n .options=${this.options}\n ?visible=${this.options && this.options.length > 0}\n >\n ${this.currentFunction\n ? html`\n <div class=\"current-fn\">\n ${renderCompletionOption(this.currentFunction, true)}\n </div>\n `\n : null}\n <div class=\"footer\">${msg('Tab to complete, enter to select')}</div>\n </temba-options>\n </div>\n </temba-field>\n `;\n }\n}\n"]}
@@ -200,7 +200,6 @@ export class TextInput extends FormElement {
200
200
  }
201
201
  if (this.inputElement) {
202
202
  this.inputElement.focus();
203
- this.inputElement.setSelectionRange(this.value.length, this.value.length);
204
203
  }
205
204
  }
206
205
  handleInput(update) {
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../src/textinput/TextInput.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAA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AAI,CAAC,UAAU;qBAChB,IAAI,CAAC,SAAS;oBACf,IAAI,CAAC,QAAQ;;;;kBAIf,QAAQ,CAAC,cAAc,CAAC;mBACvB,IAAI,CAAC,oBAAoB;;;YAGhC,KAAK,IAAI,KAAK;;;;KAIrB,CAAC;IACJ,CAAC;CACF;AA/UC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CACX;AAIhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACP;AAGrB;IADC,QAAQ,EAAE;yCACC;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACX","sourcesContent":["import { TemplateResult, html, css } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit-html/directives/if-defined.js';\nimport { styleMap } from 'lit-html/directives/style-map.js';\nimport { FormElement } from '../FormElement';\nimport { Modax } from '../dialog/Modax';\nimport { sanitize } from './helpers';\nimport { CharCount } from '../charcount/CharCount';\n\nexport class TextInput extends FormElement {\n static get styles() {\n return css`\n .input-container {\n border-radius: var(--curvature-widget);\n cursor: var(--input-cursor);\n background: var(--color-widget-bg);\n border: 1px solid var(--color-widget-border);\n transition: all ease-in-out var(--transition-speed);\n display: flex;\n flex-direction: row;\n align-items: stretch;\n box-shadow: var(--widget-box-shadow);\n caret-color: var(--input-caret);\n }\n\n .clear-icon {\n --icon-color: var(--color-text-dark-secondary);\n cursor: pointer;\n margin: auto;\n padding-right: 10px;\n line-height: 1;\n }\n\n .clear-icon:hover {\n --icon-color: var(--color-text-dark);\n }\n\n .hidden {\n visibility: hidden;\n position: absolute;\n }\n\n .input-container:focus-within {\n border-color: var(--color-focus);\n background: var(--color-widget-bg-focused);\n box-shadow: var(--widget-box-shadow-focused);\n position: relative;\n }\n\n .input-container:hover {\n }\n\n textarea {\n height: var(--textarea-height);\n }\n\n .textinput {\n padding: var(--temba-textinput-padding);\n border: none;\n flex: 1;\n margin: 0;\n background: none;\n background-color: transparent;\n color: var(--color-widget-text);\n font-family: var(--font-family);\n font-size: var(--temba-textinput-font-size);\n line-height: normal;\n cursor: var(--input-cursor);\n resize: none;\n font-weight: 300;\n width: 100%;\n }\n\n .textinput:focus {\n outline: none;\n box-shadow: none;\n cursor: text;\n color: var(--color-widget-text-focused, var(--color-widget-text));\n }\n\n .textinput::placeholder {\n color: var(--color-placeholder);\n font-weight: 300;\n }\n\n .grow-wrap {\n display: flex;\n align-items: stretch;\n width: 100%;\n }\n\n .grow-wrap > div {\n border: 0px solid green;\n width: 100%;\n padding: var(--temba-textinput-padding);\n flex: 1;\n margin: 0;\n background: none;\n color: var(--color-widget-text);\n font-family: var(--font-family);\n font-size: var(--temba-textinput-font-size);\n line-height: normal;\n cursor: text;\n resize: none;\n font-weight: 300;\n width: 100%;\n visibility: hidden;\n word-break: break-word;\n }\n\n .grow-wrap textarea {\n margin-left: -100%;\n }\n `;\n }\n\n @property({ type: Boolean })\n textarea: boolean;\n\n @property({ type: String })\n placeholder = '';\n\n @property({ type: Boolean })\n password: boolean;\n\n @property({ type: Number })\n maxlength: number;\n\n @property({ type: Object })\n inputElement: HTMLInputElement;\n\n @property({ type: Boolean })\n clearable: boolean;\n\n @property({ type: Boolean })\n gsm: boolean;\n\n @property({ type: String })\n counter: string;\n\n // if we are still loading\n @property({ type: Boolean })\n loading = true;\n\n @property({ type: Boolean })\n submitOnEnter = true;\n\n @property()\n onBlur: any;\n\n @property({ type: Boolean })\n autogrow = false;\n\n counterElement: CharCount = null;\n cursorStart = -1;\n cursorEnd = -1;\n\n public constructor() {\n super();\n }\n\n public firstUpdated(changes: Map<string, any>) {\n super.firstUpdated(changes);\n\n this.inputElement = this.shadowRoot.querySelector('.textinput');\n\n if (changes.has('counter')) {\n let root = this.getParentModax() as any;\n if (root) {\n root = root.shadowRoot;\n }\n if (!root) {\n root = document;\n }\n this.counterElement = root.querySelector(this.counter);\n this.counterElement.text = this.value;\n }\n }\n\n public updated(changes: Map<string, any>) {\n super.updated(changes);\n\n if (changes.has('value')) {\n this.fireEvent('change');\n\n if (this.textarea && this.autogrow) {\n const autogrow = this.shadowRoot.querySelector(\n '.grow-wrap > div'\n ) as HTMLDivElement;\n autogrow.innerText = this.value + String.fromCharCode(10);\n }\n\n if (this.cursorStart > -1 && this.cursorEnd > -1) {\n this.inputElement.setSelectionRange(this.cursorStart, this.cursorEnd);\n this.cursorStart = -1;\n this.cursorEnd = -1;\n }\n }\n }\n\n public getDisplayValue() {\n return this.inputElement.value;\n }\n\n private handleClear(event: any): void {\n event.stopPropagation();\n event.preventDefault();\n this.value = null;\n }\n\n private updateValue(value: string): void {\n const cursorStart = this.inputElement.selectionStart;\n const cursorEnd = this.inputElement.selectionEnd;\n\n const sanitized = this.sanitizeGSM(value);\n\n if (sanitized !== value) {\n this.cursorStart = cursorStart;\n this.cursorEnd = cursorEnd;\n }\n\n this.value = sanitized;\n\n if (this.textarea) {\n this.inputElement.value = this.value;\n }\n\n if (this.counterElement) {\n this.counterElement.text = value;\n }\n }\n\n private sanitizeGSM(text: string): string {\n return this.gsm ? sanitize(text) : text;\n }\n\n private handleChange(update: any): void {\n if (this.disabled) {\n return;\n }\n this.updateValue(update.target.value);\n this.fireEvent('change');\n }\n\n private handleContainerClick(): void {\n if (this.disabled) {\n return;\n }\n if (this.inputElement) {\n this.inputElement.click();\n }\n }\n\n private handleContainerFocus(): void {\n if (this.disabled) {\n return;\n }\n if (this.inputElement) {\n this.inputElement.focus();\n this.inputElement.setSelectionRange(this.value.length, this.value.length);\n }\n }\n\n private handleInput(update: any): void {\n if (this.disabled) {\n return;\n }\n\n this.updateValue(update.target.value);\n this.fireEvent('input');\n }\n\n /** we just return the value since it should be a string */\n public serializeValue(value: any): string {\n return value;\n }\n\n public getParentModax(): Modax {\n let parent = this as HTMLElement;\n\n while (parent) {\n if (parent.parentElement) {\n parent = parent.parentElement;\n } else {\n parent = (parent as any).getRootNode().host;\n }\n\n if (!parent) {\n return null;\n }\n\n if (parent.tagName == 'TEMBA-MODAX') {\n return parent as Modax;\n }\n }\n }\n\n public getParentForm(): HTMLFormElement {\n let parent = this as HTMLElement;\n\n while (parent) {\n if (parent.parentElement) {\n parent = parent.parentElement;\n } else {\n parent = (parent as any).getRootNode().host;\n }\n\n if (!parent) {\n return null;\n }\n\n if (parent.tagName === 'FORM') {\n return parent as HTMLFormElement;\n }\n }\n }\n\n public click(): void {\n super.click();\n this.handleContainerClick();\n }\n\n public focus(): void {\n super.focus();\n this.handleContainerFocus();\n }\n\n // TODO make this a formelement and have contactsearch set the root\n public render(): TemplateResult {\n const containerStyle = {\n height: `${this.textarea ? '100%' : 'auto'}`,\n };\n\n const clear =\n this.clearable && this.inputElement && this.inputElement.value\n ? html`<temba-icon\n name=\"x\"\n class=\"clear-icon\"\n @click=${this.handleClear}\n />`\n : null;\n\n let input = html`\n <input\n class=\"textinput\"\n name=${this.name}\n type=\"${this.password ? 'password' : 'text'}\"\n maxlength=\"${ifDefined(this.maxlength)}\"\n @change=${this.handleChange}\n @input=${this.handleInput}\n @blur=${this.blur}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const input = this;\n\n if (this.submitOnEnter) {\n const parentModax = input.getParentModax();\n const parentForm = !parentModax ? input.getParentForm() : null;\n\n // if we don't have something to submit then bail\n if (!parentModax && !parentForm) {\n return false;\n }\n\n // don't submit disabled forms on enter\n if (parentModax && parentModax.disabled) {\n return false;\n }\n\n input.blur();\n\n // look for a form to submit\n window.setTimeout(function () {\n // first, look for a modax that contains us\n const modax = input.getParentModax();\n if (modax) {\n input.blur();\n\n modax.submit();\n } else {\n // otherwise, just look for a vanilla submit button\n const form = input.getParentForm();\n\n if (form) {\n const submitButton = form.querySelector(\n \"input[type='submit']\"\n ) as HTMLInputElement;\n if (submitButton) {\n submitButton.click();\n } else {\n form.submit();\n }\n }\n }\n }, 10);\n // this is needed for firefox, would be nice to\n // find a way to do this with a callback instead\n }\n }\n }}\n placeholder=${this.placeholder}\n .value=${this.value}\n .disabled=${this.disabled}\n />\n `;\n\n if (this.textarea) {\n input = html`\n <textarea\n class=\"textinput\"\n name=${this.name}\n maxlength=\"${ifDefined(this.maxlength)}\"\n placeholder=${this.placeholder}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @blur=${this.blur}\n .value=${this.value}\n .disabled=${this.disabled}\n ></textarea>\n `;\n\n if (this.autogrow) {\n input = html` <div class=\"grow-wrap\">\n <div></div>\n ${input}\n </div>`;\n }\n }\n\n return html`\n <temba-field\n name=${this.name}\n .label=\"${this.label}\"\n .helpText=\"${this.helpText}\"\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n .hideLabel=${this.hideLabel}\n .disabled=${this.disabled}\n >\n <div\n class=\"input-container\"\n style=${styleMap(containerStyle)}\n @click=${this.handleContainerClick}\n >\n <slot name=\"prefix\"></slot>\n ${input} ${clear}\n <slot></slot>\n </div>\n </temba-field>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../src/textinput/TextInput.ts"],"names":[],"mappings":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AI,CAAC,SAAS;oBACf,IAAI,CAAC,QAAQ;;;;kBAIf,QAAQ,CAAC,cAAc,CAAC;mBACvB,IAAI,CAAC,oBAAoB;;;YAGhC,KAAK,IAAI,KAAK;;;;KAIrB,CAAC;IACJ,CAAC;CACF;AA9UC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CACX;AAIhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACP;AAGrB;IADC,QAAQ,EAAE;yCACC;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACX","sourcesContent":["import { TemplateResult, html, css } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit-html/directives/if-defined.js';\nimport { styleMap } from 'lit-html/directives/style-map.js';\nimport { FormElement } from '../FormElement';\nimport { Modax } from '../dialog/Modax';\nimport { sanitize } from './helpers';\nimport { CharCount } from '../charcount/CharCount';\n\nexport class TextInput extends FormElement {\n static get styles() {\n return css`\n .input-container {\n border-radius: var(--curvature-widget);\n cursor: var(--input-cursor);\n background: var(--color-widget-bg);\n border: 1px solid var(--color-widget-border);\n transition: all ease-in-out var(--transition-speed);\n display: flex;\n flex-direction: row;\n align-items: stretch;\n box-shadow: var(--widget-box-shadow);\n caret-color: var(--input-caret);\n }\n\n .clear-icon {\n --icon-color: var(--color-text-dark-secondary);\n cursor: pointer;\n margin: auto;\n padding-right: 10px;\n line-height: 1;\n }\n\n .clear-icon:hover {\n --icon-color: var(--color-text-dark);\n }\n\n .hidden {\n visibility: hidden;\n position: absolute;\n }\n\n .input-container:focus-within {\n border-color: var(--color-focus);\n background: var(--color-widget-bg-focused);\n box-shadow: var(--widget-box-shadow-focused);\n position: relative;\n }\n\n .input-container:hover {\n }\n\n textarea {\n height: var(--textarea-height);\n }\n\n .textinput {\n padding: var(--temba-textinput-padding);\n border: none;\n flex: 1;\n margin: 0;\n background: none;\n background-color: transparent;\n color: var(--color-widget-text);\n font-family: var(--font-family);\n font-size: var(--temba-textinput-font-size);\n line-height: normal;\n cursor: var(--input-cursor);\n resize: none;\n font-weight: 300;\n width: 100%;\n }\n\n .textinput:focus {\n outline: none;\n box-shadow: none;\n cursor: text;\n color: var(--color-widget-text-focused, var(--color-widget-text));\n }\n\n .textinput::placeholder {\n color: var(--color-placeholder);\n font-weight: 300;\n }\n\n .grow-wrap {\n display: flex;\n align-items: stretch;\n width: 100%;\n }\n\n .grow-wrap > div {\n border: 0px solid green;\n width: 100%;\n padding: var(--temba-textinput-padding);\n flex: 1;\n margin: 0;\n background: none;\n color: var(--color-widget-text);\n font-family: var(--font-family);\n font-size: var(--temba-textinput-font-size);\n line-height: normal;\n cursor: text;\n resize: none;\n font-weight: 300;\n width: 100%;\n visibility: hidden;\n word-break: break-word;\n }\n\n .grow-wrap textarea {\n margin-left: -100%;\n }\n `;\n }\n\n @property({ type: Boolean })\n textarea: boolean;\n\n @property({ type: String })\n placeholder = '';\n\n @property({ type: Boolean })\n password: boolean;\n\n @property({ type: Number })\n maxlength: number;\n\n @property({ type: Object })\n inputElement: HTMLInputElement;\n\n @property({ type: Boolean })\n clearable: boolean;\n\n @property({ type: Boolean })\n gsm: boolean;\n\n @property({ type: String })\n counter: string;\n\n // if we are still loading\n @property({ type: Boolean })\n loading = true;\n\n @property({ type: Boolean })\n submitOnEnter = true;\n\n @property()\n onBlur: any;\n\n @property({ type: Boolean })\n autogrow = false;\n\n counterElement: CharCount = null;\n cursorStart = -1;\n cursorEnd = -1;\n\n public constructor() {\n super();\n }\n\n public firstUpdated(changes: Map<string, any>) {\n super.firstUpdated(changes);\n\n this.inputElement = this.shadowRoot.querySelector('.textinput');\n\n if (changes.has('counter')) {\n let root = this.getParentModax() as any;\n if (root) {\n root = root.shadowRoot;\n }\n if (!root) {\n root = document;\n }\n this.counterElement = root.querySelector(this.counter);\n this.counterElement.text = this.value;\n }\n }\n\n public updated(changes: Map<string, any>) {\n super.updated(changes);\n\n if (changes.has('value')) {\n this.fireEvent('change');\n\n if (this.textarea && this.autogrow) {\n const autogrow = this.shadowRoot.querySelector(\n '.grow-wrap > div'\n ) as HTMLDivElement;\n autogrow.innerText = this.value + String.fromCharCode(10);\n }\n\n if (this.cursorStart > -1 && this.cursorEnd > -1) {\n this.inputElement.setSelectionRange(this.cursorStart, this.cursorEnd);\n this.cursorStart = -1;\n this.cursorEnd = -1;\n }\n }\n }\n\n public getDisplayValue() {\n return this.inputElement.value;\n }\n\n private handleClear(event: any): void {\n event.stopPropagation();\n event.preventDefault();\n this.value = null;\n }\n\n private updateValue(value: string): void {\n const cursorStart = this.inputElement.selectionStart;\n const cursorEnd = this.inputElement.selectionEnd;\n\n const sanitized = this.sanitizeGSM(value);\n\n if (sanitized !== value) {\n this.cursorStart = cursorStart;\n this.cursorEnd = cursorEnd;\n }\n\n this.value = sanitized;\n\n if (this.textarea) {\n this.inputElement.value = this.value;\n }\n\n if (this.counterElement) {\n this.counterElement.text = value;\n }\n }\n\n private sanitizeGSM(text: string): string {\n return this.gsm ? sanitize(text) : text;\n }\n\n private handleChange(update: any): void {\n if (this.disabled) {\n return;\n }\n this.updateValue(update.target.value);\n this.fireEvent('change');\n }\n\n private handleContainerClick(): void {\n if (this.disabled) {\n return;\n }\n if (this.inputElement) {\n this.inputElement.click();\n }\n }\n\n private handleContainerFocus(): void {\n if (this.disabled) {\n return;\n }\n if (this.inputElement) {\n this.inputElement.focus();\n }\n }\n\n private handleInput(update: any): void {\n if (this.disabled) {\n return;\n }\n\n this.updateValue(update.target.value);\n this.fireEvent('input');\n }\n\n /** we just return the value since it should be a string */\n public serializeValue(value: any): string {\n return value;\n }\n\n public getParentModax(): Modax {\n let parent = this as HTMLElement;\n\n while (parent) {\n if (parent.parentElement) {\n parent = parent.parentElement;\n } else {\n parent = (parent as any).getRootNode().host;\n }\n\n if (!parent) {\n return null;\n }\n\n if (parent.tagName == 'TEMBA-MODAX') {\n return parent as Modax;\n }\n }\n }\n\n public getParentForm(): HTMLFormElement {\n let parent = this as HTMLElement;\n\n while (parent) {\n if (parent.parentElement) {\n parent = parent.parentElement;\n } else {\n parent = (parent as any).getRootNode().host;\n }\n\n if (!parent) {\n return null;\n }\n\n if (parent.tagName === 'FORM') {\n return parent as HTMLFormElement;\n }\n }\n }\n\n public click(): void {\n super.click();\n this.handleContainerClick();\n }\n\n public focus(): void {\n super.focus();\n this.handleContainerFocus();\n }\n\n // TODO make this a formelement and have contactsearch set the root\n public render(): TemplateResult {\n const containerStyle = {\n height: `${this.textarea ? '100%' : 'auto'}`,\n };\n\n const clear =\n this.clearable && this.inputElement && this.inputElement.value\n ? html`<temba-icon\n name=\"x\"\n class=\"clear-icon\"\n @click=${this.handleClear}\n />`\n : null;\n\n let input = html`\n <input\n class=\"textinput\"\n name=${this.name}\n type=\"${this.password ? 'password' : 'text'}\"\n maxlength=\"${ifDefined(this.maxlength)}\"\n @change=${this.handleChange}\n @input=${this.handleInput}\n @blur=${this.blur}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const input = this;\n\n if (this.submitOnEnter) {\n const parentModax = input.getParentModax();\n const parentForm = !parentModax ? input.getParentForm() : null;\n\n // if we don't have something to submit then bail\n if (!parentModax && !parentForm) {\n return false;\n }\n\n // don't submit disabled forms on enter\n if (parentModax && parentModax.disabled) {\n return false;\n }\n\n input.blur();\n\n // look for a form to submit\n window.setTimeout(function () {\n // first, look for a modax that contains us\n const modax = input.getParentModax();\n if (modax) {\n input.blur();\n\n modax.submit();\n } else {\n // otherwise, just look for a vanilla submit button\n const form = input.getParentForm();\n\n if (form) {\n const submitButton = form.querySelector(\n \"input[type='submit']\"\n ) as HTMLInputElement;\n if (submitButton) {\n submitButton.click();\n } else {\n form.submit();\n }\n }\n }\n }, 10);\n // this is needed for firefox, would be nice to\n // find a way to do this with a callback instead\n }\n }\n }}\n placeholder=${this.placeholder}\n .value=${this.value}\n .disabled=${this.disabled}\n />\n `;\n\n if (this.textarea) {\n input = html`\n <textarea\n class=\"textinput\"\n name=${this.name}\n maxlength=\"${ifDefined(this.maxlength)}\"\n placeholder=${this.placeholder}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @blur=${this.blur}\n .value=${this.value}\n .disabled=${this.disabled}\n ></textarea>\n `;\n\n if (this.autogrow) {\n input = html` <div class=\"grow-wrap\">\n <div></div>\n ${input}\n </div>`;\n }\n }\n\n return html`\n <temba-field\n name=${this.name}\n .label=\"${this.label}\"\n .helpText=\"${this.helpText}\"\n .errors=${this.errors}\n .widgetOnly=${this.widgetOnly}\n .hideLabel=${this.hideLabel}\n .disabled=${this.disabled}\n >\n <div\n class=\"input-container\"\n style=${styleMap(containerStyle)}\n @click=${this.handleContainerClick}\n >\n <slot name=\"prefix\"></slot>\n ${input} ${clear}\n <slot></slot>\n </div>\n </temba-field>\n `;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyaruka/temba-components",
3
- "version": "0.62.1",
3
+ "version": "0.62.2",
4
4
  "description": "Web components to support rapidpro and related projects",
5
5
  "author": "Nyaruka <code@nyaruka.coim>",
6
6
  "main": "dist/index.js",
@@ -78,7 +78,7 @@ export class Completion extends FormElement {
78
78
  }
79
79
 
80
80
  @property({ type: Number })
81
- maxLength = 10;
81
+ maxLength: number;
82
82
 
83
83
  @property({ type: Boolean })
84
84
  session: boolean;
@@ -275,7 +275,7 @@ export class Completion extends FormElement {
275
275
  @click=${this.handleClick}
276
276
  @input=${this.handleInput}
277
277
  @blur=${this.handleOptionCanceled}
278
- maxlength=${this.maxLength}
278
+ maxlength="${ifDefined(this.maxLength)}"
279
279
  .value=${this.value}
280
280
  ?autogrow=${this.autogrow}
281
281
  ?textarea=${this.textarea}
@@ -257,7 +257,6 @@ export class TextInput extends FormElement {
257
257
  }
258
258
  if (this.inputElement) {
259
259
  this.inputElement.focus();
260
- this.inputElement.setSelectionRange(this.value.length, this.value.length);
261
260
  }
262
261
  }
263
262