stimeo-ui 0.18.2 → 0.19.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 +33 -0
- data/dist/controllers/alert_dialog_controller.js +246 -42
- data/dist/controllers/auto_submit_controller.js +26 -5
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +25 -4
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +26 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +84 -20
- data/dist/controllers/command_palette_controller.js +296 -77
- data/dist/controllers/confirm_controller.js +225 -34
- data/dist/controllers/context_menu_controller.js +58 -29
- data/dist/controllers/currency_input_controller.js +1 -1
- data/dist/controllers/data_grid_controller.js +196 -9
- data/dist/controllers/date_range_picker_controller.js +25 -4
- data/dist/controllers/dialog_controller.js +252 -45
- data/dist/controllers/dismissible_controller.js +57 -11
- data/dist/controllers/drawer_controller.js +284 -58
- data/dist/controllers/dropdown_controller.js +63 -51
- data/dist/controllers/editable_controller.js +69 -6
- data/dist/controllers/empty_state_controller.js +187 -4
- data/dist/controllers/file_dropzone_controller.js +300 -12
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +199 -12
- data/dist/controllers/focus_controller.js +195 -23
- data/dist/controllers/form_field_controller.js +65 -9
- data/dist/controllers/frame_loading_controller.js +25 -4
- data/dist/controllers/hover_card_controller.js +107 -38
- data/dist/controllers/input_mask_controller.js +1 -1
- data/dist/controllers/listbox_controller.js +94 -36
- data/dist/controllers/menu_controller.js +44 -23
- data/dist/controllers/menubar_controller.js +228 -46
- data/dist/controllers/meter_controller.js +25 -4
- data/dist/controllers/multi_select_controller.js +110 -42
- data/dist/controllers/nested_form_controller.js +258 -9
- data/dist/controllers/network_status_controller.js +25 -4
- data/dist/controllers/number_input_controller.js +26 -5
- data/dist/controllers/otp_controller.js +26 -5
- data/dist/controllers/overflow_menu_controller.js +183 -22
- data/dist/controllers/pagination_controller.js +179 -22
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/popover_controller.js +454 -34
- data/dist/controllers/progress_controller.js +25 -4
- data/dist/controllers/radio_group_controller.js +195 -40
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/roving_controller.js +197 -6
- data/dist/controllers/scroll_area_controller.js +50 -12
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +179 -3
- data/dist/controllers/separator_controller.js +25 -4
- data/dist/controllers/sidebar_controller.js +290 -93
- data/dist/controllers/skeleton_controller.js +25 -4
- data/dist/controllers/spinner_controller.js +25 -4
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +25 -4
- data/dist/controllers/submit_once_controller.js +25 -4
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +210 -9
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +198 -35
- data/dist/controllers/toolbar_controller.js +198 -7
- data/dist/controllers/tooltip_controller.js +243 -45
- data/dist/controllers/tree_view_controller.js +200 -8
- data/dist/index.js +1764 -739
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -24,16 +24,23 @@ function actionSource(source) {
|
|
|
24
24
|
|
|
25
25
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
26
26
|
if (element.getAttribute(name) === value) return false;
|
|
27
|
+
beforeWrite?.();
|
|
27
28
|
if (value === null) element.removeAttribute(name);
|
|
28
29
|
else element.setAttribute(name, value);
|
|
29
30
|
return true;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
function syncActiveOption(options, active) {
|
|
33
|
+
function syncActiveOption(options, active, lease) {
|
|
33
34
|
let written = 0;
|
|
34
35
|
for (const option of options) {
|
|
35
36
|
const next = option === active ? "true" : "false";
|
|
36
|
-
if (
|
|
37
|
+
if (lease) {
|
|
38
|
+
if (option.getAttribute("aria-selected") === next) continue;
|
|
39
|
+
lease.adopt(option, { ifChanged: true });
|
|
40
|
+
lease.write(option, next, () => {
|
|
41
|
+
written += 1;
|
|
42
|
+
});
|
|
43
|
+
} else if (setAttributeIfChanged(option, "aria-selected", next)) written += 1;
|
|
37
44
|
}
|
|
38
45
|
return written;
|
|
39
46
|
}
|
|
@@ -114,14 +121,34 @@ var AttributeLease = class {
|
|
|
114
121
|
const names = registry.names;
|
|
115
122
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
116
123
|
}
|
|
117
|
-
write(element, value) {
|
|
124
|
+
write(element, value, beforeWrite) {
|
|
118
125
|
const stack = attributeStack(element, this.#attribute);
|
|
119
126
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
120
127
|
this.#held.add(element);
|
|
121
128
|
const shows = !this.#covered(element, stack, hold);
|
|
122
129
|
hold.written = value;
|
|
123
130
|
this.#mark(element, stack);
|
|
124
|
-
if (shows) this.#reflect(element, value);
|
|
131
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
132
|
+
}
|
|
133
|
+
adopt(element, options = {}) {
|
|
134
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
135
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
136
|
+
const stack = attributeStack(element, this.#attribute);
|
|
137
|
+
const hold = this.#take(stack);
|
|
138
|
+
if (!hold) return false;
|
|
139
|
+
const current = element.getAttribute(this.#attribute);
|
|
140
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
this.#held.add(element);
|
|
144
|
+
hold.original = current;
|
|
145
|
+
hold.linked = false;
|
|
146
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
147
|
+
if (!above.linked) break;
|
|
148
|
+
above.original = current;
|
|
149
|
+
}
|
|
150
|
+
this.#mark(element, stack);
|
|
151
|
+
return true;
|
|
125
152
|
}
|
|
126
153
|
return(element) {
|
|
127
154
|
const held = this.#held.delete(element);
|
|
@@ -187,8 +214,8 @@ var AttributeLease = class {
|
|
|
187
214
|
setAttributeIfChanged(element, name, recorded);
|
|
188
215
|
}
|
|
189
216
|
}
|
|
190
|
-
#reflect(element, value) {
|
|
191
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
217
|
+
#reflect(element, value, beforeWrite) {
|
|
218
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
192
219
|
}
|
|
193
220
|
};
|
|
194
221
|
|
|
@@ -306,7 +333,7 @@ var CompositionTracker = class {
|
|
|
306
333
|
this.#confirmedTarget = null;
|
|
307
334
|
if (confirmed === null || confirmed !== event.target) return false;
|
|
308
335
|
const inputType = event.inputType;
|
|
309
|
-
return
|
|
336
|
+
return inputType ? isCompositionInputType(inputType) : event.isTrusted === true;
|
|
310
337
|
}
|
|
311
338
|
#release(target) {
|
|
312
339
|
target.removeEventListener("compositionstart", this.#handleStart);
|
|
@@ -666,17 +693,26 @@ var ComboboxController = class extends Controller {
|
|
|
666
693
|
#activeId = null;
|
|
667
694
|
#connected = false;
|
|
668
695
|
#list = null;
|
|
696
|
+
#open = false;
|
|
697
|
+
#pendingEntry = null;
|
|
669
698
|
#listHidden = new AttributeLease("hidden", this.identifier);
|
|
699
|
+
#optionHidden = new AttributeLease("hidden", this.identifier);
|
|
670
700
|
#expanded = new AttributeLease("aria-expanded", this.identifier);
|
|
671
701
|
#activeDescendant = new AttributeLease(
|
|
672
702
|
"aria-activedescendant",
|
|
673
703
|
this.identifier
|
|
674
704
|
);
|
|
705
|
+
#optionSelected = new AttributeLease("aria-selected", this.identifier);
|
|
706
|
+
#knownOptions = /* @__PURE__ */ new Set();
|
|
675
707
|
#reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());
|
|
676
708
|
#suppressOpen = false;
|
|
677
709
|
#composition = new CompositionTracker({ onEnd: () => this.filter() });
|
|
678
710
|
#listeners = new ListenerSet();
|
|
679
711
|
connect() {
|
|
712
|
+
const options = new Set(this.optionTargets);
|
|
713
|
+
for (const option of this.#knownOptions) {
|
|
714
|
+
if (!options.has(option)) this.#returnOption(option);
|
|
715
|
+
}
|
|
680
716
|
if (this.hasInputTarget) this.#composition.observe(this.inputTarget);
|
|
681
717
|
this.close();
|
|
682
718
|
this.#list = this.hasListTarget ? this.listTarget : null;
|
|
@@ -713,21 +749,34 @@ var ComboboxController = class extends Controller {
|
|
|
713
749
|
this.#reflectEmptyState();
|
|
714
750
|
}
|
|
715
751
|
optionTargetConnected(option) {
|
|
716
|
-
|
|
752
|
+
if (!this.#knownOptions.has(option)) {
|
|
753
|
+
this.#knownOptions.add(option);
|
|
754
|
+
syncActiveOption([option], null, this.#optionSelected);
|
|
755
|
+
}
|
|
717
756
|
if (this.#connected) this.#queueOptionReconciliation();
|
|
718
757
|
}
|
|
719
758
|
optionTargetDisconnected(option) {
|
|
720
|
-
option.
|
|
759
|
+
if (!this.scope.containsElement(option) || !this.optionTargets.includes(option)) {
|
|
760
|
+
this.#returnOption(option);
|
|
761
|
+
}
|
|
721
762
|
if (this.#connected) this.#queueOptionReconciliation();
|
|
722
763
|
}
|
|
764
|
+
#returnOption(option) {
|
|
765
|
+
this.#knownOptions.delete(option);
|
|
766
|
+
this.#optionSelected.return(option);
|
|
767
|
+
this.#optionHidden.return(option);
|
|
768
|
+
}
|
|
723
769
|
filter(event) {
|
|
724
770
|
if (this.#composition.isComposing(event)) return;
|
|
725
771
|
this.open();
|
|
726
772
|
}
|
|
727
773
|
open() {
|
|
728
|
-
if (!this.
|
|
774
|
+
if (!this.hasInputTarget || this.#suppressOpen) return;
|
|
775
|
+
this.#adoptList();
|
|
729
776
|
this.#applyFilter();
|
|
730
|
-
this.#
|
|
777
|
+
this.#open = true;
|
|
778
|
+
this.#pendingEntry = null;
|
|
779
|
+
if (this.hasListTarget) this.#listHidden.write(this.listTarget, null);
|
|
731
780
|
this.#expanded.write(this.inputTarget, "true");
|
|
732
781
|
this.#setActive(-1);
|
|
733
782
|
this.#reflectEmptyState();
|
|
@@ -736,12 +785,15 @@ var ComboboxController = class extends Controller {
|
|
|
736
785
|
const query = this.inputTarget.value.trim().toLowerCase();
|
|
737
786
|
for (const option of this.optionTargets) {
|
|
738
787
|
const text = (option.textContent ?? "").trim().toLowerCase();
|
|
739
|
-
|
|
788
|
+
if (text.includes(query)) this.#optionHidden.return(option);
|
|
789
|
+
else if (!option.hidden) this.#optionHidden.write(option, "");
|
|
740
790
|
}
|
|
741
791
|
}
|
|
742
792
|
close() {
|
|
743
|
-
|
|
744
|
-
this.#
|
|
793
|
+
this.#adoptList();
|
|
794
|
+
this.#open = false;
|
|
795
|
+
this.#pendingEntry = null;
|
|
796
|
+
if (this.hasListTarget) this.#listHidden.write(this.listTarget, "");
|
|
745
797
|
this.#reflectEmptyState();
|
|
746
798
|
if (this.hasInputTarget) this.#expanded.write(this.inputTarget, "false");
|
|
747
799
|
this.#setActive(-1);
|
|
@@ -751,6 +803,7 @@ var ComboboxController = class extends Controller {
|
|
|
751
803
|
if (event.defaultPrevented) return;
|
|
752
804
|
if (isReservedArrowChord(event, ["alt"])) return;
|
|
753
805
|
if ((event.key === "Home" || event.key === "End") && hasModifierChord(event)) return;
|
|
806
|
+
this.#adoptList();
|
|
754
807
|
if (event.altKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
|
|
755
808
|
if (event.key === "ArrowDown" ? !this.#isClosed : this.#isClosed) return;
|
|
756
809
|
event.preventDefault();
|
|
@@ -771,6 +824,8 @@ var ComboboxController = class extends Controller {
|
|
|
771
824
|
const activeIndex = this.#findActiveIndex(visible);
|
|
772
825
|
const next = activeIndex === -1 ? 0 : (activeIndex + 1) % visible.length;
|
|
773
826
|
this.#setActive(next);
|
|
827
|
+
} else if (!this.hasListTarget) {
|
|
828
|
+
this.#pendingEntry = 1;
|
|
774
829
|
}
|
|
775
830
|
break;
|
|
776
831
|
}
|
|
@@ -782,6 +837,8 @@ var ComboboxController = class extends Controller {
|
|
|
782
837
|
const activeIndex = this.#findActiveIndex(visible);
|
|
783
838
|
const next = activeIndex === -1 ? visible.length - 1 : (activeIndex - 1 + visible.length) % visible.length;
|
|
784
839
|
this.#setActive(next);
|
|
840
|
+
} else if (!this.hasListTarget) {
|
|
841
|
+
this.#pendingEntry = -1;
|
|
785
842
|
}
|
|
786
843
|
break;
|
|
787
844
|
}
|
|
@@ -855,7 +912,7 @@ var ComboboxController = class extends Controller {
|
|
|
855
912
|
this.dispatch("selected", { detail: { value, reason } });
|
|
856
913
|
}
|
|
857
914
|
#reflectEmptyState() {
|
|
858
|
-
const empty = !this.#isClosed && this.#visibleOptions().length === 0;
|
|
915
|
+
const empty = this.hasListTarget && !this.#isClosed && this.#visibleOptions().length === 0;
|
|
859
916
|
if (empty) {
|
|
860
917
|
this.element.setAttribute(`data-${this.identifier}-empty`, "");
|
|
861
918
|
} else {
|
|
@@ -866,7 +923,7 @@ var ComboboxController = class extends Controller {
|
|
|
866
923
|
#setActive(index) {
|
|
867
924
|
const visible = this.#visibleOptions();
|
|
868
925
|
const active = index === -1 ? null : visible[index] ?? null;
|
|
869
|
-
syncActiveOption(this.optionTargets, active);
|
|
926
|
+
syncActiveOption(this.optionTargets, active, this.#optionSelected);
|
|
870
927
|
this.#activeId = active?.id || null;
|
|
871
928
|
if (this.hasInputTarget) this.#activeDescendant.write(this.inputTarget, active?.id || null);
|
|
872
929
|
if (active && this.hasListTarget) scrollOptionIntoView(this.listTarget, active);
|
|
@@ -876,8 +933,9 @@ var ComboboxController = class extends Controller {
|
|
|
876
933
|
const list = this.hasListTarget ? this.listTarget : null;
|
|
877
934
|
const previous = this.#list;
|
|
878
935
|
if (list === previous) return;
|
|
936
|
+
if (previous) this.#open = !previous.hidden;
|
|
879
937
|
this.#list = list;
|
|
880
|
-
if (list) this.#listHidden.write(list,
|
|
938
|
+
if (list) this.#listHidden.write(list, this.#open ? null : "");
|
|
881
939
|
this.#queueOptionReconciliation();
|
|
882
940
|
}
|
|
883
941
|
#reconcileOptions() {
|
|
@@ -885,7 +943,13 @@ var ComboboxController = class extends Controller {
|
|
|
885
943
|
this.#expanded.write(this.inputTarget, String(!this.#isClosed));
|
|
886
944
|
if (!this.#isClosed) this.#applyFilter();
|
|
887
945
|
}
|
|
888
|
-
this.#
|
|
946
|
+
if (this.#pendingEntry !== null && this.hasListTarget && this.hasInputTarget && !this.#isClosed) {
|
|
947
|
+
const index = this.#pendingEntry === 1 ? 0 : this.#visibleOptions().length - 1;
|
|
948
|
+
this.#pendingEntry = null;
|
|
949
|
+
this.#setActive(index);
|
|
950
|
+
} else {
|
|
951
|
+
this.#reconcileActive();
|
|
952
|
+
}
|
|
889
953
|
this.#reflectEmptyState();
|
|
890
954
|
}
|
|
891
955
|
#reconcileActive() {
|
|
@@ -912,10 +976,10 @@ var ComboboxController = class extends Controller {
|
|
|
912
976
|
this.#reconcile.schedule();
|
|
913
977
|
}
|
|
914
978
|
#visibleOptions() {
|
|
915
|
-
return this.optionTargets.filter((option) => !option.hidden);
|
|
979
|
+
return this.hasListTarget ? this.optionTargets.filter((option) => !option.hidden) : [];
|
|
916
980
|
}
|
|
917
981
|
get #isClosed() {
|
|
918
|
-
return
|
|
982
|
+
return this.#list ? this.#list.hidden !== false : !this.#open;
|
|
919
983
|
}
|
|
920
984
|
};
|
|
921
985
|
|