stimeo-ui 0.17.0 → 0.18.1
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 -2
- data/README.md +19 -10
- data/dist/cable/index.js +22 -14
- data/dist/controllers/accordion_controller.js +14 -6
- data/dist/controllers/alert_dialog_controller.js +145 -118
- data/dist/controllers/announcer_controller.js +113 -17
- data/dist/controllers/auto_submit_controller.js +185 -60
- data/dist/controllers/avatar_controller.js +55 -43
- data/dist/controllers/bulk_select_controller.js +64 -50
- data/dist/controllers/calendar_controller.js +55 -53
- data/dist/controllers/carousel_controller.js +124 -86
- data/dist/controllers/character_counter_controller.js +291 -95
- data/dist/controllers/checkbox_controller.js +6 -0
- data/dist/controllers/clipboard_controller.js +118 -27
- data/dist/controllers/collapsible_controller.js +52 -49
- data/dist/controllers/color_picker_controller.js +29 -7
- data/dist/controllers/combobox_controller.js +210 -71
- data/dist/controllers/command_palette_controller.js +290 -140
- data/dist/controllers/conditional_fields_controller.js +145 -58
- data/dist/controllers/confirm_controller.js +145 -118
- data/dist/controllers/context_menu_controller.js +138 -73
- data/dist/controllers/countdown_controller.js +109 -21
- data/dist/controllers/currency_input_controller.js +446 -72
- data/dist/controllers/data_grid_controller.js +134 -28
- data/dist/controllers/date_range_picker_controller.js +93 -72
- data/dist/controllers/dialog_controller.js +145 -118
- data/dist/controllers/direct_upload_controller.js +24 -14
- data/dist/controllers/dirty_form_controller.js +68 -31
- data/dist/controllers/dismissible_controller.js +66 -46
- data/dist/controllers/drawer_controller.js +145 -118
- data/dist/controllers/dropdown_controller.js +76 -63
- data/dist/controllers/editable_controller.js +200 -62
- data/dist/controllers/empty_state_controller.js +13 -6
- data/dist/controllers/file_dropzone_controller.js +55 -48
- data/dist/controllers/filter_controller.js +9 -2
- data/dist/controllers/flash_controller.js +66 -33
- data/dist/controllers/focus_controller.js +39 -14
- data/dist/controllers/form_field_controller.js +52 -43
- data/dist/controllers/form_validation_controller.js +18 -11
- data/dist/controllers/frame_loading_controller.js +55 -48
- data/dist/controllers/hover_card_controller.js +67 -61
- data/dist/controllers/idle_controller.js +10 -6
- data/dist/controllers/input_mask_controller.js +434 -24
- data/dist/controllers/intersection_controller.js +3 -0
- data/dist/controllers/lazy_frame_controller.js +15 -3
- data/dist/controllers/listbox_controller.js +260 -79
- data/dist/controllers/local_time_controller.js +48 -13
- data/dist/controllers/masonry_controller.js +11 -4
- data/dist/controllers/menu_controller.js +138 -82
- data/dist/controllers/menubar_controller.js +65 -19
- data/dist/controllers/meter_controller.js +270 -24
- data/dist/controllers/multi_select_controller.js +272 -95
- data/dist/controllers/navigation_menu_controller.js +67 -19
- data/dist/controllers/nested_form_controller.js +98 -64
- data/dist/controllers/network_status_controller.js +70 -52
- data/dist/controllers/number_input_controller.js +344 -94
- data/dist/controllers/optimistic_controller.js +29 -11
- data/dist/controllers/otp_controller.js +502 -104
- data/dist/controllers/overflow_indicator_controller.js +6 -0
- data/dist/controllers/overflow_menu_controller.js +136 -21
- data/dist/controllers/pagination_controller.js +47 -14
- data/dist/controllers/password_reveal_controller.js +52 -49
- data/dist/controllers/password_strength_controller.js +13 -6
- data/dist/controllers/persist_controller.js +48 -128
- data/dist/controllers/pointer_drag_controller.js +255 -24
- data/dist/controllers/popover_controller.js +91 -65
- data/dist/controllers/portal_controller.js +6 -0
- data/dist/controllers/preview_guard_controller.js +14 -3
- data/dist/controllers/progress_controller.js +271 -27
- data/dist/controllers/radio_group_controller.js +167 -80
- data/dist/controllers/range_slider_controller.js +27 -7
- data/dist/controllers/rating_controller.js +93 -57
- data/dist/controllers/read_more_controller.js +10 -6
- data/dist/controllers/reading_progress_controller.js +22 -5
- data/dist/controllers/relative_time_controller.js +75 -11
- data/dist/controllers/reset_on_restore_controller.js +6 -0
- data/dist/controllers/resizable_controller.js +55 -22
- data/dist/controllers/roving_controller.js +10 -4
- data/dist/controllers/scroll_area_controller.js +129 -88
- data/dist/controllers/scroll_restore_controller.js +14 -2
- data/dist/controllers/scroll_visibility_controller.js +93 -60
- data/dist/controllers/scrollspy_controller.js +11 -5
- data/dist/controllers/separator_controller.js +59 -43
- data/dist/controllers/sidebar_controller.js +150 -122
- data/dist/controllers/skeleton_controller.js +55 -48
- data/dist/controllers/slider_controller.js +27 -6
- data/dist/controllers/smart_sticky_header_controller.js +13 -5
- data/dist/controllers/sortable_controller.js +27 -14
- data/dist/controllers/spinner_controller.js +55 -48
- data/dist/controllers/step_indicator_controller.js +6 -0
- data/dist/controllers/stepper_controller.js +6 -0
- data/dist/controllers/stick_to_bottom_controller.js +19 -8
- data/dist/controllers/sticky_observer_controller.js +49 -43
- data/dist/controllers/submit_once_controller.js +145 -85
- data/dist/controllers/switch_controller.js +172 -28
- data/dist/controllers/tabs_controller.js +6 -1
- data/dist/controllers/tags_input_controller.js +157 -28
- data/dist/controllers/textarea_autosize_controller.js +40 -19
- data/dist/controllers/theme_controller.js +10 -4
- data/dist/controllers/time_picker_controller.js +192 -54
- data/dist/controllers/toast_controller.js +58 -27
- data/dist/controllers/toggle_group_controller.js +158 -56
- data/dist/controllers/toolbar_controller.js +150 -21
- data/dist/controllers/tree_view_controller.js +134 -25
- data/dist/index.js +2515 -1315
- data/dist/positioning/index.js +6 -0
- 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 +2 -2
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
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
|
+
}
|
|
9
|
+
|
|
3
10
|
function announce(message, options = {}) {
|
|
4
11
|
const text = message.trim();
|
|
5
12
|
if (text.length === 0) return;
|
|
@@ -9,12 +16,6 @@ function announce(message, options = {}) {
|
|
|
9
16
|
})
|
|
10
17
|
);
|
|
11
18
|
}
|
|
12
|
-
function fillTemplate(template, values) {
|
|
13
|
-
return template.replace(/\{([a-zA-Z][a-zA-Z0-9]*)\}/g, (match, name) => {
|
|
14
|
-
const replacement = values[name];
|
|
15
|
-
return replacement === void 0 ? match : String(replacement);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
19
|
|
|
19
20
|
var NUMBER_BOUNDS = {
|
|
20
21
|
finite: { finite: true }};
|
|
@@ -32,6 +33,9 @@ function matchesNumberBounds(value, bounds) {
|
|
|
32
33
|
return true;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
function eventNumber(event) {
|
|
37
|
+
return toFiniteNumber(event.params?.amount ?? event.detail?.value);
|
|
38
|
+
}
|
|
35
39
|
function toFiniteNumber(raw) {
|
|
36
40
|
if (typeof raw !== "number" && typeof raw !== "string") return null;
|
|
37
41
|
if (typeof raw === "string" && raw.trim().length === 0) return null;
|
|
@@ -69,6 +73,9 @@ var MicrotaskCoalescer = class {
|
|
|
69
73
|
this.#queued = false;
|
|
70
74
|
this.#generation += 1;
|
|
71
75
|
}
|
|
76
|
+
get pending() {
|
|
77
|
+
return this.#queued;
|
|
78
|
+
}
|
|
72
79
|
schedule() {
|
|
73
80
|
if (!this.#active || this.#queued) return;
|
|
74
81
|
this.#queued = true;
|
|
@@ -99,6 +106,9 @@ var MorphRenderWatcher = class {
|
|
|
99
106
|
schedule() {
|
|
100
107
|
this.#pass.schedule();
|
|
101
108
|
}
|
|
109
|
+
get pending() {
|
|
110
|
+
return this.#pass.pending;
|
|
111
|
+
}
|
|
102
112
|
disconnect() {
|
|
103
113
|
this.#listeners.dispose();
|
|
104
114
|
this.#pass.cancel();
|
|
@@ -133,7 +143,7 @@ var NumberValueReader = class {
|
|
|
133
143
|
function rangeFraction(value, min, max) {
|
|
134
144
|
const span = max - min;
|
|
135
145
|
if (!(span > 0)) return 0;
|
|
136
|
-
const clamped =
|
|
146
|
+
const clamped = clampRange(value, min, max);
|
|
137
147
|
let fraction;
|
|
138
148
|
if (Number.isFinite(span)) {
|
|
139
149
|
fraction = (clamped - min) / span;
|
|
@@ -144,13 +154,254 @@ function rangeFraction(value, min, max) {
|
|
|
144
154
|
if (!Number.isFinite(fraction)) return 0;
|
|
145
155
|
return Math.min(1, Math.max(0, fraction));
|
|
146
156
|
}
|
|
157
|
+
function clampRange(value, min, max) {
|
|
158
|
+
return Math.min(max, Math.max(min, value));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
162
|
+
if (element.getAttribute(name) === value) return false;
|
|
163
|
+
if (value === null) element.removeAttribute(name);
|
|
164
|
+
else element.setAttribute(name, value);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function sharedRegistry(key, create) {
|
|
169
|
+
const symbol = Symbol.for(key);
|
|
170
|
+
const scope = globalThis;
|
|
171
|
+
const existing = scope[symbol];
|
|
172
|
+
if (existing !== void 0) return existing;
|
|
173
|
+
const registry2 = create();
|
|
174
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
175
|
+
return registry2;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var registry = sharedRegistry(
|
|
179
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
180
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
181
|
+
);
|
|
182
|
+
function isAttributeValue(value) {
|
|
183
|
+
return value === null || typeof value === "string";
|
|
184
|
+
}
|
|
185
|
+
function readLeaseRecord(element, record) {
|
|
186
|
+
try {
|
|
187
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
188
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
189
|
+
const [original, written, ...rest] = parsed;
|
|
190
|
+
const linked = rest[0] !== false;
|
|
191
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
192
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
193
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
194
|
+
} catch {
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function attributeStack(element, attribute) {
|
|
199
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
200
|
+
registry.stacks.set(element, byAttribute);
|
|
201
|
+
const known = byAttribute.get(attribute);
|
|
202
|
+
if (known) return known;
|
|
203
|
+
const found = [];
|
|
204
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
205
|
+
const read = readLeaseRecord(element, record);
|
|
206
|
+
if (read) found.push({ ...read, record });
|
|
207
|
+
}
|
|
208
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
209
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
210
|
+
lease: null,
|
|
211
|
+
record,
|
|
212
|
+
written,
|
|
213
|
+
original,
|
|
214
|
+
linked: linked && index > 0
|
|
215
|
+
}));
|
|
216
|
+
byAttribute.set(attribute, stack);
|
|
217
|
+
return stack;
|
|
218
|
+
}
|
|
219
|
+
function findHold(stack, lease, record) {
|
|
220
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
221
|
+
}
|
|
222
|
+
function readAttributeLease(element, attribute, owner, lease, expected) {
|
|
223
|
+
const stack = attributeStack(element, attribute);
|
|
224
|
+
const hold = findHold(stack, lease, `data-${owner}-${attribute}-lease`);
|
|
225
|
+
const current = element.getAttribute(attribute);
|
|
226
|
+
const covering = [...stack].reverse().find((other) => other.written === current);
|
|
227
|
+
const original = (hold ?? covering)?.original;
|
|
228
|
+
const authored = original === void 0 ? current : original;
|
|
229
|
+
return {
|
|
230
|
+
original: authored,
|
|
231
|
+
allowed: hold ? current === hold.written || stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current) : authored === expected
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
var AttributeLease = class {
|
|
235
|
+
#attribute;
|
|
236
|
+
#record;
|
|
237
|
+
#base;
|
|
238
|
+
#preserveAuthor;
|
|
239
|
+
#held = /* @__PURE__ */ new Set();
|
|
240
|
+
constructor(attribute, owner, options = {}) {
|
|
241
|
+
this.#attribute = attribute;
|
|
242
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
243
|
+
this.#base = options.base === true;
|
|
244
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
245
|
+
const names = registry.names;
|
|
246
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
247
|
+
}
|
|
248
|
+
write(element, value) {
|
|
249
|
+
const stack = attributeStack(element, this.#attribute);
|
|
250
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
251
|
+
this.#held.add(element);
|
|
252
|
+
const shows = !this.#covered(element, stack, hold);
|
|
253
|
+
hold.written = value;
|
|
254
|
+
this.#mark(element, stack);
|
|
255
|
+
if (shows) this.#reflect(element, value);
|
|
256
|
+
}
|
|
257
|
+
return(element) {
|
|
258
|
+
const held = this.#held.delete(element);
|
|
259
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
260
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
261
|
+
const hold = this.#take(stack);
|
|
262
|
+
if (!hold) return false;
|
|
263
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
264
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
265
|
+
const index = stack.indexOf(hold);
|
|
266
|
+
stack.splice(index, 1);
|
|
267
|
+
const above = stack[index];
|
|
268
|
+
if (above) above.linked &&= hold.linked;
|
|
269
|
+
this.#mark(element, stack);
|
|
270
|
+
if (!owns) return true;
|
|
271
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
272
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
returnAll() {
|
|
276
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
277
|
+
}
|
|
278
|
+
#take(stack) {
|
|
279
|
+
const hold = findHold(stack, this, this.#record);
|
|
280
|
+
if (hold) hold.lease = this;
|
|
281
|
+
return hold;
|
|
282
|
+
}
|
|
283
|
+
#acquire(element, stack) {
|
|
284
|
+
const current = element.getAttribute(this.#attribute);
|
|
285
|
+
const top = stack.at(-1);
|
|
286
|
+
const bottom = stack[0];
|
|
287
|
+
const over = top?.written === current ? top : void 0;
|
|
288
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
289
|
+
const hold = {
|
|
290
|
+
lease: this,
|
|
291
|
+
record: this.#record,
|
|
292
|
+
written: current,
|
|
293
|
+
original: from ? from.original : current,
|
|
294
|
+
linked: !this.#base && over !== void 0
|
|
295
|
+
};
|
|
296
|
+
if (this.#base && bottom) {
|
|
297
|
+
bottom.linked = true;
|
|
298
|
+
stack.unshift(hold);
|
|
299
|
+
} else stack.push(hold);
|
|
300
|
+
return hold;
|
|
301
|
+
}
|
|
302
|
+
#covered(element, stack, hold) {
|
|
303
|
+
const current = element.getAttribute(this.#attribute);
|
|
304
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
305
|
+
}
|
|
306
|
+
#mark(element, stack) {
|
|
307
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
308
|
+
stack.forEach((hold, index) => {
|
|
309
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
310
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
311
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
312
|
+
records.set(
|
|
313
|
+
hold.record,
|
|
314
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
for (const [name, recorded] of records) {
|
|
318
|
+
setAttributeIfChanged(element, name, recorded);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
#reflect(element, value) {
|
|
322
|
+
setAttributeIfChanged(element, this.#attribute, value);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
var TemplateAttributeLease = class {
|
|
327
|
+
#lease;
|
|
328
|
+
#record;
|
|
329
|
+
#attribute;
|
|
330
|
+
#owner;
|
|
331
|
+
#states = /* @__PURE__ */ new WeakMap();
|
|
332
|
+
constructor(attribute, owner) {
|
|
333
|
+
this.#attribute = attribute;
|
|
334
|
+
this.#owner = owner;
|
|
335
|
+
this.#lease = new AttributeLease(attribute, owner, { base: true, preserveAuthor: true });
|
|
336
|
+
this.#record = `data-${owner}-${attribute}-template`;
|
|
337
|
+
}
|
|
338
|
+
render(element, source, value) {
|
|
339
|
+
let state = this.#read(element);
|
|
340
|
+
if (!state && source.length === 0) {
|
|
341
|
+
this.#lease.return(element);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (!state || state.source !== source) {
|
|
345
|
+
this.#lease.return(element);
|
|
346
|
+
state = { source, expected: this.#view(element, null).original, yielded: false };
|
|
347
|
+
}
|
|
348
|
+
if (source.length === 0 || value === null) {
|
|
349
|
+
this.#states.set(element, state);
|
|
350
|
+
this.release(element);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (!state.yielded && this.#continues(element, state)) {
|
|
354
|
+
this.#lease.write(element, value);
|
|
355
|
+
state.expected = value;
|
|
356
|
+
} else {
|
|
357
|
+
state.yielded = true;
|
|
358
|
+
this.#lease.return(element);
|
|
359
|
+
}
|
|
360
|
+
this.#mark(element, state);
|
|
361
|
+
}
|
|
362
|
+
release(element) {
|
|
363
|
+
const state = this.#read(element);
|
|
364
|
+
if (state && !state.yielded) {
|
|
365
|
+
state.yielded = !this.#continues(element, state);
|
|
366
|
+
if (!state.yielded) state.expected = this.#view(element, null).original;
|
|
367
|
+
}
|
|
368
|
+
this.#lease.return(element);
|
|
369
|
+
if (state) this.#mark(element, state);
|
|
370
|
+
}
|
|
371
|
+
#continues(element, state) {
|
|
372
|
+
const view = this.#view(element, state.expected);
|
|
373
|
+
return view.allowed || !element.hasAttribute(this.#record) && element.getAttribute(this.#attribute) === view.original;
|
|
374
|
+
}
|
|
375
|
+
#view(element, expected) {
|
|
376
|
+
return readAttributeLease(element, this.#attribute, this.#owner, this.#lease, expected);
|
|
377
|
+
}
|
|
378
|
+
#read(element) {
|
|
379
|
+
const live = this.#states.get(element);
|
|
380
|
+
if (live) return live;
|
|
381
|
+
try {
|
|
382
|
+
const parsed = JSON.parse(element.getAttribute(this.#record) ?? "null");
|
|
383
|
+
if (!Array.isArray(parsed) || parsed.length !== 3) return void 0;
|
|
384
|
+
const [source, expected, yielded] = parsed;
|
|
385
|
+
if (typeof source !== "string" || expected !== null && typeof expected !== "string" || typeof yielded !== "boolean")
|
|
386
|
+
return void 0;
|
|
387
|
+
return { source, expected, yielded };
|
|
388
|
+
} catch {
|
|
389
|
+
return void 0;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
#mark(element, state) {
|
|
393
|
+
this.#states.set(element, state);
|
|
394
|
+
setAttributeIfChanged(
|
|
395
|
+
element,
|
|
396
|
+
this.#record,
|
|
397
|
+
JSON.stringify([state.source, state.expected, state.yielded])
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
147
401
|
|
|
148
|
-
var OWNED_VALUE_TEXT = "owns-valuetext";
|
|
149
402
|
var MeterController = class _MeterController extends Controller {
|
|
150
403
|
#numbers = new NumberValueReader();
|
|
151
|
-
|
|
152
|
-
return `data-${this.identifier}-${OWNED_VALUE_TEXT}`;
|
|
153
|
-
}
|
|
404
|
+
#valueText = new TemplateAttributeLease("aria-valuetext", this.identifier);
|
|
154
405
|
static targets = ["bar"];
|
|
155
406
|
static values = {
|
|
156
407
|
announceText: { type: String, default: "" },
|
|
@@ -182,9 +433,10 @@ var MeterController = class _MeterController extends Controller {
|
|
|
182
433
|
}
|
|
183
434
|
disconnect() {
|
|
184
435
|
this.#repaint.disconnect();
|
|
436
|
+
this.#valueText.release(this.element);
|
|
185
437
|
}
|
|
186
438
|
setValue(event) {
|
|
187
|
-
const next =
|
|
439
|
+
const next = eventNumber(event);
|
|
188
440
|
if (next === null) return;
|
|
189
441
|
this.valueValue = this.#clamp(next);
|
|
190
442
|
const shown = this.#shownState;
|
|
@@ -215,7 +467,7 @@ var MeterController = class _MeterController extends Controller {
|
|
|
215
467
|
this.#repaint.schedule();
|
|
216
468
|
}
|
|
217
469
|
#clamp(raw) {
|
|
218
|
-
return
|
|
470
|
+
return clampRange(raw, this.#safeMin, this.#safeMax);
|
|
219
471
|
}
|
|
220
472
|
#hasThreshold(name) {
|
|
221
473
|
return this.element.hasAttribute(`data-${this.identifier}-${name}-value`);
|
|
@@ -242,17 +494,11 @@ var MeterController = class _MeterController extends Controller {
|
|
|
242
494
|
return reading;
|
|
243
495
|
}
|
|
244
496
|
#applyValueText({ value, ratio, state }) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const percent = Math.round(ratio * 100);
|
|
253
|
-
const text = this.valueTextValue.replaceAll("{value}", String(value)).replaceAll("{percent}", String(percent)).replaceAll("{state}", state);
|
|
254
|
-
this.element.setAttribute("aria-valuetext", text);
|
|
255
|
-
this.element.setAttribute(this.#ownedValueText, "");
|
|
497
|
+
this.#valueText.render(
|
|
498
|
+
this.element,
|
|
499
|
+
this.valueTextValue,
|
|
500
|
+
fillTemplate(this.valueTextValue, { value, percent: Math.round(ratio * 100), state })
|
|
501
|
+
);
|
|
256
502
|
}
|
|
257
503
|
get #safeValue() {
|
|
258
504
|
return this.#numbers.read(
|