@unabridged/midwest 0.19.1 → 0.19.2
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.
- package/app/assets/javascript/midwest/index.ts +2 -0
- package/app/assets/javascript/midwest.js +68 -0
- package/app/assets/javascript/midwest.js.map +1 -1
- package/app/assets/stylesheets/midwest.css +1 -1
- package/dist/css/midwest.css +1 -1
- package/dist/javascript/collection/app/assets/javascript/midwest/index.js +2 -0
- package/dist/javascript/collection/app/assets/javascript/midwest/index.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/pagination_component/pagination_component_controller.js +52 -0
- package/dist/javascript/collection/app/components/midwest/pagination_component/pagination_component_controller.js.map +1 -0
- package/dist/javascript/collection/app/components/midwest/table_component/table_component_controller.js +19 -0
- package/dist/javascript/collection/app/components/midwest/table_component/table_component_controller.js.map +1 -1
- package/dist/javascript/midwest.js +68 -0
- package/dist/javascript/midwest.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ import Notification from '../../../components/midwest/notification_component/not
|
|
|
24
24
|
import HorizontalScroll from '../../../components/midwest/horizontal_scroll_component/horizontal_scroll_component_controller'
|
|
25
25
|
import Table from '../../../components/midwest/table_component/table_component_controller'
|
|
26
26
|
import LoadMore from '../../../components/midwest/table_component/load_more_controller'
|
|
27
|
+
import Pagination from '../../../components/midwest/pagination_component/pagination_component_controller'
|
|
27
28
|
/* IMPORTS */
|
|
28
29
|
|
|
29
30
|
export { Card, Banner, CountdownTimer, Chart }
|
|
@@ -55,5 +56,6 @@ export function registerMidwestControllers (application: any) {
|
|
|
55
56
|
application.register('midwest-horizontal-scroll', HorizontalScroll)
|
|
56
57
|
application.register('midwest-table', Table)
|
|
57
58
|
application.register('midwest-load-more', LoadMore)
|
|
59
|
+
application.register('midwest-pagination', Pagination)
|
|
58
60
|
/* EXPORTS */
|
|
59
61
|
}
|
|
@@ -4784,6 +4784,25 @@ class Table extends Controller {
|
|
|
4784
4784
|
cb.checked = checked;
|
|
4785
4785
|
});
|
|
4786
4786
|
}
|
|
4787
|
+
navigateRow(event) {
|
|
4788
|
+
const target = event.target;
|
|
4789
|
+
if (target.closest('a, button, input, select, textarea, [role="button"]'))
|
|
4790
|
+
return;
|
|
4791
|
+
const row = event.currentTarget;
|
|
4792
|
+
const href = row.dataset.href;
|
|
4793
|
+
if (!href)
|
|
4794
|
+
return;
|
|
4795
|
+
if (event.metaKey || event.ctrlKey) {
|
|
4796
|
+
window.open(href, "_blank");
|
|
4797
|
+
} else {
|
|
4798
|
+
const Turbo = window.Turbo;
|
|
4799
|
+
if (Turbo?.visit) {
|
|
4800
|
+
Turbo.visit(href);
|
|
4801
|
+
} else {
|
|
4802
|
+
window.location.href = href;
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4787
4806
|
updateSelectAll() {
|
|
4788
4807
|
if (!this.hasSelectAllTarget)
|
|
4789
4808
|
return;
|
|
@@ -4858,6 +4877,54 @@ class LoadMore extends Controller {
|
|
|
4858
4877
|
}
|
|
4859
4878
|
}
|
|
4860
4879
|
|
|
4880
|
+
class Pagination extends Controller {
|
|
4881
|
+
static targets = ["jumpInput"];
|
|
4882
|
+
static values = { urlTemplate: String, turboFrameId: String };
|
|
4883
|
+
debounceTimer = null;
|
|
4884
|
+
// Intercepts the jump-to-page form submit and navigates to the resolved URL.
|
|
4885
|
+
jump(event) {
|
|
4886
|
+
event.preventDefault();
|
|
4887
|
+
if (!this.hasJumpInputTarget)
|
|
4888
|
+
return;
|
|
4889
|
+
const page = parseInt(this.jumpInputTarget.value, 10);
|
|
4890
|
+
if (!isNaN(page) && page >= 1) {
|
|
4891
|
+
this.visitUrl(this.urlTemplateValue.replace("__PAGE__", String(page)));
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
// Debounced handler for the `incremental` input — navigates 400 ms after the
|
|
4895
|
+
// user stops typing, and only when the value is within the valid page range.
|
|
4896
|
+
jumpIncremental() {
|
|
4897
|
+
if (this.debounceTimer)
|
|
4898
|
+
clearTimeout(this.debounceTimer);
|
|
4899
|
+
this.debounceTimer = setTimeout(() => {
|
|
4900
|
+
if (!this.hasJumpInputTarget)
|
|
4901
|
+
return;
|
|
4902
|
+
const input = this.jumpInputTarget;
|
|
4903
|
+
const page = parseInt(input.value, 10);
|
|
4904
|
+
const max = parseInt(input.max, 10);
|
|
4905
|
+
if (!isNaN(page) && page >= 1 && (!max || page <= max)) {
|
|
4906
|
+
this.visitUrl(this.urlTemplateValue.replace("__PAGE__", String(page)));
|
|
4907
|
+
}
|
|
4908
|
+
}, 400);
|
|
4909
|
+
}
|
|
4910
|
+
// Navigates to the URL selected in the per-page <select> element.
|
|
4911
|
+
navigate(event) {
|
|
4912
|
+
const select = event.target;
|
|
4913
|
+
const href = select.value;
|
|
4914
|
+
if (href && href !== "#") {
|
|
4915
|
+
this.visitUrl(href);
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
// Navigates to a URL via Turbo visit, updating the browser URL.
|
|
4919
|
+
visitUrl(url) {
|
|
4920
|
+
if (window.Turbo) {
|
|
4921
|
+
window.Turbo.visit(url);
|
|
4922
|
+
} else {
|
|
4923
|
+
window.location.href = url;
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
|
|
4861
4928
|
function registerMidwestControllers(application) {
|
|
4862
4929
|
application.register("midwest-card", Card);
|
|
4863
4930
|
application.register("midwest-banner", Banner);
|
|
@@ -4885,6 +4952,7 @@ function registerMidwestControllers(application) {
|
|
|
4885
4952
|
application.register("midwest-horizontal-scroll", HorizontalScroll);
|
|
4886
4953
|
application.register("midwest-table", Table);
|
|
4887
4954
|
application.register("midwest-load-more", LoadMore);
|
|
4955
|
+
application.register("midwest-pagination", Pagination);
|
|
4888
4956
|
}
|
|
4889
4957
|
|
|
4890
4958
|
export { Banner, Card, Chart, CountdownTimer, registerMidwestControllers };
|