marz-ui 1.0.2 → 1.0.3
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/components/input/index.js +27 -17
- package/dist/index.js +8 -3
- package/dist/styles/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
class
|
|
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.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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((
|
|
13
|
-
this.input.addEventListener(
|
|
14
|
-
this.dispatchEvent(new Event(
|
|
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,17 +28,23 @@ 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") || "",
|
|
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 =
|
|
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 {
|
|
@@ -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,7 @@ class n extends HTMLElement {
|
|
|
67
76
|
outline: none;
|
|
68
77
|
box-sizing: border-box;
|
|
69
78
|
font-family: 'Inter', sans-serif;
|
|
79
|
+
resize: vertical;
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
.marz-input:disabled {
|
|
@@ -142,7 +152,7 @@ class n extends HTMLElement {
|
|
|
142
152
|
this.input.blur();
|
|
143
153
|
}
|
|
144
154
|
}
|
|
145
|
-
customElements.get("marz-input") || customElements.define("marz-input",
|
|
155
|
+
customElements.get("marz-input") || customElements.define("marz-input", h);
|
|
146
156
|
export {
|
|
147
|
-
|
|
157
|
+
h as MarzInput
|
|
148
158
|
};
|
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(--
|
|
291
|
-
border-radius:
|
|
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 {
|