@pacem/pacem-ui 1.0.0-abel

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 (56) hide show
  1. package/LICENSE +191 -0
  2. package/NOTICE +4 -0
  3. package/dist/browser/pacem-ui.js +6343 -0
  4. package/dist/browser/pacem-ui.js.map +1 -0
  5. package/dist/browser/pacem-ui.min.js +2 -0
  6. package/dist/browser/pacem-ui.min.js.map +1 -0
  7. package/dist/bundle/pacem-ui.min.mjs +168 -0
  8. package/dist/bundle/pacem-ui.mjs +6276 -0
  9. package/dist/bundle/pacem-ui.mjs.map +7 -0
  10. package/dist/esm/adapter.js +360 -0
  11. package/dist/esm/anchor.js +149 -0
  12. package/dist/esm/balloon.js +583 -0
  13. package/dist/esm/binder.js +678 -0
  14. package/dist/esm/blade.js +31 -0
  15. package/dist/esm/bottom-sheet.js +277 -0
  16. package/dist/esm/button.js +100 -0
  17. package/dist/esm/buttonset.js +41 -0
  18. package/dist/esm/calendar.js +662 -0
  19. package/dist/esm/collapse.js +72 -0
  20. package/dist/esm/dialog-abstractions.js +61 -0
  21. package/dist/esm/dialog.js +102 -0
  22. package/dist/esm/divider.js +48 -0
  23. package/dist/esm/icon.js +131 -0
  24. package/dist/esm/image.js +109 -0
  25. package/dist/esm/index-components-ui.js +41 -0
  26. package/dist/esm/index-components.js +1 -0
  27. package/dist/esm/index-iife.js +3 -0
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/infinite-scroller.js +137 -0
  30. package/dist/esm/iterative.js +45 -0
  31. package/dist/esm/lightbox-abstractions.js +6 -0
  32. package/dist/esm/lightbox.js +203 -0
  33. package/dist/esm/loader.js +100 -0
  34. package/dist/esm/markdown-svc.js +235 -0
  35. package/dist/esm/markdown.js +35 -0
  36. package/dist/esm/marquee.js +87 -0
  37. package/dist/esm/media-query.js +85 -0
  38. package/dist/esm/menu.js +165 -0
  39. package/dist/esm/pager.js +111 -0
  40. package/dist/esm/picture.js +157 -0
  41. package/dist/esm/progressbar.js +54 -0
  42. package/dist/esm/sidebar.js +60 -0
  43. package/dist/esm/slideshow.js +27 -0
  44. package/dist/esm/social-twitter.js +39 -0
  45. package/dist/esm/sticky-header.js +113 -0
  46. package/dist/esm/tabs.js +187 -0
  47. package/dist/esm/ticker.js +78 -0
  48. package/dist/esm/toast.js +171 -0
  49. package/dist/esm/toc.js +171 -0
  50. package/dist/esm/tuner.js +200 -0
  51. package/dist/esm/types.js +7 -0
  52. package/dist/esm/vibration.js +33 -0
  53. package/dist/esm/view.js +206 -0
  54. package/dist/esm/window.js +181 -0
  55. package/package.json +38 -0
  56. package/typings/index.d.ts +1165 -0
@@ -0,0 +1,235 @@
1
+ import { Compile } from '@pacem/pacem-foundation';
2
+ import { P } from '@pacem/pacem-core';
3
+ //namespace Pacem {
4
+ const match = (input, pattern, fn) => {
5
+ const arr = pattern.exec(input);
6
+ if (arr && arr.length) {
7
+ return fn(arr);
8
+ }
9
+ return null;
10
+ };
11
+ const MARKUP_RULES = [
12
+ {
13
+ // comment
14
+ exec: (input) => match(input, /^((<|&lt;)!--(?:(?!(--(>|&gt;)))[\s\S])*(--(?:>|&gt;)|$))/, arr => {
15
+ const raw = arr[0], text = raw;
16
+ return [{
17
+ type: 'code-comment', raw, text, index: arr.index
18
+ }];
19
+ })
20
+ },
21
+ {
22
+ // opening/self-closing tag
23
+ exec: (input, lexer) => match(input, /^(<|&lt;)([\w-]+)(?:\s+[\w-]+(?:=(?:'[^']*'|"[^"]*"))*)*(\s*\/?(?:&gt;|>))/, arr => {
24
+ const openingTag = arr[1], tagName = arr[2], closingTag = arr[3];
25
+ const closingTagIndex = arr[0].length - closingTag.length, attributesIndex = openingTag.length + tagName.length, attributesString = input.substring(attributesIndex, closingTagIndex);
26
+ const attributes = lexer.tokenize(attributesString, [{
27
+ exec: (input) => match(input, /^(\s+[\w-]+)(=('[^']*'|"[^"]*"))?/, arr => {
28
+ const raw = arr[1];
29
+ const output = [{
30
+ type: 'code-attribute', raw, text: raw, index: arr[0].indexOf(raw)
31
+ }];
32
+ if (arr.length > 2) {
33
+ output.push({
34
+ type: 'code-string', raw: arr[2], text: arr[2], index: arr.index + arr[0].length - arr[2].length
35
+ });
36
+ }
37
+ return output;
38
+ })
39
+ }]);
40
+ const retval = [{
41
+ type: 'code-tag', raw: openingTag, text: openingTag, index: 0
42
+ }, {
43
+ type: 'code-tagname', raw: tagName, text: tagName, index: openingTag.length
44
+ }];
45
+ // attributes
46
+ Array.prototype.push.apply(retval, attributes);
47
+ retval.push({
48
+ type: 'code-tag', raw: closingTag, text: closingTag, index: closingTagIndex
49
+ });
50
+ return retval;
51
+ })
52
+ },
53
+ {
54
+ // closing tag
55
+ exec: (input) => match(input, /^((?:<|&lt;)\/)([\w-]+)(\s*(?:&gt;|>))/, arr => {
56
+ const openingTag = arr[1], tagName = arr[2], closingTag = arr[3];
57
+ return [{
58
+ type: 'code-tag', raw: openingTag, text: openingTag, index: 0
59
+ }, {
60
+ type: 'code-tagname', raw: tagName, text: tagName, index: openingTag.length
61
+ }, {
62
+ type: 'code-tag', raw: closingTag, text: closingTag, index: arr.index + arr[0].length - closingTag.length
63
+ }];
64
+ })
65
+ },
66
+ {
67
+ // text
68
+ exec: (input) => match(input, /^(<|&lt;)?((?!<|&lt;).)+/, arr => {
69
+ const raw = arr[0], text = raw;
70
+ return [{
71
+ type: 'text', raw, text
72
+ }];
73
+ })
74
+ }
75
+ ];
76
+ const C_LIKE_RULES = [{
77
+ // comments
78
+ exec: (input, _) => match(input, /^\/\/.*/, arr => {
79
+ const raw = arr[0], text = raw;
80
+ return [{
81
+ type: 'code-comment', raw, text
82
+ }];
83
+ })
84
+ }, {
85
+ exec: (input, _) => match(input, /^\/\*(?:(?!(\*\/))[\s\S])*(?:\*\/|$)/, arr => {
86
+ const raw = arr[0], text = raw;
87
+ return [{
88
+ type: 'code-comment', raw, text
89
+ }];
90
+ })
91
+ }, {
92
+ // string literal
93
+ exec: (input, _) => match(input, /^('(\\'|[^'])*[^\\]?'|@?\$?"(\\"|[^"])*[^\\]?")/, arr => {
94
+ const raw = arr[0], text = raw;
95
+ return [{
96
+ type: 'code-string', raw, text
97
+ }];
98
+ })
99
+ }, {
100
+ // keywords
101
+ exec: (input, _) => match(input, /^\b(abstract|as|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|static|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|nameof|orderby|partial|remove|select|set|value|var|when|where|yield)\b/, arr => {
102
+ const raw = arr[0], text = raw;
103
+ return [{
104
+ type: 'code-keyword', raw, text
105
+ }];
106
+ })
107
+ }, {
108
+ // number
109
+ exec: (input, _) => match(input, /^\b((0x[0-9a-fA-F]|[\d])*\.?[\d]+)\b/, arr => {
110
+ const raw = arr[0], text = raw;
111
+ return [{
112
+ type: 'code-number', raw, text
113
+ }];
114
+ })
115
+ }, {
116
+ // variables, operators, parentheses
117
+ exec: (input, _) => match(input, /^(@?\w+|:|\?\??|\?=?|\|\|?|&&?|&=?|;|,|=|\*=?|--|-=?|\+\+|\+=?|\/=?|\^|\(|\[|\)|\]|\{|\})/, arr => {
118
+ const raw = arr[0], text = raw;
119
+ return [{
120
+ type: 'text', raw, text
121
+ }];
122
+ }),
123
+ }, {
124
+ // spaces
125
+ exec: (input, _) => match(input, /^\s+/, arr => {
126
+ const raw = arr[0], text = raw;
127
+ return [{
128
+ type: 'space', raw, text
129
+ }];
130
+ }),
131
+ }];
132
+ const SCRIPT_RULES = [
133
+ C_LIKE_RULES[0], C_LIKE_RULES[1], {
134
+ // string literal
135
+ exec: (input, _) => match(input, /^('(\\'|[^'])*[^\\]?'|"(\\"|[^"])*[^\\]?"|`(\\`|[^`])*[^\\]?`)/, arr => {
136
+ const raw = arr[0], text = raw;
137
+ return [{
138
+ type: 'code-string', raw, text
139
+ }];
140
+ })
141
+ }, {
142
+ // keywords
143
+ exec: (input, _) => match(input, /^\b(abstract|any|arguments|async|await|boolean|break|byte|case|catch|char|class|const|continue|debugger|declare|default|delete|do|double|else|enum|eval|export|extends|false|final|finally|float|for|function|get|goto|if|implements|import|in|instanceof|int|interface|let|long|native|new|null|number|package|private|protected|public|return|short|static|string|super|switch|synchronized|this|throw|throws|transient|true|try|type|typeof|var|void|volatile|while|with|yield)\b/, arr => {
144
+ const raw = arr[0], text = raw;
145
+ return [{
146
+ type: 'code-keyword', raw, text
147
+ }];
148
+ })
149
+ },
150
+ C_LIKE_RULES[4],
151
+ C_LIKE_RULES[5],
152
+ C_LIKE_RULES[6]
153
+ ];
154
+ const TWITTER_RULE = {
155
+ rule: {
156
+ exec: (input) => {
157
+ const arr = /\{tweet\}\(([^\)]+)\)/.exec(input);
158
+ if (arr && arr.length > 1) {
159
+ return [{
160
+ type: 'tweet', raw: arr[0], text: arr[1], index: arr.index
161
+ }];
162
+ }
163
+ return null;
164
+ }
165
+ },
166
+ type: 'inline'
167
+ };
168
+ const YOUTUBE_RULE = {
169
+ rule: {
170
+ exec: (input) => {
171
+ const arr = /\{yt([\d]+x[\d]+)?\}\(([^\)]+)\)/.exec(input);
172
+ if (arr && arr.length > 2) {
173
+ const m0 = arr[1] || '560x315';
174
+ const size = m0.split('x'), w = size[0], h = size[1];
175
+ return [{
176
+ type: 'youtube', raw: arr[0], text: arr[2], index: arr.index, width: w, height: h
177
+ }];
178
+ }
179
+ return null;
180
+ }
181
+ },
182
+ type: 'inline'
183
+ };
184
+ const RULES_TO_HTML = (token) => {
185
+ switch (token.type) {
186
+ case 'youtube':
187
+ return `<!-- youtube embed -->
188
+ <iframe width="${token['width']}" height="${token['height']}" src="https://www.youtube-nocookie.com/embed/${token.text}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>`;
189
+ case 'tweet':
190
+ return `<!-- twitter embed -->
191
+ <${P}-tweetembed tweetid="${token.text}"></${P}-tweetembed>`;
192
+ // code
193
+ case 'code-string':
194
+ case 'code-keyword':
195
+ case 'code-number':
196
+ case 'code-comment':
197
+ case 'code-tag':
198
+ case 'code-tagname':
199
+ case 'code-attribute':
200
+ return `<span class="${token.type}">${token.text}</span>`;
201
+ }
202
+ };
203
+ export class MarkdownService {
204
+ constructor() {
205
+ const grammar = [
206
+ TWITTER_RULE,
207
+ YOUTUBE_RULE
208
+ ];
209
+ for (let lang of ['c-sharp', 'c', 'c#', 'csharp', 'c++', 'cpp']) {
210
+ const c_like_rules = C_LIKE_RULES.map(rule => { return { rule, lang, type: 'code' }; });
211
+ Array.prototype.push.apply(grammar, c_like_rules);
212
+ }
213
+ for (let lang of ['ts', 'js', 'typescript', 'javascript']) {
214
+ const script_rules = SCRIPT_RULES.map(rule => { return { rule, lang, type: 'code' }; });
215
+ Array.prototype.push.apply(grammar, script_rules);
216
+ }
217
+ for (let lang of ['xml', 'html']) {
218
+ const markup_rules = MARKUP_RULES.map(rule => { return { rule, lang, type: 'code' }; });
219
+ Array.prototype.push.apply(grammar, markup_rules);
220
+ }
221
+ this.#grammar = grammar;
222
+ }
223
+ #grammar;
224
+ #md = new Compile.Markdown.Parser();
225
+ _escape(md) {
226
+ // no html allowed
227
+ return (md ?? '').replace(/</g, '&lt;');
228
+ }
229
+ toHtml(md) {
230
+ return this.#md.toHtml(this._escape(md), this.#grammar, RULES_TO_HTML);
231
+ }
232
+ tokenize(md) {
233
+ return this.#md.tokenize(this._escape(md), this.#grammar);
234
+ }
235
+ }
@@ -0,0 +1,35 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { P, CustomElement, Watch, PropertyConverters, Components } from '@pacem/pacem-core';
8
+ import { MarkdownService } from './markdown-svc';
9
+ //namespace Pacem.Components.UI {
10
+ let PacemMarkdownElement = class PacemMarkdownElement extends Components.PacemElement {
11
+ constructor(_md = new MarkdownService()) {
12
+ super();
13
+ this._md = _md;
14
+ }
15
+ propertyChangedCallback(name, old, val, first) {
16
+ super.propertyChangedCallback(name, old, val, first);
17
+ if (name === 'value') {
18
+ this.innerHTML = this.html();
19
+ }
20
+ }
21
+ // IDEA: allow extensible parsing (grammar components?...)
22
+ tokens(md = this.value) {
23
+ return this._md.tokenize(md);
24
+ }
25
+ html(md = this.value) {
26
+ return this._md.toHtml(md);
27
+ }
28
+ };
29
+ __decorate([
30
+ Watch({ emit: false, converter: PropertyConverters.String })
31
+ ], PacemMarkdownElement.prototype, "value", void 0);
32
+ PacemMarkdownElement = __decorate([
33
+ CustomElement({ tagName: P + '-markdown' })
34
+ ], PacemMarkdownElement);
35
+ export { PacemMarkdownElement };
@@ -0,0 +1,87 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { P, PCSS, Utils, CustomElement, Watch, ViewChild, PropertyConverters, Components, Defaults } from '@pacem/pacem-core';
8
+ //namespace Pacem.Components.UI {
9
+ let PacemMarqueeElement = class PacemMarqueeElement extends Components.PacemElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._state = { overlap: 0, content: 0 };
13
+ }
14
+ // TODO: reuse css animation injection
15
+ connectedCallback() {
16
+ super.connectedCallback();
17
+ const css = this._css = document.createElement('style');
18
+ document.head.appendChild(css);
19
+ }
20
+ propertyChangedCallback(name, old, val, first) {
21
+ super.propertyChangedCallback(name, old, val, first);
22
+ if (name === 'speed') {
23
+ this._adjust();
24
+ }
25
+ }
26
+ viewActivatedCallback() {
27
+ super.viewActivatedCallback();
28
+ this._adjust();
29
+ }
30
+ disconnectedCallback() {
31
+ if (!Utils.isNull(this._css))
32
+ this._css.remove();
33
+ super.disconnectedCallback();
34
+ }
35
+ _overlapResize(evt) {
36
+ this._state.overlap = evt.detail.width;
37
+ this._adjust();
38
+ }
39
+ _contentResize(evt) {
40
+ this._state.content = evt.detail.width;
41
+ this._adjust();
42
+ }
43
+ _adjust() {
44
+ const state = this._state;
45
+ if (state.content > 0 && state.overlap > 0) {
46
+ const m = this._marquee;
47
+ const id = 'marquee-' + Utils.uniqueCode(), // rename the animation every time (Edge bug)
48
+ from = Math.round(state.overlap), to = -Math.round(state.content);
49
+ this._css.innerHTML = `@keyframes ${id} {
50
+ 0% {
51
+ transform: translateX(${from}px);
52
+ }
53
+
54
+ 100% {
55
+ transform: translateX(${to}px);
56
+ }
57
+ }`;
58
+ const speed = this.speed || 20;
59
+ const time = Math.max(speed, Math.round(speed * Math.abs(from - to) / 1920));
60
+ m.style.animationName = id;
61
+ m.style.animationDuration = time + 's';
62
+ m.style.animationIterationCount = 'infinite';
63
+ m.style.animationTimingFunction = 'linear';
64
+ }
65
+ }
66
+ };
67
+ __decorate([
68
+ ViewChild(`.${PCSS}-marquee`)
69
+ ], PacemMarqueeElement.prototype, "_marquee", void 0);
70
+ __decorate([
71
+ ViewChild(`.${PCSS}-marquee-overlap`)
72
+ ], PacemMarqueeElement.prototype, "_overlap", void 0);
73
+ __decorate([
74
+ ViewChild(P + "-resize")
75
+ ], PacemMarqueeElement.prototype, "_resizer", void 0);
76
+ __decorate([
77
+ Watch({ converter: PropertyConverters.Number })
78
+ ], PacemMarqueeElement.prototype, "speed", void 0);
79
+ PacemMarqueeElement = __decorate([
80
+ CustomElement({
81
+ tagName: P + '-marquee', shadow: Defaults.USE_SHADOW_ROOT,
82
+ template: `<div class="${PCSS}-marquee"><${P}-content></${P}-content></div><div class="${PCSS}-marquee-overlap"></div>
83
+ <${P}-resize target="{{ :host._overlap }}" on-${Components.ResizeEventName}=":host._overlapResize($event)"></${P}-resize>
84
+ <${P}-resize target="{{ :host._marquee }}" on-${Components.ResizeEventName}=":host._contentResize($event)"></${P}-resize>`
85
+ })
86
+ ], PacemMarqueeElement);
87
+ export { PacemMarqueeElement };
@@ -0,0 +1,85 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { P, Utils, CustomElement, Watch, PropertyConverters, PacemEventTarget } from '@pacem/pacem-core';
8
+ //namespace Pacem.Components.UI {
9
+ const THRESHOLD_SM = 768;
10
+ const THRESHOLD_MD = 992;
11
+ const THRESHOLD_LG = 1200;
12
+ const THRESHOLD_XL = 1824;
13
+ const THRESHOLD_HD = 1920;
14
+ const THRESHOLD_2K = 2048;
15
+ const THRESHOLD_4K = 3840;
16
+ export const MEDIAQUERY_XS = `(max-width: ${(THRESHOLD_SM - 1)}px)`;
17
+ export const MEDIAQUERY_SM = `(min-width: ${THRESHOLD_SM}px)`;
18
+ export const MEDIAQUERY_MD = `(min-width: ${THRESHOLD_MD}px)`;
19
+ export const MEDIAQUERY_LG = `(min-width: ${THRESHOLD_LG}px)`;
20
+ export const MEDIAQUERY_XL = `(min-width: ${THRESHOLD_XL}px)`;
21
+ export const MEDIAQUERY_HD = `(min-width: ${THRESHOLD_HD}px)`;
22
+ export const MEDIAQUERY_2K = `(min-width: ${THRESHOLD_2K}px)`;
23
+ export const MEDIAQUERY_4K = `(min-width: ${THRESHOLD_4K}px)`;
24
+ export const MEDIAQUERY_PORTRAIT = `(orientation: portrait)`;
25
+ export const MEDIAQUERY_LANDSCAPE = `(orientation: landscape)`;
26
+ export const MEDIAQUERY_PREFERS_LIGHT = `(prefers-color-scheme: light)`;
27
+ export const MEDIAQUERY_PREFERS_DARK = `(prefers-color-scheme: dark)`;
28
+ let PacemMediaQueryElement = class PacemMediaQueryElement extends PacemEventTarget {
29
+ constructor() {
30
+ super(...arguments);
31
+ this._changeHandler = (evt) => {
32
+ this.isMatch = evt.matches;
33
+ };
34
+ }
35
+ #mql;
36
+ viewActivatedCallback() {
37
+ super.viewActivatedCallback();
38
+ this._init();
39
+ }
40
+ propertyChangedCallback(name, old, val, first) {
41
+ super.propertyChangedCallback(name, old, val, first);
42
+ switch (name) {
43
+ case 'query':
44
+ if (!first) {
45
+ this._init();
46
+ }
47
+ break;
48
+ case 'isMatch':
49
+ // dedicated change events
50
+ this._broadcastChange(val);
51
+ break;
52
+ }
53
+ }
54
+ disconnectedCallback() {
55
+ this._init('');
56
+ super.disconnectedCallback();
57
+ }
58
+ _broadcastChange(val = this.isMatch) {
59
+ this.dispatchEvent(new Event('change'));
60
+ this.dispatchEvent(new Event(val ? 'match' : 'unmatch'));
61
+ }
62
+ _init(q = this.query) {
63
+ const old = this.#mql;
64
+ if (!Utils.isNull(old)) {
65
+ old.removeEventListener('change', this._changeHandler);
66
+ }
67
+ if (!Utils.isNullOrEmpty(q)) {
68
+ const val = this.#mql = window.matchMedia(q);
69
+ val.addEventListener('change', this._changeHandler);
70
+ this.isMatch = val.matches;
71
+ }
72
+ }
73
+ };
74
+ __decorate([
75
+ Watch({ emit: false, converter: PropertyConverters.String })
76
+ ], PacemMediaQueryElement.prototype, "query", void 0);
77
+ __decorate([
78
+ Watch({ reflectBack: true, converter: PropertyConverters.Boolean })
79
+ ], PacemMediaQueryElement.prototype, "isMatch", void 0);
80
+ PacemMediaQueryElement = __decorate([
81
+ CustomElement({
82
+ tagName: P + '-media-query'
83
+ })
84
+ ], PacemMediaQueryElement);
85
+ export { PacemMediaQueryElement };
@@ -0,0 +1,165 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var PacemMenuCursorElement_1;
8
+ import { P, PCSS, Utils, CustomElement, Watch, ViewChild, PropertyConverters, Components, Defaults, avoidHandler, stopPropagationHandler, CustomElementUtils, Logging } from '@pacem/pacem-core';
9
+ //namespace Components.UI {
10
+ let PacemMenuElement = class PacemMenuElement extends Components.PacemElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.synchronizeShell = true;
14
+ this._stopPropagationHandlerConditional = (_) => {
15
+ if (!Utils.isNull(this._container) && !Utils.isNull(this._base)) {
16
+ const offsetNav = Utils.offset(this._container);
17
+ const offsetBase = Utils.offset(this._base);
18
+ // TODO: consider height as well for different skins, but DO manage edge cases...
19
+ if (offsetNav.width < offsetBase.width) {
20
+ this.open = false;
21
+ }
22
+ }
23
+ };
24
+ }
25
+ viewActivatedCallback() {
26
+ super.viewActivatedCallback();
27
+ this._container.addEventListener('click', stopPropagationHandler, false);
28
+ this._container.addEventListener("scroll", stopPropagationHandler, false);
29
+ this._sync();
30
+ }
31
+ disconnectedCallback() {
32
+ window.removeEventListener('navigate', this._stopPropagationHandlerConditional, false);
33
+ if (!Utils.isNull(this._container)) {
34
+ this._container.removeEventListener('click', stopPropagationHandler, false);
35
+ this._container.removeEventListener("scroll", stopPropagationHandler, false);
36
+ }
37
+ this._sync(false);
38
+ super.disconnectedCallback();
39
+ }
40
+ connectedCallback() {
41
+ super.connectedCallback();
42
+ window.addEventListener('navigate', this._stopPropagationHandlerConditional, false);
43
+ this._shell = CustomElementUtils.findAncestorShell(this);
44
+ }
45
+ _toggle(evt) {
46
+ avoidHandler(evt);
47
+ this.open = !this.open;
48
+ this.dispatchEvent(new Event('toggle'));
49
+ }
50
+ _sync(val = this.open) {
51
+ if (this.synchronizeShell) {
52
+ Utils.addClass(this, 'menu-sync');
53
+ Utils.addClass(this._shell, PCSS + (val === true ? '-menu-open' : '-menu-close'));
54
+ Utils.removeClass(this._shell, PCSS + (val === true ? '-menu-close' : '-menu-open'));
55
+ }
56
+ else {
57
+ Utils.removeClass(this, 'menu-sync');
58
+ Utils.removeClass(this._shell, PCSS + '-menu-close ' + PCSS + '-menu-open');
59
+ }
60
+ if (this.outset) {
61
+ Utils.addClass(this, 'menu-outset');
62
+ }
63
+ else {
64
+ Utils.removeClass(this, 'menu-outset');
65
+ }
66
+ }
67
+ propertyChangedCallback(name, old, val, first) {
68
+ super.propertyChangedCallback(name, old, val, first);
69
+ if (name === 'open' || name === 'synchronizeShell' || name === 'outset') {
70
+ this._sync();
71
+ }
72
+ }
73
+ };
74
+ __decorate([
75
+ Watch({ converter: PropertyConverters.Boolean })
76
+ ], PacemMenuElement.prototype, "open", void 0);
77
+ __decorate([
78
+ Watch({ converter: PropertyConverters.Boolean })
79
+ ], PacemMenuElement.prototype, "hideHamburgerButton", void 0);
80
+ __decorate([
81
+ Watch({ converter: PropertyConverters.Boolean })
82
+ ], PacemMenuElement.prototype, "hideBackButton", void 0);
83
+ __decorate([
84
+ Watch({ emit: false, converter: PropertyConverters.Boolean })
85
+ ], PacemMenuElement.prototype, "outset", void 0);
86
+ __decorate([
87
+ Watch({ emit: false, converter: PropertyConverters.Boolean })
88
+ ], PacemMenuElement.prototype, "synchronizeShell", void 0);
89
+ __decorate([
90
+ ViewChild('nav')
91
+ ], PacemMenuElement.prototype, "_container", void 0);
92
+ __decorate([
93
+ ViewChild(`.${PCSS}-menu`)
94
+ ], PacemMenuElement.prototype, "_base", void 0);
95
+ PacemMenuElement = __decorate([
96
+ CustomElement({
97
+ tagName: P + '-menu', template: `<${P}-panel class="${PCSS}-menu" css-class="{{ {'menu-close': !:host.open, 'menu-open': :host.open} }}" on-click=":host._toggle($event)">
98
+ <nav><${P}-content></${P}-content></nav>
99
+ </${P}-panel>
100
+ <${P}-shell-proxy>
101
+ <${P}-button hide="{{ :host.hideBackButton }}" class="${PCSS}-back ${PCSS}-menu button-flat" css-class="{{ {'menu-close': !:host.open, 'menu-open': :host.open} }}" on-click=":host._toggle($event)">BACK</${P}-button>
102
+ <${P}-button hide="{{ :host.hideHamburgerButton }}" class="${PCSS}-hamburger ${PCSS}-menu button-flat" css-class="{{ {'menu-close': :host.open, 'menu-open': !:host.open} }}" on-click=":host._toggle($event)">MENU</${P}-button></${P}-shell-proxy>`,
103
+ shadow: Defaults.USE_SHADOW_ROOT
104
+ })
105
+ ], PacemMenuElement);
106
+ export { PacemMenuElement };
107
+ let PacemMenuCursorElement = PacemMenuCursorElement_1 = class PacemMenuCursorElement extends Components.PacemElement {
108
+ constructor() {
109
+ super(...arguments);
110
+ this._onPathChange = (evt) => {
111
+ const menu = this._menu, path = (evt && evt.detail) || window.location.pathname;
112
+ if (Utils.isNull(menu)) {
113
+ this.log(Logging.LogLevel.Warn, `Couldn't find a ${PacemMenuElement} ancestor for this ${PacemMenuCursorElement_1}.`);
114
+ return;
115
+ }
116
+ // 1. try to find a matching PacemAnchorElement
117
+ var anchors = menu.querySelectorAll(P + '-a');
118
+ var tget = null;
119
+ for (let j = 0; j < anchors.length; j++) {
120
+ let a = anchors.item(j);
121
+ if (a.href === path) {
122
+ tget = a;
123
+ break;
124
+ }
125
+ }
126
+ if (Utils.isNull(tget)) {
127
+ // 2. try with real HTMLAnchorElement
128
+ tget = menu.querySelector(`a[href='${path}']`);
129
+ }
130
+ if (!Utils.isNull(tget)) {
131
+ // TODO: use transforms (remove width/height/top/... animations)
132
+ // TODO: consider <nav> scrollTop
133
+ const rect = Utils.offset(tget);
134
+ const rectMenu = Utils.offset(menu);
135
+ this.style.top = rect.top + 'px';
136
+ this.style.left = rectMenu.left + 'px';
137
+ this.style.width = '0';
138
+ this.style.height = rect.height + 'px';
139
+ Utils.addAnimationEndCallback(this, () => {
140
+ this.style.width = (rect.width + rect.left - rectMenu.left) + 'px';
141
+ }, 500);
142
+ }
143
+ };
144
+ }
145
+ viewActivatedCallback() {
146
+ super.viewActivatedCallback();
147
+ this._menu = CustomElementUtils.findAncestorOfType(this, PacemMenuElement);
148
+ this._onPathChange();
149
+ }
150
+ connectedCallback() {
151
+ super.connectedCallback();
152
+ window.addEventListener('navigate', this._onPathChange, false);
153
+ }
154
+ disconnectedCallback() {
155
+ this._menu = null;
156
+ window.removeEventListener('navigate', this._onPathChange, false);
157
+ super.disconnectedCallback();
158
+ }
159
+ };
160
+ PacemMenuCursorElement = PacemMenuCursorElement_1 = __decorate([
161
+ CustomElement({
162
+ tagName: P + '-menu-cursor'
163
+ })
164
+ ], PacemMenuCursorElement);
165
+ export { PacemMenuCursorElement };