chooser.js 716 B

123456789101112131415161718192021222324252627282930
  1. import { database } from "./database.js";
  2. import { items_list } from "./items_list.js";
  3. class chooser {
  4. #list;
  5. #store;
  6. #container;
  7. constructor(store, click) {
  8. if (!(store instanceof database)) {
  9. throw "Store must be instance of an database.";
  10. }
  11. if (typeof(click) !== "function") {
  12. throw "Click function must be an function instance.";
  13. }
  14. this.#container = document.createElement("div");
  15. this.#container.className = "chooser";
  16. this.#list = new items_list(this.#container, click);
  17. this.#list.update(store.content.submissions);
  18. }
  19. get ui() {
  20. return this.#container;
  21. }
  22. }
  23. export { chooser };