wj-elements 0.1.45 → 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";
@@ -155,24 +155,24 @@ class w extends g {
155
155
  const t = Array.from(this.children);
156
156
  this.steps = t.map((c, m) => {
157
157
  if (c.nodeName === "WJE-STEP") {
158
- const i = document.createElement("div");
159
- i.className = "step-header";
158
+ const n = document.createElement("div");
159
+ n.className = "step-header";
160
160
  const u = document.createElement("wje-badge");
161
161
  u.className = "step-badge", u.setAttribute("label", (m + 1).toString()), u.innerHTML = "12";
162
162
  const x = document.createElement("span");
163
- 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) {
164
164
  const h = document.createElement("wje-icon");
165
165
  h.setAttribute("name", "chevron-right"), h.classList.add("arrow-icon"), h.setAttribute("size", "small"), s.appendChild(h);
166
166
  }
167
167
  return c.classList.add("step"), m !== this.currentStep && (c.style.display = "none"), c;
168
168
  }
169
169
  }), this.steps.forEach((c) => a.appendChild(c));
170
- const l = document.createElement("div");
171
- l.className = "nav-buttons";
170
+ const i = document.createElement("div");
171
+ i.className = "nav-buttons";
172
172
  const d = document.createElement("wje-button");
173
173
  d.setAttribute("label", "Previous"), d.disabled = this.currentStep === 0, d.addEventListener("click", () => this.navigate(-1)), d.innerHTML = "Prev";
174
174
  const p = document.createElement("wje-button");
175
- 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;
176
176
  }
177
177
  navigate(e) {
178
178
  this.gotoStep(this.currentStep + e);
@@ -241,14 +241,14 @@ class b extends g {
241
241
  let a = document.createDocumentFragment();
242
242
  const t = document.createElement("div");
243
243
  t.setAttribute("part", "native"), t.classList.add("native-timeline");
244
- const l = document.createElement("div");
245
- l.classList.add("vertical-line");
244
+ const i = document.createElement("div");
245
+ i.setAttribute("part", "vertical-line"), i.classList.add("vertical-line");
246
246
  const d = document.createElement("slot");
247
- return t.appendChild(l), t.appendChild(d), a.appendChild(t), a;
247
+ return t.appendChild(i), t.appendChild(d), a.appendChild(t), a;
248
248
  }
249
249
  }
250
250
  b.define("wje-timeline", b);
251
- function T(o, n) {
251
+ function T(o, l) {
252
252
  let e;
253
253
  if (typeof o == "string")
254
254
  e = new Date(o);
@@ -271,7 +271,7 @@ function T(o, n) {
271
271
  MMM: e.toLocaleString("en-US", { month: "short" })
272
272
  // Short month name
273
273
  };
274
- 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]);
275
275
  }
276
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)}";
277
277
  class S extends g {
@@ -310,16 +310,16 @@ class S extends g {
310
310
  draw(e, r, s) {
311
311
  let a = document.createDocumentFragment(), t = document.createElement("div");
312
312
  t.setAttribute("part", "native"), t.classList.add("native-timeline-item");
313
- let l = document.createElement("div");
314
- l.classList.add("content-container");
313
+ let i = document.createElement("div");
314
+ i.classList.add("content-container");
315
315
  let d = document.createElement("wje-tooltip");
316
316
  d.setAttribute("text", this.getAttribute("tooltip") || ""), d.setAttribute("position", "top"), d.setAttribute("content", T(this.datetime, "dd.MM.yyyy HH:mm"));
317
317
  let p = document.createElement("wje-relative-time");
318
318
  p.setAttribute("date", this.datetime || ""), p.setAttribute("format", this.getAttribute("format") || ""), d.appendChild(p);
319
319
  let c = document.createElement("h3");
320
320
  c.classList.add("event"), c.textContent = this.getAttribute("event") || "";
321
- let m = document.createElement("slot"), i = document.createElement("wje-icon");
322
- 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;
323
323
  }
324
324
  }
325
325
  S.define("wje-timeline-item", S);
@@ -1,9 +1,9 @@
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 {
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
7
  /**
8
8
  * Creates an instance of SlidingContainer.
9
9
  *
@@ -11,14 +11,14 @@ class h extends p {
11
11
  */
12
12
  constructor() {
13
13
  super();
14
- l(this, "className", "SlidingContainer");
14
+ h(this, "className", "SlidingContainer");
15
15
  /**
16
16
  * Triggers the event based on the target element.
17
17
  * If the target element is different from the last caller, it refreshes the children by calling the `open` method.
18
18
  * If the target element is the same as the last caller, it toggles the state by calling the `toggle` method.
19
19
  * @param {Event} e - The event object.
20
20
  */
21
- l(this, "triggerEvent", (t) => {
21
+ h(this, "triggerEvent", (t) => {
22
22
  this._lastCaller && this._lastCaller !== t.target ? this.open() : this.toggle(), this._lastCaller = t.target;
23
23
  });
24
24
  this._isOpen = !1, this._lastCaller = null;
@@ -65,8 +65,23 @@ class h extends p {
65
65
  set screenBreakPoint(t) {
66
66
  this.setAttribute("screen-break-point", t);
67
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
+ }
68
83
  static get observedAttributes() {
69
- return ["max-width", "max-height", "trigger", "direction", "variant", "screen-break-point", "remove-child-after-close"];
84
+ return ["max-width", "max-height", "trigger", "direction", "variant", "screen-break-point", "remove-child-after-close", "animation-duration", "animation-easing", "has-opacity"];
70
85
  }
71
86
  /**
72
87
  * Returns the CSS styles for the component.
@@ -75,7 +90,7 @@ class h extends p {
75
90
  * @returns {CSSStyleSheet}
76
91
  */
77
92
  static get cssStyleSheet() {
78
- return u;
93
+ return v;
79
94
  }
80
95
  /**
81
96
  * Sets up the attributes for the component.
@@ -91,13 +106,13 @@ class h extends p {
91
106
  * @param {Object} params - The parameters for drawing.
92
107
  * @returns {DocumentFragment}
93
108
  */
94
- draw(t, i, n) {
95
- let a = document.createDocumentFragment();
109
+ draw(t, i, a) {
110
+ let s = document.createDocumentFragment();
96
111
  this.style.position = "relative", this.style.height = "100%", this.transparentDiv = document.createElement("div"), this.transparentDiv.classList.add("sliding-container-transparent");
97
112
  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;
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;
99
114
  let o = document.createElement("slot");
100
- return e.appendChild(this.getCloseButton()), e.appendChild(o), a.appendChild(this.transparentDiv), a.appendChild(e), a;
115
+ return e.appendChild(this.getCloseButton()), e.appendChild(o), s.appendChild(this.transparentDiv), s.appendChild(e), this.nativeElement = e, s;
101
116
  }
102
117
  /**
103
118
  * Creates and returns a close button element.
@@ -127,18 +142,23 @@ class h extends p {
127
142
  async afterDraw() {
128
143
  document.addEventListener(this.trigger, this.triggerEvent), this.screenBreakPoint && window.innerWidth < this.screenBreakPoint && (this.variant = "over"), this.checkForVariant(this.variant);
129
144
  }
145
+ getParentElement() {
146
+ let t = this.parentElement;
147
+ return t || (t = this.getRootNode().host), t;
148
+ }
130
149
  /**
131
150
  * Checks for a specific variant and applies corresponding styles.
132
151
  *
133
152
  * @param {string} variant - The variant to check for.
134
153
  */
135
154
  checkForVariant(t) {
155
+ var i, a;
136
156
  if (t === "over") {
137
157
  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");
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");
142
162
  }
143
163
  }
144
164
  /**
@@ -170,29 +190,38 @@ class h extends p {
170
190
  delay: 0,
171
191
  endDelay: 0,
172
192
  fill: "both",
173
- duration: 500,
193
+ duration: +this.animationDuration,
174
194
  iterationStart: 0,
175
195
  iterations: 1,
176
196
  direction: "normal",
177
- easing: "linear"
197
+ easing: this.animationEasing
178
198
  };
179
199
  if (this._isOpen)
180
- this.animation.reverse();
200
+ this.animation.reverse(), this.hasOpacity && this.nativeAnimation.reverse();
181
201
  else {
182
202
  if (this.animation) {
183
- this.animation.reverse();
203
+ this.animation.reverse(), this.hasOpacity && this.nativeAnimation.reverse();
184
204
  return;
185
205
  }
186
206
  this.animation = this.transparentDiv.animate([
187
207
  {
188
- width: 0
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
189
218
  },
190
219
  {
191
- width: this.maxWidth
220
+ opacity: 1
192
221
  }
193
- ], t);
222
+ ], t));
194
223
  }
195
- return new Promise((i, n) => {
224
+ return new Promise((i, a) => {
196
225
  this.animation.onfinish = () => {
197
226
  i();
198
227
  };
@@ -238,8 +267,8 @@ class h extends p {
238
267
  this._isOpen ? await this.close() : await this.open();
239
268
  }
240
269
  }
241
- customElements.define("wje-sliding-container", h);
242
- h.define("wje-sliding-container", h);
270
+ customElements.define("wje-sliding-container", l);
271
+ l.define("wje-sliding-container", l);
243
272
  export {
244
- h as default
273
+ l as default
245
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.45",
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",