wj-elements 0.1.11 → 0.1.13
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/package.json +1 -1
- package/dist/dark.css +0 -1
- package/dist/light.css +0 -1
- package/dist/localize-DVuO3S17.js +0 -43
- package/dist/popup.element-CpEjis9f.js +0 -1068
- package/dist/router-links-FtZbFUto.js +0 -146
- package/dist/styles.css +0 -1
- package/dist/wje-accordion-item.js +0 -88
- package/dist/wje-accordion.js +0 -79
- package/dist/wje-animation.js +0 -121
- package/dist/wje-aside.js +0 -55
- package/dist/wje-avatar.js +0 -74
- package/dist/wje-badge.js +0 -50
- package/dist/wje-breadcrumb.js +0 -148
- package/dist/wje-breadcrumbs.js +0 -67
- package/dist/wje-button-group.js +0 -78
- package/dist/wje-button.js +0 -175
- package/dist/wje-card-content.js +0 -48
- package/dist/wje-card-controls.js +0 -48
- package/dist/wje-card-header.js +0 -47
- package/dist/wje-card-subtitle.js +0 -55
- package/dist/wje-card-title.js +0 -55
- package/dist/wje-card.js +0 -50
- package/dist/wje-carousel-item.js +0 -33
- package/dist/wje-carousel.js +0 -177
- package/dist/wje-checkbox.js +0 -104
- package/dist/wje-chip.js +0 -32
- package/dist/wje-col.js +0 -27
- package/dist/wje-color-picker.js +0 -953
- package/dist/wje-container.js +0 -57
- package/dist/wje-copy-button.js +0 -164
- package/dist/wje-dialog.js +0 -86
- package/dist/wje-divider.js +0 -53
- package/dist/wje-dropdown.js +0 -68
- package/dist/wje-element.js +0 -453
- package/dist/wje-fetchAndParseCSS.js +0 -40
- package/dist/wje-file-upload-item.js +0 -115
- package/dist/wje-file-upload.js +0 -297
- package/dist/wje-footer.js +0 -56
- package/dist/wje-form.js +0 -28
- package/dist/wje-format-digital.js +0 -85
- package/dist/wje-grid.js +0 -28
- package/dist/wje-header.js +0 -58
- package/dist/wje-icon-picker.js +0 -221
- package/dist/wje-icon.js +0 -119
- package/dist/wje-img-comparer.js +0 -111
- package/dist/wje-img.js +0 -58
- package/dist/wje-infinite-scroll.js +0 -193
- package/dist/wje-inline-edit.js +0 -120
- package/dist/wje-input-file.js +0 -85
- package/dist/wje-input.js +0 -240
- package/dist/wje-item.js +0 -45
- package/dist/wje-label.js +0 -67
- package/dist/wje-list.js +0 -53
- package/dist/wje-main.js +0 -56
- package/dist/wje-masonry.js +0 -218
- package/dist/wje-master.js +0 -196
- package/dist/wje-menu-button.js +0 -65
- package/dist/wje-menu-item.js +0 -192
- package/dist/wje-menu-label.js +0 -57
- package/dist/wje-menu.js +0 -74
- package/dist/wje-option.js +0 -99
- package/dist/wje-options.js +0 -63
- package/dist/wje-popup.js +0 -5
- package/dist/wje-progress-bar.js +0 -145
- package/dist/wje-radio-group.js +0 -101
- package/dist/wje-radio.js +0 -46
- package/dist/wje-rate.js +0 -260
- package/dist/wje-relative-time.js +0 -85
- package/dist/wje-reorder-dropzone.js +0 -27
- package/dist/wje-reorder-item.js +0 -32
- package/dist/wje-reorder.js +0 -132
- package/dist/wje-route.js +0 -28
- package/dist/wje-router-link.js +0 -64
- package/dist/wje-router-outlet.js +0 -127
- package/dist/wje-routerx.js +0 -1088
- package/dist/wje-row.js +0 -58
- package/dist/wje-select.js +0 -240
- package/dist/wje-slider.js +0 -177
- package/dist/wje-split-view.js +0 -112
- package/dist/wje-store.js +0 -192
- package/dist/wje-tab-group.js +0 -105
- package/dist/wje-tab-panel.js +0 -52
- package/dist/wje-tab.js +0 -59
- package/dist/wje-textarea.js +0 -116
- package/dist/wje-thumbnail.js +0 -64
- package/dist/wje-toast.js +0 -76
- package/dist/wje-toggle.js +0 -94
- package/dist/wje-toolbar-action.js +0 -63
- package/dist/wje-toolbar.js +0 -61
- package/dist/wje-tooltip.js +0 -105
- package/dist/wje-visually-hidden.js +0 -56
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
var g = Object.defineProperty;
|
|
2
|
-
var p = (o, r, t) => r in o ? g(o, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[r] = t;
|
|
3
|
-
var h = (o, r, t) => (p(o, typeof r != "symbol" ? r + "" : r, t), t);
|
|
4
|
-
import f, { WjElementUtils as w, event as d } from "./wje-element.js";
|
|
5
|
-
const y = ":host{overflow-x:auto;width:var(--wje-infinite-scroll-width);height:var(--wje-infinite-scroll-height);display:block}.loading{position:sticky;display:none;justify-content:center;align-items:center;width:100%;height:100%;top:0;left:0;z-index:9999;background-color:var(--wje-infinite-scroll-loading-bg)}.loading.show{display:flex}[name=ending]{display:none;margin-top:1rem;text-align:center}[name=ending].show{display:block}";
|
|
6
|
-
class u extends f {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of InfiniteScroll.
|
|
9
|
-
*
|
|
10
|
-
* @constructor
|
|
11
|
-
* @param {Object} options - The options for the InfiniteScroll.
|
|
12
|
-
*/
|
|
13
|
-
constructor(t = {}) {
|
|
14
|
-
super();
|
|
15
|
-
h(this, "className", "InfiniteScroll");
|
|
16
|
-
/**
|
|
17
|
-
* Adds the scroll event listener.
|
|
18
|
-
*/
|
|
19
|
-
h(this, "scrollEvent", () => {
|
|
20
|
-
this.addEventListener("scroll", this.onScroll);
|
|
21
|
-
});
|
|
22
|
-
/**
|
|
23
|
-
* Removes the scroll event listener.
|
|
24
|
-
*/
|
|
25
|
-
h(this, "unScrollEvent", () => {
|
|
26
|
-
this.removeEventListener("scroll", this.onScroll);
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* Handles the scroll event.
|
|
30
|
-
*
|
|
31
|
-
* @param {Event} e - The event.
|
|
32
|
-
*/
|
|
33
|
-
h(this, "onScroll", (t) => {
|
|
34
|
-
const { scrollTop: e, scrollHeight: i, clientHeight: s } = t.target;
|
|
35
|
-
e + s >= i - 300 && this.currentPage <= this.totalPages && this.isLoading.includes(this.currentPage) && (this.currentPage++, this.loadPages(this.currentPage));
|
|
36
|
-
});
|
|
37
|
-
this.totalPages = 0, this.isLoading = [], this._response = {}, this.iterate = null, this._infiniteScrollTemplate = null, String.prototype.interpolate = function(e) {
|
|
38
|
-
let i = this, s = i.match(/\{{.*?\}}/g);
|
|
39
|
-
if (s)
|
|
40
|
-
for (let n of s) {
|
|
41
|
-
let c = n.replace("{{", "").replace("}}", ""), l = "";
|
|
42
|
-
c.split(".").forEach((a) => {
|
|
43
|
-
l = l == "" ? e[a] : l[a];
|
|
44
|
-
}), i = i.replace(n, l);
|
|
45
|
-
}
|
|
46
|
-
return i;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
set infiniteScrollTemplate(t) {
|
|
50
|
-
this._infiniteScrollTemplate = t;
|
|
51
|
-
}
|
|
52
|
-
get infiniteScrollTemplate() {
|
|
53
|
-
return this._infiniteScrollTemplate;
|
|
54
|
-
}
|
|
55
|
-
set response(t) {
|
|
56
|
-
this._response = t;
|
|
57
|
-
}
|
|
58
|
-
get response() {
|
|
59
|
-
return this._response;
|
|
60
|
-
}
|
|
61
|
-
set objectName(t) {
|
|
62
|
-
this.setAttribute("object-name", t);
|
|
63
|
-
}
|
|
64
|
-
get objectName() {
|
|
65
|
-
return this.getAttribute("object-name") || "data";
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Returns the CSS styles for the component.
|
|
69
|
-
*
|
|
70
|
-
* @static
|
|
71
|
-
* @returns {CSSStyleSheet}
|
|
72
|
-
*/
|
|
73
|
-
static get cssStyleSheet() {
|
|
74
|
-
return y;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Returns the list of attributes to observe for changes.
|
|
78
|
-
*
|
|
79
|
-
* @static
|
|
80
|
-
* @returns {Array<string>}
|
|
81
|
-
*/
|
|
82
|
-
static get observedAttributes() {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Sets up the attributes for the component.
|
|
87
|
-
*/
|
|
88
|
-
setupAttributes() {
|
|
89
|
-
this.isShadowRoot = "open";
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Prepares the component before drawing.
|
|
93
|
-
*
|
|
94
|
-
* @param {Object} context - The context for drawing.
|
|
95
|
-
* @param {Object} store - The store for drawing.
|
|
96
|
-
* @param {Object} params - The parameters for drawing.
|
|
97
|
-
*/
|
|
98
|
-
beforeDraw(t, e, i) {
|
|
99
|
-
var s, n;
|
|
100
|
-
this.iterate = this.querySelector("[iterate]"), this.infiniteScrollTemplate = (s = this.iterate) == null ? void 0 : s.outerHTML, (n = this.iterate) == null || n.remove(), this.setAttribute("style", "height: " + this.height);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Draws the component.
|
|
104
|
-
*
|
|
105
|
-
* @param {Object} context - The context for drawing.
|
|
106
|
-
* @param {Object} store - The store for drawing.
|
|
107
|
-
* @param {Object} params - The parameters for drawing.
|
|
108
|
-
* @returns {DocumentFragment}
|
|
109
|
-
*/
|
|
110
|
-
draw(t, e, i) {
|
|
111
|
-
let s = document.createDocumentFragment(), n = document.createElement("div");
|
|
112
|
-
n.classList.add("native"), n.setAttribute("part", "native-infinite-scroll");
|
|
113
|
-
let c = document.createElement("slot"), l = document.createElement("slot");
|
|
114
|
-
if (l.setAttribute("name", "ending"), w.hasSlot(this, "loader")) {
|
|
115
|
-
let a = document.createElement("div");
|
|
116
|
-
a.classList.add("loading");
|
|
117
|
-
let m = document.createElement("slot");
|
|
118
|
-
m.setAttribute("name", "loader"), a.appendChild(m), this.loadingEl = a, s.appendChild(a);
|
|
119
|
-
}
|
|
120
|
-
return n.appendChild(c), n.appendChild(l), s.appendChild(n), this.endingEl = l, s;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Called after the component has been drawn.
|
|
124
|
-
*/
|
|
125
|
-
async afterDraw() {
|
|
126
|
-
this.queryParams = this.queryParams || "", this.size = +this.size || 10, this.currentPage = 0, this.scrollEvent(), await this.loadPages(this.currentPage);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Fetches the pages from the server.
|
|
130
|
-
*
|
|
131
|
-
* @param {number} page - The page number.
|
|
132
|
-
* @returns {Promise<Object>} The response from the server.
|
|
133
|
-
*/
|
|
134
|
-
async getPages(t) {
|
|
135
|
-
let e = this.url.includes("?");
|
|
136
|
-
const i = await fetch(`${this.url}${e ? "&" : "?"}page=${t}&size=${this.size}${this == null ? void 0 : this.queryParams}`);
|
|
137
|
-
if (!i.ok)
|
|
138
|
-
throw new Error(`An error occurred: ${i.status}`);
|
|
139
|
-
return await i.json();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Hides the loader.
|
|
143
|
-
*/
|
|
144
|
-
hideLoader() {
|
|
145
|
-
var t;
|
|
146
|
-
(t = this == null ? void 0 : this.loadingEl) == null || t.classList.remove("show");
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Shows the loader.
|
|
150
|
-
*/
|
|
151
|
-
showLoader() {
|
|
152
|
-
var t;
|
|
153
|
-
(t = this == null ? void 0 : this.loadingEl) == null || t.classList.add("show");
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Checks if there are more pages to load.
|
|
157
|
-
*
|
|
158
|
-
* @param {number} page - The page number.
|
|
159
|
-
* @returns {boolean} Whether there are more pages to load.
|
|
160
|
-
*/
|
|
161
|
-
hasMorePages(t) {
|
|
162
|
-
return this.totalPages === 0 || t < this.totalPages;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Loads the pages.
|
|
166
|
-
*
|
|
167
|
-
* @param {number} page - The page number.
|
|
168
|
-
*/
|
|
169
|
-
async loadPages(t) {
|
|
170
|
-
this.showLoader();
|
|
171
|
-
try {
|
|
172
|
-
if (this.hasMorePages(t) || typeof this.setCustomData == "function") {
|
|
173
|
-
let e;
|
|
174
|
-
typeof this.setCustomData == "function" ? e = await this.setCustomData(t) : e = await this.getPages(t), this.totalPages = e.totalPages, this.currentPage = t;
|
|
175
|
-
const i = new DOMParser();
|
|
176
|
-
let s = this;
|
|
177
|
-
this.hasAttribute("placement") && (s = this.querySelector(this.placement)), d.dispatchCustomEvent(this, "wje-infinite-scroll:load", e), this.response = e, e[this.objectName].forEach((n) => {
|
|
178
|
-
const c = this.infiniteScrollTemplate.interpolate(n), a = i.parseFromString(c, "text/html").activeElement.firstElementChild;
|
|
179
|
-
d.addListener(a, "click", "wje-infinite-scroll:click-item", null), s.insertAdjacentElement("beforeend", a);
|
|
180
|
-
}), this.isLoading.push(t);
|
|
181
|
-
} else
|
|
182
|
-
d.dispatchCustomEvent(this, "wje-infinite-scroll:complete"), this.endingEl.classList.add("show");
|
|
183
|
-
} catch (e) {
|
|
184
|
-
console.log(e.message);
|
|
185
|
-
} finally {
|
|
186
|
-
this.hideLoader();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
u.define("wje-infinite-scroll", u);
|
|
191
|
-
export {
|
|
192
|
-
u as default
|
|
193
|
-
};
|
package/dist/wje-inline-edit.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
var h = Object.defineProperty;
|
|
2
|
-
var r = (s, n, t) => n in s ? h(s, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[n] = t;
|
|
3
|
-
var a = (s, n, t) => (r(s, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
|
-
import l from "./wje-element.js";
|
|
5
|
-
const u = ":host{cursor:pointer;overflow:hidden;@keyframes wjFade{0%{display:flex}to{display:none}}}:host .heading{z-index:1;display:flex;align-items:center;position:relative;min-height:34px}:host .heading .edit{margin-left:.5rem;opacity:0}:host .heading:hover .edit{opacity:1}:host .heading h5{margin:0;width:calc(100% - 50px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host form{align-items:center;border-radius:3px!important;margin:0 1rem 0 0;display:flex}:host form.open{z-index:9}:host form .buttons{display:flex;margin:0 0 0 .5rem}:host .fade-out{display:none}:host .fade-in{display:flex}";
|
|
6
|
-
class o extends l {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
a(this, "className", "InfiniteScroll");
|
|
10
|
-
}
|
|
11
|
-
get title() {
|
|
12
|
-
return this.getAttribute("title");
|
|
13
|
-
}
|
|
14
|
-
set title(t) {
|
|
15
|
-
return this.setAttribute("title", t);
|
|
16
|
-
}
|
|
17
|
-
get notEditable() {
|
|
18
|
-
return this.hasAttribute("not-editable");
|
|
19
|
-
}
|
|
20
|
-
set notEditable(t) {
|
|
21
|
-
return this.setAttribute("not-editable", "");
|
|
22
|
-
}
|
|
23
|
-
get endpoint() {
|
|
24
|
-
return this.getAttribute("endpoint");
|
|
25
|
-
}
|
|
26
|
-
set endpoint(t) {
|
|
27
|
-
return this.setAttribute("endpoint", t);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Returns the CSS styles for the component.
|
|
31
|
-
*
|
|
32
|
-
* @static
|
|
33
|
-
* @returns {CSSStyleSheet}
|
|
34
|
-
*/
|
|
35
|
-
static get cssStyleSheet() {
|
|
36
|
-
return u;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns the list of attributes to observe for changes.
|
|
40
|
-
*
|
|
41
|
-
* @static
|
|
42
|
-
* @returns {Array<string>}
|
|
43
|
-
*/
|
|
44
|
-
static get observedAttributes() {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Sets up the attributes for the component.
|
|
49
|
-
*/
|
|
50
|
-
setupAttributes() {
|
|
51
|
-
this.isShadowRoot = "open";
|
|
52
|
-
}
|
|
53
|
-
draw(t, e, d) {
|
|
54
|
-
let i = document.createDocumentFragment();
|
|
55
|
-
return this.heading = document.createElement("div"), this.heading.classList.add("heading"), this.h5 = document.createElement("h5"), this.h5.innerHTML = this.title, this.heading.appendChild(this.h5), i.appendChild(this.heading), this.notEditable || (this.span = document.createElement("span"), this.span.classList.add("edit", "text-primary"), this.span.innerHTML = "Upraviť", this.form = document.createElement("form"), this.form.classList.add("fade-out"), this.input = this.inputElement(), this.buttons = document.createElement("div"), this.buttons.classList.add("buttons", "btn-group"), this.buttonSave = document.createElement("button"), this.buttonSave.classList.add("btn", "btn-primary"), this.buttonSave.setAttribute("type", "button"), this.buttonSave.innerHTML = '<i class="fa-light fa-check"></i>', this.buttonClose = document.createElement("button"), this.buttonClose.classList.add("btn", "btn-default", "btn-close"), this.buttonClose.setAttribute("type", "button"), this.buttonClose.innerHTML = '<i class="fa-light fa-xmark"></i>', this.heading.appendChild(this.span), this.buttons.appendChild(this.buttonSave), this.buttons.appendChild(this.buttonClose), this.form.appendChild(this.input), this.form.appendChild(this.buttons), i.appendChild(this.form)), i;
|
|
56
|
-
}
|
|
57
|
-
afterDraw(t, e, d) {
|
|
58
|
-
this.notEditable || (this.heading.addEventListener("click", (i) => {
|
|
59
|
-
this.form.classList.add("open", "fade-in"), this.heading.classList.remove("fade-in"), this.heading.classList.add("fade-out");
|
|
60
|
-
}), this.buttonClose.addEventListener("click", (i) => {
|
|
61
|
-
i.preventDefault(), i.stopImmediatePropagation(), i.stopPropagation(), this.form.classList.remove("open", "fade-in"), this.heading.classList.remove("fade-out"), this.heading.classList.add("fade-in");
|
|
62
|
-
}), this.buttonSave.addEventListener("click", (i) => {
|
|
63
|
-
this.endpoint === null ? this.dispatchEdit(this.input.value) : this.save(this.input.value);
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
inputElement() {
|
|
67
|
-
let t = document.createElement("input");
|
|
68
|
-
return t.type = "text", t.placeholder = this.title, t.value = this.title, t.classList.add("form-control", "input-sm"), t;
|
|
69
|
-
}
|
|
70
|
-
save(t) {
|
|
71
|
-
return fetch(this.endpoint, {
|
|
72
|
-
method: "PUT",
|
|
73
|
-
headers: {
|
|
74
|
-
"Content-Type": "application/json"
|
|
75
|
-
},
|
|
76
|
-
body: t
|
|
77
|
-
}).then((e) => e.ok ? e.json() : e.text).then((e) => {
|
|
78
|
-
this.title = e.data, this.refresh(), intranet.notification(e), this.dispatchResponse(e.data);
|
|
79
|
-
}).catch((e) => {
|
|
80
|
-
intranet.notification(e), this.dispatchError(e);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
dispatchEdit(t) {
|
|
84
|
-
document.dispatchEvent(
|
|
85
|
-
new CustomEvent("wje-inline-edit-save", {
|
|
86
|
-
bubbles: !0,
|
|
87
|
-
detail: {
|
|
88
|
-
value: t,
|
|
89
|
-
element: this
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
dispatchResponse(t) {
|
|
95
|
-
document.dispatchEvent(
|
|
96
|
-
new CustomEvent("wje-inline-edit-response", {
|
|
97
|
-
bubbles: !0,
|
|
98
|
-
detail: {
|
|
99
|
-
value: t,
|
|
100
|
-
element: this
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
dispatchError(t) {
|
|
106
|
-
document.dispatchEvent(
|
|
107
|
-
new CustomEvent("wje-inline-edit-error", {
|
|
108
|
-
bubbles: !0,
|
|
109
|
-
detail: {
|
|
110
|
-
value: t,
|
|
111
|
-
element: this
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
o.define("wje-inline-edit", o);
|
|
118
|
-
export {
|
|
119
|
-
o as default
|
|
120
|
-
};
|
package/dist/wje-input-file.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var b = Object.defineProperty;
|
|
2
|
-
var h = (i, e, t) => e in i ? b(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
-
var u = (i, e, t) => (h(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import m, { event as v } from "./wje-element.js";
|
|
5
|
-
const w = ':host{--wje-input-font-family: var(--wje-font-family);--wje-input-background-color: var(--wje-background);--wje-input-color: var(--wje-color);--wje-input-color-invalid: var(--wje-color-danger);--wje-input-border-color: var(--wje-border-color);--wje-input-border-color-focus: var(--wje-color-primary);--wje-input-border-width: 1px;--wje-input-border-style: solid;--wje-input-border-radius: 4px;--wje-input-margin-bottom: .5rem;--wje-input-line-height: 20px;--wje-input-slot-padding-inline: .5rem;width:100%;margin-bottom:var(--wje-input-margin-bottom);display:block}:host .wrapper{display:flex;width:100%}:host .native-input .input-wrapper{width:100%;position:relative}:host .native-input.default{background-color:var(--wje-input-background-color);font-family:var(--wje-input-font-family);position:relative;border-radius:var(--wje-input-border-radius);border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color);padding-inline:0;padding-top:.25rem;padding-bottom:.25rem;transition:background-color .2s ease;cursor:text}:host .native-input.default .input-wrapper{margin-inline:.5rem}:host .native-input.default.focused{border-color:var(--wje-input-border-color-focus)!important}:host .native-input.default.focused label{opacity:.67;font-size:12px;letter-spacing:normal}:host .native-input.default input{border:none;height:25px;min-height:25px;padding:0;margin-top:-4px;background:none;box-shadow:none;width:100%}:host .native-input.default label{margin:0;display:block;opacity:1;cursor:text;transition:opacity .2s ease;line-height:var(--wje-input-line-height)}:host .native-input.default label.fade{opacity:.5;font-size:12px;letter-spacing:normal}:host .native-input.default ::slotted([slot="start"]){border-left:none;border-top:none;border-bottom:none}:host .native-input.default ::slotted([slot="end"]){border-right:none;border-top:none;border-bottom:none}:host .native-input.standard{background-color:var(--wje-input-background-color);font-family:var(--wje-input-font-family);position:relative;border-radius:var(--wje-input-border-radius);padding-inline:0;padding-top:0;padding-bottom:0;transition:background-color .2s ease;cursor:text}:host .native-input.standard.focused input{border-color:var(--wje-input-border-color-focus)!important}:host .native-input.standard input{display:block;min-height:32px;padding-inline:.5rem;padding-top:0;padding-bottom:0;background:none;box-shadow:none;width:100%;box-sizing:border-box;border-radius:var(--wje-input-border-radius);border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color)}:host .native-input.standard label{margin:0;display:inline-block;opacity:1;cursor:text;transition:opacity .2s ease;line-height:var(--wje-input-line-height)}:host .native-input.standard .input-wrapper:hover .clear{visibility:visible}:host .native-input.standard ::slotted([slot="start"]){border-right:none;border-radius:var(--wje-input-border-radius) 0 0 var(--wje-input-border-radius)}:host .native-input.standard ::slotted([slot="end"]){border-left:none;border-radius:0 var(--wje-input-border-radius) var(--wje-input-border-radius) 0}:host .native-input.standard.has-start input{border-top-left-radius:0;border-bottom-left-radius:0}:host .native-input.standard.has-end input{border-top-right-radius:0;border-bottom-right-radius:0}:host .native-input.standard .error-message{position:static;background:transparent;padding:.25rem 0;left:auto;transform:none;color:var(--wje-input-color-invalid);font-size:12px;line-height:normal}.clear{visibility:hidden;position:absolute;right:0;top:3px;--wje-padding-top: .25rem;--wje-padding-start: .25rem;--wje-padding-end: .25rem;--wje-padding-bottom: .25rem;--wje-button-margin-inline: 0 .25rem}:host([required]) .input-wrapper:after{color:var(--wje-input-color-invalid);content:"*";font-family:var(--wje-force-mac-font-family);font-size:20px;position:absolute;right:10px;top:2px}:host([required]) .standard .input-wrapper:after{top:0}:host([invalid]) .error-message{display:block}:host([invalid]) .default label{opacity:1!important;color:var(--wje-input-color-invalid)!important;animation-name:shake;animation-duration:.4s;animation-iteration-count:1}::slotted([slot="start"]),::slotted([slot="end"]){display:flex;align-items:center;border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color);padding-inline:var(--wje-input-slot-padding-inline)}slot[name=start],slot[name=end]{display:flex}input{background-color:var(--wje-input-background-color);border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color);font-family:var(--wje-input-font-family);color:var(--wje-input-color);-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0;padding:.25rem .5rem;line-height:var(--wje-input-line-height);font-size:14px;font-weight:400;vertical-align:middle;min-height:32px}.error-message{display:none;position:absolute;width:auto;max-width:100%;min-width:auto;border-radius:50px;background:#000;padding:.25rem .5rem;top:0;left:50%;transform:translate(-50%,-50%);color:#fff;font-size:12px;line-height:normal}@keyframes shake{8%,41%{transform:translate(-4px)}25%,58%{transform:translate(4px)}75%{transform:translate(-2px)}92%{transform:translate(2px)}0%,to{transform:translate(0)}}';
|
|
6
|
-
class c extends m {
|
|
7
|
-
/**
|
|
8
|
-
* @constructor
|
|
9
|
-
* @summary InputFile constructor
|
|
10
|
-
* @param {Object} options - The options
|
|
11
|
-
*/
|
|
12
|
-
constructor(t = {}) {
|
|
13
|
-
super();
|
|
14
|
-
/**
|
|
15
|
-
* @summary Class name
|
|
16
|
-
* @type {string}
|
|
17
|
-
*/
|
|
18
|
-
u(this, "className", "Input");
|
|
19
|
-
this._value = "";
|
|
20
|
-
}
|
|
21
|
-
set value(t) {
|
|
22
|
-
this._value = t;
|
|
23
|
-
}
|
|
24
|
-
get value() {
|
|
25
|
-
return this._value;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @summary Get CSS stylesheet
|
|
29
|
-
* @static
|
|
30
|
-
* @returns {Object} styles
|
|
31
|
-
*/
|
|
32
|
-
static get cssStyleSheet() {
|
|
33
|
-
return w;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @summary Get observed attributes
|
|
37
|
-
* @static
|
|
38
|
-
* @returns {Array} An empty array
|
|
39
|
-
*/
|
|
40
|
-
static get observedAttributes() {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @summary Setup attributes
|
|
45
|
-
*/
|
|
46
|
-
setupAttributes() {
|
|
47
|
-
this.isShadowRoot = "open";
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* @summary Draw method
|
|
51
|
-
* @param {Object} context - The context
|
|
52
|
-
* @param {Object} store - The store
|
|
53
|
-
* @param {Object} params - The parameters
|
|
54
|
-
* @returns {Object} Document fragment
|
|
55
|
-
*/
|
|
56
|
-
draw(t, a, s) {
|
|
57
|
-
let n = document.createDocumentFragment(), o = document.createElement("div");
|
|
58
|
-
o.setAttribute("part", "native"), o.classList.add("native-input-file", this.variant || "default");
|
|
59
|
-
let d = document.createElement("input");
|
|
60
|
-
d.setAttribute("type", "file"), d.setAttribute("multiple", ""), d.setAttribute("hidden", "");
|
|
61
|
-
let r = document.createElement("wje-input");
|
|
62
|
-
r.setAttribute("variant", "standard"), r.setAttribute("type", "text"), r.setAttribute("placeholder", "Click to upload"), r.setAttribute("readonly", "");
|
|
63
|
-
let l = document.createElement("span");
|
|
64
|
-
l.setAttribute("slot", "start");
|
|
65
|
-
let p = document.createElement("wje-icon");
|
|
66
|
-
return p.setAttribute("slot", "icon-only"), p.setAttribute("name", "cloud-upload"), l.appendChild(p), r.appendChild(l), o.appendChild(r), o.appendChild(d), n.appendChild(o), this.native = o, this.input = r, this.fileInput = d, n;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @summary After draw method
|
|
70
|
-
*/
|
|
71
|
-
afterDraw() {
|
|
72
|
-
this.input.addEventListener("click", () => {
|
|
73
|
-
this.fileInput.click();
|
|
74
|
-
}), this.fileInput.addEventListener("change", (t) => {
|
|
75
|
-
let a = t.target.files, s = [];
|
|
76
|
-
for (let n = 0; n < a.length; n++)
|
|
77
|
-
s.push(a[n].name);
|
|
78
|
-
this.input.value = s.join(", "), this.value = a, v.dispatchCustomEvent(this, "wje-input-file:change", { files: a });
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
c.define("wje-input-file", c);
|
|
83
|
-
export {
|
|
84
|
-
c as default
|
|
85
|
-
};
|
package/dist/wje-input.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
var j = Object.defineProperty;
|
|
2
|
-
var y = (n, a, t) => a in n ? j(n, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[a] = t;
|
|
3
|
-
var b = (n, a, t) => (y(n, typeof a != "symbol" ? a + "" : a, t), t);
|
|
4
|
-
import x, { event as w } from "./wje-element.js";
|
|
5
|
-
const A = ':host{--wje-input-font-family: var(--wje-font-family);--wje-input-background-color: var(--wje-background);--wje-input-color: var(--wje-color);--wje-input-color-invalid: var(--wje-color-danger);--wje-input-border-color: var(--wje-border-color);--wje-input-border-color-focus: var(--wje-color-primary);--wje-input-border-width: 1px;--wje-input-border-style: solid;--wje-input-border-radius: 4px;--wje-input-margin-bottom: .5rem;--wje-input-line-height: 20px;--wje-input-slot-padding-inline: .5rem;width:100%;margin-bottom:var(--wje-input-margin-bottom);display:block}:host .wrapper{display:flex;width:100%}:host .native-input .input-wrapper{width:100%;position:relative}:host .native-input.default{background-color:var(--wje-input-background-color);font-family:var(--wje-input-font-family);position:relative;border-radius:var(--wje-input-border-radius);border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color);padding-inline:0;padding-top:.25rem;padding-bottom:.25rem;transition:background-color .2s ease;cursor:text}:host .native-input.default .input-wrapper{margin-inline:.5rem}:host .native-input.default.focused{border-color:var(--wje-input-border-color-focus)!important}:host .native-input.default.focused label{opacity:.67;font-size:12px;letter-spacing:normal}:host .native-input.default input{border:none;height:25px;min-height:25px;padding:0;margin-top:-4px;background:none;box-shadow:none;width:100%}:host .native-input.default label{margin:0;display:block;opacity:1;cursor:text;transition:opacity .2s ease;line-height:var(--wje-input-line-height)}:host .native-input.default label.fade{opacity:.5;font-size:12px;letter-spacing:normal}:host .native-input.default ::slotted([slot="start"]){border-left:none;border-top:none;border-bottom:none}:host .native-input.default ::slotted([slot="end"]){border-right:none;border-top:none;border-bottom:none}:host .native-input.standard{background-color:var(--wje-input-background-color);font-family:var(--wje-input-font-family);position:relative;border-radius:var(--wje-input-border-radius);padding-inline:0;padding-top:0;padding-bottom:0;transition:background-color .2s ease;cursor:text}:host .native-input.standard.focused input{border-color:var(--wje-input-border-color-focus)!important}:host .native-input.standard input{display:block;min-height:32px;padding-inline:.5rem;padding-top:0;padding-bottom:0;background:none;box-shadow:none;width:100%;box-sizing:border-box;border-radius:var(--wje-input-border-radius);border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color)}:host .native-input.standard label{margin:0;display:inline-block;opacity:1;cursor:text;transition:opacity .2s ease;line-height:var(--wje-input-line-height)}:host .native-input.standard .input-wrapper:hover .clear{visibility:visible}:host .native-input.standard ::slotted([slot="start"]){border-right:none;border-radius:var(--wje-input-border-radius) 0 0 var(--wje-input-border-radius)}:host .native-input.standard ::slotted([slot="end"]){border-left:none;border-radius:0 var(--wje-input-border-radius) var(--wje-input-border-radius) 0}:host .native-input.standard.has-start input{border-top-left-radius:0;border-bottom-left-radius:0}:host .native-input.standard.has-end input{border-top-right-radius:0;border-bottom-right-radius:0}:host .native-input.standard .error-message{position:static;background:transparent;padding:.25rem 0;left:auto;transform:none;color:var(--wje-input-color-invalid);font-size:12px;line-height:normal}.clear{visibility:hidden;position:absolute;right:0;top:3px;--wje-padding-top: .25rem;--wje-padding-start: .25rem;--wje-padding-end: .25rem;--wje-padding-bottom: .25rem;--wje-button-margin-inline: 0 .25rem}:host([required]) .input-wrapper:after{color:var(--wje-input-color-invalid);content:"*";font-family:var(--wje-force-mac-font-family);font-size:20px;position:absolute;right:10px;top:2px}:host([required]) .standard .input-wrapper:after{top:0}:host([invalid]) .error-message{display:block}:host([invalid]) .default label{opacity:1!important;color:var(--wje-input-color-invalid)!important;animation-name:shake;animation-duration:.4s;animation-iteration-count:1}::slotted([slot="start"]),::slotted([slot="end"]){display:flex;align-items:center;border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color);padding-inline:var(--wje-input-slot-padding-inline)}slot[name=start],slot[name=end]{display:flex}input{background-color:var(--wje-input-background-color);border-width:var(--wje-input-border-width);border-style:var(--wje-input-border-style);border-color:var(--wje-input-border-color);font-family:var(--wjinput-font-family);color:var(--wje-input-color);-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0;padding:.25rem .5rem;line-height:var(--wje-input-line-height);font-size:14px;font-weight:400;vertical-align:middle;min-height:32px}.error-message{display:none;position:absolute;width:auto;max-width:100%;min-width:auto;border-radius:50px;background:#000;padding:.25rem .5rem;top:0;left:50%;transform:translate(-50%,-50%);color:#fff;font-size:12px;line-height:normal}@keyframes shake{8%,41%{transform:translate(-4px)}25%,58%{transform:translate(4px)}75%{transform:translate(-2px)}92%{transform:translate(2px)}0%,to{transform:translate(0)}}';
|
|
6
|
-
class m extends x {
|
|
7
|
-
/**
|
|
8
|
-
* Constructor for the Input class.
|
|
9
|
-
* @param {Object} options - The options for the Input class.
|
|
10
|
-
*/
|
|
11
|
-
constructor(t = {}) {
|
|
12
|
-
super();
|
|
13
|
-
/**
|
|
14
|
-
* The class name of the input.
|
|
15
|
-
* @type {string}
|
|
16
|
-
*/
|
|
17
|
-
b(this, "className", "Input");
|
|
18
|
-
this.invalid = !1, this.pristine = !0, this.internals = this.attachInternals();
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Setter for the value attribute.
|
|
22
|
-
* @param {string} value - The value to set.
|
|
23
|
-
*/
|
|
24
|
-
set value(t) {
|
|
25
|
-
this.setAttribute("value", t);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Getter for the value attribute.
|
|
29
|
-
* @returns {string} The value of the attribute.
|
|
30
|
-
*/
|
|
31
|
-
get value() {
|
|
32
|
-
return this.getAttribute("value") || "";
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Getter for the customErrorDisplay attribute.
|
|
36
|
-
* @returns {boolean} Whether the attribute is present.
|
|
37
|
-
*/
|
|
38
|
-
get customErrorDisplay() {
|
|
39
|
-
return this.hasAttribute("custom-error-display");
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Getter for the validateOnChange attribute.
|
|
43
|
-
* @returns {boolean} Whether the attribute is present.
|
|
44
|
-
*/
|
|
45
|
-
get validateOnChange() {
|
|
46
|
-
return this.hasAttribute("validate-on-change");
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Getter for the invalid attribute.
|
|
50
|
-
* @returns {boolean} Whether the attribute is present.
|
|
51
|
-
*/
|
|
52
|
-
get invalid() {
|
|
53
|
-
return this.hasAttribute("invalid");
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Setter for the invalid attribute.
|
|
57
|
-
* @param {boolean} isInvalid - Whether the input is invalid.
|
|
58
|
-
*/
|
|
59
|
-
set invalid(t) {
|
|
60
|
-
t && this.customErrorDisplay ? this.setAttribute("invalid", "") : this.removeAttribute("invalid");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Getter for the form attribute.
|
|
64
|
-
* @returns {HTMLFormElement} The form the input is associated with.
|
|
65
|
-
*/
|
|
66
|
-
get form() {
|
|
67
|
-
return this.internals.form;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Getter for the name attribute.
|
|
71
|
-
* @returns {string} The name of the input.
|
|
72
|
-
*/
|
|
73
|
-
get name() {
|
|
74
|
-
return this.getAttribute("name");
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Getter for the type attribute.
|
|
78
|
-
* @returns {string} The type of the input.
|
|
79
|
-
*/
|
|
80
|
-
get type() {
|
|
81
|
-
return this.localName;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Getter for the validity attribute.
|
|
85
|
-
* @returns {ValidityState} The validity state of the input.
|
|
86
|
-
*/
|
|
87
|
-
get validity() {
|
|
88
|
-
return this.internals.validity;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Getter for the validationMessage attribute.
|
|
92
|
-
* @returns {string} The validation message of the input.
|
|
93
|
-
*/
|
|
94
|
-
get validationMessage() {
|
|
95
|
-
return this.internals.validationMessage;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Getter for the willValidate attribute.
|
|
99
|
-
* @returns {boolean} Whether the input will be validated.
|
|
100
|
-
*/
|
|
101
|
-
get willValidate() {
|
|
102
|
-
return this.internals.willValidate;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Checks the validity of the input.
|
|
106
|
-
* @returns {boolean} Whether the input is valid.
|
|
107
|
-
*/
|
|
108
|
-
checkValidity() {
|
|
109
|
-
return this.internals.checkValidity();
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Reports the validity of the input.
|
|
113
|
-
* @returns {boolean} Whether the input is valid.
|
|
114
|
-
*/
|
|
115
|
-
reportValidity() {
|
|
116
|
-
return this.internals.reportValidity();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Getter for the cssStyleSheet attribute.
|
|
120
|
-
* @returns {CSSStyleSheet} The CSS style sheet of the input.
|
|
121
|
-
*/
|
|
122
|
-
static get cssStyleSheet() {
|
|
123
|
-
return A;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Getter for the observedAttributes attribute.
|
|
127
|
-
* @returns {Array} The attributes to observe for changes.
|
|
128
|
-
*/
|
|
129
|
-
static get observedAttributes() {
|
|
130
|
-
return ["value"];
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Sets up the attributes for the input.
|
|
134
|
-
*/
|
|
135
|
-
setupAttributes() {
|
|
136
|
-
this.isShadowRoot = "open";
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Draws the input.
|
|
140
|
-
* @param {CanvasRenderingContext2D} context - The context to draw on.
|
|
141
|
-
* @param {Object} store - The store to use.
|
|
142
|
-
* @param {Object} params - The parameters to use.
|
|
143
|
-
* @returns {DocumentFragment} The drawn input.
|
|
144
|
-
*/
|
|
145
|
-
draw(t, e, s) {
|
|
146
|
-
let o = this.hasSlot(this, "start"), v = this.hasSlot(this, "end"), f = document.createDocumentFragment(), r = document.createElement("div");
|
|
147
|
-
r.setAttribute("part", "native"), r.classList.add("native-input", this.variant || "default"), this.hasAttribute("invalid") && r.classList.add("has-error");
|
|
148
|
-
let l = document.createElement("div");
|
|
149
|
-
l.classList.add("wrapper");
|
|
150
|
-
let d = document.createElement("div");
|
|
151
|
-
d.classList.add("input-wrapper");
|
|
152
|
-
let u = document.createElement("label");
|
|
153
|
-
u.innerText = this.label, this.value && !this.hasAttribute("error") && u.classList.add("fade");
|
|
154
|
-
let i = document.createElement("input");
|
|
155
|
-
i.setAttribute("type", "text"), i.setAttribute("part", "input"), i.setAttribute("value", this.value || ""), i.classList.add("form-control"), this.hasAttribute("placeholder") && i.setAttribute("placeholder", this.placeholder), this.hasAttribute("multiple") && i.setAttribute("multiple", this.multiple), this.hasAttribute("disabled") && i.setAttribute("disabled", ""), this.hasAttribute("readonly") && i.setAttribute("readonly", ""), this.hasAttribute("maxlength") && i.setAttribute("maxlength", this.maxlength), this.hasAttribute("max") && i.setAttribute("max", this.max), this.hasAttribute("min") && i.setAttribute("min", this.min);
|
|
156
|
-
let p = document.createElement("div");
|
|
157
|
-
p.classList.add("error-message");
|
|
158
|
-
let h = null;
|
|
159
|
-
o && (h = document.createElement("slot"), h.setAttribute("name", "start"));
|
|
160
|
-
let c = null;
|
|
161
|
-
if (v && (c = document.createElement("slot"), c.setAttribute("name", "end")), o && (l.appendChild(h), r.classList.add("has-start")), this.variant === "standard" ? this.label && r.appendChild(u) : d.appendChild(u), d.appendChild(i), l.appendChild(d), r.appendChild(l), this.hasAttribute("clearable")) {
|
|
162
|
-
this.clear = document.createElement("wje-button"), this.clear.classList.add("clear"), this.clear.setAttribute("fill", "link"), this.clear.setAttribute("part", "clear");
|
|
163
|
-
let g = document.createElement("wje-icon");
|
|
164
|
-
g.setAttribute("name", "x"), this.clear.appendChild(g), d.appendChild(this.clear);
|
|
165
|
-
}
|
|
166
|
-
return v && (l.appendChild(c), r.classList.add("has-end")), r.appendChild(p), f.appendChild(r), this.native = r, this.labelElement = u, this.input = i, this.errorMessage = p, f;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Runs after the input is drawn.
|
|
170
|
-
*/
|
|
171
|
-
afterDraw() {
|
|
172
|
-
[
|
|
173
|
-
"type",
|
|
174
|
-
"value",
|
|
175
|
-
"placeholder",
|
|
176
|
-
"required",
|
|
177
|
-
"min",
|
|
178
|
-
"max",
|
|
179
|
-
"minLength",
|
|
180
|
-
"maxLength",
|
|
181
|
-
"pattern"
|
|
182
|
-
].forEach((t) => {
|
|
183
|
-
const e = t === "required" ? this.hasAttribute(t) : this.getAttribute(t);
|
|
184
|
-
e != null && (this.input[t] = e);
|
|
185
|
-
}), this.input.addEventListener("focus", (t) => {
|
|
186
|
-
this.labelElement.classList.add("fade"), this.native.classList.add("focused");
|
|
187
|
-
}), this.input.addEventListener("blur", (t) => {
|
|
188
|
-
this.native.classList.remove("focused"), t.target.value || this.labelElement.classList.remove("fade");
|
|
189
|
-
}), this.input.addEventListener("input", (t) => {
|
|
190
|
-
this.validateOnChange && (this.pristine = !1), this.input.classList.remove("pristine"), this.labelElement.classList.add("fade");
|
|
191
|
-
const e = new t.constructor(t.type, t);
|
|
192
|
-
this.dispatchEvent(e), this.validateInput(), w.dispatchCustomEvent(this, "wje-input:input", {
|
|
193
|
-
value: this.input.value
|
|
194
|
-
});
|
|
195
|
-
}), this.addEventListener("invalid", (t) => {
|
|
196
|
-
this.invalid = !0, this.pristine = !1, this.errorMessage.textContent = this.internals.validationMessage, this.customErrorDisplay && t.preventDefault();
|
|
197
|
-
}), this.addEventListener("focus", () => this.input.focus()), this.clear && this.clear.addEventListener("wje-button:click", (t) => {
|
|
198
|
-
this.input.value = "", w.dispatchCustomEvent(this.clear, "wje-input:clear");
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Validates the input.
|
|
203
|
-
*/
|
|
204
|
-
validateInput() {
|
|
205
|
-
const t = this.input.validity;
|
|
206
|
-
if (this.invalid = !1, t.valid)
|
|
207
|
-
this.internals.setValidity({}), this.pristine = !1, this.errorMessage.textContent = this.input.validationMessage;
|
|
208
|
-
else
|
|
209
|
-
for (let e in t) {
|
|
210
|
-
const s = `message-${e.toString()}`;
|
|
211
|
-
if (t[e]) {
|
|
212
|
-
this.validationError = e.toString(), this.invalid = !this.pristine && !t.valid;
|
|
213
|
-
let o = this.message;
|
|
214
|
-
this.hasAttribute("message") || (o = this.hasAttribute(s) ? this.getAttribute(s) : this.input.validationMessage), this.internals.setValidity(
|
|
215
|
-
{ [this.validationError]: !0 },
|
|
216
|
-
o
|
|
217
|
-
), this.invalid && this.customErrorDisplay && this.dispatchEvent(new Event("invalid"));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Checks whether the input has a slot.
|
|
223
|
-
* @param {HTMLElement} el - The element to check.
|
|
224
|
-
* @param {string} slotName - The name of the slot to check for.
|
|
225
|
-
* @returns {boolean} Whether the input has the slot.
|
|
226
|
-
*/
|
|
227
|
-
hasSlot(t, e = null) {
|
|
228
|
-
let s = e ? `[slot="${e}"]` : "[slot]";
|
|
229
|
-
return t.querySelectorAll(s).length > 0;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Whether the input is associated with a form.
|
|
234
|
-
* @type {boolean}
|
|
235
|
-
*/
|
|
236
|
-
b(m, "formAssociated", !0);
|
|
237
|
-
m.define("wje-input", m);
|
|
238
|
-
export {
|
|
239
|
-
m as default
|
|
240
|
-
};
|