wj-elements 0.1.103 → 0.1.104
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/infinite-scroll.element-7dR-X4sd.js +263 -0
- package/dist/list.element-BkOOqBtW.js +58 -0
- package/dist/wje-element.js +4 -3
- package/dist/wje-icon-picker.js +2 -1
- package/dist/wje-infinite-scroll.js +1 -250
- package/dist/wje-list.js +1 -55
- package/dist/wje-master.js +102 -100
- package/dist/wje-options.js +107 -10
- package/dist/wje-select.js +12 -7
- package/dist/wje-textarea.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import WJElement, { WjElementUtils, event } from "./wje-element.js";
|
|
8
|
+
const styles = "/*\r\n[ Wj infinite Scroll ]\r\n*/\r\n\r\n:host {\r\n overflow-x: auto;\r\n width: var(--wje-infinite-scroll-width);\r\n height: var(--wje-infinite-scroll-height);\r\n display: block;\r\n}\r\n\r\n.native {\r\n /*position: relative;*/\r\n}\r\n\r\n.loading {\r\n position: sticky;\r\n display: none;\r\n justify-content: center;\r\n align-items: center;\r\n width: 100%;\r\n height: 100%;\r\n top: 0;\r\n left: 0;\r\n z-index: 9999;\r\n background-color: var(--wje-infinite-scroll-loading-bg);\r\n &.show {\r\n display: flex;\r\n }\r\n}\r\n\r\n[name=ending] {\r\n display: none;\r\n margin-top: 1rem;\r\n text-align: center;\r\n}\r\n\r\n[name=ending].show {\r\n display: block;\r\n}";
|
|
9
|
+
class InfiniteScroll extends WJElement {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of InfiniteScroll.
|
|
12
|
+
*
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {Object} options - The options for the InfiniteScroll.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
super();
|
|
18
|
+
__publicField(this, "className", "InfiniteScroll");
|
|
19
|
+
/**
|
|
20
|
+
* Adds the scroll event listener.
|
|
21
|
+
*/
|
|
22
|
+
__publicField(this, "scrollEvent", () => {
|
|
23
|
+
this.addEventListener("scroll", this.onScroll);
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Removes the scroll event listener.
|
|
27
|
+
*/
|
|
28
|
+
__publicField(this, "unScrollEvent", () => {
|
|
29
|
+
this.removeEventListener("scroll", this.onScroll);
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Handles the scroll event.
|
|
33
|
+
*
|
|
34
|
+
* @param {Event} e - The event.
|
|
35
|
+
*/
|
|
36
|
+
__publicField(this, "onScroll", (e) => {
|
|
37
|
+
const { scrollTop, scrollHeight, clientHeight } = e.target;
|
|
38
|
+
if (scrollTop + clientHeight >= scrollHeight - 300 && this.currentPage <= this.totalPages && this.isLoading.includes(this.currentPage)) {
|
|
39
|
+
this.currentPage++;
|
|
40
|
+
this._loading = this.loadPages(this.currentPage);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Sets the custom data.
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
__publicField(this, "dataToHtml", (item) => {
|
|
48
|
+
let interpolateItem = this.infiniteScrollTemplate.interpolate(item);
|
|
49
|
+
let doc = this.parser.parseFromString(interpolateItem, "text/html");
|
|
50
|
+
let element = doc.activeElement.firstElementChild;
|
|
51
|
+
return element;
|
|
52
|
+
});
|
|
53
|
+
__publicField(this, "customForeach", (data) => {
|
|
54
|
+
data.forEach((item) => {
|
|
55
|
+
let element = this.dataToHtml(item);
|
|
56
|
+
event.addListener(element, "click", "wje-infinite-scroll:click-item", null);
|
|
57
|
+
this.placementObj.insertAdjacentElement("beforeend", element);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
this.totalPages = 0;
|
|
61
|
+
this.isLoading = [];
|
|
62
|
+
this._response = {};
|
|
63
|
+
this.iterate = null;
|
|
64
|
+
this._infiniteScrollTemplate = null;
|
|
65
|
+
this._abortController = new AbortController();
|
|
66
|
+
this._signal;
|
|
67
|
+
String.prototype.interpolate = function(params) {
|
|
68
|
+
let template = this;
|
|
69
|
+
let keys = template.match(/\{{.*?\}}/g);
|
|
70
|
+
if (keys) {
|
|
71
|
+
for (let key of keys) {
|
|
72
|
+
let cleanKey = key.replace("{{", "").replace("}}", "");
|
|
73
|
+
let val = "";
|
|
74
|
+
cleanKey.split(".").forEach((k) => {
|
|
75
|
+
val = val == "" ? params[k] : val[k];
|
|
76
|
+
});
|
|
77
|
+
template = template.replace(key, val);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return template;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
set infiniteScrollTemplate(value) {
|
|
84
|
+
this._infiniteScrollTemplate = value;
|
|
85
|
+
}
|
|
86
|
+
get infiniteScrollTemplate() {
|
|
87
|
+
return this._infiniteScrollTemplate;
|
|
88
|
+
}
|
|
89
|
+
set response(value) {
|
|
90
|
+
this._response = value;
|
|
91
|
+
}
|
|
92
|
+
get response() {
|
|
93
|
+
return this._response;
|
|
94
|
+
}
|
|
95
|
+
set objectName(value) {
|
|
96
|
+
this.setAttribute("object-name", value);
|
|
97
|
+
}
|
|
98
|
+
get objectName() {
|
|
99
|
+
return this.getAttribute("object-name") ?? "data";
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the CSS styles for the component.
|
|
103
|
+
*
|
|
104
|
+
* @static
|
|
105
|
+
* @returns {CSSStyleSheet}
|
|
106
|
+
*/
|
|
107
|
+
static get cssStyleSheet() {
|
|
108
|
+
return styles;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the list of attributes to observe for changes.
|
|
112
|
+
*
|
|
113
|
+
* @static
|
|
114
|
+
* @returns {Array<string>}
|
|
115
|
+
*/
|
|
116
|
+
static get observedAttributes() {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Sets up the attributes for the component.
|
|
121
|
+
*/
|
|
122
|
+
setupAttributes() {
|
|
123
|
+
this.isShadowRoot = "open";
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Prepares the component before drawing.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} context - The context for drawing.
|
|
129
|
+
* @param {Object} store - The store for drawing.
|
|
130
|
+
* @param {Object} params - The parameters for drawing.
|
|
131
|
+
*/
|
|
132
|
+
beforeDraw(context, store, params) {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
this.iterate = this.querySelector("[iterate]");
|
|
135
|
+
this.infiniteScrollTemplate = (_a = this.iterate) == null ? void 0 : _a.outerHTML;
|
|
136
|
+
(_b = this.iterate) == null ? void 0 : _b.remove();
|
|
137
|
+
this.setAttribute("style", "height: " + this.height);
|
|
138
|
+
if (this._signal) {
|
|
139
|
+
this._abortController.abort();
|
|
140
|
+
this._abortController = new AbortController();
|
|
141
|
+
this._signal = this._abortController.signal;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Draws the component.
|
|
146
|
+
*
|
|
147
|
+
* @param {Object} context - The context for drawing.
|
|
148
|
+
* @param {Object} store - The store for drawing.
|
|
149
|
+
* @param {Object} params - The parameters for drawing.
|
|
150
|
+
* @returns {DocumentFragment}
|
|
151
|
+
*/
|
|
152
|
+
draw(context, store, params) {
|
|
153
|
+
let fragment = document.createDocumentFragment();
|
|
154
|
+
let native = document.createElement("div");
|
|
155
|
+
native.classList.add("native");
|
|
156
|
+
native.setAttribute("part", "native-infinite-scroll");
|
|
157
|
+
let slot = document.createElement("slot");
|
|
158
|
+
let ending = document.createElement("slot");
|
|
159
|
+
ending.setAttribute("name", "ending");
|
|
160
|
+
if (WjElementUtils.hasSlot(this, "loader")) {
|
|
161
|
+
let loading = document.createElement("div");
|
|
162
|
+
loading.classList.add("loading");
|
|
163
|
+
let loader = document.createElement("slot");
|
|
164
|
+
loader.setAttribute("name", "loader");
|
|
165
|
+
loading.appendChild(loader);
|
|
166
|
+
this.loadingEl = loading;
|
|
167
|
+
fragment.appendChild(loading);
|
|
168
|
+
}
|
|
169
|
+
native.appendChild(slot);
|
|
170
|
+
native.appendChild(ending);
|
|
171
|
+
fragment.appendChild(native);
|
|
172
|
+
this.endingEl = ending;
|
|
173
|
+
return fragment;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Called after the component has been drawn.
|
|
177
|
+
*/
|
|
178
|
+
async afterDraw() {
|
|
179
|
+
this.queryParams = this.queryParams || "";
|
|
180
|
+
this.size = +this.size || 10;
|
|
181
|
+
this.currentPage = 0;
|
|
182
|
+
this.scrollEvent();
|
|
183
|
+
this._loading = this.loadPages(this.currentPage);
|
|
184
|
+
await this._loading;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Fetches the pages from the server.
|
|
188
|
+
*
|
|
189
|
+
* @param {number} page - The page number.
|
|
190
|
+
* @returns {Promise<Object>} The response from the server.
|
|
191
|
+
*/
|
|
192
|
+
async getPages(page) {
|
|
193
|
+
let hasParams = this.url.includes("?");
|
|
194
|
+
const response = await fetch(`${this.url}${hasParams ? "&" : "?"}page=${page}&size=${this.size}${this == null ? void 0 : this.queryParams}`, {
|
|
195
|
+
signal: this._signal
|
|
196
|
+
});
|
|
197
|
+
if (!response.ok) {
|
|
198
|
+
throw new Error(`An error occurred: ${response.status}`);
|
|
199
|
+
}
|
|
200
|
+
return await response.json();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Hides the loader.
|
|
204
|
+
*/
|
|
205
|
+
hideLoader() {
|
|
206
|
+
var _a;
|
|
207
|
+
(_a = this == null ? void 0 : this.loadingEl) == null ? void 0 : _a.classList.remove("show");
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Shows the loader.
|
|
211
|
+
*/
|
|
212
|
+
showLoader() {
|
|
213
|
+
var _a;
|
|
214
|
+
(_a = this == null ? void 0 : this.loadingEl) == null ? void 0 : _a.classList.add("show");
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Checks if there are more pages to load.
|
|
218
|
+
*
|
|
219
|
+
* @param {number} page - The page number.
|
|
220
|
+
* @returns {boolean} Whether there are more pages to load.
|
|
221
|
+
*/
|
|
222
|
+
hasMorePages(page) {
|
|
223
|
+
return this.totalPages === 0 || page < this.totalPages;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Loads the pages.
|
|
227
|
+
*
|
|
228
|
+
* @param {number} page - The page number.
|
|
229
|
+
*/
|
|
230
|
+
async loadPages(page) {
|
|
231
|
+
this.showLoader();
|
|
232
|
+
try {
|
|
233
|
+
if (this.hasMorePages(page)) {
|
|
234
|
+
let response;
|
|
235
|
+
this.parser = new DOMParser();
|
|
236
|
+
if (typeof this.setCustomData === "function") {
|
|
237
|
+
response = await this.setCustomData(page, this._signal);
|
|
238
|
+
} else {
|
|
239
|
+
response = await this.getPages(page);
|
|
240
|
+
}
|
|
241
|
+
this.totalPages = response.totalPages;
|
|
242
|
+
this.currentPage = page;
|
|
243
|
+
this.placementObj = this;
|
|
244
|
+
if (this.hasAttribute("placement"))
|
|
245
|
+
this.placementObj = this.querySelector(this.placement);
|
|
246
|
+
event.dispatchCustomEvent(this, "wje-infinite-scroll:load", response);
|
|
247
|
+
this.response = response;
|
|
248
|
+
this.customForeach(this.objectName ? response[this.objectName] : response);
|
|
249
|
+
this.isLoading.push(page);
|
|
250
|
+
} else {
|
|
251
|
+
event.dispatchCustomEvent(this, "wje-infinite-scroll:complete");
|
|
252
|
+
this.endingEl.classList.add("show");
|
|
253
|
+
}
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.log(error.message);
|
|
256
|
+
} finally {
|
|
257
|
+
this.hideLoader();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
export {
|
|
262
|
+
InfiniteScroll as I
|
|
263
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import WJElement from "./wje-element.js";
|
|
8
|
+
const styles = "/*\n[ WJ List ]\n*/\n:host {\n margin: 0;\n padding: 0;\n display: block;\n contain: content;\n list-style-type: none;\n}\n\n:host(.wje-inset) {\n background: var(--wje-list-background);\n transform: translateZ(0);\n overflow: hidden;\n padding: var(--wje-list-inset-padding);\n border-radius: var(--wje-list-border-radius);\n}\n\n:host(.wje-lines-none) ::slotted(wje-item) {\n --wje-border-width: 0 !important;\n}";
|
|
9
|
+
class List extends WJElement {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of List.
|
|
12
|
+
*
|
|
13
|
+
* @constructor
|
|
14
|
+
*/
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
__publicField(this, "className", "List");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the CSS styles for the component.
|
|
21
|
+
*
|
|
22
|
+
* @static
|
|
23
|
+
* @returns {CSSStyleSheet}
|
|
24
|
+
*/
|
|
25
|
+
static get cssStyleSheet() {
|
|
26
|
+
return styles;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets up the attributes for the component.
|
|
30
|
+
*/
|
|
31
|
+
setupAttributes() {
|
|
32
|
+
this.isShadowRoot = "open";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Draws the component.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} context - The context for drawing.
|
|
38
|
+
* @param {Object} store - The store for drawing.
|
|
39
|
+
* @param {Object} params - The parameters for drawing.
|
|
40
|
+
* @returns {DocumentFragment}
|
|
41
|
+
*/
|
|
42
|
+
draw(context, store, params) {
|
|
43
|
+
let fragment = document.createDocumentFragment();
|
|
44
|
+
let element = document.createElement("slot");
|
|
45
|
+
fragment.appendChild(element);
|
|
46
|
+
return fragment;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Called after the component has been drawn.
|
|
50
|
+
*/
|
|
51
|
+
afterDraw() {
|
|
52
|
+
this.classList.toggle("wje-lines-" + this.lines, this.hasAttribute("lines"));
|
|
53
|
+
this.classList.toggle("wje-inset", this.hasAttribute("inset"));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
List as L
|
|
58
|
+
};
|
package/dist/wje-element.js
CHANGED
|
@@ -115,13 +115,14 @@ class UniversalService {
|
|
|
115
115
|
});
|
|
116
116
|
return this.dispatch(promise, dispatchMethod, action);
|
|
117
117
|
}
|
|
118
|
-
_get(url, action, dispatchMethod) {
|
|
118
|
+
_get(url, action, dispatchMethod, signal) {
|
|
119
119
|
let promise = fetch(url, {
|
|
120
120
|
method: "GET",
|
|
121
121
|
// cache: 'no-cache',
|
|
122
122
|
headers: {
|
|
123
123
|
"Content-Type": "application/json"
|
|
124
|
-
}
|
|
124
|
+
},
|
|
125
|
+
...signal ? { signal } : {}
|
|
125
126
|
// referrerPolicy: 'same-origin',
|
|
126
127
|
}).then(async (response) => {
|
|
127
128
|
let text;
|
|
@@ -144,7 +145,7 @@ class UniversalService {
|
|
|
144
145
|
delete(url, data, action, dispatchMethod = true) {
|
|
145
146
|
return this._save(url, data, action, dispatchMethod, "DELETE");
|
|
146
147
|
}
|
|
147
|
-
get(url, action, dispatchMethod = true) {
|
|
148
|
+
get(url, action, dispatchMethod = true, signal) {
|
|
148
149
|
return this._get(url, action, dispatchMethod);
|
|
149
150
|
}
|
|
150
151
|
dispatch(promise, dispatchMethod, action) {
|
package/dist/wje-icon-picker.js
CHANGED
|
@@ -5,10 +5,11 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import WJElement, { event } from "./wje-element.js";
|
|
8
|
-
import
|
|
8
|
+
import "./wje-infinite-scroll.js";
|
|
9
9
|
import Input from "./wje-input.js";
|
|
10
10
|
import Tooltip from "./wje-tooltip.js";
|
|
11
11
|
import "./wje-popup.js";
|
|
12
|
+
import { I as InfiniteScroll } from "./infinite-scroll.element-7dR-X4sd.js";
|
|
12
13
|
import { P as Popup } from "./popup.element-Dna4OwCH.js";
|
|
13
14
|
const styles = "/*\r\n[ Wj Icon Picker ]\r\n*/\r\n\r\n:host {\r\n --wje-icon-picker-radius: var(--wje-border-radius-small);\r\n --wje-icon-picker-icon-size: 1.5rem;\r\n --wje-icon-picker-border-width: 1px;\r\n --wje-icon-picker-border-style: solid;\r\n --wje-icon-picker-border-color: var(--wje-border-color);\r\n --wje-icon-picker-padding: .25rem;\r\n padding: 0 1rem;\r\n}\r\n\r\n.anchor {\r\n width: var(--wje-icon-picker-icon-size);\r\n height: var(--wje-icon-picker-icon-size);\r\n padding: var(--wje-icon-picker-padding);\r\n border-width: var(--wje-icon-picker-border-width);\r\n border-style: var(--wje-icon-picker-border-style);\r\n border-color: var(--wje-icon-picker-border-color);\r\n box-sizing: border-box;\r\n border-radius: var(--wje-icon-picker-radius);\r\n}\r\n\r\n.picker {\r\n width: 320px;\r\n height: 271px;\r\n box-shadow: 0 0 5px rgba(0,0,0,.05), 0 5px 20px rgba(0,0,0,.1);\r\n border-radius: var(--wje-icon-picker-radius);\r\n border-width: var(--wje-icon-picker-border-width);\r\n border-style: var(--wje-icon-picker-border-style);\r\n border-color: var(--wje-icon-picker-border-color);\r\n overflow: auto;\r\n padding: 1rem;\r\n background: var(--wje-background);\r\n}\r\n\r\n.icon-items {\r\n --icon-min-width: 2rem;\r\n display: grid;\r\n grid-gap: .5rem;\r\n grid-template-columns: repeat(auto-fit,minmax(var(--icon-min-width),1fr));\r\n}\r\n\r\n.icon-item {\r\n box-sizing: border-box;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n text-align: center;\r\n color: inherit;\r\n padding: .25rem;\r\n min-height: var(--wje-icon-picker-icon-size);\r\n min-width: var(--wje-icon-picker-icon-size);\r\n text-decoration: none;\r\n\r\n &:hover {\r\n border-radius: .25rem;\r\n background: var(--wje-border-color);\r\n }\r\n}\r\n\r\n.wje-size {\r\n --wje-icon-size: 24px !important;\r\n}\r\n\r\nicon-item svg {\r\n width: var(--wje-icon-picker-icon-size);\r\n height: var(--wje-icon-picker-icon-size);\r\n}\r\n\r\nwje-input {\r\n --wje-input-border-radius: 4px;\r\n --wje-input-margin-bottom: 0;\r\n}\r\n\r\nwje-infinite-scroll {\r\n margin-top: 1rem;\r\n}\r\n\r\nwje-select {\r\n --wje-select-border-width: 0 0 1px 0 !important;\r\n --wje-select-border-radius: 0 !important;\r\n margin-bottom: 1rem;\r\n}\r\n\r\n.anchor wje-icon {\r\n --wje-icon-size: 100% !important;\r\n}";
|
|
14
15
|
class IconPicker extends WJElement {
|
|
@@ -1,253 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import WJElement, { WjElementUtils, event } from "./wje-element.js";
|
|
8
|
-
const styles = "/*\r\n[ Wj infinite Scroll ]\r\n*/\r\n\r\n:host {\r\n overflow-x: auto;\r\n width: var(--wje-infinite-scroll-width);\r\n height: var(--wje-infinite-scroll-height);\r\n display: block;\r\n}\r\n\r\n.native {\r\n /*position: relative;*/\r\n}\r\n\r\n.loading {\r\n position: sticky;\r\n display: none;\r\n justify-content: center;\r\n align-items: center;\r\n width: 100%;\r\n height: 100%;\r\n top: 0;\r\n left: 0;\r\n z-index: 9999;\r\n background-color: var(--wje-infinite-scroll-loading-bg);\r\n &.show {\r\n display: flex;\r\n }\r\n}\r\n\r\n[name=ending] {\r\n display: none;\r\n margin-top: 1rem;\r\n text-align: center;\r\n}\r\n\r\n[name=ending].show {\r\n display: block;\r\n}";
|
|
9
|
-
class InfiniteScroll extends WJElement {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of InfiniteScroll.
|
|
12
|
-
*
|
|
13
|
-
* @constructor
|
|
14
|
-
* @param {Object} options - The options for the InfiniteScroll.
|
|
15
|
-
*/
|
|
16
|
-
constructor(options = {}) {
|
|
17
|
-
super();
|
|
18
|
-
__publicField(this, "className", "InfiniteScroll");
|
|
19
|
-
/**
|
|
20
|
-
* Adds the scroll event listener.
|
|
21
|
-
*/
|
|
22
|
-
__publicField(this, "scrollEvent", () => {
|
|
23
|
-
this.addEventListener("scroll", this.onScroll);
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Removes the scroll event listener.
|
|
27
|
-
*/
|
|
28
|
-
__publicField(this, "unScrollEvent", () => {
|
|
29
|
-
this.removeEventListener("scroll", this.onScroll);
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Handles the scroll event.
|
|
33
|
-
*
|
|
34
|
-
* @param {Event} e - The event.
|
|
35
|
-
*/
|
|
36
|
-
__publicField(this, "onScroll", (e) => {
|
|
37
|
-
const { scrollTop, scrollHeight, clientHeight } = e.target;
|
|
38
|
-
if (scrollTop + clientHeight >= scrollHeight - 300 && this.currentPage <= this.totalPages && this.isLoading.includes(this.currentPage)) {
|
|
39
|
-
this.currentPage++;
|
|
40
|
-
this.loadPages(this.currentPage);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
/**
|
|
44
|
-
* Sets the custom data.
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
__publicField(this, "dataToHtml", (item) => {
|
|
48
|
-
let interpolateItem = this.infiniteScrollTemplate.interpolate(item);
|
|
49
|
-
let doc = this.parser.parseFromString(interpolateItem, "text/html");
|
|
50
|
-
let element = doc.activeElement.firstElementChild;
|
|
51
|
-
return element;
|
|
52
|
-
});
|
|
53
|
-
__publicField(this, "customForeach", (data) => {
|
|
54
|
-
data.forEach((item) => {
|
|
55
|
-
let element = this.dataToHtml(item);
|
|
56
|
-
event.addListener(element, "click", "wje-infinite-scroll:click-item", null);
|
|
57
|
-
this.placementObj.insertAdjacentElement("beforeend", element);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
this.totalPages = 0;
|
|
61
|
-
this.isLoading = [];
|
|
62
|
-
this._response = {};
|
|
63
|
-
this.iterate = null;
|
|
64
|
-
this._infiniteScrollTemplate = null;
|
|
65
|
-
String.prototype.interpolate = function(params) {
|
|
66
|
-
let template = this;
|
|
67
|
-
let keys = template.match(/\{{.*?\}}/g);
|
|
68
|
-
if (keys) {
|
|
69
|
-
for (let key of keys) {
|
|
70
|
-
let cleanKey = key.replace("{{", "").replace("}}", "");
|
|
71
|
-
let val = "";
|
|
72
|
-
cleanKey.split(".").forEach((k) => {
|
|
73
|
-
val = val == "" ? params[k] : val[k];
|
|
74
|
-
});
|
|
75
|
-
template = template.replace(key, val);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return template;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
set infiniteScrollTemplate(value) {
|
|
82
|
-
this._infiniteScrollTemplate = value;
|
|
83
|
-
}
|
|
84
|
-
get infiniteScrollTemplate() {
|
|
85
|
-
return this._infiniteScrollTemplate;
|
|
86
|
-
}
|
|
87
|
-
set response(value) {
|
|
88
|
-
this._response = value;
|
|
89
|
-
}
|
|
90
|
-
get response() {
|
|
91
|
-
return this._response;
|
|
92
|
-
}
|
|
93
|
-
set objectName(value) {
|
|
94
|
-
this.setAttribute("object-name", value);
|
|
95
|
-
}
|
|
96
|
-
get objectName() {
|
|
97
|
-
return this.getAttribute("object-name") || "data";
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Returns the CSS styles for the component.
|
|
101
|
-
*
|
|
102
|
-
* @static
|
|
103
|
-
* @returns {CSSStyleSheet}
|
|
104
|
-
*/
|
|
105
|
-
static get cssStyleSheet() {
|
|
106
|
-
return styles;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Returns the list of attributes to observe for changes.
|
|
110
|
-
*
|
|
111
|
-
* @static
|
|
112
|
-
* @returns {Array<string>}
|
|
113
|
-
*/
|
|
114
|
-
static get observedAttributes() {
|
|
115
|
-
return [];
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Sets up the attributes for the component.
|
|
119
|
-
*/
|
|
120
|
-
setupAttributes() {
|
|
121
|
-
this.isShadowRoot = "open";
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Prepares the component before drawing.
|
|
125
|
-
*
|
|
126
|
-
* @param {Object} context - The context for drawing.
|
|
127
|
-
* @param {Object} store - The store for drawing.
|
|
128
|
-
* @param {Object} params - The parameters for drawing.
|
|
129
|
-
*/
|
|
130
|
-
beforeDraw(context, store, params) {
|
|
131
|
-
var _a, _b;
|
|
132
|
-
this.iterate = this.querySelector("[iterate]");
|
|
133
|
-
this.infiniteScrollTemplate = (_a = this.iterate) == null ? void 0 : _a.outerHTML;
|
|
134
|
-
(_b = this.iterate) == null ? void 0 : _b.remove();
|
|
135
|
-
this.setAttribute("style", "height: " + this.height);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Draws the component.
|
|
139
|
-
*
|
|
140
|
-
* @param {Object} context - The context for drawing.
|
|
141
|
-
* @param {Object} store - The store for drawing.
|
|
142
|
-
* @param {Object} params - The parameters for drawing.
|
|
143
|
-
* @returns {DocumentFragment}
|
|
144
|
-
*/
|
|
145
|
-
draw(context, store, params) {
|
|
146
|
-
let fragment = document.createDocumentFragment();
|
|
147
|
-
let native = document.createElement("div");
|
|
148
|
-
native.classList.add("native");
|
|
149
|
-
native.setAttribute("part", "native-infinite-scroll");
|
|
150
|
-
let slot = document.createElement("slot");
|
|
151
|
-
let ending = document.createElement("slot");
|
|
152
|
-
ending.setAttribute("name", "ending");
|
|
153
|
-
if (WjElementUtils.hasSlot(this, "loader")) {
|
|
154
|
-
let loading = document.createElement("div");
|
|
155
|
-
loading.classList.add("loading");
|
|
156
|
-
let loader = document.createElement("slot");
|
|
157
|
-
loader.setAttribute("name", "loader");
|
|
158
|
-
loading.appendChild(loader);
|
|
159
|
-
this.loadingEl = loading;
|
|
160
|
-
fragment.appendChild(loading);
|
|
161
|
-
}
|
|
162
|
-
native.appendChild(slot);
|
|
163
|
-
native.appendChild(ending);
|
|
164
|
-
fragment.appendChild(native);
|
|
165
|
-
this.endingEl = ending;
|
|
166
|
-
return fragment;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Called after the component has been drawn.
|
|
170
|
-
*/
|
|
171
|
-
async afterDraw() {
|
|
172
|
-
this.queryParams = this.queryParams || "";
|
|
173
|
-
this.size = +this.size || 10;
|
|
174
|
-
this.currentPage = 0;
|
|
175
|
-
this.scrollEvent();
|
|
176
|
-
await this.loadPages(this.currentPage);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Fetches the pages from the server.
|
|
180
|
-
*
|
|
181
|
-
* @param {number} page - The page number.
|
|
182
|
-
* @returns {Promise<Object>} The response from the server.
|
|
183
|
-
*/
|
|
184
|
-
async getPages(page) {
|
|
185
|
-
let hasParams = this.url.includes("?");
|
|
186
|
-
const response = await fetch(`${this.url}${hasParams ? "&" : "?"}page=${page}&size=${this.size}${this == null ? void 0 : this.queryParams}`);
|
|
187
|
-
if (!response.ok) {
|
|
188
|
-
throw new Error(`An error occurred: ${response.status}`);
|
|
189
|
-
}
|
|
190
|
-
return await response.json();
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Hides the loader.
|
|
194
|
-
*/
|
|
195
|
-
hideLoader() {
|
|
196
|
-
var _a;
|
|
197
|
-
(_a = this == null ? void 0 : this.loadingEl) == null ? void 0 : _a.classList.remove("show");
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Shows the loader.
|
|
201
|
-
*/
|
|
202
|
-
showLoader() {
|
|
203
|
-
var _a;
|
|
204
|
-
(_a = this == null ? void 0 : this.loadingEl) == null ? void 0 : _a.classList.add("show");
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Checks if there are more pages to load.
|
|
208
|
-
*
|
|
209
|
-
* @param {number} page - The page number.
|
|
210
|
-
* @returns {boolean} Whether there are more pages to load.
|
|
211
|
-
*/
|
|
212
|
-
hasMorePages(page) {
|
|
213
|
-
return this.totalPages === 0 || page < this.totalPages;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Loads the pages.
|
|
217
|
-
*
|
|
218
|
-
* @param {number} page - The page number.
|
|
219
|
-
*/
|
|
220
|
-
async loadPages(page) {
|
|
221
|
-
this.showLoader();
|
|
222
|
-
try {
|
|
223
|
-
if (this.hasMorePages(page)) {
|
|
224
|
-
let response;
|
|
225
|
-
this.parser = new DOMParser();
|
|
226
|
-
if (typeof this.setCustomData === "function") {
|
|
227
|
-
response = await this.setCustomData(page);
|
|
228
|
-
} else {
|
|
229
|
-
response = await this.getPages(page);
|
|
230
|
-
}
|
|
231
|
-
this.totalPages = response.totalPages;
|
|
232
|
-
this.currentPage = page;
|
|
233
|
-
this.placementObj = this;
|
|
234
|
-
if (this.hasAttribute("placement"))
|
|
235
|
-
this.placementObj = this.querySelector(this.placement);
|
|
236
|
-
event.dispatchCustomEvent(this, "wje-infinite-scroll:load", response);
|
|
237
|
-
this.response = response;
|
|
238
|
-
this.customForeach(response[this.objectName]);
|
|
239
|
-
this.isLoading.push(page);
|
|
240
|
-
} else {
|
|
241
|
-
event.dispatchCustomEvent(this, "wje-infinite-scroll:complete");
|
|
242
|
-
this.endingEl.classList.add("show");
|
|
243
|
-
}
|
|
244
|
-
} catch (error) {
|
|
245
|
-
console.log(error.message);
|
|
246
|
-
} finally {
|
|
247
|
-
this.hideLoader();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
1
|
+
import { I as InfiniteScroll } from "./infinite-scroll.element-7dR-X4sd.js";
|
|
251
2
|
InfiniteScroll.define("wje-infinite-scroll", InfiniteScroll);
|
|
252
3
|
export {
|
|
253
4
|
InfiniteScroll as default
|
package/dist/wje-list.js
CHANGED
|
@@ -1,58 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import WJElement from "./wje-element.js";
|
|
8
|
-
const styles = "/*\n[ WJ List ]\n*/\n:host {\n margin: 0;\n padding: 0;\n display: block;\n contain: content;\n list-style-type: none;\n}\n\n:host(.wje-inset) {\n background: var(--wje-list-background);\n transform: translateZ(0);\n overflow: hidden;\n padding: var(--wje-list-inset-padding);\n border-radius: var(--wje-list-border-radius);\n}\n\n:host(.wje-lines-none) ::slotted(wje-item) {\n --wje-border-width: 0 !important;\n}";
|
|
9
|
-
class List extends WJElement {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of List.
|
|
12
|
-
*
|
|
13
|
-
* @constructor
|
|
14
|
-
*/
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
__publicField(this, "className", "List");
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Returns the CSS styles for the component.
|
|
21
|
-
*
|
|
22
|
-
* @static
|
|
23
|
-
* @returns {CSSStyleSheet}
|
|
24
|
-
*/
|
|
25
|
-
static get cssStyleSheet() {
|
|
26
|
-
return styles;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Sets up the attributes for the component.
|
|
30
|
-
*/
|
|
31
|
-
setupAttributes() {
|
|
32
|
-
this.isShadowRoot = "open";
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Draws the component.
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} context - The context for drawing.
|
|
38
|
-
* @param {Object} store - The store for drawing.
|
|
39
|
-
* @param {Object} params - The parameters for drawing.
|
|
40
|
-
* @returns {DocumentFragment}
|
|
41
|
-
*/
|
|
42
|
-
draw(context, store, params) {
|
|
43
|
-
let fragment = document.createDocumentFragment();
|
|
44
|
-
let element = document.createElement("slot");
|
|
45
|
-
fragment.appendChild(element);
|
|
46
|
-
return fragment;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Called after the component has been drawn.
|
|
50
|
-
*/
|
|
51
|
-
afterDraw() {
|
|
52
|
-
this.classList.toggle("wje-lines-" + this.lines, this.hasAttribute("lines"));
|
|
53
|
-
this.classList.toggle("wje-inset", this.hasAttribute("inset"));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { L as List } from "./list.element-BkOOqBtW.js";
|
|
56
2
|
List.define("wje-list", List);
|
|
57
3
|
export {
|
|
58
4
|
List as default
|
package/dist/wje-master.js
CHANGED
|
@@ -47,57 +47,59 @@ import { default as default35 } from "./wje-icon.js";
|
|
|
47
47
|
import { default as default36 } from "./wje-icon-picker.js";
|
|
48
48
|
import { default as default37 } from "./wje-img.js";
|
|
49
49
|
import { default as default38 } from "./wje-img-comparer.js";
|
|
50
|
-
import
|
|
51
|
-
import { default as
|
|
52
|
-
import { default as
|
|
53
|
-
import { default as
|
|
54
|
-
import { default as
|
|
55
|
-
import
|
|
56
|
-
import { default as
|
|
57
|
-
import { default as
|
|
58
|
-
import { default as
|
|
59
|
-
import { default as
|
|
60
|
-
import { default as
|
|
61
|
-
import { default as
|
|
62
|
-
import { default as
|
|
63
|
-
import { default as
|
|
64
|
-
import { default as
|
|
65
|
-
import { default as
|
|
66
|
-
import { default as
|
|
50
|
+
import "./wje-infinite-scroll.js";
|
|
51
|
+
import { default as default39 } from "./wje-input.js";
|
|
52
|
+
import { default as default40 } from "./wje-input-file.js";
|
|
53
|
+
import { default as default41 } from "./wje-item.js";
|
|
54
|
+
import { default as default42 } from "./wje-label.js";
|
|
55
|
+
import "./wje-list.js";
|
|
56
|
+
import { default as default43 } from "./wje-main.js";
|
|
57
|
+
import { default as default44 } from "./wje-masonry.js";
|
|
58
|
+
import { default as default45 } from "./wje-menu.js";
|
|
59
|
+
import { default as default46 } from "./wje-menu-button.js";
|
|
60
|
+
import { default as default47 } from "./wje-menu-item.js";
|
|
61
|
+
import { default as default48 } from "./wje-menu-label.js";
|
|
62
|
+
import { default as default49 } from "./wje-option.js";
|
|
63
|
+
import { default as default50 } from "./wje-options.js";
|
|
64
|
+
import { default as default51 } from "./wje-orgchart.js";
|
|
65
|
+
import { default as default52 } from "./wje-orgchart-group.js";
|
|
66
|
+
import { default as default53 } from "./wje-orgchart-item.js";
|
|
67
67
|
import "./wje-popup.js";
|
|
68
|
-
import { default as
|
|
69
|
-
import { default as
|
|
70
|
-
import { default as
|
|
71
|
-
import { default as
|
|
72
|
-
import { default as
|
|
73
|
-
import { default as
|
|
74
|
-
import { default as
|
|
75
|
-
import { default as
|
|
76
|
-
import { default as
|
|
77
|
-
import { default as
|
|
78
|
-
import { default as
|
|
79
|
-
import { default as
|
|
80
|
-
import { default as
|
|
81
|
-
import { default as
|
|
82
|
-
import { default as
|
|
83
|
-
import { default as
|
|
84
|
-
import { default as
|
|
85
|
-
import { default as
|
|
86
|
-
import { default as
|
|
87
|
-
import { default as
|
|
88
|
-
import { default as
|
|
89
|
-
import { default as
|
|
90
|
-
import { default as
|
|
91
|
-
import { default as
|
|
92
|
-
import { default as
|
|
93
|
-
import { default as
|
|
94
|
-
import { default as
|
|
95
|
-
import { default as
|
|
96
|
-
import { default as
|
|
97
|
-
import { default as
|
|
98
|
-
import { default as
|
|
99
|
-
import { default as
|
|
100
|
-
import { default as
|
|
68
|
+
import { default as default54 } from "./wje-progress-bar.js";
|
|
69
|
+
import { default as default55 } from "./wje-qr-code.js";
|
|
70
|
+
import { default as default56 } from "./wje-radio.js";
|
|
71
|
+
import { default as default57 } from "./wje-radio-group.js";
|
|
72
|
+
import { default as default58 } from "./wje-rate.js";
|
|
73
|
+
import { default as default59 } from "./wje-relative-time.js";
|
|
74
|
+
import { default as default60 } from "./wje-reorder.js";
|
|
75
|
+
import { default as default61 } from "./wje-reorder-dropzone.js";
|
|
76
|
+
import { default as default62 } from "./wje-reorder-handle.js";
|
|
77
|
+
import { default as default63 } from "./wje-reorder-item.js";
|
|
78
|
+
import { default as default64 } from "./wje-route.js";
|
|
79
|
+
import { default as default65 } from "./wje-routerx.js";
|
|
80
|
+
import { default as default66 } from "./wje-router-link.js";
|
|
81
|
+
import { default as default67 } from "./wje-router-outlet.js";
|
|
82
|
+
import { default as default68 } from "./wje-row.js";
|
|
83
|
+
import { default as default69 } from "./wje-select.js";
|
|
84
|
+
import { default as default70 } from "./wje-slider.js";
|
|
85
|
+
import { default as default71 } from "./wje-split-view.js";
|
|
86
|
+
import { default as default72 } from "./wje-status.js";
|
|
87
|
+
import { default as default73 } from "./wje-step.js";
|
|
88
|
+
import { default as default74 } from "./wje-stepper.js";
|
|
89
|
+
import { default as default75 } from "./wje-tab.js";
|
|
90
|
+
import { default as default76 } from "./wje-tab-group.js";
|
|
91
|
+
import { default as default77 } from "./wje-tab-panel.js";
|
|
92
|
+
import { default as default78 } from "./wje-textarea.js";
|
|
93
|
+
import { default as default79 } from "./wje-thumbnail.js";
|
|
94
|
+
import { default as default80 } from "./wje-toast.js";
|
|
95
|
+
import { default as default81 } from "./wje-toggle.js";
|
|
96
|
+
import { default as default82 } from "./wje-toolbar.js";
|
|
97
|
+
import { default as default83 } from "./wje-toolbar-action.js";
|
|
98
|
+
import { default as default84 } from "./wje-tooltip.js";
|
|
99
|
+
import { default as default85 } from "./wje-visually-hidden.js";
|
|
100
|
+
import { default as default86 } from "./wje-sliding-container.js";
|
|
101
|
+
import { L } from "./list.element-BkOOqBtW.js";
|
|
102
|
+
import { I } from "./infinite-scroll.element-7dR-X4sd.js";
|
|
101
103
|
import { P } from "./popup.element-Dna4OwCH.js";
|
|
102
104
|
function formatDate(input, format) {
|
|
103
105
|
let date;
|
|
@@ -314,60 +316,60 @@ export {
|
|
|
314
316
|
default36 as IconPicker,
|
|
315
317
|
default37 as Img,
|
|
316
318
|
default38 as ImgComparer,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
I as InfiniteScroll,
|
|
320
|
+
default39 as Input,
|
|
321
|
+
default40 as InputFile,
|
|
322
|
+
default41 as Item,
|
|
323
|
+
default42 as Label,
|
|
324
|
+
L as List,
|
|
323
325
|
Localizer,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
326
|
+
default43 as Main,
|
|
327
|
+
default44 as Masonry,
|
|
328
|
+
default45 as Menu,
|
|
329
|
+
default46 as MenuButton,
|
|
330
|
+
default47 as MenuItem,
|
|
331
|
+
default48 as MenuLabel,
|
|
332
|
+
default49 as Option,
|
|
333
|
+
default50 as Options,
|
|
334
|
+
default51 as Orgchart,
|
|
335
|
+
default52 as OrgchartGroup,
|
|
336
|
+
default53 as OrgchartItem,
|
|
335
337
|
P as Popup,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
338
|
+
default54 as ProgressBar,
|
|
339
|
+
default55 as QrCode,
|
|
340
|
+
default56 as Radio,
|
|
341
|
+
default57 as RadioGroup,
|
|
342
|
+
default58 as Rate,
|
|
343
|
+
default59 as RelativeTime,
|
|
344
|
+
default60 as Reorder,
|
|
345
|
+
default61 as ReorderDropzone,
|
|
346
|
+
default62 as ReorderHandle,
|
|
347
|
+
default63 as ReorderItem,
|
|
348
|
+
default64 as Route,
|
|
349
|
+
default66 as RouterLink,
|
|
350
|
+
default67 as RouterOutlet,
|
|
351
|
+
default65 as Routerx,
|
|
352
|
+
default68 as Row,
|
|
353
|
+
default69 as Select,
|
|
354
|
+
default70 as Slider,
|
|
355
|
+
default86 as SlidingContainer,
|
|
356
|
+
default71 as SplitView,
|
|
357
|
+
default72 as Status,
|
|
358
|
+
default73 as Step,
|
|
359
|
+
default74 as Stepper,
|
|
360
|
+
default75 as Tab,
|
|
361
|
+
default76 as TabGroup,
|
|
362
|
+
default77 as TabPanel,
|
|
363
|
+
default78 as Textarea,
|
|
364
|
+
default79 as Thumbnail,
|
|
363
365
|
Timeline,
|
|
364
366
|
TimelineItem,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
367
|
+
default80 as Toast,
|
|
368
|
+
default81 as Toggle,
|
|
369
|
+
default82 as Toolbar,
|
|
370
|
+
default83 as ToolbarAction,
|
|
371
|
+
default84 as Tooltip,
|
|
372
|
+
default85 as VisuallyHidden,
|
|
371
373
|
WJElement,
|
|
372
374
|
WjePermissionsApi,
|
|
373
375
|
b as bindRouterLinks,
|
package/dist/wje-options.js
CHANGED
|
@@ -5,6 +5,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import WJElement, { event } from "./wje-element.js";
|
|
8
|
+
import { I as InfiniteScroll } from "./infinite-scroll.element-7dR-X4sd.js";
|
|
9
|
+
import { L as List } from "./list.element-BkOOqBtW.js";
|
|
8
10
|
import Option from "./wje-option.js";
|
|
9
11
|
class Options extends WJElement {
|
|
10
12
|
/**
|
|
@@ -15,9 +17,23 @@ class Options extends WJElement {
|
|
|
15
17
|
constructor() {
|
|
16
18
|
super();
|
|
17
19
|
__publicField(this, "dependencies", {
|
|
18
|
-
"wje-option": Option
|
|
20
|
+
"wje-option": Option,
|
|
21
|
+
"wje-infinite-scroll": InfiniteScroll,
|
|
22
|
+
"wje-list": List
|
|
19
23
|
});
|
|
20
24
|
__publicField(this, "className", "Options");
|
|
25
|
+
/**
|
|
26
|
+
* Generates an HTML option element based on the provided item.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} item - The item to generate the option element for.
|
|
29
|
+
* @returns {HTMLElement} The generated option element.
|
|
30
|
+
*/
|
|
31
|
+
__publicField(this, "htmlItem", (item) => {
|
|
32
|
+
let option = document.createElement("wje-option");
|
|
33
|
+
option.setAttribute("value", item[this.itemValue] || item.value);
|
|
34
|
+
option.innerText = item[this.itemText] || item.text;
|
|
35
|
+
return option;
|
|
36
|
+
});
|
|
21
37
|
}
|
|
22
38
|
/**
|
|
23
39
|
* Returns the list of attributes to observe for changes.
|
|
@@ -26,7 +42,59 @@ class Options extends WJElement {
|
|
|
26
42
|
* @returns {Array<string>}
|
|
27
43
|
*/
|
|
28
44
|
static get observedAttributes() {
|
|
29
|
-
return [];
|
|
45
|
+
return ["search"];
|
|
46
|
+
}
|
|
47
|
+
set optionArrayPath(value) {
|
|
48
|
+
this.setAttribute("option-array-path", value);
|
|
49
|
+
}
|
|
50
|
+
get optionArrayPath() {
|
|
51
|
+
return this.getAttribute("option-array-path") ?? "data";
|
|
52
|
+
}
|
|
53
|
+
get hasOptionArrayPath() {
|
|
54
|
+
return this.hasAttribute("option-array-path");
|
|
55
|
+
}
|
|
56
|
+
set itemValue(value) {
|
|
57
|
+
this.setAttribute("item-value", value);
|
|
58
|
+
}
|
|
59
|
+
get itemValue() {
|
|
60
|
+
return this.getAttribute("item-value") || "value";
|
|
61
|
+
}
|
|
62
|
+
set itemText(value) {
|
|
63
|
+
this.setAttribute("item-text", value);
|
|
64
|
+
}
|
|
65
|
+
get itemText() {
|
|
66
|
+
return this.getAttribute("item-text") || "text";
|
|
67
|
+
}
|
|
68
|
+
get lazyLoadSize() {
|
|
69
|
+
return this.getAttribute("lazy-load-size") || 10;
|
|
70
|
+
}
|
|
71
|
+
set lazyLoadSize(value) {
|
|
72
|
+
this.setAttribute("lazy-load-size", value);
|
|
73
|
+
}
|
|
74
|
+
set search(value) {
|
|
75
|
+
this.setAttribute("search", value);
|
|
76
|
+
}
|
|
77
|
+
get search() {
|
|
78
|
+
return this.getAttribute("search");
|
|
79
|
+
}
|
|
80
|
+
get hasSearch() {
|
|
81
|
+
return this.hasAttribute("search");
|
|
82
|
+
}
|
|
83
|
+
get lazy() {
|
|
84
|
+
return this.hasAttribute("lazy");
|
|
85
|
+
}
|
|
86
|
+
set lazy(value) {
|
|
87
|
+
this.setAttribute("lazy", value);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Lifecycle method, called whenever an observed property changes
|
|
91
|
+
*/
|
|
92
|
+
attributeChangedCallback(name, old, newName) {
|
|
93
|
+
if (this.infiniteScroll) {
|
|
94
|
+
this.infiniteScroll.placementObj.innerHTML = "";
|
|
95
|
+
this.infiniteScroll.totalPages = 0;
|
|
96
|
+
this.infiniteScroll.refresh();
|
|
97
|
+
}
|
|
30
98
|
}
|
|
31
99
|
/**
|
|
32
100
|
* Sets up the attributes for the component.
|
|
@@ -39,16 +107,45 @@ class Options extends WJElement {
|
|
|
39
107
|
* Fetches the pages and creates the options elements.
|
|
40
108
|
*/
|
|
41
109
|
async beforeDraw() {
|
|
42
|
-
this
|
|
110
|
+
event.dispatchCustomEvent(this, "wje-options:load", {});
|
|
111
|
+
}
|
|
112
|
+
async draw() {
|
|
43
113
|
let fragment = document.createDocumentFragment();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
114
|
+
const slot = document.createElement("slot");
|
|
115
|
+
if (this.hasAttribute("lazy")) {
|
|
116
|
+
const list = document.createElement("wje-list");
|
|
117
|
+
const infiniteScroll = document.createElement("wje-infinite-scroll");
|
|
118
|
+
infiniteScroll.setAttribute("placement", "wje-list");
|
|
119
|
+
infiniteScroll.setAttribute("height", "100%");
|
|
120
|
+
infiniteScroll.append(list);
|
|
121
|
+
infiniteScroll.dataToHtml = this.htmlItem;
|
|
122
|
+
infiniteScroll.setCustomData = async (page, signal) => {
|
|
123
|
+
let res = await this.service.get(`${this.url}${this.search ? `/${this.search}` : ""}?page=${page}&size=${this.lazyLoadSize}`, null, false, signal);
|
|
124
|
+
return res;
|
|
125
|
+
};
|
|
126
|
+
this.contains(infiniteScroll) || this.appendChild(infiniteScroll);
|
|
127
|
+
this.infiniteScroll = infiniteScroll;
|
|
128
|
+
} else {
|
|
129
|
+
this.response = await this.getPages();
|
|
130
|
+
this.append(...this.processData(this.response).map(this.htmlItem));
|
|
131
|
+
}
|
|
132
|
+
fragment.appendChild(slot);
|
|
133
|
+
return fragment;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Processes the given data and returns the options based on the option array path.
|
|
137
|
+
*
|
|
138
|
+
* @param {any} data - The data to be processed.
|
|
139
|
+
* @returns {any} - The options based on the option array path.
|
|
140
|
+
*/
|
|
141
|
+
processData(data) {
|
|
142
|
+
var _a;
|
|
143
|
+
const splittedOptionArrayPath = (_a = this.optionArrayPath) == null ? void 0 : _a.split(".");
|
|
144
|
+
let options = data;
|
|
145
|
+
splittedOptionArrayPath == null ? void 0 : splittedOptionArrayPath.forEach((path) => {
|
|
146
|
+
options = options[path];
|
|
49
147
|
});
|
|
50
|
-
|
|
51
|
-
event.dispatchCustomEvent(this, "wje-options:load", {});
|
|
148
|
+
return options;
|
|
52
149
|
}
|
|
53
150
|
/**
|
|
54
151
|
* Fetches the pages from the provided URL.
|
package/dist/wje-select.js
CHANGED
|
@@ -359,13 +359,18 @@ class Select extends WJElement {
|
|
|
359
359
|
});
|
|
360
360
|
if (this.hasAttribute("find") && this.findEl instanceof HTMLElement) {
|
|
361
361
|
event.addListener(this.findEl, "keyup", "", (e) => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
362
|
+
const optionsElement = this.querySelector("wje-options");
|
|
363
|
+
if (optionsElement && optionsElement.hasAttribute("lazy")) {
|
|
364
|
+
optionsElement.setAttribute("search", e.target.value);
|
|
365
|
+
} else {
|
|
366
|
+
let value = e.target.value.trim().toLowerCase();
|
|
367
|
+
this.getAllOptions().forEach((option) => {
|
|
368
|
+
if (option.textContent.trim().toLowerCase().includes(value))
|
|
369
|
+
option.style.display = "block";
|
|
370
|
+
else
|
|
371
|
+
option.style.display = "none";
|
|
372
|
+
});
|
|
373
|
+
}
|
|
369
374
|
});
|
|
370
375
|
}
|
|
371
376
|
}
|
package/dist/wje-textarea.js
CHANGED
|
@@ -51,6 +51,12 @@ class Textarea extends WJElement {
|
|
|
51
51
|
static get observedAttributes() {
|
|
52
52
|
return [];
|
|
53
53
|
}
|
|
54
|
+
set placeholder(value) {
|
|
55
|
+
this.setAttribute("placeholder", value);
|
|
56
|
+
}
|
|
57
|
+
get placeholder() {
|
|
58
|
+
return this.getAttribute("placeholder");
|
|
59
|
+
}
|
|
54
60
|
/**
|
|
55
61
|
* Sets up the attributes for the component.
|
|
56
62
|
*/
|
|
@@ -84,6 +90,7 @@ class Textarea extends WJElement {
|
|
|
84
90
|
input.name = this.name;
|
|
85
91
|
input.disabled = this.hasAttribute("disabled");
|
|
86
92
|
input.innerText = this.innerHTML;
|
|
93
|
+
input.placeholder = this.placeholder || "";
|
|
87
94
|
input.classList.add("form-control");
|
|
88
95
|
input.setAttribute("part", "input");
|
|
89
96
|
input.setAttribute("rows", this.rows || 3);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wj-elements",
|
|
3
3
|
"description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.104",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|