stimeo-ui 0.16.0 → 0.18.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +136 -0
- data/README.md +27 -11
- data/dist/cable/index.js +384 -449
- data/dist/controllers/accordion_controller.js +174 -55
- data/dist/controllers/alert_dialog_controller.js +903 -235
- data/dist/controllers/announcer_controller.js +238 -205
- data/dist/controllers/aspect_ratio_controller.js +0 -10
- data/dist/controllers/auto_submit_controller.js +414 -145
- data/dist/controllers/avatar_controller.js +185 -107
- data/dist/controllers/breadcrumb_controller.js +0 -130
- data/dist/controllers/bulk_select_controller.js +282 -58
- data/dist/controllers/calendar_controller.js +228 -260
- data/dist/controllers/carousel_controller.js +536 -436
- data/dist/controllers/character_counter_controller.js +493 -207
- data/dist/controllers/checkbox_controller.js +38 -74
- data/dist/controllers/clipboard_controller.js +261 -149
- data/dist/controllers/collapsible_controller.js +304 -120
- data/dist/controllers/color_picker_controller.js +178 -146
- data/dist/controllers/combobox_controller.js +522 -156
- data/dist/controllers/command_palette_controller.js +1156 -395
- data/dist/controllers/conditional_fields_controller.js +300 -171
- data/dist/controllers/confirm_controller.js +980 -262
- data/dist/controllers/context_menu_controller.js +346 -153
- data/dist/controllers/count_up_controller.js +73 -21
- data/dist/controllers/countdown_controller.js +281 -158
- data/dist/controllers/currency_input_controller.js +575 -225
- data/dist/controllers/data_grid_controller.js +248 -214
- data/dist/controllers/date_range_picker_controller.js +338 -235
- data/dist/controllers/dialog_controller.js +899 -237
- data/dist/controllers/direct_upload_controller.js +97 -167
- data/dist/controllers/dirty_form_controller.js +72 -69
- data/dist/controllers/dismissible_controller.js +196 -24
- data/dist/controllers/drawer_controller.js +974 -355
- data/dist/controllers/dropdown_controller.js +339 -96
- data/dist/controllers/editable_controller.js +315 -88
- data/dist/controllers/empty_state_controller.js +79 -58
- data/dist/controllers/file_dropzone_controller.js +322 -211
- data/dist/controllers/filter_controller.js +77 -42
- data/dist/controllers/flash_controller.js +238 -347
- data/dist/controllers/focus_controller.js +679 -240
- data/dist/controllers/form_field_controller.js +156 -132
- data/dist/controllers/form_validation_controller.js +31 -97
- data/dist/controllers/frame_loading_controller.js +275 -217
- data/dist/controllers/highlight_controller.js +107 -75
- data/dist/controllers/hover_card_controller.js +327 -130
- data/dist/controllers/idle_controller.js +271 -101
- data/dist/controllers/input_mask_controller.js +483 -97
- data/dist/controllers/intersection_controller.js +150 -106
- data/dist/controllers/lazy_frame_controller.js +24 -68
- data/dist/controllers/listbox_controller.js +523 -240
- data/dist/controllers/local_time_controller.js +102 -77
- data/dist/controllers/masonry_controller.js +80 -96
- data/dist/controllers/menu_controller.js +302 -188
- data/dist/controllers/menubar_controller.js +232 -345
- data/dist/controllers/meter_controller.js +417 -87
- data/dist/controllers/multi_select_controller.js +785 -393
- data/dist/controllers/navigation_menu_controller.js +190 -250
- data/dist/controllers/nested_form_controller.js +396 -192
- data/dist/controllers/network_status_controller.js +268 -62
- data/dist/controllers/number_input_controller.js +610 -303
- data/dist/controllers/optimistic_controller.js +45 -87
- data/dist/controllers/otp_controller.js +658 -255
- data/dist/controllers/overflow_indicator_controller.js +122 -113
- data/dist/controllers/overflow_menu_controller.js +470 -295
- data/dist/controllers/pagination_controller.js +332 -123
- data/dist/controllers/password_reveal_controller.js +392 -121
- data/dist/controllers/password_strength_controller.js +111 -158
- data/dist/controllers/persist_controller.js +165 -111
- data/dist/controllers/pointer_drag_controller.js +434 -188
- data/dist/controllers/popover_controller.js +269 -113
- data/dist/controllers/portal_controller.js +215 -76
- data/dist/controllers/preview_guard_controller.js +243 -116
- data/dist/controllers/progress_controller.js +391 -78
- data/dist/controllers/radio_group_controller.js +278 -211
- data/dist/controllers/range_slider_controller.js +220 -113
- data/dist/controllers/rating_controller.js +458 -211
- data/dist/controllers/read_more_controller.js +138 -63
- data/dist/controllers/reading_progress_controller.js +166 -137
- data/dist/controllers/relative_time_controller.js +211 -112
- data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +103 -38
- data/dist/controllers/resizable_controller.js +299 -150
- data/dist/controllers/roving_controller.js +49 -88
- data/dist/controllers/scroll_area_controller.js +490 -246
- data/dist/controllers/scroll_restore_controller.js +14 -55
- data/dist/controllers/scroll_visibility_controller.js +432 -149
- data/dist/controllers/scrollspy_controller.js +193 -248
- data/dist/controllers/separator_controller.js +285 -142
- data/dist/controllers/sidebar_controller.js +1069 -404
- data/dist/controllers/skeleton_controller.js +259 -101
- data/dist/controllers/slider_controller.js +187 -86
- data/dist/controllers/smart_sticky_header_controller.js +173 -66
- data/dist/controllers/sortable_controller.js +26 -125
- data/dist/controllers/spinner_controller.js +288 -173
- data/dist/controllers/step_indicator_controller.js +105 -46
- data/dist/controllers/stepper_controller.js +120 -73
- data/dist/controllers/stick_to_bottom_controller.js +275 -140
- data/dist/controllers/sticky_observer_controller.js +220 -49
- data/dist/controllers/submit_once_controller.js +376 -227
- data/dist/controllers/switch_controller.js +201 -84
- data/dist/controllers/tabs_controller.js +41 -30
- data/dist/controllers/tags_input_controller.js +293 -173
- data/dist/controllers/textarea_autosize_controller.js +108 -74
- data/dist/controllers/theme_controller.js +140 -116
- data/dist/controllers/time_picker_controller.js +331 -127
- data/dist/controllers/toast_controller.js +244 -324
- data/dist/controllers/toggle_group_controller.js +252 -191
- data/dist/controllers/toolbar_controller.js +219 -120
- data/dist/controllers/tooltip_controller.js +158 -124
- data/dist/controllers/transition_controller.js +123 -119
- data/dist/controllers/tree_view_controller.js +283 -369
- data/dist/index.js +8573 -10410
- data/dist/positioning/index.js +154 -47
- data/lib/generators/stimeo/install/install_generator.rb +7 -2
- data/lib/generators/stimeo/install/templates/stimeo.js +19 -6
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +3 -3
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function fillTemplate(template, values) {
|
|
4
|
+
return template.replace(/\{([a-zA-Z][a-zA-Z0-9]*)\}/g, (match, name) => {
|
|
5
|
+
const replacement = Object.hasOwn(values, name) ? values[name] : void 0;
|
|
6
|
+
return replacement === void 0 ? match : String(replacement);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
4
9
|
|
|
5
|
-
// src/utils/announce.ts
|
|
6
10
|
function announce(message, options = {}) {
|
|
7
11
|
const text = message.trim();
|
|
8
12
|
if (text.length === 0) return;
|
|
@@ -12,50 +16,235 @@ function announce(message, options = {}) {
|
|
|
12
16
|
})
|
|
13
17
|
);
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
21
|
+
if (element.getAttribute(name) === value) return false;
|
|
22
|
+
if (value === null) element.removeAttribute(name);
|
|
23
|
+
else element.setAttribute(name, value);
|
|
24
|
+
return true;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
function sharedRegistry(key, create) {
|
|
28
|
+
const symbol = Symbol.for(key);
|
|
29
|
+
const scope = globalThis;
|
|
30
|
+
const existing = scope[symbol];
|
|
31
|
+
if (existing !== void 0) return existing;
|
|
32
|
+
const registry2 = create();
|
|
33
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
34
|
+
return registry2;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var registry = sharedRegistry(
|
|
38
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
39
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
40
|
+
);
|
|
41
|
+
function isAttributeValue(value) {
|
|
42
|
+
return value === null || typeof value === "string";
|
|
43
|
+
}
|
|
44
|
+
function readLeaseRecord(element, record) {
|
|
45
|
+
try {
|
|
46
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
47
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
48
|
+
const [original, written, ...rest] = parsed;
|
|
49
|
+
const linked = rest[0] !== false;
|
|
50
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
51
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
52
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
53
|
+
} catch {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function attributeStack(element, attribute) {
|
|
58
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
59
|
+
registry.stacks.set(element, byAttribute);
|
|
60
|
+
const known = byAttribute.get(attribute);
|
|
61
|
+
if (known) return known;
|
|
62
|
+
const found = [];
|
|
63
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
64
|
+
const read = readLeaseRecord(element, record);
|
|
65
|
+
if (read) found.push({ ...read, record });
|
|
66
|
+
}
|
|
67
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
68
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
69
|
+
lease: null,
|
|
70
|
+
record,
|
|
71
|
+
written,
|
|
72
|
+
original,
|
|
73
|
+
linked: linked && index > 0
|
|
74
|
+
}));
|
|
75
|
+
byAttribute.set(attribute, stack);
|
|
76
|
+
return stack;
|
|
77
|
+
}
|
|
78
|
+
function findHold(stack, lease, record) {
|
|
79
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
80
|
+
}
|
|
81
|
+
var AttributeLease = class {
|
|
82
|
+
#attribute;
|
|
83
|
+
#record;
|
|
84
|
+
#base;
|
|
85
|
+
#preserveAuthor;
|
|
86
|
+
#held = /* @__PURE__ */ new Set();
|
|
87
|
+
constructor(attribute, owner, options = {}) {
|
|
88
|
+
this.#attribute = attribute;
|
|
89
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
90
|
+
this.#base = options.base === true;
|
|
91
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
92
|
+
const names = registry.names;
|
|
93
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
94
|
+
}
|
|
95
|
+
write(element, value) {
|
|
96
|
+
const stack = attributeStack(element, this.#attribute);
|
|
97
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
98
|
+
this.#held.add(element);
|
|
99
|
+
const shows = !this.#covered(element, stack, hold);
|
|
100
|
+
hold.written = value;
|
|
101
|
+
this.#mark(element, stack);
|
|
102
|
+
if (shows) this.#reflect(element, value);
|
|
103
|
+
}
|
|
104
|
+
return(element) {
|
|
105
|
+
const held = this.#held.delete(element);
|
|
106
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
107
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
108
|
+
const hold = this.#take(stack);
|
|
109
|
+
if (!hold) return false;
|
|
110
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
111
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
112
|
+
const index = stack.indexOf(hold);
|
|
113
|
+
stack.splice(index, 1);
|
|
114
|
+
const above = stack[index];
|
|
115
|
+
if (above) above.linked &&= hold.linked;
|
|
116
|
+
this.#mark(element, stack);
|
|
117
|
+
if (!owns) return true;
|
|
118
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
119
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
returnAll() {
|
|
123
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
124
|
+
}
|
|
125
|
+
#take(stack) {
|
|
126
|
+
const hold = findHold(stack, this, this.#record);
|
|
127
|
+
if (hold) hold.lease = this;
|
|
128
|
+
return hold;
|
|
129
|
+
}
|
|
130
|
+
#acquire(element, stack) {
|
|
131
|
+
const current = element.getAttribute(this.#attribute);
|
|
132
|
+
const top = stack.at(-1);
|
|
133
|
+
const bottom = stack[0];
|
|
134
|
+
const over = top?.written === current ? top : void 0;
|
|
135
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
136
|
+
const hold = {
|
|
137
|
+
lease: this,
|
|
138
|
+
record: this.#record,
|
|
139
|
+
written: current,
|
|
140
|
+
original: from ? from.original : current,
|
|
141
|
+
linked: !this.#base && over !== void 0
|
|
142
|
+
};
|
|
143
|
+
if (this.#base && bottom) {
|
|
144
|
+
bottom.linked = true;
|
|
145
|
+
stack.unshift(hold);
|
|
146
|
+
} else stack.push(hold);
|
|
147
|
+
return hold;
|
|
148
|
+
}
|
|
149
|
+
#covered(element, stack, hold) {
|
|
150
|
+
const current = element.getAttribute(this.#attribute);
|
|
151
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
152
|
+
}
|
|
153
|
+
#mark(element, stack) {
|
|
154
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
155
|
+
stack.forEach((hold, index) => {
|
|
156
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
157
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
158
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
159
|
+
records.set(
|
|
160
|
+
hold.record,
|
|
161
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
for (const [name, recorded] of records) {
|
|
165
|
+
setAttributeIfChanged(element, name, recorded);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
#reflect(element, value) {
|
|
169
|
+
setAttributeIfChanged(element, this.#attribute, value);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
var ListenerSet = class {
|
|
174
|
+
#abort = new AbortController();
|
|
175
|
+
add(target, type, handler, options) {
|
|
176
|
+
target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
|
|
177
|
+
}
|
|
178
|
+
dispose() {
|
|
179
|
+
this.#abort.abort();
|
|
180
|
+
this.#abort = new AbortController();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
185
|
+
|
|
186
|
+
var NUMBER_BOUNDS = {
|
|
187
|
+
timer: { finite: true, min: 0, max: MAX_TIMER_DELAY_MS }};
|
|
188
|
+
function matchesNumberBounds(value, bounds) {
|
|
189
|
+
if (!Number.isFinite(value)) {
|
|
190
|
+
const direction = value === Infinity ? "positive" : value === -Infinity ? "negative" : null;
|
|
191
|
+
if (direction === null) return false;
|
|
192
|
+
if (bounds.allowInfinity !== "both" && bounds.allowInfinity !== direction) return false;
|
|
193
|
+
}
|
|
194
|
+
if (bounds.min !== void 0 && value < bounds.min) return false;
|
|
195
|
+
if (bounds.max !== void 0 && value > bounds.max) return false;
|
|
196
|
+
if (bounds.exclusiveMin !== void 0 && value <= bounds.exclusiveMin) return false;
|
|
197
|
+
if (bounds.integer && !Number.isInteger(value)) return false;
|
|
198
|
+
if (bounds.allowedValues !== void 0 && !bounds.allowedValues.includes(value)) return false;
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function readNumber(raw, fallback, bounds) {
|
|
203
|
+
return matchesNumberBounds(raw, bounds) ? raw : fallback;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
var NumberValueReader = class {
|
|
207
|
+
#lastRejected = /* @__PURE__ */ new Map();
|
|
208
|
+
read(owner, name, raw, fallback, bounds) {
|
|
209
|
+
const resolved = readNumber(raw, fallback, bounds);
|
|
210
|
+
if (matchesNumberBounds(raw, bounds)) {
|
|
211
|
+
this.#lastRejected.delete(name);
|
|
212
|
+
return resolved;
|
|
213
|
+
}
|
|
214
|
+
const attribute = `data-${owner.identifier}-${name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}-value`;
|
|
215
|
+
const literal = owner.element.getAttribute(attribute);
|
|
216
|
+
if (literal === null) {
|
|
217
|
+
this.#lastRejected.delete(name);
|
|
218
|
+
return resolved;
|
|
219
|
+
}
|
|
220
|
+
if (this.#lastRejected.get(name) !== literal) {
|
|
221
|
+
this.#lastRejected.set(name, literal);
|
|
222
|
+
console.warn(
|
|
223
|
+
`Stimeo UI: "${owner.identifier}" has an invalid number Value "${name}" declaration ${JSON.stringify(literal)}; using ${fallback}.`
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
return resolved;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
23
230
|
var TimerRegistry = class {
|
|
24
|
-
/** Live timer ids that have not yet been cleared (or, for timeouts, fired). */
|
|
25
231
|
ids = /* @__PURE__ */ new Set();
|
|
26
|
-
/**
|
|
27
|
-
* Cancels a single tracked timer.
|
|
28
|
-
*
|
|
29
|
-
* No-ops if the id is unknown (already cleared, fired, or never owned by this
|
|
30
|
-
* registry), so callers can clear defensively without guarding.
|
|
31
|
-
*/
|
|
32
232
|
clear(id) {
|
|
33
233
|
if (this.ids.delete(id)) {
|
|
34
234
|
this.cancel(id);
|
|
35
235
|
}
|
|
36
236
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Cancels every tracked timer. Call this from a controller's `disconnect()`
|
|
39
|
-
* to guarantee no timer outlives the element.
|
|
40
|
-
*/
|
|
41
237
|
clearAll() {
|
|
42
238
|
for (const id of this.ids) {
|
|
43
239
|
this.cancel(id);
|
|
44
240
|
}
|
|
45
241
|
this.ids.clear();
|
|
46
242
|
}
|
|
47
|
-
/** Number of timers currently tracked (pending). */
|
|
48
243
|
get size() {
|
|
49
244
|
return this.ids.size;
|
|
50
245
|
}
|
|
51
246
|
};
|
|
52
247
|
var SafeTimeout = class extends TimerRegistry {
|
|
53
|
-
/**
|
|
54
|
-
* Schedules `callback` after `delay` ms and returns the timer id.
|
|
55
|
-
*
|
|
56
|
-
* The id is removed from the registry automatically when the timeout fires,
|
|
57
|
-
* so {@link TimerRegistry.size | size} reflects only still-pending timers.
|
|
58
|
-
*/
|
|
59
248
|
set(callback, delay) {
|
|
60
249
|
const id = this.schedule(() => {
|
|
61
250
|
this.ids.delete(id);
|
|
@@ -72,43 +261,54 @@ var SafeTimeout = class extends TimerRegistry {
|
|
|
72
261
|
}
|
|
73
262
|
};
|
|
74
263
|
|
|
75
|
-
|
|
76
|
-
|
|
264
|
+
var NetworkStatusController = class _NetworkStatusController extends Controller {
|
|
265
|
+
#numbers = new NumberValueReader();
|
|
77
266
|
static targets = ["offline", "online"];
|
|
78
267
|
static values = {
|
|
79
268
|
announceText: { type: String, default: "" },
|
|
80
269
|
announceOnlineText: { type: String, default: "" },
|
|
81
270
|
onlineAutoHide: { type: Number, default: 0 }
|
|
82
271
|
};
|
|
272
|
+
static valueConstraints = {
|
|
273
|
+
onlineAutoHide: NUMBER_BOUNDS.timer
|
|
274
|
+
};
|
|
83
275
|
static events = ["change"];
|
|
84
276
|
#timers = new SafeTimeout();
|
|
85
|
-
|
|
277
|
+
#hidden = new AttributeLease("hidden", this.identifier);
|
|
278
|
+
#connected = false;
|
|
86
279
|
#online = true;
|
|
280
|
+
#recoveryShown = false;
|
|
87
281
|
#handleOnline = () => this.#update(true);
|
|
88
282
|
#handleOffline = () => this.#update(false);
|
|
283
|
+
#listeners = new ListenerSet();
|
|
89
284
|
connect() {
|
|
90
|
-
|
|
91
|
-
if (this.hasOnlineTarget) this.onlineTarget.hidden = true;
|
|
285
|
+
this.#connected = true;
|
|
92
286
|
this.#online = navigator.onLine;
|
|
287
|
+
this.#recoveryShown = false;
|
|
93
288
|
this.element.setAttribute("data-state", this.#online ? "online" : "offline");
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
289
|
+
this.#paint();
|
|
290
|
+
this.#listeners.add(window, "online", this.#handleOnline);
|
|
291
|
+
this.#listeners.add(window, "offline", this.#handleOffline);
|
|
97
292
|
}
|
|
98
293
|
disconnect() {
|
|
99
|
-
|
|
100
|
-
|
|
294
|
+
this.#connected = false;
|
|
295
|
+
this.#listeners.dispose();
|
|
101
296
|
this.#timers.clearAll();
|
|
102
297
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
298
|
+
offlineTargetConnected() {
|
|
299
|
+
if (this.#connected) this.#paint();
|
|
300
|
+
}
|
|
301
|
+
offlineTargetDisconnected(banner) {
|
|
302
|
+
if (!this.offlineTargets.includes(banner)) this.#hidden.return(banner);
|
|
303
|
+
if (this.#connected) this.#paint();
|
|
304
|
+
}
|
|
305
|
+
onlineTargetConnected() {
|
|
306
|
+
if (this.#connected) this.#paint();
|
|
307
|
+
}
|
|
308
|
+
onlineTargetDisconnected(banner) {
|
|
309
|
+
if (!this.onlineTargets.includes(banner)) this.#hidden.return(banner);
|
|
310
|
+
if (this.#connected) this.#paint();
|
|
311
|
+
}
|
|
112
312
|
#update(online) {
|
|
113
313
|
if (online === this.#online) return;
|
|
114
314
|
this.#online = online;
|
|
@@ -123,30 +323,36 @@ var NetworkStatusController = class extends Controller {
|
|
|
123
323
|
});
|
|
124
324
|
this.dispatch("change", { detail: { online } });
|
|
125
325
|
}
|
|
126
|
-
/** Shows the offline banner and hides the recovery banner. */
|
|
127
326
|
#showOffline() {
|
|
128
327
|
this.#timers.clearAll();
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Shows the recovery banner, optionally auto-hiding it after `onlineAutoHide`.
|
|
134
|
-
*
|
|
135
|
-
* @stimeoRuntimeOnly `onlineAutoHide` is the delay of the one timer that hides the banner this
|
|
136
|
-
* transition shows.
|
|
137
|
-
*/
|
|
328
|
+
this.#recoveryShown = false;
|
|
329
|
+
this.#paint();
|
|
330
|
+
}
|
|
138
331
|
#showOnline() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this
|
|
142
|
-
if (this.onlineAutoHideValue > 0) {
|
|
332
|
+
this.#recoveryShown = true;
|
|
333
|
+
this.#paint();
|
|
334
|
+
if (this.#safeOnlineAutoHide > 0) {
|
|
143
335
|
this.#timers.set(() => {
|
|
144
|
-
this
|
|
145
|
-
|
|
336
|
+
this.#recoveryShown = false;
|
|
337
|
+
this.#paint();
|
|
338
|
+
}, this.#safeOnlineAutoHide);
|
|
146
339
|
}
|
|
147
340
|
}
|
|
341
|
+
#paint() {
|
|
342
|
+
if (this.hasOfflineTarget) this.#hidden.write(this.offlineTarget, this.#online ? "" : null);
|
|
343
|
+
if (this.hasOnlineTarget)
|
|
344
|
+
this.#hidden.write(this.onlineTarget, this.#recoveryShown ? null : "");
|
|
345
|
+
}
|
|
346
|
+
get #safeOnlineAutoHide() {
|
|
347
|
+
return this.#numbers.read(
|
|
348
|
+
this,
|
|
349
|
+
"onlineAutoHide",
|
|
350
|
+
this.onlineAutoHideValue,
|
|
351
|
+
_NetworkStatusController.values.onlineAutoHide.default,
|
|
352
|
+
_NetworkStatusController.valueConstraints.onlineAutoHide
|
|
353
|
+
);
|
|
354
|
+
}
|
|
148
355
|
};
|
|
149
356
|
|
|
150
357
|
export { NetworkStatusController };
|
|
151
|
-
//# sourceMappingURL=network_status_controller.js.map
|
|
152
358
|
//# sourceMappingURL=network_status_controller.js.map
|