pagy 8.0.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/apps/calendar.ru +745 -0
  3. data/{lib/apps → apps}/demo.ru +35 -52
  4. data/apps/keyset_ar.ru +236 -0
  5. data/apps/keyset_s.ru +238 -0
  6. data/{lib/apps → apps}/rails.ru +40 -33
  7. data/{lib/apps → apps}/repro.ru +33 -24
  8. data/apps/tmp/calendar.sqlite3 +0 -0
  9. data/apps/tmp/calendar.sqlite3-shm +0 -0
  10. data/apps/tmp/calendar.sqlite3-wal +0 -0
  11. data/apps/tmp/local_secret.txt +1 -0
  12. data/apps/tmp/pagy-keyset-ar.sqlite3 +0 -0
  13. data/apps/tmp/pagy-keyset-ar.sqlite3-shm +0 -0
  14. data/apps/tmp/pagy-keyset-ar.sqlite3-wal +0 -0
  15. data/apps/tmp/pagy-keyset-s.sqlite3 +0 -0
  16. data/{lib/bin → bin}/pagy +36 -17
  17. data/{lib/config → config}/pagy.rb +37 -68
  18. data/javascripts/pagy-module.js +100 -0
  19. data/javascripts/pagy.js +4 -0
  20. data/javascripts/pagy.min.js +4 -0
  21. data/javascripts/pagy.min.js.map +10 -0
  22. data/javascripts/pagy.mjs +100 -0
  23. data/lib/optimist.rb +1 -1
  24. data/lib/pagy/b64.rb +33 -0
  25. data/lib/pagy/backend.rb +24 -15
  26. data/lib/pagy/calendar/day.rb +5 -4
  27. data/lib/pagy/calendar/month.rb +5 -4
  28. data/lib/pagy/calendar/quarter.rb +5 -4
  29. data/lib/pagy/calendar/unit.rb +103 -0
  30. data/lib/pagy/calendar/week.rb +4 -4
  31. data/lib/pagy/calendar/year.rb +5 -4
  32. data/lib/pagy/calendar.rb +55 -99
  33. data/lib/pagy/console.rb +2 -2
  34. data/lib/pagy/countless.rb +17 -16
  35. data/lib/pagy/extras/arel.rb +8 -10
  36. data/lib/pagy/extras/array.rb +4 -6
  37. data/lib/pagy/extras/bootstrap.rb +7 -7
  38. data/lib/pagy/extras/bulma.rb +13 -9
  39. data/lib/pagy/extras/calendar.rb +35 -6
  40. data/lib/pagy/extras/countless.rb +7 -14
  41. data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
  42. data/lib/pagy/extras/gearbox.rb +36 -35
  43. data/lib/pagy/extras/headers.rb +26 -25
  44. data/lib/pagy/extras/i18n.rb +1 -1
  45. data/lib/pagy/extras/js_tools.rb +12 -9
  46. data/lib/pagy/extras/jsonapi.rb +27 -17
  47. data/lib/pagy/extras/keyset.rb +26 -0
  48. data/lib/pagy/extras/limit.rb +63 -0
  49. data/lib/pagy/extras/meilisearch.rb +11 -11
  50. data/lib/pagy/extras/metadata.rb +7 -3
  51. data/lib/pagy/extras/overflow.rb +9 -8
  52. data/lib/pagy/extras/pagy.rb +18 -18
  53. data/lib/pagy/extras/searchkick.rb +11 -11
  54. data/lib/pagy/extras/size.rb +40 -0
  55. data/lib/pagy/extras/standalone.rb +8 -8
  56. data/lib/pagy/extras/trim.rb +3 -3
  57. data/lib/pagy/frontend.rb +39 -37
  58. data/lib/pagy/i18n.rb +1 -1
  59. data/lib/pagy/keyset/active_record.rb +38 -0
  60. data/lib/pagy/keyset/sequel.rb +51 -0
  61. data/lib/pagy/keyset.rb +99 -0
  62. data/lib/pagy/url_helpers.rb +11 -11
  63. data/lib/pagy.rb +96 -120
  64. data/{lib/locales → locales}/ar.yml +9 -10
  65. data/{lib/locales → locales}/be.yml +2 -2
  66. data/{lib/locales → locales}/bg.yml +2 -2
  67. data/{lib/locales → locales}/bs.yml +2 -2
  68. data/{lib/locales → locales}/ca.yml +5 -7
  69. data/{lib/locales → locales}/ckb.yml +2 -2
  70. data/{lib/locales → locales}/cs.yml +2 -2
  71. data/{lib/locales → locales}/da.yml +5 -7
  72. data/{lib/locales → locales}/de.yml +2 -2
  73. data/{lib/locales → locales}/en.yml +2 -2
  74. data/{lib/locales → locales}/es.yml +2 -2
  75. data/{lib/locales → locales}/fr.yml +2 -2
  76. data/{lib/locales → locales}/hr.yml +2 -2
  77. data/{lib/locales → locales}/id.yml +2 -2
  78. data/{lib/locales → locales}/it.yml +2 -2
  79. data/{lib/locales → locales}/ja.yml +2 -2
  80. data/{lib/locales → locales}/km.yml +2 -2
  81. data/{lib/locales → locales}/ko.yml +3 -5
  82. data/{lib/locales → locales}/nb.yml +2 -2
  83. data/{lib/locales → locales}/nl.yml +2 -2
  84. data/{lib/locales → locales}/nn.yml +2 -2
  85. data/{lib/locales → locales}/pl.yml +2 -2
  86. data/{lib/locales → locales}/pt-BR.yml +2 -2
  87. data/{lib/locales → locales}/pt.yml +2 -2
  88. data/{lib/locales → locales}/ru.yml +7 -9
  89. data/{lib/locales → locales}/sr.yml +2 -2
  90. data/{lib/locales → locales}/sv-SE.yml +2 -2
  91. data/{lib/locales → locales}/sv.yml +2 -2
  92. data/{lib/locales → locales}/sw.yml +2 -2
  93. data/{lib/locales → locales}/ta.yml +2 -2
  94. data/{lib/locales → locales}/tr.yml +2 -2
  95. data/{lib/locales → locales}/uk.yml +2 -2
  96. data/{lib/locales → locales}/vi.yml +2 -2
  97. data/{lib/locales → locales}/zh-CN.yml +2 -2
  98. data/{lib/locales → locales}/zh-HK.yml +2 -2
  99. data/{lib/locales → locales}/zh-TW.yml +2 -2
  100. data/pkg/pagy-9.0.0.gem +0 -0
  101. metadata +75 -70
  102. data/lib/apps/calendar.ru +0 -2196
  103. data/lib/javascripts/pagy-dev.js +0 -112
  104. data/lib/javascripts/pagy-module.js +0 -111
  105. data/lib/javascripts/pagy.js +0 -1
  106. data/lib/pagy/calendar/helper.rb +0 -65
  107. data/lib/pagy/extras/foundation.rb +0 -93
  108. data/lib/pagy/extras/items.rb +0 -64
  109. data/lib/pagy/extras/materialize.rb +0 -97
  110. data/lib/pagy/extras/semantic.rb +0 -91
  111. data/lib/pagy/extras/uikit.rb +0 -96
  112. /data/{lib/javascripts/pagy-module.d.ts → javascripts/pagy.d.ts} +0 -0
  113. /data/{lib/stylesheets → stylesheets}/pagy.css +0 -0
  114. /data/{lib/stylesheets → stylesheets}/pagy.scss +0 -0
  115. /data/{lib/stylesheets → stylesheets}/pagy.tailwind.css +0 -0
@@ -1,112 +0,0 @@
1
- "use strict";
2
- window.Pagy = (() => {
3
- // The observer instance for responsive navs
4
- const rjsObserver = new ResizeObserver(entries => entries.forEach(e => e.target.querySelectorAll(".pagy-rjs").forEach(el => el.pagyRender())));
5
- // Init the *_nav_js helpers
6
- const initNav = (el, [tokens, sequels, labelSequels, trimParam]) => {
7
- const container = el.parentElement ?? el;
8
- const widths = Object.keys(sequels).map(w => parseInt(w)).sort((a, b) => b - a);
9
- let lastWidth = -1;
10
- const fillIn = (a, page, label) => a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
11
- (el.pagyRender = function () {
12
- const width = widths.find(w => w < container.clientWidth) || 0;
13
- if (width === lastWidth) {
14
- return;
15
- } // no change: abort
16
- let html = tokens.before; // already trimmed in html
17
- const series = sequels[width.toString()];
18
- const labels = labelSequels?.[width.toString()] ?? series.map(l => l.toString());
19
- for (const i in series) {
20
- const item = series[i];
21
- const label = labels[i];
22
- let filled;
23
- if (typeof item === "number") {
24
- filled = fillIn(tokens.a, item.toString(), label);
25
- }
26
- else if (item === "gap") {
27
- filled = tokens.gap;
28
- }
29
- else { // active page
30
- filled = fillIn(tokens.current, item, label);
31
- }
32
- html += (typeof trimParam === "string" && item == 1) ? trim(filled, trimParam) : filled;
33
- }
34
- html += tokens.after; // eslint-disable-line align-assignments/align-assignments
35
- el.innerHTML = "";
36
- el.insertAdjacentHTML("afterbegin", html);
37
- lastWidth = width;
38
- })();
39
- if (el.classList.contains("pagy-rjs")) {
40
- rjsObserver.observe(container);
41
- }
42
- };
43
- // Init the *_combo_nav_js helpers
44
- const initCombo = (el, [url_token, trimParam]) => initInput(el, inputValue => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);
45
- // Init the items_selector_js helper
46
- const initSelector = (el, [from, url_token, trimParam]) => {
47
- initInput(el, inputValue => {
48
- const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
49
- const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
50
- return [page, url];
51
- }, trimParam);
52
- };
53
- // Init the input element
54
- const initInput = (el, getVars, trimParam) => {
55
- const input = el.querySelector("input");
56
- const initial = input.value;
57
- const action = function () {
58
- if (input.value === initial) {
59
- return;
60
- } // not changed
61
- const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);
62
- if (val < min || val > max) { // reset invalid/out-of-range
63
- input.value = initial;
64
- input.select();
65
- return;
66
- }
67
- let [page, url] = getVars(input.value); // eslint-disable-line prefer-const
68
- if (typeof trimParam === "string" && page === "1") {
69
- url = trim(url, trimParam);
70
- }
71
- window.location.href = url;
72
- };
73
- ["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
74
- input.addEventListener("focusout", action); // trigger action
75
- input.addEventListener("keypress", e => { if (e.key === "Enter") {
76
- action();
77
- } }); // trigger action
78
- };
79
- // Trim the ${page-param}=1 params in links
80
- const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
81
- // Public interface
82
- return {
83
- version: "8.0.0",
84
- // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
85
- init(arg) {
86
- const target = arg instanceof Element ? arg : document;
87
- const elements = target.querySelectorAll("[data-pagy]");
88
- for (const el of elements) {
89
- try {
90
- const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
91
- const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)); // base64-utf8 -> JSON -> Array
92
- if (keyword === "nav") {
93
- initNav(el, args);
94
- }
95
- else if (keyword === "combo") {
96
- initCombo(el, args);
97
- }
98
- else if (keyword === "selector") {
99
- initSelector(el, args);
100
- }
101
- else {
102
- console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
103
- }
104
- }
105
- catch (err) {
106
- console.warn("Skipped Pagy.init() for: %o\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GNvbnN0IHNlcmllcyA9IHNlcXVlbHNbd2lkdGgudG9TdHJpbmcoKV07XG4gICAgICAgICAgICBjb25zdCBsYWJlbHMgPSBsYWJlbFNlcXVlbHM/Llt3aWR0aC50b1N0cmluZygpXSA/PyBzZXJpZXMubWFwKGwgPT4gbC50b1N0cmluZygpKTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgaSBpbiBzZXJpZXMpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gc2VyaWVzW2ldO1xuICAgICAgICAgICAgICAgIGNvbnN0IGxhYmVsID0gbGFiZWxzW2ldO1xuICAgICAgICAgICAgICAgIGxldCBmaWxsZWQ7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBpdGVtID09PSBcIm51bWJlclwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpbGxlZCA9IGZpbGxJbih0b2tlbnMuYSwgaXRlbS50b1N0cmluZygpLCBsYWJlbCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpdGVtID09PSBcImdhcFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpbGxlZCA9IHRva2Vucy5nYXA7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHsgLy8gYWN0aXZlIHBhZ2VcbiAgICAgICAgICAgICAgICAgICAgZmlsbGVkID0gZmlsbEluKHRva2Vucy5jdXJyZW50LCBpdGVtLCBsYWJlbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGh0bWwgKz0gKHR5cGVvZiB0cmltUGFyYW0gPT09IFwic3RyaW5nXCIgJiYgaXRlbSA9PSAxKSA/IHRyaW0oZmlsbGVkLCB0cmltUGFyYW0pIDogZmlsbGVkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaHRtbCArPSB0b2tlbnMuYWZ0ZXI7ICAgLy8gZXNsaW50LWRpc2FibGUtbGluZSBhbGlnbi1hc3NpZ25tZW50cy9hbGlnbi1hc3NpZ25tZW50c1xuICAgICAgIC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BuZXZlcikge1xuICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYXJnIGluc3RhbmNlb2YgRWxlbWVudCA/IGFyZyA6IGRvY3VtZW50O1xuICAgICAgICAgICAgY29uc3QgZWxlbWVudHMgPSB0YXJnZXQucXVlcnlTZWxlY3RvckFsbChcIltkYXRhLXBhZ3ldXCIpO1xuICAgICAgICAgICAgZm9yIChjb25zdCBlbCBvZiBlbGVtZW50cykge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHVpbnQ4YXJyYXkgPSBVaW50OEFycmF5LmZyb20oYXRvYihlbC5nZXRBdHRyaWJ1dGUoXCJkYXRhLXBhZ3lcIikgYXMgc3RyaW5nKSwgYyA9PiBjLmNoYXJDb2RlQXQoMCkpO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBba2V5d29yZCwgLi4uYXJnc10gPSBKU09OLnBhcnNlKChuZXcgVGV4dERlY29kZXIoKSkuZGVjb2RlKHVpbnQ4YXJyYXkpKTsgLy8gYmFzZTY0LXV0ZjggLT4gSlNPTiAtPiBBcnJheVxuICAgICAgICAgICAgICAgICAgICBpZiAoa2V5d29yZCA9PT0gXCJuYXZcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdE5hdihlbCBhcyBOYXZFbGVtZW50LCBhcmdzIGFzIE5hdkFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGtleXdvcmQgPT09IFwiY29tYm9cIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdENvbWJvKGVsLCBhcmdzIGFzIENvbWJvQXJncyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoa2V5d29yZCA9PT0gXCJzZWxlY3RvclwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbml0U2VsZWN0b3IoZWwsIGFyZ3MgYXMgU2VsZWN0b3JBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIlNraXBwZWQgUGFneS5pbml0KCkgZm9yOiAlb1xcblVua25vd24ga2V5d29yZCAnJXMnXCIsIGVsLCBrZXl3b3JkKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgeyBjb25zb2xlLndhcm4oXCJTa2lwcGVkIFBhZ3kuaW5pdCgpIGZvcjogJW9cXG4lc1wiLCBlbCwgZXJyKSB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufSkoKTtcbiJdfQ==
@@ -1,111 +0,0 @@
1
- const Pagy = (() => {
2
- // The observer instance for responsive navs
3
- const rjsObserver = new ResizeObserver(entries => entries.forEach(e => e.target.querySelectorAll(".pagy-rjs").forEach(el => el.pagyRender())));
4
- // Init the *_nav_js helpers
5
- const initNav = (el, [tokens, sequels, labelSequels, trimParam]) => {
6
- const container = el.parentElement ?? el;
7
- const widths = Object.keys(sequels).map(w => parseInt(w)).sort((a, b) => b - a);
8
- let lastWidth = -1;
9
- const fillIn = (a, page, label) => a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
10
- (el.pagyRender = function () {
11
- const width = widths.find(w => w < container.clientWidth) || 0;
12
- if (width === lastWidth) {
13
- return;
14
- } // no change: abort
15
- let html = tokens.before; // already trimmed in html
16
- const series = sequels[width.toString()];
17
- const labels = labelSequels?.[width.toString()] ?? series.map(l => l.toString());
18
- for (const i in series) {
19
- const item = series[i];
20
- const label = labels[i];
21
- let filled;
22
- if (typeof item === "number") {
23
- filled = fillIn(tokens.a, item.toString(), label);
24
- }
25
- else if (item === "gap") {
26
- filled = tokens.gap;
27
- }
28
- else { // active page
29
- filled = fillIn(tokens.current, item, label);
30
- }
31
- html += (typeof trimParam === "string" && item == 1) ? trim(filled, trimParam) : filled;
32
- }
33
- html += tokens.after; // eslint-disable-line align-assignments/align-assignments
34
- el.innerHTML = "";
35
- el.insertAdjacentHTML("afterbegin", html);
36
- lastWidth = width;
37
- })();
38
- if (el.classList.contains("pagy-rjs")) {
39
- rjsObserver.observe(container);
40
- }
41
- };
42
- // Init the *_combo_nav_js helpers
43
- const initCombo = (el, [url_token, trimParam]) => initInput(el, inputValue => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);
44
- // Init the items_selector_js helper
45
- const initSelector = (el, [from, url_token, trimParam]) => {
46
- initInput(el, inputValue => {
47
- const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
48
- const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
49
- return [page, url];
50
- }, trimParam);
51
- };
52
- // Init the input element
53
- const initInput = (el, getVars, trimParam) => {
54
- const input = el.querySelector("input");
55
- const initial = input.value;
56
- const action = function () {
57
- if (input.value === initial) {
58
- return;
59
- } // not changed
60
- const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);
61
- if (val < min || val > max) { // reset invalid/out-of-range
62
- input.value = initial;
63
- input.select();
64
- return;
65
- }
66
- let [page, url] = getVars(input.value); // eslint-disable-line prefer-const
67
- if (typeof trimParam === "string" && page === "1") {
68
- url = trim(url, trimParam);
69
- }
70
- window.location.href = url;
71
- };
72
- ["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
73
- input.addEventListener("focusout", action); // trigger action
74
- input.addEventListener("keypress", e => { if (e.key === "Enter") {
75
- action();
76
- } }); // trigger action
77
- };
78
- // Trim the ${page-param}=1 params in links
79
- const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
80
- // Public interface
81
- return {
82
- version: "8.0.0",
83
- // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
84
- init(arg) {
85
- const target = arg instanceof Element ? arg : document;
86
- const elements = target.querySelectorAll("[data-pagy]");
87
- for (const el of elements) {
88
- try {
89
- const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
90
- const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)); // base64-utf8 -> JSON -> Array
91
- if (keyword === "nav") {
92
- initNav(el, args);
93
- }
94
- else if (keyword === "combo") {
95
- initCombo(el, args);
96
- }
97
- else if (keyword === "selector") {
98
- initSelector(el, args);
99
- }
100
- else {
101
- console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
102
- }
103
- }
104
- catch (err) {
105
- console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
106
- }
107
- }
108
- }
109
- };
110
- })();
111
- export default Pagy;
@@ -1 +0,0 @@
1
- !function(){let e=(()=>{let e=new ResizeObserver(e=>e.forEach(e=>e.target.querySelectorAll(".pagy-rjs").forEach(e=>e.pagyRender()))),t=(t,[r,n,a,i])=>{let l=t.parentElement??t,p=Object.keys(n).map(e=>parseInt(e)).sort((e,t)=>t-e),c=-1,s=(e,t,r)=>e.replace(/__pagy_page__/g,t).replace(/__pagy_label__/g,r);(t.pagyRender=function(){let e=p.find(e=>e<l.clientWidth)||0;if(e===c)return;let g=r.before,f=n[e.toString()],y=a?.[e.toString()]??f.map(e=>e.toString());for(let e in f){let t;let n=f[e],a=y[e];t="number"==typeof n?s(r.a,n.toString(),a):"gap"===n?r.gap:s(r.current,n,a),g+="string"==typeof i&&1==n?o(t,i):t}g+=r.after,t.innerHTML="",t.insertAdjacentHTML("afterbegin",g),c=e})(),t.classList.contains("pagy-rjs")&&e.observe(l)},r=(e,[t,r])=>a(e,e=>[e,t.replace(/__pagy_page__/,e)],r),n=(e,[t,r,n])=>{a(e,e=>{let n=Math.max(Math.ceil(t/parseInt(e)),1).toString(),a=r.replace(/__pagy_page__/,n).replace(/__pagy_items__/,e);return[n,a]},n)},a=(e,t,r)=>{let n=e.querySelector("input"),a=n.value,i=function(){if(n.value===a)return;let[e,i,l]=[n.min,n.value,n.max].map(e=>parseInt(e)||0);if(i<e||i>l){n.value=a,n.select();return}let[p,c]=t(n.value);"string"==typeof r&&"1"===p&&(c=o(c,r)),window.location.href=c};["change","focus"].forEach(e=>n.addEventListener(e,n.select)),n.addEventListener("focusout",i),n.addEventListener("keypress",e=>{"Enter"===e.key&&i()})},o=(e,t)=>e.replace(RegExp(`[?&]${t}=1\\b(?!&)|\\b${t}=1&`),"");return{version:"8.0.0",init(e){for(let a of(e instanceof Element?e:document).querySelectorAll("[data-pagy]"))try{let e=Uint8Array.from(atob(a.getAttribute("data-pagy")),e=>e.charCodeAt(0)),[o,...i]=JSON.parse(new TextDecoder().decode(e));"nav"===o?t(a,i):"combo"===o?r(a,i):"selector"===o?n(a,i):console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",a,o)}catch(e){console.warn("Skipped Pagy.init() for: %o\n%s",a,e)}}}})();window.Pagy=e}();
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Pagy # :nodoc:
4
- class Calendar # :nodoc:
5
- # Initializes the calendar objects, reducing complexity in the extra
6
- # The returned calendar is a simple hash of units/objects
7
- class Helper < Hash
8
- class << self
9
- private
10
-
11
- def init(conf, period, params)
12
- new.send(:init, conf, period, params)
13
- end
14
- end
15
-
16
- private
17
-
18
- # Create the calendar
19
- def init(conf, period, params)
20
- @conf = Marshal.load(Marshal.dump(conf)) # store a copy
21
- @units = Calendar::UNITS & @conf.keys # get the units in time length desc order
22
- raise ArgumentError, 'no calendar unit found in pagy_calendar @configuration' if @units.empty?
23
-
24
- @period = period
25
- @params = params
26
- @page_param = conf[:pagy][:page_param] || DEFAULT[:page_param]
27
- @units.each do |unit| # set all the :page_param vars for later deletion
28
- unit_page_param = :"#{unit}_#{@page_param}"
29
- conf[unit][:page_param] = unit_page_param
30
- conf[unit][:page] = @params[unit_page_param]
31
- end
32
- calendar = {}
33
- object = nil
34
- @units.each_with_index do |unit, index|
35
- params_to_delete = @units[(index + 1), @units.size].map { |sub| conf[sub][:page_param] } + [@page_param]
36
- conf[unit][:params] = lambda { |up| up.except(*params_to_delete.map(&:to_s)) } # rubocop:disable Style/Lambda
37
- conf[unit][:period] = object&.send(:active_period) || @period
38
- calendar[unit] = object = Calendar.send(:create, unit, conf[unit])
39
- end
40
- [replace(calendar), object.from, object.to]
41
- end
42
-
43
- # Return the calendar object at time
44
- def calendar_at(time, **opts)
45
- conf = Marshal.load(Marshal.dump(@conf))
46
- page_params = {}
47
- @units.inject(nil) do |object, unit|
48
- conf[unit][:period] = object&.send(:active_period) || @period
49
- conf[unit][:page] = page_params[:"#{unit}_#{@page_param}"] \
50
- = Calendar.send(:create, unit, conf[unit]).send(:page_at, time, **opts)
51
- conf[unit][:params] ||= {}
52
- conf[unit][:params].merge!(page_params)
53
- Calendar.send(:create, unit, conf[unit])
54
- end
55
- end
56
-
57
- public
58
-
59
- # Return the current time of the smallest time unit shown
60
- def showtime
61
- self[@units.last].from
62
- end
63
- end
64
- end
65
- end
@@ -1,93 +0,0 @@
1
- # See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/foundation
2
- # frozen_string_literal: true
3
-
4
- require 'pagy/extras/js_tools'
5
-
6
- class Pagy # :nodoc:
7
- # Frontend modules are specially optimized for performance.
8
- # The resulting code may not look very elegant, but produces the best benchmarks
9
- module FoundationExtra
10
- # Pagination for Foundation: it returns the html with the series of links to the pages
11
- def pagy_foundation_nav(pagy, id: nil, aria_label: nil, **vars)
12
- id = %( id="#{id}") if id
13
- a = pagy_anchor(pagy)
14
-
15
- html = +%(<nav#{id} class="pagy-foundation-nav" #{
16
- nav_aria_label(pagy, aria_label:)}><ul class="pagination"> #{
17
- foundation_prev_html(pagy, a)})
18
- pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
19
- html << case item
20
- when Integer
21
- %(<li>#{a.(item)}</li>)
22
- when String
23
- %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</li>)
24
- when :gap
25
- %(<li class="ellipsis gap"></li>)
26
- else
27
- raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
28
- end
29
- end
30
- html << %(#{foundation_next_html(pagy, a)}</ul></nav>)
31
- end
32
-
33
- # Javascript pagination for foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
34
- def pagy_foundation_nav_js(pagy, id: nil, aria_label: nil, **vars)
35
- sequels = pagy.sequels(**vars)
36
- id = %( id="#{id}") if id
37
- a = pagy_anchor(pagy)
38
- tokens = { 'before' => %(<ul class="pagination">#{foundation_prev_html pagy, a}),
39
- 'a' => %(<li>#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
40
- 'current' => %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</li>),
41
- 'gap' => %(<li class="ellipsis gap"></li>),
42
- 'after' => %(#{foundation_next_html pagy, a}</ul>) }
43
-
44
- %(<nav#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-foundation-nav-js" #{
45
- nav_aria_label(pagy, aria_label:)} #{
46
- pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
47
- }></nav>)
48
- end
49
-
50
- # Javascript combo pagination for Foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
51
- def pagy_foundation_combo_nav_js(pagy, id: nil, aria_label: nil)
52
- id = %( id="#{id}") if id
53
- a = pagy_anchor(pagy)
54
- pages = pagy.pages
55
-
56
- page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
57
- %(style="text-align: center; width: #{pages.to_s.length + 1}rem; ) <<
58
- %(height: 1.5rem; padding: .5rem; margin: 0 .4rem; font-size: .875rem;" class="current">)
59
-
60
- %(<nav#{id} class="pagy-foundation-combo-nav-js" #{
61
- nav_aria_label(pagy, aria_label:)} #{
62
- pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
63
- }><ul class="pagination">#{
64
- foundation_prev_html(pagy, a)
65
- }<li style="padding: 0 .3rem"><label style="display: flex; align-items: center; white-space: nowrap">#{
66
- pagy_t('pagy.combo_nav_js', page_input:, pages:)
67
- }</label></li>#{
68
- foundation_next_html(pagy, a)
69
- }</ul></nav>)
70
- end
71
-
72
- private
73
-
74
- def foundation_prev_html(pagy, a)
75
- if (p_prev = pagy.prev)
76
- %(<li class="prev">#{a.(p_prev, pagy_t('pagy.prev'), aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
77
- else
78
- %(<li class="prev disabled" role="link" aria-disabled="true" #{
79
- pagy_t('pagy.aria_label.prev')}>#{pagy_t('pagy.prev')}</li>)
80
- end
81
- end
82
-
83
- def foundation_next_html(pagy, a)
84
- if (p_next = pagy.next)
85
- %(<li class="next">#{a.(p_next, pagy_t('pagy.next'), aria_label: pagy_t('pagy.aria_label.next'))}</li>)
86
- else
87
- %(<li class="next disabled" role="link" aria-disabled="true" #{
88
- pagy_t('pagy.aria_label.next')}>#{pagy_t('pagy.next')}</li>)
89
- end
90
- end
91
- end
92
- Frontend.prepend FoundationExtra
93
- end
@@ -1,64 +0,0 @@
1
- # See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/items
2
- # frozen_string_literal: true
3
-
4
- require 'pagy/extras/js_tools'
5
-
6
- class Pagy # :nodoc:
7
- DEFAULT[:items_param] = :items
8
- DEFAULT[:max_items] = 100
9
- DEFAULT[:items_extra] = true # extra enabled by default
10
-
11
- # Allow the client to request a custom number of items per page with an optional selector UI
12
- module ItemsExtra
13
- # Additions for the Backend module
14
- module BackendAddOn
15
- private
16
-
17
- # Set the items variable considering the params and other pagy variables
18
- def pagy_set_items_from_params(vars)
19
- return if vars[:items] # :items explicitly set
20
- return unless vars.key?(:items_extra) ? vars[:items_extra] : DEFAULT[:items_extra] # :items_extra is false
21
- return unless (items_count = pagy_get_items_size(vars)) # no items from request params
22
-
23
- vars[:items] = [items_count.to_i, vars.key?(:max_items) ? vars[:max_items] : DEFAULT[:max_items]].compact.min
24
- end
25
-
26
- # Get the items count from the params
27
- # Overridable by the jsonapi extra
28
- def pagy_get_items_size(vars)
29
- params[vars[:items_param] || DEFAULT[:items_param]]
30
- end
31
- end
32
- Backend.prepend ItemsExtra::BackendAddOn
33
-
34
- # Additions for the Frontend module
35
- module FrontendAddOn
36
- ITEMS_TOKEN = '__pagy_items__'
37
-
38
- # Return the items selector HTML. For example "Show [20] items per page"
39
- def pagy_items_selector_js(pagy, id: nil, item_name: nil)
40
- return '' unless pagy.vars[:items_extra]
41
-
42
- id = %( id="#{id}") if id
43
- vars = pagy.vars
44
- items = vars[:items]
45
- vars[:items] = ITEMS_TOKEN
46
- url_token = pagy_url_for(pagy, PAGE_TOKEN)
47
- vars[:items] = items # restore the items
48
-
49
- items_input = %(<input name="items" type="number" min="1" max="#{vars[:max_items]}" value="#{
50
- items}" style="padding: 0; text-align: center; width: #{items.to_s.length + 1}rem;">)
51
-
52
- %(<span#{id} class="pagy items-selector-js" #{
53
- pagy_data(pagy, :selector, pagy.from, url_token)
54
- }><label>#{
55
- pagy_t('pagy.items_selector_js',
56
- item_name: item_name || pagy_t('pagy.item_name', count: items),
57
- items_input:,
58
- count: items)
59
- }</label></span>)
60
- end
61
- end
62
- Frontend.prepend ItemsExtra::FrontendAddOn
63
- end
64
- end
@@ -1,97 +0,0 @@
1
- # See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/materialize
2
- # frozen_string_literal: true
3
-
4
- require 'pagy/extras/js_tools'
5
-
6
- class Pagy # :nodoc:
7
- # Frontend modules are specially optimized for performance.
8
- # The resulting code may not look very elegant, but produces the best benchmarks
9
- module MaterializeExtra
10
- # Pagination for materialize: it returns the html with the series of links to the pages
11
- def pagy_materialize_nav(pagy, id: nil, aria_label: nil, **vars)
12
- id = %( id="#{id}") if id
13
- a = pagy_anchor(pagy)
14
-
15
- html = +%(<div#{id} class="pagy-materialize nav pagination" role="navigation" #{
16
- nav_aria_label(pagy, aria_label:)}><ul class="pagination">#{
17
- materialize_prev_html(pagy, a)})
18
- pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
19
- html << case item
20
- when Integer
21
- %(<li class="waves-effect">#{a.(item)}</li>)
22
- when String
23
- %(<li class="active"><a role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</a></li>)
24
- when :gap
25
- %(<li class="gap disabled"><a role="link" aria-disabled="true">#{pagy_t 'pagy.gap'}</a></li>)
26
- else
27
- raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
28
- end
29
- end
30
- html << %(#{materialize_next_html(pagy, a)}</ul></div>)
31
- end
32
-
33
- # Javascript pagination for materialize: it returns a nav with a data-pagy attribute used by the pagy.js file
34
- def pagy_materialize_nav_js(pagy, id: nil, aria_label: nil, **vars)
35
- sequels = pagy.sequels(**vars)
36
- id = %( id="#{id}") if id
37
- a = pagy_anchor(pagy)
38
-
39
- tokens = { 'before' => %(<ul class="pagination">#{materialize_prev_html pagy, a}),
40
- 'a' => %(<li class="waves-effect">#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
41
- 'current' => %(<li class="active"><a role="link" aria-current="page" aria-disabled="true">#{
42
- LABEL_TOKEN}</a></li>),
43
- 'gap' => %(<li class="gap disabled"><a role="link" aria-disabled="true">#{pagy_t 'pagy.gap'}</a></li>),
44
- 'after' => %(#{materialize_next_html pagy, a}</ul>) }
45
-
46
- %(<div#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-materialize nav-js" role="navigation" #{
47
- nav_aria_label(pagy, aria_label:)} #{
48
- pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
49
- }></div>)
50
- end
51
-
52
- # Javascript combo pagination for materialize: it returns a nav with a data-pagy attribute used by the pagy.js file
53
- def pagy_materialize_combo_nav_js(pagy, id: nil, aria_label: nil)
54
- id = %( id="#{id}") if id
55
- a = pagy_anchor(pagy)
56
- pages = pagy.pages
57
-
58
- page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
59
- %(style="text-align: center; width: #{pages.to_s.length + 1}rem; height: 1.5rem; font-size: 1.2rem; ) <<
60
- %(border: none; border-radius: 2px; color: white; background-color: #ee6e73;" class="browser-default">)
61
-
62
- %(<ul#{id} class="pagy-materialize combo-nav-js pagination" role="navigation" style="padding-right: 0;" #{
63
- nav_aria_label(pagy, aria_label:)} #{
64
- pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
65
- }>#{
66
- materialize_prev_html(pagy, a)
67
- }<li style="vertical-align: -webkit-baseline-middle;"><label style="font-size: 1.2rem;">#{
68
- pagy_t('pagy.combo_nav_js', page_input:, pages:)
69
- }</label></li>#{
70
- materialize_next_html(pagy, a)
71
- }</ul>)
72
- end
73
-
74
- private
75
-
76
- def materialize_prev_html(pagy, a)
77
- if (p_prev = pagy.prev)
78
- %(<li class="waves-effect prev">#{
79
- a.(p_prev, '<i class="material-icons">chevron_left</i>', aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
80
- else
81
- %(<li class="prev disabled"><a role="link" aria-disabled="true" aria-label="#{
82
- pagy_t('pagy.aria_label.prev')}"><i class="material-icons">chevron_left</i></a></li>)
83
- end
84
- end
85
-
86
- def materialize_next_html(pagy, a)
87
- if (p_next = pagy.next)
88
- %(<li class="waves-effect next">#{
89
- a.(p_next, '<i class="material-icons">chevron_right</i>', aria_label: pagy_t('pagy.aria_label.next'))}</li>)
90
- else
91
- %(<li class="next disabled"#><a role="link" aria-disabled="true" aria-label="#{
92
- pagy_t('pagy.aria_label.next')}><i class="material-icons">chevron_right</i></a></li>)
93
- end
94
- end
95
- end
96
- Frontend.prepend MaterializeExtra
97
- end