stimeo-ui 0.15.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.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +209 -0
  3. data/README.md +128 -1
  4. data/dist/cable/index.js +392 -417
  5. data/dist/controllers/accordion_controller.js +228 -28
  6. data/dist/controllers/alert_dialog_controller.js +862 -221
  7. data/dist/controllers/announcer_controller.js +135 -191
  8. data/dist/controllers/aspect_ratio_controller.js +0 -10
  9. data/dist/controllers/auto_submit_controller.js +295 -110
  10. data/dist/controllers/avatar_controller.js +172 -106
  11. data/dist/controllers/breadcrumb_controller.js +0 -129
  12. data/dist/controllers/bulk_select_controller.js +264 -53
  13. data/dist/controllers/calendar_controller.js +346 -180
  14. data/dist/controllers/carousel_controller.js +587 -300
  15. data/dist/controllers/character_counter_controller.js +271 -143
  16. data/dist/controllers/checkbox_controller.js +77 -75
  17. data/dist/controllers/clipboard_controller.js +187 -108
  18. data/dist/controllers/collapsible_controller.js +374 -108
  19. data/dist/controllers/color_picker_controller.js +183 -127
  20. data/dist/controllers/combobox_controller.js +426 -109
  21. data/dist/controllers/command_palette_controller.js +994 -350
  22. data/dist/controllers/conditional_fields_controller.js +212 -125
  23. data/dist/controllers/confirm_controller.js +939 -245
  24. data/dist/controllers/context_menu_controller.js +275 -127
  25. data/dist/controllers/count_up_controller.js +73 -21
  26. data/dist/controllers/countdown_controller.js +235 -97
  27. data/dist/controllers/currency_input_controller.js +241 -118
  28. data/dist/controllers/data_grid_controller.js +229 -135
  29. data/dist/controllers/date_range_picker_controller.js +359 -165
  30. data/dist/controllers/dialog_controller.js +887 -225
  31. data/dist/controllers/direct_upload_controller.js +80 -142
  32. data/dist/controllers/dirty_form_controller.js +26 -47
  33. data/dist/controllers/dismissible_controller.js +175 -20
  34. data/dist/controllers/drawer_controller.js +963 -336
  35. data/dist/controllers/dropdown_controller.js +342 -85
  36. data/dist/controllers/editable_controller.js +182 -58
  37. data/dist/controllers/empty_state_controller.js +67 -53
  38. data/dist/controllers/file_dropzone_controller.js +426 -229
  39. data/dist/controllers/filter_controller.js +78 -36
  40. data/dist/controllers/flash_controller.js +328 -211
  41. data/dist/controllers/focus_controller.js +654 -239
  42. data/dist/controllers/form_field_controller.js +153 -136
  43. data/dist/controllers/form_validation_controller.js +29 -96
  44. data/dist/controllers/frame_loading_controller.js +263 -198
  45. data/dist/controllers/highlight_controller.js +119 -70
  46. data/dist/controllers/hover_card_controller.js +335 -118
  47. data/dist/controllers/idle_controller.js +316 -65
  48. data/dist/controllers/input_mask_controller.js +116 -61
  49. data/dist/controllers/intersection_controller.js +147 -103
  50. data/dist/controllers/lazy_frame_controller.js +9 -56
  51. data/dist/controllers/listbox_controller.js +413 -153
  52. data/dist/controllers/local_time_controller.js +54 -64
  53. data/dist/controllers/masonry_controller.js +70 -95
  54. data/dist/controllers/menu_controller.js +254 -167
  55. data/dist/controllers/menubar_controller.js +206 -331
  56. data/dist/controllers/meter_controller.js +159 -71
  57. data/dist/controllers/multi_select_controller.js +797 -388
  58. data/dist/controllers/navigation_menu_controller.js +156 -231
  59. data/dist/controllers/nested_form_controller.js +373 -174
  60. data/dist/controllers/network_status_controller.js +241 -45
  61. data/dist/controllers/number_input_controller.js +387 -227
  62. data/dist/controllers/optimistic_controller.js +28 -75
  63. data/dist/controllers/otp_controller.js +344 -196
  64. data/dist/controllers/overflow_indicator_controller.js +167 -93
  65. data/dist/controllers/overflow_menu_controller.js +408 -277
  66. data/dist/controllers/pagination_controller.js +342 -120
  67. data/dist/controllers/password_reveal_controller.js +424 -99
  68. data/dist/controllers/password_strength_controller.js +99 -153
  69. data/dist/controllers/persist_controller.js +252 -96
  70. data/dist/controllers/pointer_drag_controller.js +263 -164
  71. data/dist/controllers/popover_controller.js +267 -94
  72. data/dist/controllers/portal_controller.js +209 -72
  73. data/dist/controllers/preview_guard_controller.js +243 -112
  74. data/dist/controllers/progress_controller.js +132 -59
  75. data/dist/controllers/radio_group_controller.js +138 -133
  76. data/dist/controllers/range_slider_controller.js +245 -112
  77. data/dist/controllers/rating_controller.js +429 -194
  78. data/dist/controllers/read_more_controller.js +185 -47
  79. data/dist/controllers/reading_progress_controller.js +147 -135
  80. data/dist/controllers/relative_time_controller.js +145 -110
  81. data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
  82. data/dist/controllers/resizable_controller.js +294 -118
  83. data/dist/controllers/roving_controller.js +39 -84
  84. data/dist/controllers/scroll_area_controller.js +428 -221
  85. data/dist/controllers/scroll_restore_controller.js +0 -53
  86. data/dist/controllers/scroll_visibility_controller.js +395 -146
  87. data/dist/controllers/scrollspy_controller.js +181 -236
  88. data/dist/controllers/separator_controller.js +288 -132
  89. data/dist/controllers/sidebar_controller.js +1071 -375
  90. data/dist/controllers/skeleton_controller.js +248 -92
  91. data/dist/controllers/slider_controller.js +211 -96
  92. data/dist/controllers/smart_sticky_header_controller.js +163 -54
  93. data/dist/controllers/sortable_controller.js +13 -110
  94. data/dist/controllers/spinner_controller.js +277 -161
  95. data/dist/controllers/step_indicator_controller.js +107 -53
  96. data/dist/controllers/stepper_controller.js +171 -48
  97. data/dist/controllers/stick_to_bottom_controller.js +310 -116
  98. data/dist/controllers/sticky_observer_controller.js +214 -49
  99. data/dist/controllers/submit_once_controller.js +294 -192
  100. data/dist/controllers/switch_controller.js +107 -43
  101. data/dist/controllers/tabs_controller.js +50 -25
  102. data/dist/controllers/tags_input_controller.js +290 -149
  103. data/dist/controllers/textarea_autosize_controller.js +71 -58
  104. data/dist/controllers/theme_controller.js +148 -80
  105. data/dist/controllers/time_picker_controller.js +162 -81
  106. data/dist/controllers/toast_controller.js +365 -193
  107. data/dist/controllers/toggle_group_controller.js +194 -99
  108. data/dist/controllers/toolbar_controller.js +92 -90
  109. data/dist/controllers/tooltip_controller.js +185 -125
  110. data/dist/controllers/transition_controller.js +123 -115
  111. data/dist/controllers/tree_view_controller.js +248 -290
  112. data/dist/index.js +8649 -8572
  113. data/dist/positioning/index.js +148 -45
  114. data/lib/stimeo/ui/version.rb +1 -1
  115. metadata +3 -3
@@ -1,6 +1,69 @@
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
+ schedule() {
31
+ if (!this.#active || this.#queued) return;
32
+ this.#queued = true;
33
+ const generation = this.#generation;
34
+ queueMicrotask(() => {
35
+ if (generation !== this.#generation || !this.#queued || !this.#active) return;
36
+ this.#queued = false;
37
+ this.#run();
38
+ });
39
+ }
40
+ };
41
+
42
+ var MorphRenderWatcher = class {
43
+ #listeners = new ListenerSet();
44
+ #pass;
45
+ #element = null;
46
+ #onMorph = () => this.#pass.schedule();
47
+ constructor(run) {
48
+ this.#pass = new MicrotaskCoalescer(run);
49
+ }
50
+ observe(element) {
51
+ if (this.#element === element) return;
52
+ this.disconnect();
53
+ this.#element = element;
54
+ this.#pass.activate();
55
+ this.#listeners.add(element, "turbo:morph-element", this.#onMorph);
56
+ }
57
+ schedule() {
58
+ this.#pass.schedule();
59
+ }
60
+ disconnect() {
61
+ this.#listeners.dispose();
62
+ this.#pass.cancel();
63
+ this.#element = null;
64
+ }
65
+ };
66
+
4
67
  var FilterController = class extends Controller {
5
68
  static targets = ["item", "control", "group", "empty"];
6
69
  static values = { match: { type: String, default: "all" } };
@@ -9,45 +72,28 @@ var FilterController = class extends Controller {
9
72
  #onChange = () => {
10
73
  this.apply();
11
74
  };
12
- /**
13
- * Gates the declaration callback to the connected window.
14
- *
15
- * Stimulus delivers a Value callback ahead of `connect()` and again for every
16
- * runtime change; without the gate, merely connecting would emit an evaluation
17
- * — and its `change` — before `connect()` runs its own.
18
- */
75
+ #reported = null;
19
76
  #connected = false;
77
+ #morphRender = new MorphRenderWatcher(() => this.#evaluate());
20
78
  connect() {
79
+ this.#morphRender.observe(this.element);
80
+ this.#reported = null;
21
81
  this.#evaluate();
22
82
  this.element.addEventListener("change", this.#onChange);
23
83
  this.#connected = true;
24
84
  }
25
85
  disconnect() {
86
+ this.#morphRender.disconnect();
26
87
  this.#connected = false;
27
88
  this.element.removeEventListener("change", this.#onChange);
28
89
  }
29
- /**
30
- * Re-evaluates when the match declaration changes at runtime.
31
- *
32
- * The declaration decides which items are shown, so an element kept across a
33
- * morph — where `connect()` does not run again — still has to follow it instead
34
- * of waiting for the next control interaction. The evaluation is the ordinary
35
- * one, `change` included: a declaration swap is an evaluation like any other.
36
- */
37
90
  matchValueChanged() {
38
91
  if (!this.#connected) return;
39
92
  this.#evaluate();
40
93
  }
41
- /** Re-derives every item's visibility from the active tokens and syncs groups/empty. */
42
94
  apply() {
43
95
  this.#evaluate();
44
96
  }
45
- /**
46
- * The evaluation itself: every item's visibility from the active tokens, then
47
- * the groups and the empty element, then the `change` event.
48
- *
49
- * @stimeoRenderRoot
50
- */
51
97
  #evaluate() {
52
98
  const active = this.#activeTokens();
53
99
  let visibleCount = 0;
@@ -62,11 +108,14 @@ var FilterController = class extends Controller {
62
108
  for (const empty of this.emptyTargets) {
63
109
  empty.hidden = visibleCount > 0;
64
110
  }
65
- this.dispatch("change", {
66
- detail: { active, visible: visibleCount, total: this.itemTargets.length }
67
- });
111
+ const total = this.itemTargets.length;
112
+ const reported = this.#reported;
113
+ if (reported !== null && reported.visibleCount === visibleCount && reported.total === total && reported.active.length === active.length && reported.active.every((token, index) => token === active[index])) {
114
+ return;
115
+ }
116
+ this.#reported = { active, visibleCount, total };
117
+ this.dispatch("change", { detail: { active: [...active], visibleCount, total } });
68
118
  }
69
- /** Turns every control off (uncheck / aria-pressed="false") and re-applies. */
70
119
  clear() {
71
120
  for (const control of this.controlTargets) {
72
121
  if (control instanceof HTMLInputElement) {
@@ -77,7 +126,6 @@ var FilterController = class extends Controller {
77
126
  }
78
127
  this.apply();
79
128
  }
80
- /** The tokens of every control currently "on" (checked or aria-pressed="true"). */
81
129
  #activeTokens() {
82
130
  const tokens = [];
83
131
  for (const control of this.controlTargets) {
@@ -85,33 +133,27 @@ var FilterController = class extends Controller {
85
133
  }
86
134
  return tokens.filter(Boolean);
87
135
  }
88
- /** Whether a control is in its "on" state. */
89
136
  #isOn(control) {
90
137
  if (control instanceof HTMLInputElement) return control.checked;
91
138
  return control.getAttribute("aria-pressed") === "true";
92
139
  }
93
- /** A control's token: explicit `data-stimeo--filter-token`, else `data-value` / value. */
94
140
  #tokenOf(control) {
95
- const explicit = control.getAttribute("data-stimeo--filter-token") ?? control.dataset.value;
141
+ const explicit = control.getAttribute(`data-${this.identifier}-token`) ?? control.dataset.value;
96
142
  if (explicit) return explicit;
97
143
  return control instanceof HTMLInputElement ? control.value : "";
98
144
  }
99
- /** Whether an item satisfies the active token set per `match` (empty active → shown). */
100
145
  #matches(item, active) {
101
146
  if (active.length === 0) return true;
102
147
  const tokens = this.#tokensOf(item);
103
148
  return this.matchValue === "any" ? active.some((token) => tokens.includes(token)) : active.every((token) => tokens.includes(token));
104
149
  }
105
- /** An item's declared tokens (`data-stimeo--filter-tokens`, space-separated). */
106
150
  #tokensOf(item) {
107
- return (item.getAttribute("data-stimeo--filter-tokens") ?? "").split(/\s+/).filter(Boolean);
151
+ return (item.getAttribute(`data-${this.identifier}-tokens`) ?? "").split(/\s+/).filter(Boolean);
108
152
  }
109
- /** Whether a group still contains at least one non-hidden item. */
110
153
  #hasVisibleItem(group) {
111
154
  return this.itemTargets.some((item) => !item.hidden && group.contains(item));
112
155
  }
113
156
  };
114
157
 
115
158
  export { FilterController };
116
- //# sourceMappingURL=filter_controller.js.map
117
159
  //# sourceMappingURL=filter_controller.js.map