wj-elements 0.1.44 → 0.1.46

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.
@@ -1,6 +1,6 @@
1
1
  var y = Object.defineProperty;
2
- var C = (o, n, e) => n in o ? y(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
3
- var f = (o, n, e) => (C(o, typeof n != "symbol" ? n + "" : n, e), e);
2
+ var C = (o, l, e) => l in o ? y(o, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[l] = e;
3
+ var f = (o, l, e) => (C(o, typeof l != "symbol" ? l + "" : l, e), e);
4
4
  import g from "./wje-element.js";
5
5
  import { event as q } from "./wje-element.js";
6
6
  import { defaultStoreActions as P, store as U } from "./wje-store.js";
@@ -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 { P as Kr } from "./popup.element-CWsSOxs2.js";
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",
@@ -154,24 +155,24 @@ class w extends g {
154
155
  const t = Array.from(this.children);
155
156
  this.steps = t.map((c, m) => {
156
157
  if (c.nodeName === "WJE-STEP") {
157
- const i = document.createElement("div");
158
- i.className = "step-header";
158
+ const n = document.createElement("div");
159
+ n.className = "step-header";
159
160
  const u = document.createElement("wje-badge");
160
161
  u.className = "step-badge", u.setAttribute("label", (m + 1).toString()), u.innerHTML = "12";
161
162
  const x = document.createElement("span");
162
- if (x.innerText = c.getAttribute("label") || `Step ${m + 1}`, m === this.currentStep && (i.classList.add("active"), u.setAttribute("color", "primary")), c.hasAttribute("disabled") || (i.addEventListener("click", () => this.gotoStep(m)), i.classList.add("pointer")), i.appendChild(u), i.appendChild(x), s.appendChild(i), m < t.length - 1) {
163
+ if (x.innerText = c.getAttribute("label") || `Step ${m + 1}`, m === this.currentStep && (n.classList.add("active"), u.setAttribute("color", "primary")), c.hasAttribute("disabled") || (n.addEventListener("click", () => this.gotoStep(m)), n.classList.add("pointer")), n.appendChild(u), n.appendChild(x), s.appendChild(n), m < t.length - 1) {
163
164
  const h = document.createElement("wje-icon");
164
165
  h.setAttribute("name", "chevron-right"), h.classList.add("arrow-icon"), h.setAttribute("size", "small"), s.appendChild(h);
165
166
  }
166
167
  return c.classList.add("step"), m !== this.currentStep && (c.style.display = "none"), c;
167
168
  }
168
169
  }), this.steps.forEach((c) => a.appendChild(c));
169
- const l = document.createElement("div");
170
- l.className = "nav-buttons";
170
+ const i = document.createElement("div");
171
+ i.className = "nav-buttons";
171
172
  const d = document.createElement("wje-button");
172
173
  d.setAttribute("label", "Previous"), d.disabled = this.currentStep === 0, d.addEventListener("click", () => this.navigate(-1)), d.innerHTML = "Prev";
173
174
  const p = document.createElement("wje-button");
174
- return p.setAttribute("label", "Next"), p.disabled = this.currentStep === this.steps.length - 1, p.addEventListener("click", () => this.navigate(1)), p.innerHTML = "Next", l.appendChild(d), l.appendChild(p), r.appendChild(s), r.appendChild(a), r.appendChild(l), e.appendChild(r), e;
175
+ return p.setAttribute("label", "Next"), p.disabled = this.currentStep === this.steps.length - 1, p.addEventListener("click", () => this.navigate(1)), p.innerHTML = "Next", i.appendChild(d), i.appendChild(p), r.appendChild(s), r.appendChild(a), r.appendChild(i), e.appendChild(r), e;
175
176
  }
176
177
  navigate(e) {
177
178
  this.gotoStep(this.currentStep + e);
@@ -240,14 +241,14 @@ class b extends g {
240
241
  let a = document.createDocumentFragment();
241
242
  const t = document.createElement("div");
242
243
  t.setAttribute("part", "native"), t.classList.add("native-timeline");
243
- const l = document.createElement("div");
244
- l.classList.add("vertical-line");
244
+ const i = document.createElement("div");
245
+ i.setAttribute("part", "vertical-line"), i.classList.add("vertical-line");
245
246
  const d = document.createElement("slot");
246
- return t.appendChild(l), t.appendChild(d), a.appendChild(t), a;
247
+ return t.appendChild(i), t.appendChild(d), a.appendChild(t), a;
247
248
  }
248
249
  }
249
250
  b.define("wje-timeline", b);
250
- function T(o, n) {
251
+ function T(o, l) {
251
252
  let e;
252
253
  if (typeof o == "string")
253
254
  e = new Date(o);
@@ -270,7 +271,7 @@ function T(o, n) {
270
271
  MMM: e.toLocaleString("en-US", { month: "short" })
271
272
  // Short month name
272
273
  };
273
- return n.replace(/yyyy|MM|dd|HH|mm|ss|MMMM|MMM/g, (s) => r[s]);
274
+ return l.replace(/yyyy|MM|dd|HH|mm|ss|MMMM|MMM/g, (s) => r[s]);
274
275
  }
275
276
  const k = ":host{--wje-card-content-padding: var(--wje-spacing-medium);margin-bottom:.5rem;display:block}.native-timeline-item>wje-icon{color:var(--wje-color-contrast-5)!important}.timeline-items{display:flex;flex-direction:column}.native-timeline-item{display:flex;position:relative;padding:var(--wje-spacing-medium) var(--wje-spacing-medium) var(--wje-spacing-medium) var(--wje-spacing-large);gap:var(--wje-spacing-medium);border-width:1px;border-style:solid;border-color:transparent;border-radius:var(--wje-border-radius-large)}:host .native-timeline-item:hover{background-color:var(--wje-color-contrast-1);border-color:var(--wje-color-contrast-3)}:host([active]) .native-timeline-item{background-color:var(--wje-color-primary-1);border-color:var(--wje-color-primary-3)}:host([active]) .native-timeline-item:hover{background-color:var(--wje-color-primary-2)}.icon-container{position:absolute;display:flex;width:var(--wje-size-small);height:var(--wje-size-small);padding:var(--wje-spacing-2x-small);border-radius:var(--wje-border-radius-circle);opacity:0}.content-container{height:fit-content;gap:var(--wje-spacing-small)}.event{margin:0;font-size:var(--wje-font-size-large);font-weight:var(--wje-font-weight-bold);line-height:var(--wje-line-height-dense);letter-spacing:var(--wje-spacing-4x-small)}.additional-content{font-size:var(--wje-font-size-medium);margin-top:1rem}wje-status{position:relative;z-index:1}wje-relative-time{display:block;margin-bottom:var(--wje-spacing-2x-small)}";
276
277
  class S extends g {
@@ -309,16 +310,16 @@ class S extends g {
309
310
  draw(e, r, s) {
310
311
  let a = document.createDocumentFragment(), t = document.createElement("div");
311
312
  t.setAttribute("part", "native"), t.classList.add("native-timeline-item");
312
- let l = document.createElement("div");
313
- l.classList.add("content-container");
313
+ let i = document.createElement("div");
314
+ i.classList.add("content-container");
314
315
  let d = document.createElement("wje-tooltip");
315
316
  d.setAttribute("text", this.getAttribute("tooltip") || ""), d.setAttribute("position", "top"), d.setAttribute("content", T(this.datetime, "dd.MM.yyyy HH:mm"));
316
317
  let p = document.createElement("wje-relative-time");
317
318
  p.setAttribute("date", this.datetime || ""), p.setAttribute("format", this.getAttribute("format") || ""), d.appendChild(p);
318
319
  let c = document.createElement("h3");
319
320
  c.classList.add("event"), c.textContent = this.getAttribute("event") || "";
320
- let m = document.createElement("slot"), i = document.createElement("wje-icon");
321
- return i.setAttribute("name", "circle-dot"), i.setAttribute("filled", ""), i.setAttribute("part", "default-icon"), this.querySelector('[slot="status"]') && (i = document.createElement("slot"), i.setAttribute("name", "status")), l.appendChild(d), l.appendChild(c), l.appendChild(m), t.appendChild(i), t.appendChild(l), a.appendChild(t), a;
321
+ let m = document.createElement("slot"), n = document.createElement("wje-icon");
322
+ return n.setAttribute("name", "circle-dot"), n.setAttribute("filled", ""), n.setAttribute("part", "default-icon"), this.querySelector('[slot="status"]') && (n = document.createElement("slot"), n.setAttribute("name", "status")), i.appendChild(d), i.appendChild(c), i.appendChild(m), t.appendChild(n), t.appendChild(i), a.appendChild(t), a;
322
323
  }
323
324
  }
324
325
  S.define("wje-timeline-item", S);
@@ -376,7 +377,7 @@ export {
376
377
  qt as MenuLabel,
377
378
  Pt as Option,
378
379
  Gt as Options,
379
- Kr as Popup,
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,
@@ -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,274 @@
1
+ var p = Object.defineProperty;
2
+ var u = (r, n, t) => n in r ? p(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
+ var h = (r, n, t) => (u(r, typeof n != "symbol" ? n + "" : n, t), t);
4
+ import f from "./wje-element.js";
5
+ const v = ":host{display:block;overflow:hidden;display:table}";
6
+ class l extends f {
7
+ /**
8
+ * Creates an instance of SlidingContainer.
9
+ *
10
+ * @constructor
11
+ */
12
+ constructor() {
13
+ super();
14
+ h(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
+ h(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
+ get animationDuration() {
69
+ return this.getAttribute("animation-duration") ?? "500";
70
+ }
71
+ set animationDuration(t) {
72
+ this.setAttribute("animation-duration", t);
73
+ }
74
+ get animationEasing() {
75
+ return this.getAttribute("animation-easing") ?? "linear";
76
+ }
77
+ set animationEasing(t) {
78
+ this.setAttribute("animation-easing", t);
79
+ }
80
+ get hasOpacity() {
81
+ return this.hasAttribute("has-opacity") ?? !1;
82
+ }
83
+ static get observedAttributes() {
84
+ return ["max-width", "max-height", "trigger", "direction", "variant", "screen-break-point", "remove-child-after-close", "animation-duration", "animation-easing", "has-opacity"];
85
+ }
86
+ /**
87
+ * Returns the CSS styles for the component.
88
+ *
89
+ * @static
90
+ * @returns {CSSStyleSheet}
91
+ */
92
+ static get cssStyleSheet() {
93
+ return v;
94
+ }
95
+ /**
96
+ * Sets up the attributes for the component.
97
+ */
98
+ setupAttributes() {
99
+ this.isShadowRoot = "open";
100
+ }
101
+ /**
102
+ * Draws the component.
103
+ *
104
+ * @param {Object} context - The context for drawing.
105
+ * @param {Object} store - The store for drawing.
106
+ * @param {Object} params - The parameters for drawing.
107
+ * @returns {DocumentFragment}
108
+ */
109
+ draw(t, i, a) {
110
+ let s = document.createDocumentFragment();
111
+ this.style.position = "relative", this.style.height = "100%", this.transparentDiv = document.createElement("div"), this.transparentDiv.classList.add("sliding-container-transparent");
112
+ let e = document.createElement("div");
113
+ e.style.position = "absolute", e.style.width = this.maxWidth, this.hasOpacity && (e.style.opacity = 0), 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;
114
+ let o = document.createElement("slot");
115
+ return e.appendChild(this.getCloseButton()), e.appendChild(o), s.appendChild(this.transparentDiv), s.appendChild(e), this.nativeElement = e, s;
116
+ }
117
+ /**
118
+ * Creates and returns a close button element.
119
+ * @returns {HTMLElement} The close button element.
120
+ */
121
+ getCloseButton() {
122
+ let t = document.createElement("wje-button");
123
+ t.setAttribute("part", "close-button"), t.style.position = "absolute", t.style.top = "0", t.style.right = "0", t.style.zIndex = "1000";
124
+ let i = document.createElement("wje-icon");
125
+ return i.setAttribute("slot", "icon-only"), i.setAttribute("name", "x"), t.appendChild(i), t.addEventListener("click", () => {
126
+ this.close();
127
+ }), t;
128
+ }
129
+ /**
130
+ * Executes before drawing the element.
131
+ */
132
+ beforeDraw() {
133
+ document.removeEventListener(this.trigger, this.triggerEvent);
134
+ }
135
+ /**
136
+ * Performs actions after the element is drawn on the screen.
137
+ * Attaches an event listener to the document based on the specified trigger.
138
+ * Sets the variant to "over" if the document width is smaller than the screen break point.
139
+ * Calls the checkForVariant method with the current variant.
140
+ * @returns {Promise<void>} A promise that resolves after the actions are completed.
141
+ */
142
+ async afterDraw() {
143
+ document.addEventListener(this.trigger, this.triggerEvent), this.screenBreakPoint && window.innerWidth < this.screenBreakPoint && (this.variant = "over"), this.checkForVariant(this.variant);
144
+ }
145
+ getParentElement() {
146
+ let t = this.parentElement;
147
+ return t || (t = this.getRootNode().host), t;
148
+ }
149
+ /**
150
+ * Checks for a specific variant and applies corresponding styles.
151
+ *
152
+ * @param {string} variant - The variant to check for.
153
+ */
154
+ checkForVariant(t) {
155
+ var i, a;
156
+ if (t === "over") {
157
+ this.style.position = "fixed";
158
+ let s = window.getComputedStyle(this.getParentElement()), e = this.getParentElement().getBoundingClientRect(), o = parseFloat(s.height), d = parseFloat(s.width), m = parseFloat(s.top);
159
+ this.style.height = o + "px", this.style.top = m + "px";
160
+ let c = this.getParentElement().firstElementChild === this || ((i = this.getParentElement().shadowRoot) == null ? void 0 : i.firstElementChild) === this, g = this.getParentElement().lastElementChild === this || ((a = this.getParentElement().shadowRoot) == null ? void 0 : a.lastElementChild) === this;
161
+ c && (this.direction === "right" ? this.style.left = e.left + "px" : this.style.right = window.innerWidth - (e.left + e.width) + d + "px"), g && (this.style.right = window.innerWidth - (e.left + e.width) + "px");
162
+ }
163
+ }
164
+ /**
165
+ * Executes before the element is opened.
166
+ */
167
+ beforeOpen() {
168
+ }
169
+ /**
170
+ * Callback function called after the element is opened.
171
+ */
172
+ afterOpen() {
173
+ }
174
+ /**
175
+ * Executes before closing the element.
176
+ */
177
+ beforeClose() {
178
+ }
179
+ /**
180
+ * Callback function that is called after the container is closed.
181
+ */
182
+ afterClose() {
183
+ }
184
+ /**
185
+ * Animates the transition of the element's width from 0 to the maximum width or vice versa.
186
+ * @returns {Promise<void>} A promise that resolves when the animation finishes.
187
+ */
188
+ doAnimateTransition() {
189
+ const t = {
190
+ delay: 0,
191
+ endDelay: 0,
192
+ fill: "both",
193
+ duration: +this.animationDuration,
194
+ iterationStart: 0,
195
+ iterations: 1,
196
+ direction: "normal",
197
+ easing: this.animationEasing
198
+ };
199
+ if (this._isOpen)
200
+ this.animation.reverse(), this.hasOpacity && this.nativeAnimation.reverse();
201
+ else {
202
+ if (this.animation) {
203
+ this.animation.reverse(), this.hasOpacity && this.nativeAnimation.reverse();
204
+ return;
205
+ }
206
+ this.animation = this.transparentDiv.animate([
207
+ {
208
+ width: 0,
209
+ opacity: 0
210
+ },
211
+ {
212
+ width: this.maxWidth,
213
+ opacity: +this.containerOpacity
214
+ }
215
+ ], t), this.hasOpacity && (this.nativeAnimation = this.nativeElement.animate([
216
+ {
217
+ opacity: 0
218
+ },
219
+ {
220
+ opacity: 1
221
+ }
222
+ ], t));
223
+ }
224
+ return new Promise((i, a) => {
225
+ this.animation.onfinish = () => {
226
+ i();
227
+ };
228
+ });
229
+ }
230
+ /**
231
+ * Opens the container with an animation.
232
+ * @returns {Promise<void>} A promise that resolves when the container is opened.
233
+ */
234
+ async open() {
235
+ await Promise.resolve(this.beforeOpen()).then(() => {
236
+ Promise.resolve(this._isOpen ? () => {
237
+ } : this.doAnimateTransition()).then(() => {
238
+ Promise.resolve(this.afterOpen()).then(() => {
239
+ this._isOpen = !0;
240
+ });
241
+ });
242
+ });
243
+ }
244
+ /**
245
+ * Closes the animation container.
246
+ *
247
+ * @returns {Promise<void>} A promise that resolves when the container is closed.
248
+ */
249
+ async close() {
250
+ await Promise.resolve(this.beforeClose()).then(() => {
251
+ Promise.resolve(this._isOpen ? this.doAnimateTransition() : () => {
252
+ }).then(() => {
253
+ Promise.resolve(this.afterClose()).then(() => {
254
+ this.removeChildAfterClose && this.childNodes.forEach((t) => {
255
+ t.remove();
256
+ }), this._isOpen = !1;
257
+ });
258
+ });
259
+ });
260
+ }
261
+ /**
262
+ * Toggles the state of the element.
263
+ * If the element is open, it will be closed. If it is closed, it will be opened.
264
+ * @returns {Promise<void>} A promise that resolves when the toggle operation is complete.
265
+ */
266
+ async toggle() {
267
+ this._isOpen ? await this.close() : await this.open();
268
+ }
269
+ }
270
+ customElements.define("wje-sliding-container", l);
271
+ l.define("wje-sliding-container", l);
272
+ export {
273
+ l as default
274
+ };
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.44",
4
+ "version": "0.1.46",
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"