pagy 8.4.0 → 9.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/apps/calendar.ru +682 -2137
  3. data/apps/demo.ru +17 -13
  4. data/apps/keyset_ar.ru +236 -0
  5. data/apps/keyset_s.ru +238 -0
  6. data/apps/rails.ru +25 -15
  7. data/apps/repro.ru +17 -14
  8. data/bin/pagy +17 -12
  9. data/config/pagy.rb +37 -34
  10. data/javascripts/pagy.min.js +4 -0
  11. data/javascripts/pagy.min.js.map +10 -0
  12. data/javascripts/pagy.mjs +100 -0
  13. data/lib/optimist.rb +1 -1
  14. data/lib/pagy/b64.rb +33 -0
  15. data/lib/pagy/backend.rb +19 -19
  16. data/lib/pagy/calendar/day.rb +4 -3
  17. data/lib/pagy/calendar/month.rb +4 -3
  18. data/lib/pagy/calendar/quarter.rb +4 -3
  19. data/lib/pagy/calendar/unit.rb +103 -0
  20. data/lib/pagy/calendar/week.rb +3 -3
  21. data/lib/pagy/calendar/year.rb +4 -3
  22. data/lib/pagy/calendar.rb +54 -97
  23. data/lib/pagy/countless.rb +15 -16
  24. data/lib/pagy/extras/arel.rb +3 -11
  25. data/lib/pagy/extras/array.rb +5 -10
  26. data/lib/pagy/extras/bootstrap.rb +5 -5
  27. data/lib/pagy/extras/bulma.rb +10 -7
  28. data/lib/pagy/extras/calendar.rb +34 -5
  29. data/lib/pagy/extras/countless.rb +8 -13
  30. data/lib/pagy/extras/elasticsearch_rails.rb +16 -25
  31. data/lib/pagy/extras/gearbox.rb +26 -26
  32. data/lib/pagy/extras/headers.rb +25 -24
  33. data/lib/pagy/extras/i18n.rb +1 -1
  34. data/lib/pagy/extras/js_tools.rb +10 -10
  35. data/lib/pagy/extras/jsonapi.rb +26 -19
  36. data/lib/pagy/extras/keyset.rb +30 -0
  37. data/lib/pagy/extras/limit.rb +63 -0
  38. data/lib/pagy/extras/meilisearch.rb +9 -17
  39. data/lib/pagy/extras/metadata.rb +6 -2
  40. data/lib/pagy/extras/overflow.rb +11 -10
  41. data/lib/pagy/extras/pagy.rb +16 -16
  42. data/lib/pagy/extras/searchkick.rb +9 -17
  43. data/lib/pagy/extras/size.rb +40 -0
  44. data/lib/pagy/extras/standalone.rb +6 -6
  45. data/lib/pagy/extras/trim.rb +3 -3
  46. data/lib/pagy/frontend.rb +37 -35
  47. data/lib/pagy/i18n.rb +2 -2
  48. data/lib/pagy/keyset/active_record.rb +38 -0
  49. data/lib/pagy/keyset/sequel.rb +51 -0
  50. data/lib/pagy/keyset.rb +98 -0
  51. data/lib/pagy/shared_methods.rb +27 -0
  52. data/lib/pagy/url_helpers.rb +5 -5
  53. data/lib/pagy.rb +70 -94
  54. data/locales/ar.yml +9 -10
  55. data/locales/be.yml +2 -2
  56. data/locales/bg.yml +2 -2
  57. data/locales/bs.yml +2 -2
  58. data/locales/ca.yml +5 -7
  59. data/locales/ckb.yml +2 -2
  60. data/locales/cs.yml +2 -2
  61. data/locales/da.yml +2 -2
  62. data/locales/de.yml +2 -2
  63. data/locales/en.yml +2 -2
  64. data/locales/es.yml +2 -2
  65. data/locales/fr.yml +2 -2
  66. data/locales/hr.yml +2 -2
  67. data/locales/id.yml +2 -2
  68. data/locales/it.yml +2 -2
  69. data/locales/ja.yml +2 -2
  70. data/locales/km.yml +2 -2
  71. data/locales/ko.yml +2 -2
  72. data/locales/nb.yml +2 -2
  73. data/locales/nl.yml +2 -2
  74. data/locales/nn.yml +2 -2
  75. data/locales/pl.yml +2 -2
  76. data/locales/pt-BR.yml +2 -2
  77. data/locales/pt.yml +2 -2
  78. data/locales/ru.yml +2 -2
  79. data/locales/sr.yml +2 -2
  80. data/locales/sv-SE.yml +2 -2
  81. data/locales/sv.yml +2 -2
  82. data/locales/sw.yml +2 -2
  83. data/locales/ta.yml +2 -2
  84. data/locales/tr.yml +2 -2
  85. data/locales/uk.yml +2 -2
  86. data/locales/vi.yml +2 -2
  87. data/locales/zh-CN.yml +2 -2
  88. data/locales/zh-HK.yml +2 -2
  89. data/locales/zh-TW.yml +2 -2
  90. metadata +19 -19
  91. data/javascripts/pagy-dev.js +0 -114
  92. data/javascripts/pagy-module.js +0 -113
  93. data/javascripts/pagy.js +0 -1
  94. data/lib/pagy/calendar/helper.rb +0 -65
  95. data/lib/pagy/extras/foundation.rb +0 -95
  96. data/lib/pagy/extras/items.rb +0 -64
  97. data/lib/pagy/extras/materialize.rb +0 -100
  98. data/lib/pagy/extras/semantic.rb +0 -94
  99. data/lib/pagy/extras/uikit.rb +0 -98
  100. /data/javascripts/{pagy-module.d.ts → pagy.d.ts} +0 -0
data/locales/uk.yml CHANGED
@@ -1,4 +1,4 @@
1
- # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
2
2
  uk:
3
3
  pagy:
4
4
  aria_label:
@@ -22,4 +22,4 @@ uk:
22
22
  single_page: "%{count} %{item_name}"
23
23
  multiple_pages: "Загалом %{count} %{item_name}, показані з %{from} по %{to}"
24
24
  combo_nav_js: "Сторінка %{page_input} з %{pages}"
25
- items_selector_js: "Показати %{items_input} %{item_name} на сторінці"
25
+ limit_selector_js: "Показати %{limit_input} %{item_name} на сторінці"
data/locales/vi.yml CHANGED
@@ -1,4 +1,4 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
2
2
  vi:
3
3
  pagy:
4
4
  aria_label:
@@ -14,4 +14,4 @@ vi:
14
14
  single_page: "%{count} %{item_name}"
15
15
  multiple_pages: "Đang hiển thị %{from}-%{to} trong tổng số %{count} %{item_name}"
16
16
  combo_nav_js: "Trang %{page_input} trên %{pages}"
17
- items_selector_js: "Hiển thị %{items_input} %{item_name} mỗi trang"
17
+ limit_selector_js: "Hiển thị %{limit_input} %{item_name} mỗi trang"
data/locales/zh-CN.yml CHANGED
@@ -1,4 +1,4 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
2
2
  zh-CN:
3
3
  pagy:
4
4
  aria_label:
@@ -16,4 +16,4 @@ zh-CN:
16
16
  single_page: "显示%{count} 项%{item_name}"
17
17
  multiple_pages: "共 %{count} 项%{item_name},显示 %{from}-%{to}"
18
18
  combo_nav_js: "第 %{page_input} / %{pages} 页"
19
- items_selector_js: "每页显示 %{items_input} 条%"
19
+ limit_selector_js: "每页显示 %{limit_input} 条%"
data/locales/zh-HK.yml CHANGED
@@ -1,4 +1,4 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
2
2
  zh-HK:
3
3
  pagy:
4
4
  aria_label:
@@ -16,4 +16,4 @@ zh-HK:
16
16
  single_page: "顯示 %{count} %{item_name}"
17
17
  multiple_pages: "共 %{count} %{item_name},顯示 %{from}-%{to}"
18
18
  combo_nav_js: "第 %{page_input} / %{pages} 頁"
19
- items_selector_js: "每頁顯示 %{items_input} 記錄"
19
+ limit_selector_js: "每頁顯示 %{limit_input} 記錄"
data/locales/zh-TW.yml CHANGED
@@ -1,4 +1,4 @@
1
- # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
2
2
  zh-TW:
3
3
  pagy:
4
4
  aria_label:
@@ -16,4 +16,4 @@ zh-TW:
16
16
  single_page: "顯示 %{count} 項%{item_name}"
17
17
  multiple_pages: "共 %{count} 項%{item_name},顯示 %{from}-%{to}"
18
18
  combo_nav_js: "第 %{page_input} / %{pages} 頁"
19
- items_selector_js: "每頁顯示 %{items_input} 項%{item_name}"
19
+ limit_selector_js: "每頁顯示 %{limit_input} 項%{item_name}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.4.0
4
+ version: 9.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-06 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
14
  email:
@@ -21,22 +21,25 @@ files:
21
21
  - LICENSE.txt
22
22
  - apps/calendar.ru
23
23
  - apps/demo.ru
24
+ - apps/keyset_ar.ru
25
+ - apps/keyset_s.ru
24
26
  - apps/rails.ru
25
27
  - apps/repro.ru
26
28
  - bin/pagy
27
29
  - config/pagy.rb
28
- - javascripts/pagy-dev.js
29
- - javascripts/pagy-module.d.ts
30
- - javascripts/pagy-module.js
31
- - javascripts/pagy.js
30
+ - javascripts/pagy.d.ts
31
+ - javascripts/pagy.min.js
32
+ - javascripts/pagy.min.js.map
33
+ - javascripts/pagy.mjs
32
34
  - lib/optimist.rb
33
35
  - lib/pagy.rb
36
+ - lib/pagy/b64.rb
34
37
  - lib/pagy/backend.rb
35
38
  - lib/pagy/calendar.rb
36
39
  - lib/pagy/calendar/day.rb
37
- - lib/pagy/calendar/helper.rb
38
40
  - lib/pagy/calendar/month.rb
39
41
  - lib/pagy/calendar/quarter.rb
42
+ - lib/pagy/calendar/unit.rb
40
43
  - lib/pagy/calendar/week.rb
41
44
  - lib/pagy/calendar/year.rb
42
45
  - lib/pagy/console.rb
@@ -49,25 +52,27 @@ files:
49
52
  - lib/pagy/extras/calendar.rb
50
53
  - lib/pagy/extras/countless.rb
51
54
  - lib/pagy/extras/elasticsearch_rails.rb
52
- - lib/pagy/extras/foundation.rb
53
55
  - lib/pagy/extras/gearbox.rb
54
56
  - lib/pagy/extras/headers.rb
55
57
  - lib/pagy/extras/i18n.rb
56
- - lib/pagy/extras/items.rb
57
58
  - lib/pagy/extras/js_tools.rb
58
59
  - lib/pagy/extras/jsonapi.rb
59
- - lib/pagy/extras/materialize.rb
60
+ - lib/pagy/extras/keyset.rb
61
+ - lib/pagy/extras/limit.rb
60
62
  - lib/pagy/extras/meilisearch.rb
61
63
  - lib/pagy/extras/metadata.rb
62
64
  - lib/pagy/extras/overflow.rb
63
65
  - lib/pagy/extras/pagy.rb
64
66
  - lib/pagy/extras/searchkick.rb
65
- - lib/pagy/extras/semantic.rb
67
+ - lib/pagy/extras/size.rb
66
68
  - lib/pagy/extras/standalone.rb
67
69
  - lib/pagy/extras/trim.rb
68
- - lib/pagy/extras/uikit.rb
69
70
  - lib/pagy/frontend.rb
70
71
  - lib/pagy/i18n.rb
72
+ - lib/pagy/keyset.rb
73
+ - lib/pagy/keyset/active_record.rb
74
+ - lib/pagy/keyset/sequel.rb
75
+ - lib/pagy/shared_methods.rb
71
76
  - lib/pagy/url_helpers.rb
72
77
  - locales/ar.yml
73
78
  - locales/be.yml
@@ -118,12 +123,7 @@ metadata:
118
123
  bug_tracker_uri: https://github.com/ddnexus/pagy/issues
119
124
  changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
120
125
  support: https://github.com/ddnexus/pagy/discussions/categories/q-a
121
- post_install_message: |
122
- *********************** PAGY WARNING! ***********************
123
- The foundation, materialize, semantic and uikit CSS extras
124
- have been discontinued and will be removed in v9
125
- https://github.com/ddnexus/pagy/discussions/672
126
- *************************************************************
126
+ post_install_message:
127
127
  rdoc_options: []
128
128
  require_paths:
129
129
  - lib
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.5.3
141
+ rubygems_version: 3.5.11
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: The best pagination ruby gem
@@ -1,114 +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 link = el.querySelector("a");
57
- const initial = input.value;
58
- const action = function () {
59
- if (input.value === initial) {
60
- return;
61
- } // not changed
62
- const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);
63
- if (val < min || val > max) { // reset invalid/out-of-range
64
- input.value = initial;
65
- input.select();
66
- return;
67
- }
68
- let [page, url] = getVars(input.value); // eslint-disable-line prefer-const
69
- if (typeof trimParam === "string" && page === "1") {
70
- url = trim(url, trimParam);
71
- }
72
- link.href = url;
73
- link.click();
74
- };
75
- ["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
76
- input.addEventListener("focusout", action); // trigger action
77
- input.addEventListener("keypress", e => { if (e.key === "Enter") {
78
- action();
79
- } }); // trigger action
80
- };
81
- // Trim the ${page-param}=1 params in links
82
- const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
83
- // Public interface
84
- return {
85
- version: "8.4.0",
86
- // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
87
- init(arg) {
88
- const target = arg instanceof Element ? arg : document;
89
- const elements = target.querySelectorAll("[data-pagy]");
90
- for (const el of elements) {
91
- try {
92
- const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
93
- const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)); // base64-utf8 -> JSON -> Array
94
- if (keyword === "nav") {
95
- initNav(el, args);
96
- }
97
- else if (keyword === "combo") {
98
- initCombo(el, args);
99
- }
100
- else if (keyword === "selector") {
101
- initSelector(el, args);
102
- }
103
- else {
104
- console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
105
- }
106
- }
107
- catch (err) {
108
- console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
109
- }
110
- }
111
- }
112
- };
113
- })();
114
- //# sourceMappingURL=data:application/json;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8gYWxyZWFkeSB0cmltbWVkIGluIGh0bWxcbiAgICAgICAgICAgIGNvbnN0IHNlcmllcyA9IHNlcXVlbHNbd2lkdGgudG9TdHJpbmcoKV07XG4gICAgICAgICAgICBjb25zdCBsYWJlbHMgPSBsYWJlbFNlcXVlbHM/Llt3aWR0aC50b1N0cmluZygpXSA/PyBzZXJpZXMubWFwKGwgPT4gbC50b1N0cmluZygpKTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgaSBpbiBzZXJpZXMpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gc2VyaWVzW2ldO1xuICAgICAgICAgICAgICAgIGNvbnN0IGxhYmVsID0gbGFiZWxzW2ldO1xuICAgICAgICAgICAgICAgIGxldCBmaWxsZWQ7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBpdGVtID09PSBcIm51bWJlclwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpbGxlZCA9IGZpbGxJbih0b2tlbnMuYSwgaXRlbS50b1N0cmluZygpLCBsYWJlbCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpdGVtID09PSBcImdhcFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpbGxlZCA9IHRva2Vucy5nYXA7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHsgLy8gYWN0aXZlIHBhZ2VcbiAgICAgICAgICAgICAgICAgICAgZmlsbGVkID0gZmlsbEluKHRva2Vucy5jdXJyZW50LCBpdGVtLCBsYWJlbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGh0bWwgKz0gKHR5cGVvZiB0cmltUGFyYW0gPT09IFwic3RyaW5nXCIgJiYgaXRlbSA9PSAxKSA/IHRyaW0oZmlsbGVkLCB0cmltUGFyYW0pIDogZmlsbGVkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaHRtbCArPSB0b2tlbnMuYWZ0ZXI7ICAgLy8gZXNsaW50LWRpc2FibGUtbGluZSBhbGlnbi1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IGVsZW1lbnRzIHdpdGggYSBcImRhdGEtcGFneVwiIGF0dHJpYnV0ZSBhbmQgY2FsbCB0aGVpciBpbml0IGZ1bmN0aW9ucyB3aXRoIHRoZSBkZWNvZGVkIGFyZ3NcbiAgICAgICAgaW5pdChhcmc/OkVsZW1lbnQgfCBuZXZlcikge1xuICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYXJnIGluc3RhbmNlb2YgRWxlbWVudCA/IGFyZyA6IGRvY3VtZW50O1xuICAgICAgICAgICAgY29uc3QgZWxlbWVudHMgPSB0YXJnZXQucXVlcnlTZWxlY3RvckFsbChcIltkYXRhLXBhZ3ldXCIpO1xuICAgICAgICAgICAgZm9yIChjb25zdCBlbCBvZiBlbGVtZW50cykge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHVpbnQ4YXJyYXkgPSBVaW50OEFycmF5LmZyb20oYXRvYihlbC5nZXRBdHRyaWJ1dGUoXCJkYXRhLXBhZ3lcIikgYXMgc3RyaW5nKSwgYyA9PiBjLmNoYXJDb2RlQXQoMCkpO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBba2V5d29yZCwgLi4uYXJnc10gPSBKU09OLnBhcnNlKChuZXcgVGV4dERlY29kZXIoKSkuZGVjb2RlKHVpbnQ4YXJyYXkpKTsgLy8gYmFzZTY0LXV0ZjggLT4gSlNPTiAtPiBBcnJheVxuICAgICAgICAgICAgICAgICAgICBpZiAoa2V5d29yZCA9PT0gXCJuYXZcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdE5hdihlbCBhcyBOYXZFbGVtZW50LCBhcmdzIGFzIE5hdkFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGtleXdvcmQgPT09IFwiY29tYm9cIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdENvbWJvKGVsLCBhcmdzIGFzIENvbWJvQXJncyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoa2V5d29yZCA9PT0gXCJzZWxlY3RvclwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbml0U2VsZWN0b3IoZWwsIGFyZ3MgYXMgU2VsZWN0b3JBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIlNraXBwZWQgUGFneS5pbml0KCkgZm9yOiAlb1xcblVua25vd24ga2V5d29yZCAnJXMnXCIsIGVsLCBrZXl3b3JkKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgeyBjb25zb2xlLndhcm4oXCJTa2lwcGVkIFBhZ3kuaW5pdCgpIGZvcjogJW9cXG4lc1wiLCBlbCwgZXJyKSB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufSkoKTtcbiJdfQ==
@@ -1,113 +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 link = el.querySelector("a");
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
- link.href = url;
72
- link.click();
73
- };
74
- ["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
75
- input.addEventListener("focusout", action); // trigger action
76
- input.addEventListener("keypress", e => { if (e.key === "Enter") {
77
- action();
78
- } }); // trigger action
79
- };
80
- // Trim the ${page-param}=1 params in links
81
- const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
82
- // Public interface
83
- return {
84
- version: "8.4.0",
85
- // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
86
- init(arg) {
87
- const target = arg instanceof Element ? arg : document;
88
- const elements = target.querySelectorAll("[data-pagy]");
89
- for (const el of elements) {
90
- try {
91
- const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
92
- const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)); // base64-utf8 -> JSON -> Array
93
- if (keyword === "nav") {
94
- initNav(el, args);
95
- }
96
- else if (keyword === "combo") {
97
- initCombo(el, args);
98
- }
99
- else if (keyword === "selector") {
100
- initSelector(el, args);
101
- }
102
- else {
103
- console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
104
- }
105
- }
106
- catch (err) {
107
- console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
108
- }
109
- }
110
- }
111
- };
112
- })();
113
- export default Pagy;
data/javascripts/pagy.js DELETED
@@ -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,a,n,l])=>{let i=t.parentElement??t,c=Object.keys(a).map(e=>parseInt(e)).sort((e,t)=>t-e),p=-1,s=(e,t,r)=>e.replace(/__pagy_page__/g,t).replace(/__pagy_label__/g,r);(t.pagyRender=function(){let e=c.find(e=>e<i.clientWidth)||0;if(e===p)return;let g=r.before,y=a[e.toString()],f=n?.[e.toString()]??y.map(e=>e.toString());for(let e in y){let t;let a=y[e],n=f[e];t="number"==typeof a?s(r.a,a.toString(),n):"gap"===a?r.gap:s(r.current,a,n),g+="string"==typeof l&&1==a?o(t,l):t}g+=r.after,t.innerHTML="",t.insertAdjacentHTML("afterbegin",g),p=e})(),t.classList.contains("pagy-rjs")&&e.observe(i)},r=(e,[t,r])=>n(e,e=>[e,t.replace(/__pagy_page__/,e)],r),a=(e,[t,r,a])=>{n(e,e=>{let a=Math.max(Math.ceil(t/parseInt(e)),1).toString(),n=r.replace(/__pagy_page__/,a).replace(/__pagy_items__/,e);return[a,n]},a)},n=(e,t,r)=>{let a=e.querySelector("input"),n=e.querySelector("a"),l=a.value,i=function(){if(a.value===l)return;let[e,i,c]=[a.min,a.value,a.max].map(e=>parseInt(e)||0);if(i<e||i>c){a.value=l,a.select();return}let[p,s]=t(a.value);"string"==typeof r&&"1"===p&&(s=o(s,r)),n.href=s,n.click()};["change","focus"].forEach(e=>a.addEventListener(e,a.select)),a.addEventListener("focusout",i),a.addEventListener("keypress",e=>{"Enter"===e.key&&i()})},o=(e,t)=>e.replace(RegExp(`[?&]${t}=1\\b(?!&)|\\b${t}=1&`),"");return{version:"8.4.0",init(e){for(let n of(e instanceof Element?e:document).querySelectorAll("[data-pagy]"))try{let e=Uint8Array.from(atob(n.getAttribute("data-pagy")),e=>e.charCodeAt(0)),[o,...l]=JSON.parse(new TextDecoder().decode(e));"nav"===o?t(n,l):"combo"===o?r(n,l):"selector"===o?a(n,l):console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",n,o)}catch(e){console.warn("Skipped Pagy.init() for: %o\n%s",n,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,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- warn '[PAGY WARNING] The foundation extra has been discontinued and it will be removed in v9 ' \
4
- '(https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328)'
5
-
6
- require_relative 'js_tools'
7
-
8
- class Pagy # :nodoc:
9
- # Frontend modules are specially optimized for performance.
10
- # The resulting code may not look very elegant, but produces the best benchmarks
11
- module FoundationExtra
12
- # Pagination for Foundation: it returns the html with the series of links to the pages
13
- def pagy_foundation_nav(pagy, id: nil, aria_label: nil, **vars)
14
- id = %( id="#{id}") if id
15
- a = pagy_anchor(pagy)
16
-
17
- html = +%(<nav#{id} class="pagy-foundation-nav" #{
18
- nav_aria_label(pagy, aria_label:)}><ul class="pagination"> #{
19
- foundation_prev_html(pagy, a)})
20
- pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
21
- html << case item
22
- when Integer
23
- %(<li>#{a.(item)}</li>)
24
- when String
25
- %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</li>)
26
- when :gap
27
- %(<li class="ellipsis gap"></li>)
28
- else
29
- raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
30
- end
31
- end
32
- html << %(#{foundation_next_html(pagy, a)}</ul></nav>)
33
- end
34
-
35
- # Javascript pagination for foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
36
- def pagy_foundation_nav_js(pagy, id: nil, aria_label: nil, **vars)
37
- sequels = pagy.sequels(**vars)
38
- id = %( id="#{id}") if id
39
- a = pagy_anchor(pagy)
40
- tokens = { 'before' => %(<ul class="pagination">#{foundation_prev_html pagy, a}),
41
- 'a' => %(<li>#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
42
- 'current' => %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</li>),
43
- 'gap' => %(<li class="ellipsis gap"></li>),
44
- 'after' => %(#{foundation_next_html pagy, a}</ul>) }
45
-
46
- %(<nav#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-foundation-nav-js" #{
47
- nav_aria_label(pagy, aria_label:)} #{
48
- pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
49
- }></nav>)
50
- end
51
-
52
- # Javascript combo pagination for Foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
53
- def pagy_foundation_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; ) <<
60
- %(height: 1.5rem; padding: .5rem; margin: 0 .4rem; font-size: .875rem;" class="current">#{JSTools::A_TAG})
61
-
62
- %(<nav#{id} class="pagy-foundation-combo-nav-js" #{
63
- nav_aria_label(pagy, aria_label:)} #{
64
- pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
65
- }><ul class="pagination">#{
66
- foundation_prev_html(pagy, a)
67
- }<li style="padding: 0 .3rem"><label style="display: flex; align-items: center; white-space: nowrap">#{
68
- pagy_t('pagy.combo_nav_js', page_input:, pages:)
69
- }</label></li>#{
70
- foundation_next_html(pagy, a)
71
- }</ul></nav>)
72
- end
73
-
74
- private
75
-
76
- def foundation_prev_html(pagy, a)
77
- if (p_prev = pagy.prev)
78
- %(<li class="prev">#{a.(p_prev, pagy_t('pagy.prev'), aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
79
- else
80
- %(<li class="prev disabled" role="link" aria-disabled="true" aria-label="#{
81
- pagy_t('pagy.aria_label.prev')}">#{pagy_t('pagy.prev')}</li>)
82
- end
83
- end
84
-
85
- def foundation_next_html(pagy, a)
86
- if (p_next = pagy.next)
87
- %(<li class="next">#{a.(p_next, pagy_t('pagy.next'), aria_label: pagy_t('pagy.aria_label.next'))}</li>)
88
- else
89
- %(<li class="next disabled" role="link" aria-disabled="true" aria-label="#{
90
- pagy_t('pagy.aria_label.next')}">#{pagy_t('pagy.next')}</li>)
91
- end
92
- end
93
- end
94
- Frontend.prepend FoundationExtra
95
- 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_relative '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;">#{JSTools::A_TAG})
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