terrier-engine 4.7.7 → 4.7.8

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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.7.7",
7
+ "version": "4.7.8",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -170,7 +170,7 @@ class CardFragment extends ContentFragment {
170
170
  this._content(content)
171
171
  }
172
172
  })
173
- })
173
+ }).class(...this._classes)
174
174
  }
175
175
 
176
176
  }
@@ -29,11 +29,14 @@ export default abstract class TerrierPart<TState> extends Part<TState> {
29
29
  return this.element
30
30
  }
31
31
 
32
+ protected _isLoading = false
33
+
32
34
 
33
35
  /**
34
36
  * Shows the loading animation on top of the part.
35
37
  */
36
38
  startLoading() {
39
+ this._isLoading = true
37
40
  const elem = this.getLoadingContainer()
38
41
  if (!elem) {
39
42
  return
@@ -45,6 +48,7 @@ export default abstract class TerrierPart<TState> extends Part<TState> {
45
48
  * Removes the loading animation from the part.
46
49
  */
47
50
  stopLoading() {
51
+ this._isLoading = false
48
52
  const elem = this.getLoadingContainer()
49
53
  if (!elem) {
50
54
  return
@@ -76,6 +80,31 @@ export default abstract class TerrierPart<TState> extends Part<TState> {
76
80
  }
77
81
  }
78
82
 
83
+ update(elem: HTMLElement) {
84
+ super.update(elem);
85
+ if (!this._isLoading) return
86
+
87
+ const loadingContainer = this.getLoadingContainer()
88
+ if (!loadingContainer) return
89
+
90
+ const existingOverlay = Loading.getOverlay(elem)
91
+ const existingLoadingContainer = existingOverlay?.parentElement
92
+
93
+ if (
94
+ existingLoadingContainer &&
95
+ existingLoadingContainer != loadingContainer &&
96
+ existingLoadingContainer.contains(loadingContainer)
97
+ ) {
98
+ // If there's an existing overlay on this part, but on an ancestor of our loading container,
99
+ // remove the existing overlay so our loading container gets the overlay.
100
+ // This case happens most frequently when the loading container doesn't yet exist on first render, but
101
+ // does exist on subsequent renders. In that case, we prefer the more specific loading container.
102
+ Loading.removeOverlay(elem)
103
+ }
104
+
105
+ Loading.showOverlay(loadingContainer, this.theme)
106
+ }
107
+
79
108
 
80
109
  /// Errors
81
110