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,6 +1,75 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
- // src/controllers/filter_controller.ts
3
+ var ListenerSet = class {
4
+ #abort = new AbortController();
5
+ add(target, type, handler, options) {
6
+ target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
7
+ }
8
+ dispose() {
9
+ this.#abort.abort();
10
+ this.#abort = new AbortController();
11
+ }
12
+ };
13
+
14
+ var MicrotaskCoalescer = class {
15
+ #run;
16
+ #queued = false;
17
+ #active = false;
18
+ #generation = 0;
19
+ constructor(run) {
20
+ this.#run = run;
21
+ }
22
+ activate() {
23
+ this.#active = true;
24
+ }
25
+ cancel() {
26
+ this.#active = false;
27
+ this.#queued = false;
28
+ this.#generation += 1;
29
+ }
30
+ get pending() {
31
+ return this.#queued;
32
+ }
33
+ schedule() {
34
+ if (!this.#active || this.#queued) return;
35
+ this.#queued = true;
36
+ const generation = this.#generation;
37
+ queueMicrotask(() => {
38
+ if (generation !== this.#generation || !this.#queued || !this.#active) return;
39
+ this.#queued = false;
40
+ this.#run();
41
+ });
42
+ }
43
+ };
44
+
45
+ var MorphRenderWatcher = class {
46
+ #listeners = new ListenerSet();
47
+ #pass;
48
+ #element = null;
49
+ #onMorph = () => this.#pass.schedule();
50
+ constructor(run) {
51
+ this.#pass = new MicrotaskCoalescer(run);
52
+ }
53
+ observe(element) {
54
+ if (this.#element === element) return;
55
+ this.disconnect();
56
+ this.#element = element;
57
+ this.#pass.activate();
58
+ this.#listeners.add(element, "turbo:morph-element", this.#onMorph);
59
+ }
60
+ schedule() {
61
+ this.#pass.schedule();
62
+ }
63
+ get pending() {
64
+ return this.#pass.pending;
65
+ }
66
+ disconnect() {
67
+ this.#listeners.dispose();
68
+ this.#pass.cancel();
69
+ this.#element = null;
70
+ }
71
+ };
72
+
4
73
  var FilterController = class extends Controller {
5
74
  static targets = ["item", "control", "group", "empty"];
6
75
  static values = { match: { type: String, default: "all" } };
@@ -9,55 +78,29 @@ var FilterController = class extends Controller {
9
78
  #onChange = () => {
10
79
  this.apply();
11
80
  };
12
- /**
13
- * The outcome the last `change` reported, which the next evaluation is compared
14
- * with; `null` until the first evaluation after `connect()`, which reports
15
- * whatever it finds.
16
- */
17
81
  #reported = null;
18
- /**
19
- * Gates the declaration callback to the connected window.
20
- *
21
- * Stimulus delivers a Value callback ahead of `connect()` and again for every
22
- * runtime change; without the gate, merely connecting would emit an evaluation
23
- * — and its `change` — before `connect()` runs its own.
24
- */
25
82
  #connected = false;
83
+ #morphRender = new MorphRenderWatcher(() => this.#evaluate());
84
+ #listeners = new ListenerSet();
26
85
  connect() {
86
+ this.#morphRender.observe(this.element);
27
87
  this.#reported = null;
28
88
  this.#evaluate();
29
- this.element.addEventListener("change", this.#onChange);
89
+ this.#listeners.add(this.element, "change", this.#onChange);
30
90
  this.#connected = true;
31
91
  }
32
92
  disconnect() {
93
+ this.#morphRender.disconnect();
33
94
  this.#connected = false;
34
- this.element.removeEventListener("change", this.#onChange);
35
- }
36
- /**
37
- * Re-evaluates when the match declaration changes at runtime.
38
- *
39
- * The declaration decides which items are shown, so an element kept across a
40
- * morph — where `connect()` does not run again — still has to follow it instead
41
- * of waiting for the next control interaction. The evaluation is the ordinary
42
- * one, `change` included: a declaration swap is an evaluation like any other.
43
- */
95
+ this.#listeners.dispose();
96
+ }
44
97
  matchValueChanged() {
45
98
  if (!this.#connected) return;
46
99
  this.#evaluate();
47
100
  }
48
- /** Re-derives every item's visibility from the active tokens and syncs groups/empty. */
49
101
  apply() {
50
102
  this.#evaluate();
51
103
  }
52
- /**
53
- * The evaluation itself: every item's visibility from the active tokens, then
54
- * the groups and the empty element, then `change` when the outcome moved from
55
- * the one last reported. Several triggers can land on the same outcome — a
56
- * `clear` evaluates, and a toggle group wired to `apply` reports the presses it
57
- * turned off — so an evaluation that changes nothing reports nothing.
58
- *
59
- * @stimeoRenderRoot
60
- */
61
104
  #evaluate() {
62
105
  const active = this.#activeTokens();
63
106
  let visibleCount = 0;
@@ -80,7 +123,6 @@ var FilterController = class extends Controller {
80
123
  this.#reported = { active, visibleCount, total };
81
124
  this.dispatch("change", { detail: { active: [...active], visibleCount, total } });
82
125
  }
83
- /** Turns every control off (uncheck / aria-pressed="false") and re-applies. */
84
126
  clear() {
85
127
  for (const control of this.controlTargets) {
86
128
  if (control instanceof HTMLInputElement) {
@@ -91,7 +133,6 @@ var FilterController = class extends Controller {
91
133
  }
92
134
  this.apply();
93
135
  }
94
- /** The tokens of every control currently "on" (checked or aria-pressed="true"). */
95
136
  #activeTokens() {
96
137
  const tokens = [];
97
138
  for (const control of this.controlTargets) {
@@ -99,33 +140,27 @@ var FilterController = class extends Controller {
99
140
  }
100
141
  return tokens.filter(Boolean);
101
142
  }
102
- /** Whether a control is in its "on" state. */
103
143
  #isOn(control) {
104
144
  if (control instanceof HTMLInputElement) return control.checked;
105
145
  return control.getAttribute("aria-pressed") === "true";
106
146
  }
107
- /** A control's token: explicit `data-stimeo--filter-token`, else `data-value` / value. */
108
147
  #tokenOf(control) {
109
148
  const explicit = control.getAttribute(`data-${this.identifier}-token`) ?? control.dataset.value;
110
149
  if (explicit) return explicit;
111
150
  return control instanceof HTMLInputElement ? control.value : "";
112
151
  }
113
- /** Whether an item satisfies the active token set per `match` (empty active → shown). */
114
152
  #matches(item, active) {
115
153
  if (active.length === 0) return true;
116
154
  const tokens = this.#tokensOf(item);
117
155
  return this.matchValue === "any" ? active.some((token) => tokens.includes(token)) : active.every((token) => tokens.includes(token));
118
156
  }
119
- /** An item's declared tokens (`data-stimeo--filter-tokens`, space-separated). */
120
157
  #tokensOf(item) {
121
158
  return (item.getAttribute(`data-${this.identifier}-tokens`) ?? "").split(/\s+/).filter(Boolean);
122
159
  }
123
- /** Whether a group still contains at least one non-hidden item. */
124
160
  #hasVisibleItem(group) {
125
161
  return this.itemTargets.some((item) => !item.hidden && group.contains(item));
126
162
  }
127
163
  };
128
164
 
129
165
  export { FilterController };
130
- //# sourceMappingURL=filter_controller.js.map
131
166
  //# sourceMappingURL=filter_controller.js.map