Skip to content

Commit

Permalink
refactor(Combobox): export as an ecmascript module (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamssokari authored Oct 7, 2023
1 parent 948e1da commit 51740cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/doc-verification.html
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ <h1>Submission Complete</h1>
</section>
</main>

<script src="js/components/Combobox.min.js"></script>
<script src="js/doc-verification.min.js"></script>
</body>
</html>
15 changes: 7 additions & 8 deletions src/js/components/Combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function maintainScrollVisibility(activeElement, scrollParent) {
}
}

class Combobox extends HTMLElement {
class ComboboxRoot extends HTMLElement {
constructor() {
super();

Expand Down Expand Up @@ -71,8 +71,6 @@ class Combobox extends HTMLElement {
}
}

window.customElements.define("smileid-combobox", Combobox);

class ComboboxTrigger extends HTMLElement {
constructor() {
super();
Expand Down Expand Up @@ -320,8 +318,6 @@ class ComboboxTrigger extends HTMLElement {
}
}

window.customElements.define("smileid-combobox-trigger", ComboboxTrigger);

class ComboboxListbox extends HTMLElement {
constructor() {
super();
Expand Down Expand Up @@ -528,8 +524,6 @@ class ComboboxListbox extends HTMLElement {
}
}

window.customElements.define("smileid-combobox-listbox", ComboboxListbox);

class ComboboxOption extends HTMLElement {
connectedCallback() {
this.setAttribute("role", "option");
Expand Down Expand Up @@ -577,4 +571,9 @@ class ComboboxOption extends HTMLElement {
}
}

window.customElements.define("smileid-combobox-option", ComboboxOption);
export default {
Root: ComboboxRoot,
Trigger: ComboboxTrigger,
List: ComboboxListbox,
Option: ComboboxOption,
};
6 changes: 6 additions & 0 deletions src/js/doc-verification.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@smile_identity/smart-camera-web";
import JSZip from "jszip";
import { version as sdkVersion } from "../../package.json";
import Combobox from "./components/Combobox";

(function documentVerification() {
"use strict";
Expand All @@ -16,6 +17,11 @@ import { version as sdkVersion } from "../../package.json";
const referenceWindow = window.parent;
referenceWindow.postMessage("SmileIdentity::ChildPageReady", "*");

window.customElements.define("smileid-combobox", Combobox.Root);
window.customElements.define("smileid-combobox-trigger", Combobox.Trigger);
window.customElements.define("smileid-combobox-listbox", Combobox.List);
window.customElements.define("smileid-combobox-option", Combobox.Option);

let config;
let activeScreen;
let id_info;
Expand Down

0 comments on commit 51740cb

Please sign in to comment.