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.
- package/example/index.html +1 -1
- package/index.js +12 -11
- package/package.json +1 -1
package/example/index.html
CHANGED
|
@@ -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}"></
|
|
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
|
|
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
|
-
|
|
61
|
+
component.appendChild(mainStyle);
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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" });
|