lucos_search_component 0.0.4 → 0.0.6

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.
@@ -3,7 +3,7 @@
3
3
  <title>Hello World Search Component</title>
4
4
  </head>
5
5
  <body>
6
- <lucos-search api-key="${KEY_LUCOS_ARACHNE}"></lucos-search>
6
+ <label for="search-field">Search For:</label><select is="lucos-search" api-key="${KEY_LUCOS_ARACHNE}" id="search-field"></select>
7
7
  <script src="./built.js"></script>
8
8
  </body>
9
9
  </html>
package/index.js CHANGED
@@ -1,14 +1,13 @@
1
1
  import TomSelect from 'tom-select';
2
2
  import tomSelectStylesheet from 'tom-select/dist/css/tom-select.default.css';
3
3
 
4
- class LucosSearchComponent extends HTMLElement {
4
+ class LucosSearchComponent extends HTMLSelectElement {
5
5
  static get observedAttributes() {
6
6
  return ['api-key'];
7
7
  }
8
8
  constructor() {
9
9
  super();
10
10
  const component = this;
11
- const shadow = component.attachShadow({mode: 'open'});
12
11
 
13
12
  const mainStyle = document.createElement('style');
14
13
  mainStyle.textContent = `
@@ -59,16 +58,18 @@ class LucosSearchComponent extends HTMLElement {
59
58
  padding: 2px 6px;
60
59
  }
61
60
  `;
62
- shadow.appendChild(mainStyle);
61
+ component.appendChild(mainStyle);
63
62
 
64
- const tomStyle = document.createElement('style');
65
- tomStyle.textContent = tomSelectStylesheet[0][1];
66
- shadow.appendChild(tomStyle);
63
+ // If webpack is configured with `css-loader` but not `style-loader`, include the tom-select stylesheet here
64
+ // (If `style-loader` is being used, the tom-select stylesheet will be handled by that)
65
+ if (tomSelectStylesheet) {
66
+ const tomStyle = document.createElement('style');
67
+ tomStyle.textContent = tomSelectStylesheet[0][1];
68
+ component.appendChild(tomStyle);
69
+ }
67
70
 
68
- const select = document.createElement("select");
69
- select.setAttribute("multiple", "multiple");
70
- shadow.appendChild(select);
71
- const tomSelect = new TomSelect(select, {
71
+ component.setAttribute("multiple", "multiple");
72
+ new TomSelect(component, {
72
73
  valueField: 'id',
73
74
  labelField: 'pref_label',
74
75
  searchField: [],
@@ -113,4 +114,4 @@ class LucosSearchComponent extends HTMLElement {
113
114
  });
114
115
  }
115
116
  }
116
- customElements.define('lucos-search', LucosSearchComponent);
117
+ customElements.define('lucos-search', LucosSearchComponent, { extends: "select" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucos_search_component",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Web Component for searching lucOS data",
5
5
  "type": "module",
6
6
  "main": "index.js",