wj-elements 0.1.44 → 0.1.45
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/wje-master.js +4 -2
- package/dist/wje-menu-item.js +5 -0
- package/dist/wje-sliding-container.js +245 -0
- package/package.json +1 -2
package/dist/wje-master.js
CHANGED
|
@@ -90,7 +90,8 @@ import { default as Gr } from "./wje-toolbar.js";
|
|
|
90
90
|
import { default as $r } from "./wje-toolbar-action.js";
|
|
91
91
|
import { default as Wr } from "./wje-tooltip.js";
|
|
92
92
|
import { default as Qr } from "./wje-visually-hidden.js";
|
|
93
|
-
import {
|
|
93
|
+
import { default as Kr } from "./wje-sliding-container.js";
|
|
94
|
+
import { P as Zr } from "./popup.element-CWsSOxs2.js";
|
|
94
95
|
const A = {
|
|
95
96
|
code: "sk",
|
|
96
97
|
name: "Slovak",
|
|
@@ -376,7 +377,7 @@ export {
|
|
|
376
377
|
qt as MenuLabel,
|
|
377
378
|
Pt as Option,
|
|
378
379
|
Gt as Options,
|
|
379
|
-
|
|
380
|
+
Zr as Popup,
|
|
380
381
|
$t as ProgressBar,
|
|
381
382
|
Wt as QrCode,
|
|
382
383
|
Qt as Radio,
|
|
@@ -394,6 +395,7 @@ export {
|
|
|
394
395
|
vr as Row,
|
|
395
396
|
br as Select,
|
|
396
397
|
jr as Slider,
|
|
398
|
+
Kr as SlidingContainer,
|
|
397
399
|
Cr as SplitView,
|
|
398
400
|
Er as Status,
|
|
399
401
|
v as Step,
|
package/dist/wje-menu-item.js
CHANGED
|
@@ -12,6 +12,11 @@ class j extends E {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
c(this, "className", "MenuItem");
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the submenu should be hidden based on the event.
|
|
17
|
+
*
|
|
18
|
+
* @param {Event} e - The event object.
|
|
19
|
+
*/
|
|
15
20
|
c(this, "shouldHideSubmenu", (e) => {
|
|
16
21
|
if (this.collapse || this.variant === "CONTEXT" && this.hasSubmenu) {
|
|
17
22
|
if (e.relatedTarget && this.contains(e.relatedTarget) || this.variant === "NAV" && !this.collapse)
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var m = (r, s, t) => s in r ? g(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
|
+
var l = (r, s, t) => (m(r, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
+
import p from "./wje-element.js";
|
|
5
|
+
const u = ":host{display:block;overflow:hidden;display:table}";
|
|
6
|
+
class h extends p {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of SlidingContainer.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
l(this, "className", "SlidingContainer");
|
|
15
|
+
/**
|
|
16
|
+
* Triggers the event based on the target element.
|
|
17
|
+
* If the target element is different from the last caller, it refreshes the children by calling the `open` method.
|
|
18
|
+
* If the target element is the same as the last caller, it toggles the state by calling the `toggle` method.
|
|
19
|
+
* @param {Event} e - The event object.
|
|
20
|
+
*/
|
|
21
|
+
l(this, "triggerEvent", (t) => {
|
|
22
|
+
this._lastCaller && this._lastCaller !== t.target ? this.open() : this.toggle(), this._lastCaller = t.target;
|
|
23
|
+
});
|
|
24
|
+
this._isOpen = !1, this._lastCaller = null;
|
|
25
|
+
}
|
|
26
|
+
set maxWidth(t) {
|
|
27
|
+
this.setAttribute("max-width", t);
|
|
28
|
+
}
|
|
29
|
+
get maxWidth() {
|
|
30
|
+
return this.getAttribute("max-width") ?? "auto";
|
|
31
|
+
}
|
|
32
|
+
set maxHeight(t) {
|
|
33
|
+
this.setAttribute("max-height", t);
|
|
34
|
+
}
|
|
35
|
+
get maxHeight() {
|
|
36
|
+
return this.getAttribute("max-height") ?? "auto";
|
|
37
|
+
}
|
|
38
|
+
set trigger(t) {
|
|
39
|
+
this.setAttribute("trigger", t);
|
|
40
|
+
}
|
|
41
|
+
get trigger() {
|
|
42
|
+
return this.getAttribute("trigger") ?? "sliding-container";
|
|
43
|
+
}
|
|
44
|
+
set direction(t) {
|
|
45
|
+
this.setAttribute("direction", t);
|
|
46
|
+
}
|
|
47
|
+
get direction() {
|
|
48
|
+
return this.getAttribute("direction") ?? "right";
|
|
49
|
+
}
|
|
50
|
+
set removeChildAfterClose(t) {
|
|
51
|
+
this.setAttribute("remove-child-after-close", t);
|
|
52
|
+
}
|
|
53
|
+
get removeChildAfterClose() {
|
|
54
|
+
return this.hasAttribute("remove-child-after-close") ?? !1;
|
|
55
|
+
}
|
|
56
|
+
set variant(t) {
|
|
57
|
+
this.setAttribute("variant", t);
|
|
58
|
+
}
|
|
59
|
+
get variant() {
|
|
60
|
+
return this.getAttribute("variant") ?? "in-place";
|
|
61
|
+
}
|
|
62
|
+
get screenBreakPoint() {
|
|
63
|
+
return this.getAttribute("screen-break-point");
|
|
64
|
+
}
|
|
65
|
+
set screenBreakPoint(t) {
|
|
66
|
+
this.setAttribute("screen-break-point", t);
|
|
67
|
+
}
|
|
68
|
+
static get observedAttributes() {
|
|
69
|
+
return ["max-width", "max-height", "trigger", "direction", "variant", "screen-break-point", "remove-child-after-close"];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the CSS styles for the component.
|
|
73
|
+
*
|
|
74
|
+
* @static
|
|
75
|
+
* @returns {CSSStyleSheet}
|
|
76
|
+
*/
|
|
77
|
+
static get cssStyleSheet() {
|
|
78
|
+
return u;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sets up the attributes for the component.
|
|
82
|
+
*/
|
|
83
|
+
setupAttributes() {
|
|
84
|
+
this.isShadowRoot = "open";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Draws the component.
|
|
88
|
+
*
|
|
89
|
+
* @param {Object} context - The context for drawing.
|
|
90
|
+
* @param {Object} store - The store for drawing.
|
|
91
|
+
* @param {Object} params - The parameters for drawing.
|
|
92
|
+
* @returns {DocumentFragment}
|
|
93
|
+
*/
|
|
94
|
+
draw(t, i, n) {
|
|
95
|
+
let a = document.createDocumentFragment();
|
|
96
|
+
this.style.position = "relative", this.style.height = "100%", this.transparentDiv = document.createElement("div"), this.transparentDiv.classList.add("sliding-container-transparent");
|
|
97
|
+
let e = document.createElement("div");
|
|
98
|
+
e.style.position = "absolute", e.style.width = this.maxWidth, e.style.height = "100%", e.classList.add("native-sliding-container"), e.setAttribute("part", "sliding-container"), this.direction === "right" ? e.style.right = 0 : e.style.left = 0;
|
|
99
|
+
let o = document.createElement("slot");
|
|
100
|
+
return e.appendChild(this.getCloseButton()), e.appendChild(o), a.appendChild(this.transparentDiv), a.appendChild(e), a;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates and returns a close button element.
|
|
104
|
+
* @returns {HTMLElement} The close button element.
|
|
105
|
+
*/
|
|
106
|
+
getCloseButton() {
|
|
107
|
+
let t = document.createElement("wje-button");
|
|
108
|
+
t.setAttribute("part", "close-button"), t.style.position = "absolute", t.style.top = "0", t.style.right = "0", t.style.zIndex = "1000";
|
|
109
|
+
let i = document.createElement("wje-icon");
|
|
110
|
+
return i.setAttribute("slot", "icon-only"), i.setAttribute("name", "x"), t.appendChild(i), t.addEventListener("click", () => {
|
|
111
|
+
this.close();
|
|
112
|
+
}), t;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Executes before drawing the element.
|
|
116
|
+
*/
|
|
117
|
+
beforeDraw() {
|
|
118
|
+
document.removeEventListener(this.trigger, this.triggerEvent);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Performs actions after the element is drawn on the screen.
|
|
122
|
+
* Attaches an event listener to the document based on the specified trigger.
|
|
123
|
+
* Sets the variant to "over" if the document width is smaller than the screen break point.
|
|
124
|
+
* Calls the checkForVariant method with the current variant.
|
|
125
|
+
* @returns {Promise<void>} A promise that resolves after the actions are completed.
|
|
126
|
+
*/
|
|
127
|
+
async afterDraw() {
|
|
128
|
+
document.addEventListener(this.trigger, this.triggerEvent), this.screenBreakPoint && window.innerWidth < this.screenBreakPoint && (this.variant = "over"), this.checkForVariant(this.variant);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Checks for a specific variant and applies corresponding styles.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} variant - The variant to check for.
|
|
134
|
+
*/
|
|
135
|
+
checkForVariant(t) {
|
|
136
|
+
if (t === "over") {
|
|
137
|
+
this.style.position = "fixed";
|
|
138
|
+
let i = window.getComputedStyle(this.parentElement), n = this.parentElement.getBoundingClientRect(), a = parseFloat(i.height), e = parseFloat(i.width), o = parseFloat(i.top);
|
|
139
|
+
this.style.height = a + "px", this.style.top = o + "px";
|
|
140
|
+
let d = this.parentElement.firstElementChild === this, c = this.parentElement.lastElementChild === this;
|
|
141
|
+
d && (this.direction === "right" ? this.style.left = n.left + "px" : this.style.right = window.innerWidth - (n.left + n.width) + e + "px"), c && (this.style.right = window.innerWidth - (n.left + n.width) + "px");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Executes before the element is opened.
|
|
146
|
+
*/
|
|
147
|
+
beforeOpen() {
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Callback function called after the element is opened.
|
|
151
|
+
*/
|
|
152
|
+
afterOpen() {
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Executes before closing the element.
|
|
156
|
+
*/
|
|
157
|
+
beforeClose() {
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Callback function that is called after the container is closed.
|
|
161
|
+
*/
|
|
162
|
+
afterClose() {
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Animates the transition of the element's width from 0 to the maximum width or vice versa.
|
|
166
|
+
* @returns {Promise<void>} A promise that resolves when the animation finishes.
|
|
167
|
+
*/
|
|
168
|
+
doAnimateTransition() {
|
|
169
|
+
const t = {
|
|
170
|
+
delay: 0,
|
|
171
|
+
endDelay: 0,
|
|
172
|
+
fill: "both",
|
|
173
|
+
duration: 500,
|
|
174
|
+
iterationStart: 0,
|
|
175
|
+
iterations: 1,
|
|
176
|
+
direction: "normal",
|
|
177
|
+
easing: "linear"
|
|
178
|
+
};
|
|
179
|
+
if (this._isOpen)
|
|
180
|
+
this.animation.reverse();
|
|
181
|
+
else {
|
|
182
|
+
if (this.animation) {
|
|
183
|
+
this.animation.reverse();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.animation = this.transparentDiv.animate([
|
|
187
|
+
{
|
|
188
|
+
width: 0
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
width: this.maxWidth
|
|
192
|
+
}
|
|
193
|
+
], t);
|
|
194
|
+
}
|
|
195
|
+
return new Promise((i, n) => {
|
|
196
|
+
this.animation.onfinish = () => {
|
|
197
|
+
i();
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Opens the container with an animation.
|
|
203
|
+
* @returns {Promise<void>} A promise that resolves when the container is opened.
|
|
204
|
+
*/
|
|
205
|
+
async open() {
|
|
206
|
+
await Promise.resolve(this.beforeOpen()).then(() => {
|
|
207
|
+
Promise.resolve(this._isOpen ? () => {
|
|
208
|
+
} : this.doAnimateTransition()).then(() => {
|
|
209
|
+
Promise.resolve(this.afterOpen()).then(() => {
|
|
210
|
+
this._isOpen = !0;
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Closes the animation container.
|
|
217
|
+
*
|
|
218
|
+
* @returns {Promise<void>} A promise that resolves when the container is closed.
|
|
219
|
+
*/
|
|
220
|
+
async close() {
|
|
221
|
+
await Promise.resolve(this.beforeClose()).then(() => {
|
|
222
|
+
Promise.resolve(this._isOpen ? this.doAnimateTransition() : () => {
|
|
223
|
+
}).then(() => {
|
|
224
|
+
Promise.resolve(this.afterClose()).then(() => {
|
|
225
|
+
this.removeChildAfterClose && this.childNodes.forEach((t) => {
|
|
226
|
+
t.remove();
|
|
227
|
+
}), this._isOpen = !1;
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Toggles the state of the element.
|
|
234
|
+
* If the element is open, it will be closed. If it is closed, it will be opened.
|
|
235
|
+
* @returns {Promise<void>} A promise that resolves when the toggle operation is complete.
|
|
236
|
+
*/
|
|
237
|
+
async toggle() {
|
|
238
|
+
this._isOpen ? await this.close() : await this.open();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
customElements.define("wje-sliding-container", h);
|
|
242
|
+
h.define("wje-sliding-container", h);
|
|
243
|
+
export {
|
|
244
|
+
h as default
|
|
245
|
+
};
|
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.45",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"@faker-js/faker": "^8.0.0",
|
|
48
48
|
"@floating-ui/dom": "^1.5.1",
|
|
49
49
|
"animate.css": "^4.1.1",
|
|
50
|
-
"fs-extra": "^11.2.0",
|
|
51
50
|
"qrious": "^4.0.2",
|
|
52
51
|
"tinycolor2": "^1.6.0",
|
|
53
52
|
"wj-elements": "^0.1.19"
|