@pacem/pacem-ui 2.0.0-jacobi → 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 +120 -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 +110 -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 +5 -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-jacobi (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
  */
@@ -1088,6 +1088,10 @@
1088
1088
  return;
1089
1089
  }
1090
1090
  popup.style.visibility = 'hidden';
1091
+ // (a hidden, absolutely positioned balloon still extends the document's scrollable area: parked at the
1092
+ // origin, it no longer stretches a shorter page it is left on; the next popup positions it again)
1093
+ popup.style.top =
1094
+ popup.style.left = '0px';
1091
1095
  this._visible = false;
1092
1096
  pacemCore.Utils.removeClass(popup, allStyles);
1093
1097
  popup.dispatchEvent(new Event(BalloonPopoutEventName));
@@ -6087,9 +6091,95 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6087
6091
  this._manageRef();
6088
6092
  }
6089
6093
  }
6094
+ disconnectedCallback() {
6095
+ this._dispose(this.url);
6096
+ super.disconnectedCallback();
6097
+ }
6090
6098
  _isReference(url) {
6091
6099
  return url instanceof HTMLElement || (typeof url === 'string' && url.trim().startsWith('#'));
6092
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
+ }
6093
6183
  _dispose(url) {
6094
6184
  if (url instanceof pacemCore.Components.PacemTemplateProxyElement) {
6095
6185
  url.removeEventListener('templatechange', this._templateChangeHandler);
@@ -6106,19 +6196,31 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6106
6196
  this._fetchHandle = setTimeout((() => this._manageRef()), debounce);
6107
6197
  }
6108
6198
  else if (typeof url === 'string' && !pacemCore.Utils.isNullOrEmpty(url)) {
6109
- // url-based
6199
+ // url-based (but the initial content: already there)
6200
+ if (this._isInitialContent(url)) {
6201
+ this._adoptInitialContent();
6202
+ return;
6203
+ }
6110
6204
  this.fetching = true;
6111
6205
  clearTimeout(this._fetchHandle);
6112
6206
  this._fetchHandle = setTimeout((() => this._manageUrl(url)), debounce);
6113
6207
  }
6114
6208
  else /* might be a reset */ {
6115
6209
  this.innerHTML = '';
6210
+ this.initialContentUrl = null;
6116
6211
  }
6117
6212
  }
6118
6213
  _manageRef() {
6119
- 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)
6120
6216
  if (tmpl instanceof pacemCore.Components.PacemTemplateProxyElement) {
6121
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) {
6122
6224
  this._setTmpl(tmpl.target);
6123
6225
  }
6124
6226
  else if (tmpl instanceof HTMLTemplateElement) {
@@ -6132,18 +6234,13 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6132
6234
  }
6133
6235
  }
6134
6236
  _setTmpl(tmpl) {
6135
- cancelAnimationFrame(this._renderHandle);
6136
- this.#renderVersion++;
6137
- // this way, `this._container.innerHTML = ''` instruction will eventually let the page "scroll up"...
6138
- this.innerHTML = '';
6139
- this._dispatchPrerender();
6140
- this._renderHandle = requestAnimationFrame(() => {
6141
- if (pacemCore.Utils.isNull(tmpl)) {
6142
- this.log(pacemCore.Logging.LogLevel.Error, `Template element not found.`);
6143
- return;
6144
- }
6145
- this.appendChild(tmpl.cloneNode(true).content);
6146
- 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);
6147
6244
  });
6148
6245
  }
6149
6246
  #aborter;
@@ -6204,25 +6301,15 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6204
6301
  });
6205
6302
  }
6206
6303
  _manageResult(result) {
6207
- // this way, `this._container.innerHTML = ''` instruction will eventually let the page "scroll up"...
6208
- cancelAnimationFrame(this._renderHandle);
6209
- const version = ++this.#renderVersion;
6210
6304
  this.scrollTo({ top: 0, left: 0, behavior: 'instant' });
6211
- this.innerHTML = '';
6212
- this._dispatchPrerender();
6213
- 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(() => {
6214
6309
  this.innerHTML = result;
6215
6310
  this.fetching = false;
6216
6311
  this.progress = Number.NaN;
6217
- // setting fetching to `false` triggers a css class change that could/should cause a css transition to happen
6218
- // 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)
6219
- pacemCore.Utils.addAnimationEndCallback(this, () => {
6220
- if (version !== this.#renderVersion) {
6221
- return;
6222
- }
6223
- this._dispatchRender();
6224
- }, ANIM_TIMEOUT);
6225
- });
6312
+ }, true);
6226
6313
  }
6227
6314
  #resizeHandle;
6228
6315
  _dispatchRender() {
@@ -6259,6 +6346,9 @@ css-class="{{ ['hour-start-'+ (^item.hour + 1), 'hour-end-'+ (^item.hour + ^item
6259
6346
  __decorate$1([
6260
6347
  pacemCore.Watch({ emit: false, converter: pacemCore.PropertyConverters.Number })
6261
6348
  ], PacemViewElement.prototype, "debounce", void 0);
6349
+ __decorate$1([
6350
+ pacemCore.Watch({ emit: false, converter: ElementOrStringPropertyConverter })
6351
+ ], PacemViewElement.prototype, "initialContentUrl", void 0);
6262
6352
  PacemViewElement = __decorate$1([
6263
6353
  pacemCore.CustomElement({
6264
6354
  tagName: pacemCore.P + '-view'