stimeo-ui 0.16.0 → 0.18.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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +136 -0
  3. data/README.md +27 -11
  4. data/dist/cable/index.js +384 -449
  5. data/dist/controllers/accordion_controller.js +174 -55
  6. data/dist/controllers/alert_dialog_controller.js +903 -235
  7. data/dist/controllers/announcer_controller.js +238 -205
  8. data/dist/controllers/aspect_ratio_controller.js +0 -10
  9. data/dist/controllers/auto_submit_controller.js +414 -145
  10. data/dist/controllers/avatar_controller.js +185 -107
  11. data/dist/controllers/breadcrumb_controller.js +0 -130
  12. data/dist/controllers/bulk_select_controller.js +282 -58
  13. data/dist/controllers/calendar_controller.js +228 -260
  14. data/dist/controllers/carousel_controller.js +536 -436
  15. data/dist/controllers/character_counter_controller.js +493 -207
  16. data/dist/controllers/checkbox_controller.js +38 -74
  17. data/dist/controllers/clipboard_controller.js +261 -149
  18. data/dist/controllers/collapsible_controller.js +304 -120
  19. data/dist/controllers/color_picker_controller.js +178 -146
  20. data/dist/controllers/combobox_controller.js +522 -156
  21. data/dist/controllers/command_palette_controller.js +1156 -395
  22. data/dist/controllers/conditional_fields_controller.js +300 -171
  23. data/dist/controllers/confirm_controller.js +980 -262
  24. data/dist/controllers/context_menu_controller.js +346 -153
  25. data/dist/controllers/count_up_controller.js +73 -21
  26. data/dist/controllers/countdown_controller.js +281 -158
  27. data/dist/controllers/currency_input_controller.js +575 -225
  28. data/dist/controllers/data_grid_controller.js +248 -214
  29. data/dist/controllers/date_range_picker_controller.js +338 -235
  30. data/dist/controllers/dialog_controller.js +899 -237
  31. data/dist/controllers/direct_upload_controller.js +97 -167
  32. data/dist/controllers/dirty_form_controller.js +72 -69
  33. data/dist/controllers/dismissible_controller.js +196 -24
  34. data/dist/controllers/drawer_controller.js +974 -355
  35. data/dist/controllers/dropdown_controller.js +339 -96
  36. data/dist/controllers/editable_controller.js +315 -88
  37. data/dist/controllers/empty_state_controller.js +79 -58
  38. data/dist/controllers/file_dropzone_controller.js +322 -211
  39. data/dist/controllers/filter_controller.js +77 -42
  40. data/dist/controllers/flash_controller.js +238 -347
  41. data/dist/controllers/focus_controller.js +679 -240
  42. data/dist/controllers/form_field_controller.js +156 -132
  43. data/dist/controllers/form_validation_controller.js +31 -97
  44. data/dist/controllers/frame_loading_controller.js +275 -217
  45. data/dist/controllers/highlight_controller.js +107 -75
  46. data/dist/controllers/hover_card_controller.js +327 -130
  47. data/dist/controllers/idle_controller.js +271 -101
  48. data/dist/controllers/input_mask_controller.js +483 -97
  49. data/dist/controllers/intersection_controller.js +150 -106
  50. data/dist/controllers/lazy_frame_controller.js +24 -68
  51. data/dist/controllers/listbox_controller.js +523 -240
  52. data/dist/controllers/local_time_controller.js +102 -77
  53. data/dist/controllers/masonry_controller.js +80 -96
  54. data/dist/controllers/menu_controller.js +302 -188
  55. data/dist/controllers/menubar_controller.js +232 -345
  56. data/dist/controllers/meter_controller.js +417 -87
  57. data/dist/controllers/multi_select_controller.js +785 -393
  58. data/dist/controllers/navigation_menu_controller.js +190 -250
  59. data/dist/controllers/nested_form_controller.js +396 -192
  60. data/dist/controllers/network_status_controller.js +268 -62
  61. data/dist/controllers/number_input_controller.js +610 -303
  62. data/dist/controllers/optimistic_controller.js +45 -87
  63. data/dist/controllers/otp_controller.js +658 -255
  64. data/dist/controllers/overflow_indicator_controller.js +122 -113
  65. data/dist/controllers/overflow_menu_controller.js +470 -295
  66. data/dist/controllers/pagination_controller.js +332 -123
  67. data/dist/controllers/password_reveal_controller.js +392 -121
  68. data/dist/controllers/password_strength_controller.js +111 -158
  69. data/dist/controllers/persist_controller.js +165 -111
  70. data/dist/controllers/pointer_drag_controller.js +434 -188
  71. data/dist/controllers/popover_controller.js +269 -113
  72. data/dist/controllers/portal_controller.js +215 -76
  73. data/dist/controllers/preview_guard_controller.js +243 -116
  74. data/dist/controllers/progress_controller.js +391 -78
  75. data/dist/controllers/radio_group_controller.js +278 -211
  76. data/dist/controllers/range_slider_controller.js +220 -113
  77. data/dist/controllers/rating_controller.js +458 -211
  78. data/dist/controllers/read_more_controller.js +138 -63
  79. data/dist/controllers/reading_progress_controller.js +166 -137
  80. data/dist/controllers/relative_time_controller.js +211 -112
  81. data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +103 -38
  82. data/dist/controllers/resizable_controller.js +299 -150
  83. data/dist/controllers/roving_controller.js +49 -88
  84. data/dist/controllers/scroll_area_controller.js +490 -246
  85. data/dist/controllers/scroll_restore_controller.js +14 -55
  86. data/dist/controllers/scroll_visibility_controller.js +432 -149
  87. data/dist/controllers/scrollspy_controller.js +193 -248
  88. data/dist/controllers/separator_controller.js +285 -142
  89. data/dist/controllers/sidebar_controller.js +1069 -404
  90. data/dist/controllers/skeleton_controller.js +259 -101
  91. data/dist/controllers/slider_controller.js +187 -86
  92. data/dist/controllers/smart_sticky_header_controller.js +173 -66
  93. data/dist/controllers/sortable_controller.js +26 -125
  94. data/dist/controllers/spinner_controller.js +288 -173
  95. data/dist/controllers/step_indicator_controller.js +105 -46
  96. data/dist/controllers/stepper_controller.js +120 -73
  97. data/dist/controllers/stick_to_bottom_controller.js +275 -140
  98. data/dist/controllers/sticky_observer_controller.js +220 -49
  99. data/dist/controllers/submit_once_controller.js +376 -227
  100. data/dist/controllers/switch_controller.js +201 -84
  101. data/dist/controllers/tabs_controller.js +41 -30
  102. data/dist/controllers/tags_input_controller.js +293 -173
  103. data/dist/controllers/textarea_autosize_controller.js +108 -74
  104. data/dist/controllers/theme_controller.js +140 -116
  105. data/dist/controllers/time_picker_controller.js +331 -127
  106. data/dist/controllers/toast_controller.js +244 -324
  107. data/dist/controllers/toggle_group_controller.js +252 -191
  108. data/dist/controllers/toolbar_controller.js +219 -120
  109. data/dist/controllers/tooltip_controller.js +158 -124
  110. data/dist/controllers/transition_controller.js +123 -119
  111. data/dist/controllers/tree_view_controller.js +283 -369
  112. data/dist/index.js +8573 -10410
  113. data/dist/positioning/index.js +154 -47
  114. data/lib/generators/stimeo/install/install_generator.rb +7 -2
  115. data/lib/generators/stimeo/install/templates/stimeo.js +19 -6
  116. data/lib/stimeo/ui/version.rb +1 -1
  117. 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
- // src/utils/reduced_motion.ts
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 Number.isFinite(this.durationValue) && this.durationValue > 0 ? this.durationValue : DEFAULT_DURATION;
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 Number.isFinite(this.fromValue) ? this.fromValue : 0;
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) / this.#duration, 1);
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