stimeo-ui 0.18.1 → 0.19.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 +54 -0
- data/dist/cable/index.js +6 -5
- data/dist/controllers/alert_dialog_controller.js +324 -76
- data/dist/controllers/announcer_controller.js +22 -9
- data/dist/controllers/auto_submit_controller.js +103 -16
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +31 -13
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +103 -16
- data/dist/controllers/clipboard_controller.js +6 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +155 -26
- data/dist/controllers/command_palette_controller.js +445 -117
- data/dist/controllers/conditional_fields_controller.js +84 -44
- data/dist/controllers/confirm_controller.js +303 -68
- data/dist/controllers/context_menu_controller.js +59 -30
- data/dist/controllers/countdown_controller.js +6 -5
- data/dist/controllers/currency_input_controller.js +72 -7
- data/dist/controllers/data_grid_controller.js +273 -51
- data/dist/controllers/date_range_picker_controller.js +27 -5
- data/dist/controllers/dialog_controller.js +330 -79
- data/dist/controllers/direct_upload_controller.js +6 -5
- data/dist/controllers/dismissible_controller.js +68 -18
- data/dist/controllers/drawer_controller.js +362 -92
- data/dist/controllers/dropdown_controller.js +64 -52
- data/dist/controllers/editable_controller.js +140 -12
- data/dist/controllers/empty_state_controller.js +193 -9
- data/dist/controllers/file_dropzone_controller.js +313 -23
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +205 -17
- data/dist/controllers/focus_controller.js +273 -57
- data/dist/controllers/form_field_controller.js +71 -14
- data/dist/controllers/form_validation_controller.js +11 -7
- data/dist/controllers/frame_loading_controller.js +75 -20
- data/dist/controllers/hover_card_controller.js +108 -39
- data/dist/controllers/input_mask_controller.js +95 -37
- data/dist/controllers/intersection_controller.js +61 -29
- data/dist/controllers/lazy_frame_controller.js +61 -29
- data/dist/controllers/listbox_controller.js +174 -83
- data/dist/controllers/local_time_controller.js +1 -7
- data/dist/controllers/menu_controller.js +45 -24
- data/dist/controllers/menubar_controller.js +232 -52
- data/dist/controllers/meter_controller.js +31 -9
- data/dist/controllers/multi_select_controller.js +195 -62
- data/dist/controllers/navigation_menu_controller.js +1 -1
- data/dist/controllers/nested_form_controller.js +275 -21
- data/dist/controllers/network_status_controller.js +31 -9
- data/dist/controllers/number_input_controller.js +180 -71
- data/dist/controllers/otp_controller.js +97 -11
- data/dist/controllers/overflow_menu_controller.js +190 -24
- data/dist/controllers/pagination_controller.js +186 -24
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/password_strength_controller.js +6 -5
- data/dist/controllers/popover_controller.js +466 -42
- data/dist/controllers/progress_controller.js +31 -9
- data/dist/controllers/radio_group_controller.js +279 -88
- data/dist/controllers/range_slider_controller.js +72 -54
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/relative_time_controller.js +1 -7
- data/dist/controllers/roving_controller.js +204 -8
- data/dist/controllers/scroll_area_controller.js +61 -19
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +240 -32
- data/dist/controllers/separator_controller.js +97 -58
- data/dist/controllers/sidebar_controller.js +368 -127
- data/dist/controllers/skeleton_controller.js +75 -20
- data/dist/controllers/slider_controller.js +72 -54
- data/dist/controllers/sortable_controller.js +6 -5
- data/dist/controllers/spinner_controller.js +75 -20
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +86 -33
- data/dist/controllers/submit_once_controller.js +31 -9
- data/dist/controllers/switch_controller.js +84 -44
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +293 -29
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/time_picker_controller.js +77 -42
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +282 -79
- data/dist/controllers/toolbar_controller.js +276 -15
- data/dist/controllers/tooltip_controller.js +244 -46
- data/dist/controllers/tree_view_controller.js +287 -57
- data/dist/index.js +2258 -1016
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -7,18 +7,20 @@ function fillTemplate(template, values) {
|
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
10
11
|
function announce(message, options = {}) {
|
|
11
12
|
const text = message.trim();
|
|
12
13
|
if (text.length === 0) return;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
14
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
15
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
16
|
+
});
|
|
17
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
18
|
+
window.dispatchEvent(event);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
21
22
|
if (element.getAttribute(name) === value) return false;
|
|
23
|
+
beforeWrite?.();
|
|
22
24
|
if (value === null) element.removeAttribute(name);
|
|
23
25
|
else element.setAttribute(name, value);
|
|
24
26
|
return true;
|
|
@@ -92,14 +94,34 @@ var AttributeLease = class {
|
|
|
92
94
|
const names = registry.names;
|
|
93
95
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
94
96
|
}
|
|
95
|
-
write(element, value) {
|
|
97
|
+
write(element, value, beforeWrite) {
|
|
96
98
|
const stack = attributeStack(element, this.#attribute);
|
|
97
99
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
98
100
|
this.#held.add(element);
|
|
99
101
|
const shows = !this.#covered(element, stack, hold);
|
|
100
102
|
hold.written = value;
|
|
101
103
|
this.#mark(element, stack);
|
|
102
|
-
if (shows) this.#reflect(element, value);
|
|
104
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
105
|
+
}
|
|
106
|
+
adopt(element, options = {}) {
|
|
107
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
108
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
109
|
+
const stack = attributeStack(element, this.#attribute);
|
|
110
|
+
const hold = this.#take(stack);
|
|
111
|
+
if (!hold) return false;
|
|
112
|
+
const current = element.getAttribute(this.#attribute);
|
|
113
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
this.#held.add(element);
|
|
117
|
+
hold.original = current;
|
|
118
|
+
hold.linked = false;
|
|
119
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
120
|
+
if (!above.linked) break;
|
|
121
|
+
above.original = current;
|
|
122
|
+
}
|
|
123
|
+
this.#mark(element, stack);
|
|
124
|
+
return true;
|
|
103
125
|
}
|
|
104
126
|
return(element) {
|
|
105
127
|
const held = this.#held.delete(element);
|
|
@@ -165,8 +187,8 @@ var AttributeLease = class {
|
|
|
165
187
|
setAttributeIfChanged(element, name, recorded);
|
|
166
188
|
}
|
|
167
189
|
}
|
|
168
|
-
#reflect(element, value) {
|
|
169
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
190
|
+
#reflect(element, value, beforeWrite) {
|
|
191
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
170
192
|
}
|
|
171
193
|
};
|
|
172
194
|
|
|
@@ -180,7 +202,50 @@ function isCompositionInputType(inputType) {
|
|
|
180
202
|
return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
|
|
181
203
|
}
|
|
182
204
|
var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
|
|
183
|
-
var textOf = (element) =>
|
|
205
|
+
var textOf = (element) => {
|
|
206
|
+
if ("value" in element) return element.value;
|
|
207
|
+
return element instanceof Element ? element.textContent : void 0;
|
|
208
|
+
};
|
|
209
|
+
var nodesOf = (element) => {
|
|
210
|
+
const nodes = [];
|
|
211
|
+
if ("value" in element || !(element instanceof Element)) return nodes;
|
|
212
|
+
const walker = element.ownerDocument.createTreeWalker(element);
|
|
213
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
|
|
214
|
+
return nodes;
|
|
215
|
+
};
|
|
216
|
+
var folded = (text) => text.replaceAll("\xA0", " ");
|
|
217
|
+
var startOf = (node, data, replaced, caret) => {
|
|
218
|
+
const text = folded(node.data);
|
|
219
|
+
const composed = folded(data);
|
|
220
|
+
if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
|
|
221
|
+
return replaced.startOffset;
|
|
222
|
+
}
|
|
223
|
+
const start = text.lastIndexOf(composed, caret);
|
|
224
|
+
return start !== -1 && start + composed.length >= caret ? start : -1;
|
|
225
|
+
};
|
|
226
|
+
var spotOf = (element, replaced, data) => {
|
|
227
|
+
if ("value" in element || !(element instanceof Element)) return null;
|
|
228
|
+
const selection = element.ownerDocument.getSelection();
|
|
229
|
+
const node = selection?.focusNode;
|
|
230
|
+
if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
|
|
231
|
+
const range = element.ownerDocument.createRange();
|
|
232
|
+
const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
|
|
233
|
+
if (start === -1) {
|
|
234
|
+
range.selectNodeContents(node);
|
|
235
|
+
} else {
|
|
236
|
+
range.setStart(node, start);
|
|
237
|
+
range.setEnd(node, start + data.length);
|
|
238
|
+
}
|
|
239
|
+
return range;
|
|
240
|
+
};
|
|
241
|
+
var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
|
|
242
|
+
var rewritten = ({ element, text, nodes, spot }) => {
|
|
243
|
+
if (spot !== null) {
|
|
244
|
+
return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
|
|
245
|
+
}
|
|
246
|
+
const current = nodesOf(element);
|
|
247
|
+
return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
|
|
248
|
+
};
|
|
184
249
|
var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
|
|
185
250
|
var CompositionTracker = class {
|
|
186
251
|
#observedTargets = /* @__PURE__ */ new Set();
|
|
@@ -241,7 +306,7 @@ var CompositionTracker = class {
|
|
|
241
306
|
this.#confirmedTarget = null;
|
|
242
307
|
if (confirmed === null || confirmed !== event.target) return false;
|
|
243
308
|
const inputType = event.inputType;
|
|
244
|
-
return
|
|
309
|
+
return inputType ? isCompositionInputType(inputType) : event.isTrusted === true;
|
|
245
310
|
}
|
|
246
311
|
#release(target) {
|
|
247
312
|
target.removeEventListener("compositionstart", this.#handleStart);
|
|
@@ -271,11 +336,11 @@ var CompositionTracker = class {
|
|
|
271
336
|
}
|
|
272
337
|
#settle() {
|
|
273
338
|
const composition = this.#composition;
|
|
274
|
-
if (composition === null) return;
|
|
275
|
-
const { target, element
|
|
339
|
+
if (composition === null || !this.#observedTargets.has(composition.target)) return;
|
|
340
|
+
const { target, element } = composition;
|
|
276
341
|
if (target instanceof Node && element instanceof Node && !target.contains(element)) {
|
|
277
342
|
this.#composition = null;
|
|
278
|
-
} else if (
|
|
343
|
+
} else if (rewritten(composition)) {
|
|
279
344
|
this.#abandon(false);
|
|
280
345
|
}
|
|
281
346
|
}
|
|
@@ -300,7 +365,14 @@ var CompositionTracker = class {
|
|
|
300
365
|
this.#owe(true);
|
|
301
366
|
const target = event.currentTarget;
|
|
302
367
|
const element = event.target;
|
|
303
|
-
this.#composition = {
|
|
368
|
+
this.#composition = {
|
|
369
|
+
target,
|
|
370
|
+
element,
|
|
371
|
+
text: textOf(element),
|
|
372
|
+
nodes: nodesOf(element),
|
|
373
|
+
spot: spotOf(element, null, void 0),
|
|
374
|
+
replaced: null
|
|
375
|
+
};
|
|
304
376
|
this.#runAbandon();
|
|
305
377
|
this.#onStart?.(event);
|
|
306
378
|
};
|
|
@@ -324,6 +396,10 @@ var CompositionTracker = class {
|
|
|
324
396
|
if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
|
|
325
397
|
this.#abandon(true);
|
|
326
398
|
}
|
|
399
|
+
const composition = this.#composition;
|
|
400
|
+
if (composition !== null && event.target === composition.element) {
|
|
401
|
+
composition.replaced = replacedBy(event);
|
|
402
|
+
}
|
|
327
403
|
this.#runAbandon();
|
|
328
404
|
};
|
|
329
405
|
#handleInput = (event) => {
|
|
@@ -331,6 +407,15 @@ var CompositionTracker = class {
|
|
|
331
407
|
const { isTrusted, isComposing, inputType } = event;
|
|
332
408
|
if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
|
|
333
409
|
composition.text = textOf(composition.element);
|
|
410
|
+
composition.nodes = nodesOf(composition.element);
|
|
411
|
+
if (isCompositionInputType(inputType)) {
|
|
412
|
+
composition.spot = spotOf(
|
|
413
|
+
composition.element,
|
|
414
|
+
composition.replaced,
|
|
415
|
+
event.data
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
composition.replaced = null;
|
|
334
419
|
} else {
|
|
335
420
|
this.#settle();
|
|
336
421
|
}
|
|
@@ -351,7 +436,9 @@ var CompositionTracker = class {
|
|
|
351
436
|
const composition = this.#composition;
|
|
352
437
|
if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
|
|
353
438
|
const detail = event.detail;
|
|
354
|
-
if (detail?.attributeName === "value"
|
|
439
|
+
if (detail?.attributeName === "value" && "value" in composition.element) {
|
|
440
|
+
event.preventDefault();
|
|
441
|
+
}
|
|
355
442
|
};
|
|
356
443
|
};
|
|
357
444
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
3
4
|
function announce(message, options = {}) {
|
|
4
5
|
const text = message.trim();
|
|
5
6
|
if (text.length === 0) return;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
7
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
8
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
9
|
+
});
|
|
10
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
11
|
+
window.dispatchEvent(event);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
function setDefaultAttribute(element, name, value) {
|
|
@@ -2,6 +2,7 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
2
2
|
|
|
3
3
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
4
4
|
if (element.getAttribute(name) === value) return false;
|
|
5
|
+
beforeWrite?.();
|
|
5
6
|
if (value === null) element.removeAttribute(name);
|
|
6
7
|
else element.setAttribute(name, value);
|
|
7
8
|
return true;
|
|
@@ -75,14 +76,34 @@ var AttributeLease = class {
|
|
|
75
76
|
const names = registry.names;
|
|
76
77
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
77
78
|
}
|
|
78
|
-
write(element, value) {
|
|
79
|
+
write(element, value, beforeWrite) {
|
|
79
80
|
const stack = attributeStack(element, this.#attribute);
|
|
80
81
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
81
82
|
this.#held.add(element);
|
|
82
83
|
const shows = !this.#covered(element, stack, hold);
|
|
83
84
|
hold.written = value;
|
|
84
85
|
this.#mark(element, stack);
|
|
85
|
-
if (shows) this.#reflect(element, value);
|
|
86
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
87
|
+
}
|
|
88
|
+
adopt(element, options = {}) {
|
|
89
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
90
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
91
|
+
const stack = attributeStack(element, this.#attribute);
|
|
92
|
+
const hold = this.#take(stack);
|
|
93
|
+
if (!hold) return false;
|
|
94
|
+
const current = element.getAttribute(this.#attribute);
|
|
95
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
this.#held.add(element);
|
|
99
|
+
hold.original = current;
|
|
100
|
+
hold.linked = false;
|
|
101
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
102
|
+
if (!above.linked) break;
|
|
103
|
+
above.original = current;
|
|
104
|
+
}
|
|
105
|
+
this.#mark(element, stack);
|
|
106
|
+
return true;
|
|
86
107
|
}
|
|
87
108
|
return(element) {
|
|
88
109
|
const held = this.#held.delete(element);
|
|
@@ -148,8 +169,8 @@ var AttributeLease = class {
|
|
|
148
169
|
setAttributeIfChanged(element, name, recorded);
|
|
149
170
|
}
|
|
150
171
|
}
|
|
151
|
-
#reflect(element, value) {
|
|
152
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
172
|
+
#reflect(element, value, beforeWrite) {
|
|
173
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
153
174
|
}
|
|
154
175
|
};
|
|
155
176
|
|
|
@@ -476,6 +497,7 @@ var CollapsibleController = class extends Controller {
|
|
|
476
497
|
);
|
|
477
498
|
#connected = false;
|
|
478
499
|
#reporting = false;
|
|
500
|
+
#syncedTrigger = null;
|
|
479
501
|
connect() {
|
|
480
502
|
this.#connected = true;
|
|
481
503
|
this.#apply(this.#initialOpen(), false, "api");
|
|
@@ -496,6 +518,7 @@ var CollapsibleController = class extends Controller {
|
|
|
496
518
|
disconnect() {
|
|
497
519
|
this.#connected = false;
|
|
498
520
|
this.#reporting = false;
|
|
521
|
+
this.#syncedTrigger = null;
|
|
499
522
|
this.#transition.cancel();
|
|
500
523
|
}
|
|
501
524
|
triggerTargetConnected(trigger) {
|
|
@@ -509,6 +532,7 @@ var CollapsibleController = class extends Controller {
|
|
|
509
532
|
if (this.#connected && this.hasTriggerTarget) this.#reconcileTrigger(this.triggerTarget);
|
|
510
533
|
}
|
|
511
534
|
#reconcileTrigger(trigger) {
|
|
535
|
+
if (this.hasTriggerTarget && this.triggerTarget === trigger) this.#syncedTrigger = trigger;
|
|
512
536
|
if (this.hasContentTarget) {
|
|
513
537
|
this.#expanded.write(
|
|
514
538
|
trigger,
|
|
@@ -549,16 +573,19 @@ var CollapsibleController = class extends Controller {
|
|
|
549
573
|
this.#apply(!this.#isOpen, true, stateReasonFor(event));
|
|
550
574
|
}
|
|
551
575
|
get #isOpen() {
|
|
552
|
-
|
|
553
|
-
|
|
576
|
+
const trigger = this.hasTriggerTarget ? this.triggerTarget : null;
|
|
577
|
+
if (trigger && (trigger === this.#syncedTrigger || !this.hasContentTarget)) {
|
|
578
|
+
return trigger.getAttribute("aria-expanded") === "true";
|
|
554
579
|
}
|
|
555
580
|
return this.hasContentTarget && this.contentTarget.getAttribute("data-state") === "open";
|
|
556
581
|
}
|
|
557
582
|
#apply(open, waitForCloseTransition, reason) {
|
|
558
583
|
const was = this.#isOpen;
|
|
559
584
|
if (this.hasTriggerTarget) {
|
|
560
|
-
this
|
|
561
|
-
this.#
|
|
585
|
+
const trigger = this.triggerTarget;
|
|
586
|
+
this.#syncedTrigger = trigger;
|
|
587
|
+
this.#expanded.write(trigger, open ? "true" : "false");
|
|
588
|
+
this.#labels.reflect(trigger, open);
|
|
562
589
|
}
|
|
563
590
|
if (this.hasContentTarget) {
|
|
564
591
|
const content = this.contentTarget;
|