wj-elements 0.1.128 → 0.1.129
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/dark.css +6 -1
- package/dist/{infinite-scroll.element-DcO1E5Es.js → infinite-scroll.element-R3y_ZQj6.js} +42 -14
- package/dist/light.css +5 -0
- package/dist/{list.element-TZXMx1rt.js → list.element-syl98NWS.js} +4 -1
- package/dist/localize.js +4 -3
- package/dist/{popup.element-l8v-dMoK.js → popup.element-C0a1z1y2.js} +191 -78
- package/dist/wje-accordion-item.js +1 -1
- package/dist/wje-animation.js +141 -13
- package/dist/wje-aside.js +1 -1
- package/dist/wje-avatar.js +5 -5
- package/dist/wje-badge.js +1 -1
- package/dist/wje-breadcrumb.js +16 -6
- package/dist/wje-breadcrumbs.js +4 -4
- package/dist/wje-button-group.js +2 -2
- package/dist/wje-button.js +64 -6
- package/dist/wje-card-content.js +1 -1
- package/dist/wje-card-controls.js +1 -1
- package/dist/wje-card-header.js +1 -1
- package/dist/wje-card-subtitle.js +1 -1
- package/dist/wje-card-title.js +1 -1
- package/dist/wje-carousel-item.js +1 -1
- package/dist/wje-carousel.js +1 -1
- package/dist/wje-checkbox.js +14 -11
- package/dist/wje-chip.js +1 -1
- package/dist/wje-col.js +9 -3
- package/dist/wje-color-picker.js +72 -42
- package/dist/wje-container.js +1 -1
- package/dist/wje-copy-button.js +3 -3
- package/dist/wje-dialog.js +89 -0
- package/dist/wje-divider.js +1 -1
- package/dist/wje-dropdown.js +21 -6
- package/dist/wje-element.js +284 -127
- package/dist/wje-fetchAndParseCSS.js +2 -1
- package/dist/wje-file-upload-item.js +5 -2
- package/dist/wje-file-upload.js +57 -13
- package/dist/wje-footer.js +1 -1
- package/dist/wje-form.js +1 -1
- package/dist/wje-format-digital.js +1 -1
- package/dist/wje-grid.js +1 -1
- package/dist/wje-header.js +1 -1
- package/dist/wje-icon-picker.js +6 -3
- package/dist/wje-icon.js +4 -1
- package/dist/wje-img-comparer.js +1 -3
- package/dist/wje-img.js +5 -2
- package/dist/wje-infinite-scroll.js +1 -1
- package/dist/wje-input-file.js +4 -1
- package/dist/wje-input.js +9 -4
- package/dist/wje-item.js +34 -3
- package/dist/wje-kanban.js +16 -31
- package/dist/wje-label.js +1 -10
- package/dist/wje-list.js +1 -1
- package/dist/wje-main.js +1 -1
- package/dist/wje-masonry.js +9 -9
- package/dist/wje-master.js +9 -117
- package/dist/wje-menu-button.js +4 -1
- package/dist/wje-menu-item.js +13 -4
- package/dist/wje-menu-label.js +1 -1
- package/dist/wje-menu.js +4 -1
- package/dist/wje-option.js +8 -4
- package/dist/wje-options.js +25 -11
- package/dist/wje-orgchart-group.js +2 -2
- package/dist/wje-orgchart-item.js +7 -4
- package/dist/wje-orgchart.js +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +6 -2
- package/dist/wje-qr-code.js +2 -2
- package/dist/wje-radio-group.js +4 -1
- package/dist/wje-radio.js +1 -1
- package/dist/wje-rate.js +6 -3
- package/dist/wje-relative-time.js +37 -19
- package/dist/wje-reorder.js +73 -10
- package/dist/wje-route.js +1 -1
- package/dist/wje-router-link.js +1 -2
- package/dist/wje-routerx.js +3 -1
- package/dist/wje-row.js +1 -11
- package/dist/wje-select.js +15 -12
- package/dist/wje-slider.js +7 -4
- package/dist/wje-sliding-container.js +125 -49
- package/dist/wje-split-view.js +10 -2
- package/dist/wje-status.js +1 -1
- package/dist/wje-stepper.js +879 -766
- package/dist/wje-store.js +17 -18
- package/dist/wje-tab-group.js +4 -1
- package/dist/wje-tab-panel.js +1 -1
- package/dist/wje-tab.js +4 -1
- package/dist/wje-textarea.js +8 -2
- package/dist/wje-thumbnail.js +1 -9
- package/dist/wje-toast.js +24 -23
- package/dist/wje-toggle.js +7 -1
- package/dist/wje-toolbar-action.js +1 -1
- package/dist/wje-toolbar.js +1 -1
- package/dist/wje-tooltip.js +5 -1
- package/dist/wje-visually-hidden.js +1 -1
- package/package.json +16 -5
package/dist/wje-rate.js
CHANGED
|
@@ -39,8 +39,8 @@ class Rate extends WJElement {
|
|
|
39
39
|
*/
|
|
40
40
|
__publicField(this, "onMouseMove", (e) => {
|
|
41
41
|
e.preventDefault();
|
|
42
|
-
let newValue = this.getValueFromXPosition(e.clientX);
|
|
43
|
-
if (newValue
|
|
42
|
+
let newValue = +this.getValueFromXPosition(e.clientX);
|
|
43
|
+
if (newValue !== +this.hoverValue) {
|
|
44
44
|
this.hoverValue = newValue;
|
|
45
45
|
this.changeRate();
|
|
46
46
|
}
|
|
@@ -190,7 +190,7 @@ class Rate extends WJElement {
|
|
|
190
190
|
* @param {Object} params - The parameters for drawing.
|
|
191
191
|
* @returns {DocumentFragment}
|
|
192
192
|
*/
|
|
193
|
-
draw(
|
|
193
|
+
draw() {
|
|
194
194
|
let fragment = document.createDocumentFragment();
|
|
195
195
|
let native = document.createElement("div");
|
|
196
196
|
native.setAttribute("part", "native");
|
|
@@ -212,6 +212,9 @@ class Rate extends WJElement {
|
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Adds event listeners after the component is drawn.
|
|
215
|
+
* @params {Object} context - The context for drawing.
|
|
216
|
+
* @params {Object} store - The store for drawing.
|
|
217
|
+
* @params {Object} params - The parameters for drawing.
|
|
215
218
|
*/
|
|
216
219
|
afterDraw() {
|
|
217
220
|
if (this.hasAttribute("disabled") || this.hasAttribute("readonly")) {
|
|
@@ -15,22 +15,38 @@ class RelativeTime extends WJElement {
|
|
|
15
15
|
this.localizer = new Localizer(this);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
18
|
+
* Sets the date of the relative time component
|
|
19
|
+
* @param value
|
|
20
|
+
*/
|
|
21
|
+
set date(value) {
|
|
22
|
+
this.setAttribute("date", value);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the date of the relative time component
|
|
26
|
+
* @returns {string}
|
|
21
27
|
*/
|
|
22
|
-
get
|
|
28
|
+
get date() {
|
|
29
|
+
return this.getAttribute("date");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sets the object date of the relative time component
|
|
33
|
+
* @param value
|
|
34
|
+
*/
|
|
35
|
+
set objectDate(value) {
|
|
36
|
+
this.setAttribute("object-date", value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the object date of the relative time component
|
|
40
|
+
* @returns {Date}
|
|
41
|
+
*/
|
|
42
|
+
get objectDate() {
|
|
23
43
|
let date = /* @__PURE__ */ new Date();
|
|
24
|
-
let inputDate = this.
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
inputDate = inputDate;
|
|
28
|
-
} else {
|
|
29
|
-
inputDate = +inputDate * 1e3;
|
|
30
|
-
}
|
|
44
|
+
let inputDate = this.date;
|
|
45
|
+
if (!!inputDate && inputDate !== "") {
|
|
46
|
+
inputDate = this.isISODate(inputDate) ? inputDate : +inputDate * 1e3;
|
|
31
47
|
date = new Date(inputDate);
|
|
32
48
|
}
|
|
33
|
-
return date
|
|
49
|
+
return date;
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
36
52
|
* Returns the list of attributes to observe for changes.
|
|
@@ -39,7 +55,7 @@ class RelativeTime extends WJElement {
|
|
|
39
55
|
* @returns {Array<string>}
|
|
40
56
|
*/
|
|
41
57
|
static get observedAttributes() {
|
|
42
|
-
return [
|
|
58
|
+
return [];
|
|
43
59
|
}
|
|
44
60
|
/**
|
|
45
61
|
* Sets up the attributes for the component.
|
|
@@ -55,12 +71,12 @@ class RelativeTime extends WJElement {
|
|
|
55
71
|
* @param {Object} params - The parameters for drawing.
|
|
56
72
|
* @returns {DocumentFragment}
|
|
57
73
|
*/
|
|
58
|
-
draw(
|
|
74
|
+
draw() {
|
|
59
75
|
let fragment = document.createDocumentFragment();
|
|
60
76
|
let element = document.createElement("div");
|
|
61
77
|
element.setAttribute("part", "native");
|
|
62
78
|
element.classList.add("native-relative-time");
|
|
63
|
-
element.innerText = this.getRelativeTimeString(
|
|
79
|
+
element.innerText = this.getRelativeTimeString();
|
|
64
80
|
fragment.appendChild(element);
|
|
65
81
|
return fragment;
|
|
66
82
|
}
|
|
@@ -71,9 +87,11 @@ class RelativeTime extends WJElement {
|
|
|
71
87
|
* @param {string} lang - The language.
|
|
72
88
|
* @returns {string} The relative time string.
|
|
73
89
|
*/
|
|
74
|
-
getRelativeTimeString(
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
getRelativeTimeString(lang = navigator.language) {
|
|
91
|
+
if (this.objectDate.toString() === "Invalid Date" || this.objectDate.toString() === "NaN") {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
const timeMs = this.objectDate.getTime();
|
|
77
95
|
const deltaSeconds = Math.round((timeMs - Date.now()) / 1e3);
|
|
78
96
|
const cutoffs = [
|
|
79
97
|
60,
|
|
@@ -87,7 +105,7 @@ class RelativeTime extends WJElement {
|
|
|
87
105
|
const units = ["second", "minute", "hour", "day", "week", "month", "year"];
|
|
88
106
|
const unitIndex = cutoffs.findIndex((cutoff) => cutoff > Math.abs(deltaSeconds));
|
|
89
107
|
const divisor = unitIndex ? cutoffs[unitIndex - 1] : 1;
|
|
90
|
-
return this.localizer.relativeTime(Math.floor(deltaSeconds / divisor), units[unitIndex], { numeric: "auto" });
|
|
108
|
+
return this.localizer.relativeTime(this.getAttribute("lang"), Math.floor(deltaSeconds / divisor), units[unitIndex], { numeric: "auto" });
|
|
91
109
|
}
|
|
92
110
|
/**
|
|
93
111
|
* Checks if the given string is an ISO date.
|
package/dist/wje-reorder.js
CHANGED
|
@@ -44,7 +44,14 @@ class Reorder extends WJElement {
|
|
|
44
44
|
setupAttributes() {
|
|
45
45
|
this.isShadowRoot = "open";
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Draws the component.
|
|
49
|
+
* @param {Object} context - The context for drawing.
|
|
50
|
+
* @param {Object} store - The store for drawing.
|
|
51
|
+
* @param {Object} params - The parameters for drawing.
|
|
52
|
+
* @returns {DocumentFragment}
|
|
53
|
+
*/
|
|
54
|
+
draw() {
|
|
48
55
|
const fragment = document.createDocumentFragment();
|
|
49
56
|
const container = document.createElement("div");
|
|
50
57
|
container.classList.add("container");
|
|
@@ -56,7 +63,13 @@ class Reorder extends WJElement {
|
|
|
56
63
|
this.container = container;
|
|
57
64
|
return fragment;
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Adds event listeners after the component is drawn.
|
|
68
|
+
* @param context
|
|
69
|
+
* @param store
|
|
70
|
+
* @param params
|
|
71
|
+
*/
|
|
72
|
+
afterDraw() {
|
|
60
73
|
const items = this.querySelectorAll("wje-reorder-item");
|
|
61
74
|
const dropZones = this.querySelectorAll("wje-reorder-dropzone");
|
|
62
75
|
this.container.classList.add(this.hasAttribute("reverse") ? "reversed" : "basic");
|
|
@@ -76,19 +89,29 @@ class Reorder extends WJElement {
|
|
|
76
89
|
});
|
|
77
90
|
}
|
|
78
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Attaches event listeners to the element.
|
|
94
|
+
* @param element
|
|
95
|
+
*/
|
|
79
96
|
attachEventListeners(element) {
|
|
80
97
|
element.addEventListener("mousedown", this.onMouseDown.bind(this), false);
|
|
81
98
|
element.addEventListener("touchstart", this.onTouchStart.bind(this), false);
|
|
82
99
|
element.addEventListener("dragstart", this.onDragStart.bind(this), false);
|
|
83
100
|
}
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Handles the mouse down event.
|
|
103
|
+
* @param e
|
|
104
|
+
*/
|
|
86
105
|
onMouseDown(e) {
|
|
87
106
|
this.startDragging(e.clientX, e.clientY, e.currentTarget);
|
|
88
107
|
document.addEventListener("mousemove", this.onMouseMove.bind(this), false);
|
|
89
108
|
document.addEventListener("mouseup", this.onMouseUp.bind(this), false);
|
|
90
109
|
document.body.style.userSelect = "none";
|
|
91
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Handles the touch start event.
|
|
113
|
+
* @param e
|
|
114
|
+
*/
|
|
92
115
|
onTouchStart(e) {
|
|
93
116
|
const touch = e.touches[0];
|
|
94
117
|
this.startDragging(touch.clientX, touch.clientY, e.currentTarget);
|
|
@@ -96,6 +119,12 @@ class Reorder extends WJElement {
|
|
|
96
119
|
document.addEventListener("touchend", this.onTouchEnd.bind(this), false);
|
|
97
120
|
document.body.style.userSelect = "none";
|
|
98
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Starts dragging the element.
|
|
124
|
+
* @param clientX
|
|
125
|
+
* @param clientY
|
|
126
|
+
* @param target
|
|
127
|
+
*/
|
|
99
128
|
startDragging(clientX, clientY, target) {
|
|
100
129
|
if (this.hasAttribute("disabled")) {
|
|
101
130
|
return;
|
|
@@ -111,8 +140,10 @@ class Reorder extends WJElement {
|
|
|
111
140
|
this.originalIndex = [...this.dragEl.parentNode.children].indexOf(this.dragEl);
|
|
112
141
|
this.originalParent = this.dragEl.parentNode;
|
|
113
142
|
}
|
|
114
|
-
|
|
115
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Handles the mouse move event.
|
|
145
|
+
* @param e
|
|
146
|
+
*/
|
|
116
147
|
onMouseMove(e) {
|
|
117
148
|
if (!this.isDragging) return;
|
|
118
149
|
this.moveElement(e.pageX, e.pageY);
|
|
@@ -121,11 +152,20 @@ class Reorder extends WJElement {
|
|
|
121
152
|
this.cloneEl.style.top = `${e.pageY - this.offsetY}px`;
|
|
122
153
|
}
|
|
123
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Handles the touch move event.
|
|
157
|
+
* @param e
|
|
158
|
+
*/
|
|
124
159
|
onTouchMove(e) {
|
|
125
160
|
if (!this.isDragging) return;
|
|
126
161
|
const touch = e.touches[0];
|
|
127
162
|
this.moveElement(touch.pageX, touch.pageY);
|
|
128
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Moves the element.
|
|
166
|
+
* @param pageX
|
|
167
|
+
* @param pageY
|
|
168
|
+
*/
|
|
129
169
|
moveElement(pageX, pageY) {
|
|
130
170
|
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
131
171
|
const scrollY = window.scrollY || document.documentElement.scrollTop;
|
|
@@ -150,8 +190,9 @@ class Reorder extends WJElement {
|
|
|
150
190
|
}
|
|
151
191
|
});
|
|
152
192
|
}
|
|
153
|
-
|
|
154
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Handles the mouse up event.
|
|
195
|
+
*/
|
|
155
196
|
onMouseUp() {
|
|
156
197
|
this.stopDragging();
|
|
157
198
|
document.removeEventListener("mousemove", this.onMouseMove.bind(this), false);
|
|
@@ -164,11 +205,17 @@ class Reorder extends WJElement {
|
|
|
164
205
|
this.dragEl.style.opacity = "1";
|
|
165
206
|
}
|
|
166
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Handles the touch end event.
|
|
210
|
+
*/
|
|
167
211
|
onTouchEnd() {
|
|
168
212
|
this.stopDragging();
|
|
169
213
|
document.removeEventListener("touchmove", this.onTouchMove.bind(this), false);
|
|
170
214
|
document.removeEventListener("touchend", this.onTouchEnd.bind(this), false);
|
|
171
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Stops dragging the element.
|
|
218
|
+
*/
|
|
172
219
|
stopDragging() {
|
|
173
220
|
if (!this.isDragging) return;
|
|
174
221
|
this.isDragging = false;
|
|
@@ -188,11 +235,16 @@ class Reorder extends WJElement {
|
|
|
188
235
|
this.dispatchChange(this.originalIndex, newIndex, newOrder);
|
|
189
236
|
document.body.style.userSelect = "";
|
|
190
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Handles the drag start event.
|
|
240
|
+
* @param e
|
|
241
|
+
*/
|
|
191
242
|
onDragStart(e) {
|
|
192
243
|
e.preventDefault();
|
|
193
244
|
}
|
|
194
|
-
|
|
195
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Creates a clone of the element.
|
|
247
|
+
*/
|
|
196
248
|
createClone() {
|
|
197
249
|
this.cloneEl = this.dragEl.cloneNode(true);
|
|
198
250
|
this.cloneEl.style.position = "absolute";
|
|
@@ -200,12 +252,23 @@ class Reorder extends WJElement {
|
|
|
200
252
|
this.cloneEl.style.visibility = "visible";
|
|
201
253
|
document.body.appendChild(this.cloneEl);
|
|
202
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Checks if the dragged element is moving down.
|
|
257
|
+
* @param droppedElement
|
|
258
|
+
* @returns {boolean}
|
|
259
|
+
*/
|
|
203
260
|
isMovingDown(droppedElement) {
|
|
204
261
|
const parent = droppedElement.parentNode;
|
|
205
262
|
const dragIndex = Array.from(parent.children).indexOf(this.dragEl);
|
|
206
263
|
const dropIndex = Array.from(parent.children).indexOf(droppedElement);
|
|
207
264
|
return dragIndex < dropIndex;
|
|
208
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Dispatches the change event.
|
|
268
|
+
* @param from
|
|
269
|
+
* @param to
|
|
270
|
+
* @param order
|
|
271
|
+
*/
|
|
209
272
|
dispatchChange(from, to, order) {
|
|
210
273
|
console.log("FROM:", from);
|
|
211
274
|
console.log("TO:", to);
|
package/dist/wje-route.js
CHANGED
|
@@ -35,7 +35,7 @@ class Route extends WJElement {
|
|
|
35
35
|
* @param {Object} params - The parameters for drawing.
|
|
36
36
|
* @returns {DocumentFragment}
|
|
37
37
|
*/
|
|
38
|
-
draw(
|
|
38
|
+
draw() {
|
|
39
39
|
let fragment = document.createDocumentFragment();
|
|
40
40
|
let slot = document.createElement("slot");
|
|
41
41
|
fragment.appendChild(slot);
|
package/dist/wje-router-link.js
CHANGED
|
@@ -42,13 +42,12 @@ class RouterLink extends WJElement {
|
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Draws the component.
|
|
45
|
-
*
|
|
46
45
|
* @param {Object} context - The context for drawing.
|
|
47
46
|
* @param {Object} store - The store for drawing.
|
|
48
47
|
* @param {Object} params - The parameters for drawing.
|
|
49
48
|
* @returns {DocumentFragment}
|
|
50
49
|
*/
|
|
51
|
-
draw(
|
|
50
|
+
draw() {
|
|
52
51
|
let fragment = document.createDocumentFragment();
|
|
53
52
|
let element = document.createElement("slot");
|
|
54
53
|
fragment.appendChild(element);
|
package/dist/wje-routerx.js
CHANGED
|
@@ -1424,7 +1424,6 @@ class Routerx extends WJElement {
|
|
|
1424
1424
|
__publicField(this, "className", "Routerx");
|
|
1425
1425
|
/**
|
|
1426
1426
|
* Sets the breadcrumb for the transition.
|
|
1427
|
-
*
|
|
1428
1427
|
* @param {Object} transition - The transition.
|
|
1429
1428
|
*/
|
|
1430
1429
|
__publicField(this, "setBreadcrumb", (transition2) => {
|
|
@@ -1467,6 +1466,9 @@ class Routerx extends WJElement {
|
|
|
1467
1466
|
}
|
|
1468
1467
|
/**
|
|
1469
1468
|
* Sets up the router after the component is drawn.
|
|
1469
|
+
* @params {Object} context - The context for drawing.
|
|
1470
|
+
* @params {Object} store - The store for drawing.
|
|
1471
|
+
* @params {Object} params - The parameters for drawing.
|
|
1470
1472
|
*/
|
|
1471
1473
|
afterDraw() {
|
|
1472
1474
|
const htmlString = this.outerHTML;
|
package/dist/wje-row.js
CHANGED
|
@@ -28,24 +28,14 @@ class Row extends WJElement {
|
|
|
28
28
|
setupAttributes() {
|
|
29
29
|
this.isShadowRoot = "open";
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Executes before the component is drawn.
|
|
33
|
-
*
|
|
34
|
-
* @param {Object} context - The context for drawing.
|
|
35
|
-
* @param {Object} store - The store for drawing.
|
|
36
|
-
* @param {Object} params - The parameters for drawing.
|
|
37
|
-
*/
|
|
38
|
-
beforeDraw(context, store, params) {
|
|
39
|
-
}
|
|
40
31
|
/**
|
|
41
32
|
* Draws the component.
|
|
42
|
-
*
|
|
43
33
|
* @param {Object} context - The context for drawing.
|
|
44
34
|
* @param {Object} store - The store for drawing.
|
|
45
35
|
* @param {Object} params - The parameters for drawing.
|
|
46
36
|
* @returns {DocumentFragment}
|
|
47
37
|
*/
|
|
48
|
-
draw(
|
|
38
|
+
draw() {
|
|
49
39
|
let fragment = document.createDocumentFragment();
|
|
50
40
|
if (this.hasAttribute("wrap"))
|
|
51
41
|
this.classList.add("wje-wrap");
|
package/dist/wje-select.js
CHANGED
|
@@ -10,7 +10,7 @@ import Chip from "./wje-chip.js";
|
|
|
10
10
|
import Input from "./wje-input.js";
|
|
11
11
|
import Option from "./wje-option.js";
|
|
12
12
|
import Options from "./wje-options.js";
|
|
13
|
-
import { P as Popup } from "./popup.element-
|
|
13
|
+
import { P as Popup } from "./popup.element-C0a1z1y2.js";
|
|
14
14
|
const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n --wje-select-border-width: 1px;\n --wje-select-border-style: solid;\n --wje-select-border-color: var(--wje-border-color);\n\n --wje-select-options-border-width: 1px;\n --wje-select-options-border-style: var(--wje-border-style);\n --wje-select-options-border-color: var(--wje-border-color);\n\n --wje-select-background: var(--wje-background);\n --wje-select-line-height: 20px;\n --wje-select-color: var(--wje-color);\n --wje-select-border-radius: var(--wje-border-radius-medium);\n\n --wje-select-margin-bottom: .5rem;\n margin-bottom: var(--wje-select-margin-bottom);\n\n width: 100%;\n display: block;\n [slot=arrow] {\n transform: rotate(0deg);\n transition: all .2s ease-in;\n }\n}\n\n.native-select {\n &.default{\n .wrapper {\n display: block;\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n padding-inline: .5rem;\n padding-top: 0.125rem;\n padding-bottom: 0.125rem;\n }\n .input-wrapper {\n padding: 0;\n min-height: 28px;\n margin-top: -4px;\n }\n &.focused {\n wje-label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n wje-label {\n margin: 0;\n display: block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease 0s;\n line-height: var(--wje-select-line-height);\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n }\n .input-wrapper {\n background: transparent;\n width: 100%;\n }\n }\n}\n\n.wrapper {\n display: flex;\n width: 100%;\n}\n\n.input-wrapper {\n display: grid;\n grid-template-columns: auto 1fr auto auto auto;\n align-items: center;\n background-color: var(--wje-select-background);\n min-height: 28px;\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n appearance: none;\n padding: 2px .5rem;\n font-size: 14px !important;\n font-weight: normal;\n vertical-align: middle;\n}\n\ninput {\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: .01em;\n border: medium;\n height: 25px;\n min-height: 25px;\n padding: 0;\n background: none;\n box-shadow: none;\n width: 100%;\n outline: 0;\n font-size: 14px !important;\n}\n\n::placeholder {\n opacity: 1;\n}\n\n:host [active] {\n .wrapper {\n border-radius: var(--wje-select-border-radius) var(--wje-select-border-radius) 0 0;\n }\n [slot=arrow] {\n transform: rotate(180deg);\n transition: all .2s ease-in;\n }\n}\n\n.options-wrapper {\n border-width: var(--wje-select-options-border-width);\n border-style: var(--wje-select-options-border-style);\n border-color: var(--wje-select-options-border-color);\n border-radius: 0 0 var(--wje-select-border-radius) var(--wje-select-border-radius);\n margin-top: calc(0px - var(--wje-select-border-width));\n background: var(--wje-select-background);\n overflow: hidden;\n\n}\n\n.find {\n --wje-input-border-radius: 0;\n --wje-input-border-width: 0 0 1px 0;\n}\n\n.list {\n overflow: auto;\n height: 100%;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - .5rem);\n}\n\n:host([multiple]) input {\n position: absolute;\n z-index: -1;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n opacity: 0;\n}\n\n:host([multiple]) .chips {\n display: flex;\n flex: 1;\n align-items: center;\n flex-wrap: wrap;\n}\n\n:host([disabled]) .input-wrapper{\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n.counter {\n padding-inline: .5rem;\n}\n\nwje-chip {\n --wje-chip-margin: 0 .25rem 0 0;\n}\n\nwje-button {\n --wje-padding-top: .25rem;\n --wje-padding-start: .25rem;\n --wje-padding-end: .25rem;\n --wje-padding-bottom: .25rem;\n --wje-button-margin-inline: 0 .25rem;\n}\n\n.slot-start, .slot-end {\n &:not(:empty) {\n margin-right: .5rem;\n }\n}\n";
|
|
15
15
|
class Select extends WJElement {
|
|
16
16
|
/**
|
|
@@ -108,7 +108,10 @@ class Select extends WJElement {
|
|
|
108
108
|
* @param {boolean} isInvalid - Whether the input is invalid.
|
|
109
109
|
*/
|
|
110
110
|
set invalid(isInvalid) {
|
|
111
|
-
|
|
111
|
+
if (isInvalid)
|
|
112
|
+
this.setAttribute("invalid", "");
|
|
113
|
+
else
|
|
114
|
+
this.removeAttribute("invalid");
|
|
112
115
|
}
|
|
113
116
|
/**
|
|
114
117
|
* Getter for the form attribute.
|
|
@@ -235,7 +238,7 @@ class Select extends WJElement {
|
|
|
235
238
|
* @param {Object} params - The parameters for drawing.
|
|
236
239
|
* @returns {DocumentFragment}
|
|
237
240
|
*/
|
|
238
|
-
draw(
|
|
241
|
+
draw() {
|
|
239
242
|
let fragment = document.createDocumentFragment();
|
|
240
243
|
this.classList.add("wje-placement", "wje-" + this.placement || "wje-start");
|
|
241
244
|
let native = document.createElement("div");
|
|
@@ -329,12 +332,11 @@ class Select extends WJElement {
|
|
|
329
332
|
}
|
|
330
333
|
/**
|
|
331
334
|
* Sets up the event listeners after the component is drawn.
|
|
332
|
-
*
|
|
333
335
|
* @param {Object} context - The context for drawing.
|
|
334
336
|
* @param {Object} store - The store for drawing.
|
|
335
337
|
* @param {Object} params - The parameters for drawing.
|
|
336
338
|
*/
|
|
337
|
-
afterDraw(
|
|
339
|
+
afterDraw() {
|
|
338
340
|
this.input.addEventListener("focus", (e) => {
|
|
339
341
|
this.labelElement.classList.add("fade");
|
|
340
342
|
this.native.classList.add("focused");
|
|
@@ -396,13 +398,13 @@ class Select extends WJElement {
|
|
|
396
398
|
* @param {Element} option - The option to get.
|
|
397
399
|
* @returns {Array} The selected options.
|
|
398
400
|
*/
|
|
399
|
-
getSelected(
|
|
401
|
+
getSelected() {
|
|
400
402
|
let selectedOptions = this.getSelectedOptions();
|
|
401
403
|
selectedOptions = Array.isArray(selectedOptions) ? selectedOptions : Array.from(selectedOptions);
|
|
402
|
-
selectedOptions = selectedOptions.map((
|
|
404
|
+
selectedOptions = selectedOptions.map((option) => {
|
|
403
405
|
return {
|
|
404
|
-
value:
|
|
405
|
-
text:
|
|
406
|
+
value: option.value,
|
|
407
|
+
text: option.textContent.trim()
|
|
406
408
|
};
|
|
407
409
|
});
|
|
408
410
|
return selectedOptions;
|
|
@@ -424,7 +426,7 @@ class Select extends WJElement {
|
|
|
424
426
|
if (this.counterEl instanceof HTMLElement || length > +this.maxOptions) {
|
|
425
427
|
this.counter();
|
|
426
428
|
} else {
|
|
427
|
-
if (option
|
|
429
|
+
if (option !== null)
|
|
428
430
|
this.chips.appendChild(this.getChip(option));
|
|
429
431
|
}
|
|
430
432
|
}
|
|
@@ -509,10 +511,10 @@ class Select extends WJElement {
|
|
|
509
511
|
*/
|
|
510
512
|
htmlOption(item, map = { value: "value", text: "text" }) {
|
|
511
513
|
let option = document.createElement("wje-option");
|
|
512
|
-
if (item[map.value]
|
|
514
|
+
if (item[map.value] === null) {
|
|
513
515
|
console.warn(`The item ${JSON.stringify(item)} does not have the property ${map.value}`);
|
|
514
516
|
}
|
|
515
|
-
if (item[map.text]
|
|
517
|
+
if (item[map.text] === null) {
|
|
516
518
|
console.warn(`The item ${JSON.stringify(item)} does not have the property ${map.text}`);
|
|
517
519
|
}
|
|
518
520
|
option.setAttribute("value", item[map.value] ?? "");
|
|
@@ -569,6 +571,7 @@ class Select extends WJElement {
|
|
|
569
571
|
if (option) {
|
|
570
572
|
option.selected = true;
|
|
571
573
|
}
|
|
574
|
+
this.selections(silent);
|
|
572
575
|
}
|
|
573
576
|
/**
|
|
574
577
|
* Selects one or multiple options in the select element.
|
package/dist/wje-slider.js
CHANGED
|
@@ -16,13 +16,13 @@ class Slider extends WJElement {
|
|
|
16
16
|
* Sets the handle position of the slider.
|
|
17
17
|
*/
|
|
18
18
|
__publicField(this, "setHandlePosition", () => {
|
|
19
|
-
this.input.style.backgroundSize = this.getPercentage(this.input.
|
|
19
|
+
this.input.style.backgroundSize = this.getPercentage(this.input.min, this.input.max, this.input.value) + "% 100%";
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Sets the bubble of the slider.
|
|
23
23
|
*/
|
|
24
24
|
__publicField(this, "setBubble", () => {
|
|
25
|
-
let newValue = this.getPercentage(this.input.
|
|
25
|
+
let newValue = this.getPercentage(this.input.min, this.input.max, this.input.value);
|
|
26
26
|
this.output.style.left = `calc(${newValue}% + (${8 - newValue * 0.15}px) - ${this.output.offsetWidth / 2}px)`;
|
|
27
27
|
this.output.innerHTML = this.input.value;
|
|
28
28
|
});
|
|
@@ -127,7 +127,7 @@ class Slider extends WJElement {
|
|
|
127
127
|
* @param {Object} params - The parameters for drawing.
|
|
128
128
|
* @returns {DocumentFragment}
|
|
129
129
|
*/
|
|
130
|
-
draw(
|
|
130
|
+
draw() {
|
|
131
131
|
let fragment = document.createDocumentFragment();
|
|
132
132
|
let element = document.createElement("div");
|
|
133
133
|
element.className = "native-slider";
|
|
@@ -173,6 +173,9 @@ class Slider extends WJElement {
|
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* Sets up the event listeners after the component is drawn.
|
|
176
|
+
* @params {Object} context - The context for drawing.
|
|
177
|
+
* @params {Object} store - The store for drawing.
|
|
178
|
+
* @params {Object} params - The parameters for drawing.
|
|
176
179
|
*/
|
|
177
180
|
afterDraw() {
|
|
178
181
|
this.setHandlePosition();
|
|
@@ -210,7 +213,7 @@ class Slider extends WJElement {
|
|
|
210
213
|
* @param {number} max - The maximum value of the slider.
|
|
211
214
|
* @returns {number} The percentage of the slider value.
|
|
212
215
|
*/
|
|
213
|
-
getPercentage(value = 0
|
|
216
|
+
getPercentage(min, max, value = 0) {
|
|
214
217
|
return Number((value - min) * 100 / (max - min)) || 0;
|
|
215
218
|
}
|
|
216
219
|
}
|