stimeo-ui 0.16.0 → 0.17.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 +31 -0
- data/README.md +8 -1
- data/dist/cable/index.js +363 -436
- data/dist/controllers/accordion_controller.js +166 -55
- data/dist/controllers/alert_dialog_controller.js +862 -221
- data/dist/controllers/announcer_controller.js +135 -198
- data/dist/controllers/aspect_ratio_controller.js +0 -10
- data/dist/controllers/auto_submit_controller.js +271 -127
- data/dist/controllers/avatar_controller.js +171 -105
- data/dist/controllers/breadcrumb_controller.js +0 -130
- data/dist/controllers/bulk_select_controller.js +262 -52
- data/dist/controllers/calendar_controller.js +175 -209
- data/dist/controllers/carousel_controller.js +461 -399
- data/dist/controllers/character_counter_controller.js +246 -156
- data/dist/controllers/checkbox_controller.js +32 -74
- data/dist/controllers/clipboard_controller.js +168 -147
- data/dist/controllers/collapsible_controller.js +301 -120
- data/dist/controllers/color_picker_controller.js +149 -139
- data/dist/controllers/combobox_controller.js +360 -133
- data/dist/controllers/command_palette_controller.js +970 -358
- data/dist/controllers/conditional_fields_controller.js +166 -124
- data/dist/controllers/confirm_controller.js +939 -248
- data/dist/controllers/context_menu_controller.js +256 -128
- data/dist/controllers/count_up_controller.js +73 -21
- data/dist/controllers/countdown_controller.js +183 -148
- data/dist/controllers/currency_input_controller.js +134 -158
- data/dist/controllers/data_grid_controller.js +114 -186
- data/dist/controllers/date_range_picker_controller.js +288 -206
- data/dist/controllers/dialog_controller.js +858 -223
- data/dist/controllers/direct_upload_controller.js +73 -153
- data/dist/controllers/dirty_form_controller.js +14 -48
- data/dist/controllers/dismissible_controller.js +175 -21
- data/dist/controllers/drawer_controller.js +933 -341
- data/dist/controllers/dropdown_controller.js +312 -82
- data/dist/controllers/editable_controller.js +158 -68
- data/dist/controllers/empty_state_controller.js +67 -53
- data/dist/controllers/file_dropzone_controller.js +311 -207
- data/dist/controllers/filter_controller.js +67 -39
- data/dist/controllers/flash_controller.js +172 -314
- data/dist/controllers/focus_controller.js +654 -240
- data/dist/controllers/form_field_controller.js +147 -132
- data/dist/controllers/form_validation_controller.js +13 -86
- data/dist/controllers/frame_loading_controller.js +264 -213
- data/dist/controllers/highlight_controller.js +107 -75
- data/dist/controllers/hover_card_controller.js +309 -118
- data/dist/controllers/idle_controller.js +267 -101
- data/dist/controllers/input_mask_controller.js +71 -72
- data/dist/controllers/intersection_controller.js +147 -106
- data/dist/controllers/lazy_frame_controller.js +9 -65
- data/dist/controllers/listbox_controller.js +306 -204
- data/dist/controllers/local_time_controller.js +54 -64
- data/dist/controllers/masonry_controller.js +70 -93
- data/dist/controllers/menu_controller.js +214 -156
- data/dist/controllers/menubar_controller.js +170 -329
- data/dist/controllers/meter_controller.js +151 -67
- data/dist/controllers/multi_select_controller.js +593 -358
- data/dist/controllers/navigation_menu_controller.js +124 -232
- data/dist/controllers/nested_form_controller.js +352 -182
- data/dist/controllers/network_status_controller.js +242 -54
- data/dist/controllers/number_input_controller.js +320 -263
- data/dist/controllers/optimistic_controller.js +16 -76
- data/dist/controllers/otp_controller.js +198 -193
- data/dist/controllers/overflow_indicator_controller.js +116 -113
- data/dist/controllers/overflow_menu_controller.js +343 -283
- data/dist/controllers/pagination_controller.js +295 -119
- data/dist/controllers/password_reveal_controller.js +389 -121
- data/dist/controllers/password_strength_controller.js +99 -153
- data/dist/controllers/persist_controller.js +237 -103
- data/dist/controllers/pointer_drag_controller.js +185 -165
- data/dist/controllers/popover_controller.js +236 -97
- data/dist/controllers/portal_controller.js +209 -76
- data/dist/controllers/preview_guard_controller.js +232 -116
- data/dist/controllers/progress_controller.js +125 -56
- data/dist/controllers/radio_group_controller.js +117 -137
- data/dist/controllers/range_slider_controller.js +192 -105
- data/dist/controllers/rating_controller.js +418 -207
- data/dist/controllers/read_more_controller.js +134 -63
- data/dist/controllers/reading_progress_controller.js +147 -135
- data/dist/controllers/relative_time_controller.js +145 -110
- data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
- data/dist/controllers/resizable_controller.js +255 -139
- data/dist/controllers/roving_controller.js +39 -84
- data/dist/controllers/scroll_area_controller.js +428 -225
- data/dist/controllers/scroll_restore_controller.js +0 -53
- data/dist/controllers/scroll_visibility_controller.js +395 -145
- data/dist/controllers/scrollspy_controller.js +181 -242
- data/dist/controllers/separator_controller.js +267 -140
- data/dist/controllers/sidebar_controller.js +1023 -386
- data/dist/controllers/skeleton_controller.js +248 -97
- data/dist/controllers/slider_controller.js +159 -79
- data/dist/controllers/smart_sticky_header_controller.js +162 -63
- data/dist/controllers/sortable_controller.js +0 -112
- data/dist/controllers/spinner_controller.js +277 -169
- data/dist/controllers/step_indicator_controller.js +99 -46
- data/dist/controllers/stepper_controller.js +114 -73
- data/dist/controllers/stick_to_bottom_controller.js +262 -138
- data/dist/controllers/sticky_observer_controller.js +214 -49
- data/dist/controllers/submit_once_controller.js +294 -205
- data/dist/controllers/switch_controller.js +33 -60
- data/dist/controllers/tabs_controller.js +35 -29
- data/dist/controllers/tags_input_controller.js +136 -145
- data/dist/controllers/textarea_autosize_controller.js +71 -58
- data/dist/controllers/theme_controller.js +130 -112
- data/dist/controllers/time_picker_controller.js +146 -80
- data/dist/controllers/toast_controller.js +186 -297
- data/dist/controllers/toggle_group_controller.js +95 -136
- data/dist/controllers/toolbar_controller.js +68 -98
- data/dist/controllers/tooltip_controller.js +158 -124
- data/dist/controllers/transition_controller.js +123 -119
- data/dist/controllers/tree_view_controller.js +150 -345
- data/dist/index.js +6370 -9346
- data/dist/positioning/index.js +148 -47
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +3 -3
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
-
// src/controllers/count_up_controller.ts
|
|
4
|
-
|
|
5
|
-
// src/utils/authored_integer.ts
|
|
6
3
|
var TOKEN_BODY = /\d[\d.,'’’ _]*\d|\d/;
|
|
7
4
|
var SIGN_OPENER = /[\s([]/;
|
|
8
5
|
function authoredInteger(text) {
|
|
@@ -24,29 +21,75 @@ function authoredInteger(text) {
|
|
|
24
21
|
return signed ? -magnitude || 0 : magnitude;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
var NUMBER_BOUNDS = {
|
|
25
|
+
finite: { finite: true },
|
|
26
|
+
positive: { finite: true, exclusiveMin: 0 }};
|
|
27
|
+
function matchesNumberBounds(value, bounds) {
|
|
28
|
+
if (!Number.isFinite(value)) {
|
|
29
|
+
const direction = value === Infinity ? "positive" : value === -Infinity ? "negative" : null;
|
|
30
|
+
if (direction === null) return false;
|
|
31
|
+
if (bounds.allowInfinity !== "both" && bounds.allowInfinity !== direction) return false;
|
|
32
|
+
}
|
|
33
|
+
if (bounds.min !== void 0 && value < bounds.min) return false;
|
|
34
|
+
if (bounds.max !== void 0 && value > bounds.max) return false;
|
|
35
|
+
if (bounds.exclusiveMin !== void 0 && value <= bounds.exclusiveMin) return false;
|
|
36
|
+
if (bounds.integer && !Number.isInteger(value)) return false;
|
|
37
|
+
if (bounds.allowedValues !== void 0 && !bounds.allowedValues.includes(value)) return false;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function readNumber(raw, fallback, bounds) {
|
|
42
|
+
return matchesNumberBounds(raw, bounds) ? raw : fallback;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var NumberValueReader = class {
|
|
46
|
+
#lastRejected = /* @__PURE__ */ new Map();
|
|
47
|
+
read(owner, name, raw, fallback, bounds) {
|
|
48
|
+
const resolved = readNumber(raw, fallback, bounds);
|
|
49
|
+
if (matchesNumberBounds(raw, bounds)) {
|
|
50
|
+
this.#lastRejected.delete(name);
|
|
51
|
+
return resolved;
|
|
52
|
+
}
|
|
53
|
+
const attribute = `data-${owner.identifier}-${name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}-value`;
|
|
54
|
+
const literal = owner.element.getAttribute(attribute);
|
|
55
|
+
if (literal === null) {
|
|
56
|
+
this.#lastRejected.delete(name);
|
|
57
|
+
return resolved;
|
|
58
|
+
}
|
|
59
|
+
if (this.#lastRejected.get(name) !== literal) {
|
|
60
|
+
this.#lastRejected.set(name, literal);
|
|
61
|
+
console.warn(
|
|
62
|
+
`Stimeo UI: "${owner.identifier}" has an invalid number Value "${name}" declaration ${JSON.stringify(literal)}; using ${fallback}.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return resolved;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
28
69
|
function prefersReducedMotion() {
|
|
29
70
|
return typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
30
71
|
}
|
|
31
72
|
|
|
32
|
-
// src/controllers/count_up_controller.ts
|
|
33
73
|
var DEFAULT_DURATION = 1200;
|
|
34
|
-
var CountUpController = class extends Controller {
|
|
74
|
+
var CountUpController = class _CountUpController extends Controller {
|
|
75
|
+
#numbers = new NumberValueReader();
|
|
35
76
|
static values = {
|
|
36
77
|
duration: { type: Number, default: DEFAULT_DURATION },
|
|
37
78
|
from: { type: Number, default: 0 },
|
|
38
79
|
once: { type: Boolean, default: true }
|
|
39
80
|
};
|
|
81
|
+
static valueConstraints = {
|
|
82
|
+
duration: NUMBER_BOUNDS.positive,
|
|
83
|
+
from: NUMBER_BOUNDS.finite
|
|
84
|
+
};
|
|
40
85
|
static actions = ["start"];
|
|
41
86
|
static events = ["end"];
|
|
42
87
|
#frame = null;
|
|
43
|
-
/** The animation length, with a declaration outside its domain read as the default. */
|
|
44
88
|
get #duration() {
|
|
45
|
-
return
|
|
89
|
+
return this.#safeDuration;
|
|
46
90
|
}
|
|
47
|
-
/** The starting value, with a declaration that is not a finite number read as zero. */
|
|
48
91
|
get #from() {
|
|
49
|
-
return
|
|
92
|
+
return this.#safeFrom;
|
|
50
93
|
}
|
|
51
94
|
connect() {
|
|
52
95
|
const ticker = this.#ownedTicker();
|
|
@@ -58,10 +101,6 @@ var CountUpController = class extends Controller {
|
|
|
58
101
|
disconnect() {
|
|
59
102
|
if (this.#frame !== null) this.#settle();
|
|
60
103
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Starts the animation (typically from `stimeo--intersection:enter` via
|
|
63
|
-
* `data-action`). No-ops while running, and after a finished run when `once`.
|
|
64
|
-
*/
|
|
65
104
|
start() {
|
|
66
105
|
if (this.#frame !== null) return;
|
|
67
106
|
if (this.onceValue && this.element.hasAttribute("data-count-up-done")) return;
|
|
@@ -76,9 +115,10 @@ var CountUpController = class extends Controller {
|
|
|
76
115
|
}
|
|
77
116
|
const ticker = this.#wrap(node, authored);
|
|
78
117
|
const from = this.#from;
|
|
118
|
+
const duration = this.#duration;
|
|
79
119
|
const started = performance.now();
|
|
80
120
|
const step = (now) => {
|
|
81
|
-
const t = Math.min((now - started) /
|
|
121
|
+
const t = Math.min((now - started) / duration, 1);
|
|
82
122
|
const eased = 1 - (1 - t) ** 3;
|
|
83
123
|
ticker.textContent = String(Math.round(from + (target - from) * eased));
|
|
84
124
|
if (t < 1) {
|
|
@@ -90,7 +130,6 @@ var CountUpController = class extends Controller {
|
|
|
90
130
|
};
|
|
91
131
|
this.#frame = requestAnimationFrame(step);
|
|
92
132
|
}
|
|
93
|
-
/** The first text node that displays a number, or null when the host has none. */
|
|
94
133
|
#numericNode() {
|
|
95
134
|
const walker = document.createTreeWalker(this.element, NodeFilter.SHOW_TEXT);
|
|
96
135
|
let node = walker.nextNode();
|
|
@@ -99,11 +138,9 @@ var CountUpController = class extends Controller {
|
|
|
99
138
|
}
|
|
100
139
|
return node;
|
|
101
140
|
}
|
|
102
|
-
/** The wrapper this controller published, if one outlived its run. */
|
|
103
141
|
#ownedTicker() {
|
|
104
142
|
return this.element.querySelector("[data-count-up-label]");
|
|
105
143
|
}
|
|
106
|
-
/** Publishes the ticking number inside a named wrapper, replacing `node`. */
|
|
107
144
|
#wrap(node, authored) {
|
|
108
145
|
const ticker = document.createElement("span");
|
|
109
146
|
ticker.setAttribute("data-count-up-label", "true");
|
|
@@ -113,11 +150,9 @@ var CountUpController = class extends Controller {
|
|
|
113
150
|
ticker.append(node);
|
|
114
151
|
return ticker;
|
|
115
152
|
}
|
|
116
|
-
/** Puts `text` back where the wrapper stood, leaving the rest of the host alone. */
|
|
117
153
|
#unwrap(ticker, text) {
|
|
118
154
|
ticker.replaceWith(document.createTextNode(text ?? ticker.textContent ?? ""));
|
|
119
155
|
}
|
|
120
|
-
/** Ends the run: cancels the frame and restores the authored presentation. */
|
|
121
156
|
#settle() {
|
|
122
157
|
if (this.#frame !== null) cancelAnimationFrame(this.#frame);
|
|
123
158
|
this.#frame = null;
|
|
@@ -125,8 +160,25 @@ var CountUpController = class extends Controller {
|
|
|
125
160
|
if (ticker !== null) this.#unwrap(ticker, ticker.getAttribute("aria-label"));
|
|
126
161
|
this.element.setAttribute("data-count-up-done", "true");
|
|
127
162
|
}
|
|
163
|
+
get #safeDuration() {
|
|
164
|
+
return this.#numbers.read(
|
|
165
|
+
this,
|
|
166
|
+
"duration",
|
|
167
|
+
this.durationValue,
|
|
168
|
+
_CountUpController.values.duration.default,
|
|
169
|
+
_CountUpController.valueConstraints.duration
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
get #safeFrom() {
|
|
173
|
+
return this.#numbers.read(
|
|
174
|
+
this,
|
|
175
|
+
"from",
|
|
176
|
+
this.fromValue,
|
|
177
|
+
_CountUpController.values.from.default,
|
|
178
|
+
_CountUpController.valueConstraints.from
|
|
179
|
+
);
|
|
180
|
+
}
|
|
128
181
|
};
|
|
129
182
|
|
|
130
183
|
export { CountUpController };
|
|
131
|
-
//# sourceMappingURL=count_up_controller.js.map
|
|
132
184
|
//# sourceMappingURL=count_up_controller.js.map
|