wj-elements 0.0.11 → 0.0.13

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.
Files changed (79) hide show
  1. package/dist/localize-20081fd1.js +55 -0
  2. package/dist/router-links-26e4a166.js +204 -0
  3. package/dist/style.css +2243 -2
  4. package/dist/wj-animation.js +35 -23
  5. package/dist/wj-aside.js +22 -16
  6. package/dist/wj-avatar.js +49 -30
  7. package/dist/wj-badge.js +22 -18
  8. package/dist/wj-breadcrumb.js +102 -50
  9. package/dist/wj-breadcrumbs.js +36 -19
  10. package/dist/wj-button-group.js +36 -22
  11. package/dist/wj-button.js +104 -39
  12. package/dist/wj-card-content.js +18 -14
  13. package/dist/wj-card-controls.js +18 -14
  14. package/dist/wj-card-header.js +20 -14
  15. package/dist/wj-card-subtitle.js +19 -15
  16. package/dist/wj-card-title.js +18 -14
  17. package/dist/wj-card.js +20 -14
  18. package/dist/wj-carousel-item.js +22 -16
  19. package/dist/wj-carousel.js +169 -92
  20. package/dist/wj-checkbox.js +46 -24
  21. package/dist/wj-chip.js +39 -21
  22. package/dist/wj-col.js +31 -17
  23. package/dist/wj-color-picker.js +877 -509
  24. package/dist/wj-container.js +20 -16
  25. package/dist/wj-copy-button.js +112 -64
  26. package/dist/wj-dialog.js +68 -42
  27. package/dist/wj-divider.js +20 -14
  28. package/dist/wj-dropdown.js +29 -17
  29. package/dist/wj-element.js +415 -241
  30. package/dist/wj-fetchAndParseCSS.js +49 -32
  31. package/dist/wj-file-upload-item.js +64 -38
  32. package/dist/wj-file-upload.js +237 -137
  33. package/dist/wj-footer.js +18 -14
  34. package/dist/wj-form.js +18 -14
  35. package/dist/wj-format-digital.js +40 -25
  36. package/dist/wj-grid.js +20 -16
  37. package/dist/wj-header.js +22 -16
  38. package/dist/wj-icon-picker.js +122 -68
  39. package/dist/wj-icon.js +144 -64
  40. package/dist/wj-img-comparer.js +72 -41
  41. package/dist/wj-img.js +31 -19
  42. package/dist/wj-infinite-scroll.js +90 -52
  43. package/dist/wj-input-file.js +50 -27
  44. package/dist/wj-input.js +169 -70
  45. package/dist/wj-item.js +34 -17
  46. package/dist/wj-label.js +21 -19
  47. package/dist/wj-list.js +20 -15
  48. package/dist/wj-main.js +18 -14
  49. package/dist/wj-masonry.js +140 -83
  50. package/dist/wj-master.js +492 -350
  51. package/dist/wj-menu-button.js +19 -15
  52. package/dist/wj-menu-item.js +150 -64
  53. package/dist/wj-menu-label.js +21 -17
  54. package/dist/wj-menu.js +24 -18
  55. package/dist/wj-popup.js +1140 -712
  56. package/dist/wj-progress-bar.js +100 -40
  57. package/dist/wj-radio-group.js +38 -25
  58. package/dist/wj-radio.js +46 -22
  59. package/dist/wj-rate.js +121 -71
  60. package/dist/wj-relative-time.js +48 -24
  61. package/dist/wj-route.js +11 -8
  62. package/dist/wj-router-link.js +22 -17
  63. package/dist/wj-router-outlet.js +135 -71
  64. package/dist/wj-routerx.js +1124 -641
  65. package/dist/wj-row.js +21 -19
  66. package/dist/wj-slider.js +97 -55
  67. package/dist/wj-split-view.js +81 -43
  68. package/dist/wj-store.js +195 -110
  69. package/dist/wj-textarea.js +86 -37
  70. package/dist/wj-thumbnail.js +19 -15
  71. package/dist/wj-toast.js +87 -34
  72. package/dist/wj-toggle.js +42 -24
  73. package/dist/wj-toolbar-action.js +27 -16
  74. package/dist/wj-toolbar.js +26 -19
  75. package/dist/wj-tooltip.js +40 -24
  76. package/dist/wj-visually-hidden.js +18 -14
  77. package/package.json +1 -1
  78. package/dist/localize-762a9f0f.js +0 -43
  79. package/dist/router-links-e0087f84.js +0 -146
@@ -1,22 +1,34 @@
1
- var g = Object.defineProperty;
2
- var h = (n, i, t) => i in n ? g(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
3
- var d = (n, i, t) => (h(n, typeof i != "symbol" ? i + "" : i, t), t);
4
- import v from "./wj-element.js";
5
- import { L as p } from "./localize-762a9f0f.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import WJElement from "./wj-element.js";
8
+ import { L as Localizer } from "./localize-20081fd1.js";
6
9
  import "./wj-store.js";
7
- const w = "";
8
- class S extends v {
10
+ const styles = "/*\n[ WJ Avatar ]\n*/";
11
+ class RelativeTime extends WJElement {
9
12
  constructor() {
10
13
  super();
11
- d(this, "className", "RelativeTime");
12
- this.localizer = new p(this);
14
+ __publicField(this, "className", "RelativeTime");
15
+ this.localizer = new Localizer(this);
13
16
  }
14
17
  get dateISO() {
15
- let t = /* @__PURE__ */ new Date(), e = this.getAttribute("date");
16
- return this.hasAttribute("date") && (this.isISODate(e) ? e = e : e = +e * 1e3, t = new Date(e)), t.toISOString();
18
+ let date = /* @__PURE__ */ new Date();
19
+ let inputDate = this.getAttribute("date");
20
+ if (this.hasAttribute("date")) {
21
+ if (this.isISODate(inputDate)) {
22
+ inputDate = inputDate;
23
+ } else {
24
+ inputDate = +inputDate * 1e3;
25
+ }
26
+ date = new Date(inputDate);
27
+ }
28
+ return date.toISOString();
17
29
  }
18
30
  static get cssStyleSheet() {
19
- return w;
31
+ return styles;
20
32
  }
21
33
  static get observedAttributes() {
22
34
  return [""];
@@ -24,27 +36,39 @@ class S extends v {
24
36
  setupAttributes() {
25
37
  this.isShadowRoot = "open";
26
38
  }
27
- draw(t, e, l) {
28
- let s = document.createDocumentFragment(), a = document.createElement("div");
29
- return a.setAttribute("part", "native"), a.classList.add("native-relative-time"), a.innerText = this.getRelativeTimeString(this.dateISO), s.appendChild(a), s;
39
+ draw(context, store, params) {
40
+ let fragment = document.createDocumentFragment();
41
+ let element = document.createElement("div");
42
+ element.setAttribute("part", "native");
43
+ element.classList.add("native-relative-time");
44
+ element.innerText = this.getRelativeTimeString(this.dateISO);
45
+ fragment.appendChild(element);
46
+ return fragment;
30
47
  }
31
- getRelativeTimeString(t, e = navigator.language) {
32
- const s = new Date(t).getTime(), a = Math.round((s - Date.now()) / 1e3), o = [
48
+ getRelativeTimeString(date, lang = navigator.language) {
49
+ let dateObj = new Date(date);
50
+ const timeMs = dateObj.getTime();
51
+ const deltaSeconds = Math.round((timeMs - Date.now()) / 1e3);
52
+ const cutoffs = [
33
53
  60,
34
54
  3600,
35
55
  86400,
36
56
  86400 * 7,
37
57
  86400 * 30,
38
58
  86400 * 365,
39
- 1 / 0
40
- ], m = ["second", "minute", "hour", "day", "week", "month", "year"], r = o.findIndex((u) => u > Math.abs(a)), c = r ? o[r - 1] : 1;
41
- return this.localizer.relativeTime(Math.floor(a / c), m[r], { numeric: "auto" });
59
+ Infinity
60
+ ];
61
+ const units = ["second", "minute", "hour", "day", "week", "month", "year"];
62
+ const unitIndex = cutoffs.findIndex((cutoff) => cutoff > Math.abs(deltaSeconds));
63
+ const divisor = unitIndex ? cutoffs[unitIndex - 1] : 1;
64
+ return this.localizer.relativeTime(Math.floor(deltaSeconds / divisor), units[unitIndex], { numeric: "auto" });
42
65
  }
43
- isISODate(t) {
44
- return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$/.test(t);
66
+ isISODate(str) {
67
+ let regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$/;
68
+ return regex.test(str);
45
69
  }
46
70
  }
47
- customElements.get("wj-relative-time") || window.customElements.define("wj-relative-time", S);
71
+ customElements.get("wj-relative-time") || window.customElements.define("wj-relative-time", RelativeTime);
48
72
  export {
49
- S as RelativeTime
73
+ RelativeTime
50
74
  };
package/dist/wj-route.js CHANGED
@@ -1,18 +1,21 @@
1
- var r = Object.defineProperty;
2
- var u = (t, e, o) => e in t ? r(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var s = (t, e, o) => (u(t, typeof e != "symbol" ? e + "" : e, o), o);
4
- import m from "./wj-element.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import WJElement from "./wj-element.js";
5
8
  import "./wj-store.js";
6
- class n extends m {
9
+ class Route extends WJElement {
7
10
  constructor() {
8
11
  super();
9
- s(this, "className", "Route");
12
+ __publicField(this, "className", "Route");
10
13
  }
11
14
  static get observedAttributes() {
12
15
  return [];
13
16
  }
14
17
  }
15
- customElements.get("wj-route") || window.customElements.define("wj-route", n);
18
+ customElements.get("wj-route") || window.customElements.define("wj-route", Route);
16
19
  export {
17
- n as Route
20
+ Route
18
21
  };
@@ -1,35 +1,40 @@
1
- var i = Object.defineProperty;
2
- var c = (e, t, s) => t in e ? i(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var n = (e, t, s) => (c(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- import a from "./wj-element.js";
5
- import { b as u } from "./router-links-e0087f84.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import WJElement from "./wj-element.js";
8
+ import { b as bindRouterLinks } from "./router-links-26e4a166.js";
6
9
  import "./wj-store.js";
7
- const l = `:host{display:block;background:transparent!important}:host(.active){cursor:pointer;font-weight:700}
8
- `;
9
- class m extends a {
10
+ const styles = "/*\n[ WJ Router Link ]\n*/\n:host {\n display: block;\n background: transparent !important;\n}\n\n:host(.active) {\n cursor: pointer;\n font-weight: bold;\n}";
11
+ class RouterLink extends WJElement {
10
12
  constructor() {
11
13
  super();
12
- n(this, "className", "RouterLink");
13
- this.unbindRouterLinks = u(this, { selector: !1 });
14
+ __publicField(this, "className", "RouterLink");
15
+ this.unbindRouterLinks = bindRouterLinks(this, { selector: false });
14
16
  }
15
17
  static get cssStyleSheet() {
16
- return l;
18
+ return styles;
17
19
  }
18
20
  static get observedAttributes() {
19
21
  return [];
20
22
  }
21
23
  setupAttributes() {
22
- this.isShadowRoot = "open", this.setAttribute("active-class", "active");
24
+ this.isShadowRoot = "open";
25
+ this.setAttribute("active-class", "active");
23
26
  }
24
- draw(s, d, p) {
25
- let r = document.createDocumentFragment(), o = document.createElement("slot");
26
- return r.appendChild(o), r;
27
+ draw(context, store, params) {
28
+ let fragment = document.createDocumentFragment();
29
+ let element = document.createElement("slot");
30
+ fragment.appendChild(element);
31
+ return fragment;
27
32
  }
28
33
  beforeDisconnect() {
29
34
  this.unbindRouterLinks();
30
35
  }
31
36
  }
32
- customElements.get("wj-router-link") || window.customElements.define("wj-router-link", m);
37
+ customElements.get("wj-router-link") || window.customElements.define("wj-router-link", RouterLink);
33
38
  export {
34
- m as RouterLink
39
+ RouterLink
35
40
  };
@@ -1,111 +1,175 @@
1
1
  import "./wj-element.js";
2
2
  import "./wj-store.js";
3
- class E {
4
- constructor(t = {}) {
5
- this.options = t;
3
+ class AnimationHook {
4
+ constructor(options = {}) {
5
+ this.options = options;
6
6
  }
7
- getOption(t, n) {
8
- return t.hasAttribute(n) ? t.getAttribute(n) : this.options[n];
7
+ getOption(outlet, name) {
8
+ return outlet.hasAttribute(name) ? outlet.getAttribute(name) : this.options[name];
9
9
  }
10
- hasOption(t, n) {
11
- return t.hasAttribute(n) || this.options[n];
10
+ hasOption(outlet, name) {
11
+ return outlet.hasAttribute(name) || this.options[name];
12
12
  }
13
- runParallel(t) {
14
- return this.hasOption(t, "parallel");
13
+ runParallel(outlet) {
14
+ return this.hasOption(outlet, "parallel");
15
15
  }
16
- beforeEnter(t, n) {
16
+ beforeEnter(outlet, el) {
17
17
  }
18
- enter(t, n) {
18
+ enter(outlet, el) {
19
19
  }
20
- leave(t, n, e) {
21
- e();
20
+ leave(outlet, el, done) {
21
+ done();
22
22
  }
23
23
  }
24
- var v = window.requestAnimationFrame, m = "transition", T = "animation", p = "transition", C = "transitionend", d = "animation", b = "animationend";
25
- function $(i) {
26
- window.scrollTo(0, 0), v(function() {
27
- window.scrollTo(0, 0), v(i);
24
+ var raf = window.requestAnimationFrame;
25
+ var TRANSITION = "transition";
26
+ var ANIMATION = "animation";
27
+ var transitionProp = "transition";
28
+ var transitionEndEvent = "transitionend";
29
+ var animationProp = "animation";
30
+ var animationEndEvent = "animationend";
31
+ function nextFrame(fn) {
32
+ window.scrollTo(0, 0);
33
+ raf(function() {
34
+ window.scrollTo(0, 0);
35
+ raf(fn);
28
36
  });
29
37
  }
30
- function L(i, t) {
31
- var n = D(i), e = n.type, r = n.timeout, l = n.propCount;
32
- if (!e)
33
- return t();
34
- var s = e === m ? C : b, u = 0, o = function() {
35
- i.removeEventListener(s, a), t();
36
- }, a = function(h) {
37
- h.target === i && ++u >= l && o();
38
+ function whenTransitionEnds(el, cb) {
39
+ var ref = getTransitionInfo(el);
40
+ var type = ref.type;
41
+ var timeout = ref.timeout;
42
+ var propCount = ref.propCount;
43
+ if (!type) {
44
+ return cb();
45
+ }
46
+ var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
47
+ var ended = 0;
48
+ var end = function() {
49
+ el.removeEventListener(event, onEnd);
50
+ cb();
51
+ };
52
+ var onEnd = function(e) {
53
+ if (e.target === el) {
54
+ if (++ended >= propCount) {
55
+ end();
56
+ }
57
+ }
38
58
  };
39
59
  setTimeout(function() {
40
- u < l && o();
41
- }, r + 1), i.addEventListener(s, a);
60
+ if (ended < propCount) {
61
+ end();
62
+ }
63
+ }, timeout + 1);
64
+ el.addEventListener(event, onEnd);
42
65
  }
43
- function D(i) {
44
- var t = window.getComputedStyle(i), n = (t[p + "Delay"] || "").split(", "), e = (t[p + "Duration"] || "").split(", "), r = c(n, e), l = (t[d + "Delay"] || "").split(", "), s = (t[d + "Duration"] || "").split(", "), u = c(l, s), o, a = 0, h = 0;
45
- return a = Math.max(r, u), o = a > 0 ? r > u ? m : T : null, h = o ? o === m ? e.length : s.length : 0, {
46
- type: o,
47
- timeout: a,
48
- propCount: h
66
+ function getTransitionInfo(el) {
67
+ var styles = window.getComputedStyle(el);
68
+ var transitionDelays = (styles[transitionProp + "Delay"] || "").split(", ");
69
+ var transitionDurations = (styles[transitionProp + "Duration"] || "").split(", ");
70
+ var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
71
+ var animationDelays = (styles[animationProp + "Delay"] || "").split(", ");
72
+ var animationDurations = (styles[animationProp + "Duration"] || "").split(", ");
73
+ var animationTimeout = getTimeout(animationDelays, animationDurations);
74
+ var type;
75
+ var timeout = 0;
76
+ var propCount = 0;
77
+ timeout = Math.max(transitionTimeout, animationTimeout);
78
+ type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
79
+ propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
80
+ return {
81
+ type,
82
+ timeout,
83
+ propCount
49
84
  };
50
85
  }
51
- function c(i, t) {
52
- for (; i.length < t.length; )
53
- i = i.concat(i);
54
- return Math.max.apply(null, t.map(function(n, e) {
55
- return f(n) + f(i[e]);
86
+ function getTimeout(delays, durations) {
87
+ while (delays.length < durations.length) {
88
+ delays = delays.concat(delays);
89
+ }
90
+ return Math.max.apply(null, durations.map(function(d, i) {
91
+ return toMs(d) + toMs(delays[i]);
56
92
  }));
57
93
  }
58
- function f(i) {
59
- return Number(i.slice(0, -1).replace(",", ".")) * 1e3;
94
+ function toMs(s) {
95
+ return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
60
96
  }
61
- function g(i, t, n, e) {
62
- i.classList.add(`${t}-${n}-active`), $(function() {
63
- window.scrollTo(0, 0), i.classList.remove(`${t}-${n}`), i.classList.add(`${t}-${n}-to`), L(i, function() {
64
- i.classList.remove(`${t}-${n}-active`, `${t}-${n}-to`), e && e();
97
+ function runTransition(el, name, type, cb) {
98
+ el.classList.add(`${name}-${type}-active`);
99
+ nextFrame(function() {
100
+ window.scrollTo(0, 0);
101
+ el.classList.remove(`${name}-${type}`);
102
+ el.classList.add(`${name}-${type}-to`);
103
+ whenTransitionEnds(el, function() {
104
+ el.classList.remove(`${name}-${type}-active`, `${name}-${type}-to`);
105
+ if (cb)
106
+ cb();
65
107
  });
66
108
  });
67
109
  }
68
- class N extends E {
69
- beforeEnter(t, n) {
70
- const e = t.getAttribute("animation") || "outlet";
71
- n.classList.add(`${e}-enter`);
110
+ class GenericCSS extends AnimationHook {
111
+ beforeEnter(outlet, el) {
112
+ const name = outlet.getAttribute("animation") || "outlet";
113
+ el.classList.add(`${name}-enter`);
72
114
  }
73
- enter(t, n) {
74
- const e = t.getAttribute("animation") || "outlet";
75
- g(n, e, "enter");
115
+ enter(outlet, el) {
116
+ const name = outlet.getAttribute("animation") || "outlet";
117
+ runTransition(el, name, "enter");
76
118
  }
77
- leave(t, n, e) {
78
- const r = t.getAttribute("animation") || "outlet";
79
- n.classList.add(`${r}-leave`), n.style.display = "none", g(n, r, "leave", e);
119
+ leave(outlet, el, done) {
120
+ const name = outlet.getAttribute("animation") || "outlet";
121
+ el.classList.add(`${name}-leave`);
122
+ el.style.display = "none";
123
+ runTransition(el, name, "leave", done);
80
124
  }
81
125
  }
82
- const O = {};
83
- let w;
84
- function A(i) {
85
- return O[i] || w || (w = new N());
126
+ const animationRegistry = {};
127
+ let defaultHook;
128
+ function getAnimationHook(name) {
129
+ return animationRegistry[name] || defaultHook || (defaultHook = new GenericCSS());
86
130
  }
87
- class k extends HTMLElement {
88
- appendChild(t) {
131
+ class AnimatedOutlet extends HTMLElement {
132
+ appendChild(el) {
89
133
  if (!this.hasAttribute("animation")) {
90
- super.appendChild(t);
134
+ super.appendChild(el);
91
135
  return;
92
136
  }
93
- const n = A(this.getAttribute("animation")), e = n.runParallel(this);
94
- n.beforeEnter(this, t), super.appendChild(t), !e && this.removing ? this.appending = t : n.enter(this, t);
137
+ const hook = getAnimationHook(this.getAttribute("animation"));
138
+ const runParallel = hook.runParallel(this);
139
+ hook.beforeEnter(this, el);
140
+ super.appendChild(el);
141
+ if (!runParallel && this.removing) {
142
+ this.appending = el;
143
+ } else {
144
+ hook.enter(this, el);
145
+ }
95
146
  }
96
- removeChild(t) {
147
+ removeChild(el) {
97
148
  if (!this.hasAttribute("animation")) {
98
- super.removeChild(t);
149
+ super.removeChild(el);
99
150
  return;
100
151
  }
101
- const n = A(this.getAttribute("animation"));
102
- if (this.removing && this.removing.parentNode === this && super.removeChild(this.removing), t === this.appending) {
103
- t.parentNode === this && super.removeChild(t), this.removing = null;
152
+ const hook = getAnimationHook(this.getAttribute("animation"));
153
+ if (this.removing && this.removing.parentNode === this) {
154
+ super.removeChild(this.removing);
155
+ }
156
+ if (el === this.appending) {
157
+ if (el.parentNode === this) {
158
+ super.removeChild(el);
159
+ }
160
+ this.removing = null;
104
161
  return;
105
162
  }
106
- this.removing = t, n.leave(this, t, () => {
107
- this.removing && this.removing.parentNode === this && super.removeChild(this.removing), this.appending && n.enter(this, this.appending), this.appending = null, this.removing = null;
163
+ this.removing = el;
164
+ hook.leave(this, el, () => {
165
+ if (this.removing && this.removing.parentNode === this) {
166
+ super.removeChild(this.removing);
167
+ }
168
+ if (this.appending)
169
+ hook.enter(this, this.appending);
170
+ this.appending = null;
171
+ this.removing = null;
108
172
  });
109
173
  }
110
174
  }
111
- customElements.get("wj-router-outlet") || window.customElements.define("wj-router-outlet", k);
175
+ customElements.get("wj-router-outlet") || window.customElements.define("wj-router-outlet", AnimatedOutlet);