@vaadin/common-frontend 0.0.19 → 0.0.21
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/ConnectionIndicator.d.ts +21 -35
- package/ConnectionIndicator.d.ts.map +1 -1
- package/ConnectionIndicator.js +293 -268
- package/ConnectionIndicator.js.map +7 -1
- package/ConnectionState.d.ts +3 -7
- package/ConnectionState.d.ts.map +1 -1
- package/ConnectionState.js +100 -129
- package/ConnectionState.js.map +7 -1
- package/README.md +2 -2
- package/index.js +11 -12
- package/index.js.map +7 -1
- package/package.json +24 -20
package/ConnectionIndicator.js
CHANGED
|
@@ -1,209 +1,265 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
export class ConnectionIndicator extends LitElement {
|
|
37
|
-
/**
|
|
38
|
-
* Initialize global connection indicator instance at
|
|
39
|
-
* window.Vaadin.connectionIndicator and add instance to the document body.
|
|
40
|
-
*/
|
|
41
|
-
static create() {
|
|
42
|
-
var _a, _b;
|
|
43
|
-
const $wnd = window;
|
|
44
|
-
if (!((_a = $wnd.Vaadin) === null || _a === void 0 ? void 0 : _a.connectionIndicator)) {
|
|
45
|
-
$wnd.Vaadin || ($wnd.Vaadin = {});
|
|
46
|
-
$wnd.Vaadin.connectionIndicator = document.createElement('vaadin-connection-indicator');
|
|
47
|
-
document.body.appendChild($wnd.Vaadin.connectionIndicator);
|
|
48
|
-
}
|
|
49
|
-
return (_b = $wnd.Vaadin) === null || _b === void 0 ? void 0 : _b.connectionIndicator;
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
50
35
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
|
+
}
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
|
+
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
50
|
+
var _applyDefaultTheme_dec, _loadingBarState_dec, _loading_dec, _expanded_dec, _reconnecting_dec, _offline_dec, _reconnectingText_dec, _offlineText_dec, _onlineText_dec, _expandedDuration_dec, _thirdDelay_dec, _secondDelay_dec, _firstDelay_dec, _a, _init, _firstDelay, _secondDelay, _thirdDelay, _expandedDuration, _onlineText, _offlineText, _reconnectingText, _offline, _reconnecting, _expanded, _loading, _loadingBarState, _b, loadingBarState_get, loadingBarState_set, _ConnectionIndicator_instances, __isPopover, isPopover_get, isPopover_set, _applyDefaultThemeState, _firstTimeout, _secondTimeout, _thirdTimeout, _expandedTimeout, _connectionStateStore, _lastMessageState, initPopover_fn, updateConnectionState_fn, updateLoading_fn, updatePopoverState_fn, renderMessage_fn, updateTheme_fn, getDefaultStyle_fn, getLoadingBarStyle_fn, timeoutFor_fn;
|
|
51
|
+
import { html, LitElement } from "lit";
|
|
52
|
+
import { property, state } from "lit/decorators.js";
|
|
53
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
54
|
+
import { ConnectionState } from "./ConnectionState.js";
|
|
55
|
+
const DEFAULT_STYLE_ID = "css-loading-indicator";
|
|
56
|
+
var LoadingBarState = /* @__PURE__ */ ((LoadingBarState2) => {
|
|
57
|
+
LoadingBarState2["IDLE"] = "";
|
|
58
|
+
LoadingBarState2["FIRST"] = "first";
|
|
59
|
+
LoadingBarState2["SECOND"] = "second";
|
|
60
|
+
LoadingBarState2["THIRD"] = "third";
|
|
61
|
+
return LoadingBarState2;
|
|
62
|
+
})(LoadingBarState || {});
|
|
63
|
+
const _ConnectionIndicator = class _ConnectionIndicator extends (_a = LitElement, _firstDelay_dec = [property({ type: Number })], _secondDelay_dec = [property({ type: Number })], _thirdDelay_dec = [property({ type: Number })], _expandedDuration_dec = [property({ type: Number })], _onlineText_dec = [property({ type: String })], _offlineText_dec = [property({ type: String })], _reconnectingText_dec = [property({ type: String })], _offline_dec = [property({ type: Boolean, reflect: true })], _reconnecting_dec = [property({ type: Boolean, reflect: true })], _expanded_dec = [property({ type: Boolean, reflect: true })], _loading_dec = [property({ type: Boolean, reflect: true })], _loadingBarState_dec = [state()], _applyDefaultTheme_dec = [property({ type: Boolean, reflect: true })], _a) {
|
|
64
|
+
constructor() {
|
|
65
|
+
super();
|
|
66
|
+
__runInitializers(_init, 5, this);
|
|
67
|
+
__privateAdd(this, _ConnectionIndicator_instances);
|
|
68
|
+
__privateAdd(this, _firstDelay, __runInitializers(_init, 8, this, 450)), __runInitializers(_init, 11, this);
|
|
69
|
+
__privateAdd(this, _secondDelay, __runInitializers(_init, 12, this, 1500)), __runInitializers(_init, 15, this);
|
|
70
|
+
__privateAdd(this, _thirdDelay, __runInitializers(_init, 16, this, 5e3)), __runInitializers(_init, 19, this);
|
|
71
|
+
__privateAdd(this, _expandedDuration, __runInitializers(_init, 20, this, 2e3)), __runInitializers(_init, 23, this);
|
|
72
|
+
__privateAdd(this, _onlineText, __runInitializers(_init, 24, this, "Online")), __runInitializers(_init, 27, this);
|
|
73
|
+
__privateAdd(this, _offlineText, __runInitializers(_init, 28, this, "Connection lost")), __runInitializers(_init, 31, this);
|
|
74
|
+
__privateAdd(this, _reconnectingText, __runInitializers(_init, 32, this, "Connection lost, trying to reconnect...")), __runInitializers(_init, 35, this);
|
|
75
|
+
__privateAdd(this, _offline, __runInitializers(_init, 36, this, false)), __runInitializers(_init, 39, this);
|
|
76
|
+
__privateAdd(this, _reconnecting, __runInitializers(_init, 40, this, false)), __runInitializers(_init, 43, this);
|
|
77
|
+
__privateAdd(this, _expanded, __runInitializers(_init, 44, this, false)), __runInitializers(_init, 47, this);
|
|
78
|
+
__privateAdd(this, _loading, __runInitializers(_init, 48, this, false)), __runInitializers(_init, 51, this);
|
|
79
|
+
__privateAdd(this, _loadingBarState, __runInitializers(_init, 52, this, "" /* IDLE */)), __runInitializers(_init, 55, this);
|
|
80
|
+
__privateAdd(this, __isPopover, false);
|
|
81
|
+
__privateAdd(this, _applyDefaultThemeState, true);
|
|
82
|
+
__privateAdd(this, _firstTimeout, 0);
|
|
83
|
+
__privateAdd(this, _secondTimeout, 0);
|
|
84
|
+
__privateAdd(this, _thirdTimeout, 0);
|
|
85
|
+
__privateAdd(this, _expandedTimeout, 0);
|
|
86
|
+
__privateAdd(this, _connectionStateStore);
|
|
87
|
+
__publicField(this, "connectionStateListener");
|
|
88
|
+
__privateAdd(this, _lastMessageState, ConnectionState.CONNECTED);
|
|
89
|
+
this.connectionStateListener = () => {
|
|
90
|
+
this.expanded = __privateMethod(this, _ConnectionIndicator_instances, updateConnectionState_fn).call(this);
|
|
91
|
+
__privateSet(this, _expandedTimeout, __privateMethod(this, _ConnectionIndicator_instances, timeoutFor_fn).call(this, __privateGet(this, _expandedTimeout), this.expanded, () => {
|
|
84
92
|
this.expanded = false;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
}, this.expandedDuration));
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
static get instance() {
|
|
97
|
+
return _ConnectionIndicator.create();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Initialize global connection indicator instance at
|
|
101
|
+
* window.Vaadin.connectionIndicator and add instance to the document body.
|
|
102
|
+
*/
|
|
103
|
+
static create() {
|
|
104
|
+
const $wnd = window;
|
|
105
|
+
if (!$wnd.Vaadin?.connectionIndicator) {
|
|
106
|
+
$wnd.Vaadin ??= {};
|
|
107
|
+
$wnd.Vaadin.connectionIndicator = document.createElement("vaadin-connection-indicator");
|
|
108
|
+
document.body.appendChild($wnd.Vaadin.connectionIndicator);
|
|
99
109
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
return $wnd.Vaadin?.connectionIndicator;
|
|
111
|
+
}
|
|
112
|
+
render() {
|
|
113
|
+
return html`
|
|
114
|
+
<div class="v-loading-indicator ${__privateGet(this, _ConnectionIndicator_instances, loadingBarState_get)}" style=${__privateMethod(this, _ConnectionIndicator_instances, getLoadingBarStyle_fn).call(this)}></div>
|
|
103
115
|
|
|
104
116
|
<div
|
|
105
117
|
class="v-status-message ${classMap({
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
active: this.reconnecting
|
|
119
|
+
})}"
|
|
108
120
|
>
|
|
109
|
-
<span class="text"> ${this.
|
|
121
|
+
<span class="text"> ${__privateMethod(this, _ConnectionIndicator_instances, renderMessage_fn).call(this)} </span>
|
|
110
122
|
</div>
|
|
111
123
|
`;
|
|
124
|
+
}
|
|
125
|
+
connectedCallback() {
|
|
126
|
+
super.connectedCallback();
|
|
127
|
+
__privateMethod(this, _ConnectionIndicator_instances, initPopover_fn).call(this);
|
|
128
|
+
const $wnd = window;
|
|
129
|
+
if ($wnd.Vaadin?.connectionState) {
|
|
130
|
+
__privateSet(this, _connectionStateStore, $wnd.Vaadin.connectionState);
|
|
131
|
+
__privateGet(this, _connectionStateStore).addStateChangeListener(this.connectionStateListener);
|
|
132
|
+
__privateMethod(this, _ConnectionIndicator_instances, updateConnectionState_fn).call(this);
|
|
112
133
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.connectionStateStore.addStateChangeListener(this.connectionStateListener);
|
|
120
|
-
this.updateConnectionState();
|
|
121
|
-
}
|
|
122
|
-
this.updateTheme();
|
|
134
|
+
__privateMethod(this, _ConnectionIndicator_instances, updateTheme_fn).call(this);
|
|
135
|
+
}
|
|
136
|
+
disconnectedCallback() {
|
|
137
|
+
super.disconnectedCallback();
|
|
138
|
+
if (__privateGet(this, _connectionStateStore)) {
|
|
139
|
+
__privateGet(this, _connectionStateStore).removeStateChangeListener(this.connectionStateListener);
|
|
123
140
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
get applyDefaultTheme() {
|
|
132
|
-
return this.applyDefaultThemeState;
|
|
141
|
+
__privateMethod(this, _ConnectionIndicator_instances, updateTheme_fn).call(this);
|
|
142
|
+
__privateSet(this, _ConnectionIndicator_instances, false, isPopover_set);
|
|
143
|
+
}
|
|
144
|
+
updated(props) {
|
|
145
|
+
if (["loading", "offline", "reconnecting", "expanded"].some((p) => props.has(p))) {
|
|
146
|
+
__privateMethod(this, _ConnectionIndicator_instances, updatePopoverState_fn).call(this);
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
}
|
|
149
|
+
get applyDefaultTheme() {
|
|
150
|
+
return __privateGet(this, _applyDefaultThemeState);
|
|
151
|
+
}
|
|
152
|
+
set applyDefaultTheme(applyDefaultTheme) {
|
|
153
|
+
if (applyDefaultTheme !== __privateGet(this, _applyDefaultThemeState)) {
|
|
154
|
+
__privateSet(this, _applyDefaultThemeState, applyDefaultTheme);
|
|
155
|
+
__privateMethod(this, _ConnectionIndicator_instances, updateTheme_fn).call(this);
|
|
139
156
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
157
|
+
}
|
|
158
|
+
createRenderRoot() {
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
_init = __decoratorStart(_a);
|
|
163
|
+
_firstDelay = new WeakMap();
|
|
164
|
+
_secondDelay = new WeakMap();
|
|
165
|
+
_thirdDelay = new WeakMap();
|
|
166
|
+
_expandedDuration = new WeakMap();
|
|
167
|
+
_onlineText = new WeakMap();
|
|
168
|
+
_offlineText = new WeakMap();
|
|
169
|
+
_reconnectingText = new WeakMap();
|
|
170
|
+
_offline = new WeakMap();
|
|
171
|
+
_reconnecting = new WeakMap();
|
|
172
|
+
_expanded = new WeakMap();
|
|
173
|
+
_loading = new WeakMap();
|
|
174
|
+
_loadingBarState = new WeakMap();
|
|
175
|
+
_ConnectionIndicator_instances = new WeakSet();
|
|
176
|
+
__isPopover = new WeakMap();
|
|
177
|
+
isPopover_get = function() {
|
|
178
|
+
return __privateGet(this, __isPopover);
|
|
179
|
+
};
|
|
180
|
+
isPopover_set = function(_) {
|
|
181
|
+
__privateSet(this, __isPopover, _);
|
|
182
|
+
};
|
|
183
|
+
_applyDefaultThemeState = new WeakMap();
|
|
184
|
+
_firstTimeout = new WeakMap();
|
|
185
|
+
_secondTimeout = new WeakMap();
|
|
186
|
+
_thirdTimeout = new WeakMap();
|
|
187
|
+
_expandedTimeout = new WeakMap();
|
|
188
|
+
_connectionStateStore = new WeakMap();
|
|
189
|
+
_lastMessageState = new WeakMap();
|
|
190
|
+
initPopover_fn = function() {
|
|
191
|
+
this.setAttribute("popover", "manual");
|
|
192
|
+
this.style.display = "contents";
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Update state flags.
|
|
196
|
+
*
|
|
197
|
+
* @returns true if the connection message changes, and therefore a new
|
|
198
|
+
* message should be shown
|
|
199
|
+
*/
|
|
200
|
+
updateConnectionState_fn = function() {
|
|
201
|
+
const connectionState = __privateGet(this, _connectionStateStore)?.state;
|
|
202
|
+
this.offline = connectionState === ConnectionState.CONNECTION_LOST;
|
|
203
|
+
this.reconnecting = connectionState === ConnectionState.RECONNECTING;
|
|
204
|
+
__privateMethod(this, _ConnectionIndicator_instances, updateLoading_fn).call(this, connectionState === ConnectionState.LOADING);
|
|
205
|
+
if (this.loading) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (connectionState !== __privateGet(this, _lastMessageState)) {
|
|
209
|
+
__privateSet(this, _lastMessageState, connectionState);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
};
|
|
214
|
+
updateLoading_fn = function(loading) {
|
|
215
|
+
this.loading = loading;
|
|
216
|
+
__privateSet(this, _ConnectionIndicator_instances, "" /* IDLE */, loadingBarState_set);
|
|
217
|
+
__privateSet(this, _firstTimeout, __privateMethod(this, _ConnectionIndicator_instances, timeoutFor_fn).call(this, __privateGet(this, _firstTimeout), loading, () => {
|
|
218
|
+
__privateSet(this, _ConnectionIndicator_instances, "first" /* FIRST */, loadingBarState_set);
|
|
219
|
+
}, this.firstDelay));
|
|
220
|
+
__privateSet(this, _secondTimeout, __privateMethod(this, _ConnectionIndicator_instances, timeoutFor_fn).call(this, __privateGet(this, _secondTimeout), loading, () => {
|
|
221
|
+
__privateSet(this, _ConnectionIndicator_instances, "second" /* SECOND */, loadingBarState_set);
|
|
222
|
+
}, this.secondDelay));
|
|
223
|
+
__privateSet(this, _thirdTimeout, __privateMethod(this, _ConnectionIndicator_instances, timeoutFor_fn).call(this, __privateGet(this, _thirdTimeout), loading, () => {
|
|
224
|
+
__privateSet(this, _ConnectionIndicator_instances, "third" /* THIRD */, loadingBarState_set);
|
|
225
|
+
}, this.thirdDelay));
|
|
226
|
+
};
|
|
227
|
+
updatePopoverState_fn = function() {
|
|
228
|
+
const showPopover = this.loading || this.offline || this.reconnecting || this.expanded;
|
|
229
|
+
if (__privateGet(this, _ConnectionIndicator_instances, isPopover_get)) {
|
|
230
|
+
this.hidePopover();
|
|
231
|
+
}
|
|
232
|
+
if (showPopover) {
|
|
233
|
+
this.showPopover();
|
|
234
|
+
}
|
|
235
|
+
__privateSet(this, _ConnectionIndicator_instances, showPopover, isPopover_set);
|
|
236
|
+
};
|
|
237
|
+
renderMessage_fn = function() {
|
|
238
|
+
if (this.reconnecting) {
|
|
239
|
+
return this.reconnectingText;
|
|
240
|
+
}
|
|
241
|
+
if (this.offline) {
|
|
242
|
+
return this.offlineText;
|
|
243
|
+
}
|
|
244
|
+
return this.onlineText;
|
|
245
|
+
};
|
|
246
|
+
updateTheme_fn = function() {
|
|
247
|
+
if (__privateGet(this, _applyDefaultThemeState) && this.isConnected) {
|
|
248
|
+
if (!document.getElementById(DEFAULT_STYLE_ID)) {
|
|
249
|
+
const style = document.createElement("style");
|
|
250
|
+
style.id = DEFAULT_STYLE_ID;
|
|
251
|
+
style.textContent = __privateMethod(this, _ConnectionIndicator_instances, getDefaultStyle_fn).call(this);
|
|
252
|
+
document.head.appendChild(style);
|
|
188
253
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
style.id = DEFAULT_STYLE_ID;
|
|
194
|
-
style.textContent = this.getDefaultStyle();
|
|
195
|
-
document.head.appendChild(style);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
const style = document.getElementById(DEFAULT_STYLE_ID);
|
|
200
|
-
if (style) {
|
|
201
|
-
document.head.removeChild(style);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
254
|
+
} else {
|
|
255
|
+
const style = document.getElementById(DEFAULT_STYLE_ID);
|
|
256
|
+
if (style) {
|
|
257
|
+
document.head.removeChild(style);
|
|
204
258
|
}
|
|
205
|
-
|
|
206
|
-
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
getDefaultStyle_fn = function() {
|
|
262
|
+
return `
|
|
207
263
|
@keyframes v-progress-start {
|
|
208
264
|
0% {
|
|
209
265
|
width: 0%;
|
|
@@ -248,7 +304,6 @@ export class ConnectionIndicator extends LitElement {
|
|
|
248
304
|
.v-loading-indicator,
|
|
249
305
|
.v-status-message {
|
|
250
306
|
position: fixed;
|
|
251
|
-
z-index: 251;
|
|
252
307
|
left: 0;
|
|
253
308
|
right: auto;
|
|
254
309
|
top: 0;
|
|
@@ -285,6 +340,7 @@ export class ConnectionIndicator extends LitElement {
|
|
|
285
340
|
|
|
286
341
|
.v-status-message {
|
|
287
342
|
opacity: 0;
|
|
343
|
+
pointer-events: none;
|
|
288
344
|
width: 100%;
|
|
289
345
|
max-height: var(--status-height-collapsed, 8px);
|
|
290
346
|
overflow: hidden;
|
|
@@ -303,6 +359,7 @@ export class ConnectionIndicator extends LitElement {
|
|
|
303
359
|
vaadin-connection-indicator[offline] .v-status-message,
|
|
304
360
|
vaadin-connection-indicator[reconnecting] .v-status-message {
|
|
305
361
|
opacity: 1;
|
|
362
|
+
pointer-events: auto;
|
|
306
363
|
background-color: var(--status-bg-color-offline, var(--lumo-shade, #333));
|
|
307
364
|
color: var(
|
|
308
365
|
--status-text-color-offline,
|
|
@@ -329,6 +386,7 @@ export class ConnectionIndicator extends LitElement {
|
|
|
329
386
|
|
|
330
387
|
vaadin-connection-indicator[expanded] .v-status-message {
|
|
331
388
|
opacity: 1;
|
|
389
|
+
pointer-events: auto;
|
|
332
390
|
}
|
|
333
391
|
|
|
334
392
|
.v-status-message span {
|
|
@@ -360,80 +418,47 @@ export class ConnectionIndicator extends LitElement {
|
|
|
360
418
|
}
|
|
361
419
|
}
|
|
362
420
|
`;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
property({ type: String })
|
|
400
|
-
], ConnectionIndicator.prototype, "onlineText", void 0);
|
|
401
|
-
__decorate([
|
|
402
|
-
property({ type: String })
|
|
403
|
-
], ConnectionIndicator.prototype, "offlineText", void 0);
|
|
404
|
-
__decorate([
|
|
405
|
-
property({ type: String })
|
|
406
|
-
], ConnectionIndicator.prototype, "reconnectingText", void 0);
|
|
407
|
-
__decorate([
|
|
408
|
-
property({ type: Boolean, reflect: true })
|
|
409
|
-
], ConnectionIndicator.prototype, "offline", void 0);
|
|
410
|
-
__decorate([
|
|
411
|
-
property({ type: Boolean, reflect: true })
|
|
412
|
-
], ConnectionIndicator.prototype, "reconnecting", void 0);
|
|
413
|
-
__decorate([
|
|
414
|
-
property({ type: Boolean, reflect: true })
|
|
415
|
-
], ConnectionIndicator.prototype, "expanded", void 0);
|
|
416
|
-
__decorate([
|
|
417
|
-
property({ type: Boolean, reflect: true })
|
|
418
|
-
], ConnectionIndicator.prototype, "loading", void 0);
|
|
419
|
-
__decorate([
|
|
420
|
-
property({ type: String })
|
|
421
|
-
], ConnectionIndicator.prototype, "loadingBarState", void 0);
|
|
422
|
-
__decorate([
|
|
423
|
-
property({ type: Boolean })
|
|
424
|
-
], ConnectionIndicator.prototype, "applyDefaultTheme", null);
|
|
425
|
-
if (customElements.get('vaadin-connection-indicator') === undefined) {
|
|
426
|
-
customElements.define('vaadin-connection-indicator', ConnectionIndicator);
|
|
421
|
+
};
|
|
422
|
+
getLoadingBarStyle_fn = function() {
|
|
423
|
+
switch (__privateGet(this, _ConnectionIndicator_instances, loadingBarState_get)) {
|
|
424
|
+
case "" /* IDLE */:
|
|
425
|
+
return "display: none";
|
|
426
|
+
case "first" /* FIRST */:
|
|
427
|
+
case "second" /* SECOND */:
|
|
428
|
+
case "third" /* THIRD */:
|
|
429
|
+
return "display: block";
|
|
430
|
+
default:
|
|
431
|
+
return "";
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
timeoutFor_fn = function(timeoutId, enabled, handler, delay) {
|
|
435
|
+
if (timeoutId !== 0) {
|
|
436
|
+
window.clearTimeout(timeoutId);
|
|
437
|
+
}
|
|
438
|
+
return enabled ? window.setTimeout(handler, delay) : 0;
|
|
439
|
+
};
|
|
440
|
+
__decorateElement(_init, 4, "firstDelay", _firstDelay_dec, _ConnectionIndicator, _firstDelay);
|
|
441
|
+
__decorateElement(_init, 4, "secondDelay", _secondDelay_dec, _ConnectionIndicator, _secondDelay);
|
|
442
|
+
__decorateElement(_init, 4, "thirdDelay", _thirdDelay_dec, _ConnectionIndicator, _thirdDelay);
|
|
443
|
+
__decorateElement(_init, 4, "expandedDuration", _expandedDuration_dec, _ConnectionIndicator, _expandedDuration);
|
|
444
|
+
__decorateElement(_init, 4, "onlineText", _onlineText_dec, _ConnectionIndicator, _onlineText);
|
|
445
|
+
__decorateElement(_init, 4, "offlineText", _offlineText_dec, _ConnectionIndicator, _offlineText);
|
|
446
|
+
__decorateElement(_init, 4, "reconnectingText", _reconnectingText_dec, _ConnectionIndicator, _reconnectingText);
|
|
447
|
+
__decorateElement(_init, 4, "offline", _offline_dec, _ConnectionIndicator, _offline);
|
|
448
|
+
__decorateElement(_init, 4, "reconnecting", _reconnecting_dec, _ConnectionIndicator, _reconnecting);
|
|
449
|
+
__decorateElement(_init, 4, "expanded", _expanded_dec, _ConnectionIndicator, _expanded);
|
|
450
|
+
__decorateElement(_init, 4, "loading", _loading_dec, _ConnectionIndicator, _loading);
|
|
451
|
+
_b = __decorateElement(_init, 20, "#loadingBarState", _loadingBarState_dec, _ConnectionIndicator_instances, _loadingBarState), loadingBarState_get = _b.get, loadingBarState_set = _b.set;
|
|
452
|
+
__decorateElement(_init, 3, "applyDefaultTheme", _applyDefaultTheme_dec, _ConnectionIndicator);
|
|
453
|
+
__decoratorMetadata(_init, _ConnectionIndicator);
|
|
454
|
+
let ConnectionIndicator = _ConnectionIndicator;
|
|
455
|
+
if (customElements.get("vaadin-connection-indicator") === void 0) {
|
|
456
|
+
customElements.define("vaadin-connection-indicator", ConnectionIndicator);
|
|
427
457
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
* To avoid altering the appearance while the indicator is active, apply the
|
|
436
|
-
* configuration in your application 'frontend/index.ts' file.
|
|
437
|
-
*/
|
|
438
|
-
export const connectionIndicator = ConnectionIndicator.instance;
|
|
439
|
-
//# sourceMappingURL=ConnectionIndicator.js.map
|
|
458
|
+
const connectionIndicator = ConnectionIndicator.instance;
|
|
459
|
+
export {
|
|
460
|
+
ConnectionIndicator,
|
|
461
|
+
LoadingBarState,
|
|
462
|
+
connectionIndicator
|
|
463
|
+
};
|
|
464
|
+
//# sourceMappingURL=ConnectionIndicator.js.map
|