wj-elements 0.0.3 → 0.0.4

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 (66) hide show
  1. package/dist/router-links-e0087f84.js +146 -0
  2. package/dist/style.css +2 -2365
  3. package/dist/wj-aside.js +18 -22
  4. package/dist/wj-avatar.js +32 -49
  5. package/dist/wj-badge.js +18 -22
  6. package/dist/wj-breadcrumb.js +53 -103
  7. package/dist/wj-breadcrumbs.js +21 -36
  8. package/dist/wj-button-group.js +24 -36
  9. package/dist/wj-button.js +37 -80
  10. package/dist/wj-card-content.js +16 -18
  11. package/dist/wj-card-controls.js +16 -18
  12. package/dist/wj-card-header.js +16 -20
  13. package/dist/wj-card-subtitle.js +17 -19
  14. package/dist/wj-card-title.js +16 -18
  15. package/dist/wj-card.js +16 -20
  16. package/dist/wj-checkbox.js +24 -46
  17. package/dist/wj-chip.js +21 -39
  18. package/dist/wj-col.js +18 -32
  19. package/dist/wj-color-picker.js +503 -868
  20. package/dist/wj-container.js +18 -20
  21. package/dist/wj-copy-button.js +66 -112
  22. package/dist/wj-dialog.js +43 -67
  23. package/dist/wj-divider.js +16 -20
  24. package/dist/wj-dropdown.js +22 -31
  25. package/dist/wj-element.js +241 -416
  26. package/dist/wj-footer.js +16 -18
  27. package/dist/wj-form.js +16 -18
  28. package/dist/wj-grid.js +17 -21
  29. package/dist/wj-header.js +18 -22
  30. package/dist/wj-icon-picker.js +66 -107
  31. package/dist/wj-icon.js +67 -142
  32. package/dist/wj-img-comparer.js +43 -72
  33. package/dist/wj-img.js +21 -31
  34. package/dist/wj-infinite-scroll.js +49 -84
  35. package/dist/wj-input.js +67 -146
  36. package/dist/wj-item.js +19 -34
  37. package/dist/wj-label.js +19 -21
  38. package/dist/wj-list.js +17 -20
  39. package/dist/wj-main.js +16 -18
  40. package/dist/wj-master.js +331 -462
  41. package/dist/wj-menu-button.js +18 -21
  42. package/dist/wj-menu-item.js +67 -144
  43. package/dist/wj-menu-label.js +17 -21
  44. package/dist/wj-menu.js +20 -24
  45. package/dist/wj-popup.js +714 -1140
  46. package/dist/wj-progress-bar.js +42 -100
  47. package/dist/wj-radio-group.js +27 -38
  48. package/dist/wj-radio.js +24 -46
  49. package/dist/wj-route.js +8 -11
  50. package/dist/wj-router-link.js +19 -22
  51. package/dist/wj-router-outlet.js +71 -135
  52. package/dist/wj-routerx.js +641 -1121
  53. package/dist/wj-row.js +20 -22
  54. package/dist/wj-slider.js +55 -97
  55. package/dist/wj-split-view.js +45 -81
  56. package/dist/wj-store.js +110 -195
  57. package/dist/wj-textarea.js +39 -86
  58. package/dist/wj-thumbnail.js +17 -19
  59. package/dist/wj-toast.js +34 -88
  60. package/dist/wj-toggle.js +24 -42
  61. package/dist/wj-toolbar-action.js +16 -27
  62. package/dist/wj-toolbar.js +21 -26
  63. package/dist/wj-tooltip.js +27 -41
  64. package/dist/wj-visually-hidden.js +16 -18
  65. package/package.json +1 -1
  66. package/dist/router-links-26e4a166.js +0 -204
@@ -1,175 +1,111 @@
1
1
  import "./wj-element.js";
2
2
  import "./wj-store.js";
3
- class AnimationHook {
4
- constructor(options = {}) {
5
- this.options = options;
3
+ class E {
4
+ constructor(t = {}) {
5
+ this.options = t;
6
6
  }
7
- getOption(outlet, name) {
8
- return outlet.hasAttribute(name) ? outlet.getAttribute(name) : this.options[name];
7
+ getOption(t, n) {
8
+ return t.hasAttribute(n) ? t.getAttribute(n) : this.options[n];
9
9
  }
10
- hasOption(outlet, name) {
11
- return outlet.hasAttribute(name) || this.options[name];
10
+ hasOption(t, n) {
11
+ return t.hasAttribute(n) || this.options[n];
12
12
  }
13
- runParallel(outlet) {
14
- return this.hasOption(outlet, "parallel");
13
+ runParallel(t) {
14
+ return this.hasOption(t, "parallel");
15
15
  }
16
- beforeEnter(outlet, el) {
16
+ beforeEnter(t, n) {
17
17
  }
18
- enter(outlet, el) {
18
+ enter(t, n) {
19
19
  }
20
- leave(outlet, el, done) {
21
- done();
20
+ leave(t, n, e) {
21
+ e();
22
22
  }
23
23
  }
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);
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);
36
28
  });
37
29
  }
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
- }
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();
58
38
  };
59
39
  setTimeout(function() {
60
- if (ended < propCount) {
61
- end();
62
- }
63
- }, timeout + 1);
64
- el.addEventListener(event, onEnd);
40
+ u < l && o();
41
+ }, r + 1), i.addEventListener(s, a);
65
42
  }
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
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
84
49
  };
85
50
  }
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]);
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]);
92
56
  }));
93
57
  }
94
- function toMs(s) {
95
- return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
58
+ function f(i) {
59
+ return Number(i.slice(0, -1).replace(",", ".")) * 1e3;
96
60
  }
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();
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();
107
65
  });
108
66
  });
109
67
  }
110
- class GenericCSS extends AnimationHook {
111
- beforeEnter(outlet, el) {
112
- const name = outlet.getAttribute("animation") || "outlet";
113
- el.classList.add(`${name}-enter`);
68
+ class N extends E {
69
+ beforeEnter(t, n) {
70
+ const e = t.getAttribute("animation") || "outlet";
71
+ n.classList.add(`${e}-enter`);
114
72
  }
115
- enter(outlet, el) {
116
- const name = outlet.getAttribute("animation") || "outlet";
117
- runTransition(el, name, "enter");
73
+ enter(t, n) {
74
+ const e = t.getAttribute("animation") || "outlet";
75
+ g(n, e, "enter");
118
76
  }
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);
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);
124
80
  }
125
81
  }
126
- const animationRegistry = {};
127
- let defaultHook;
128
- function getAnimationHook(name) {
129
- return animationRegistry[name] || defaultHook || (defaultHook = new GenericCSS());
82
+ const O = {};
83
+ let w;
84
+ function A(i) {
85
+ return O[i] || w || (w = new N());
130
86
  }
131
- class AnimatedOutlet extends HTMLElement {
132
- appendChild(el) {
87
+ class k extends HTMLElement {
88
+ appendChild(t) {
133
89
  if (!this.hasAttribute("animation")) {
134
- super.appendChild(el);
90
+ super.appendChild(t);
135
91
  return;
136
92
  }
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
- }
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);
146
95
  }
147
- removeChild(el) {
96
+ removeChild(t) {
148
97
  if (!this.hasAttribute("animation")) {
149
- super.removeChild(el);
98
+ super.removeChild(t);
150
99
  return;
151
100
  }
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;
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;
161
104
  return;
162
105
  }
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;
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;
172
108
  });
173
109
  }
174
110
  }
175
- customElements.get("wj-router-outlet") || window.customElements.define("wj-router-outlet", AnimatedOutlet);
111
+ customElements.get("wj-router-outlet") || window.customElements.define("wj-router-outlet", k);