wj-elements 0.1.48 → 0.1.49
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/custom-elements.json +14058 -0
- package/dist/dark.css +1 -0
- package/dist/light.css +1 -0
- package/dist/localize.js +45 -0
- package/dist/popup.element-CWsSOxs2.js +1072 -0
- package/dist/router-links-FtZbFUto.js +146 -0
- package/dist/styles.css +1 -0
- package/dist/web-types.json +3122 -0
- package/dist/wje-accordion-item.js +88 -0
- package/dist/wje-accordion.js +79 -0
- package/dist/wje-animation.js +121 -0
- package/dist/wje-aside.js +55 -0
- package/dist/wje-avatar.js +77 -0
- package/dist/wje-badge.js +50 -0
- package/dist/wje-breadcrumb.js +148 -0
- package/dist/wje-breadcrumbs.js +67 -0
- package/dist/wje-button-group.js +78 -0
- package/dist/wje-button.js +207 -0
- package/dist/wje-card-content.js +48 -0
- package/dist/wje-card-controls.js +48 -0
- package/dist/wje-card-header.js +47 -0
- package/dist/wje-card-subtitle.js +55 -0
- package/dist/wje-card-title.js +55 -0
- package/dist/wje-card.js +50 -0
- package/dist/wje-carousel-item.js +33 -0
- package/dist/wje-carousel.js +177 -0
- package/dist/wje-checkbox.js +96 -0
- package/dist/wje-chip.js +32 -0
- package/dist/wje-col.js +27 -0
- package/dist/wje-color-picker.js +953 -0
- package/dist/wje-container.js +57 -0
- package/dist/wje-copy-button.js +170 -0
- package/dist/wje-dialog.js +86 -0
- package/dist/wje-divider.js +53 -0
- package/dist/wje-dropdown.js +114 -0
- package/dist/wje-element.js +453 -0
- package/dist/wje-fetchAndParseCSS.js +40 -0
- package/dist/wje-file-upload-item.js +115 -0
- package/dist/wje-file-upload.js +297 -0
- package/dist/wje-footer.js +56 -0
- package/dist/wje-form.js +28 -0
- package/dist/wje-format-digital.js +85 -0
- package/dist/wje-grid.js +28 -0
- package/dist/wje-header.js +58 -0
- package/dist/wje-icon-picker.js +221 -0
- package/dist/wje-icon.js +119 -0
- package/dist/wje-img-comparer.js +111 -0
- package/dist/wje-img.js +58 -0
- package/dist/wje-infinite-scroll.js +201 -0
- package/dist/wje-inline-edit.js +145 -0
- package/dist/wje-input-file.js +85 -0
- package/dist/wje-input.js +334 -0
- package/dist/wje-item.js +45 -0
- package/dist/wje-label.js +67 -0
- package/dist/wje-list.js +53 -0
- package/dist/wje-main.js +56 -0
- package/dist/wje-masonry.js +218 -0
- package/dist/wje-master.js +423 -0
- package/dist/wje-menu-button.js +65 -0
- package/dist/wje-menu-item.js +230 -0
- package/dist/wje-menu-label.js +57 -0
- package/dist/wje-menu.js +74 -0
- package/dist/wje-option.js +99 -0
- package/dist/wje-options.js +63 -0
- package/dist/wje-popup.js +5 -0
- package/dist/wje-progress-bar.js +161 -0
- package/dist/wje-qr-code.js +2332 -0
- package/dist/wje-radio-group.js +101 -0
- package/dist/wje-radio.js +46 -0
- package/dist/wje-rate.js +260 -0
- package/dist/wje-relative-time.js +85 -0
- package/dist/wje-reorder-dropzone.js +27 -0
- package/dist/wje-reorder-handle.js +115 -0
- package/dist/wje-reorder-item.js +32 -0
- package/dist/wje-reorder.js +138 -0
- package/dist/wje-route.js +46 -0
- package/dist/wje-router-link.js +64 -0
- package/dist/wje-router-outlet.js +127 -0
- package/dist/wje-routerx.js +1088 -0
- package/dist/wje-row.js +58 -0
- package/dist/wje-select.js +242 -0
- package/dist/wje-slider.js +177 -0
- package/dist/wje-sliding-container.js +277 -0
- package/dist/wje-split-view.js +112 -0
- package/dist/wje-status.js +54 -0
- package/dist/wje-store.js +192 -0
- package/dist/wje-tab-group.js +107 -0
- package/dist/wje-tab-panel.js +52 -0
- package/dist/wje-tab.js +59 -0
- package/dist/wje-textarea.js +116 -0
- package/dist/wje-thumbnail.js +64 -0
- package/dist/wje-toast.js +76 -0
- package/dist/wje-toggle.js +94 -0
- package/dist/wje-toolbar-action.js +63 -0
- package/dist/wje-toolbar.js +61 -0
- package/dist/wje-tooltip.js +116 -0
- package/dist/wje-visually-hidden.js +56 -0
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var u = (i, t, e) => t in i ? c(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var n = (i, t, e) => (u(i, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import h from "./wje-element.js";
|
|
5
|
+
import r from "./wje-radio.js";
|
|
6
|
+
const m = ".wje-inline{display:flex;flex-direction:row;flex-wrap:wrap;gap:.5rem}";
|
|
7
|
+
class l extends h {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of RadioGroup.
|
|
10
|
+
*
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
n(this, "className", "RadioGroup");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the CSS styles for the component.
|
|
19
|
+
*
|
|
20
|
+
* @static
|
|
21
|
+
* @returns {CSSStyleSheet}
|
|
22
|
+
*/
|
|
23
|
+
static get cssStyleSheet() {
|
|
24
|
+
return m;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of attributes to observe for changes.
|
|
28
|
+
*
|
|
29
|
+
* @static
|
|
30
|
+
* @returns {Array<string>}
|
|
31
|
+
*/
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets up the attributes for the component.
|
|
37
|
+
*/
|
|
38
|
+
setupAttributes() {
|
|
39
|
+
this.isShadowRoot = "open";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Draws the component.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} context - The context for drawing.
|
|
45
|
+
* @param {Object} store - The store for drawing.
|
|
46
|
+
* @param {Object} params - The parameters for drawing.
|
|
47
|
+
* @returns {DocumentFragment}
|
|
48
|
+
*/
|
|
49
|
+
draw(e, s, p) {
|
|
50
|
+
let o = document.createDocumentFragment(), a = document.createElement("div");
|
|
51
|
+
a.classList.add("native-radio-group", this.hasAttribute("inline") ? "wje-inline" : "ddd");
|
|
52
|
+
let d = document.createElement("slot");
|
|
53
|
+
return a.appendChild(d), o.appendChild(a), o;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Adds event listeners after the component is drawn.
|
|
57
|
+
* Handles the selection of radio buttons.
|
|
58
|
+
*/
|
|
59
|
+
afterDraw() {
|
|
60
|
+
this.value && this.setRadioToChekced(this.getRadioByValue(this.value)), this.addEventListener("wje-radio:input", (e) => {
|
|
61
|
+
this.removeCheck(), this.setRadioToChekced(e.detail.context);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the radio button with the given value.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} value - The value of the radio button.
|
|
68
|
+
* @returns {Radio} The radio button.
|
|
69
|
+
*/
|
|
70
|
+
getRadioByValue(e) {
|
|
71
|
+
return this.getAllElements().filter((s) => s instanceof r && s.value === e)[0];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Removes the check from all radio buttons.
|
|
75
|
+
*/
|
|
76
|
+
removeCheck() {
|
|
77
|
+
this.getAllElements().forEach((e) => {
|
|
78
|
+
e instanceof r && (e.checked = !1);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sets the given radio button to checked.
|
|
83
|
+
*
|
|
84
|
+
* @param {Radio} radio - The radio button to check.
|
|
85
|
+
*/
|
|
86
|
+
setRadioToChekced(e) {
|
|
87
|
+
e instanceof r && (this.setAttribute("value", e.value), e.checked = !0);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns all the elements in the radio group.
|
|
91
|
+
*
|
|
92
|
+
* @returns {Array<Element>} The elements.
|
|
93
|
+
*/
|
|
94
|
+
getAllElements() {
|
|
95
|
+
return Array.from(this.childNodes);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
l.define("wje-radio-group", l);
|
|
99
|
+
export {
|
|
100
|
+
l as default
|
|
101
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var s = (o, t, e) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var a = (o, t, e) => (s(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import p, { event as n } from "./wje-element.js";
|
|
5
|
+
const h = ':host{--wje-radio-margin-top: 0;--wje-radio-margin-bottom: .5rem;--wje-radio-margin-inline: 0;display:block;margin-top:var(--wje-radio-margin-top);margin-bottom:var(--wje-radio-margin-bottom);margin-inline:var(--wje-radio-margin-inline);line-height:100%;padding-left:0}:host label{display:flex;cursor:pointer;position:relative;padding-left:1.5rem;min-width:16px;min-height:16px;margin-bottom:0;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;align-items:center}:host label:before{content:"";position:absolute;width:16px;height:16px;left:0;box-sizing:border-box;background-color:var(--wje-color-contrast-1);border:1px solid var(--wje-color-contrast-4)}.native-radio input[type=radio]+label:before{border-radius:var(--wje-border-radius-circle);transition:border .3s 0s cubic-bezier(.455,.03,.215,1.33)}.native-radio input[type=radio]:checked+label:before{border-color:var(--wje-color-contrast-6);border-width:5px}.native-radio input[type=radio]:focus+label{color:var(--wje-color)}.native-radio input[type=radio]:focus+label:before{outline:none!important;box-shadow:0 0 #78c8fe}.native-radio input[type=radio]{opacity:0;position:absolute;top:3px;width:16px;height:16px}.native-radio input[type=radio][disabled]+label{cursor:not-allowed!important;color:var(--wje-color-contrast-9);opacity:.5}.native-radio input[type=radio][disabled]+label:before{cursor:not-allowed!important}:host([placement=end]) label{padding-left:0;padding-right:26px}:host([placement=end]) label:before{right:0;left:auto}:host([placement=end]) input[type=checkbox]:checked+label{position:relative}:host([placement=end]) input[type=checkbox]:checked+label:after{position:absolute;right:0;left:auto}:host([color=primary]) input[type=radio]:checked+label:before{border-color:var(--wje-color-primary-9)}:host([color=complete]) input[type=radio]:checked+label:before{border-color:var(--wje-color-complete-9)}:host([color=success]) input[type=radio]:checked+label:before{border-color:var(--wje-color-success-9)}:host([color=warning]) input[type=radio]:checked+label:before{border-color:var(--wje-color-warning-9)}:host([color=danger]) input[type=radio]:checked+label:before{border-color:var(--wje-color-danger-9)}:host([color=info]) input[type=radio]:checked+label:before{border-color:var(--wje-color-info-9)}';
|
|
6
|
+
class l extends p {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
a(this, "className", "Radio");
|
|
10
|
+
a(this, "inputEvent", (e) => {
|
|
11
|
+
this.checked = e.target.checked;
|
|
12
|
+
});
|
|
13
|
+
this._checked = !1;
|
|
14
|
+
}
|
|
15
|
+
set checked(e) {
|
|
16
|
+
this._checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked");
|
|
17
|
+
}
|
|
18
|
+
get checked() {
|
|
19
|
+
return this._checked;
|
|
20
|
+
}
|
|
21
|
+
static get cssStyleSheet() {
|
|
22
|
+
return h;
|
|
23
|
+
}
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return ["checked"];
|
|
26
|
+
}
|
|
27
|
+
setupAttributes() {
|
|
28
|
+
this.isShadowRoot = "open";
|
|
29
|
+
}
|
|
30
|
+
draw(e, b, u) {
|
|
31
|
+
let c = document.createDocumentFragment(), r = document.createElement("div");
|
|
32
|
+
r.classList.add("native-radio"), this.color && r.classList.add(this.color), this.input = document.createElement("input"), this.input.type = "radio", this.input.id = "radio", this.input.name = this.name + "-radio", this.input.checked = this.hasAttribute("checked"), this.input.disabled = this.hasAttribute("disabled");
|
|
33
|
+
let i = document.createElement("label");
|
|
34
|
+
return i.htmlFor = "radio", i.innerHTML = "<slot></slot>", r.appendChild(this.input), r.appendChild(i), c.appendChild(r), c;
|
|
35
|
+
}
|
|
36
|
+
afterDraw() {
|
|
37
|
+
this.hasAttribute("disabled") || (n.addListener(this, "click", "wje-radio:change"), n.addListener(this, "click", "wje-radio:input"));
|
|
38
|
+
}
|
|
39
|
+
disconnectedCallback() {
|
|
40
|
+
n.removeElement(this);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
l.define("wje-radio", l);
|
|
44
|
+
export {
|
|
45
|
+
l as default
|
|
46
|
+
};
|
package/dist/wje-rate.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var d = (r, o, e) => o in r ? u(r, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[o] = e;
|
|
3
|
+
var n = (r, o, e) => (d(r, typeof o != "symbol" ? o + "" : o, e), e);
|
|
4
|
+
import v from "./wje-element.js";
|
|
5
|
+
const p = ":host{--wje-rate-gap: .25rem;display:flex}.native-rate{position:relative;display:flex;gap:var(--wje-rate-gap)}.wje-rate-icon{position:relative;cursor:pointer}.selected{color:var(--wje-color-danger-9)}:host(:not([readonly])) .wje-rate-icon:hover{transform:scale(1.2)}.half wje-icon:first-child{color:var(--wje-color)}.half wje-icon:last-child{color:currentColor;position:absolute;top:0;left:0}:host([disabled]) .native-rate{pointer-events:none;opacity:.5}";
|
|
6
|
+
class c extends v {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of Rate.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
n(this, "className", "Rate");
|
|
15
|
+
/**
|
|
16
|
+
* Event handler for the mouse enter event.
|
|
17
|
+
*
|
|
18
|
+
* @param {Event} e - The event.
|
|
19
|
+
*/
|
|
20
|
+
n(this, "onMouseEnter", (e) => {
|
|
21
|
+
e.preventDefault(), this.hoverValue = this.getValueFromXPosition(e.clientX), this.changeRate();
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Event handler for the mouse leave event.
|
|
25
|
+
*
|
|
26
|
+
* @param {Event} e - The event.
|
|
27
|
+
*/
|
|
28
|
+
n(this, "onMouseLeave", (e) => {
|
|
29
|
+
e.preventDefault(), this.hoverValue = 0, this.changeRate();
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Event handler for the mouse move event.
|
|
33
|
+
*
|
|
34
|
+
* @param {Event} e - The event.
|
|
35
|
+
*/
|
|
36
|
+
n(this, "onMouseMove", (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
let i = this.getValueFromXPosition(e.clientX);
|
|
39
|
+
i != this.hoverValue && (this.hoverValue = i, this.changeRate());
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Event handler for the touch start event.
|
|
43
|
+
*
|
|
44
|
+
* @param {Event} e - The event.
|
|
45
|
+
*/
|
|
46
|
+
n(this, "onTouchStart", (e) => {
|
|
47
|
+
e.preventDefault(), this.hoverValue = this.getValueFromXPosition(e.touches[0].clientX), this.changeRate();
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Event handler for the touch end event.
|
|
51
|
+
*
|
|
52
|
+
* @param {Event} e - The event.
|
|
53
|
+
*/
|
|
54
|
+
n(this, "onTouchEnd", (e) => {
|
|
55
|
+
e.preventDefault(), this.hoverValue = 0, this.changeRate();
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Event handler for the touch move event.
|
|
59
|
+
*
|
|
60
|
+
* @param {Event} e - The event.
|
|
61
|
+
*/
|
|
62
|
+
n(this, "onTouchMove", (e) => {
|
|
63
|
+
e.preventDefault(), this.hoverValue = this.getValueFromXPosition(e.touches[0].clientX), this.changeRate();
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Event handler for the click event.
|
|
67
|
+
*
|
|
68
|
+
* @param {Event} e - The event.
|
|
69
|
+
*/
|
|
70
|
+
n(this, "onClick", (e) => {
|
|
71
|
+
e.preventDefault(), this.value = +this.hoverValue;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Sets the precision of the rating component.
|
|
76
|
+
*
|
|
77
|
+
* @param {number} value - The value to set.
|
|
78
|
+
*/
|
|
79
|
+
set precision(e) {
|
|
80
|
+
this.setAttribute("precision", e);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets the precision of the rating component.
|
|
84
|
+
*
|
|
85
|
+
* @returns {number} The value of the precision.
|
|
86
|
+
*/
|
|
87
|
+
get precision() {
|
|
88
|
+
return this.hasAttribute("precision") ? +this.getAttribute("precision") : 1;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sets the maximum value of the rating component.
|
|
92
|
+
*
|
|
93
|
+
* @param {number} value - The value to set.
|
|
94
|
+
*/
|
|
95
|
+
set max(e) {
|
|
96
|
+
this.setAttribute("max", e);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Gets the maximum value of the rating component.
|
|
100
|
+
*
|
|
101
|
+
* @returns {number} The value of the maximum value.
|
|
102
|
+
*/
|
|
103
|
+
get max() {
|
|
104
|
+
return this.hasAttribute("icons") ? this.icons.length : +this.getAttribute("max");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Sets the icons of the rating component.
|
|
108
|
+
*
|
|
109
|
+
* @param {Array<string>} value - The value to set.
|
|
110
|
+
*/
|
|
111
|
+
set icons(e) {
|
|
112
|
+
return e;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Gets the icons of the rating component.
|
|
116
|
+
*
|
|
117
|
+
* @returns {Array<string>} The value of the icons.
|
|
118
|
+
*/
|
|
119
|
+
get icons() {
|
|
120
|
+
return this.hasAttribute("icons") ? JSON.parse(this.getAttribute("icons").replace(/'/g, '"')) : ["star"];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sets the value of the rating component.
|
|
124
|
+
*
|
|
125
|
+
* @param {number} value - The value to set.
|
|
126
|
+
*/
|
|
127
|
+
set value(e) {
|
|
128
|
+
this.setAttribute("value", e);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets the value of the rating component.
|
|
132
|
+
*
|
|
133
|
+
* @returns {number} The value of the value.
|
|
134
|
+
*/
|
|
135
|
+
get value() {
|
|
136
|
+
return this.hasAttribute("value") ? +this.getAttribute("value") : 0;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns the CSS styles for the component.
|
|
140
|
+
*
|
|
141
|
+
* @static
|
|
142
|
+
* @returns {CSSStyleSheet}
|
|
143
|
+
*/
|
|
144
|
+
static get cssStyleSheet() {
|
|
145
|
+
return p;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns the list of attributes to observe for changes.
|
|
149
|
+
*
|
|
150
|
+
* @static
|
|
151
|
+
* @returns {Array<string>}
|
|
152
|
+
*/
|
|
153
|
+
static get observedAttributes() {
|
|
154
|
+
return ["is-hover"];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Called when an attribute changes.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} name - The name of the attribute.
|
|
160
|
+
* @param {string} old - The old value of the attribute.
|
|
161
|
+
* @param {string} newName - The new value of the attribute.
|
|
162
|
+
*/
|
|
163
|
+
attributeChangedCallback(e, i, t) {
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Sets up the attributes for the component.
|
|
167
|
+
*/
|
|
168
|
+
setupAttributes() {
|
|
169
|
+
this.isShadowRoot = "open";
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Draws the component.
|
|
173
|
+
*
|
|
174
|
+
* @param {Object} context - The context for drawing.
|
|
175
|
+
* @param {Object} store - The store for drawing.
|
|
176
|
+
* @param {Object} params - The parameters for drawing.
|
|
177
|
+
* @returns {DocumentFragment}
|
|
178
|
+
*/
|
|
179
|
+
draw(e, i, t) {
|
|
180
|
+
let a = document.createDocumentFragment(), s = document.createElement("div");
|
|
181
|
+
if (s.setAttribute("part", "native"), s.classList.add("native-rate"), this.native = s, this.hasAttribute("icons")) {
|
|
182
|
+
let h = this.icons;
|
|
183
|
+
for (let l = 0; l < h.length; l++)
|
|
184
|
+
s.appendChild(this.createIcons(l));
|
|
185
|
+
} else
|
|
186
|
+
for (let h = 0; h < this.max; h++)
|
|
187
|
+
s.appendChild(this.createIcons(h));
|
|
188
|
+
return this.changeRate(), a.appendChild(s), a;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Adds event listeners after the component is drawn.
|
|
192
|
+
*/
|
|
193
|
+
afterDraw() {
|
|
194
|
+
this.hasAttribute("disabled") || this.hasAttribute("readonly") || (this.addEventListener("mouseenter", this.onMouseEnter), this.addEventListener("mouseleave", this.onMouseLeave), this.addEventListener("mousemove", this.onMouseMove), this.addEventListener("touchstart", this.onTouchStart), this.addEventListener("touchend", this.onTouchEnd), this.addEventListener("touchmove", this.onTouchMove), this.addEventListener("click", this.onClick));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Creates the icons for the rating component.
|
|
198
|
+
*
|
|
199
|
+
* @param {number} i - The index of the icon.
|
|
200
|
+
* @returns {Element} The icon element.
|
|
201
|
+
*/
|
|
202
|
+
createIcons(e) {
|
|
203
|
+
let i = document.createElement("div");
|
|
204
|
+
i.classList.add("wje-rate-icon");
|
|
205
|
+
let t = this.getIcons(e);
|
|
206
|
+
if (i.appendChild(t), this.value > e && this.value < e + 1) {
|
|
207
|
+
let a = t.cloneNode(!0);
|
|
208
|
+
i.appendChild(a);
|
|
209
|
+
}
|
|
210
|
+
return i;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Changes the rate of the rating component.
|
|
214
|
+
*/
|
|
215
|
+
changeRate() {
|
|
216
|
+
const e = this.native.children, i = this.value !== this.hoverValue && this.hoverValue !== 0 && this.hoverValue !== void 0 ? this.hoverValue : this.value;
|
|
217
|
+
for (let t = 0; t < e.length; t++)
|
|
218
|
+
if (e[t].classList.remove("selected", "hovered"), e[t].children.length > 1 && (e[t].classList.remove("half"), e[t].querySelector("wje-icon:first-child").removeAttribute("style"), e[t].querySelector("wje-icon:last-child").remove()), t < i && e[t].classList.add("selected"), i > t && i < t + 1 && e[t].children.length === 1) {
|
|
219
|
+
let a = e[t].querySelector("wje-icon").cloneNode(!0);
|
|
220
|
+
e[t].appendChild(a);
|
|
221
|
+
let s = (i - t) * 100;
|
|
222
|
+
e[t].classList.add("half"), e[t].querySelector("wje-icon:first-child").style.clipPath = `inset(0 0 0 ${s}%)`, e[t].querySelector("wje-icon:last-child").style.clipPath = `inset(0 ${s}% 0 0)`;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Returns the icons for the rating component.
|
|
227
|
+
*
|
|
228
|
+
* @param {number} index - The index of the icon.
|
|
229
|
+
* @returns {Element} The icon element.
|
|
230
|
+
*/
|
|
231
|
+
getIcons(e) {
|
|
232
|
+
let i = document.createElement("wje-icon");
|
|
233
|
+
return i.setAttribute("name", this.max ? this.icons[0] : this.icons[e]), i;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns the value from the x position.
|
|
237
|
+
*
|
|
238
|
+
* @param {number} coordinate - The x coordinate.
|
|
239
|
+
* @returns {number} The value.
|
|
240
|
+
*/
|
|
241
|
+
getValueFromXPosition(e) {
|
|
242
|
+
const { left: i, right: t, width: a } = this.native.getBoundingClientRect(), s = this.roundToPrecision((e - i) / a * this.max, this.precision);
|
|
243
|
+
return Math.min(Math.max(s, 0), this.max);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Rounds a number to the given precision.
|
|
247
|
+
*
|
|
248
|
+
* @param {number} numberToRound - The number to round.
|
|
249
|
+
* @param {number} precision - The precision.
|
|
250
|
+
* @returns {number} The rounded number.
|
|
251
|
+
*/
|
|
252
|
+
roundToPrecision(e, i = 0.5) {
|
|
253
|
+
const t = 1 / i;
|
|
254
|
+
return Math.ceil(e * t) / t;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
c.define("wje-rate", c);
|
|
258
|
+
export {
|
|
259
|
+
c as default
|
|
260
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var v = (n, i, e) => i in n ? h(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var d = (n, i, e) => (v(n, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
|
+
import f from "./wje-element.js";
|
|
5
|
+
import { Localizer as p } from "./localize.js";
|
|
6
|
+
class l extends f {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of RelativeTime.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
d(this, "className", "RelativeTime");
|
|
15
|
+
this.localizer = new p(this);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets the ISO date of the relative time component.
|
|
19
|
+
*
|
|
20
|
+
* @returns {string} The ISO date.
|
|
21
|
+
*/
|
|
22
|
+
get dateISO() {
|
|
23
|
+
let e = /* @__PURE__ */ new Date(), t = this.getAttribute("date");
|
|
24
|
+
return this.hasAttribute("date") && (this.isISODate(t) ? t = t : t = +t * 1e3, e = new Date(t)), e.toISOString();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of attributes to observe for changes.
|
|
28
|
+
*
|
|
29
|
+
* @static
|
|
30
|
+
* @returns {Array<string>}
|
|
31
|
+
*/
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return [""];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets up the attributes for the component.
|
|
37
|
+
*/
|
|
38
|
+
setupAttributes() {
|
|
39
|
+
this.isShadowRoot = "open";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Draws the component.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} context - The context for drawing.
|
|
45
|
+
* @param {Object} store - The store for drawing.
|
|
46
|
+
* @param {Object} params - The parameters for drawing.
|
|
47
|
+
* @returns {DocumentFragment}
|
|
48
|
+
*/
|
|
49
|
+
draw(e, t, u) {
|
|
50
|
+
let r = document.createDocumentFragment(), a = document.createElement("div");
|
|
51
|
+
return a.setAttribute("part", "native"), a.classList.add("native-relative-time"), a.innerText = this.getRelativeTimeString(this.dateISO), r.appendChild(a), r;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns the relative time string for the given date.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} date - The date.
|
|
57
|
+
* @param {string} lang - The language.
|
|
58
|
+
* @returns {string} The relative time string.
|
|
59
|
+
*/
|
|
60
|
+
getRelativeTimeString(e, t = navigator.language) {
|
|
61
|
+
const r = new Date(e).getTime(), a = Math.round((r - Date.now()) / 1e3), o = [
|
|
62
|
+
60,
|
|
63
|
+
3600,
|
|
64
|
+
86400,
|
|
65
|
+
86400 * 7,
|
|
66
|
+
86400 * 30,
|
|
67
|
+
86400 * 365,
|
|
68
|
+
1 / 0
|
|
69
|
+
], m = ["second", "minute", "hour", "day", "week", "month", "year"], s = o.findIndex((g) => g > Math.abs(a)), c = s ? o[s - 1] : 1;
|
|
70
|
+
return this.localizer.relativeTime(Math.floor(a / c), m[s], { numeric: "auto" });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the given string is an ISO date.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} str - The string to check.
|
|
76
|
+
* @returns {boolean} True if the string is an ISO date, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
isISODate(e) {
|
|
79
|
+
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$/.test(e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
l.define("wje-relative-time", l);
|
|
83
|
+
export {
|
|
84
|
+
l as default
|
|
85
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var i = (t, e, r) => e in t ? l(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var d = (t, e, r) => (i(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
+
import c from "./wje-element.js";
|
|
5
|
+
const p = ".dropzone{border:1px dashed lightgrey;border-radius:var(--wje-border-radius-small);margin:.5rem;display:flex;flex-direction:column;align-items:center;overflow:hidden;justify-content:center;min-height:250px;width:200px}";
|
|
6
|
+
class s extends c {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
d(this, "className", "ReorderDropzone");
|
|
10
|
+
}
|
|
11
|
+
static get cssStyleSheet() {
|
|
12
|
+
return p;
|
|
13
|
+
}
|
|
14
|
+
setupAttributes() {
|
|
15
|
+
this.isShadowRoot = "open";
|
|
16
|
+
}
|
|
17
|
+
draw(r, m, u) {
|
|
18
|
+
let n = document.createDocumentFragment(), o = document.createElement("div");
|
|
19
|
+
o.classList.add("dropzone");
|
|
20
|
+
let a = document.createElement("slot");
|
|
21
|
+
return o.appendChild(a), n.appendChild(o), n;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
s.define("wje-reorder-dropzone", s);
|
|
25
|
+
export {
|
|
26
|
+
s as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var z = (c, l, e) => l in c ? x(c, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[l] = e;
|
|
3
|
+
var A = (c, l, e) => (z(c, typeof l != "symbol" ? l + "" : l, e), e);
|
|
4
|
+
import D from "./wje-element.js";
|
|
5
|
+
const w = ".disabled{opacity:.3}";
|
|
6
|
+
class E extends D {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
A(this, "className", "ReorderHandle");
|
|
10
|
+
this.addEventListener("mousedown", this.startDrag.bind(this)), this.addEventListener("touchstart", this.startTouchDrag.bind(this));
|
|
11
|
+
}
|
|
12
|
+
static get cssStyleSheet() {
|
|
13
|
+
return w;
|
|
14
|
+
}
|
|
15
|
+
static get observedAttributes() {
|
|
16
|
+
return ["dropzone", "parent"];
|
|
17
|
+
}
|
|
18
|
+
setupAttributes() {
|
|
19
|
+
this.isShadowRoot = "open";
|
|
20
|
+
}
|
|
21
|
+
draw() {
|
|
22
|
+
const e = document.createDocumentFragment(), s = document.createElement("div");
|
|
23
|
+
s.classList.add("container"), s.setAttribute("part", "native");
|
|
24
|
+
const t = document.createElement("slot");
|
|
25
|
+
return s.appendChild(t), e.appendChild(s), e;
|
|
26
|
+
}
|
|
27
|
+
afterDraw() {
|
|
28
|
+
this.hasAttribute("disabled") && (this.style.opacity = ".3");
|
|
29
|
+
}
|
|
30
|
+
startDrag(e) {
|
|
31
|
+
this.hasAttribute("disabled") || this.hasAttribute("locked") || this.startDragAction(e.clientX, e.clientY);
|
|
32
|
+
}
|
|
33
|
+
startTouchDrag(e) {
|
|
34
|
+
if (this.hasAttribute("disabled") || this.hasAttribute("locked"))
|
|
35
|
+
return;
|
|
36
|
+
const s = e.touches[0];
|
|
37
|
+
this.startDragAction(s.clientX, s.clientY);
|
|
38
|
+
}
|
|
39
|
+
startDragAction(e, s) {
|
|
40
|
+
let t;
|
|
41
|
+
if (this.hasAttribute("parent")) {
|
|
42
|
+
const n = this.getAttribute("parent");
|
|
43
|
+
t = this.closest(n);
|
|
44
|
+
} else
|
|
45
|
+
t = this.parentElement;
|
|
46
|
+
const o = this.getDropzone(t);
|
|
47
|
+
this.getAttribute("dropzone") || this.setAttribute("dropzone", o.localName);
|
|
48
|
+
const r = t.getBoundingClientRect(), h = e - r.left, u = s - r.top;
|
|
49
|
+
let i = document.createElement("div");
|
|
50
|
+
i.classList.add("sortable-item"), i.style.visibility = "hidden", i.style.height = `${r.height}px`, t.classList.add("dragging"), t.style.position = "fixed", t.style.zIndex = "1000", t.style.width = `${r.width}px`;
|
|
51
|
+
const p = (n, d) => {
|
|
52
|
+
t.style.left = `${n - h - document.documentElement.scrollLeft}px`, t.style.top = `${d - u - document.documentElement.scrollTop}px`;
|
|
53
|
+
};
|
|
54
|
+
p(e, s);
|
|
55
|
+
const f = (n) => {
|
|
56
|
+
var b;
|
|
57
|
+
p(n.pageX, n.pageY);
|
|
58
|
+
const d = this.getClosestDropzone(n.clientX, n.clientY);
|
|
59
|
+
if (!d)
|
|
60
|
+
return;
|
|
61
|
+
const y = Array.from(d.children).filter((a) => a !== t && a !== i);
|
|
62
|
+
for (const a of y) {
|
|
63
|
+
const m = a.getBoundingClientRect();
|
|
64
|
+
if (!((b = a.children[0]) != null && b.hasAttribute("locked")) && n.clientY > m.top && n.clientY < m.bottom) {
|
|
65
|
+
n.clientY < m.top + m.height / 2 ? d.insertBefore(i, a) : d.insertBefore(i, a.nextSibling);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, g = () => {
|
|
70
|
+
document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", g), t.classList.remove("dragging"), t.style.position = "", t.style.zIndex = "", t.style.left = "", t.style.top = "", t.style.width = "";
|
|
71
|
+
const n = i.parentElement;
|
|
72
|
+
n.insertBefore(t, i), n.removeChild(i), this.reIndexItems(n);
|
|
73
|
+
};
|
|
74
|
+
document.addEventListener("mousemove", f), document.addEventListener("mouseup", g), o.insertBefore(i, t);
|
|
75
|
+
}
|
|
76
|
+
getDropzone(e) {
|
|
77
|
+
const s = this.getAttribute("dropzone");
|
|
78
|
+
if (s) {
|
|
79
|
+
let t = e.closest(s);
|
|
80
|
+
if (t)
|
|
81
|
+
return t;
|
|
82
|
+
}
|
|
83
|
+
return e.parentElement;
|
|
84
|
+
}
|
|
85
|
+
getClosestDropzone(e, s) {
|
|
86
|
+
const t = this.getElementsFromPointAll(e, s);
|
|
87
|
+
for (const o of t)
|
|
88
|
+
if (o.matches(this.getAttribute("dropzone")))
|
|
89
|
+
return o;
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
// Rekurzívne prechádza všetky shadow roots bez opakovania elementov
|
|
93
|
+
getElementsFromPointAll(e, s, t = document, o = /* @__PURE__ */ new Set()) {
|
|
94
|
+
if (o.has(t))
|
|
95
|
+
return [];
|
|
96
|
+
o.add(t);
|
|
97
|
+
const r = t.elementsFromPoint(e, s);
|
|
98
|
+
let h = [...r];
|
|
99
|
+
for (const u of r)
|
|
100
|
+
u.shadowRoot && !o.has(u.shadowRoot) && (h = h.concat(this.getElementsFromPointAll(e, s, u.shadowRoot, o)));
|
|
101
|
+
return h;
|
|
102
|
+
}
|
|
103
|
+
reIndexItems(e) {
|
|
104
|
+
const s = Array.from(e.children);
|
|
105
|
+
let t = 0;
|
|
106
|
+
s.forEach((o) => {
|
|
107
|
+
var r;
|
|
108
|
+
(r = o.children[0]) != null && r.hasAttribute("locked"), o.dataset.index = t, t++;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
E.define("wje-reorder-handle", E);
|
|
113
|
+
export {
|
|
114
|
+
E as default
|
|
115
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var c = (t, e, r) => e in t ? l(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var s = (t, e, r) => (c(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
+
import m, { WjElementUtils as p } from "./wje-element.js";
|
|
5
|
+
const u = ":host{--reorder-item-spacing: .5rem}.item{width:134px;height:19px;display:flex;align-items:center;justify-content:left;position:relative;gap:var(--reorder-item-spacing);padding:var(--reorder-item-spacing);border-radius:var(--wje-border-radius-small);background-color:var(--reorder-background-color);cursor:grab;transition:top .3s ease,left .3s ease}.item-w-handle{cursor:default}.item-w-handle:active{opacity:.3}.item:active:not(.item-w-handle):not(.moving){background-color:var(--reorder-background-color);cursor:grabbing}.moving{background-color:#d3d3d3}.handle{cursor:grab;gap:10px}.handle:active{cursor:grabbing}.name{width:108px;height:19px;text-align:center;font-size:var(--wje-font-size-medium);font-weight:400;line-height:19.36px;gap:10px}.item{transform:var(--item-transform)}";
|
|
6
|
+
class d extends m {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
s(this, "className", "ReorderItem");
|
|
10
|
+
}
|
|
11
|
+
static get cssStyleSheet() {
|
|
12
|
+
return u;
|
|
13
|
+
}
|
|
14
|
+
setupAttributes() {
|
|
15
|
+
this.isShadowRoot = "open";
|
|
16
|
+
}
|
|
17
|
+
draw(r, g, h) {
|
|
18
|
+
let o = document.createDocumentFragment(), a = document.createElement("div");
|
|
19
|
+
a.classList.add("item"), a.setAttribute("part", "native-reorder-item");
|
|
20
|
+
let i = document.createElement("slot");
|
|
21
|
+
if (i.classList.add("name"), p.hasSlot(this, "handle")) {
|
|
22
|
+
const n = document.createElement("slot");
|
|
23
|
+
n.classList.add("handle"), n.setAttribute("name", "handle"), n.setAttribute("part", "handle-part"), a.classList.add("item-w-handle"), a.appendChild(n);
|
|
24
|
+
} else
|
|
25
|
+
i.setAttribute("draggable", "true");
|
|
26
|
+
return a.appendChild(i), o.appendChild(a), o;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
d.define("wje-reorder-item", d);
|
|
30
|
+
export {
|
|
31
|
+
d as default
|
|
32
|
+
};
|