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,14 +7,15 @@ 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 parseDeclared(raw, parse, fallback) {
|
|
@@ -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,16 +169,21 @@ 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
|
|
|
177
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
156
178
|
function inheritsFieldsetDisabled(control) {
|
|
157
179
|
let fieldset = control.closest("fieldset[disabled]");
|
|
158
180
|
while (fieldset) {
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
182
|
+
const legend = Array.from(fieldset.children).find(
|
|
183
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
184
|
+
);
|
|
185
|
+
if (!legend?.contains(control)) return true;
|
|
186
|
+
}
|
|
161
187
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
162
188
|
}
|
|
163
189
|
return false;
|
|
@@ -215,11 +241,10 @@ function hasNativeTabStop(element) {
|
|
|
215
241
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
216
242
|
return element.hasAttribute("controls");
|
|
217
243
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return false;
|
|
244
|
+
const details = element.parentElement;
|
|
245
|
+
return details instanceof HTMLDetailsElement && Array.from(details.children).find(
|
|
246
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
|
|
247
|
+
) === element;
|
|
223
248
|
}
|
|
224
249
|
function hasEditableTabStop(element) {
|
|
225
250
|
const value = element.getAttribute("contenteditable")?.toLowerCase();
|
|
@@ -236,6 +261,19 @@ function tabStopsWithin(root) {
|
|
|
236
261
|
isTabStop
|
|
237
262
|
);
|
|
238
263
|
}
|
|
264
|
+
function isRadio(element) {
|
|
265
|
+
return element instanceof HTMLInputElement && element.type === "radio";
|
|
266
|
+
}
|
|
267
|
+
function sameRadioGroup(a, b) {
|
|
268
|
+
return a.name !== "" && a.name === b.name && a.form === b.form && a.getRootNode() === b.getRootNode();
|
|
269
|
+
}
|
|
270
|
+
function isUncheckedRadioInCheckedGroup(element) {
|
|
271
|
+
if (!isRadio(element) || element.checked) return false;
|
|
272
|
+
const root = element.getRootNode();
|
|
273
|
+
return Array.from(root.querySelectorAll("input")).some(
|
|
274
|
+
(other) => isRadio(other) && other.checked && sameRadioGroup(other, element) && isTabStop(other)
|
|
275
|
+
);
|
|
276
|
+
}
|
|
239
277
|
|
|
240
278
|
var ListenerSet = class {
|
|
241
279
|
#abort = new AbortController();
|
|
@@ -256,7 +294,8 @@ var DismissibleController = class extends Controller {
|
|
|
256
294
|
};
|
|
257
295
|
static actions = ["dismiss"];
|
|
258
296
|
static events = ["dismiss"];
|
|
259
|
-
#
|
|
297
|
+
#state = new AttributeLease("data-state", this.identifier);
|
|
298
|
+
#hidden = new AttributeLease("hidden", this.identifier);
|
|
260
299
|
#connected = false;
|
|
261
300
|
#escapeListeners = new ListenerSet();
|
|
262
301
|
connect() {
|
|
@@ -267,14 +306,19 @@ var DismissibleController = class extends Controller {
|
|
|
267
306
|
disconnect() {
|
|
268
307
|
this.#connected = false;
|
|
269
308
|
this.#escapeListeners.dispose();
|
|
309
|
+
if (this.element.isConnected && !this.scope.containsElement(this.element)) {
|
|
310
|
+
this.#returnRoot(this.element);
|
|
311
|
+
}
|
|
270
312
|
}
|
|
271
313
|
rootTargetConnected(root) {
|
|
272
314
|
if (!this.#connected) return;
|
|
273
|
-
if (!this.rootTargets.includes(this.element)) this.#
|
|
315
|
+
if (!this.rootTargets.includes(this.element)) this.#returnRoot(this.element);
|
|
274
316
|
this.#establishOpen(root);
|
|
275
317
|
}
|
|
276
318
|
rootTargetDisconnected(root) {
|
|
277
|
-
if (!this.rootTargets.includes(root))
|
|
319
|
+
if ((root.isConnected || this.element.isConnected) && !this.rootTargets.includes(root)) {
|
|
320
|
+
this.#returnRoot(root);
|
|
321
|
+
}
|
|
278
322
|
if (this.#connected && this.hasRootTarget) this.#establishOpen(this.rootTarget);
|
|
279
323
|
}
|
|
280
324
|
closeOnEscapeValueChanged() {
|
|
@@ -298,7 +342,11 @@ var DismissibleController = class extends Controller {
|
|
|
298
342
|
}
|
|
299
343
|
}
|
|
300
344
|
#establishOpen(root) {
|
|
301
|
-
if (!root.hasAttribute("data-state")) this.#
|
|
345
|
+
if (!root.hasAttribute("data-state")) this.#state.write(root, "open");
|
|
346
|
+
}
|
|
347
|
+
#returnRoot(root) {
|
|
348
|
+
this.#state.return(root);
|
|
349
|
+
this.#hidden.return(root);
|
|
302
350
|
}
|
|
303
351
|
get #root() {
|
|
304
352
|
return this.hasRootTarget ? this.rootTarget : this.element;
|
|
@@ -307,10 +355,10 @@ var DismissibleController = class extends Controller {
|
|
|
307
355
|
const root = this.#root;
|
|
308
356
|
const mode = this.modeValue === "hide" ? "hide" : "remove";
|
|
309
357
|
this.#retreatFocus(root);
|
|
310
|
-
|
|
358
|
+
this.#state.write(root, "closing");
|
|
311
359
|
this.dispatch("dismiss", { detail: { mode } });
|
|
312
360
|
if (mode === "hide") {
|
|
313
|
-
root
|
|
361
|
+
this.#hidden.write(root, "");
|
|
314
362
|
} else {
|
|
315
363
|
root.remove();
|
|
316
364
|
}
|
|
@@ -331,7 +379,9 @@ var DismissibleController = class extends Controller {
|
|
|
331
379
|
if (explicitFallback && !root.contains(explicitFallback) && this.#isExplicitFocusAvailable(explicitFallback)) {
|
|
332
380
|
yield explicitFallback;
|
|
333
381
|
}
|
|
334
|
-
const candidates = tabStopsWithin(document)
|
|
382
|
+
const candidates = tabStopsWithin(document).filter(
|
|
383
|
+
(element) => !isUncheckedRadioInCheckedGroup(element)
|
|
384
|
+
);
|
|
335
385
|
for (const element of candidates) {
|
|
336
386
|
if (element === explicitFallback || root.contains(element) || !(root.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING)) {
|
|
337
387
|
continue;
|