jb-select 1.0.11 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/JBSelect.js CHANGED
@@ -84,9 +84,13 @@ class JBSelectWebComponent extends HTMLElement {
84
84
  }
85
85
  initProp() {
86
86
  this.textValue = '';
87
+ /**
88
+ * @type {Record<string, function|null>} callbacks
89
+ */
87
90
  this.callbacks = {
88
91
  getOptionTitle: (option) => { return option; },
89
- getOptionValue: (option) => { return option; }
92
+ getOptionValue: (option) => { return option; },
93
+ getOptionDOM:null
90
94
  };
91
95
  this.value = this.getAttribute('value') || null;
92
96
  // if user set value and current option list is not contain the option.
@@ -264,6 +268,14 @@ class JBSelectWebComponent extends HTMLElement {
264
268
 
265
269
  }
266
270
  createOptionDOM(item){
271
+ if(typeof this.callbacks.getOptionDOM == 'function'){
272
+ return this.callbacks.getOptionDOM(item,this.onOptionClicked.bind(this));
273
+ }else {
274
+ return this._createOptionDom(item);
275
+ }
276
+ }
277
+
278
+ _createOptionDom(item){
267
279
  const optionElement = document.createElement('div');
268
280
  optionElement.classList.add('select-option');
269
281
  //it has defualt function who return wxact same input
@@ -1 +1 @@
1
- {"version":3,"file":"JBSelect.js","sources":["../lib/JBSelect.js"],"sourcesContent":["import HTML from './JBSelect.html';\r\nimport CSS from './JBSelect.scss';\r\nclass JBSelectWebComponent extends HTMLElement {\r\n get value() {\r\n if(this._value){\r\n return this.callbacks.getOptionValue(this._value);\r\n }else{\r\n return null;\r\n }\r\n }\r\n set value(value) {\r\n this._setValueFromOutside(value);\r\n }\r\n get textValue() {\r\n return this._textValue;\r\n }\r\n set textValue(value) {\r\n this._textValue = value;\r\n this._inputElement.value = value;\r\n }\r\n get optionList() {\r\n return this._optionList || [];\r\n }\r\n set optionList(value) {\r\n if(!Array.isArray(value)){\r\n console.error('your provided option list to jb-select is not a array. you must provide array value',{value});\r\n return;\r\n }\r\n this._optionList = value;\r\n //every time optionList get updated we set our value base on current option list we use _notFindedValue in case of value provided to component before optionList\r\n this._displayOptionList = this.filterOptionList(this.textValue);\r\n this._setValueOnOptionListChanged();\r\n this.updateOptionListDOM();\r\n }\r\n get displayOptionList() {\r\n return this._displayOptionList;\r\n }\r\n get isMobileDevice (){ return /Mobi/i.test(window.navigator.userAgent);}\r\n\r\n\r\n constructor() {\r\n super();\r\n this.initWebComponent();\r\n this.initProp();\r\n \r\n }\r\n connectedCallback() {\r\n // standard web component event that called when all of dom is binded\r\n this.callOnLoadEvent();\r\n this.callOnInitEvent();\r\n }\r\n callOnInitEvent() {\r\n var event = new CustomEvent('init', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n callOnLoadEvent() {\r\n var event = new CustomEvent('load', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n initWebComponent() {\r\n this._shadowRoot = this.attachShadow({\r\n mode: 'open'\r\n });\r\n const html = `<style>${CSS}</style>` + '\\n' + HTML;\r\n const element = document.createElement('template');\r\n element.innerHTML = html;\r\n this._shadowRoot.appendChild(element.content.cloneNode(true));\r\n this._webComponentWrapper = this._shadowRoot.querySelector('.jb-select-web-component');\r\n this._inputElement = this._shadowRoot.querySelector('.select-box input');\r\n this._optionListElement = this._shadowRoot.querySelector('.select-list');\r\n this._optionListElementWrapper = this._shadowRoot.querySelector('.select-list-wrapper');\r\n this.registerEventListener();\r\n \r\n }\r\n registerEventListener() {\r\n this._inputElement.addEventListener('change', this.onInputChange.bind(this));\r\n this._inputElement.addEventListener('keypress', this.onInputKeyPress.bind(this));\r\n this._inputElement.addEventListener('keyup', this.onInputKeyup.bind(this));\r\n this._inputElement.addEventListener('focus', this.onInputFocus.bind(this));\r\n this._inputElement.addEventListener('blur', this.onInputBlur.bind(this));\r\n this.shadowRoot.querySelector('.arrow-icon').addEventListener('click', this.onArrowKeyClick.bind(this));\r\n }\r\n initProp() {\r\n this.textValue = '';\r\n this.callbacks = {\r\n getOptionTitle: (option) => { return option; },\r\n getOptionValue: (option) => { return option; }\r\n };\r\n this.value = this.getAttribute('value') || null;\r\n // if user set value and current option list is not contain the option. \r\n // we hold it in _notFindedValue and select value when option value get updated\r\n this._notFindedValue = null;\r\n this.required = false;\r\n }\r\n static get observedAttributes() {\r\n return ['label', 'message', 'value', 'required', 'placeholder'];\r\n }\r\n attributeChangedCallback(name, oldValue, newValue) {\r\n // do something when an attribute has changed\r\n this.onAttributeChange(name, newValue);\r\n }\r\n onAttributeChange(name, value) {\r\n switch (name) {\r\n case 'label':\r\n this._shadowRoot.querySelector('label .label-value').innerHTML = value;\r\n if(value == null || value == undefined || value == \"\"){\r\n this._shadowRoot.querySelector('label').classList.add('--hide');\r\n }else{\r\n this._shadowRoot.querySelector('label').classList.remove('--hide');\r\n }\r\n break;\r\n case 'message':\r\n this._shadowRoot.querySelector('.message-box').innerHTML = value;\r\n break;\r\n case 'value':\r\n this._setValueFromOutside(value);\r\n break;\r\n case 'required':\r\n if (value === \"\" || value == \"true\" || value == true) {\r\n this.required = true;\r\n } else {\r\n this.required = false;\r\n }\r\n break;\r\n case 'placeholder':\r\n this._inputElement.placeholder = value;\r\n break;\r\n }\r\n\r\n }\r\n _setValueOnOptionListChanged(){\r\n //when option list changed we see if current value is valid for new optionlist we set it if not we reset value to null.\r\n //in some scenario value is setted before otionList attached so we store it on this._notFindedValue and after option list setted we set value from this._notFindedValue\r\n if(this.value || this._notFindedValue){\r\n //if select has no prev value or pending not finded value we dont set it becuase user may input some search terms in input box and developer-user update list base on that value\r\n //if we set it to null the search term and this.textvalue will become null and empty too and it make impossible for user to search in dynamic back-end provided searchable list so we put this condition to prevent it\r\n this._setValueFromOutside(this.value || this._notFindedValue);\r\n }\r\n }\r\n _setValueFromOutside(value) {\r\n //when user set value by attribute or value prop directly we call this function\r\n const matchedOption = this.optionList.find((option) => { // if we have value mapper we set selected value by object that match mapper\r\n if (this.callbacks.getOptionValue(option) == value) {\r\n return option;\r\n }\r\n });\r\n if (matchedOption || value == null) {\r\n this._setValue(matchedOption);\r\n } else {\r\n this._notFindedValue = value;\r\n }\r\n\r\n }\r\n _setValue(value) {\r\n this._notFindedValue = null;\r\n this._value = value;\r\n if ((value == null || value == undefined)) {\r\n this.textValue = '';\r\n this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');\r\n } else {\r\n this.textValue = this.callbacks.getOptionTitle(value);\r\n this._shadowRoot.querySelector('.jb-select-web-component').classList.add('--has-value');\r\n }\r\n //if user select an option we rest filter so user see all option again when open a select\r\n this.updateOptionList('');\r\n }\r\n onArrowKeyClick(){\r\n if(this._optionListElementWrapper.classList.contains('--show')){\r\n this.blur();\r\n }else{\r\n this.focus();\r\n }\r\n }\r\n onInputKeyPress() {\r\n //TODO: raise keypress event\r\n //hint: keypres dont called on backspace key\r\n this.onUserTypeResetValue();\r\n }\r\n onInputKeyup(e) {\r\n const inputText = e.target.value;\r\n //here is the rare time we update _value directly becuase we want trigger event that may read value directly from dom\r\n if (e.key === \"Backspace\") {\r\n //becuase on keyprees dont recieve backspace key press\r\n //we use keypress and dont do it all here becuase we dont want arrow key or any other function key to reset value \r\n this.onUserTypeResetValue();\r\n }\r\n this._textValue = inputText;\r\n this.triggerOnInputKeyup(e);\r\n this.updateOptionList(inputText);\r\n }\r\n triggerOnInputKeyup(e){\r\n const event = new KeyboardEvent('keyup',{\r\n altKey:e.altKey,\r\n bubbles:e.bubbles,\r\n cancelable:e.cancelable,\r\n code:e.code,\r\n ctrlKey:e.ctrlKey,\r\n detail:e.detail,\r\n key:e.key,\r\n shiftKey:e.shiftKey,\r\n charCode:e.charCode,\r\n location:e.location,\r\n composed:e.composed,\r\n isComposing:e.isComposing,\r\n metaKey:e.metaKey,\r\n repeat:e.repeat,\r\n keyCode:e.keyCode,\r\n view:e.view\r\n });\r\n this.dispatchEvent(event);\r\n }\r\n onUserTypeResetValue() {\r\n //when use type but dont select we want to reset value becuase typed value is not a valid value\r\n //TODO: check if typed value is the same as current selected value title dont null it\r\n this._value = null;\r\n this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');\r\n }\r\n onInputChange(e) {\r\n const inputText = e.target.value;\r\n //here is the rare time we update _text_value directly becuase we want trigger event that may read value directly from dom\r\n this._textValue = inputText;\r\n }\r\n onInputFocus() {\r\n this.focus();\r\n }\r\n onInputBlur(e) {\r\n let focusedElement = e.relatedTarget;\r\n if (focusedElement === this._optionListElement) {\r\n //user click on a menu item\r\n } else {\r\n this.blur();\r\n }\r\n }\r\n focus(){\r\n this._inputElement.focus();\r\n this.showOptionList();\r\n this._webComponentWrapper.classList.add('--focused');\r\n \r\n }\r\n blur(){\r\n this._webComponentWrapper.classList.remove('--focused');\r\n this.hideOptionList();\r\n this.triggerInputValidation();\r\n }\r\n showOptionList(){\r\n this._optionListElementWrapper.classList.add('--show');\r\n }\r\n hideOptionList() {\r\n this._optionListElementWrapper.classList.remove('--show');\r\n }\r\n updateOptionList(filterText) {\r\n this._displayOptionList = this.filterOptionList(filterText);\r\n this.updateOptionListDOM();\r\n }\r\n updateOptionListDOM() {\r\n const optionDomList = [];\r\n this.displayOptionList.forEach((item) => {\r\n const optionDOM = this.createOptionDOM(item);\r\n optionDomList.push(optionDOM);\r\n });\r\n this._optionListElement.innerHTML = '';\r\n optionDomList.forEach(optionElement => { this._optionListElement.appendChild(optionElement);});\r\n\r\n\r\n }\r\n createOptionDOM(item){\r\n const optionElement = document.createElement('div');\r\n optionElement.classList.add('select-option');\r\n //it has defualt function who return wxact same input\r\n optionElement.innerHTML = this.callbacks.getOptionTitle(item);\r\n optionElement.value = item;\r\n optionElement.addEventListener('click', this.onOptionClicked.bind(this));\r\n return optionElement;\r\n }\r\n onOptionClicked(e) {\r\n const value = e.target.value;\r\n this.selectOption(value);\r\n this.blur();\r\n this._triggerOnChangeEvent();\r\n }\r\n selectOption(value) {\r\n this._setValue(value);\r\n this.triggerInputValidation();\r\n }\r\n filterOptionList(filterString) {\r\n const displayOptionList = [];\r\n this.optionList.filter((option) => {\r\n const optionTitle = this.callbacks.getOptionTitle(option);\r\n const isString = typeof optionTitle == 'string';\r\n if (isString && optionTitle.includes(filterString)) {\r\n displayOptionList.push(option);\r\n }\r\n if (!isString) {\r\n console.warn(\"the provided values for optionsList is not of type string.\", { option, title: optionTitle });\r\n }\r\n });\r\n return displayOptionList;\r\n }\r\n triggerInputValidation(showError = true) {\r\n // this method is public and used outside of component to check if field validity param are met\r\n let errorType = '';\r\n let requiredValid = true;\r\n if (this.required) {\r\n\r\n requiredValid = this.value != null;\r\n if (!requiredValid) {\r\n errorType = 'REQUIRED';\r\n }\r\n }\r\n let isAllValid = requiredValid; //& other validation if they added\r\n if (isAllValid) {\r\n this.clearValidationError();\r\n } else if (showError) {\r\n this.showValidationError(errorType);\r\n }\r\n return {\r\n isAllValid\r\n };\r\n }\r\n showValidationError(errorType) {\r\n if (errorType == 'REQUIRED') {\r\n const label = this.getAttribute('label');\r\n this._shadowRoot.querySelector('.message-box').innerHTML = `${label} حتما باید انتخاب شود`;\r\n this._shadowRoot.querySelector('.message-box').classList.add('--error');\r\n }\r\n }\r\n clearValidationError() {\r\n this._shadowRoot.querySelector('.message-box').innerHTML = this.getAttribute('message') || '';\r\n this._shadowRoot.querySelector('.message-box').classList.remove('--error');\r\n\r\n }\r\n _triggerOnChangeEvent() {\r\n const event = new Event(\"change\");\r\n this.dispatchEvent(event);\r\n }\r\n}\r\nconst myElementNotExists = !customElements.get('jb-select');\r\nif(myElementNotExists){\r\n //prevent duplicate registering\r\n window.customElements.define('jb-select', JBSelectWebComponent);\r\n}\r\n"],"names":["CSS"],"mappings":";;;;AAEA,MAAM,oBAAoB,SAAS,WAAW,CAAC;AAC/C,IAAI,IAAI,KAAK,GAAG;AAChB,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;AACvB,YAAY,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9D,SAAS,KAAI;AACb,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,KAAK;AAC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,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1C,QAAQ,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAClC,KAAK;AACL,CAAC;AACD,MAAM,kBAAkB,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC5D,GAAG,kBAAkB,CAAC;AACtB;AACA,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;AACpE"}
1
+ {"version":3,"file":"JBSelect.js","sources":["../lib/JBSelect.js"],"sourcesContent":["import HTML from './JBSelect.html';\r\nimport CSS from './JBSelect.scss';\r\nclass JBSelectWebComponent extends HTMLElement {\r\n get value() {\r\n if(this._value){\r\n return this.callbacks.getOptionValue(this._value);\r\n }else{\r\n return null;\r\n }\r\n }\r\n set value(value) {\r\n this._setValueFromOutside(value);\r\n }\r\n get textValue() {\r\n return this._textValue;\r\n }\r\n set textValue(value) {\r\n this._textValue = value;\r\n this._inputElement.value = value;\r\n }\r\n get optionList() {\r\n return this._optionList || [];\r\n }\r\n set optionList(value) {\r\n if(!Array.isArray(value)){\r\n console.error('your provided option list to jb-select is not a array. you must provide array value',{value});\r\n return;\r\n }\r\n this._optionList = value;\r\n //every time optionList get updated we set our value base on current option list we use _notFindedValue in case of value provided to component before optionList\r\n this._displayOptionList = this.filterOptionList(this.textValue);\r\n this._setValueOnOptionListChanged();\r\n this.updateOptionListDOM();\r\n }\r\n get displayOptionList() {\r\n return this._displayOptionList;\r\n }\r\n get isMobileDevice (){ return /Mobi/i.test(window.navigator.userAgent);}\r\n\r\n\r\n constructor() {\r\n super();\r\n this.initWebComponent();\r\n this.initProp();\r\n \r\n }\r\n connectedCallback() {\r\n // standard web component event that called when all of dom is binded\r\n this.callOnLoadEvent();\r\n this.callOnInitEvent();\r\n }\r\n callOnInitEvent() {\r\n var event = new CustomEvent('init', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n callOnLoadEvent() {\r\n var event = new CustomEvent('load', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n initWebComponent() {\r\n this._shadowRoot = this.attachShadow({\r\n mode: 'open'\r\n });\r\n const html = `<style>${CSS}</style>` + '\\n' + HTML;\r\n const element = document.createElement('template');\r\n element.innerHTML = html;\r\n this._shadowRoot.appendChild(element.content.cloneNode(true));\r\n this._webComponentWrapper = this._shadowRoot.querySelector('.jb-select-web-component');\r\n this._inputElement = this._shadowRoot.querySelector('.select-box input');\r\n this._optionListElement = this._shadowRoot.querySelector('.select-list');\r\n this._optionListElementWrapper = this._shadowRoot.querySelector('.select-list-wrapper');\r\n this.registerEventListener();\r\n \r\n }\r\n registerEventListener() {\r\n this._inputElement.addEventListener('change', this.onInputChange.bind(this));\r\n this._inputElement.addEventListener('keypress', this.onInputKeyPress.bind(this));\r\n this._inputElement.addEventListener('keyup', this.onInputKeyup.bind(this));\r\n this._inputElement.addEventListener('focus', this.onInputFocus.bind(this));\r\n this._inputElement.addEventListener('blur', this.onInputBlur.bind(this));\r\n this.shadowRoot.querySelector('.arrow-icon').addEventListener('click', this.onArrowKeyClick.bind(this));\r\n }\r\n initProp() {\r\n this.textValue = '';\r\n /**\r\n * @type {Record<string, function|null>} callbacks\r\n */\r\n this.callbacks = {\r\n getOptionTitle: (option) => { return option; },\r\n getOptionValue: (option) => { return option; },\r\n getOptionDOM:null\r\n };\r\n this.value = this.getAttribute('value') || null;\r\n // if user set value and current option list is not contain the option. \r\n // we hold it in _notFindedValue and select value when option value get updated\r\n this._notFindedValue = null;\r\n this.required = false;\r\n }\r\n static get observedAttributes() {\r\n return ['label', 'message', 'value', 'required', 'placeholder'];\r\n }\r\n attributeChangedCallback(name, oldValue, newValue) {\r\n // do something when an attribute has changed\r\n this.onAttributeChange(name, newValue);\r\n }\r\n onAttributeChange(name, value) {\r\n switch (name) {\r\n case 'label':\r\n this._shadowRoot.querySelector('label .label-value').innerHTML = value;\r\n if(value == null || value == undefined || value == \"\"){\r\n this._shadowRoot.querySelector('label').classList.add('--hide');\r\n }else{\r\n this._shadowRoot.querySelector('label').classList.remove('--hide');\r\n }\r\n break;\r\n case 'message':\r\n this._shadowRoot.querySelector('.message-box').innerHTML = value;\r\n break;\r\n case 'value':\r\n this._setValueFromOutside(value);\r\n break;\r\n case 'required':\r\n if (value === \"\" || value == \"true\" || value == true) {\r\n this.required = true;\r\n } else {\r\n this.required = false;\r\n }\r\n break;\r\n case 'placeholder':\r\n this._inputElement.placeholder = value;\r\n break;\r\n }\r\n\r\n }\r\n _setValueOnOptionListChanged(){\r\n //when option list changed we see if current value is valid for new optionlist we set it if not we reset value to null.\r\n //in some scenario value is setted before otionList attached so we store it on this._notFindedValue and after option list setted we set value from this._notFindedValue\r\n if(this.value || this._notFindedValue){\r\n //if select has no prev value or pending not finded value we dont set it becuase user may input some search terms in input box and developer-user update list base on that value\r\n //if we set it to null the search term and this.textvalue will become null and empty too and it make impossible for user to search in dynamic back-end provided searchable list so we put this condition to prevent it\r\n this._setValueFromOutside(this.value || this._notFindedValue);\r\n }\r\n }\r\n _setValueFromOutside(value) {\r\n //when user set value by attribute or value prop directly we call this function\r\n const matchedOption = this.optionList.find((option) => { // if we have value mapper we set selected value by object that match mapper\r\n if (this.callbacks.getOptionValue(option) == value) {\r\n return option;\r\n }\r\n });\r\n if (matchedOption || value == null) {\r\n this._setValue(matchedOption);\r\n } else {\r\n this._notFindedValue = value;\r\n }\r\n\r\n }\r\n _setValue(value) {\r\n this._notFindedValue = null;\r\n this._value = value;\r\n if ((value == null || value == undefined)) {\r\n this.textValue = '';\r\n this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');\r\n } else {\r\n this.textValue = this.callbacks.getOptionTitle(value);\r\n this._shadowRoot.querySelector('.jb-select-web-component').classList.add('--has-value');\r\n }\r\n //if user select an option we rest filter so user see all option again when open a select\r\n this.updateOptionList('');\r\n }\r\n onArrowKeyClick(){\r\n if(this._optionListElementWrapper.classList.contains('--show')){\r\n this.blur();\r\n }else{\r\n this.focus();\r\n }\r\n }\r\n onInputKeyPress() {\r\n //TODO: raise keypress event\r\n //hint: keypres dont called on backspace key\r\n this.onUserTypeResetValue();\r\n }\r\n onInputKeyup(e) {\r\n const inputText = e.target.value;\r\n //here is the rare time we update _value directly becuase we want trigger event that may read value directly from dom\r\n if (e.key === \"Backspace\") {\r\n //becuase on keyprees dont recieve backspace key press\r\n //we use keypress and dont do it all here becuase we dont want arrow key or any other function key to reset value \r\n this.onUserTypeResetValue();\r\n }\r\n this._textValue = inputText;\r\n this.triggerOnInputKeyup(e);\r\n this.updateOptionList(inputText);\r\n }\r\n triggerOnInputKeyup(e){\r\n const event = new KeyboardEvent('keyup',{\r\n altKey:e.altKey,\r\n bubbles:e.bubbles,\r\n cancelable:e.cancelable,\r\n code:e.code,\r\n ctrlKey:e.ctrlKey,\r\n detail:e.detail,\r\n key:e.key,\r\n shiftKey:e.shiftKey,\r\n charCode:e.charCode,\r\n location:e.location,\r\n composed:e.composed,\r\n isComposing:e.isComposing,\r\n metaKey:e.metaKey,\r\n repeat:e.repeat,\r\n keyCode:e.keyCode,\r\n view:e.view\r\n });\r\n this.dispatchEvent(event);\r\n }\r\n onUserTypeResetValue() {\r\n //when use type but dont select we want to reset value becuase typed value is not a valid value\r\n //TODO: check if typed value is the same as current selected value title dont null it\r\n this._value = null;\r\n this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');\r\n }\r\n onInputChange(e) {\r\n const inputText = e.target.value;\r\n //here is the rare time we update _text_value directly becuase we want trigger event that may read value directly from dom\r\n this._textValue = inputText;\r\n }\r\n onInputFocus() {\r\n this.focus();\r\n }\r\n onInputBlur(e) {\r\n let focusedElement = e.relatedTarget;\r\n if (focusedElement === this._optionListElement) {\r\n //user click on a menu item\r\n } else {\r\n this.blur();\r\n }\r\n }\r\n focus(){\r\n this._inputElement.focus();\r\n this.showOptionList();\r\n this._webComponentWrapper.classList.add('--focused');\r\n \r\n }\r\n blur(){\r\n this._webComponentWrapper.classList.remove('--focused');\r\n this.hideOptionList();\r\n this.triggerInputValidation();\r\n }\r\n showOptionList(){\r\n this._optionListElementWrapper.classList.add('--show');\r\n }\r\n hideOptionList() {\r\n this._optionListElementWrapper.classList.remove('--show');\r\n }\r\n updateOptionList(filterText) {\r\n this._displayOptionList = this.filterOptionList(filterText);\r\n this.updateOptionListDOM();\r\n }\r\n updateOptionListDOM() {\r\n const optionDomList = [];\r\n this.displayOptionList.forEach((item) => {\r\n const optionDOM = this.createOptionDOM(item);\r\n optionDomList.push(optionDOM);\r\n });\r\n this._optionListElement.innerHTML = '';\r\n optionDomList.forEach(optionElement => { this._optionListElement.appendChild(optionElement);});\r\n\r\n\r\n }\r\n createOptionDOM(item){\r\n if(typeof this.callbacks.getOptionDOM == 'function'){\r\n return this.callbacks.getOptionDOM(item,this.onOptionClicked.bind(this));\r\n }else{\r\n return this._createOptionDom(item);\r\n }\r\n }\r\n\r\n _createOptionDom(item){\r\n const optionElement = document.createElement('div');\r\n optionElement.classList.add('select-option');\r\n //it has defualt function who return wxact same input\r\n optionElement.innerHTML = this.callbacks.getOptionTitle(item);\r\n optionElement.value = item;\r\n optionElement.addEventListener('click', this.onOptionClicked.bind(this));\r\n return optionElement;\r\n }\r\n onOptionClicked(e) {\r\n const value = e.target.value;\r\n this.selectOption(value);\r\n this.blur();\r\n this._triggerOnChangeEvent();\r\n }\r\n selectOption(value) {\r\n this._setValue(value);\r\n this.triggerInputValidation();\r\n }\r\n filterOptionList(filterString) {\r\n const displayOptionList = [];\r\n this.optionList.filter((option) => {\r\n const optionTitle = this.callbacks.getOptionTitle(option);\r\n const isString = typeof optionTitle == 'string';\r\n if (isString && optionTitle.includes(filterString)) {\r\n displayOptionList.push(option);\r\n }\r\n if (!isString) {\r\n console.warn(\"the provided values for optionsList is not of type string.\", { option, title: optionTitle });\r\n }\r\n });\r\n return displayOptionList;\r\n }\r\n triggerInputValidation(showError = true) {\r\n // this method is public and used outside of component to check if field validity param are met\r\n let errorType = '';\r\n let requiredValid = true;\r\n if (this.required) {\r\n\r\n requiredValid = this.value != null;\r\n if (!requiredValid) {\r\n errorType = 'REQUIRED';\r\n }\r\n }\r\n let isAllValid = requiredValid; //& other validation if they added\r\n if (isAllValid) {\r\n this.clearValidationError();\r\n } else if (showError) {\r\n this.showValidationError(errorType);\r\n }\r\n return {\r\n isAllValid\r\n };\r\n }\r\n showValidationError(errorType) {\r\n if (errorType == 'REQUIRED') {\r\n const label = this.getAttribute('label');\r\n this._shadowRoot.querySelector('.message-box').innerHTML = `${label} حتما باید انتخاب شود`;\r\n this._shadowRoot.querySelector('.message-box').classList.add('--error');\r\n }\r\n }\r\n clearValidationError() {\r\n this._shadowRoot.querySelector('.message-box').innerHTML = this.getAttribute('message') || '';\r\n this._shadowRoot.querySelector('.message-box').classList.remove('--error');\r\n\r\n }\r\n _triggerOnChangeEvent() {\r\n const event = new Event(\"change\");\r\n this.dispatchEvent(event);\r\n }\r\n}\r\nconst myElementNotExists = !customElements.get('jb-select');\r\nif(myElementNotExists){\r\n //prevent duplicate registering\r\n window.customElements.define('jb-select', JBSelectWebComponent);\r\n}\r\n"],"names":["CSS"],"mappings":";;;;AAEA,MAAM,oBAAoB,SAAS,WAAW,CAAC;AAC/C,IAAI,IAAI,KAAK,GAAG;AAChB,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;AACvB,YAAY,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9D,SAAS,KAAI;AACb,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,KAAK;AACL,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,QAAQ,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,IAAI,SAAS,GAAG;AACpB,QAAQ,OAAO,IAAI,CAAC,UAAU,CAAC;AAC/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CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AACtG,QAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACnF;AACA,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1C,QAAQ,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAClC,KAAK;AACL,CAAC;AACD,MAAM,kBAAkB,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC5D,GAAG,kBAAkB,CAAC;AACtB;AACA,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;AACpE"}
package/lib/JBSelect.js CHANGED
@@ -82,9 +82,13 @@ class JBSelectWebComponent extends HTMLElement {
82
82
  }
83
83
  initProp() {
84
84
  this.textValue = '';
85
+ /**
86
+ * @type {Record<string, function|null>} callbacks
87
+ */
85
88
  this.callbacks = {
86
89
  getOptionTitle: (option) => { return option; },
87
- getOptionValue: (option) => { return option; }
90
+ getOptionValue: (option) => { return option; },
91
+ getOptionDOM:null
88
92
  };
89
93
  this.value = this.getAttribute('value') || null;
90
94
  // if user set value and current option list is not contain the option.
@@ -264,6 +268,14 @@ class JBSelectWebComponent extends HTMLElement {
264
268
 
265
269
  }
266
270
  createOptionDOM(item){
271
+ if(typeof this.callbacks.getOptionDOM == 'function'){
272
+ return this.callbacks.getOptionDOM(item,this.onOptionClicked.bind(this));
273
+ }else{
274
+ return this._createOptionDom(item);
275
+ }
276
+ }
277
+
278
+ _createOptionDom(item){
267
279
  const optionElement = document.createElement('div');
268
280
  optionElement.classList.add('select-option');
269
281
  //it has defualt function who return wxact same input
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "select",
13
13
  "web component"
14
14
  ],
15
- "version": "1.0.11",
15
+ "version": "1.1.0",
16
16
  "bugs": "https://github.com/javadbat/jb-select/issues",
17
17
  "license": "MIT",
18
18
  "files": [