stimeo-ui 0.2.0 → 0.2.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 +59 -0
- data/dist/controllers/alert_dialog_controller.js +318 -0
- data/dist/controllers/carousel_controller.js +272 -0
- data/dist/controllers/clipboard_controller.js +144 -0
- data/dist/controllers/collapsible_controller.js +327 -0
- data/dist/controllers/color_picker_controller.js +213 -0
- data/dist/controllers/count_up_controller.js +8 -1
- data/dist/controllers/currency_input_controller.js +147 -0
- data/dist/controllers/data_grid_controller.js +168 -0
- data/dist/controllers/date_range_picker_controller.js +417 -0
- data/dist/controllers/dismissible_controller.js +117 -0
- data/dist/controllers/drawer_controller.js +630 -0
- data/dist/controllers/editable_controller.js +168 -0
- data/dist/controllers/file_dropzone_controller.js +165 -0
- data/dist/controllers/filter_controller.js +86 -0
- data/dist/controllers/flash_controller.js +36 -5
- data/dist/controllers/highlight_controller.js +6 -4
- data/dist/controllers/intersection_controller.js +41 -18
- data/dist/controllers/lazy_frame_controller.js +33 -11
- data/dist/controllers/masonry_controller.js +142 -0
- data/dist/controllers/menubar_controller.js +433 -0
- data/dist/controllers/multi_select_controller.js +472 -0
- data/dist/controllers/navigation_menu_controller.js +384 -0
- data/dist/controllers/overflow_indicator_controller.js +178 -27
- data/dist/controllers/password_reveal_controller.js +117 -0
- data/dist/controllers/range_slider_controller.js +166 -0
- data/dist/controllers/read_more_controller.js +194 -0
- data/dist/controllers/scroll_area_controller.js +15 -2
- data/dist/controllers/scroll_restore_controller.js +93 -0
- data/dist/controllers/scroll_visibility_controller.js +8 -4
- data/dist/controllers/scrollspy_controller.js +33 -11
- data/dist/controllers/separator_controller.js +87 -0
- data/dist/controllers/sidebar_controller.js +761 -0
- data/dist/controllers/stepper_controller.js +28 -12
- data/dist/controllers/stick_to_bottom_controller.js +8 -4
- data/dist/controllers/sticky_observer_controller.js +88 -20
- data/dist/controllers/tags_input_controller.js +275 -0
- data/dist/controllers/theme_controller.js +20 -10
- data/dist/controllers/time_picker_controller.js +212 -0
- data/dist/controllers/toast_controller.js +36 -9
- data/dist/controllers/transition_controller.js +153 -38
- data/dist/controllers/tree_view_controller.js +275 -0
- data/dist/index.js +811 -295
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +28 -2
|
@@ -18,6 +18,11 @@ var IntersectionWatcher = class {
|
|
|
18
18
|
* (Re)creates the observer and observes `targets`. Returns `false` — leaving
|
|
19
19
|
* the watcher inert — without `IntersectionObserver` support (very old
|
|
20
20
|
* browsers; the caller's no-JS fallback stays in charge) or with no targets.
|
|
21
|
+
*
|
|
22
|
+
* @throws Whatever the platform throws for an invalid `rootMargin`/`threshold`
|
|
23
|
+
* or a failing `observe()`. The exception is passed through unchanged, but
|
|
24
|
+
* the watcher rolls back first: every target observed so far is released and
|
|
25
|
+
* `active` stays `false`, so a caller that retries starts from a clean slate.
|
|
21
26
|
*/
|
|
22
27
|
start(targets, options = {}) {
|
|
23
28
|
this.stop();
|
|
@@ -25,25 +30,42 @@ var IntersectionWatcher = class {
|
|
|
25
30
|
const list = Array.isArray(targets) ? targets : [targets];
|
|
26
31
|
if (list.length === 0) return false;
|
|
27
32
|
const root = "root" in options ? options.root ?? null : options.rootSelector ? document.querySelector(options.rootSelector) : null;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
let observer = null;
|
|
34
|
+
try {
|
|
35
|
+
observer = new IntersectionObserver(
|
|
36
|
+
(entries) => {
|
|
37
|
+
if (this.#active && this.#observer === observer) this.#onEntries(entries);
|
|
38
|
+
},
|
|
39
|
+
{ root, rootMargin: options.rootMargin, threshold: options.threshold }
|
|
40
|
+
);
|
|
41
|
+
for (const target of list) observer.observe(target);
|
|
42
|
+
this.#observer = observer;
|
|
43
|
+
this.#active = true;
|
|
44
|
+
return true;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
observer?.disconnect();
|
|
47
|
+
this.#observer = null;
|
|
48
|
+
this.#active = false;
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
/**
|
|
39
53
|
* Re-delivers `target`'s CURRENT intersection state: `IntersectionObserver`
|
|
40
54
|
* only reports *changes*, but `observe()` always reports the present state,
|
|
41
55
|
* so unobserve→observe turns "still intersecting" into a fresh callback.
|
|
56
|
+
*
|
|
57
|
+
* @throws Whatever `unobserve()`/`observe()` throws. The watcher is stopped
|
|
58
|
+
* first, so it never stays live with a half-rearmed target.
|
|
42
59
|
*/
|
|
43
60
|
rearm(target) {
|
|
44
61
|
if (!this.#observer) return;
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
try {
|
|
63
|
+
this.#observer.unobserve(target);
|
|
64
|
+
this.#observer.observe(target);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
this.stop();
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
47
69
|
}
|
|
48
70
|
/** Severs the observer; late queued callbacks become no-ops via the guard. */
|
|
49
71
|
stop() {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Controller } from '@hotwired/stimulus';
|
|
2
|
+
|
|
3
|
+
// src/controllers/separator_controller.ts
|
|
4
|
+
var SeparatorController = class extends Controller {
|
|
5
|
+
static values = {
|
|
6
|
+
orientation: { type: String, default: "horizontal" },
|
|
7
|
+
focusable: { type: Boolean, default: false },
|
|
8
|
+
step: { type: Number, default: 1 }
|
|
9
|
+
};
|
|
10
|
+
static actions = ["onKeydown"];
|
|
11
|
+
static events = ["change"];
|
|
12
|
+
connect() {
|
|
13
|
+
if (!this.element.hasAttribute("role")) {
|
|
14
|
+
this.element.setAttribute("role", "separator");
|
|
15
|
+
}
|
|
16
|
+
if (!this.element.hasAttribute("aria-orientation")) {
|
|
17
|
+
this.element.setAttribute("aria-orientation", this.orientationValue);
|
|
18
|
+
}
|
|
19
|
+
if (this.focusableValue) {
|
|
20
|
+
if (!this.element.hasAttribute("tabindex")) {
|
|
21
|
+
this.element.setAttribute("tabindex", "0");
|
|
22
|
+
}
|
|
23
|
+
this.#setDefault("aria-valuemin", "0");
|
|
24
|
+
this.#setDefault("aria-valuemax", "100");
|
|
25
|
+
this.#setDefault("aria-valuenow", String(this.#clamp(this.#value)));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Adjusts the value on arrow / Home / End keys (focusable variant only). */
|
|
29
|
+
onKeydown(event) {
|
|
30
|
+
if (!this.focusableValue) return;
|
|
31
|
+
const horizontal = this.element.getAttribute("aria-orientation") !== "vertical";
|
|
32
|
+
let next = null;
|
|
33
|
+
switch (event.key) {
|
|
34
|
+
case "ArrowUp":
|
|
35
|
+
if (horizontal) next = this.#value + this.stepValue;
|
|
36
|
+
break;
|
|
37
|
+
case "ArrowDown":
|
|
38
|
+
if (horizontal) next = this.#value - this.stepValue;
|
|
39
|
+
break;
|
|
40
|
+
case "ArrowRight":
|
|
41
|
+
if (!horizontal) next = this.#value + this.stepValue;
|
|
42
|
+
break;
|
|
43
|
+
case "ArrowLeft":
|
|
44
|
+
if (!horizontal) next = this.#value - this.stepValue;
|
|
45
|
+
break;
|
|
46
|
+
case "Home":
|
|
47
|
+
next = this.#min;
|
|
48
|
+
break;
|
|
49
|
+
case "End":
|
|
50
|
+
next = this.#max;
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (next === null) return;
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
const clamped = this.#clamp(next);
|
|
58
|
+
if (clamped === this.#value) return;
|
|
59
|
+
this.element.setAttribute("aria-valuenow", String(clamped));
|
|
60
|
+
this.dispatch("change", { detail: { value: clamped } });
|
|
61
|
+
}
|
|
62
|
+
get #value() {
|
|
63
|
+
return this.#numericAttr("aria-valuenow", 0);
|
|
64
|
+
}
|
|
65
|
+
get #min() {
|
|
66
|
+
return this.#numericAttr("aria-valuemin", 0);
|
|
67
|
+
}
|
|
68
|
+
get #max() {
|
|
69
|
+
return this.#numericAttr("aria-valuemax", 100);
|
|
70
|
+
}
|
|
71
|
+
#clamp(value) {
|
|
72
|
+
return Math.min(this.#max, Math.max(this.#min, value));
|
|
73
|
+
}
|
|
74
|
+
#numericAttr(name, fallback) {
|
|
75
|
+
const parsed = Number.parseFloat(this.element.getAttribute(name) ?? "");
|
|
76
|
+
return Number.isNaN(parsed) ? fallback : parsed;
|
|
77
|
+
}
|
|
78
|
+
#setDefault(name, value) {
|
|
79
|
+
if (!this.element.hasAttribute(name)) {
|
|
80
|
+
this.element.setAttribute(name, value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { SeparatorController };
|
|
86
|
+
//# sourceMappingURL=separator_controller.js.map
|
|
87
|
+
//# sourceMappingURL=separator_controller.js.map
|