jb-select 1.0.10 → 2.0.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
@@ -40,6 +40,27 @@ for example if you have array of object as a option list and want to show custom
40
40
  ```js
41
41
  dropDownElement.callbacks.getOptionTitle = (option)=>{return`${option.province}-${option.state}-${option.city}`}
42
42
  dropDownElement.callbacks.getOptionValue = (option)=>{return`${option.value}`}
43
+ //to customizing options
44
+ dropDownElement.callbacks.getOptionDOM = (option,onOptionSelected)=>{
45
+ // option is the object or any other formatted data yoy=u privide to optionList array
46
+ const optionElement = document.createElement('div');
47
+ //defualt class of each option in jb-select. you can change or customize it if you wish
48
+ optionElement.classList.add('select-option');
49
+ // here in this example we want to show a color list with color sample next to it
50
+ optionElement.innerHTML = '<span part="color-box" style="background-color:'+option.colorCode+';width:16px;height:16px"></span>'+'&nbsp;'+option.name;
51
+ //onOptionSelected is a function you have to call when option selected it mostly bind on on option dom clicked'
52
+ // if you want to set onClick on dom other than returned wrapper DOM for example on a color-box you must set value property on it: colorBoxDOM.value = option; colorBoxDOM.addEventListener('click', onOptionSelected);
53
+ optionElement.addEventListener('click', onOptionSelected);
54
+ //return HTMLElement in the end
55
+ return optionElement;
56
+ }
57
+ //to customizing selected value
58
+ dropDownElement.callbacks.getSelectedValueDOM = (option)=>{
59
+ const optionElement = document.createElement('div');
60
+ optionElement.classList.add('selected-value');
61
+ optionElement.innerHTML = '<span part="color-box" style="background-color:'+option.value+';width:16px;height:16px"></span>'+'&nbsp;'+option.name;
62
+ return optionElement;
63
+ }
43
64
  ```
44
65
 
45
66
  remember you must set this callback before set your optionList
@@ -73,4 +94,6 @@ if you want to set a custom style to this web-component all you need is to set c
73
94
  | --jb-select-option-color-hover | change option text color on hover |
74
95
  | --jb-select-option-background-color | background of options default is `#fff` |
75
96
  | --jb-select-option-background-color-hover | background of options on mouse hover default is `#1073db` |
97
+ | --jb-select-input-color | color of input value |
98
+ | --jb-select-bgcolor-selected | set background color for selected status |
76
99
 
package/dist/JBSelect.js CHANGED
@@ -1,6 +1,6 @@
1
- var HTML = "<div class=\"jb-select-web-component\">\r\n <label class=\"--hide\"><span class=\"label-value\"></span><span>:</span></label>\r\n <div class=\"select-box\">\r\n <input class=\"input\">\r\n <div class=\"arrow-icon\"></div>\r\n </div>\r\n <div class=\"select-list-wrapper\">\r\n <div class=\"select-list\" tabindex=\"-1\">\r\n\r\n </div>\r\n </div>\r\n <div class=\"message-box\"></div>\r\n</div>";
1
+ var HTML = "<div class=\"jb-select-web-component\">\r\n <label class=\"--hide\"><span class=\"label-value\"></span><span>:</span></label>\r\n <div class=\"select-box\">\r\n <div class=\"selected-value-wrapper\">\r\n \r\n </div>\r\n <div class=\"front-box\">\r\n <input class=\"input\">\r\n <div class=\"arrow-icon\"></div>\r\n </div>\r\n </div>\r\n <div class=\"select-list-wrapper\">\r\n <div class=\"select-list\" tabindex=\"-1\">\r\n\r\n </div>\r\n </div>\r\n <div class=\"message-box\"></div>\r\n</div>";
2
2
 
3
- var css_248z = ".jb-select-web-component {\n width: var(--jb-select-width, 100%);\n margin: var(--jb-select-margin, 12px 0);\n position: relative;\n box-sizing: border-box; }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component.--focused {\n position: absolute;\n top: 0;\n left: 0;\n background-color: #0008;\n width: 100vw;\n height: 100vh;\n margin: 0;\n padding: 16px 8px;\n z-index: 900; } }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component.--focused .select-list-wrapper {\n position: initial;\n margin: 16px 0;\n border-radius: var(--jb-select-border-radius, 16px); } }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component.--focused label {\n color: #fff;\n font-size: 1.5em; } }\n .jb-select-web-component.--has-value .select-box {\n border-color: var(--jb-select-border-color-selected, #c3ff14); }\n .jb-select-web-component label {\n width: 100%;\n margin: 4px 0px;\n display: block;\n font-size: 0.8em;\n color: var(--jb-select-label-color, #1f1735); }\n .jb-select-web-component label.--hide {\n display: none; }\n .jb-select-web-component .select-box {\n width: 100%;\n box-sizing: border-box;\n height: 40px;\n border: solid var(--jb-select-border-width, 1px) var(--jb-select-border-color, #f7f6f6);\n background-color: var(--jb-select-bgcolor, #f7f6f6);\n border-bottom: solid var(--jb-select-border-bottom-width, 3px) var(--jb-select-border-color, #f7f6f6);\n border-radius: var(--jb-select-border-radius, 16px);\n margin: 4px 0px;\n overflow: hidden;\n display: flex;\n justify-content: space-between;\n padding-inline-end: 16px;\n gap: 8px; }\n .jb-select-web-component .select-box:focus-within {\n border-color: var(--jb-select-border-color, #1e2832);\n border-bottom-color: var(--jb-select-border-color, #f7f6f6);\n border-radius: var(--jb-select-border-radius, 16px) var(--jb-select-border-radius, 16px) 0 0; }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component .select-box:focus-within {\n border-radius: var(--jb-select-border-radius, 16px);\n border-bottom-color: var(--jb-select-border-color, #1e2832); } }\n .jb-select-web-component .select-box input {\n border: none;\n width: 100%;\n box-sizing: border-box;\n height: 100%;\n background-color: transparent;\n padding: 2px 12px 0 12px;\n display: block;\n font-family: inherit;\n font-size: 1.1em;\n color: var(--jb-select-input-color, #1f1735);\n margin: 0;\n border-radius: 0; }\n .jb-select-web-component .select-box input:focus {\n outline: none; }\n .jb-select-web-component .select-box .arrow-icon {\n width: 8px;\n height: 100%;\n background-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 494.1 371.1' style='enable-background:new 0 0 494.1 371.1;' xml:space='preserve'><path d='M293,343.8L480.9,69.3c8.7-12.7,13.3-25.4,13.3-36.1c0-20.5-16.5-33.2-44-33.2H44C16.4,0,0,12.7,0,33.2 c0,10.6,4.6,23.2,13.3,35.9l187.9,274.6c12.1,17.7,28.4,27.4,45.9,27.4C264.6,371.1,280.9,361.4,293,343.8z'/></svg>\");\n background-position: end;\n background-repeat: no-repeat;\n background-position-x: 0;\n background-position-y: center; }\n .jb-select-web-component .message-box {\n font-size: 0.7em;\n padding: 2px 8px;\n color: #929292; }\n .jb-select-web-component .message-box:empty {\n padding: 0; }\n .jb-select-web-component .message-box.--error {\n color: red; }\n .jb-select-web-component .select-list-wrapper {\n display: none;\n position: absolute;\n margin: -6px 0;\n height: auto;\n overflow: hidden;\n width: 100%;\n background-color: var(--jb-select-bgcolor, #f7f6f6);\n border-radius: 0 0 var(--jb-select-border-radius, 16px) var(--jb-select-border-radius, 16px);\n border: solid 1px var(--jb-select-border-color, #1e2832);\n border-top: none;\n border-bottom: solid 3px var(--jb-select-border-color, #1e2832);\n box-shadow: var(--jb-select-list-box-shadow);\n box-sizing: border-box;\n z-index: 999; }\n .jb-select-web-component .select-list-wrapper.--show {\n display: block; }\n .jb-select-web-component .select-list-wrapper .select-list {\n width: 100%;\n max-height: var(--jb-select-list-max-height, 400px);\n overflow-y: auto;\n padding: 16px 0; }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component .select-list-wrapper .select-list {\n max-height: calc(100vh - 240px); } }\n .jb-select-web-component .select-list-wrapper .select-list .select-option {\n min-height: 36px;\n padding: 4px 16px;\n display: flex;\n align-items: center;\n font-size: 0.9em;\n color: var(--jb-select-option-color, inherit);\n background-color: var(--jb-select-option-background-color, #fff); }\n .jb-select-web-component .select-list-wrapper .select-list .select-option:hover {\n background-color: var(--jb-select-option-background-color-hover, #1073db);\n color: var(--jb-select-option-color-hover, #fff);\n cursor: pointer; }\n\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkpCU2VsZWN0LnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFDRSxtQ0FBbUM7RUFDbkMsdUNBQXVDO0VBQ3ZDLGtCQUFrQjtFQUNsQixzQkFBc0IsRUFBRTtFQUN4QjtJQUNFO01BQ0Usa0JBQWt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gICAgIGNvbG9yOiB2YXIoLS1qYi1zZWxlY3Qtb3B0aW9uLWNvbG9yLCBpbmhlcml0KTtcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogdmFyKC0tamItc2VsZWN0LW9wdGlvbi1iYWNrZ3JvdW5kLWNvbG9yLCAjZmZmKTsgfVxuICAgICAgICAuamItc2VsZWN0LXdlYi1jb21wb25lbnQgLnNlbGVjdC1saXN0LXdyYXBwZXIgLnNlbGVjdC1saXN0IC5zZWxlY3Qtb3B0aW9uOmhvdmVyIHtcbiAgICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiB2YXIoLS1qYi1zZWxlY3Qtb3B0aW9uLWJhY2tncm91bmQtY29sb3ItaG92ZXIsICMxMDczZGIpO1xuICAgICAgICAgIGNvbG9yOiB2YXIoLS1qYi1zZWxlY3Qtb3B0aW9uLWNvbG9yLWhvdmVyLCAjZmZmKTtcbiAgICAgICAgICBjdXJzb3I6IHBvaW50ZXI7IH1cbiJdfQ== */";
3
+ var css_248z = ".jb-select-web-component {\n width: var(--jb-select-width, 100%);\n margin: var(--jb-select-margin, 12px 0);\n position: relative;\n box-sizing: border-box;\n}\n@media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component.--focused {\n position: absolute;\n top: 0;\n left: 0;\n background-color: #0008;\n width: 100vw;\n height: 100vh;\n margin: 0;\n padding: 16px 8px;\n z-index: 900;\n }\n}\n@media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component.--focused .select-list-wrapper {\n position: initial;\n margin: 16px 0;\n border-radius: var(--jb-select-border-radius, 16px);\n }\n}\n@media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component.--focused label {\n color: #fff;\n font-size: 1.5em;\n }\n}\n.jb-select-web-component.--has-value .select-box {\n border-color: var(--jb-select-border-color-selected, #c3ff14);\n background-color: var(--jb-select-bgcolor-selected, #f7f6f6);\n}\n.jb-select-web-component label {\n width: 100%;\n margin: 4px 0px;\n display: block;\n font-size: 0.8em;\n color: var(--jb-select-label-color, #1f1735);\n}\n.jb-select-web-component label.--hide {\n display: none;\n}\n.jb-select-web-component .select-box {\n width: 100%;\n box-sizing: border-box;\n height: 40px;\n border: solid var(--jb-select-border-width, 1px) var(--jb-select-border-color, #f7f6f6);\n background-color: var(--jb-select-bgcolor, #f7f6f6);\n border-bottom: solid var(--jb-select-border-bottom-width, 3px) var(--jb-select-border-color, #f7f6f6);\n border-radius: var(--jb-select-border-radius, 16px);\n margin: 4px 0px;\n overflow: hidden;\n display: flex;\n justify-content: space-between;\n padding-inline-end: 16px;\n gap: 8px;\n position: relative;\n}\n.jb-select-web-component .select-box:focus-within {\n border-color: var(--jb-select-border-color, #1e2832);\n border-bottom-color: var(--jb-select-border-color, #f7f6f6);\n border-radius: var(--jb-select-border-radius, 16px) var(--jb-select-border-radius, 16px) 0 0;\n}\n@media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component .select-box:focus-within {\n border-radius: var(--jb-select-border-radius, 16px);\n border-bottom-color: var(--jb-select-border-color, #1e2832);\n }\n}\n.jb-select-web-component .select-box .selected-value-wrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n border-radius: inherit;\n overflow: hidden;\n z-index: 1;\n}\n.jb-select-web-component .select-box .selected-value-wrapper.--search-typed {\n opacity: 0;\n}\n.jb-select-web-component .select-box .selected-value-wrapper .selected-value {\n width: 100%;\n box-sizing: border-box;\n height: 100%;\n background-color: transparent;\n padding: 2px 12px 0 12px;\n display: block;\n font-family: inherit;\n font-size: 1.1em;\n color: #1f1735;\n margin: 0;\n border-radius: 0;\n display: flex;\n align-items: center;\n}\n.jb-select-web-component .select-box:focus-within .selected-value {\n opacity: 0.7;\n transition: all 0.3s ease;\n}\n.jb-select-web-component .select-box .front-box {\n position: absolute;\n width: 100%;\n height: 100%;\n border-radius: inherit;\n overflow: hidden;\n z-index: 2;\n}\n.jb-select-web-component .select-box .front-box input {\n border: none;\n width: 100%;\n box-sizing: border-box;\n height: 100%;\n background-color: transparent;\n padding: 2px 12px 0 12px;\n display: block;\n font-family: inherit;\n font-size: 1.1em;\n color: var(--jb-select-input-color, #1f1735);\n margin: 0;\n border-radius: 0;\n}\n.jb-select-web-component .select-box .front-box input:focus {\n outline: none;\n}\n.jb-select-web-component .select-box .front-box .arrow-icon {\n width: 8px;\n height: 100%;\n background-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 494.1 371.1' style='enable-background:new 0 0 494.1 371.1;' xml:space='preserve'><path d='M293,343.8L480.9,69.3c8.7-12.7,13.3-25.4,13.3-36.1c0-20.5-16.5-33.2-44-33.2H44C16.4,0,0,12.7,0,33.2 c0,10.6,4.6,23.2,13.3,35.9l187.9,274.6c12.1,17.7,28.4,27.4,45.9,27.4C264.6,371.1,280.9,361.4,293,343.8z'/></svg>\");\n background-position: end;\n background-repeat: no-repeat;\n background-position-x: 0;\n background-position-y: center;\n}\n.jb-select-web-component .message-box {\n font-size: 0.7em;\n padding: 2px 8px;\n color: #929292;\n}\n.jb-select-web-component .message-box:empty {\n padding: 0;\n}\n.jb-select-web-component .message-box.--error {\n color: red;\n}\n.jb-select-web-component .select-list-wrapper {\n display: none;\n position: absolute;\n margin: -6px 0;\n height: auto;\n overflow: hidden;\n width: 100%;\n background-color: var(--jb-select-bgcolor, #f7f6f6);\n border-radius: 0 0 var(--jb-select-border-radius, 16px) var(--jb-select-border-radius, 16px);\n border: solid 1px var(--jb-select-border-color, #1e2832);\n border-top: none;\n border-bottom: solid 3px var(--jb-select-border-color, #1e2832);\n box-shadow: var(--jb-select-list-box-shadow);\n box-sizing: border-box;\n z-index: 999;\n}\n.jb-select-web-component .select-list-wrapper.--show {\n display: block;\n}\n.jb-select-web-component .select-list-wrapper .select-list {\n width: 100%;\n max-height: var(--jb-select-list-max-height, 400px);\n overflow-y: auto;\n padding: 16px 0;\n}\n@media (min-width: 320px) and (max-width: 767px) {\n .jb-select-web-component .select-list-wrapper .select-list {\n max-height: calc(100vh - 240px);\n }\n}\n.jb-select-web-component .select-list-wrapper .select-list .select-option {\n min-height: 36px;\n padding: 4px 16px;\n display: flex;\n align-items: center;\n font-size: 0.9em;\n color: var(--jb-select-option-color, inherit);\n background-color: var(--jb-select-option-background-color, #fff);\n}\n.jb-select-web-component .select-list-wrapper .select-list .select-option:hover {\n background-color: var(--jb-select-option-background-color-hover, #1073db);\n color: var(--jb-select-option-color-hover, #fff);\n cursor: pointer;\n}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkpCU2VsZWN0LnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFDRSxtQ0FBbUM7RUFDbkMsdUNBQXVDO0VBQ3ZDLGtCQUFrQjtFQUNsQixzQkFBc0I7QUFDeEI7QUFDQTtFQUNFO0lBQ0Usa0JBQWtCO0lBQ2xCLE1BQU07SUFDTixPQUFPO0lBQ1AsdUJBQXVCO0lBQ3ZCLFlBQVk7SUFDWixhQUFhO0lBQ2IsU0FBUztJQUNULGlCQUFpQjtJQUNqQixZQUFZO0VBQ2Q7QUFDRjtBQUNBO0VBQ0U7SUFDRSxpQkFBaUI7SUFDakIsY0FBYztJQUNkLG1EQUFtRDtFQUNyRDtBQUNGO0FBQ0E7RUFDRTtJQUNFLFdBQVc7SUFDWCxnQkFBZ0I7RUFDbEI7QUFDRjtBQUNBO0VBQ0UsNkRBQTZEO0VBQzdELDREQUE0RDtBQUM5RDtBQUNBO0VBQ0UsV0FBVztFQUNYLGVBQWU7RUFDZixjQUFjO0VBQ2QsZ0JBQWdCO0VBQ2hCLDRDQUE0QztBQUM5QztBQUNBO0VBQ0UsYUFBYTtBQUNmO0FBQ0E7RUFDRSxXQUFXO0VBQ1gsc0JBQXNCO0VBQ3RCLFlBQVk7RUFDWix1RkFBdUY7RUFDdkYsbURBQW1EO0VBQ25ELHFHQU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XNpemU6IDAuOWVtO1xuICBjb2xvcjogdmFyKC0tamItc2VsZWN0LW9wdGlvbi1jb2xvciwgaW5oZXJpdCk7XG4gIGJhY2tncm91bmQtY29sb3I6IHZhcigtLWpiLXNlbGVjdC1vcHRpb24tYmFja2dyb3VuZC1jb2xvciwgI2ZmZik7XG59XG4uamItc2VsZWN0LXdlYi1jb21wb25lbnQgLnNlbGVjdC1saXN0LXdyYXBwZXIgLnNlbGVjdC1saXN0IC5zZWxlY3Qtb3B0aW9uOmhvdmVyIHtcbiAgYmFja2dyb3VuZC1jb2xvcjogdmFyKC0tamItc2VsZWN0LW9wdGlvbi1iYWNrZ3JvdW5kLWNvbG9yLWhvdmVyLCAjMTA3M2RiKTtcbiAgY29sb3I6IHZhcigtLWpiLXNlbGVjdC1vcHRpb24tY29sb3ItaG92ZXIsICNmZmYpO1xuICBjdXJzb3I6IHBvaW50ZXI7XG59Il19 */";
4
4
 
5
5
  class JBSelectWebComponent extends HTMLElement {
6
6
  get value() {
@@ -18,7 +18,8 @@ class JBSelectWebComponent extends HTMLElement {
18
18
  }
19
19
  set textValue(value) {
20
20
  this._textValue = value;
21
- this._inputElement.value = value;
21
+ this.elements.input.value = value;
22
+ this.updateOptionList(value);
22
23
  }
23
24
  get optionList() {
24
25
  return this._optionList || [];
@@ -60,33 +61,43 @@ class JBSelectWebComponent extends HTMLElement {
60
61
  this.dispatchEvent(event);
61
62
  }
62
63
  initWebComponent() {
63
- this._shadowRoot = this.attachShadow({
64
+ const shadowRoot = this.attachShadow({
64
65
  mode: 'open'
65
66
  });
66
67
  const html = `<style>${css_248z}</style>` + '\n' + HTML;
67
68
  const element = document.createElement('template');
68
69
  element.innerHTML = html;
69
- this._shadowRoot.appendChild(element.content.cloneNode(true));
70
- this._webComponentWrapper = this._shadowRoot.querySelector('.jb-select-web-component');
71
- this._inputElement = this._shadowRoot.querySelector('.select-box input');
72
- this._optionListElement = this._shadowRoot.querySelector('.select-list');
73
- this._optionListElementWrapper = this._shadowRoot.querySelector('.select-list-wrapper');
70
+ shadowRoot.appendChild(element.content.cloneNode(true));
71
+ this.elements = {
72
+ input: shadowRoot.querySelector('.select-box input'),
73
+ componentWrapper: shadowRoot.querySelector('.jb-select-web-component'),
74
+ selectedValueWrapper: shadowRoot.querySelector('.selected-value-wrapper'),
75
+ };
76
+ this._optionListElement = shadowRoot.querySelector('.select-list');
77
+ this._optionListElementWrapper = shadowRoot.querySelector('.select-list-wrapper');
74
78
  this.registerEventListener();
75
79
 
76
80
  }
77
81
  registerEventListener() {
78
- this._inputElement.addEventListener('change', this.onInputChange.bind(this));
79
- this._inputElement.addEventListener('keypress', this.onInputKeyPress.bind(this));
80
- this._inputElement.addEventListener('keyup', this.onInputKeyup.bind(this));
81
- this._inputElement.addEventListener('focus', this.onInputFocus.bind(this));
82
- this._inputElement.addEventListener('blur', this.onInputBlur.bind(this));
82
+ this.elements.input.addEventListener('change', this.onInputChange.bind(this));
83
+ this.elements.input.addEventListener('keypress', this.onInputKeyPress.bind(this));
84
+ this.elements.input.addEventListener('keyup', this.onInputKeyup.bind(this));
85
+ this.elements.input.addEventListener('beforeinput', this.onInputBeforeInput.bind(this));
86
+ this.elements.input.addEventListener('input', this.onInputInput.bind(this));
87
+ this.elements.input.addEventListener('focus', this.onInputFocus.bind(this));
88
+ this.elements.input.addEventListener('blur', this.onInputBlur.bind(this));
83
89
  this.shadowRoot.querySelector('.arrow-icon').addEventListener('click', this.onArrowKeyClick.bind(this));
84
90
  }
85
91
  initProp() {
86
92
  this.textValue = '';
93
+ /**
94
+ * @type {Record<string, function|null>} callbacks
95
+ */
87
96
  this.callbacks = {
88
97
  getOptionTitle: (option) => { return option; },
89
- getOptionValue: (option) => { return option; }
98
+ getOptionValue: (option) => { return option; },
99
+ getOptionDOM:null,
100
+ getSelectedValueDOM:null,
90
101
  };
91
102
  this.value = this.getAttribute('value') || null;
92
103
  // if user set value and current option list is not contain the option.
@@ -104,15 +115,15 @@ class JBSelectWebComponent extends HTMLElement {
104
115
  onAttributeChange(name, value) {
105
116
  switch (name) {
106
117
  case 'label':
107
- this._shadowRoot.querySelector('label .label-value').innerHTML = value;
118
+ this.shadowRoot.querySelector('label .label-value').innerHTML = value;
108
119
  if(value == null || value == undefined || value == ""){
109
- this._shadowRoot.querySelector('label').classList.add('--hide');
120
+ this.shadowRoot.querySelector('label').classList.add('--hide');
110
121
  }else {
111
- this._shadowRoot.querySelector('label').classList.remove('--hide');
122
+ this.shadowRoot.querySelector('label').classList.remove('--hide');
112
123
  }
113
124
  break;
114
125
  case 'message':
115
- this._shadowRoot.querySelector('.message-box').innerHTML = value;
126
+ this.shadowRoot.querySelector('.message-box').innerHTML = value;
116
127
  break;
117
128
  case 'value':
118
129
  this._setValueFromOutside(value);
@@ -125,7 +136,7 @@ class JBSelectWebComponent extends HTMLElement {
125
136
  }
126
137
  break;
127
138
  case 'placeholder':
128
- this._inputElement.placeholder = value;
139
+ this.elements.input.placeholder = value;
129
140
  break;
130
141
  }
131
142
 
@@ -158,10 +169,12 @@ class JBSelectWebComponent extends HTMLElement {
158
169
  this._value = value;
159
170
  if ((value == null || value == undefined)) {
160
171
  this.textValue = '';
161
- this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');
172
+ this.setSelectedOptionDom(null);
173
+ this.shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');
162
174
  } else {
163
- this.textValue = this.callbacks.getOptionTitle(value);
164
- this._shadowRoot.querySelector('.jb-select-web-component').classList.add('--has-value');
175
+ this.textValue = '';
176
+ this.setSelectedOptionDom(value);
177
+ this.shadowRoot.querySelector('.jb-select-web-component').classList.add('--has-value');
165
178
  }
166
179
  //if user select an option we rest filter so user see all option again when open a select
167
180
  this.updateOptionList('');
@@ -175,20 +188,30 @@ class JBSelectWebComponent extends HTMLElement {
175
188
  }
176
189
  onInputKeyPress() {
177
190
  //TODO: raise keypress event
178
- //hint: keypres dont called on backspace key
179
- this.onUserTypeResetValue();
191
+ }
192
+ onInputBeforeInput(e){
193
+ this.handleSelectedValueDisplay(e.data);
194
+ }
195
+ onInputInput(e){
196
+ this.textValue = e.target.value;
180
197
  }
181
198
  onInputKeyup(e) {
182
199
  const inputText = e.target.value;
183
200
  //here is the rare time we update _value directly becuase we want trigger event that may read value directly from dom
184
- if (e.key === "Backspace") {
201
+ if (e.key === "Backspace" || e.key === "Delete") {
185
202
  //becuase on keyprees dont recieve backspace key press
186
- //we use keypress and dont do it all here becuase we dont want arrow key or any other function key to reset value
187
- this.onUserTypeResetValue();
203
+ this.handleSelectedValueDisplay(inputText);
188
204
  }
189
- this._textValue = inputText;
205
+
190
206
  this.triggerOnInputKeyup(e);
191
- this.updateOptionList(inputText);
207
+
208
+ }
209
+ handleSelectedValueDisplay(inputValue) {
210
+ if(inputValue !== ""){
211
+ this.elements.selectedValueWrapper.classList.add('--search-typed');
212
+ }else {
213
+ this.elements.selectedValueWrapper.classList.remove('--search-typed');
214
+ }
192
215
  }
193
216
  triggerOnInputKeyup(e){
194
217
  const event = new KeyboardEvent('keyup',{
@@ -211,12 +234,6 @@ class JBSelectWebComponent extends HTMLElement {
211
234
  });
212
235
  this.dispatchEvent(event);
213
236
  }
214
- onUserTypeResetValue() {
215
- //when use type but dont select we want to reset value becuase typed value is not a valid value
216
- //TODO: check if typed value is the same as current selected value title dont null it
217
- this._value = null;
218
- this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');
219
- }
220
237
  onInputChange(e) {
221
238
  const inputText = e.target.value;
222
239
  //here is the rare time we update _text_value directly becuase we want trigger event that may read value directly from dom
@@ -232,13 +249,15 @@ class JBSelectWebComponent extends HTMLElement {
232
249
  }
233
250
  }
234
251
  focus(){
235
- this._inputElement.focus();
252
+ this.elements.input.focus();
236
253
  this.showOptionList();
237
- this._webComponentWrapper.classList.add('--focused');
254
+ this.elements.componentWrapper.classList.add('--focused');
238
255
 
239
256
  }
240
257
  blur(){
241
- this._webComponentWrapper.classList.remove('--focused');
258
+ this.elements.componentWrapper.classList.remove('--focused');
259
+ this.textValue = "";
260
+ this.handleSelectedValueDisplay('');
242
261
  this.hideOptionList();
243
262
  this.triggerInputValidation();
244
263
  }
@@ -264,16 +283,26 @@ class JBSelectWebComponent extends HTMLElement {
264
283
 
265
284
  }
266
285
  createOptionDOM(item){
286
+ let optionDOM = null;
287
+ if(typeof this.callbacks.getOptionDOM == 'function'){
288
+ optionDOM = this.callbacks.getOptionDOM(item,this.onOptionClicked.bind(this));
289
+ }else {
290
+ optionDOM = this._createOptionDom(item);
291
+ }
292
+ optionDOM.value = item;
293
+ return optionDOM;
294
+ }
295
+
296
+ _createOptionDom(item){
267
297
  const optionElement = document.createElement('div');
268
298
  optionElement.classList.add('select-option');
269
299
  //it has defualt function who return wxact same input
270
300
  optionElement.innerHTML = this.callbacks.getOptionTitle(item);
271
- optionElement.value = item;
272
301
  optionElement.addEventListener('click', this.onOptionClicked.bind(this));
273
302
  return optionElement;
274
303
  }
275
304
  onOptionClicked(e) {
276
- const value = e.target.value;
305
+ const value = e.currentTarget.value;
277
306
  this.selectOption(value);
278
307
  this.blur();
279
308
  this._triggerOnChangeEvent();
@@ -285,9 +314,14 @@ class JBSelectWebComponent extends HTMLElement {
285
314
  filterOptionList(filterString) {
286
315
  const displayOptionList = [];
287
316
  this.optionList.filter((option) => {
288
- if (typeof this.callbacks.getOptionTitle(option) == 'string' && this.callbacks.getOptionTitle(option).includes(filterString)) {
317
+ const optionTitle = this.callbacks.getOptionTitle(option);
318
+ const isString = typeof optionTitle == 'string';
319
+ if (isString && optionTitle.includes(filterString)) {
289
320
  displayOptionList.push(option);
290
321
  }
322
+ if (!isString) {
323
+ console.warn("the provided values for optionsList is not of type string.", { option, title: optionTitle });
324
+ }
291
325
  });
292
326
  return displayOptionList;
293
327
  }
@@ -315,19 +349,42 @@ class JBSelectWebComponent extends HTMLElement {
315
349
  showValidationError(errorType) {
316
350
  if (errorType == 'REQUIRED') {
317
351
  const label = this.getAttribute('label');
318
- this._shadowRoot.querySelector('.message-box').innerHTML = `${label} حتما باید انتخاب شود`;
319
- this._shadowRoot.querySelector('.message-box').classList.add('--error');
352
+ this.shadowRoot.querySelector('.message-box').innerHTML = `${label} حتما باید انتخاب شود`;
353
+ this.shadowRoot.querySelector('.message-box').classList.add('--error');
320
354
  }
321
355
  }
322
356
  clearValidationError() {
323
- this._shadowRoot.querySelector('.message-box').innerHTML = this.getAttribute('message') || '';
324
- this._shadowRoot.querySelector('.message-box').classList.remove('--error');
357
+ this.shadowRoot.querySelector('.message-box').innerHTML = this.getAttribute('message') || '';
358
+ this.shadowRoot.querySelector('.message-box').classList.remove('--error');
325
359
 
326
360
  }
327
361
  _triggerOnChangeEvent() {
328
362
  const event = new Event("change");
329
363
  this.dispatchEvent(event);
330
364
  }
365
+ setSelectedOptionDom(value) {
366
+ //when user select option or value changed in any condition we set selected option DOM
367
+ this.elements.selectedValueWrapper.innerHTML = '';
368
+ //if value was null or undifined it remain empty
369
+ if(value !== null && value !== undefined){
370
+ const selectedOptionDom = this.createSelectedValueDom(value);
371
+ this.elements.selectedValueWrapper.appendChild(selectedOptionDom);
372
+ }
373
+ }
374
+ createSelectedValueDom(value){
375
+ if(typeof this.callbacks.getSelectedValueDOM == 'function'){
376
+ return this.callbacks.getSelectedValueDOM(value);
377
+ }else {
378
+ return this._createSelectedValueDom(value);
379
+ }
380
+ }
381
+ _createSelectedValueDom(value){
382
+ const valueText = this.callbacks.getOptionTitle(value);
383
+ const selectedOptionDom = document.createElement('div');
384
+ selectedOptionDom.classList.add('selected-value');
385
+ selectedOptionDom.innerHTML = valueText;
386
+ return selectedOptionDom;
387
+ }
331
388
  }
332
389
  const myElementNotExists = !customElements.get('jb-select');
333
390
  if(myElementNotExists){
@@ -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 if (typeof this.callbacks.getOptionTitle(option) == 'string' && this.callbacks.getOptionTitle(option).includes(filterString)) {\r\n displayOptionList.push(option);\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;A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C;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"}
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.elements.input.value = value;\r\n this.updateOptionList(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 const 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 shadowRoot.appendChild(element.content.cloneNode(true));\r\n this.elements = {\r\n input: shadowRoot.querySelector('.select-box input'),\r\n componentWrapper: shadowRoot.querySelector('.jb-select-web-component'),\r\n selectedValueWrapper: shadowRoot.querySelector('.selected-value-wrapper'),\r\n };\r\n this._optionListElement = shadowRoot.querySelector('.select-list');\r\n this._optionListElementWrapper = shadowRoot.querySelector('.select-list-wrapper');\r\n this.registerEventListener();\r\n \r\n }\r\n registerEventListener() {\r\n this.elements.input.addEventListener('change', this.onInputChange.bind(this));\r\n this.elements.input.addEventListener('keypress', this.onInputKeyPress.bind(this));\r\n this.elements.input.addEventListener('keyup', this.onInputKeyup.bind(this));\r\n this.elements.input.addEventListener('beforeinput', this.onInputBeforeInput.bind(this));\r\n this.elements.input.addEventListener('input', this.onInputInput.bind(this));\r\n this.elements.input.addEventListener('focus', this.onInputFocus.bind(this));\r\n this.elements.input.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 getSelectedValueDOM: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.elements.input.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.setSelectedOptionDom(null);\r\n this.shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');\r\n } else {\r\n this.textValue = '';\r\n this.setSelectedOptionDom(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 }\r\n onInputBeforeInput(e){\r\n this.handleSelectedValueDisplay(e.data);\r\n }\r\n onInputInput(e){\r\n this.textValue = e.target.value;\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\" || e.key === \"Delete\") {\r\n //becuase on keyprees dont recieve backspace key press\r\n this.handleSelectedValueDisplay(inputText);\r\n }\r\n \r\n this.triggerOnInputKeyup(e);\r\n \r\n }\r\n handleSelectedValueDisplay(inputValue) {\r\n if(inputValue !== \"\"){\r\n this.elements.selectedValueWrapper.classList.add('--search-typed');\r\n }else{\r\n this.elements.selectedValueWrapper.classList.remove('--search-typed');\r\n }\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 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.elements.input.focus();\r\n this.showOptionList();\r\n this.elements.componentWrapper.classList.add('--focused');\r\n \r\n }\r\n blur(){\r\n this.elements.componentWrapper.classList.remove('--focused');\r\n this.textValue = \"\";\r\n this.handleSelectedValueDisplay('');\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 let optionDOM = null;\r\n if(typeof this.callbacks.getOptionDOM == 'function'){\r\n optionDOM = this.callbacks.getOptionDOM(item,this.onOptionClicked.bind(this));\r\n }else{\r\n optionDOM = this._createOptionDom(item);\r\n }\r\n optionDOM.value = item;\r\n return optionDOM;\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.addEventListener('click', this.onOptionClicked.bind(this));\r\n return optionElement;\r\n }\r\n onOptionClicked(e) {\r\n const value = e.currentTarget.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 setSelectedOptionDom(value) {\r\n //when user select option or value changed in any condition we set selected option DOM\r\n this.elements.selectedValueWrapper.innerHTML = '';\r\n //if value was null or undifined it remain empty\r\n if(value !== null && value !== undefined){\r\n const selectedOptionDom = this.createSelectedValueDom(value);\r\n this.elements.selectedValueWrapper.appendChild(selectedOptionDom);\r\n }\r\n }\r\n createSelectedValueDom(value){\r\n if(typeof this.callbacks.getSelectedValueDOM == 'function'){\r\n return this.callbacks.getSelectedValueDOM(value);\r\n }else{\r\n return this._createSelectedValueDom(value);\r\n }\r\n }\r\n _createSelectedValueDom(value){\r\n const valueText = this.callbacks.getOptionTitle(value);\r\n const selectedOptionDom = document.createElement('div');\r\n selectedOptionDom.classList.add('selected-value');\r\n selectedOptionDom.innerHTML = valueText;\r\n return selectedOptionDom;\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/B,KAAK;AACL,IAAI,IAAI,SAAS,CAAC,KAAK,EAAE;AACzB,QAAQ,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;AAChC,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;AAC1C,QAAQ,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACrC,KAAK;AACL,IAAI,IAAI,UAAU,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;AACtC,KAAK;AACL,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE;AAC1B,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,CA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AC;AACzE,YAAY,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC9E,SAAS;AACT,KAAK;AACL,IAAI,sBAAsB,CAAC,KAAK,CAAC;AACjC,QAAQ,GAAG,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,IAAI,UAAU,CAAC;AACnE,YAAY,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC7D,SAAS,KAAI;AACb,YAAY,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;AACvD,SAAS;AACT,KAAK;AACL,IAAI,uBAAuB,CAAC,KAAK,CAAC;AAClC,QAAQ,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/D,QAAQ,MAAM,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAChE,QAAQ,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC1D,QAAQ,iBAAiB,CAAC,SAAS,GAAG,SAAS,CAAC;AAChD,QAAQ,OAAO,iBAAiB,CAAC;AACjC,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.html CHANGED
@@ -1,8 +1,13 @@
1
1
  <div class="jb-select-web-component">
2
2
  <label class="--hide"><span class="label-value"></span><span>:</span></label>
3
3
  <div class="select-box">
4
- <input class="input"/>
5
- <div class="arrow-icon"></div>
4
+ <div class="selected-value-wrapper">
5
+
6
+ </div>
7
+ <div class="front-box">
8
+ <input class="input"/>
9
+ <div class="arrow-icon"></div>
10
+ </div>
6
11
  </div>
7
12
  <div class="select-list-wrapper">
8
13
  <div class="select-list" tabindex="-1">
package/lib/JBSelect.js CHANGED
@@ -16,7 +16,8 @@ class JBSelectWebComponent extends HTMLElement {
16
16
  }
17
17
  set textValue(value) {
18
18
  this._textValue = value;
19
- this._inputElement.value = value;
19
+ this.elements.input.value = value;
20
+ this.updateOptionList(value);
20
21
  }
21
22
  get optionList() {
22
23
  return this._optionList || [];
@@ -58,33 +59,43 @@ class JBSelectWebComponent extends HTMLElement {
58
59
  this.dispatchEvent(event);
59
60
  }
60
61
  initWebComponent() {
61
- this._shadowRoot = this.attachShadow({
62
+ const shadowRoot = this.attachShadow({
62
63
  mode: 'open'
63
64
  });
64
65
  const html = `<style>${CSS}</style>` + '\n' + HTML;
65
66
  const element = document.createElement('template');
66
67
  element.innerHTML = html;
67
- this._shadowRoot.appendChild(element.content.cloneNode(true));
68
- this._webComponentWrapper = this._shadowRoot.querySelector('.jb-select-web-component');
69
- this._inputElement = this._shadowRoot.querySelector('.select-box input');
70
- this._optionListElement = this._shadowRoot.querySelector('.select-list');
71
- this._optionListElementWrapper = this._shadowRoot.querySelector('.select-list-wrapper');
68
+ shadowRoot.appendChild(element.content.cloneNode(true));
69
+ this.elements = {
70
+ input: shadowRoot.querySelector('.select-box input'),
71
+ componentWrapper: shadowRoot.querySelector('.jb-select-web-component'),
72
+ selectedValueWrapper: shadowRoot.querySelector('.selected-value-wrapper'),
73
+ };
74
+ this._optionListElement = shadowRoot.querySelector('.select-list');
75
+ this._optionListElementWrapper = shadowRoot.querySelector('.select-list-wrapper');
72
76
  this.registerEventListener();
73
77
 
74
78
  }
75
79
  registerEventListener() {
76
- this._inputElement.addEventListener('change', this.onInputChange.bind(this));
77
- this._inputElement.addEventListener('keypress', this.onInputKeyPress.bind(this));
78
- this._inputElement.addEventListener('keyup', this.onInputKeyup.bind(this));
79
- this._inputElement.addEventListener('focus', this.onInputFocus.bind(this));
80
- this._inputElement.addEventListener('blur', this.onInputBlur.bind(this));
80
+ this.elements.input.addEventListener('change', this.onInputChange.bind(this));
81
+ this.elements.input.addEventListener('keypress', this.onInputKeyPress.bind(this));
82
+ this.elements.input.addEventListener('keyup', this.onInputKeyup.bind(this));
83
+ this.elements.input.addEventListener('beforeinput', this.onInputBeforeInput.bind(this));
84
+ this.elements.input.addEventListener('input', this.onInputInput.bind(this));
85
+ this.elements.input.addEventListener('focus', this.onInputFocus.bind(this));
86
+ this.elements.input.addEventListener('blur', this.onInputBlur.bind(this));
81
87
  this.shadowRoot.querySelector('.arrow-icon').addEventListener('click', this.onArrowKeyClick.bind(this));
82
88
  }
83
89
  initProp() {
84
90
  this.textValue = '';
91
+ /**
92
+ * @type {Record<string, function|null>} callbacks
93
+ */
85
94
  this.callbacks = {
86
95
  getOptionTitle: (option) => { return option; },
87
- getOptionValue: (option) => { return option; }
96
+ getOptionValue: (option) => { return option; },
97
+ getOptionDOM:null,
98
+ getSelectedValueDOM:null,
88
99
  };
89
100
  this.value = this.getAttribute('value') || null;
90
101
  // if user set value and current option list is not contain the option.
@@ -102,15 +113,15 @@ class JBSelectWebComponent extends HTMLElement {
102
113
  onAttributeChange(name, value) {
103
114
  switch (name) {
104
115
  case 'label':
105
- this._shadowRoot.querySelector('label .label-value').innerHTML = value;
116
+ this.shadowRoot.querySelector('label .label-value').innerHTML = value;
106
117
  if(value == null || value == undefined || value == ""){
107
- this._shadowRoot.querySelector('label').classList.add('--hide');
118
+ this.shadowRoot.querySelector('label').classList.add('--hide');
108
119
  }else{
109
- this._shadowRoot.querySelector('label').classList.remove('--hide');
120
+ this.shadowRoot.querySelector('label').classList.remove('--hide');
110
121
  }
111
122
  break;
112
123
  case 'message':
113
- this._shadowRoot.querySelector('.message-box').innerHTML = value;
124
+ this.shadowRoot.querySelector('.message-box').innerHTML = value;
114
125
  break;
115
126
  case 'value':
116
127
  this._setValueFromOutside(value);
@@ -123,7 +134,7 @@ class JBSelectWebComponent extends HTMLElement {
123
134
  }
124
135
  break;
125
136
  case 'placeholder':
126
- this._inputElement.placeholder = value;
137
+ this.elements.input.placeholder = value;
127
138
  break;
128
139
  }
129
140
 
@@ -156,10 +167,12 @@ class JBSelectWebComponent extends HTMLElement {
156
167
  this._value = value;
157
168
  if ((value == null || value == undefined)) {
158
169
  this.textValue = '';
159
- this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');
170
+ this.setSelectedOptionDom(null);
171
+ this.shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');
160
172
  } else {
161
- this.textValue = this.callbacks.getOptionTitle(value);
162
- this._shadowRoot.querySelector('.jb-select-web-component').classList.add('--has-value');
173
+ this.textValue = '';
174
+ this.setSelectedOptionDom(value);
175
+ this.shadowRoot.querySelector('.jb-select-web-component').classList.add('--has-value');
163
176
  }
164
177
  //if user select an option we rest filter so user see all option again when open a select
165
178
  this.updateOptionList('');
@@ -173,20 +186,30 @@ class JBSelectWebComponent extends HTMLElement {
173
186
  }
174
187
  onInputKeyPress() {
175
188
  //TODO: raise keypress event
176
- //hint: keypres dont called on backspace key
177
- this.onUserTypeResetValue();
189
+ }
190
+ onInputBeforeInput(e){
191
+ this.handleSelectedValueDisplay(e.data);
192
+ }
193
+ onInputInput(e){
194
+ this.textValue = e.target.value;
178
195
  }
179
196
  onInputKeyup(e) {
180
197
  const inputText = e.target.value;
181
198
  //here is the rare time we update _value directly becuase we want trigger event that may read value directly from dom
182
- if (e.key === "Backspace") {
199
+ if (e.key === "Backspace" || e.key === "Delete") {
183
200
  //becuase on keyprees dont recieve backspace key press
184
- //we use keypress and dont do it all here becuase we dont want arrow key or any other function key to reset value
185
- this.onUserTypeResetValue();
201
+ this.handleSelectedValueDisplay(inputText);
186
202
  }
187
- this._textValue = inputText;
203
+
188
204
  this.triggerOnInputKeyup(e);
189
- this.updateOptionList(inputText);
205
+
206
+ }
207
+ handleSelectedValueDisplay(inputValue) {
208
+ if(inputValue !== ""){
209
+ this.elements.selectedValueWrapper.classList.add('--search-typed');
210
+ }else{
211
+ this.elements.selectedValueWrapper.classList.remove('--search-typed');
212
+ }
190
213
  }
191
214
  triggerOnInputKeyup(e){
192
215
  const event = new KeyboardEvent('keyup',{
@@ -209,12 +232,6 @@ class JBSelectWebComponent extends HTMLElement {
209
232
  });
210
233
  this.dispatchEvent(event);
211
234
  }
212
- onUserTypeResetValue() {
213
- //when use type but dont select we want to reset value becuase typed value is not a valid value
214
- //TODO: check if typed value is the same as current selected value title dont null it
215
- this._value = null;
216
- this._shadowRoot.querySelector('.jb-select-web-component').classList.remove('--has-value');
217
- }
218
235
  onInputChange(e) {
219
236
  const inputText = e.target.value;
220
237
  //here is the rare time we update _text_value directly becuase we want trigger event that may read value directly from dom
@@ -232,13 +249,15 @@ class JBSelectWebComponent extends HTMLElement {
232
249
  }
233
250
  }
234
251
  focus(){
235
- this._inputElement.focus();
252
+ this.elements.input.focus();
236
253
  this.showOptionList();
237
- this._webComponentWrapper.classList.add('--focused');
254
+ this.elements.componentWrapper.classList.add('--focused');
238
255
 
239
256
  }
240
257
  blur(){
241
- this._webComponentWrapper.classList.remove('--focused');
258
+ this.elements.componentWrapper.classList.remove('--focused');
259
+ this.textValue = "";
260
+ this.handleSelectedValueDisplay('');
242
261
  this.hideOptionList();
243
262
  this.triggerInputValidation();
244
263
  }
@@ -264,16 +283,26 @@ class JBSelectWebComponent extends HTMLElement {
264
283
 
265
284
  }
266
285
  createOptionDOM(item){
286
+ let optionDOM = null;
287
+ if(typeof this.callbacks.getOptionDOM == 'function'){
288
+ optionDOM = this.callbacks.getOptionDOM(item,this.onOptionClicked.bind(this));
289
+ }else{
290
+ optionDOM = this._createOptionDom(item);
291
+ }
292
+ optionDOM.value = item;
293
+ return optionDOM;
294
+ }
295
+
296
+ _createOptionDom(item){
267
297
  const optionElement = document.createElement('div');
268
298
  optionElement.classList.add('select-option');
269
299
  //it has defualt function who return wxact same input
270
300
  optionElement.innerHTML = this.callbacks.getOptionTitle(item);
271
- optionElement.value = item;
272
301
  optionElement.addEventListener('click', this.onOptionClicked.bind(this));
273
302
  return optionElement;
274
303
  }
275
304
  onOptionClicked(e) {
276
- const value = e.target.value;
305
+ const value = e.currentTarget.value;
277
306
  this.selectOption(value);
278
307
  this.blur();
279
308
  this._triggerOnChangeEvent();
@@ -285,9 +314,14 @@ class JBSelectWebComponent extends HTMLElement {
285
314
  filterOptionList(filterString) {
286
315
  const displayOptionList = [];
287
316
  this.optionList.filter((option) => {
288
- if (typeof this.callbacks.getOptionTitle(option) == 'string' && this.callbacks.getOptionTitle(option).includes(filterString)) {
317
+ const optionTitle = this.callbacks.getOptionTitle(option);
318
+ const isString = typeof optionTitle == 'string';
319
+ if (isString && optionTitle.includes(filterString)) {
289
320
  displayOptionList.push(option);
290
321
  }
322
+ if (!isString) {
323
+ console.warn("the provided values for optionsList is not of type string.", { option, title: optionTitle });
324
+ }
291
325
  });
292
326
  return displayOptionList;
293
327
  }
@@ -315,19 +349,42 @@ class JBSelectWebComponent extends HTMLElement {
315
349
  showValidationError(errorType) {
316
350
  if (errorType == 'REQUIRED') {
317
351
  const label = this.getAttribute('label');
318
- this._shadowRoot.querySelector('.message-box').innerHTML = `${label} حتما باید انتخاب شود`;
319
- this._shadowRoot.querySelector('.message-box').classList.add('--error');
352
+ this.shadowRoot.querySelector('.message-box').innerHTML = `${label} حتما باید انتخاب شود`;
353
+ this.shadowRoot.querySelector('.message-box').classList.add('--error');
320
354
  }
321
355
  }
322
356
  clearValidationError() {
323
- this._shadowRoot.querySelector('.message-box').innerHTML = this.getAttribute('message') || '';
324
- this._shadowRoot.querySelector('.message-box').classList.remove('--error');
357
+ this.shadowRoot.querySelector('.message-box').innerHTML = this.getAttribute('message') || '';
358
+ this.shadowRoot.querySelector('.message-box').classList.remove('--error');
325
359
 
326
360
  }
327
361
  _triggerOnChangeEvent() {
328
362
  const event = new Event("change");
329
363
  this.dispatchEvent(event);
330
364
  }
365
+ setSelectedOptionDom(value) {
366
+ //when user select option or value changed in any condition we set selected option DOM
367
+ this.elements.selectedValueWrapper.innerHTML = '';
368
+ //if value was null or undifined it remain empty
369
+ if(value !== null && value !== undefined){
370
+ const selectedOptionDom = this.createSelectedValueDom(value);
371
+ this.elements.selectedValueWrapper.appendChild(selectedOptionDom);
372
+ }
373
+ }
374
+ createSelectedValueDom(value){
375
+ if(typeof this.callbacks.getSelectedValueDOM == 'function'){
376
+ return this.callbacks.getSelectedValueDOM(value);
377
+ }else{
378
+ return this._createSelectedValueDom(value);
379
+ }
380
+ }
381
+ _createSelectedValueDom(value){
382
+ const valueText = this.callbacks.getOptionTitle(value);
383
+ const selectedOptionDom = document.createElement('div');
384
+ selectedOptionDom.classList.add('selected-value');
385
+ selectedOptionDom.innerHTML = valueText;
386
+ return selectedOptionDom;
387
+ }
331
388
  }
332
389
  const myElementNotExists = !customElements.get('jb-select');
333
390
  if(myElementNotExists){
package/lib/JBSelect.scss CHANGED
@@ -35,7 +35,8 @@
35
35
  &.--has-value{
36
36
  //if user select a option and value is setted and not null
37
37
  .select-box{
38
- border-color: var(--jb-select-border-color-selected , #c3ff14) ;
38
+ border-color: var(--jb-select-border-color-selected , #c3ff14);
39
+ background-color: var(--jb-select-bgcolor-selected , #f7f6f6);
39
40
  }
40
41
  }
41
42
  label {
@@ -63,6 +64,7 @@
63
64
  justify-content: space-between;
64
65
  padding-inline-end: 16px;
65
66
  gap: 8px;
67
+ position: relative;
66
68
  &:focus-within {
67
69
  border-color: var(--jb-select-border-color , #1e2832);
68
70
  border-bottom-color: var(--jb-select-border-color , #f7f6f6);;
@@ -72,33 +74,75 @@
72
74
  border-bottom-color: var(--jb-select-border-color , #1e2832);
73
75
  }
74
76
  }
75
- input {
76
- border: none;
77
+ .selected-value-wrapper{
78
+ position: absolute;
77
79
  width: 100%;
78
- box-sizing: border-box;
79
80
  height: 100%;
80
- background-color: transparent;
81
- padding: 2px 12px 0 12px;
82
- display: block;
83
- font-family: inherit;
84
- font-size: 1.1em;
85
- color: var(--jb-select-input-color, #1f1735);
86
- margin: 0;
87
- border-radius: 0;
81
+ border-radius: inherit;
82
+ overflow: hidden;
83
+ z-index: 1;
84
+ &.--search-typed{
85
+ opacity: 0;
86
+ }
87
+ .selected-value{
88
+ width: 100%;
89
+ box-sizing: border-box;
90
+ height: 100%;
91
+ background-color: transparent;
92
+ padding: 2px 12px 0 12px;
93
+ display: block;
94
+ font-family: inherit;
95
+ font-size: 1.1em;
96
+ color:#1f1735;
97
+ margin: 0;
98
+ border-radius: 0;
99
+ display: flex;
100
+ align-items: center;
88
101
 
89
- &:focus {
90
- outline: none;
91
102
  }
103
+
92
104
  }
93
- .arrow-icon{
94
- width: 8px;
105
+ &:focus-within .selected-value{
106
+ opacity: 0.7;
107
+ transition: all 0.3s ease;
108
+ }
109
+ .front-box{
110
+ position: absolute;
111
+ width: 100%;
95
112
  height: 100%;
96
- background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 494.1 371.1' style='enable-background:new 0 0 494.1 371.1;' xml:space='preserve'><path d='M293,343.8L480.9,69.3c8.7-12.7,13.3-25.4,13.3-36.1c0-20.5-16.5-33.2-44-33.2H44C16.4,0,0,12.7,0,33.2 c0,10.6,4.6,23.2,13.3,35.9l187.9,274.6c12.1,17.7,28.4,27.4,45.9,27.4C264.6,371.1,280.9,361.4,293,343.8z'/></svg>");
97
- background-position: end;
98
- background-repeat: no-repeat;
99
- background-position-x: 0;
100
- background-position-y: center;
113
+ border-radius: inherit;
114
+ overflow: hidden;
115
+ z-index: 2;
116
+
117
+ input {
118
+ border: none;
119
+ width: 100%;
120
+ box-sizing: border-box;
121
+ height: 100%;
122
+ background-color: transparent;
123
+ padding: 2px 12px 0 12px;
124
+ display: block;
125
+ font-family: inherit;
126
+ font-size: 1.1em;
127
+ color: var(--jb-select-input-color, #1f1735);
128
+ margin: 0;
129
+ border-radius: 0;
130
+
131
+ &:focus {
132
+ outline: none;
133
+ }
134
+ }
135
+ .arrow-icon{
136
+ width: 8px;
137
+ height: 100%;
138
+ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 494.1 371.1' style='enable-background:new 0 0 494.1 371.1;' xml:space='preserve'><path d='M293,343.8L480.9,69.3c8.7-12.7,13.3-25.4,13.3-36.1c0-20.5-16.5-33.2-44-33.2H44C16.4,0,0,12.7,0,33.2 c0,10.6,4.6,23.2,13.3,35.9l187.9,274.6c12.1,17.7,28.4,27.4,45.9,27.4C264.6,371.1,280.9,361.4,293,343.8z'/></svg>");
139
+ background-position: end;
140
+ background-repeat: no-repeat;
141
+ background-position-x: 0;
142
+ background-position-y: center;
143
+ }
101
144
  }
145
+
102
146
  }
103
147
  .message-box{
104
148
  font-size: 0.7em;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "select",
13
13
  "web component"
14
14
  ],
15
- "version": "1.0.10",
15
+ "version": "2.0.1",
16
16
  "bugs": "https://github.com/javadbat/jb-select/issues",
17
17
  "license": "MIT",
18
18
  "files": [