@pacem/pacem-ui 2.0.0-kepler → 2.0.0-lyapunov

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 (54) hide show
  1. package/dist/browser/pacem-ui.js +116 -30
  2. package/dist/browser/pacem-ui.js.map +1 -1
  3. package/dist/browser/pacem-ui.min.js +2 -2
  4. package/dist/bundle/pacem-ui.min.mjs +42 -42
  5. package/dist/bundle/pacem-ui.mjs +109 -26
  6. package/dist/bundle/pacem-ui.mjs.map +2 -2
  7. package/dist/docs/pacem-ui.json +75 -0
  8. package/dist/esm/adapter.js +1 -1
  9. package/dist/esm/anchor.js +1 -1
  10. package/dist/esm/balloon.js +1 -1
  11. package/dist/esm/binder.js +1 -1
  12. package/dist/esm/blade.js +1 -1
  13. package/dist/esm/bottom-sheet.js +1 -1
  14. package/dist/esm/button.js +1 -1
  15. package/dist/esm/buttonset.js +1 -1
  16. package/dist/esm/calendar.js +1 -1
  17. package/dist/esm/collapse.js +1 -1
  18. package/dist/esm/dialog-abstractions.js +1 -1
  19. package/dist/esm/dialog.js +1 -1
  20. package/dist/esm/divider.js +1 -1
  21. package/dist/esm/icon.js +1 -1
  22. package/dist/esm/image.js +1 -1
  23. package/dist/esm/index-components-ui.js +1 -1
  24. package/dist/esm/index-components.js +1 -1
  25. package/dist/esm/index-iife.js +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/infinite-scroller.js +1 -1
  28. package/dist/esm/iterative.js +1 -1
  29. package/dist/esm/lightbox-abstractions.js +1 -1
  30. package/dist/esm/lightbox.js +1 -1
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/markdown-svc.js +1 -1
  33. package/dist/esm/markdown.js +1 -1
  34. package/dist/esm/marquee.js +1 -1
  35. package/dist/esm/media-query.js +1 -1
  36. package/dist/esm/menu.js +1 -1
  37. package/dist/esm/pager.js +1 -1
  38. package/dist/esm/picture.js +1 -1
  39. package/dist/esm/progressbar.js +1 -1
  40. package/dist/esm/sidebar.js +1 -1
  41. package/dist/esm/slideshow.js +1 -1
  42. package/dist/esm/social-twitter.js +1 -1
  43. package/dist/esm/sticky-header.js +1 -1
  44. package/dist/esm/tabs.js +1 -1
  45. package/dist/esm/ticker.js +1 -1
  46. package/dist/esm/toast.js +1 -1
  47. package/dist/esm/toc.js +1 -1
  48. package/dist/esm/tuner.js +1 -1
  49. package/dist/esm/types.js +1 -1
  50. package/dist/esm/vibration.js +1 -1
  51. package/dist/esm/view.js +116 -31
  52. package/dist/esm/window.js +1 -1
  53. package/package.json +1 -1
  54. package/typings/index.d.ts +33 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-ui v2.0.0-kepler (https://js.pacem.it)
2
+ * @pacem/pacem-ui v2.0.0-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -6091,9 +6091,95 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6091
6091
  this._manageRef();
6092
6092
  }
6093
6093
  }
6094
+ disconnectedCallback() {
6095
+ this._dispose(this.url);
6096
+ super.disconnectedCallback();
6097
+ }
6094
6098
  _isReference(url) {
6095
6099
  return url instanceof HTMLElement || (typeof url === 'string' && url.trim().startsWith('#'));
6096
6100
  }
6101
+ /**
6102
+ * Resolves a reference source to its element, as {@link _manageRef} does: the element itself, or the
6103
+ * `<template>` a `#id` string points to; `null` for anything else.
6104
+ */
6105
+ _resolveRef(source) {
6106
+ if (source instanceof HTMLElement) {
6107
+ return source;
6108
+ }
6109
+ if (typeof source !== 'string' || !this._isReference(source)) {
6110
+ return null;
6111
+ }
6112
+ return document.querySelector('template' + source);
6113
+ }
6114
+ /**
6115
+ * Whether `url` is the source of the initial content ({@link initialContentUrl}): urls match by their string,
6116
+ * references by the element they resolve to. Any other source consumes it.
6117
+ */
6118
+ _isInitialContent(url) {
6119
+ const initial = this.initialContentUrl;
6120
+ if (pacemCore.Utils.isNull(initial)) {
6121
+ return false;
6122
+ }
6123
+ let matches = false;
6124
+ if (!this._isReference(url)) {
6125
+ matches = typeof url === 'string' && url === initial;
6126
+ }
6127
+ else if (this._isReference(initial)) {
6128
+ const target = this._resolveRef(url);
6129
+ matches = !pacemCore.Utils.isNull(target) && target === this._resolveRef(initial);
6130
+ }
6131
+ if (!matches) {
6132
+ this.initialContentUrl = null;
6133
+ }
6134
+ return matches;
6135
+ }
6136
+ /**
6137
+ * Keeps the initial content: announced once, as a fresh content would be (a reference may be managed twice on
6138
+ * activation: the second time, it was announced already).
6139
+ */
6140
+ _adoptInitialContent() {
6141
+ clearTimeout(this._fetchHandle);
6142
+ if (this.#renderVersion > 0) {
6143
+ return;
6144
+ }
6145
+ this._render(null);
6146
+ }
6147
+ /**
6148
+ * The rendering pipeline of every content: a new version, `prerender`, the content on the next frame, `render`
6149
+ * (dropped when newer content came meanwhile).
6150
+ * @param fill Writes the new content (the former one is cleared first); `null` keeps the content already there
6151
+ * (the initial content), which also leaves {@link initialContentUrl} in place.
6152
+ * @param waitForAnimation Whether `render` waits for the view's css transition (see `fetching`) instead of
6153
+ * following the content right away.
6154
+ */
6155
+ _render(fill, waitForAnimation = false) {
6156
+ cancelAnimationFrame(this._renderHandle);
6157
+ const version = ++this.#renderVersion;
6158
+ const replacing = !pacemCore.Utils.isNull(fill);
6159
+ if (replacing) {
6160
+ this.initialContentUrl = null;
6161
+ // this way, `this._container.innerHTML = ''` instruction will eventually let the page "scroll up"...
6162
+ this.innerHTML = '';
6163
+ }
6164
+ this._dispatchPrerender();
6165
+ this._renderHandle = requestAnimationFrame(() => {
6166
+ if (replacing) {
6167
+ fill();
6168
+ }
6169
+ if (!waitForAnimation) {
6170
+ this._dispatchRenderOf(version);
6171
+ return;
6172
+ }
6173
+ pacemCore.Utils.addAnimationEndCallback(this, () => this._dispatchRenderOf(version), ANIM_TIMEOUT);
6174
+ });
6175
+ }
6176
+ /** Dispatches `render` for the content of `version`, unless newer content superseded it. */
6177
+ _dispatchRenderOf(version) {
6178
+ if (version !== this.#renderVersion) {
6179
+ return;
6180
+ }
6181
+ this._dispatchRender();
6182
+ }
6097
6183
  _dispose(url) {
6098
6184
  if (url instanceof pacemCore.Components.PacemTemplateProxyElement) {
6099
6185
  url.removeEventListener('templatechange', this._templateChangeHandler);
@@ -6110,19 +6196,31 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6110
6196
  this._fetchHandle = setTimeout((() => this._manageRef()), debounce);
6111
6197
  }
6112
6198
  else if (typeof url === 'string' && !pacemCore.Utils.isNullOrEmpty(url)) {
6113
- // url-based
6199
+ // url-based (but the initial content: already there)
6200
+ if (this._isInitialContent(url)) {
6201
+ this._adoptInitialContent();
6202
+ return;
6203
+ }
6114
6204
  this.fetching = true;
6115
6205
  clearTimeout(this._fetchHandle);
6116
6206
  this._fetchHandle = setTimeout((() => this._manageUrl(url)), debounce);
6117
6207
  }
6118
6208
  else /* might be a reset */ {
6119
6209
  this.innerHTML = '';
6210
+ this.initialContentUrl = null;
6120
6211
  }
6121
6212
  }
6122
6213
  _manageRef() {
6123
- const url = this.url, tmpl = url instanceof HTMLElement ? url : document.querySelector('template' + url);
6214
+ const url = this.url, tmpl = this._resolveRef(url);
6215
+ // (a proxy keeps notifying its template changes, the initial content too: listening twice is a no-op)
6124
6216
  if (tmpl instanceof pacemCore.Components.PacemTemplateProxyElement) {
6125
6217
  tmpl.addEventListener('templatechange', this._templateChangeHandler, false);
6218
+ }
6219
+ if (this._isInitialContent(url)) {
6220
+ this._adoptInitialContent();
6221
+ return;
6222
+ }
6223
+ if (tmpl instanceof pacemCore.Components.PacemTemplateProxyElement) {
6126
6224
  this._setTmpl(tmpl.target);
6127
6225
  }
6128
6226
  else if (tmpl instanceof HTMLTemplateElement) {
@@ -6136,18 +6234,13 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6136
6234
  }
6137
6235
  }
6138
6236
  _setTmpl(tmpl) {
6139
- cancelAnimationFrame(this._renderHandle);
6140
- this.#renderVersion++;
6141
- // this way, `this._container.innerHTML = ''` instruction will eventually let the page "scroll up"...
6142
- this.innerHTML = '';
6143
- this._dispatchPrerender();
6144
- this._renderHandle = requestAnimationFrame(() => {
6145
- if (pacemCore.Utils.isNull(tmpl)) {
6146
- this.log(pacemCore.Logging.LogLevel.Error, `Template element not found.`);
6147
- return;
6148
- }
6149
- this.appendChild(tmpl.cloneNode(true).content);
6150
- this._dispatchRender();
6237
+ if (pacemCore.Utils.isNull(tmpl)) {
6238
+ this.log(pacemCore.Logging.LogLevel.Error, `Template element not found.`);
6239
+ return;
6240
+ }
6241
+ this._render(() => {
6242
+ const clone = tmpl.cloneNode(true);
6243
+ this.appendChild(clone.content);
6151
6244
  });
6152
6245
  }
6153
6246
  #aborter;
@@ -6208,25 +6301,15 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6208
6301
  });
6209
6302
  }
6210
6303
  _manageResult(result) {
6211
- // this way, `this._container.innerHTML = ''` instruction will eventually let the page "scroll up"...
6212
- cancelAnimationFrame(this._renderHandle);
6213
- const version = ++this.#renderVersion;
6214
6304
  this.scrollTo({ top: 0, left: 0, behavior: 'instant' });
6215
- this.innerHTML = '';
6216
- this._dispatchPrerender();
6217
- this._renderHandle = requestAnimationFrame(() => {
6305
+ // setting fetching to `false` triggers a css class change that could/should cause a css transition to happen:
6306
+ // `render` waits for it
6307
+ // TODO: manage to switch to native in a near future (https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API or https://youtu.be/oDcb3fvtETs)
6308
+ this._render(() => {
6218
6309
  this.innerHTML = result;
6219
6310
  this.fetching = false;
6220
6311
  this.progress = Number.NaN;
6221
- // setting fetching to `false` triggers a css class change that could/should cause a css transition to happen
6222
- // TODO: manage to switch to native in a near future (https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API or https://youtu.be/oDcb3fvtETs)
6223
- pacemCore.Utils.addAnimationEndCallback(this, () => {
6224
- if (version !== this.#renderVersion) {
6225
- return;
6226
- }
6227
- this._dispatchRender();
6228
- }, ANIM_TIMEOUT);
6229
- });
6312
+ }, true);
6230
6313
  }
6231
6314
  #resizeHandle;
6232
6315
  _dispatchRender() {
@@ -6263,6 +6346,9 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6263
6346
  __decorate$1([
6264
6347
  pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
6265
6348
  ], PacemViewElement.prototype, "debounce", void 0);
6349
+ __decorate$1([
6350
+ pacemCore.Watch({ emit: false, converter: ElementOrStringPropertyConverter })
6351
+ ], PacemViewElement.prototype, "initialContentUrl", void 0);
6266
6352
  PacemViewElement = __decorate$1([
6267
6353
  pacemCore.CustomElement({
6268
6354
  tagName: pacemCore.P + '-view'