@aquera/nile-elements 0.1.60-beta-1.0 → 0.1.60-beta-1.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/README.md CHANGED
@@ -79,6 +79,9 @@ To run a local development server that serves the basic demo located in `demo/in
79
79
 
80
80
  In this section, you can find the updates for each release of `nile-elements`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
81
81
 
82
+ #### Version 0.1.60-beta-1.1
83
+ - Nile Tokenization: Ng nxt defect fixes
84
+
82
85
  #### Version 0.1.60-beta-1.0
83
86
  - Nile Tokenization: Ng nxt defect fixes
84
87
  - Dependeny Nile 0.3.72-beta-1.2
@@ -159,6 +162,9 @@ In this section, you can find the updates for each release of `nile-elements`. I
159
162
  - Nile Tokenization: Admin UI defect fixes
160
163
  - Dependency Nile 0.3.69-beta-1.0
161
164
 
165
+ #### Version 0.1.60
166
+ - Nile Chip: Defect fix [UIF-921]
167
+
162
168
  #### Version 0.1.59
163
169
  - Nile Select: Virtual scroll feature added [UIF-734]
164
170
 
package/dist/index.js CHANGED
@@ -117,7 +117,7 @@ const Te=1,de=2,ye=3,Ae=4,Oe=e=>(...t)=>({_$litDirective$:e,values:t});let he=cl
117
117
  .nds-icon--push {
118
118
  margin-right: var(--nile-spacing-lg);
119
119
  }
120
- `,e([ue({type:String,reflect:!0})],ke.prototype,"set",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"name",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"description",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"method",void 0),e([ue({type:String})],ke.prototype,"customSvgPath",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"size",void 0),e([je()],ke.prototype,"_svg",void 0),e([ue({type:String})],ke.prototype,"title",void 0),e([ue({reflect:!0})],ke.prototype,"color",void 0),e([ue({type:Boolean})],ke.prototype,"push",void 0),e([ue({type:Boolean})],ke.prototype,"noFill",void 0),e([ue({reflect:!0})],ke.prototype,"frame",void 0),ke=e([ge("nile-icon")],ke);const me=new WeakMap,Ce=new WeakMap,Ue=new WeakSet,be=new WeakMap;class fe{constructor(e,t){(this.host=e).addController(this),this.options={form:e=>{if(e.hasAttribute("form")&&""!==e.getAttribute("form")){const t=e.getRootNode(),M=e.getAttribute("form");if(M)return t.getElementById(M)}return e.closest("form")},name:e=>e.name,value:e=>e.value,defaultValue:e=>e.defaultValue,disabled:e=>e.disabled??!1,reportValidity:e=>"function"!=typeof e.reportValidity||e.reportValidity(),setValue:(e,t)=>e.value=t,assumeInteractionOn:["nile-input"],...t},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const e=this.options.form(this.host);e&&this.attachForm(e),be.set(this.host,[]),this.options.assumeInteractionOn.forEach((e=>{this.host.addEventListener(e,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),be.delete(this.host),this.options.assumeInteractionOn.forEach((e=>{this.host.removeEventListener(e,this.handleInteraction)}))}hostUpdated(){const e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(e){e?(this.form=e,me.has(this.form)?me.get(this.form).add(this.host):me.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),Ce.has(this.form)||(Ce.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){this.form&&(me.get(this.form)?.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),Ce.has(this.form)&&(this.form.reportValidity=Ce.get(this.form),Ce.delete(this.form))),this.form=void 0}handleFormData(e){const t=this.options.disabled(this.host),M=this.options.name(this.host),i=this.options.value(this.host),n="nile-button"===this.host.tagName.toLowerCase();!t&&!n&&"string"==typeof M&&M.length>0&&void 0!==i&&(Array.isArray(i)?i.forEach((t=>{e.formData.append(M,t.toString())})):e.formData.append(M,i.toString()))}handleFormSubmit(e){const t=this.options.disabled(this.host),M=this.options.reportValidity;this.form&&!this.form.noValidate&&me.get(this.form)?.forEach((e=>{this.setUserInteracted(e,!0)})),!this.form||this.form.noValidate||t||M(this.host)||(e.preventDefault(),e.stopImmediatePropagation())}handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),be.set(this.host,[])}handleInteraction(e){const t=be.get(this.host);t.includes(e.type)||t.push(e.type),t.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)}reportFormValidity(){if(this.form&&!this.form.noValidate){const e=this.form.querySelectorAll("*");for(const t of e)if("function"==typeof t.reportValidity&&!t.reportValidity())return!1}return!0}setUserInteracted(e,t){t?Ue.add(e):Ue.delete(e),e.requestUpdate()}doAction(e,t){if(this.form){const M=document.createElement("button");M.type=e,M.style.position="absolute",M.style.width="0",M.style.height="0",M.style.clipPath="inset(50%)",M.style.overflow="hidden",M.style.whiteSpace="nowrap",t&&(M.name=t.name,M.value=t.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((e=>{t.hasAttribute(e)&&M.setAttribute(e,t.getAttribute(e))}))),this.form.append(M),M.click(),M.remove()}}getForm(){return this.form??null}reset(e){this.doAction("reset",e)}submit(e){this.doAction("submit",e)}setValidity(e){const t=this.host,M=Boolean(Ue.has(t)),i=Boolean(t.required);t.toggleAttribute("data-required",i),t.toggleAttribute("data-optional",!i),t.toggleAttribute("data-invalid",!e),t.toggleAttribute("data-valid",e),t.toggleAttribute("data-user-invalid",!e&&M),t.toggleAttribute("data-user-valid",e&&M)}updateValidity(){const e=this.host;this.setValidity(e.validity.valid)}emitInvalidEvent(e){const t=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});e||t.preventDefault(),this.host.dispatchEvent(t)||e?.preventDefault()}}const Ye=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze({...Ye,valid:!1,valueMissing:!0}),Object.freeze({...Ye,valid:!1,customError:!0});let ve=class{constructor(e,...t){this.slotNames=[],(this.host=e).addController(this),this.slotNames=t,this.handleSlotChange=this.handleSlotChange.bind(this)}hasDefaultSlot(){return[...this.host.childNodes].some((e=>{if(e.nodeType===e.TEXT_NODE&&""!==e.textContent.trim())return!0;if(e.nodeType===e.ELEMENT_NODE){const t=e;if("nile-visually-hidden"===t.tagName.toLowerCase())return!1;if(!t.hasAttribute("slot"))return!0}return!1}))}hasNamedSlot(e){return null!==this.host.querySelector(`:scope > [slot="${e}"]`)}test(e){return"[default]"===e?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}handleSlotChange(e){const t=e.target;(this.slotNames.includes("[default]")&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()}};
120
+ `,e([ue({type:String,reflect:!0})],ke.prototype,"set",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"name",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"description",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"method",void 0),e([ue({type:String})],ke.prototype,"customSvgPath",void 0),e([ue({type:String,reflect:!0})],ke.prototype,"size",void 0),e([je()],ke.prototype,"_svg",void 0),e([ue({type:String})],ke.prototype,"title",void 0),e([ue({reflect:!0})],ke.prototype,"color",void 0),e([ue({type:Boolean})],ke.prototype,"push",void 0),e([ue({type:Boolean})],ke.prototype,"noFill",void 0),e([ue({reflect:!0})],ke.prototype,"frame",void 0),ke=e([ge("nile-icon")],ke);const me=new WeakMap,Ce=new WeakMap,Ue=new WeakSet,be=new WeakMap;class fe{constructor(e,t){(this.host=e).addController(this),this.options={form:e=>{if(e.hasAttribute("form")&&""!==e.getAttribute("form")){const t=e.getRootNode(),M=e.getAttribute("form");if(M)return t.getElementById(M)}return e.closest("form")},name:e=>e.name,value:e=>e.value,defaultValue:e=>e.defaultValue,disabled:e=>e.disabled??!1,reportValidity:e=>"function"!=typeof e.reportValidity||e.reportValidity(),setValue:(e,t)=>e.value=t,assumeInteractionOn:["nile-input"],...t},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const e=this.options?.form(this.host);e&&this.attachForm(e),be.set(this.host,[]),this.options?.assumeInteractionOn.forEach((e=>{this.host.addEventListener(e,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),be.delete(this.host),this.options?.assumeInteractionOn.forEach((e=>{this.host.removeEventListener(e,this.handleInteraction)}))}hostUpdated(){const e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(e){e?(this.form=e,me.has(this.form)?me.get(this.form).add(this.host):me.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),Ce.has(this.form)||(Ce.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){this.form&&(me.get(this.form)?.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),Ce.has(this.form)&&(this.form.reportValidity=Ce.get(this.form),Ce.delete(this.form))),this.form=void 0}handleFormData(e){const t=this.options.disabled(this.host),M=this.options.name(this.host),i=this.options.value(this.host),n="nile-button"===this.host.tagName.toLowerCase();!t&&!n&&"string"==typeof M&&M.length>0&&void 0!==i&&(Array.isArray(i)?i.forEach((t=>{e.formData.append(M,t.toString())})):e.formData.append(M,i.toString()))}handleFormSubmit(e){const t=this.options.disabled(this.host),M=this.options.reportValidity;this.form&&!this.form.noValidate&&me.get(this.form)?.forEach((e=>{this.setUserInteracted(e,!0)})),!this.form||this.form.noValidate||t||M(this.host)||(e.preventDefault(),e.stopImmediatePropagation())}handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),be.set(this.host,[])}handleInteraction(e){const t=be.get(this.host);t.includes(e.type)||t.push(e.type),t.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)}reportFormValidity(){if(this.form&&!this.form.noValidate){const e=this.form.querySelectorAll("*");for(const t of e)if("function"==typeof t.reportValidity&&!t.reportValidity())return!1}return!0}setUserInteracted(e,t){t?Ue.add(e):Ue.delete(e),e.requestUpdate()}doAction(e,t){if(this.form){const M=document.createElement("button");M.type=e,M.style.position="absolute",M.style.width="0",M.style.height="0",M.style.clipPath="inset(50%)",M.style.overflow="hidden",M.style.whiteSpace="nowrap",t&&(M.name=t.name,M.value=t.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((e=>{t.hasAttribute(e)&&M.setAttribute(e,t.getAttribute(e))}))),this.form.append(M),M.click(),M.remove()}}getForm(){return this.form??null}reset(e){this.doAction("reset",e)}submit(e){this.doAction("submit",e)}setValidity(e){const t=this.host,M=Boolean(Ue.has(t)),i=Boolean(t.required);t.toggleAttribute("data-required",i),t.toggleAttribute("data-optional",!i),t.toggleAttribute("data-invalid",!e),t.toggleAttribute("data-valid",e),t.toggleAttribute("data-user-invalid",!e&&M),t.toggleAttribute("data-user-valid",e&&M)}updateValidity(){const e=this.host;this.setValidity(e.validity.valid)}emitInvalidEvent(e){const t=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});e||t.preventDefault(),this.host.dispatchEvent(t)||e?.preventDefault()}}const Ye=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze({...Ye,valid:!1,valueMissing:!0}),Object.freeze({...Ye,valid:!1,customError:!0});let ve=class{constructor(e,...t){this.slotNames=[],(this.host=e).addController(this),this.slotNames=t,this.handleSlotChange=this.handleSlotChange.bind(this)}hasDefaultSlot(){return[...this.host.childNodes].some((e=>{if(e.nodeType===e.TEXT_NODE&&""!==e.textContent.trim())return!0;if(e.nodeType===e.ELEMENT_NODE){const t=e;if("nile-visually-hidden"===t.tagName.toLowerCase())return!1;if(!t.hasAttribute("slot"))return!0}return!1}))}hasNamedSlot(e){return null!==this.host.querySelector(`:scope > [slot="${e}"]`)}test(e){return"[default]"===e?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}handleSlotChange(e){const t=e.target;(this.slotNames.includes("[default]")&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()}};
121
121
  /**
122
122
  * @license
123
123
  * Copyright 2018 Google LLC
@@ -5692,7 +5692,7 @@ class Xi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
5692
5692
  .nile-chip__tags {
5693
5693
  margin: var(--nile-margin-size-rem-small);
5694
5694
  }
5695
- `;let An=class extends Pe{constructor(){super(...arguments),this.hasSlotController=new ve(this,"help-text","label"),this.tags=[],this.inputValue="",this.isDropdownOpen=!1,this.warning=!1,this.error=!1,this.success=!1,this.noDuplicates=!1,this.label="",this.tagVariant="",this.acceptUserInput=!1,this.clearable=!1,this.placeholder="type here...",this.readonly=!1,this.disabled=!1,this.enableVirtualScroll=!1,this.autoCompleteOptions=[],this.filteredAutoCompleteOptions=[],this.value=[],this.noWrap=!1,this.loading=!1,this.errorIndexes=[],this.helpText="",this.errorMessage="",this.filterFunction=(e,t)=>e.toLowerCase().includes(t.toLowerCase()),this.renderItemFunction=e=>e}static get styles(){return[yn]}updated(e){super.updated(e),e.has("autoCompleteOptions")&&(this.filteredAutoCompleteOptions=[...this.autoCompleteOptions],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((e=>!this.value.includes(e))))),e.has("value")&&(this.tags=[...this.value],this.onTagsChanged()),e.has("tags")&&this.onTagsChanged()}connectedCallback(){super.connectedCallback(),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((e=>!this.value.includes(e)))),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=!!this.label||!!e,M=!!this.helpText,i=!!this.errorMessage;return R`
5695
+ `;let An=class extends Pe{constructor(){super(...arguments),this.hasSlotController=new ve(this,"help-text","label"),this.tags=[],this.inputValue="",this.isDropdownOpen=!1,this.warning=!1,this.error=!1,this.success=!1,this.noDuplicates=!1,this.label="",this.tagVariant="",this.acceptUserInput=!1,this.clearable=!1,this.placeholder="type here...",this.readonly=!1,this.disabled=!1,this.enableVirtualScroll=!1,this.autoCompleteOptions=[],this.filteredAutoCompleteOptions=[],this.value=[],this.noWrap=!1,this.loading=!1,this.errorIndexes=[],this.helpText="",this.errorMessage="",this.filterFunction=(e,t)=>e.toLowerCase().includes(t.toLowerCase()),this.renderItemFunction=e=>e}static get styles(){return[yn]}updated(e){if(super.updated(e),e.has("autoCompleteOptions")){let e=this.autoCompleteOptions;if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e=[]}this.filteredAutoCompleteOptions=Array.isArray(e)?[...e]:[],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((e=>!this.value.includes(e))))}e.has("value")&&(this.tags=[...this.value],this.onTagsChanged()),e.has("tags")&&this.onTagsChanged()}connectedCallback(){super.connectedCallback(),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((e=>!this.value.includes(e)))),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=!!this.label||!!e,M=!!this.helpText,i=!!this.errorMessage;return R`
5696
5696
  <div
5697
5697
  part="form-control"
5698
5698
  class=${Le({"form-control":!0,"form-control--medium":!0,"form-control--has-label":t,"form-control--has-help-text":M,"nile-chip--disabled":this.disabled})}
@@ -1,2 +1,2 @@
1
- System.register([],function(_export,_context){"use strict";var t,i,s,h,e,o;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[],execute:function execute(){t=new WeakMap(),i=new WeakMap(),s=new WeakSet(),h=new WeakMap();_export("F",e=/*#__PURE__*/function(){function e(t,i){_classCallCheck(this,e);(this.host=t).addController(this),this.options=_objectSpread({form:function form(t){if(t.hasAttribute("form")&&""!==t.getAttribute("form")){var _i=t.getRootNode(),_s=t.getAttribute("form");if(_s)return _i.getElementById(_s);}return t.closest("form");},name:function name(t){return t.name;},value:function value(t){return t.value;},defaultValue:function defaultValue(t){return t.defaultValue;},disabled:function disabled(t){var _t$disabled;return(_t$disabled=t.disabled)!==null&&_t$disabled!==void 0?_t$disabled:!1;},reportValidity:function reportValidity(t){return"function"!=typeof t.reportValidity||t.reportValidity();},setValue:function setValue(t,i){return t.value=i;},assumeInteractionOn:["nile-input"]},i),this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this);}return _createClass(e,[{key:"hostConnected",value:function hostConnected(){var _this=this;var t=this.options.form(this.host);t&&this.attachForm(t),h.set(this.host,[]),this.options.assumeInteractionOn.forEach(function(t){_this.host.addEventListener(t,_this.handleInteraction);});}},{key:"hostDisconnected",value:function hostDisconnected(){var _this2=this;this.detachForm(),h["delete"](this.host),this.options.assumeInteractionOn.forEach(function(t){_this2.host.removeEventListener(t,_this2.handleInteraction);});}},{key:"hostUpdated",value:function hostUpdated(){var t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid);}},{key:"attachForm",value:function attachForm(s){var _this3=this;s?(this.form=s,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),i.has(this.form)||(i.set(this.form,this.form.reportValidity),this.form.reportValidity=function(){return _this3.reportFormValidity();})):this.form=void 0;}},{key:"detachForm",value:function detachForm(){var _t$get;this.form&&((_t$get=t.get(this.form))!==null&&_t$get!==void 0&&_t$get["delete"](this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),i.has(this.form)&&(this.form.reportValidity=i.get(this.form),i["delete"](this.form))),this.form=void 0;}},{key:"handleFormData",value:function handleFormData(t){var i=this.options.disabled(this.host),s=this.options.name(this.host),h=this.options.value(this.host),_e="nile-button"===this.host.tagName.toLowerCase();!i&&!_e&&"string"==typeof s&&s.length>0&&void 0!==h&&(Array.isArray(h)?h.forEach(function(i){t.formData.append(s,i.toString());}):t.formData.append(s,h.toString()));}},{key:"handleFormSubmit",value:function handleFormSubmit(i){var _t$get2,_this4=this;var s=this.options.disabled(this.host),h=this.options.reportValidity;this.form&&!this.form.noValidate&&(_t$get2=t.get(this.form))!==null&&_t$get2!==void 0&&_t$get2.forEach(function(t){_this4.setUserInteracted(t,!0);}),!this.form||this.form.noValidate||s||h(this.host)||(i.preventDefault(),i.stopImmediatePropagation());}},{key:"handleFormReset",value:function handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),h.set(this.host,[]);}},{key:"handleInteraction",value:function handleInteraction(t){var i=h.get(this.host);i.includes(t.type)||i.push(t.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0);}},{key:"reportFormValidity",value:function reportFormValidity(){if(this.form&&!this.form.noValidate){var _t=this.form.querySelectorAll("*");var _iterator=_createForOfIteratorHelper(_t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _i2=_step.value;if("function"==typeof _i2.reportValidity&&!_i2.reportValidity())return!1;}}catch(err){_iterator.e(err);}finally{_iterator.f();}}return!0;}},{key:"setUserInteracted",value:function setUserInteracted(t,i){i?s.add(t):s["delete"](t),t.requestUpdate();}},{key:"doAction",value:function doAction(t,i){if(this.form){var _s2=document.createElement("button");_s2.type=t,_s2.style.position="absolute",_s2.style.width="0",_s2.style.height="0",_s2.style.clipPath="inset(50%)",_s2.style.overflow="hidden",_s2.style.whiteSpace="nowrap",i&&(_s2.name=i.name,_s2.value=i.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach(function(t){i.hasAttribute(t)&&_s2.setAttribute(t,i.getAttribute(t));})),this.form.append(_s2),_s2.click(),_s2.remove();}}},{key:"getForm",value:function getForm(){var _this$form;return(_this$form=this.form)!==null&&_this$form!==void 0?_this$form:null;}},{key:"reset",value:function reset(t){this.doAction("reset",t);}},{key:"submit",value:function submit(t){this.doAction("submit",t);}},{key:"setValidity",value:function setValidity(t){var i=this.host,h=Boolean(s.has(i)),_e2=Boolean(i.required);i.toggleAttribute("data-required",_e2),i.toggleAttribute("data-optional",!_e2),i.toggleAttribute("data-invalid",!t),i.toggleAttribute("data-valid",t),i.toggleAttribute("data-user-invalid",!t&&h),i.toggleAttribute("data-user-valid",t&&h);}},{key:"updateValidity",value:function updateValidity(){var t=this.host;this.setValidity(t.validity.valid);}},{key:"emitInvalidEvent",value:function emitInvalidEvent(t){var i=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||i.preventDefault(),this.host.dispatchEvent(i)||(t===null||t===void 0?void 0:t.preventDefault());}}]);}());_export("v",o=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}));Object.freeze(_objectSpread(_objectSpread({},o),{},{valid:!1,valueMissing:!0})),Object.freeze(_objectSpread(_objectSpread({},o),{},{valid:!1,customError:!0}));}};});
1
+ System.register([],function(_export,_context){"use strict";var t,i,s,h,e,o;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[],execute:function execute(){t=new WeakMap(),i=new WeakMap(),s=new WeakSet(),h=new WeakMap();_export("F",e=/*#__PURE__*/function(){function e(t,i){_classCallCheck(this,e);(this.host=t).addController(this),this.options=_objectSpread({form:function form(t){if(t.hasAttribute("form")&&""!==t.getAttribute("form")){var _i=t.getRootNode(),_s=t.getAttribute("form");if(_s)return _i.getElementById(_s);}return t.closest("form");},name:function name(t){return t.name;},value:function value(t){return t.value;},defaultValue:function defaultValue(t){return t.defaultValue;},disabled:function disabled(t){var _t$disabled;return(_t$disabled=t.disabled)!==null&&_t$disabled!==void 0?_t$disabled:!1;},reportValidity:function reportValidity(t){return"function"!=typeof t.reportValidity||t.reportValidity();},setValue:function setValue(t,i){return t.value=i;},assumeInteractionOn:["nile-input"]},i),this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this);}return _createClass(e,[{key:"hostConnected",value:function hostConnected(){var _this$options,_this$options2,_this=this;var t=(_this$options=this.options)===null||_this$options===void 0?void 0:_this$options.form(this.host);t&&this.attachForm(t),h.set(this.host,[]),(_this$options2=this.options)===null||_this$options2===void 0?void 0:_this$options2.assumeInteractionOn.forEach(function(t){_this.host.addEventListener(t,_this.handleInteraction);});}},{key:"hostDisconnected",value:function hostDisconnected(){var _this$options3,_this2=this;this.detachForm(),h["delete"](this.host),(_this$options3=this.options)===null||_this$options3===void 0?void 0:_this$options3.assumeInteractionOn.forEach(function(t){_this2.host.removeEventListener(t,_this2.handleInteraction);});}},{key:"hostUpdated",value:function hostUpdated(){var t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid);}},{key:"attachForm",value:function attachForm(s){var _this3=this;s?(this.form=s,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),i.has(this.form)||(i.set(this.form,this.form.reportValidity),this.form.reportValidity=function(){return _this3.reportFormValidity();})):this.form=void 0;}},{key:"detachForm",value:function detachForm(){var _t$get;this.form&&((_t$get=t.get(this.form))!==null&&_t$get!==void 0&&_t$get["delete"](this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),i.has(this.form)&&(this.form.reportValidity=i.get(this.form),i["delete"](this.form))),this.form=void 0;}},{key:"handleFormData",value:function handleFormData(t){var i=this.options.disabled(this.host),s=this.options.name(this.host),h=this.options.value(this.host),_e="nile-button"===this.host.tagName.toLowerCase();!i&&!_e&&"string"==typeof s&&s.length>0&&void 0!==h&&(Array.isArray(h)?h.forEach(function(i){t.formData.append(s,i.toString());}):t.formData.append(s,h.toString()));}},{key:"handleFormSubmit",value:function handleFormSubmit(i){var _t$get2,_this4=this;var s=this.options.disabled(this.host),h=this.options.reportValidity;this.form&&!this.form.noValidate&&(_t$get2=t.get(this.form))!==null&&_t$get2!==void 0&&_t$get2.forEach(function(t){_this4.setUserInteracted(t,!0);}),!this.form||this.form.noValidate||s||h(this.host)||(i.preventDefault(),i.stopImmediatePropagation());}},{key:"handleFormReset",value:function handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),h.set(this.host,[]);}},{key:"handleInteraction",value:function handleInteraction(t){var i=h.get(this.host);i.includes(t.type)||i.push(t.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0);}},{key:"reportFormValidity",value:function reportFormValidity(){if(this.form&&!this.form.noValidate){var _t=this.form.querySelectorAll("*");var _iterator=_createForOfIteratorHelper(_t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _i2=_step.value;if("function"==typeof _i2.reportValidity&&!_i2.reportValidity())return!1;}}catch(err){_iterator.e(err);}finally{_iterator.f();}}return!0;}},{key:"setUserInteracted",value:function setUserInteracted(t,i){i?s.add(t):s["delete"](t),t.requestUpdate();}},{key:"doAction",value:function doAction(t,i){if(this.form){var _s2=document.createElement("button");_s2.type=t,_s2.style.position="absolute",_s2.style.width="0",_s2.style.height="0",_s2.style.clipPath="inset(50%)",_s2.style.overflow="hidden",_s2.style.whiteSpace="nowrap",i&&(_s2.name=i.name,_s2.value=i.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach(function(t){i.hasAttribute(t)&&_s2.setAttribute(t,i.getAttribute(t));})),this.form.append(_s2),_s2.click(),_s2.remove();}}},{key:"getForm",value:function getForm(){var _this$form;return(_this$form=this.form)!==null&&_this$form!==void 0?_this$form:null;}},{key:"reset",value:function reset(t){this.doAction("reset",t);}},{key:"submit",value:function submit(t){this.doAction("submit",t);}},{key:"setValidity",value:function setValidity(t){var i=this.host,h=Boolean(s.has(i)),_e2=Boolean(i.required);i.toggleAttribute("data-required",_e2),i.toggleAttribute("data-optional",!_e2),i.toggleAttribute("data-invalid",!t),i.toggleAttribute("data-valid",t),i.toggleAttribute("data-user-invalid",!t&&h),i.toggleAttribute("data-user-valid",t&&h);}},{key:"updateValidity",value:function updateValidity(){var t=this.host;this.setValidity(t.validity.valid);}},{key:"emitInvalidEvent",value:function emitInvalidEvent(t){var i=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||i.preventDefault(),this.host.dispatchEvent(i)||(t===null||t===void 0?void 0:t.preventDefault());}}]);}());_export("v",o=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}));Object.freeze(_objectSpread(_objectSpread({},o),{},{valid:!1,valueMissing:!0})),Object.freeze(_objectSpread(_objectSpread({},o),{},{valid:!1,customError:!0}));}};});
2
2
  //# sourceMappingURL=form.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.cjs.js","sources":["../../../src/internal/form.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { NileFormControl } from '../internal/nile-element';\nimport type { NileButton } from '../nile-button';\n\n//\n// We store a WeakMap of forms + controls so we can keep references to all Nile controls within a given form. As\n// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is\n// added and removed from the form's set, respectively.\n//\nexport const formCollections: WeakMap<HTMLFormElement, Set<NileFormControl>> = new WeakMap();\n\n//\n// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and\n// restore the original behavior when they disconnect.\n//\nconst reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();\n\n//\n// We store a Set of controls that users have interacted with. This allows us to determine the interaction state\n// without littering the DOM with additional data attributes.\n//\nconst userInteractedControls: WeakSet<NileFormControl> = new WeakSet();\n\n//\n// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.\n//\nconst interactions = new WeakMap<NileFormControl, string[]>();\n\nexport interface FormControlControllerOptions {\n /** A function that returns the form containing the form control. */\n form: (input: NileFormControl) => HTMLFormElement | null;\n /** A function that returns the form control's name, which will be submitted with the form data. */\n name: (input: NileFormControl) => string;\n /** A function that returns the form control's current value. */\n value: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's default value. */\n defaultValue: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */\n disabled: (input: NileFormControl) => boolean;\n /**\n * A function that maps to the form control's reportValidity() function. When the control is invalid, this will\n * prevent submission and trigger the browser's constraint violation warning.\n */\n reportValidity: (input: NileFormControl) => boolean;\n /** A function that sets the form control's value */\n setValue: (input: NileFormControl, value: unknown) => void;\n /**\n * An array of event names to listen to. When all events in the list are emitted, the control will receive validity\n * states such as user-valid and user-invalid.user interacted validity states. */\n assumeInteractionOn: string[];\n}\n\n/** A reactive controller to allow form controls to participate in form submission, validation, etc. */\nexport class FormControlController implements ReactiveController {\n host: NileFormControl & ReactiveControllerHost;\n form?: HTMLFormElement | null;\n options: FormControlControllerOptions;\n\n constructor(host: ReactiveControllerHost & NileFormControl, options?: Partial<FormControlControllerOptions>) {\n (this.host = host).addController(this);\n this.options = {\n form: input => {\n // If there's a form attribute, use it to find the target form by id\n if (input.hasAttribute('form') && input.getAttribute('form') !== '') {\n const root = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute('form');\n\n if (formId) {\n return root.getElementById(formId) as HTMLFormElement;\n }\n }\n\n return input.closest('form');\n },\n name: input => input.name,\n value: input => input.value,\n defaultValue: input => input.defaultValue,\n disabled: input => input.disabled ?? false,\n reportValidity: input => (typeof input.reportValidity === 'function' ? input.reportValidity() : true),\n setValue: (input, value: string) => (input.value = value),\n assumeInteractionOn: ['nile-input'],\n ...options\n };\n this.handleFormData = this.handleFormData.bind(this);\n this.handleFormSubmit = this.handleFormSubmit.bind(this);\n this.handleFormReset = this.handleFormReset.bind(this);\n this.reportFormValidity = this.reportFormValidity.bind(this);\n this.handleInteraction = this.handleInteraction.bind(this);\n }\n\n hostConnected() {\n const form = this.options.form(this.host);\n\n if (form) {\n this.attachForm(form);\n }\n\n // Listen for interactions\n interactions.set(this.host, []);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.addEventListener(event, this.handleInteraction);\n });\n }\n\n hostDisconnected() {\n this.detachForm();\n\n // Clean up interactions\n interactions.delete(this.host);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.removeEventListener(event, this.handleInteraction);\n });\n }\n\n hostUpdated() {\n const form = this.options.form(this.host);\n\n // Detach if the form no longer exists\n if (!form) {\n this.detachForm();\n }\n\n // If the form has changed, reattach it\n if (form && this.form !== form) {\n this.detachForm();\n this.attachForm(form);\n }\n\n if (this.host.hasUpdated) {\n this.setValidity(this.host.validity.valid);\n }\n }\n\n private attachForm(form?: HTMLFormElement) {\n if (form) {\n this.form = form;\n\n // Add this element to the form's collection\n if (formCollections.has(this.form)) {\n formCollections.get(this.form)!.add(this.host);\n } else {\n formCollections.set(this.form, new Set<NileFormControl>([this.host]));\n }\n\n this.form.addEventListener('formdata', this.handleFormData);\n this.form.addEventListener('submit', this.handleFormSubmit);\n this.form.addEventListener('reset', this.handleFormReset);\n\n // Overload the form's reportValidity() method so it looks at nile form controls\n if (!reportValidityOverloads.has(this.form)) {\n reportValidityOverloads.set(this.form, this.form.reportValidity);\n this.form.reportValidity = () => this.reportFormValidity();\n }\n } else {\n this.form = undefined;\n }\n }\n\n private detachForm() {\n if (this.form) {\n // Remove this element from the form's collection\n formCollections.get(this.form)?.delete(this.host);\n\n this.form.removeEventListener('formdata', this.handleFormData);\n this.form.removeEventListener('submit', this.handleFormSubmit);\n this.form.removeEventListener('reset', this.handleFormReset);\n\n // Remove the overload and restore the original method\n if (reportValidityOverloads.has(this.form)) {\n this.form.reportValidity = reportValidityOverloads.get(this.form)!;\n reportValidityOverloads.delete(this.form);\n }\n }\n\n this.form = undefined;\n }\n\n private handleFormData(event: FormDataEvent) {\n const disabled = this.options.disabled(this.host);\n const name = this.options.name(this.host);\n const value = this.options.value(this.host);\n\n // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by\n // injecting the name/value on a temporary button, so we can just skip them here.\n const isButton = this.host.tagName.toLowerCase() === 'nile-button';\n\n if (!disabled && !isButton && typeof name === 'string' && name.length > 0 && typeof value !== 'undefined') {\n if (Array.isArray(value)) {\n (value as unknown[]).forEach(val => {\n event.formData.append(name, (val as string | number | boolean).toString());\n });\n } else {\n event.formData.append(name, (value as string | number | boolean).toString());\n }\n }\n }\n\n private handleFormSubmit(event: Event) {\n const disabled = this.options.disabled(this.host);\n const reportValidity = this.options.reportValidity;\n\n // Update the interacted state for all controls when the form is submitted\n if (this.form && !this.form.noValidate) {\n formCollections.get(this.form)?.forEach(control => {\n this.setUserInteracted(control, true);\n });\n }\n\n if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleFormReset() {\n this.options.setValue(this.host, this.options.defaultValue(this.host));\n this.setUserInteracted(this.host, false);\n interactions.set(this.host, []);\n }\n\n private handleInteraction(event: Event) {\n const emittedEvents = interactions.get(this.host)!;\n\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.options.assumeInteractionOn.length) {\n this.setUserInteracted(this.host, true);\n }\n }\n\n private reportFormValidity() {\n //\n // Nile form controls work hard to act like regular form controls. They support the Constraint Validation API\n // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also\n // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using\n // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.\n //\n // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger\n // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't\n // be necessary once we can use ElementInternals.\n //\n // Note that we're also honoring the form's novalidate attribute.\n //\n if (this.form && !this.form.noValidate) {\n // This seems sloppy, but checking all elements will cover native inputs, Nile inputs, and other custom\n // elements that support the constraint validation API.\n const elements = this.form.querySelectorAll<HTMLInputElement>('*');\n\n for (const element of elements) {\n if (typeof element.reportValidity === 'function') {\n if (!element.reportValidity()) {\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n private setUserInteracted(el: NileFormControl, hasInteracted: boolean) {\n if (hasInteracted) {\n userInteractedControls.add(el);\n } else {\n userInteractedControls.delete(el);\n }\n\n el.requestUpdate();\n }\n\n private doAction(type: 'submit' | 'reset', submitter?: HTMLInputElement | NileButton) {\n if (this.form) {\n const button = document.createElement('button');\n button.type = type;\n button.style.position = 'absolute';\n button.style.width = '0';\n button.style.height = '0';\n button.style.clipPath = 'inset(50%)';\n button.style.overflow = 'hidden';\n button.style.whiteSpace = 'nowrap';\n\n // Pass name, value, and form attributes through to the temporary button\n if (submitter) {\n button.name = submitter.name;\n button.value = submitter.value;\n\n ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {\n if (submitter.hasAttribute(attr)) {\n button.setAttribute(attr, submitter.getAttribute(attr)!);\n }\n });\n }\n\n this.form.append(button);\n button.click();\n button.remove();\n }\n }\n\n /** Returns the associated `<form>` element, if one exists. */\n getForm() {\n return this.form ?? null;\n }\n\n /** Resets the form, restoring all the control to their default value */\n reset(submitter?: HTMLInputElement | NileButton) {\n this.doAction('reset', submitter);\n }\n\n /** Submits the form, triggering validation and form data injection. */\n submit(submitter?: HTMLInputElement | NileButton) {\n // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a\n // native submit button into the form, \"click\" it, then remove it to simulate a standard form submission.\n this.doAction('submit', submitter);\n }\n\n /**\n * Synchronously sets the form control's validity. Call this when you know the future validity but need to update\n * the host element immediately, i.e. before Lit updates the component in the next update.\n */\n setValidity(isValid: boolean) {\n const host = this.host;\n const hasInteracted = Boolean(userInteractedControls.has(host));\n const required = Boolean(host.required);\n\n //\n // We're mapping the following \"states\" to data attributes. In the future, we can use ElementInternals.states to\n // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.\n //\n //\n host.toggleAttribute('data-required', required);\n host.toggleAttribute('data-optional', !required);\n host.toggleAttribute('data-invalid', !isValid);\n host.toggleAttribute('data-valid', isValid);\n host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);\n host.toggleAttribute('data-user-valid', isValid && hasInteracted);\n }\n\n /**\n * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything\n * that affects constraint validation changes so the component receives the correct validity states.\n */\n updateValidity() {\n const host = this.host;\n this.setValidity(host.validity.valid);\n }\n\n /**\n * Dispatches a non-bubbling, cancelable custom event of type `nile-invalid`.\n * If the `nile-invalid` event will be cancelled then the original `invalid`\n * event (which may have been passed as argument) will also be cancelled.\n * If no original `invalid` event has been passed then the `nile-invalid`\n * event will be cancelled before being dispatched.\n */\n emitInvalidEvent(originalInvalidEvent?: Event) {\n const slInvalidEvent = new CustomEvent<Record<PropertyKey, never>>('nile-invalid', {\n bubbles: false,\n composed: false,\n cancelable: true,\n detail: {}\n });\n\n if (!originalInvalidEvent) {\n slInvalidEvent.preventDefault();\n }\n\n if (!this.host.dispatchEvent(slInvalidEvent)) {\n originalInvalidEvent?.preventDefault();\n }\n }\n}\n\n/*\n * Predefined common validity states.\n * All of them are read-only.\n */\n\n// A validity state object that represents `valid`\nexport const validValidityState: ValidityState = Object.freeze({\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false\n});\n\n// A validity state object that represents `value missing`\nexport const valueMissingValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n valueMissing: true\n});\n\n// A validity state object that represents a custom error\nexport const customErrorValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n customError: true\n});\n"],"names":["formCollections","WeakMap","reportValidityOverloads","userInteractedControls","WeakSet","interactions","FormControlController","e","host","options","this","addController","_objectSpread","form","input","hasAttribute","getAttribute","root","getRootNode","formId","getElementById","closest","name","value","defaultValue","disabled","reportValidity","setValue","assumeInteractionOn","handleFormData","bind","handleFormSubmit","handleFormReset","reportFormValidity","handleInteraction","_createClass","key","hostConnected","_this","attachForm","set","forEach","event","addEventListener","hostDisconnected","detachForm","removeEventListener","hostUpdated","hasUpdated","setValidity","validity","valid","has","get","add","Set","undefined","isButton","tagName","toLowerCase","length","Array","isArray","val","formData","append","toString","noValidate","control","setUserInteracted","preventDefault","stopImmediatePropagation","emittedEvents","includes","type","push","elements","querySelectorAll","_iterator","_createForOfIteratorHelper","s","_step","n","done","element","err","f","el","hasInteracted","delete","requestUpdate","doAction","submitter","button","document","createElement","style","position","width","height","clipPath","overflow","whiteSpace","attr","setAttribute","click","remove","getForm","_this$form","reset","submit","isValid","Boolean","required","toggleAttribute","updateValidity","emitInvalidEvent","originalInvalidEvent","slInvalidEvent","CustomEvent","bubbles","composed","cancelable","detail","dispatchEvent","_export","validValidityState","Object","freeze","badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],"mappings":"wmGASaA,EAAkE,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAM7EC,EAAmE,GAAID,CAAAA,OAAAA,CAAAA,CAAAA,CAMvEE,EAAmD,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAKvDC,EAAe,GAAIJ,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,OAAAA,KA2BZK,CAKX,yBAAA,SAAAC,EAAYC,CAAgDC,CAAAA,CAAAA,CAAAA,CAAAA,eAAAA,MAAAA,CAAAA,EAAAA,CACzDC,KAAKF,IAAOA,CAAAA,CAAAA,EAAMG,aAAcD,CAAAA,IAAAA,CAAAA,CACjCA,KAAKD,OAAU,CAAAG,aAAA,EACbC,KAAMC,QAAND,CAAAA,KAAMC,CAEJ,CAAA,CAAA,GAAIA,EAAMC,YAAa,CAAA,MAAA,CAAA,EAA0C,KAA/BD,CAAME,CAAAA,YAAAA,CAAa,QAAgB,CACnE,GAAMC,CAAAA,GAAOH,CAAMI,CAAAA,WAAAA,CAAAA,CAAAA,CACbC,GAASL,CAAME,CAAA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C,CAAAA,UAAAA,CAAAA,CAAY,EACZC,MAAQ,CAAA,CAAE,IAGPN,CACHC,EAAAA,CAAAA,CAAehD,iBAGZ5D,IAAKF,CAAAA,IAAAA,CAAKoH,cAAcN,CAC3BD,CAAAA,GAAAA,CAAAA,SAAAA,CAAAA,iBAAAA,CAAAA,CAAsB/C,cAEzB,CAAA,CAAA,GAAA,SAAAuD,OAAA,KASUC,CAAoCC,CAAAA,MAAAA,CAAOC,OAAO,CAC7DC,QAAAA,CAAAA,CAAU,EACVC,WAAa,CAAA,CAAA,CAAA,CACbC,iBAAiB,CACjBC,CAAAA,aAAAA,CAAAA,CAAe,EACfC,cAAgB,CAAA,CAAA,CAAA,CAChBC,cAAc,CACdC,CAAAA,OAAAA,CAAAA,CAAS,EACTC,QAAU,CAAA,CAAA,CAAA,CACVC,cAAc,CACdtF,CAAAA,KAAAA,CAAAA,CAAO,EACPuF,YAAc,CAAA,CAAA,CAAA,CAAA,CAAA,EAIwCX,OAAOC,MAAO,CAAApH,aAAA,CAAAA,aAAA,IACjEkH,OACH3E,KAAO,CAAA,CAAA,CAAA,CACPuF,cAAc,CAIuCX,EAAAA,CAAAA,CAAAA,MAAAA,CAAOC,sCACzDF,CAAAA,MACH3E,OAAO,CACP+E,CAAAA,WAAAA,CAAAA,CAAa"}
1
+ {"version":3,"file":"form.cjs.js","sources":["../../../src/internal/form.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { NileFormControl } from '../internal/nile-element';\nimport type { NileButton } from '../nile-button';\n\n//\n// We store a WeakMap of forms + controls so we can keep references to all Nile controls within a given form. As\n// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is\n// added and removed from the form's set, respectively.\n//\nexport const formCollections: WeakMap<HTMLFormElement, Set<NileFormControl>> = new WeakMap();\n\n//\n// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and\n// restore the original behavior when they disconnect.\n//\nconst reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();\n\n//\n// We store a Set of controls that users have interacted with. This allows us to determine the interaction state\n// without littering the DOM with additional data attributes.\n//\nconst userInteractedControls: WeakSet<NileFormControl> = new WeakSet();\n\n//\n// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.\n//\nconst interactions = new WeakMap<NileFormControl, string[]>();\n\nexport interface FormControlControllerOptions {\n /** A function that returns the form containing the form control. */\n form: (input: NileFormControl) => HTMLFormElement | null;\n /** A function that returns the form control's name, which will be submitted with the form data. */\n name: (input: NileFormControl) => string;\n /** A function that returns the form control's current value. */\n value: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's default value. */\n defaultValue: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */\n disabled: (input: NileFormControl) => boolean;\n /**\n * A function that maps to the form control's reportValidity() function. When the control is invalid, this will\n * prevent submission and trigger the browser's constraint violation warning.\n */\n reportValidity: (input: NileFormControl) => boolean;\n /** A function that sets the form control's value */\n setValue: (input: NileFormControl, value: unknown) => void;\n /**\n * An array of event names to listen to. When all events in the list are emitted, the control will receive validity\n * states such as user-valid and user-invalid.user interacted validity states. */\n assumeInteractionOn: string[];\n}\n\n/** A reactive controller to allow form controls to participate in form submission, validation, etc. */\nexport class FormControlController implements ReactiveController {\n host: NileFormControl & ReactiveControllerHost;\n form?: HTMLFormElement | null;\n options: FormControlControllerOptions;\n\n constructor(host: ReactiveControllerHost & NileFormControl, options?: Partial<FormControlControllerOptions>) {\n (this.host = host).addController(this);\n this.options = {\n form: input => {\n // If there's a form attribute, use it to find the target form by id\n if (input.hasAttribute('form') && input.getAttribute('form') !== '') {\n const root = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute('form');\n\n if (formId) {\n return root.getElementById(formId) as HTMLFormElement;\n }\n }\n\n return input.closest('form');\n },\n name: input => input.name,\n value: input => input.value,\n defaultValue: input => input.defaultValue,\n disabled: input => input.disabled ?? false,\n reportValidity: input => (typeof input.reportValidity === 'function' ? input.reportValidity() : true),\n setValue: (input, value: string) => (input.value = value),\n assumeInteractionOn: ['nile-input'],\n ...options\n };\n this.handleFormData = this.handleFormData.bind(this);\n this.handleFormSubmit = this.handleFormSubmit.bind(this);\n this.handleFormReset = this.handleFormReset.bind(this);\n this.reportFormValidity = this.reportFormValidity.bind(this);\n this.handleInteraction = this.handleInteraction.bind(this);\n }\n\n hostConnected() {\n const form = this.options?.form(this.host);\n\n if (form) {\n this.attachForm(form);\n }\n\n // Listen for interactions\n interactions.set(this.host, []);\n this.options?.assumeInteractionOn.forEach(event => {\n this.host.addEventListener(event, this.handleInteraction);\n });\n }\n\n hostDisconnected() {\n this.detachForm();\n\n // Clean up interactions\n interactions.delete(this.host);\n this.options?.assumeInteractionOn.forEach(event => {\n this.host.removeEventListener(event, this.handleInteraction);\n });\n }\n\n hostUpdated() {\n const form = this.options.form(this.host);\n\n // Detach if the form no longer exists\n if (!form) {\n this.detachForm();\n }\n\n // If the form has changed, reattach it\n if (form && this.form !== form) {\n this.detachForm();\n this.attachForm(form);\n }\n\n if (this.host.hasUpdated) {\n this.setValidity(this.host.validity.valid);\n }\n }\n\n private attachForm(form?: HTMLFormElement) {\n if (form) {\n this.form = form;\n\n // Add this element to the form's collection\n if (formCollections.has(this.form)) {\n formCollections.get(this.form)!.add(this.host);\n } else {\n formCollections.set(this.form, new Set<NileFormControl>([this.host]));\n }\n\n this.form.addEventListener('formdata', this.handleFormData);\n this.form.addEventListener('submit', this.handleFormSubmit);\n this.form.addEventListener('reset', this.handleFormReset);\n\n // Overload the form's reportValidity() method so it looks at nile form controls\n if (!reportValidityOverloads.has(this.form)) {\n reportValidityOverloads.set(this.form, this.form.reportValidity);\n this.form.reportValidity = () => this.reportFormValidity();\n }\n } else {\n this.form = undefined;\n }\n }\n\n private detachForm() {\n if (this.form) {\n // Remove this element from the form's collection\n formCollections.get(this.form)?.delete(this.host);\n\n this.form.removeEventListener('formdata', this.handleFormData);\n this.form.removeEventListener('submit', this.handleFormSubmit);\n this.form.removeEventListener('reset', this.handleFormReset);\n\n // Remove the overload and restore the original method\n if (reportValidityOverloads.has(this.form)) {\n this.form.reportValidity = reportValidityOverloads.get(this.form)!;\n reportValidityOverloads.delete(this.form);\n }\n }\n\n this.form = undefined;\n }\n\n private handleFormData(event: FormDataEvent) {\n const disabled = this.options.disabled(this.host);\n const name = this.options.name(this.host);\n const value = this.options.value(this.host);\n\n // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by\n // injecting the name/value on a temporary button, so we can just skip them here.\n const isButton = this.host.tagName.toLowerCase() === 'nile-button';\n\n if (!disabled && !isButton && typeof name === 'string' && name.length > 0 && typeof value !== 'undefined') {\n if (Array.isArray(value)) {\n (value as unknown[]).forEach(val => {\n event.formData.append(name, (val as string | number | boolean).toString());\n });\n } else {\n event.formData.append(name, (value as string | number | boolean).toString());\n }\n }\n }\n\n private handleFormSubmit(event: Event) {\n const disabled = this.options.disabled(this.host);\n const reportValidity = this.options.reportValidity;\n\n // Update the interacted state for all controls when the form is submitted\n if (this.form && !this.form.noValidate) {\n formCollections.get(this.form)?.forEach(control => {\n this.setUserInteracted(control, true);\n });\n }\n\n if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleFormReset() {\n this.options.setValue(this.host, this.options.defaultValue(this.host));\n this.setUserInteracted(this.host, false);\n interactions.set(this.host, []);\n }\n\n private handleInteraction(event: Event) {\n const emittedEvents = interactions.get(this.host)!;\n\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.options.assumeInteractionOn.length) {\n this.setUserInteracted(this.host, true);\n }\n }\n\n private reportFormValidity() {\n //\n // Nile form controls work hard to act like regular form controls. They support the Constraint Validation API\n // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also\n // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using\n // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.\n //\n // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger\n // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't\n // be necessary once we can use ElementInternals.\n //\n // Note that we're also honoring the form's novalidate attribute.\n //\n if (this.form && !this.form.noValidate) {\n // This seems sloppy, but checking all elements will cover native inputs, Nile inputs, and other custom\n // elements that support the constraint validation API.\n const elements = this.form.querySelectorAll<HTMLInputElement>('*');\n\n for (const element of elements) {\n if (typeof element.reportValidity === 'function') {\n if (!element.reportValidity()) {\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n private setUserInteracted(el: NileFormControl, hasInteracted: boolean) {\n if (hasInteracted) {\n userInteractedControls.add(el);\n } else {\n userInteractedControls.delete(el);\n }\n\n el.requestUpdate();\n }\n\n private doAction(type: 'submit' | 'reset', submitter?: HTMLInputElement | NileButton) {\n if (this.form) {\n const button = document.createElement('button');\n button.type = type;\n button.style.position = 'absolute';\n button.style.width = '0';\n button.style.height = '0';\n button.style.clipPath = 'inset(50%)';\n button.style.overflow = 'hidden';\n button.style.whiteSpace = 'nowrap';\n\n // Pass name, value, and form attributes through to the temporary button\n if (submitter) {\n button.name = submitter.name;\n button.value = submitter.value;\n\n ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {\n if (submitter.hasAttribute(attr)) {\n button.setAttribute(attr, submitter.getAttribute(attr)!);\n }\n });\n }\n\n this.form.append(button);\n button.click();\n button.remove();\n }\n }\n\n /** Returns the associated `<form>` element, if one exists. */\n getForm() {\n return this.form ?? null;\n }\n\n /** Resets the form, restoring all the control to their default value */\n reset(submitter?: HTMLInputElement | NileButton) {\n this.doAction('reset', submitter);\n }\n\n /** Submits the form, triggering validation and form data injection. */\n submit(submitter?: HTMLInputElement | NileButton) {\n // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a\n // native submit button into the form, \"click\" it, then remove it to simulate a standard form submission.\n this.doAction('submit', submitter);\n }\n\n /**\n * Synchronously sets the form control's validity. Call this when you know the future validity but need to update\n * the host element immediately, i.e. before Lit updates the component in the next update.\n */\n setValidity(isValid: boolean) {\n const host = this.host;\n const hasInteracted = Boolean(userInteractedControls.has(host));\n const required = Boolean(host.required);\n\n //\n // We're mapping the following \"states\" to data attributes. In the future, we can use ElementInternals.states to\n // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.\n //\n //\n host.toggleAttribute('data-required', required);\n host.toggleAttribute('data-optional', !required);\n host.toggleAttribute('data-invalid', !isValid);\n host.toggleAttribute('data-valid', isValid);\n host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);\n host.toggleAttribute('data-user-valid', isValid && hasInteracted);\n }\n\n /**\n * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything\n * that affects constraint validation changes so the component receives the correct validity states.\n */\n updateValidity() {\n const host = this.host;\n this.setValidity(host.validity.valid);\n }\n\n /**\n * Dispatches a non-bubbling, cancelable custom event of type `nile-invalid`.\n * If the `nile-invalid` event will be cancelled then the original `invalid`\n * event (which may have been passed as argument) will also be cancelled.\n * If no original `invalid` event has been passed then the `nile-invalid`\n * event will be cancelled before being dispatched.\n */\n emitInvalidEvent(originalInvalidEvent?: Event) {\n const slInvalidEvent = new CustomEvent<Record<PropertyKey, never>>('nile-invalid', {\n bubbles: false,\n composed: false,\n cancelable: true,\n detail: {}\n });\n\n if (!originalInvalidEvent) {\n slInvalidEvent.preventDefault();\n }\n\n if (!this.host.dispatchEvent(slInvalidEvent)) {\n originalInvalidEvent?.preventDefault();\n }\n }\n}\n\n/*\n * Predefined common validity states.\n * All of them are read-only.\n */\n\n// A validity state object that represents `valid`\nexport const validValidityState: ValidityState = Object.freeze({\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false\n});\n\n// A validity state object that represents `value missing`\nexport const valueMissingValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n valueMissing: true\n});\n\n// A validity state object that represents a custom error\nexport const customErrorValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n customError: true\n});\n"],"names":["formCollections","WeakMap","reportValidityOverloads","userInteractedControls","WeakSet","interactions","FormControlController","e","host","options","this","addController","_objectSpread","form","input","hasAttribute","getAttribute","root","getRootNode","formId","getElementById","closest","name","value","defaultValue","disabled","reportValidity","setValue","assumeInteractionOn","handleFormData","bind","handleFormSubmit","handleFormReset","reportFormValidity","handleInteraction","_createClass","key","hostConnected","_this$options","_this$options2","_this","attachForm","set","forEach","event","addEventListener","hostDisconnected","detachForm","removeEventListener","hostUpdated","hasUpdated","setValidity","validity","valid","has","get","add","Set","undefined","isButton","tagName","toLowerCase","length","Array","isArray","val","formData","append","toString","noValidate","control","setUserInteracted","preventDefault","stopImmediatePropagation","emittedEvents","includes","type","push","elements","querySelectorAll","_iterator","_createForOfIteratorHelper","s","_step","n","done","element","err","f","el","hasInteracted","delete","requestUpdate","doAction","submitter","button","document","createElement","style","position","width","height","clipPath","overflow","whiteSpace","attr","setAttribute","click","remove","getForm","_this$form","reset","submit","isValid","Boolean","required","toggleAttribute","updateValidity","emitInvalidEvent","originalInvalidEvent","slInvalidEvent","CustomEvent","bubbles","composed","cancelable","detail","dispatchEvent","_export","validValidityState","Object","freeze","badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],"mappings":"wmGASaA,EAAkE,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAM7EC,EAAmE,GAAID,CAAAA,OAAAA,CAAAA,CAAAA,CAMvEE,EAAmD,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAKvDC,EAAe,GAAIJ,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,OAAAA,KA2BZK,CAKX,yBAAA,SAAAC,EAAYC,CAAgDC,CAAAA,CAAAA,CAAAA,CA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,sCACzDF,CAAAA,MACH3E,OAAO,CACP+E,CAAAA,WAAAA,CAAAA,CAAa"}
@@ -1 +1 @@
1
- const t=new WeakMap,i=new WeakMap,s=new WeakSet,h=new WeakMap;class e{constructor(t,i){(this.host=t).addController(this),this.options={form:t=>{if(t.hasAttribute("form")&&""!==t.getAttribute("form")){const i=t.getRootNode(),s=t.getAttribute("form");if(s)return i.getElementById(s)}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled??!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),setValue:(t,i)=>t.value=i,assumeInteractionOn:["nile-input"],...i},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),h.set(this.host,[]),this.options.assumeInteractionOn.forEach((t=>{this.host.addEventListener(t,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),h.delete(this.host),this.options.assumeInteractionOn.forEach((t=>{this.host.removeEventListener(t,this.handleInteraction)}))}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(s){s?(this.form=s,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),i.has(this.form)||(i.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){this.form&&(t.get(this.form)?.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),i.has(this.form)&&(this.form.reportValidity=i.get(this.form),i.delete(this.form))),this.form=void 0}handleFormData(t){const i=this.options.disabled(this.host),s=this.options.name(this.host),h=this.options.value(this.host),e="nile-button"===this.host.tagName.toLowerCase();!i&&!e&&"string"==typeof s&&s.length>0&&void 0!==h&&(Array.isArray(h)?h.forEach((i=>{t.formData.append(s,i.toString())})):t.formData.append(s,h.toString()))}handleFormSubmit(i){const s=this.options.disabled(this.host),h=this.options.reportValidity;this.form&&!this.form.noValidate&&t.get(this.form)?.forEach((t=>{this.setUserInteracted(t,!0)})),!this.form||this.form.noValidate||s||h(this.host)||(i.preventDefault(),i.stopImmediatePropagation())}handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),h.set(this.host,[])}handleInteraction(t){const i=h.get(this.host);i.includes(t.type)||i.push(t.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const i of t)if("function"==typeof i.reportValidity&&!i.reportValidity())return!1}return!0}setUserInteracted(t,i){i?s.add(t):s.delete(t),t.requestUpdate()}doAction(t,i){if(this.form){const s=document.createElement("button");s.type=t,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",i&&(s.name=i.name,s.value=i.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((t=>{i.hasAttribute(t)&&s.setAttribute(t,i.getAttribute(t))}))),this.form.append(s),s.click(),s.remove()}}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const i=this.host,h=Boolean(s.has(i)),e=Boolean(i.required);i.toggleAttribute("data-required",e),i.toggleAttribute("data-optional",!e),i.toggleAttribute("data-invalid",!t),i.toggleAttribute("data-valid",t),i.toggleAttribute("data-user-invalid",!t&&h),i.toggleAttribute("data-user-valid",t&&h)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const i=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||i.preventDefault(),this.host.dispatchEvent(i)||t?.preventDefault()}}const o=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze({...o,valid:!1,valueMissing:!0}),Object.freeze({...o,valid:!1,customError:!0});export{e as F,o as v};
1
+ const t=new WeakMap,i=new WeakMap,s=new WeakSet,h=new WeakMap;class e{constructor(t,i){(this.host=t).addController(this),this.options={form:t=>{if(t.hasAttribute("form")&&""!==t.getAttribute("form")){const i=t.getRootNode(),s=t.getAttribute("form");if(s)return i.getElementById(s)}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled??!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),setValue:(t,i)=>t.value=i,assumeInteractionOn:["nile-input"],...i},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const t=this.options?.form(this.host);t&&this.attachForm(t),h.set(this.host,[]),this.options?.assumeInteractionOn.forEach((t=>{this.host.addEventListener(t,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),h.delete(this.host),this.options?.assumeInteractionOn.forEach((t=>{this.host.removeEventListener(t,this.handleInteraction)}))}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(s){s?(this.form=s,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),i.has(this.form)||(i.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){this.form&&(t.get(this.form)?.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),i.has(this.form)&&(this.form.reportValidity=i.get(this.form),i.delete(this.form))),this.form=void 0}handleFormData(t){const i=this.options.disabled(this.host),s=this.options.name(this.host),h=this.options.value(this.host),e="nile-button"===this.host.tagName.toLowerCase();!i&&!e&&"string"==typeof s&&s.length>0&&void 0!==h&&(Array.isArray(h)?h.forEach((i=>{t.formData.append(s,i.toString())})):t.formData.append(s,h.toString()))}handleFormSubmit(i){const s=this.options.disabled(this.host),h=this.options.reportValidity;this.form&&!this.form.noValidate&&t.get(this.form)?.forEach((t=>{this.setUserInteracted(t,!0)})),!this.form||this.form.noValidate||s||h(this.host)||(i.preventDefault(),i.stopImmediatePropagation())}handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),h.set(this.host,[])}handleInteraction(t){const i=h.get(this.host);i.includes(t.type)||i.push(t.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const i of t)if("function"==typeof i.reportValidity&&!i.reportValidity())return!1}return!0}setUserInteracted(t,i){i?s.add(t):s.delete(t),t.requestUpdate()}doAction(t,i){if(this.form){const s=document.createElement("button");s.type=t,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",i&&(s.name=i.name,s.value=i.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((t=>{i.hasAttribute(t)&&s.setAttribute(t,i.getAttribute(t))}))),this.form.append(s),s.click(),s.remove()}}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const i=this.host,h=Boolean(s.has(i)),e=Boolean(i.required);i.toggleAttribute("data-required",e),i.toggleAttribute("data-optional",!e),i.toggleAttribute("data-invalid",!t),i.toggleAttribute("data-valid",t),i.toggleAttribute("data-user-invalid",!t&&h),i.toggleAttribute("data-user-valid",t&&h)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const i=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||i.preventDefault(),this.host.dispatchEvent(i)||t?.preventDefault()}}const o=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze({...o,valid:!1,valueMissing:!0}),Object.freeze({...o,valid:!1,customError:!0});export{e as F,o as v};
@@ -1,2 +1,2 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js","./nile-chip.css.cjs.js","lit/directives/class-map.js","../internal/slot.cjs.js","../internal/nile-element.cjs.js"],function(_export,_context){"use strict";var t,i,e,s,o,l,h,r,n,a,_templateObject,_templateObject2,_templateObject3,_templateObject4,p;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){i=_lit.html;},function(_litDecoratorsJs){e=_litDecoratorsJs.state;s=_litDecoratorsJs.query;o=_litDecoratorsJs.property;l=_litDecoratorsJs.customElement;},function(_nileChipCssCjsJs){h=_nileChipCssCjsJs.s;},function(_litDirectivesClassMapJs){r=_litDirectivesClassMapJs.classMap;},function(_internalSlotCjsJs){n=_internalSlotCjsJs.H;},function(_internalNileElementCjsJs){a=_internalNileElementCjsJs.N;}],execute:function execute(){_export("N",p=/*#__PURE__*/function(_a){function p(){var _this;_classCallCheck(this,p);_this=_callSuper(this,p,arguments),_this.hasSlotController=new n(_assertThisInitialized(_this),"help-text","label"),_this.tags=[],_this.inputValue="",_this.isDropdownOpen=!1,_this.warning=!1,_this.error=!1,_this.success=!1,_this.noDuplicates=!1,_this.label="",_this.tagVariant="",_this.acceptUserInput=!1,_this.clearable=!1,_this.placeholder="type here...",_this.readonly=!1,_this.disabled=!1,_this.enableVirtualScroll=!1,_this.autoCompleteOptions=[],_this.filteredAutoCompleteOptions=[],_this.value=[],_this.noWrap=!1,_this.loading=!1,_this.errorIndexes=[],_this.helpText="",_this.errorMessage="",_this.filterFunction=function(t,i){return t.toLowerCase().includes(i.toLowerCase());},_this.renderItemFunction=function(t){return t;};return _this;}_inherits(p,_a);return _createClass(p,[{key:"updated",value:function updated(t){var _this2=this;_superPropGet(p,"updated",this,3)([t]),t.has("autoCompleteOptions")&&(this.filteredAutoCompleteOptions=_toConsumableArray(this.autoCompleteOptions),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter(function(t){return!_this2.value.includes(t);}))),t.has("value")&&(this.tags=_toConsumableArray(this.value),this.onTagsChanged()),t.has("tags")&&this.onTagsChanged();}},{key:"connectedCallback",value:function connectedCallback(){var _this3=this;_superPropGet(p,"connectedCallback",this,3)([]),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter(function(t){return!_this3.value.includes(t);})),this.emit("nile-init");}},{key:"disconnectedCallback",value:function disconnectedCallback(){_superPropGet(p,"disconnectedCallback",this,3)([]),this.emit("nile-destroy");}},{key:"render",value:function render(){var _this4=this;var t=this.hasSlotController.test("label");this.hasSlotController.test("help-text");var e=!!this.label||!!t,s=!!this.helpText,o=!!this.errorMessage;return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div\n part=\"form-control\"\n class=","\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=","\n >\n <slot name=\"label\">","</slot>\n </label>\n\n <div\n part='base' \n class=","\n >\n ","\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .enableVirtualScroll=","\n .allMenuItems=","\n .filterFunction=","\n .renderItemFunction=","\n .loading=\"","\"\n .value="," \n ?isDropdownOpen=","\n .noBorder=","\n .noOutline=","\n .noPadding=","\n .disabled=","\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=","\n @nile-input=","\n @keydown=","\n @nile-focus=","\n @nile-complete=","\n ></nile-auto-complete>\n </div>\n </div>\n ","\n\n ","\n </div>\n "])),r({"form-control":!0,"form-control--medium":!0,"form-control--has-label":e,"form-control--has-help-text":s,"nile-chip--disabled":this.disabled}),e?"false":"true",this.label,r({"nile-chip":!0,"nile-chip--warning":this.warning,"nile-chip--error":this.error,"nile-chip--success":this.success,"nile-chip--no-wrap":this.noWrap}),this.tags.map(function(t,e){return i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <nile-tag\n class=","\n .variant=","\n @nile-remove=","\n removable\n ?pill=","\n >\n ","\n </nile-tag>\n "])),r({"nile-chip__tags":!0}),_this4.errorIndexes.includes(e)?"error":"normal",function(){return _this4.handleRemove(t);},"normal"!==_this4.tagVariant,t);}),this.enableVirtualScroll,this.filteredAutoCompleteOptions,this.filterFunction,this.renderItemFunction,this.loading,this.inputValue,this.isDropdownOpen,!0,!0,!0,this.disabled,this.placeholder,this.handleInputChange,this.handleInputKeydown,this.handleFocus,this.handleSelect,s?i(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <nile-form-help-text>","</nile-form-help-text>\n "])),this.helpText):"",o?i(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-form-error-message\n >","</nile-form-error-message\n >\n "])),this.errorMessage):"");}},{key:"handleSelect",value:function handleSelect(t){this.noDuplicates&&this.tags.includes(t.detail.value)||(this.tags=[].concat(_toConsumableArray(this.tags),[t.detail.value]),this.emit("nile-chip-change",{value:this.tags}),this.resetInput());}},{key:"handleRemove",value:function handleRemove(t){this.tags=this.tags.filter(function(i){return i!==t;}),this.noDuplicates&&this.autoCompleteOptions.includes(t)&&(this.filteredAutoCompleteOptions=[].concat(_toConsumableArray(this.filteredAutoCompleteOptions),[t])),this.emit("nile-chip-change",{value:this.tags});}},{key:"handleInputChange",value:function handleInputChange(t){this.inputValue=t.detail.value;}},{key:"handleInputKeydown",value:function handleInputKeydown(t){this.acceptUserInput&&("Tab"===t.key&&t.preventDefault(),"Enter"!==t.key&&"Tab"!==t.key||!this.inputValue||this.noDuplicates&&this.tags.includes(this.inputValue)||(t.preventDefault(),this.tags=[].concat(_toConsumableArray(this.tags),[this.inputValue]),this.resetInput(),this.emit("nile-chip-change",{value:this.tags})),"Enter"!==t.key&&"Tab"!==t.key||!this.inputValue||!this.noDuplicates&&!this.tags.includes(this.inputValue)||this.emit("nile-duplicates-blocked"));}},{key:"handleFocus",value:function handleFocus(){this.isDropdownOpen=!0;}},{key:"onTagsChanged",value:function onTagsChanged(){var _this5=this;this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter(function(t){return!_this5.tags.includes(t);}));}},{key:"resetInput",value:function resetInput(){this.inputValue="",this.isDropdownOpen=!1,this.autoComplete.value="",this.autoComplete.handleFocus();}}],[{key:"styles",get:function get(){return[h];}}]);}(a));t([e()],p.prototype,"tags",void 0),t([e()],p.prototype,"inputValue",void 0),t([e()],p.prototype,"isDropdownOpen",void 0),t([s("nile-auto-complete")],p.prototype,"autoComplete",void 0),t([o({type:Boolean})],p.prototype,"warning",void 0),t([o({type:Boolean})],p.prototype,"error",void 0),t([o({type:Boolean})],p.prototype,"success",void 0),t([o({type:Boolean})],p.prototype,"noDuplicates",void 0),t([o()],p.prototype,"label",void 0),t([o({type:String})],p.prototype,"tagVariant",void 0),t([o({type:Boolean})],p.prototype,"acceptUserInput",void 0),t([o({type:Boolean})],p.prototype,"clearable",void 0),t([o()],p.prototype,"placeholder",void 0),t([o({type:Boolean,reflect:!0})],p.prototype,"readonly",void 0),t([o({type:Boolean,reflect:!0})],p.prototype,"disabled",void 0),t([o({type:Boolean})],p.prototype,"enableVirtualScroll",void 0),t([o({type:Array})],p.prototype,"autoCompleteOptions",void 0),t([o({type:Array})],p.prototype,"filteredAutoCompleteOptions",void 0),t([o({type:Array})],p.prototype,"value",void 0),t([o({type:Boolean})],p.prototype,"noWrap",void 0),t([o({type:Boolean})],p.prototype,"loading",void 0),t([o({type:Array})],p.prototype,"errorIndexes",void 0),t([o({attribute:"help-text",reflect:!0})],p.prototype,"helpText",void 0),t([o({attribute:"error-message",reflect:!0})],p.prototype,"errorMessage",void 0),t([o({attribute:!1})],p.prototype,"filterFunction",void 0),t([o({attribute:!1})],p.prototype,"renderItemFunction",void 0),_export("N",p=t([l("nile-chip")],p));}};});
1
+ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js","./nile-chip.css.cjs.js","lit/directives/class-map.js","../internal/slot.cjs.js","../internal/nile-element.cjs.js"],function(_export,_context){"use strict";var t,i,e,s,o,l,h,r,n,a,_templateObject,_templateObject2,_templateObject3,_templateObject4,p;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){i=_lit.html;},function(_litDecoratorsJs){e=_litDecoratorsJs.state;s=_litDecoratorsJs.query;o=_litDecoratorsJs.property;l=_litDecoratorsJs.customElement;},function(_nileChipCssCjsJs){h=_nileChipCssCjsJs.s;},function(_litDirectivesClassMapJs){r=_litDirectivesClassMapJs.classMap;},function(_internalSlotCjsJs){n=_internalSlotCjsJs.H;},function(_internalNileElementCjsJs){a=_internalNileElementCjsJs.N;}],execute:function execute(){_export("N",p=/*#__PURE__*/function(_a){function p(){var _this;_classCallCheck(this,p);_this=_callSuper(this,p,arguments),_this.hasSlotController=new n(_assertThisInitialized(_this),"help-text","label"),_this.tags=[],_this.inputValue="",_this.isDropdownOpen=!1,_this.warning=!1,_this.error=!1,_this.success=!1,_this.noDuplicates=!1,_this.label="",_this.tagVariant="",_this.acceptUserInput=!1,_this.clearable=!1,_this.placeholder="type here...",_this.readonly=!1,_this.disabled=!1,_this.enableVirtualScroll=!1,_this.autoCompleteOptions=[],_this.filteredAutoCompleteOptions=[],_this.value=[],_this.noWrap=!1,_this.loading=!1,_this.errorIndexes=[],_this.helpText="",_this.errorMessage="",_this.filterFunction=function(t,i){return t.toLowerCase().includes(i.toLowerCase());},_this.renderItemFunction=function(t){return t;};return _this;}_inherits(p,_a);return _createClass(p,[{key:"updated",value:function updated(t){var _this2=this;if(_superPropGet(p,"updated",this,3)([t]),t.has("autoCompleteOptions")){var _t=this.autoCompleteOptions;if("string"==typeof _t)try{_t=JSON.parse(_t);}catch(i){_t=[];}this.filteredAutoCompleteOptions=Array.isArray(_t)?_toConsumableArray(_t):[],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter(function(t){return!_this2.value.includes(t);}));}t.has("value")&&(this.tags=_toConsumableArray(this.value),this.onTagsChanged()),t.has("tags")&&this.onTagsChanged();}},{key:"connectedCallback",value:function connectedCallback(){var _this3=this;_superPropGet(p,"connectedCallback",this,3)([]),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter(function(t){return!_this3.value.includes(t);})),this.emit("nile-init");}},{key:"disconnectedCallback",value:function disconnectedCallback(){_superPropGet(p,"disconnectedCallback",this,3)([]),this.emit("nile-destroy");}},{key:"render",value:function render(){var _this4=this;var t=this.hasSlotController.test("label");this.hasSlotController.test("help-text");var e=!!this.label||!!t,s=!!this.helpText,o=!!this.errorMessage;return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div\n part=\"form-control\"\n class=","\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=","\n >\n <slot name=\"label\">","</slot>\n </label>\n\n <div\n part='base' \n class=","\n >\n ","\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .enableVirtualScroll=","\n .allMenuItems=","\n .filterFunction=","\n .renderItemFunction=","\n .loading=\"","\"\n .value="," \n ?isDropdownOpen=","\n .noBorder=","\n .noOutline=","\n .noPadding=","\n .disabled=","\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=","\n @nile-input=","\n @keydown=","\n @nile-focus=","\n @nile-complete=","\n ></nile-auto-complete>\n </div>\n </div>\n ","\n\n ","\n </div>\n "])),r({"form-control":!0,"form-control--medium":!0,"form-control--has-label":e,"form-control--has-help-text":s,"nile-chip--disabled":this.disabled}),e?"false":"true",this.label,r({"nile-chip":!0,"nile-chip--warning":this.warning,"nile-chip--error":this.error,"nile-chip--success":this.success,"nile-chip--no-wrap":this.noWrap}),this.tags.map(function(t,e){return i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <nile-tag\n class=","\n .variant=","\n @nile-remove=","\n removable\n ?pill=","\n >\n ","\n </nile-tag>\n "])),r({"nile-chip__tags":!0}),_this4.errorIndexes.includes(e)?"error":"normal",function(){return _this4.handleRemove(t);},"normal"!==_this4.tagVariant,t);}),this.enableVirtualScroll,this.filteredAutoCompleteOptions,this.filterFunction,this.renderItemFunction,this.loading,this.inputValue,this.isDropdownOpen,!0,!0,!0,this.disabled,this.placeholder,this.handleInputChange,this.handleInputKeydown,this.handleFocus,this.handleSelect,s?i(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <nile-form-help-text>","</nile-form-help-text>\n "])),this.helpText):"",o?i(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-form-error-message\n >","</nile-form-error-message\n >\n "])),this.errorMessage):"");}},{key:"handleSelect",value:function handleSelect(t){this.noDuplicates&&this.tags.includes(t.detail.value)||(this.tags=[].concat(_toConsumableArray(this.tags),[t.detail.value]),this.emit("nile-chip-change",{value:this.tags}),this.resetInput());}},{key:"handleRemove",value:function handleRemove(t){this.tags=this.tags.filter(function(i){return i!==t;}),this.noDuplicates&&this.autoCompleteOptions.includes(t)&&(this.filteredAutoCompleteOptions=[].concat(_toConsumableArray(this.filteredAutoCompleteOptions),[t])),this.emit("nile-chip-change",{value:this.tags});}},{key:"handleInputChange",value:function handleInputChange(t){this.inputValue=t.detail.value;}},{key:"handleInputKeydown",value:function handleInputKeydown(t){this.acceptUserInput&&("Tab"===t.key&&t.preventDefault(),"Enter"!==t.key&&"Tab"!==t.key||!this.inputValue||this.noDuplicates&&this.tags.includes(this.inputValue)||(t.preventDefault(),this.tags=[].concat(_toConsumableArray(this.tags),[this.inputValue]),this.resetInput(),this.emit("nile-chip-change",{value:this.tags})),"Enter"!==t.key&&"Tab"!==t.key||!this.inputValue||!this.noDuplicates&&!this.tags.includes(this.inputValue)||this.emit("nile-duplicates-blocked"));}},{key:"handleFocus",value:function handleFocus(){this.isDropdownOpen=!0;}},{key:"onTagsChanged",value:function onTagsChanged(){var _this5=this;this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter(function(t){return!_this5.tags.includes(t);}));}},{key:"resetInput",value:function resetInput(){this.inputValue="",this.isDropdownOpen=!1,this.autoComplete.value="",this.autoComplete.handleFocus();}}],[{key:"styles",get:function get(){return[h];}}]);}(a));t([e()],p.prototype,"tags",void 0),t([e()],p.prototype,"inputValue",void 0),t([e()],p.prototype,"isDropdownOpen",void 0),t([s("nile-auto-complete")],p.prototype,"autoComplete",void 0),t([o({type:Boolean})],p.prototype,"warning",void 0),t([o({type:Boolean})],p.prototype,"error",void 0),t([o({type:Boolean})],p.prototype,"success",void 0),t([o({type:Boolean})],p.prototype,"noDuplicates",void 0),t([o()],p.prototype,"label",void 0),t([o({type:String})],p.prototype,"tagVariant",void 0),t([o({type:Boolean})],p.prototype,"acceptUserInput",void 0),t([o({type:Boolean})],p.prototype,"clearable",void 0),t([o()],p.prototype,"placeholder",void 0),t([o({type:Boolean,reflect:!0})],p.prototype,"readonly",void 0),t([o({type:Boolean,reflect:!0})],p.prototype,"disabled",void 0),t([o({type:Boolean})],p.prototype,"enableVirtualScroll",void 0),t([o({type:Array})],p.prototype,"autoCompleteOptions",void 0),t([o({type:Array})],p.prototype,"filteredAutoCompleteOptions",void 0),t([o({type:Array})],p.prototype,"value",void 0),t([o({type:Boolean})],p.prototype,"noWrap",void 0),t([o({type:Boolean})],p.prototype,"loading",void 0),t([o({type:Array})],p.prototype,"errorIndexes",void 0),t([o({attribute:"help-text",reflect:!0})],p.prototype,"helpText",void 0),t([o({attribute:"error-message",reflect:!0})],p.prototype,"errorMessage",void 0),t([o({attribute:!1})],p.prototype,"filterFunction",void 0),t([o({attribute:!1})],p.prototype,"renderItemFunction",void 0),_export("N",p=t([l("nile-chip")],p));}};});
2
2
  //# sourceMappingURL=nile-chip.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-chip.cjs.js","sources":["../../../src/nile-chip/nile-chip.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, query, state, property } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n @property({ type: String }) tagVariant: string = ''; // can be '', 'normal', 'success', etc.\n\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // AUTO-COMPLETE-OPTIONS\n\n /** Virtual scroll in dropdown options. */\n @property({ type: Boolean }) enableVirtualScroll = false;\n\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text', reflect: true }) helpText = '';\n\n @property({ attribute: 'error-message', reflect: true }) errorMessage = '';\n\n @property({ attribute:false}) filterFunction: (item:string,searchedValue:string)=>boolean = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());\n\n @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item;\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has('autoCompleteOptions')) {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n if (changedProperties.has('value')){\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n if (changedProperties.has('tags')){\n this.onTagsChanged();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n part='base' \n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n ?pill=${this.tagVariant !== 'normal'}\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .enableVirtualScroll=${this.enableVirtualScroll}\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .filterFunction=${this.filterFunction}\n .renderItemFunction=${this.renderItemFunction}\n .loading=\"${this.loading}\"\n .value=${this.inputValue} \n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n .noOutline=${true}\n .noPadding=${true}\n .disabled=${this.disabled}\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if(event.key === 'Tab'){\n event.preventDefault()\n }\n \n if (\n (event.key === 'Enter' || event.key === 'Tab' ) \n && this.inputValue \n && (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n event.preventDefault()\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n if(\n (event.key === 'Enter'|| event.key === 'Tab' ) \n && this.inputValue \n && (this.noDuplicates || this.tags.includes(this.inputValue))\n ){\n this.emit('nile-duplicates-blocked');\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n onTagsChanged() {\n if (this.noDuplicates)\n this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));\n }\n\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"],"names":["NileChip","p","this","hasSlotController","HasSlotController","tags","inputValue","isDropdownOpen","warning","error","success","noDuplicates","label","tagVariant","acceptUserInput","clearable","placeholder","readonly","disabled","enableVirtualScroll","autoCompleteOptions","filteredAutoCompleteOptions","value","noWrap","loading","errorIndexes","helpText","errorMessage","filterFunction","item","searchedValue","toLowerCase","includes","renderItemFunction","_this","_inherits","_a","_createClass","key","updated","changedProperties","super","has","filter","option","_toConsumableArray","onTagsChanged","connectedCallback","emit","disconnectedCallback","render","_this4","hasLabelSlot","test","hasLabel","hasHelpText","hasErrorMessage","html","_templateObject","_taggedTemplateLiteral","classMap","map","tag","index","_templateObject2","handleRemove","handleInputChange","handleInputKeydown","handleFocus","handleSelect","_templateObject3","_templateObject4","event","detail","concat","resetInput","preventDefault","autoComplete","__decorate","get","styles","NileElement","state","prototype","query","property","type","Boolean","String","reflect","Array","attribute","_export","customElement"],"mappings":"63JAyBaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,qEAKYC,EAAAA,KAAAA,CAAiBC,kBAAG,GAAIC,CAAAA,CAAAA,CAAAA,sBAAAA,CAAAA,KAAAA,EAEvC,WACA,CAAA,OAAA,CAAA,CAGOF,KAAAA,CAAIG,IAAa,CAAA,EAAA,CAEjBH,KAAAA,CAAUI,UAAAA,CAAW,EAErBJ,CAAAA,KAAAA,CAAcK,gBAAY,CAKNL,CAAAA,KAAAA,CAAOM,OAAG,CAAA,CAAA,CAAA,CAGVN,KAAAA,CAAKO,KAAAA,CAAAA,CAAG,EAGRP,KAAAA,CAAOQ,OAAAA,CAAAA,CAAG,CAGVR,CAAAA,KAAAA,CAAYS,YAAG,CAAA,CAAA,CAAA,CAGhCT,KAAAA,CAAKU,KAAG,CAAA,EAAA,CAEQV,KAAAA,CAAAW,UAAqB,CAAA,EAAA,CAIpBX,KAAAA,CAAeY,eAAG,CAAA,CAAA,CAAA,CAGlBZ,KAAAA,CAASa,SAAAA,CAAAA,CAAG,CAG7Bb,CAAAA,KAAAA,CAAWc,YAAG,cAGkBd,CAAAA,KAAAA,CAAQe,QAAG,CAAA,C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CAAAA,CAAoCvF,CAAAmF,CAAAA,SAAAA,CAAA,SAAA,CAAA,IAAA,EAAA,CAAA,CAE3BL,EAAA,CAA1BO,CAAAA,CAAS,CAAEC,IAAAA,CAAMI,KAAqC1F,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmF,UAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAEFL,EAAA,CAApDO,CAAAA,CAAS,CAAEM,SAAW,CAAA,WAAA,CAAaF,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsBzF,CAAAmF,CAAAA,SAAAA,CAAA,eAAA,EAEVL,CAAAA,CAAAA,CAAAA,CAAA,CAAxDO,CAAAA,CAAS,CAAEM,SAAAA,CAAW,gBAAiBF,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0BzF,CAAAmF,CAAAA,SAAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAE7CL,EAAA,CAA7BO,CAAAA,CAAS,CAAEM,SAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmK3F,EAAAmF,SAAA,CAAA,gBAAA,CAAA,IAAA,EAE3JL,CAAAA,CAAAA,CAAAA,CAAA,CAA7BO,CAAAA,CAAS,CAAEM,SAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAkE3F,CAAAmF,CAAAA,SAAAA,CAAA,oBAAA,CAAA,IAAA,EAAA,CAAA,CAAAS,OAAA,KA3E7E5F,EAAQ8E,CAAA,CAAA,CADpBe,CAAc,CAAA,WAAA,CAAA,CAAA,CACF7F"}
1
+ {"version":3,"file":"nile-chip.cjs.js","sources":["../../../src/nile-chip/nile-chip.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, query, state, property } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n @property({ type: String }) tagVariant: string = ''; // can be '', 'normal', 'success', etc.\n\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // AUTO-COMPLETE-OPTIONS\n\n /** Virtual scroll in dropdown options. */\n @property({ type: Boolean }) enableVirtualScroll = false;\n\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text', reflect: true }) helpText = '';\n\n @property({ attribute: 'error-message', reflect: true }) errorMessage = '';\n\n @property({ attribute:false}) filterFunction: (item:string,searchedValue:string)=>boolean = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());\n\n @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item;\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has('autoCompleteOptions')) {\n let options = this.autoCompleteOptions;\n if (typeof options === 'string') {\n try {\n options = JSON.parse(options);\n } catch (e) {\n options = [];\n }\n }\n this.filteredAutoCompleteOptions = Array.isArray(options) ? [...options] : [];\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n if (changedProperties.has('value')){\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n if (changedProperties.has('tags')){\n this.onTagsChanged();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n part='base' \n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n ?pill=${this.tagVariant !== 'normal'}\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .enableVirtualScroll=${this.enableVirtualScroll}\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .filterFunction=${this.filterFunction}\n .renderItemFunction=${this.renderItemFunction}\n .loading=\"${this.loading}\"\n .value=${this.inputValue} \n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n .noOutline=${true}\n .noPadding=${true}\n .disabled=${this.disabled}\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if(event.key === 'Tab'){\n event.preventDefault()\n }\n \n if (\n (event.key === 'Enter' || event.key === 'Tab' ) \n && this.inputValue \n && (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n event.preventDefault()\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n if(\n (event.key === 'Enter'|| event.key === 'Tab' ) \n && this.inputValue \n && (this.noDuplicates || this.tags.includes(this.inputValue))\n ){\n this.emit('nile-duplicates-blocked');\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n onTagsChanged() {\n if (this.noDuplicates)\n this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));\n }\n\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"],"names":["NileChip","p","constructor","this","hasSlotController","HasSlotController","tags","inputValue","isDropdownOpen","warning","error","success","noDuplicates","label","tagVariant","acceptUserInput","clearable","placeholder","readonly","disabled","enableVirtualScroll","autoCompleteOptions","filteredAutoCompleteOptions","value","noWrap","loading","errorIndexes","helpText","errorMessage","filterFunction","item","searchedValue","toLowerCase","includes","renderItemFunction","_this","_inherits","_a","_createClass","key","updated","changedProperties","super","has","options","JSON","parse","e","Array","isArray","_toConsumableArray","filter","option","onTagsChanged","connectedCallback","emit","disconnectedCallback","render","hasLabelSlot","test","hasLabel","hasHelpText","hasErrorMessage","html","_templateObject","_taggedTemplateLiteral","classMap","map","tag","index","_templateObject2","handleRemove","handleInputChange","handleInputKeydown","handleFocus","handleSelect","_templateObject3","_templateObject4","event","detail","concat","resetInput","preventDefault","autoComplete","__decorate","get","styles","NileElement","state","prototype","query","property","type","Boolean","String","reflect","attribute","_export","customElement"],"mappings":"63JAyBaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,qCAKYC,KAAAA,CAAiBC,iBAAAA,CAAG,GAAIC,CAAAA,CAAAA,CAAAA,sBAAAA,CAAAA,KAAAA,EAEvC,WACA,CAAA,OAAA,CAAA,CAGOF,KAAAA,CAAIG,IAAAA,CAAa,EAEjBH,CAAAA,KAAAA,CAAUI,UAAW,CAAA,EAAA,CAErBJ,KAAAA,CAAcK,cAAAA,CAAAA,CAAY,CAKNL,CAAAA,KAAAA,CAAOM,OAAG,CAAA,CAAA,CAAA,CAGVN,KAAAA,CAAKO,KAAG,CAAA,CAAA,CAAA,CAGRP,KAAAA,CAAOQ,OAAAA,CAAAA,CAAG,CAGVR,CAAAA,KAAAA,CAAYS,YAAG,CAAA,CAAA,CAAA,CAGhCT,KAAAA,CAAKU,KAAAA,CAAG,EAEQV,CAAAA,KAAAA,CAAAW,UAAqB,CAAA,EAAA,CAIpBX,KAAAA,CAAeY,eAAG,CAAA,CAAA,CAAA,CAGlBZ,KAAAA,CAASa,SAAAA,CAAAA,CAAG,CAG7Bb,CAAAA,KAAAA,CAAWc,WAAG,CAAA,cAAA,CAGkBd,KAAAA,CAAQe,QAAAA,CAAAA,CAAG,CAGXf,CAAAA,KAAAA,CAAQgB,QAAG,CAAA,CAAA,CAAA,CAK1BhB,KAAAA,CAAmBiB,mBAAG,CAAA,CAAA,CAAA,CAExBjB,KAAAA,CAAmBkB,mBAAAA,CAAU,EAE7BlB,CAAAA,KAAAA,CAA2BmB,2BAAU,CAAA,EAAA,CAErCnB,KAAAA,CAAKoB,KAAAA,CAAU,E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,IAAA,EAExBL,CAAAA,CAAAA,CAAAA,CAAA,CAA5BO,CAAAA,CAAS,CAAEC,IAAMC,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,CAAoC7F,CAAAyF,CAAAA,SAAAA,CAAA,SAAA,CAAA,IAAA,EAAA,CAAA,CAE3BL,EAAA,CAA1BO,CAAAA,CAAS,CAAEC,IAAAA,CAAM5C,KAAqChD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAyF,UAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAEFL,EAAA,CAApDO,CAAAA,CAAS,CAAEK,SAAW,CAAA,WAAA,CAAaD,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB/F,CAAAyF,CAAAA,SAAAA,CAAA,eAAA,EAEVL,CAAAA,CAAAA,CAAAA,CAAA,CAAxDO,CAAAA,CAAS,CAAEK,SAAAA,CAAW,gBAAiBD,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0B/F,CAAAyF,CAAAA,SAAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAE7CL,EAAA,CAA7BO,CAAAA,CAAS,CAAEK,SAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmKhG,EAAAyF,SAAA,CAAA,gBAAA,CAAA,IAAA,EAE3JL,CAAAA,CAAAA,CAAAA,CAAA,CAA7BO,CAAAA,CAAS,CAAEK,SAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAkEhG,CAAAyF,CAAAA,SAAAA,CAAA,oBAAA,CAAA,IAAA,EAAA,CAAA,CAAAQ,OAAA,KA3E7EjG,EAAQoF,CAAA,CAAA,CADpBc,CAAc,CAAA,WAAA,CAAA,CAAA,CACFlG"}
@@ -1,4 +1,4 @@
1
- import{__decorate as t}from"tslib";import{html as i}from"lit";import{state as e,query as s,property as o,customElement as l}from"lit/decorators.js";import{s as h}from"./nile-chip.css.esm.js";import{classMap as r}from"lit/directives/class-map.js";import{H as n}from"../internal/slot.esm.js";import{N as a}from"../internal/nile-element.esm.js";let p=class extends a{constructor(){super(...arguments),this.hasSlotController=new n(this,"help-text","label"),this.tags=[],this.inputValue="",this.isDropdownOpen=!1,this.warning=!1,this.error=!1,this.success=!1,this.noDuplicates=!1,this.label="",this.tagVariant="",this.acceptUserInput=!1,this.clearable=!1,this.placeholder="type here...",this.readonly=!1,this.disabled=!1,this.enableVirtualScroll=!1,this.autoCompleteOptions=[],this.filteredAutoCompleteOptions=[],this.value=[],this.noWrap=!1,this.loading=!1,this.errorIndexes=[],this.helpText="",this.errorMessage="",this.filterFunction=(t,i)=>t.toLowerCase().includes(i.toLowerCase()),this.renderItemFunction=t=>t}static get styles(){return[h]}updated(t){super.updated(t),t.has("autoCompleteOptions")&&(this.filteredAutoCompleteOptions=[...this.autoCompleteOptions],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t))))),t.has("value")&&(this.tags=[...this.value],this.onTagsChanged()),t.has("tags")&&this.onTagsChanged()}connectedCallback(){super.connectedCallback(),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t)))),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}render(){const t=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const e=!!this.label||!!t,s=!!this.helpText,o=!!this.errorMessage;return i`
1
+ import{__decorate as t}from"tslib";import{html as i}from"lit";import{state as e,query as s,property as o,customElement as l}from"lit/decorators.js";import{s as h}from"./nile-chip.css.esm.js";import{classMap as r}from"lit/directives/class-map.js";import{H as n}from"../internal/slot.esm.js";import{N as a}from"../internal/nile-element.esm.js";let p=class extends a{constructor(){super(...arguments),this.hasSlotController=new n(this,"help-text","label"),this.tags=[],this.inputValue="",this.isDropdownOpen=!1,this.warning=!1,this.error=!1,this.success=!1,this.noDuplicates=!1,this.label="",this.tagVariant="",this.acceptUserInput=!1,this.clearable=!1,this.placeholder="type here...",this.readonly=!1,this.disabled=!1,this.enableVirtualScroll=!1,this.autoCompleteOptions=[],this.filteredAutoCompleteOptions=[],this.value=[],this.noWrap=!1,this.loading=!1,this.errorIndexes=[],this.helpText="",this.errorMessage="",this.filterFunction=(t,i)=>t.toLowerCase().includes(i.toLowerCase()),this.renderItemFunction=t=>t}static get styles(){return[h]}updated(t){if(super.updated(t),t.has("autoCompleteOptions")){let t=this.autoCompleteOptions;if("string"==typeof t)try{t=JSON.parse(t)}catch(i){t=[]}this.filteredAutoCompleteOptions=Array.isArray(t)?[...t]:[],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t))))}t.has("value")&&(this.tags=[...this.value],this.onTagsChanged()),t.has("tags")&&this.onTagsChanged()}connectedCallback(){super.connectedCallback(),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t)))),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}render(){const t=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const e=!!this.label||!!t,s=!!this.helpText,o=!!this.errorMessage;return i`
2
2
  <div
3
3
  part="form-control"
4
4
  class=${r({"form-control":!0,"form-control--medium":!0,"form-control--has-label":e,"form-control--has-help-text":s,"nile-chip--disabled":this.disabled})}
@@ -50,13 +50,13 @@ export class FormControlController {
50
50
  this.handleInteraction = this.handleInteraction.bind(this);
51
51
  }
52
52
  hostConnected() {
53
- const form = this.options.form(this.host);
53
+ const form = this.options?.form(this.host);
54
54
  if (form) {
55
55
  this.attachForm(form);
56
56
  }
57
57
  // Listen for interactions
58
58
  interactions.set(this.host, []);
59
- this.options.assumeInteractionOn.forEach(event => {
59
+ this.options?.assumeInteractionOn.forEach(event => {
60
60
  this.host.addEventListener(event, this.handleInteraction);
61
61
  });
62
62
  }
@@ -64,7 +64,7 @@ export class FormControlController {
64
64
  this.detachForm();
65
65
  // Clean up interactions
66
66
  interactions.delete(this.host);
67
- this.options.assumeInteractionOn.forEach(event => {
67
+ this.options?.assumeInteractionOn.forEach(event => {
68
68
  this.host.removeEventListener(event, this.handleInteraction);
69
69
  });
70
70
  }