marz-ui 1.0.2 → 1.0.4

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.
@@ -1,23 +1,26 @@
1
- class n extends HTMLElement {
1
+ class h extends HTMLElement {
2
2
  constructor() {
3
- super(), this.attachShadow({ mode: "open" }), this.wrapper = document.createElement("div"), this.wrapper.className = "marz-input-wrapper", this.labelElement = document.createElement("label"), this.labelElement.className = "marz-input-label", this.input = document.createElement("input");
3
+ super(), this.attachShadow({ mode: "open" }), this.wrapper = document.createElement("div"), this.wrapper.className = "marz-input-wrapper", this.labelElement = document.createElement("label"), this.labelElement.className = "marz-input-label", this.input = this.hasAttribute("multiline") ? document.createElement("textarea") : document.createElement("input");
4
4
  const t = document.createElement("style");
5
- t.textContent = this.getStyles(), this.wrapper.appendChild(this.labelElement), this.wrapper.appendChild(this.input), this.shadowRoot.appendChild(t), this.shadowRoot.appendChild(this.wrapper), this.input.addEventListener("input", () => {
6
- const e = this.input.value;
7
- this.setAttribute("value", e), this.dispatchEvent(new CustomEvent("change", {
8
- detail: { value: e },
5
+ t.textContent = this.getStyles(), this.wrapper.appendChild(this.labelElement), this.wrapper.appendChild(this.input), this.shadowRoot.appendChild(t), this.shadowRoot.appendChild(this.wrapper), this.setupEventListeners();
6
+ }
7
+ static get observedAttributes() {
8
+ return ["size", "label", "placeholder", "value", "disabled", "type", "multiline", "rows"];
9
+ }
10
+ setupEventListeners() {
11
+ this.input.addEventListener("input", () => {
12
+ const t = this.input.value;
13
+ this.setAttribute("value", t), this.dispatchEvent(new CustomEvent("change", {
14
+ detail: { value: t },
9
15
  bubbles: !0,
10
16
  composed: !0
11
17
  }));
12
- }), ["focus", "blur", "keydown", "keyup"].forEach((e) => {
13
- this.input.addEventListener(e, () => {
14
- this.dispatchEvent(new Event(e, { bubbles: !0, composed: !0 }));
18
+ }), ["focus", "blur", "keydown", "keyup"].forEach((t) => {
19
+ this.input.addEventListener(t, () => {
20
+ this.dispatchEvent(new Event(t, { bubbles: !0, composed: !0 }));
15
21
  });
16
22
  });
17
23
  }
18
- static get observedAttributes() {
19
- return ["size", "label", "placeholder", "value", "disabled", "type"];
20
- }
21
24
  connectedCallback() {
22
25
  this.render();
23
26
  }
@@ -25,23 +28,29 @@ class n extends HTMLElement {
25
28
  e !== i && this.render();
26
29
  }
27
30
  render() {
28
- const t = this.getAttribute("size") || "medium", e = this.getAttribute("label") || "", i = this.getAttribute("placeholder") || "", s = this.getAttribute("value") || "", a = this.hasAttribute("disabled"), r = this.getAttribute("type") || "text", l = [
31
+ const t = this.getAttribute("size") || "medium", e = this.getAttribute("label") || "", i = this.getAttribute("placeholder") || "", s = this.getAttribute("value") || "", r = this.hasAttribute("disabled"), a = this.getAttribute("type") || "text", n = this.hasAttribute("multiline"), l = parseInt(this.getAttribute("rows") || "3"), u = this.input instanceof HTMLTextAreaElement;
32
+ if (n !== u) {
33
+ const o = this.input;
34
+ this.input = n ? document.createElement("textarea") : document.createElement("input"), this.wrapper.replaceChild(this.input, o), this.setupEventListeners();
35
+ }
36
+ const p = [
29
37
  "marz-input",
30
38
  `marz-input--${t}`
31
39
  ].join(" ");
32
- this.input.className = l, this.input.placeholder = i, this.input.disabled = a, this.input.type = r, this.input.value !== s && (this.input.value = s), this.labelElement.textContent = e, this.labelElement.style.display = e ? "block" : "none";
40
+ this.input.className = p, this.input.placeholder = i, this.input.disabled = r, this.input instanceof HTMLInputElement ? this.input.type = a : this.input instanceof HTMLTextAreaElement && (this.input.rows = l), this.input.value !== s && (this.input.value = s), this.labelElement.textContent = e, this.labelElement.style.display = e ? "block" : "none";
33
41
  }
34
42
  getStyles() {
35
43
  return `
36
44
  :host {
37
45
  display: block;
38
46
  width: 100%;
47
+ margin-bottom: var(--form-element-gap, 20px);
39
48
  }
40
49
 
41
50
  .marz-input-wrapper {
42
51
  display: flex;
43
52
  flex-direction: column;
44
- gap: 8px;
53
+ gap: 12px;
45
54
  width: 100%;
46
55
  }
47
56
 
@@ -58,7 +67,7 @@ class n extends HTMLElement {
58
67
  border: 0;
59
68
  border-radius: 1em;
60
69
  font-weight: 500;
61
- line-height: 1;
70
+ line-height: 1.5;
62
71
  width: 100%;
63
72
  transition: all 100ms;
64
73
  background-color: var(--bg-element, rgba(0, 0, 0, 0.02));
@@ -67,6 +76,11 @@ class n extends HTMLElement {
67
76
  outline: none;
68
77
  box-sizing: border-box;
69
78
  font-family: 'Inter', sans-serif;
79
+ resize: vertical;
80
+ }
81
+
82
+ textarea.marz-input {
83
+ min-height: 80px;
70
84
  }
71
85
 
72
86
  .marz-input:disabled {
@@ -142,7 +156,7 @@ class n extends HTMLElement {
142
156
  this.input.blur();
143
157
  }
144
158
  }
145
- customElements.get("marz-input") || customElements.define("marz-input", n);
159
+ customElements.get("marz-input") || customElements.define("marz-input", h);
146
160
  export {
147
- n as MarzInput
161
+ h as MarzInput
148
162
  };
package/dist/index.js CHANGED
@@ -287,11 +287,16 @@ class p extends HTMLElement {
287
287
  .markdown-editor-container {
288
288
  display: flex;
289
289
  flex-direction: column;
290
- border: 1px solid var(--bg-element-2);
291
- border-radius: 8px;
292
- background-color: var(--bg);
290
+ border: 1px solid var(--secondary, #ababab);
291
+ border-radius: 1em;
292
+ background-color: var(--bg-element, rgba(0, 0, 0, 0.02));
293
293
  font-family: 'Inter', sans-serif;
294
294
  overflow: hidden;
295
+ transition: all 100ms;
296
+ }
297
+
298
+ .markdown-editor-container:focus-within {
299
+ border: 1px solid var(--primary, #2b2b2b);
295
300
  }
296
301
 
297
302
  .markdown-toolbar {