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,15 +1,7 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
- // src/controllers/scroll_restore_controller.ts
4
-
5
- // src/utils/frame_coalescer.ts
6
3
  var FrameCoalescer = class {
7
4
  #frame = null;
8
- /**
9
- * Runs `run` on the next frame, unless a frame is already pending — the first
10
- * request of a burst wins and the rest are dropped. The pending frame is
11
- * released before `run`, so `run` may request the next one.
12
- */
13
5
  schedule(run) {
14
6
  if (this.#frame !== null) return;
15
7
  this.#frame = requestAnimationFrame(() => {
@@ -17,14 +9,6 @@ var FrameCoalescer = class {
17
9
  run();
18
10
  });
19
11
  }
20
- /**
21
- * Drops the pending frame, and reaches the platform only when there is one.
22
- *
23
- * There is no handle value that stands for "nothing pending":
24
- * `cancelAnimationFrame` takes an `unsigned long`, so a negative placeholder
25
- * arrives as a large positive number that the same allocator can hand out, and
26
- * an idle cancel would then drop a frame belonging to someone else.
27
- */
28
12
  cancel() {
29
13
  if (this.#frame === null) return;
30
14
  cancelAnimationFrame(this.#frame);
@@ -32,7 +16,17 @@ var FrameCoalescer = class {
32
16
  }
33
17
  };
34
18
 
35
- // src/controllers/scroll_restore_controller.ts
19
+ var ListenerSet = class {
20
+ #abort = new AbortController();
21
+ add(target, type, handler, options) {
22
+ target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
23
+ }
24
+ dispose() {
25
+ this.#abort.abort();
26
+ this.#abort = new AbortController();
27
+ }
28
+ };
29
+
36
30
  function parseStored(raw) {
37
31
  if (raw === null) return null;
38
32
  try {
@@ -49,58 +43,39 @@ var ScrollRestoreController = class extends Controller {
49
43
  key: { type: String, default: "" },
50
44
  axis: { type: String, default: "vertical" }
51
45
  };
52
- /** Coalesces scroll bursts into one save per frame. */
53
46
  #frames = new FrameCoalescer();
54
- /** Resolved storage key; empty disables persistence (no key and no id). */
55
47
  #storageKey = "";
56
- /** Last offset captured while the element was live; persisted as-is on teardown. */
57
48
  #lastTop = 0;
58
49
  #lastLeft = 0;
59
- /**
60
- * The offsets this controller's own restore produced, awaiting the `scroll`
61
- * the engine fires for them. A restore the layout cannot reach yet lands short,
62
- * so treating that echo as the reader's position would cut the saved offset
63
- * down to whatever the unfinished layout allowed.
64
- */
65
50
  #echoTop = null;
66
51
  #echoLeft = null;
67
- /** Offsets stored for an axis that is not tracked, carried through saves. */
68
52
  #carried = {};
69
- /**
70
- * Whether each axis holds an offset worth saving — one this namespace restored
71
- * or the reader moved. A save writes only the axes that are marked, so an
72
- * offset taken under a different key or axis is never re-published as if the
73
- * reader had left it there.
74
- */
75
53
  #capturedTop = false;
76
54
  #capturedLeft = false;
77
- /** Whether the controller is connected; Value callbacks outside that window do not resync. */
78
55
  #connected = false;
79
56
  #onScroll = () => {
80
57
  this.#capture();
81
58
  this.#frames.schedule(() => this.#persist());
82
59
  };
60
+ #listeners = new ListenerSet();
83
61
  connect() {
84
62
  this.#connected = true;
85
63
  this.#storageKey = this.#resolveKey();
86
- this.element.addEventListener("scroll", this.#onScroll, { passive: true });
64
+ this.#listeners.add(this.element, "scroll", this.#onScroll, { passive: true });
87
65
  if (this.#storageKey) this.#restore();
88
66
  }
89
67
  disconnect() {
90
68
  this.#connected = false;
91
- this.element.removeEventListener("scroll", this.#onScroll);
69
+ this.#listeners.dispose();
92
70
  this.#frames.cancel();
93
71
  this.#persist();
94
72
  }
95
- /** Re-derives the namespace when application code or a Turbo morph moves `key`. */
96
73
  keyValueChanged() {
97
74
  this.#resync();
98
75
  }
99
- /** Re-derives the tracked axes when application code or a Turbo morph moves `axis`. */
100
76
  axisValueChanged() {
101
77
  this.#resync();
102
78
  }
103
- /** Rebuilds the persistence state around the Values as they now read. */
104
79
  #resync() {
105
80
  if (!this.#connected) return;
106
81
  this.#frames.cancel();
@@ -112,15 +87,6 @@ var ScrollRestoreController = class extends Controller {
112
87
  this.#capturedLeft = false;
113
88
  if (this.#storageKey) this.#restore();
114
89
  }
115
- /**
116
- * Records the live scroll offset for the configured axis.
117
- *
118
- * An axis holds its echo until that axis actually moves. A scroll event names
119
- * no axis, so consuming both on the first one to arrive would leave the other
120
- * unguarded: on `both`, moving one axis would take the clamped reading of the
121
- * untouched axis as the reader's own position and save it, cutting the stored
122
- * offset down to whatever the layout could reach at restore time.
123
- */
124
90
  #capture() {
125
91
  if (this.#tracksVertical) {
126
92
  const top = this.element.scrollTop;
@@ -139,10 +105,6 @@ var ScrollRestoreController = class extends Controller {
139
105
  }
140
106
  }
141
107
  }
142
- /**
143
- * Writes the marked axes, carrying through any offset held for an untracked one.
144
- * Without a key, or with neither axis marked, it writes nothing.
145
- */
146
108
  #persist() {
147
109
  if (!this.#storageKey || !(this.#capturedTop || this.#capturedLeft)) return;
148
110
  const data = { ...this.#carried };
@@ -153,7 +115,6 @@ var ScrollRestoreController = class extends Controller {
153
115
  } catch {
154
116
  }
155
117
  }
156
- /** Applies the persisted scroll offset, if any, without moving focus. */
157
118
  #restore() {
158
119
  let raw;
159
120
  try {
@@ -196,7 +157,6 @@ var ScrollRestoreController = class extends Controller {
196
157
  if (this.element.scrollTop !== beforeTop) this.#echoTop = this.element.scrollTop;
197
158
  if (this.element.scrollLeft !== beforeLeft) this.#echoLeft = this.element.scrollLeft;
198
159
  }
199
- /** The `sessionStorage` key: explicit `key`, else the element `id`, else none. */
200
160
  #resolveKey() {
201
161
  const base = this.keyValue || this.element.id;
202
162
  return base ? `stimeo--scroll-restore:${base}` : "";
@@ -210,5 +170,4 @@ var ScrollRestoreController = class extends Controller {
210
170
  };
211
171
 
212
172
  export { ScrollRestoreController };
213
- //# sourceMappingURL=scroll_restore_controller.js.map
214
173
  //# sourceMappingURL=scroll_restore_controller.js.map