@loudy/lib 0.0.4 → 0.0.5

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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/index.d.ts
2
- declare function $(elementName: string): LoudLibElement;
2
+ declare function $(elementName: string): LoudLibElement | null;
3
3
  declare class LoudLibElement {
4
4
  constructor(element: Element);
5
5
  element: Element;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  //#region src/index.ts
2
2
  function $(elementName) {
3
- return new LoudLibElement(document.querySelector(elementName));
3
+ const element = document.querySelector(elementName);
4
+ return element ? new LoudLibElement(element) : null;
4
5
  }
5
6
  var LoudLibElement = class {
6
7
  constructor(element) {
@@ -18,17 +19,16 @@ var LoudLibElement = class {
18
19
  hidden = false;
19
20
  hide() {
20
21
  this.element.style.display = "none";
22
+ this.hidden = true;
21
23
  return this;
22
24
  }
23
25
  show() {
24
- this.element.style.display = "initial";
26
+ this.element.style.display = "";
27
+ this.hidden = false;
25
28
  return this;
26
29
  }
27
30
  toggle() {
28
- this.hidden = !this.hidden;
29
- if (this.hidden == false) this.element.style.display = "initial";
30
- else if (this.hidden == true) this.element.style.display = "none";
31
- return this;
31
+ return this.hidden ? this.show() : this.hide();
32
32
  }
33
33
  };
34
34
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loudy/lib",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "description": "library for various stuff.",
6
6
  "author": "loudsynth",
7
7
  "license": "MIT",