pagy 7.0.11 → 8.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/apps/calendar.ru +745 -0
  3. data/apps/demo.ru +435 -0
  4. data/apps/rails.ru +212 -0
  5. data/apps/repro.ru +177 -0
  6. data/apps/tmp/calendar.sqlite3 +0 -0
  7. data/apps/tmp/calendar.sqlite3-shm +0 -0
  8. data/apps/tmp/calendar.sqlite3-wal +0 -0
  9. data/apps/tmp/local_secret.txt +1 -0
  10. data/apps/tmp/pagy-keyset.sqlite3 +0 -0
  11. data/apps/tmp/pagy-keyset.sqlite3-shm +0 -0
  12. data/apps/tmp/pagy-keyset.sqlite3-wal +0 -0
  13. data/bin/pagy +100 -0
  14. data/{lib/config → config}/pagy.rb +31 -73
  15. data/javascripts/pagy-module.js +100 -0
  16. data/javascripts/pagy.js +4 -0
  17. data/javascripts/pagy.min.js +4 -0
  18. data/javascripts/pagy.min.js.map +10 -0
  19. data/javascripts/pagy.mjs +100 -0
  20. data/lib/optimist.rb +1022 -0
  21. data/lib/pagy/backend.rb +8 -3
  22. data/lib/pagy/calendar/day.rb +4 -3
  23. data/lib/pagy/calendar/month.rb +4 -3
  24. data/lib/pagy/calendar/quarter.rb +4 -3
  25. data/lib/pagy/calendar/unit.rb +106 -0
  26. data/lib/pagy/calendar/week.rb +3 -3
  27. data/lib/pagy/calendar/year.rb +4 -3
  28. data/lib/pagy/calendar.rb +55 -99
  29. data/lib/pagy/console.rb +2 -2
  30. data/lib/pagy/countless.rb +15 -10
  31. data/lib/pagy/extras/arel.rb +1 -1
  32. data/lib/pagy/extras/array.rb +1 -1
  33. data/lib/pagy/extras/bootstrap.rb +52 -63
  34. data/lib/pagy/extras/bulma.rb +49 -64
  35. data/lib/pagy/extras/calendar.rb +35 -5
  36. data/lib/pagy/extras/countless.rb +2 -2
  37. data/lib/pagy/extras/foundation.rb +52 -62
  38. data/lib/pagy/extras/gearbox.rb +28 -27
  39. data/lib/pagy/extras/headers.rb +1 -1
  40. data/lib/pagy/extras/i18n.rb +1 -1
  41. data/lib/pagy/extras/items.rb +21 -18
  42. data/lib/pagy/extras/{frontend_helpers.rb → js_tools.rb} +9 -6
  43. data/lib/pagy/extras/jsonapi.rb +2 -2
  44. data/lib/pagy/extras/materialize.rb +56 -52
  45. data/lib/pagy/extras/metadata.rb +6 -2
  46. data/lib/pagy/extras/overflow.rb +5 -4
  47. data/lib/pagy/extras/pagy.rb +82 -0
  48. data/lib/pagy/extras/semantic.rb +50 -51
  49. data/lib/pagy/extras/size.rb +40 -0
  50. data/lib/pagy/extras/standalone.rb +2 -2
  51. data/lib/pagy/extras/trim.rb +12 -12
  52. data/lib/pagy/extras/uikit.rb +51 -50
  53. data/lib/pagy/frontend.rb +39 -53
  54. data/lib/pagy/url_helpers.rb +9 -10
  55. data/lib/pagy.rb +51 -82
  56. data/{lib/locales → locales}/ar.yml +10 -11
  57. data/{lib/locales → locales}/be.yml +5 -5
  58. data/{lib/locales → locales}/bg.yml +5 -5
  59. data/{lib/locales → locales}/bs.yml +5 -5
  60. data/locales/ca.yml +21 -0
  61. data/locales/ckb.yml +18 -0
  62. data/{lib/locales → locales}/cs.yml +5 -5
  63. data/locales/da.yml +21 -0
  64. data/{lib/locales → locales}/de.yml +5 -5
  65. data/{lib/locales → locales}/en.yml +5 -5
  66. data/{lib/locales → locales}/es.yml +3 -3
  67. data/{lib/locales → locales}/fr.yml +5 -5
  68. data/{lib/locales → locales}/hr.yml +5 -5
  69. data/{lib/locales → locales}/id.yml +5 -5
  70. data/{lib/locales → locales}/it.yml +5 -5
  71. data/{lib/locales → locales}/ja.yml +5 -5
  72. data/{lib/locales → locales}/km.yml +5 -5
  73. data/locales/ko.yml +17 -0
  74. data/{lib/locales → locales}/nb.yml +5 -5
  75. data/{lib/locales → locales}/nl.yml +5 -5
  76. data/{lib/locales → locales}/nn.yml +5 -5
  77. data/{lib/locales → locales}/pl.yml +5 -5
  78. data/{lib/locales → locales}/pt-BR.yml +3 -3
  79. data/{lib/locales → locales}/pt.yml +3 -3
  80. data/locales/ru.yml +25 -0
  81. data/{lib/locales → locales}/sr.yml +5 -5
  82. data/{lib/locales → locales}/sv-SE.yml +5 -5
  83. data/{lib/locales → locales}/sv.yml +5 -5
  84. data/{lib/locales → locales}/sw.yml +5 -5
  85. data/{lib/locales → locales}/ta.yml +5 -5
  86. data/{lib/locales → locales}/tr.yml +5 -5
  87. data/{lib/locales → locales}/uk.yml +5 -5
  88. data/locales/vi.yml +17 -0
  89. data/{lib/locales → locales}/zh-CN.yml +5 -5
  90. data/{lib/locales → locales}/zh-HK.yml +5 -5
  91. data/{lib/locales → locales}/zh-TW.yml +5 -5
  92. data/{lib/stylesheets → stylesheets}/pagy.css +19 -34
  93. data/{lib/stylesheets → stylesheets}/pagy.scss +17 -19
  94. data/stylesheets/pagy.tailwind.css +21 -0
  95. metadata +76 -53
  96. data/lib/javascripts/pagy-dev.js +0 -112
  97. data/lib/javascripts/pagy-module.js +0 -111
  98. data/lib/javascripts/pagy.js +0 -1
  99. data/lib/locales/ca.yml +0 -23
  100. data/lib/locales/ckb.yml +0 -18
  101. data/lib/locales/da.yml +0 -23
  102. data/lib/locales/ko.yml +0 -19
  103. data/lib/locales/ru.yml +0 -27
  104. data/lib/locales/vi.yml +0 -17
  105. data/lib/pagy/calendar/helper.rb +0 -65
  106. data/lib/pagy/extras/navs.rb +0 -51
  107. data/lib/pagy/extras/support.rb +0 -40
  108. data/lib/stylesheets/pagy.tailwind.scss +0 -24
  109. /data/{lib/javascripts/pagy-module.d.ts → javascripts/pagy.d.ts} +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, [tags, 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 = (link, page, label) => link.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 = tags.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(tags.link, item.toString(), label);
25
- }
26
- else if (item === "gap") {
27
- filled = tags.gap;
28
- }
29
- else { // active page
30
- filled = fillIn(tags.active, item, label);
31
- }
32
- html += (typeof trimParam === "string" && item == 1) ? trim(filled, trimParam) : filled;
33
- }
34
- html += tags.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 = (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
81
- // Public interface
82
- return {
83
- version: "7.0.11",
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\n%s", el, err);
107
- }
108
- }
109
- }
110
- };
111
- })();
112
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFneS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInBhZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQWtCQSxNQUFNLElBQUksR0FBRyxDQUFDLEdBQUcsRUFBRTtJQUNmLDRDQUE0QztJQUM1QyxNQUFNLFdBQVcsR0FBRyxJQUFJLGNBQWMsQ0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0IGxhYmVsID0gbGFiZWxzW2ldO1xuICAgICAgICAgICAgICAgIGxldCBmaWxsZWQ7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBpdGVtID09PSBcIm51bWJlclwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpbGxlZCA9IGZpbGxJbih0YWdzLmxpbmssIGl0ZW0udG9TdHJpbmcoKSwgbGFiZWwpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbSA9PT0gXCJnYXBcIikge1xuICAgICAgICAgICAgICAgICAgICBmaWxsZWQgPSB0YWdzLmdhcDtcbiAgICAgICAgICAgICAgICB9IGVsc2UgeyAvLyBhY3RpdmUgcGFnZVxuICAgICAgICAgICAgICAgICAgICBmaWxsZWQgPSBmaWxsSW4odGFncy5hY3RpdmUsIGl0ZW0sIGxhYmVsKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaHRtbCArPSAodHlwZW9mIHRyaW1QYXJhbSA9PT0gXCJzdHJpbmdcIiAmJiBpdGVtID09IDEpID8gdHJpbShmaWxsZWQsIHRyaW1QYXJhbSkgOiBmaWxsZWQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBodG1sICs9IHRhZ3MuYWZ0ZXI7ICAgLy8gZXNsaW50LWRpc2FibGUtbGluZSBhbGlnbi1hc3NpZ25tZW50cy9hbGlnbi1hc3NpZ25tZW50c1xuICAgICAgICAgICAgZWwuaW5uZXJIVE1MID0gXCJcIjtcbiAgICAgICAgICAgIGVsLmluc2VydEFkamFjZW50SFRNTChcImFmdGVyYmVnaW5cIiwgaHRtbCk7XG4gICAgICAgICAgICBsYXN0V2lkdGggPSB3aWR0aDtcbiAgICAgICAgfSkoKTtcbiAgICAgICAgaWYgKGVsLmNsYXNzTGlzdC5jb250YWlucyhcInBhZ3ktcmpzXCIpKSB7IHJqc09ic2VydmVyLm9ic2VydmUoY29udGFpbmVyKSB9XG4gICAgfTtcblxuICAgIC8vIEluaXQgdGh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XRcIikgYXMgSFRNTElucHV0RWxlbWVudDtcbiAgICAgICAgY29uc3QgaW5pdGlhbCA9IGlucHV0LnZhbHVlO1xuICAgICAgICBjb25zdCBhY3Rpb24gPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoaW5wdXQudmFsdWUgPT09IGluaXRpYWwpIHsgcmV0dXJuIH0gIC8vIG5vdCBjaGFuZ2VkXG4gICAgICAgICAgICBjb25zdCBbbWluLCB2YWwsIG1heF0gPSBbaW5wdXQubWluLCBpbnB1dC52YWx1ZSwgaW5wdXQubWF4XS5tYXAobiA9PiBwYXJzZUludChuKSB8fCAwKTtcbiAgICAgICAgICAgIGlmICh2YWwgPCBtaW4gfHwgdmFsID4gbWF4KSB7ICAvLyByZXNldCBpbnZhbGlkL291dC1vZi1yYW5nZVxuICAgICAgICAgICAgICAgIGlucHV0LnZhbHVlID0gaW5pdGlhbDtcbiAgICAgICAgICAgICAgICBpbnB1dC5zZWxlY3QoKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgW3BhZ2UsIHVybF0gPSBnZXRWYXJzKGlucHV0LnZhbHVlKTsgICAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIHByZWZlci1jb25zdFxuICAgICAgICAgICAgaWYgKHR5cGVvZiB0cmltUGFyYW0gPT09IFwic3RyaW5nXCIgJiYgcGFnZSA9PT0gXCIxXCIpIHsgdXJsID0gdHJpbSh1cmwsIHRyaW1QYXJhbSkgfVxuICAgICAgICAgICAgd2luZG93LmxvY2F0aW9uLmhyZWYgPSB1cmw7XG4gICAgICAgIH07XG4gICAgICAgIFtcImNoYW5nZVwiLCBcImZvY3VzXCJdLmZvckVhY2goZSA9PiBpbnB1dC5hZGRFdmVudExpc3RlbmVyKGUsIGlucHV0LnNlbGVjdCkpOyAgICAgICAgLy8gYXV0by1zZWxlY3RcbiAgICAgICAgaW5wdXQuYWRkRXZlbnRMaXN0ZW5lcihcImZ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AgICAgICAgICBjb25zdCB1aW50OGFycmF5ID0gVWludDhBcnJheS5mcm9tKGF0b2IoZWwuZ2V0QXR0cmlidXRlKFwiZGF0YS1wYWd5XCIpIGFzIHN0cmluZyksIGMgPT4gYy5jaGFyQ29kZUF0KDApKTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgW2tleXdvcmQsIC4uLmFyZ3NdID0gSlNPTi5wYXJzZSgobmV3IFRleHREZWNvZGVyKCkpLmRlY29kZSh1aW50OGFycmF5KSk7IC8vIGJhc2U2NC11dGY4IC0+IEpTT04gLT4gQXJyYXlcbiAgICAgICAgICAgICAgICAgICAgaWYgKGtleXdvcmQgPT09IFwibmF2XCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGluaXROYXYoZWwgYXMgTmF2RWxlbWVudCwgYXJncyBhcyBOYXZBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChrZXl3b3JkID09PSBcImNvbWJvXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGluaXRDb21ibyhlbCwgYXJncyBhcyBDb21ib0FyZ3MpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGtleXdvcmQgPT09IFwic2VsZWN0b3JcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdFNlbGVjdG9yKGVsLCBhcmdzIGFzIFNlbGVjdG9yQXJncyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJTa2lwcGVkIFBhZ3kuaW5pdCgpIGZvcjogJW9cXG5Vbmtub3duIGtleXdvcmQgJyVzJ1wiLCBlbCwga2V5d29yZCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHsgY29uc29sZS53YXJuKFwiU2tpcHBlZCBQYWd5LmluaXQoKSBmb3I6ICVvXFxuJXNcIiwgZWwsIGVycikgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbn0pKCk7XG4iXX0=
@@ -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, [tags, 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 = (link, page, label) => link.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 = tags.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(tags.link, item.toString(), label);
24
- }
25
- else if (item === "gap") {
26
- filled = tags.gap;
27
- }
28
- else { // active page
29
- filled = fillIn(tags.active, item, label);
30
- }
31
- html += (typeof trimParam === "string" && item == 1) ? trim(filled, trimParam) : filled;
32
- }
33
- html += tags.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 = (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
80
- // Public interface
81
- return {
82
- version: "7.0.11",
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.link,n.toString(),a):"gap"===n?r.gap:s(r.active,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:"7.0.11",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}();
data/lib/locales/ca.yml DELETED
@@ -1,23 +0,0 @@
1
- # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
2
- ca:
3
- pagy:
4
- aria_label:
5
- # please add a comment in the https://github.com/ddnexus/pagy/issues/581
6
- # posting the translation of the following "Page"/"Pages" with the plurals for this locale
7
- nav: "Pages"
8
- # one: ""
9
- # other: ""
10
- prev: "Anterior"
11
- next: "Següent"
12
- prev: "&lt;"
13
- next: "&gt;"
14
- gap: "&hellip;"
15
- item_name:
16
- one: "element"
17
- other: "elements"
18
- info:
19
- no_items: "No s'ha trobat cap resultat"
20
- single_page: "Mostrant <b>%{count}</b> %{item_name}"
21
- multiple_pages: "Mostrant %{item_name} <b>%{from}-%{to}</b> de <b>%{count}</b> en total"
22
- combo_nav_js: "<label>Pàgina %{page_input} de %{pages}</label>"
23
- items_selector_js: "<label>Mostra %{items_input} %{item_name} per pàgina</label>"
data/lib/locales/ckb.yml DELETED
@@ -1,18 +0,0 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
2
-
3
- ckb:
4
- pagy:
5
- item_name: "بابەت"
6
- aria_label:
7
- nav: "پەڕەکان"
8
- prev: "پاش"
9
- next: "پێش"
10
- prev: "&lt;"
11
- next: "&gt;"
12
- gap: "&hellip;"
13
- info:
14
- no_items: "هیچ %{item_name}ێک نەدۆزرایەوە"
15
- single_page: "پیشاندانی <b>%{count}</b> %{item_name}"
16
- multiple_pages: "پشاندانی %{item_name}ی <b>%{from}-%{to}</b> لە کۆی <b>%{count}</b> بە گشتی"
17
- combo_nav_js: "<label>پەڕی %{page_input} لە %{pages}</label>"
18
- items_selector_js: "<label>نیشاندانی %{items_input} %{item_name} لە هەر پەڕێک</label>"
data/lib/locales/da.yml DELETED
@@ -1,23 +0,0 @@
1
- # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
2
- da:
3
- pagy:
4
- aria_label:
5
- # please add a comment in the https://github.com/ddnexus/pagy/issues/583
6
- # posting the translation of the following "Page"/"Pages" with the plurals for this locale
7
- nav: "Pages"
8
- # one: ""
9
- # other: ""
10
- prev: "Forrige"
11
- next: "Næste"
12
- prev: "&lt;"
13
- next: "&gt;"
14
- gap: "&hellip;"
15
- item_name:
16
- one: "resultat"
17
- other: "resultater"
18
- info:
19
- no_items: "Ingen %{item_name} fundet"
20
- single_page: "Viser <b>%{count}</b> %{item_name}"
21
- multiple_pages: "Viser %{item_name} <b>%{from}-%{to}</b> af <b>%{count}</b> totalt"
22
- combo_nav_js: "<label>Side %{page_input} af %{pages}</label>"
23
- items_selector_js: "<label>Antal %{items_input} %{item_name} per side</label>"
data/lib/locales/ko.yml DELETED
@@ -1,19 +0,0 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
2
- ko:
3
- pagy:
4
- aria_label:
5
- # please add a comment in the https://github.com/ddnexus/pagy/issues/592
6
- # posting the translation of the following "Page"/"Pages" with the plurals for this locale
7
- nav: "Pages"
8
- prev: "이전"
9
- next: "다음"
10
- prev: "&lt;"
11
- next: "&gt;"
12
- gap: "&hellip;"
13
- item_name: "항목"
14
- info:
15
- no_items: "%{item_name} 없음"
16
- single_page: "<b>%{count}</b>개의 %{item_name} 표시됨"
17
- multiple_pages: "총 <b>%{count}</b>개의 %{item_name} 중 <b>%{from}-%{to}</b>"
18
- combo_nav_js: "<label>총 %{pages} 중 %{page_input} 페이지</label>"
19
- items_selector_js: "<label>페이지 당 %{items_input}개 표시%</label>"
data/lib/locales/ru.yml DELETED
@@ -1,27 +0,0 @@
1
- # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
2
- ru:
3
- pagy:
4
- aria_label:
5
- # please add a comment in the https://github.com/ddnexus/pagy/issues/599
6
- # posting the translation of the following "Page"/"Pages" with the plurals for this locale
7
- nav: "Pages"
8
- # one: ""
9
- # few: ""
10
- # many: ""
11
- # other: ""
12
- prev: "Назад"
13
- next: "Вперёд"
14
- prev: "&lt;"
15
- next: "&gt;"
16
- gap: "&hellip;"
17
- item_name:
18
- one: "запись"
19
- few: "записи"
20
- many: "записей"
21
- other: "записей"
22
- info:
23
- no_items: "Пока %{item_name} нет"
24
- single_page: "<b>%{count}</b> %{item_name}"
25
- multiple_pages: "Всего <b>%{count}</b> %{item_name}, показаны с <b>%{from}</b> по <b>%{to}</b>"
26
- combo_nav_js: "<label>Страница %{page_input} из %{pages}</label>"
27
- items_selector_js: "<label>Показать %{items_input} %{item_name} на странице</label>"
data/lib/locales/vi.yml DELETED
@@ -1,17 +0,0 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
2
- vi:
3
- pagy:
4
- aria_label:
5
- nav: "Trang"
6
- prev: "Trang trước"
7
- next: "Trang sau"
8
- prev: "&lt;"
9
- next: "&gt;"
10
- gap: "&hellip;"
11
- item_name: "kết quả"
12
- info:
13
- no_items: "Không tìm thấy %{item_name} nào"
14
- single_page: "<b>%{count}</b> %{item_name}"
15
- multiple_pages: "Đang hiển thị <b>%{from}-%{to}</b> trong tổng số <b>%{count} %{item_name}</b>"
16
- combo_nav_js: "<label>Trang %{page_input} trên %{pages}</label>"
17
- items_selector_js: "<label>Hiển thị %{items_input} %{item_name} mỗi trang</label>"
@@ -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,51 +0,0 @@
1
- # See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/navs
2
- # frozen_string_literal: true
3
-
4
- require 'pagy/extras/frontend_helpers'
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 NavsExtra
10
- # Javascript pagination: it returns a nav and a JSON tag used by the pagy.js file
11
- def pagy_nav_js(pagy, pagy_id: nil, link_extra: '',
12
- nav_aria_label: nil, nav_i18n_key: nil, **vars)
13
- sequels = pagy.sequels(**vars)
14
- p_id = %( id="#{pagy_id}") if pagy_id
15
- link = pagy_link_proc(pagy, link_extra:)
16
- tags = { 'before' => prev_html(pagy, link),
17
- 'link' => %(<span class="page">#{link.call(PAGE_TOKEN, LABEL_TOKEN)}</span>),
18
- 'active' => %(<span class="page active">) +
19
- %(<a role="link" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</a></span>),
20
- 'gap' => %(<span class="page gap">#{pagy_t 'pagy.gap'}</span>),
21
- 'after' => next_html(pagy, link) }
22
-
23
- %(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy pagy-nav-js pagination" #{
24
- nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
25
- pagy_data(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))
26
- }></nav>)
27
- end
28
-
29
- # Javascript combo pagination: it returns a nav and a JSON tag used by the pagy.js file
30
- def pagy_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
31
- nav_aria_label: nil, nav_i18n_key: nil)
32
- p_id = %( id="#{pagy_id}") if pagy_id
33
- link = pagy_link_proc(pagy, link_extra:)
34
- p_page = pagy.page
35
- p_pages = pagy.pages
36
- input = %(<input name="page" type="number" min="1" max="#{p_pages}" value="#{p_page}" ) +
37
- %(style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem;" aria-current="page">)
38
-
39
- %(<nav#{p_id} class="pagy pagy-combo-nav-js pagination" #{
40
- nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
41
- pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))}>#{
42
- prev_html(pagy, link)
43
- }<span class="pagy-combo-input">#{
44
- pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages)
45
- }</span>#{
46
- next_html(pagy, link)
47
- }</nav>)
48
- end
49
- end
50
- Frontend.prepend NavsExtra
51
- end
@@ -1,40 +0,0 @@
1
- # See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/support
2
- # frozen_string_literal: true
3
-
4
- class Pagy # :nodoc:
5
- # Extra support for features like: incremental, auto-incremental and infinite pagination
6
- module SupportExtra
7
- # Return the previous page URL string or nil
8
- def pagy_prev_url(pagy, absolute: false)
9
- pagy_url_for(pagy, pagy.prev, absolute:) if pagy.prev
10
- end
11
-
12
- # Return the next page URL string or nil
13
- def pagy_next_url(pagy, absolute: false)
14
- pagy_url_for(pagy, pagy.next, absolute:) if pagy.next
15
- end
16
-
17
- # Return the HTML string for the enabled/disabled previous page link
18
- def pagy_prev_html(pagy, text: pagy_t('pagy.prev'), link_extra: '')
19
- link = pagy_link_proc(pagy, link_extra:)
20
- prev_html(pagy, link, text:)
21
- end
22
-
23
- # Return the HTML string for the enabled/disabled next page link
24
- def pagy_next_html(pagy, text: pagy_t('pagy.next'), link_extra: '')
25
- link = pagy_link_proc(pagy, link_extra:)
26
- next_html(pagy, link, text:)
27
- end
28
-
29
- # Conditionally return the HTML link tag string for the previous page
30
- def pagy_prev_link_tag(pagy, absolute: false)
31
- %(<link href="#{pagy_url_for(pagy, pagy.prev, absolute:)}" rel="prev"/>) if pagy.prev
32
- end
33
-
34
- # Conditionally return the HTML link tag string for the next page
35
- def pagy_next_link_tag(pagy, absolute: false)
36
- %(<link href="#{pagy_url_for(pagy, pagy.next, absolute:)}" rel="next"/>) if pagy.next
37
- end
38
- end
39
- Frontend.prepend SupportExtra
40
- end
@@ -1,24 +0,0 @@
1
- .pagy {
2
- @apply flex space-x-1 font-semibold text-sm text-gray-500;
3
- .page {
4
- a {
5
- @apply block rounded-lg px-3 py-1 bg-gray-200;
6
- &:hover {
7
- @apply bg-gray-300;
8
- }
9
- }
10
- &.active a {
11
- @apply text-white bg-gray-400 cursor-default;
12
- }
13
- &.disabled a {
14
- @apply text-gray-300 bg-gray-100 cursor-default;
15
- }
16
- &.gap { } /* if you need to customize it */
17
- }
18
- .pagy-combo-input, &.pagy-items-selector-js {
19
- @apply inline-block whitespace-nowrap bg-gray-200 rounded-lg px-3 py-0.5;
20
- input {
21
- @apply bg-gray-100 border-none rounded-md;
22
- }
23
- }
24
- }