pagy 8.6.3 → 9.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apps/calendar.ru +5 -5
- data/apps/demo.ru +4 -4
- data/apps/keyset_ar.ru +236 -0
- data/apps/keyset_s.ru +238 -0
- data/apps/rails.ru +5 -5
- data/apps/repro.ru +4 -4
- data/bin/pagy +4 -2
- data/config/pagy.rb +17 -13
- data/javascripts/pagy.min.js +2 -2
- data/javascripts/pagy.min.js.map +2 -2
- data/javascripts/pagy.mjs +2 -2
- data/lib/pagy/b64.rb +33 -0
- data/lib/pagy/backend.rb +19 -19
- data/lib/pagy/calendar/day.rb +1 -1
- data/lib/pagy/calendar/month.rb +1 -1
- data/lib/pagy/calendar/quarter.rb +1 -1
- data/lib/pagy/calendar/unit.rb +7 -10
- data/lib/pagy/calendar/week.rb +1 -1
- data/lib/pagy/calendar/year.rb +1 -1
- data/lib/pagy/calendar.rb +5 -5
- data/lib/pagy/countless.rb +10 -14
- data/lib/pagy/extras/arel.rb +2 -10
- data/lib/pagy/extras/array.rb +5 -10
- data/lib/pagy/extras/bootstrap.rb +5 -5
- data/lib/pagy/extras/bulma.rb +10 -7
- data/lib/pagy/extras/calendar.rb +4 -5
- data/lib/pagy/extras/countless.rb +8 -13
- data/lib/pagy/extras/elasticsearch_rails.rb +16 -25
- data/lib/pagy/extras/gearbox.rb +18 -18
- data/lib/pagy/extras/headers.rb +25 -24
- data/lib/pagy/extras/js_tools.rb +4 -4
- data/lib/pagy/extras/jsonapi.rb +26 -19
- data/lib/pagy/extras/keyset.rb +30 -0
- data/lib/pagy/extras/limit.rb +63 -0
- data/lib/pagy/extras/meilisearch.rb +9 -17
- data/lib/pagy/extras/metadata.rb +2 -2
- data/lib/pagy/extras/overflow.rb +5 -5
- data/lib/pagy/extras/pagy.rb +16 -16
- data/lib/pagy/extras/searchkick.rb +9 -17
- data/lib/pagy/extras/size.rb +1 -1
- data/lib/pagy/extras/standalone.rb +6 -6
- data/lib/pagy/extras/trim.rb +2 -2
- data/lib/pagy/frontend.rb +32 -33
- data/lib/pagy/i18n.rb +2 -2
- data/lib/pagy/keyset/active_record.rb +38 -0
- data/lib/pagy/keyset/sequel.rb +51 -0
- data/lib/pagy/keyset.rb +98 -0
- data/lib/pagy/shared_methods.rb +27 -0
- data/lib/pagy/url_helpers.rb +4 -4
- data/lib/pagy.rb +51 -65
- data/locales/ar.yml +1 -1
- data/locales/be.yml +1 -1
- data/locales/bg.yml +1 -1
- data/locales/bs.yml +1 -1
- data/locales/ca.yml +1 -1
- data/locales/ckb.yml +1 -1
- data/locales/cs.yml +1 -1
- data/locales/da.yml +1 -1
- data/locales/de.yml +1 -1
- data/locales/en.yml +1 -1
- data/locales/es.yml +1 -1
- data/locales/fr.yml +1 -1
- data/locales/hr.yml +1 -1
- data/locales/id.yml +1 -1
- data/locales/it.yml +1 -1
- data/locales/ja.yml +1 -1
- data/locales/km.yml +1 -1
- data/locales/ko.yml +1 -1
- data/locales/nb.yml +1 -1
- data/locales/nl.yml +1 -1
- data/locales/nn.yml +1 -1
- data/locales/pl.yml +1 -1
- data/locales/pt-BR.yml +1 -1
- data/locales/pt.yml +1 -1
- data/locales/ru.yml +1 -1
- data/locales/sr.yml +1 -1
- data/locales/sv-SE.yml +1 -1
- data/locales/sv.yml +1 -1
- data/locales/sw.yml +1 -1
- data/locales/ta.yml +1 -1
- data/locales/tr.yml +1 -1
- data/locales/uk.yml +1 -1
- data/locales/vi.yml +1 -1
- data/locales/zh-CN.yml +1 -1
- data/locales/zh-HK.yml +1 -1
- data/locales/zh-TW.yml +1 -1
- metadata +12 -24
- data/apps/tmp/calendar.sqlite3 +0 -0
- data/apps/tmp/calendar.sqlite3-shm +0 -0
- data/apps/tmp/calendar.sqlite3-wal +0 -0
- data/apps/tmp/local_secret.txt +0 -1
- data/apps/tmp/pagy-keyset.sqlite3 +0 -0
- data/apps/tmp/pagy-keyset.sqlite3-shm +0 -0
- data/apps/tmp/pagy-keyset.sqlite3-wal +0 -0
- data/javascripts/pagy-module.js +0 -100
- data/javascripts/pagy.js +0 -4
- data/lib/pagy/extras/foundation.rb +0 -95
- data/lib/pagy/extras/items.rb +0 -64
- data/lib/pagy/extras/materialize.rb +0 -100
- data/lib/pagy/extras/semantic.rb +0 -94
- data/lib/pagy/extras/uikit.rb +0 -98
data/locales/id.yml
CHANGED
@@ -16,4 +16,4 @@ id:
|
|
16
16
|
single_page: "Menampilkan %{count} %{item_name}"
|
17
17
|
multiple_pages: "Menampilkan %{item_name} %{from}-%{to} dari total %{count}"
|
18
18
|
combo_nav_js: "Halaman %{page_input} dari %{pages}"
|
19
|
-
|
19
|
+
limit_selector_js: "Tampilkan %{limit_input} %{item_name} per halaman"
|
data/locales/it.yml
CHANGED
@@ -18,4 +18,4 @@ it:
|
|
18
18
|
single_page: "Visualizzazione di %{count} %{item_name}"
|
19
19
|
multiple_pages: "Visualizzazione %{item_name} %{from}-%{to} di %{count} in totale"
|
20
20
|
combo_nav_js: "Pagina %{page_input} di %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Mostra %{limit_input} %{item_name} per pagina"
|
data/locales/ja.yml
CHANGED
data/locales/km.yml
CHANGED
@@ -16,4 +16,4 @@ km:
|
|
16
16
|
single_page: "បង្ហាញ %{count} %{item_name}"
|
17
17
|
multiple_pages: "បង្ហាញ %{item_name} %{from}-%{to} នៃ %{count} ជាចំនួនសរុប"
|
18
18
|
combo_nav_js: "ទំព័រ %{page_input} នៃ %{pages}"
|
19
|
-
|
19
|
+
limit_selector_js: "បង្ហាញ %{limit_input} %{item_name} ក្នុង ១ ទំព័រ"
|
data/locales/ko.yml
CHANGED
data/locales/nb.yml
CHANGED
@@ -18,4 +18,4 @@ nb:
|
|
18
18
|
single_page: "Viser %{count} %{item_name}"
|
19
19
|
multiple_pages: "Viser %{item_name} %{from}-%{to} av totalt %{count}"
|
20
20
|
combo_nav_js: "Side %{page_input} av %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Vis %{limit_input} %{item_name} per side"
|
data/locales/nl.yml
CHANGED
@@ -18,4 +18,4 @@ nl:
|
|
18
18
|
single_page: "Toont %{count} %{item_name}"
|
19
19
|
multiple_pages: "Toont %{from}-%{to} %{item_name} van %{count} in totaal"
|
20
20
|
combo_nav_js: "Pagina %{page_input} van %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Toont %{limit_input} %{item_name} per pagina"
|
data/locales/nn.yml
CHANGED
@@ -18,4 +18,4 @@ nn:
|
|
18
18
|
single_page: "Viser %{count} %{item_name}"
|
19
19
|
multiple_pages: "Viser %{item_name} %{from}-%{to} av totalt %{count}"
|
20
20
|
combo_nav_js: "Side %{page_input} av %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Vis %{limit_input} %{item_name} per side"
|
data/locales/pl.yml
CHANGED
@@ -22,4 +22,4 @@ pl:
|
|
22
22
|
single_page: "Wyświetlono %{count} %{item_name}"
|
23
23
|
multiple_pages: "Wyświetlono %{item_name} %{from}-%{to} z wszystkich %{count}"
|
24
24
|
combo_nav_js: "Strona %{page_input} z %{pages}"
|
25
|
-
|
25
|
+
limit_selector_js: "Pokaż %{limit_input} %{item_name} na stronie"
|
data/locales/pt-BR.yml
CHANGED
@@ -18,4 +18,4 @@ pt-BR:
|
|
18
18
|
single_page: "Mostrando %{count} %{item_name}"
|
19
19
|
multiple_pages: "Mostrando %{item_name} %{from}-%{to} do total de %{count}"
|
20
20
|
combo_nav_js: "Página %{page_input} de %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Mostrar %{limit_input} %{item_name} por página"
|
data/locales/pt.yml
CHANGED
@@ -18,4 +18,4 @@ pt:
|
|
18
18
|
single_page: "Mostrando %{count} %{item_name}"
|
19
19
|
multiple_pages: "Mostrando %{item_name} %{from}-%{to} de um total de %{count}"
|
20
20
|
combo_nav_js: "Página %{page_input} de %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Mostrar %{limit_input} %{item_name} por página"
|
data/locales/ru.yml
CHANGED
@@ -22,4 +22,4 @@ ru:
|
|
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
|
-
|
25
|
+
limit_selector_js: "Показать %{limit_input} %{item_name} на странице"
|
data/locales/sr.yml
CHANGED
@@ -22,4 +22,4 @@ sr:
|
|
22
22
|
single_page: "Приказује се %{count} %{item_name}"
|
23
23
|
multiple_pages: "Приказ %{item_name} %{from}-%{to} од %{count} укупно"
|
24
24
|
combo_nav_js: "Страниca %{page_input} од %{pages}"
|
25
|
-
|
25
|
+
limit_selector_js: "Прикажи %{limit_input} %{item_name} по страниcи"
|
data/locales/sv-SE.yml
CHANGED
@@ -18,4 +18,4 @@ sv-SE:
|
|
18
18
|
single_page: "Visar %{count} %{item_name}"
|
19
19
|
multiple_pages: "Visar %{item_name} %{from}-%{to} av %{count} totalt"
|
20
20
|
combo_nav_js: "Sida %{page_input} av %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Visa %{limit_input} %{item_name} per sida"
|
data/locales/sv.yml
CHANGED
@@ -18,4 +18,4 @@ sv:
|
|
18
18
|
single_page: "Visar %{count} %{item_name}"
|
19
19
|
multiple_pages: "Visar %{item_name} %{from}-%{to} av %{count} totalt"
|
20
20
|
combo_nav_js: "Sida %{page_input} av %{pages}"
|
21
|
-
|
21
|
+
limit_selector_js: "Visa %{limit_input} %{item_name} per sida"
|
data/locales/sw.yml
CHANGED
@@ -20,4 +20,4 @@ sw:
|
|
20
20
|
single_page: "Inaonyesha %{item_name} %{count}"
|
21
21
|
multiple_pages: "Inaonyesha %{item_name} %{from}-%{to} ya %{count} kwa jumla"
|
22
22
|
combo_nav_js: "Kurasa %{page_input} ya %{pages}"
|
23
|
-
|
23
|
+
limit_selector_js: "Onyesha %{limit_input} %{item_name} kwa kila ukurasa"
|
data/locales/ta.yml
CHANGED
@@ -20,4 +20,4 @@ ta:
|
|
20
20
|
single_page: "%{count} %{item_name} காட்டப்படுகின்றது"
|
21
21
|
multiple_pages: "மொத்தம் %{count} %{item_name}, காட்டப்படுபவை %{from}-%{to}"
|
22
22
|
combo_nav_js: "%{pages}-இல் %{page_input}-வது பக்கம்"
|
23
|
-
|
23
|
+
limit_selector_js: "ஒரு பக்கத்திற்கு %{limit_input} %{item_name} காட்டு"
|
data/locales/tr.yml
CHANGED
@@ -16,4 +16,4 @@ tr:
|
|
16
16
|
single_page: "Toplam %{count} %{item_name} gösteriliyor"
|
17
17
|
multiple_pages: "%{count} %{item_name} içerisinden %{from}-%{to} kadarı gösteriliyor"
|
18
18
|
combo_nav_js: "Sayfa %{page_input} / %{pages}"
|
19
|
-
|
19
|
+
limit_selector_js: "Sayfada %{limit_input} %{item_name} göster"
|
data/locales/uk.yml
CHANGED
@@ -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
|
-
|
25
|
+
limit_selector_js: "Показати %{limit_input} %{item_name} на сторінці"
|
data/locales/vi.yml
CHANGED
@@ -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
|
-
|
17
|
+
limit_selector_js: "Hiển thị %{limit_input} %{item_name} mỗi trang"
|
data/locales/zh-CN.yml
CHANGED
data/locales/zh-HK.yml
CHANGED
data/locales/zh-TW.yml
CHANGED
@@ -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
|
-
|
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:
|
4
|
+
version: 9.0.5
|
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-
|
11
|
+
date: 2024-08-01 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,25 +21,19 @@ 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
|
-
- apps/tmp/calendar.sqlite3
|
27
|
-
- apps/tmp/calendar.sqlite3-shm
|
28
|
-
- apps/tmp/calendar.sqlite3-wal
|
29
|
-
- apps/tmp/local_secret.txt
|
30
|
-
- apps/tmp/pagy-keyset.sqlite3
|
31
|
-
- apps/tmp/pagy-keyset.sqlite3-shm
|
32
|
-
- apps/tmp/pagy-keyset.sqlite3-wal
|
33
28
|
- bin/pagy
|
34
29
|
- config/pagy.rb
|
35
|
-
- javascripts/pagy-module.js
|
36
30
|
- javascripts/pagy.d.ts
|
37
|
-
- javascripts/pagy.js
|
38
31
|
- javascripts/pagy.min.js
|
39
32
|
- javascripts/pagy.min.js.map
|
40
33
|
- javascripts/pagy.mjs
|
41
34
|
- lib/optimist.rb
|
42
35
|
- lib/pagy.rb
|
36
|
+
- lib/pagy/b64.rb
|
43
37
|
- lib/pagy/backend.rb
|
44
38
|
- lib/pagy/calendar.rb
|
45
39
|
- lib/pagy/calendar/day.rb
|
@@ -58,26 +52,27 @@ files:
|
|
58
52
|
- lib/pagy/extras/calendar.rb
|
59
53
|
- lib/pagy/extras/countless.rb
|
60
54
|
- lib/pagy/extras/elasticsearch_rails.rb
|
61
|
-
- lib/pagy/extras/foundation.rb
|
62
55
|
- lib/pagy/extras/gearbox.rb
|
63
56
|
- lib/pagy/extras/headers.rb
|
64
57
|
- lib/pagy/extras/i18n.rb
|
65
|
-
- lib/pagy/extras/items.rb
|
66
58
|
- lib/pagy/extras/js_tools.rb
|
67
59
|
- lib/pagy/extras/jsonapi.rb
|
68
|
-
- lib/pagy/extras/
|
60
|
+
- lib/pagy/extras/keyset.rb
|
61
|
+
- lib/pagy/extras/limit.rb
|
69
62
|
- lib/pagy/extras/meilisearch.rb
|
70
63
|
- lib/pagy/extras/metadata.rb
|
71
64
|
- lib/pagy/extras/overflow.rb
|
72
65
|
- lib/pagy/extras/pagy.rb
|
73
66
|
- lib/pagy/extras/searchkick.rb
|
74
|
-
- lib/pagy/extras/semantic.rb
|
75
67
|
- lib/pagy/extras/size.rb
|
76
68
|
- lib/pagy/extras/standalone.rb
|
77
69
|
- lib/pagy/extras/trim.rb
|
78
|
-
- lib/pagy/extras/uikit.rb
|
79
70
|
- lib/pagy/frontend.rb
|
80
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
|
81
76
|
- lib/pagy/url_helpers.rb
|
82
77
|
- locales/ar.yml
|
83
78
|
- locales/be.yml
|
@@ -128,14 +123,7 @@ metadata:
|
|
128
123
|
bug_tracker_uri: https://github.com/ddnexus/pagy/issues
|
129
124
|
changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
|
130
125
|
support: https://github.com/ddnexus/pagy/discussions/categories/q-a
|
131
|
-
post_install_message:
|
132
|
-
*********************** PAGY WARNING! ***********************
|
133
|
-
The foundation, materialize, semantic and uikit CSS extras
|
134
|
-
have been discontinued and will be removed in v9
|
135
|
-
https://github.com/ddnexus/pagy/discussions/672
|
136
|
-
The javascript files have been deprecated/renamed
|
137
|
-
https://ddnexus.github.io/pagy/changelog/#deprecations
|
138
|
-
*************************************************************
|
126
|
+
post_install_message:
|
139
127
|
rdoc_options: []
|
140
128
|
require_paths:
|
141
129
|
- lib
|
data/apps/tmp/calendar.sqlite3
DELETED
Binary file
|
Binary file
|
File without changes
|
data/apps/tmp/local_secret.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
4c57eebd7544c7f0acc9943ab614ab3da71d2461f5581ed8d41e9b8aa1bf23bff831f82e934eed96c608da0feac2c3dd21383c269d896cf01fcd6fa81aca2462
|
Binary file
|
Binary file
|
Binary file
|
data/javascripts/pagy-module.js
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
const Pagy = (() => {
|
2
|
-
const rjsObserver = new ResizeObserver((entries) => entries.forEach((e) => e.target.querySelectorAll(".pagy-rjs").forEach((el) => el.pagyRender())));
|
3
|
-
const initNav = (el, [tokens, sequels, labelSequels, trimParam]) => {
|
4
|
-
const container = el.parentElement ?? el;
|
5
|
-
const widths = Object.keys(sequels).map((w) => parseInt(w)).sort((a, b) => b - a);
|
6
|
-
let lastWidth = -1;
|
7
|
-
const fillIn = (a, page, label) => a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
|
8
|
-
(el.pagyRender = function() {
|
9
|
-
const width = widths.find((w) => w < container.clientWidth) || 0;
|
10
|
-
if (width === lastWidth) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
let html = tokens.before;
|
14
|
-
const series = sequels[width.toString()];
|
15
|
-
const labels = labelSequels?.[width.toString()] ?? series.map((l) => l.toString());
|
16
|
-
series.forEach((item, i) => {
|
17
|
-
const label = labels[i];
|
18
|
-
let filled;
|
19
|
-
if (typeof item === "number") {
|
20
|
-
filled = fillIn(tokens.a, item.toString(), label);
|
21
|
-
} else if (item === "gap") {
|
22
|
-
filled = tokens.gap;
|
23
|
-
} else {
|
24
|
-
filled = fillIn(tokens.current, item, label);
|
25
|
-
}
|
26
|
-
html += typeof trimParam === "string" && item == 1 ? trim(filled, trimParam) : filled;
|
27
|
-
});
|
28
|
-
html += tokens.after;
|
29
|
-
el.innerHTML = "";
|
30
|
-
el.insertAdjacentHTML("afterbegin", html);
|
31
|
-
lastWidth = width;
|
32
|
-
})();
|
33
|
-
if (el.classList.contains("pagy-rjs")) {
|
34
|
-
rjsObserver.observe(container);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
const initCombo = (el, [url_token, trimParam]) => initInput(el, (inputValue) => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);
|
38
|
-
const initSelector = (el, [from, url_token, trimParam]) => {
|
39
|
-
initInput(el, (inputValue) => {
|
40
|
-
const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
|
41
|
-
const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
|
42
|
-
return [page, url];
|
43
|
-
}, trimParam);
|
44
|
-
};
|
45
|
-
const initInput = (el, getVars, trimParam) => {
|
46
|
-
const input = el.querySelector("input");
|
47
|
-
const link = el.querySelector("a");
|
48
|
-
const initial = input.value;
|
49
|
-
const action = function() {
|
50
|
-
if (input.value === initial) {
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
const [min, val, max] = [input.min, input.value, input.max].map((n) => parseInt(n) || 0);
|
54
|
-
if (val < min || val > max) {
|
55
|
-
input.value = initial;
|
56
|
-
input.select();
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
let [page, url] = getVars(input.value);
|
60
|
-
if (typeof trimParam === "string" && page === "1") {
|
61
|
-
url = trim(url, trimParam);
|
62
|
-
}
|
63
|
-
link.href = url;
|
64
|
-
link.click();
|
65
|
-
};
|
66
|
-
["change", "focus"].forEach((e) => input.addEventListener(e, () => input.select()));
|
67
|
-
input.addEventListener("focusout", action);
|
68
|
-
input.addEventListener("keypress", (e) => {
|
69
|
-
if (e.key === "Enter") {
|
70
|
-
action();
|
71
|
-
}
|
72
|
-
});
|
73
|
-
};
|
74
|
-
const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
|
75
|
-
return {
|
76
|
-
version: "8.6.3",
|
77
|
-
init(arg) {
|
78
|
-
const target = arg instanceof Element ? arg : document;
|
79
|
-
const elements = target.querySelectorAll("[data-pagy]");
|
80
|
-
for (const el of elements) {
|
81
|
-
try {
|
82
|
-
const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), (c) => c.charCodeAt(0));
|
83
|
-
const [keyword, ...args] = JSON.parse(new TextDecoder().decode(uint8array));
|
84
|
-
if (keyword === "nav") {
|
85
|
-
initNav(el, args);
|
86
|
-
} else if (keyword === "combo") {
|
87
|
-
initCombo(el, args);
|
88
|
-
} else if (keyword === "selector") {
|
89
|
-
initSelector(el, args);
|
90
|
-
} else {
|
91
|
-
console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
|
92
|
-
}
|
93
|
-
} catch (err) {
|
94
|
-
console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
};
|
99
|
-
})();
|
100
|
-
export default Pagy;
|
data/javascripts/pagy.js
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
window.Pagy=(()=>{const j=new ResizeObserver((B)=>B.forEach((D)=>D.target.querySelectorAll(".pagy-rjs").forEach((E)=>E.pagyRender()))),x=(B,[D,E,z,G])=>{const F=B.parentElement??B,K=Object.keys(E).map((H)=>parseInt(H)).sort((H,M)=>M-H);let L=-1;const T=(H,M,R)=>H.replace(/__pagy_page__/g,M).replace(/__pagy_label__/g,R);if((B.pagyRender=function(){const H=K.find((Q)=>Q<F.clientWidth)||0;if(H===L)return;let M=D.before;const R=E[H.toString()],X=z?.[H.toString()]??R.map((Q)=>Q.toString());R.forEach((Q,J)=>{const $=X[J];let U;if(typeof Q==="number")U=T(D.a,Q.toString(),$);else if(Q==="gap")U=D.gap;else U=T(D.current,Q,$);M+=typeof G==="string"&&Q==1?Z(U,G):U}),M+=D.after,B.innerHTML="",B.insertAdjacentHTML("afterbegin",M),L=H})(),B.classList.contains("pagy-rjs"))j.observe(F)},A=(B,[D,E])=>Y(B,(z)=>[z,D.replace(/__pagy_page__/,z)],E),C=(B,[D,E,z])=>{Y(B,(G)=>{const F=Math.max(Math.ceil(D/parseInt(G)),1).toString(),K=E.replace(/__pagy_page__/,F).replace(/__pagy_items__/,G);return[F,K]},z)},Y=(B,D,E)=>{const z=B.querySelector("input"),G=B.querySelector("a"),F=z.value,K=function(){if(z.value===F)return;const[L,T,H]=[z.min,z.value,z.max].map((X)=>parseInt(X)||0);if(T<L||T>H){z.value=F,z.select();return}let[M,R]=D(z.value);if(typeof E==="string"&&M==="1")R=Z(R,E);G.href=R,G.click()};["change","focus"].forEach((L)=>z.addEventListener(L,()=>z.select())),z.addEventListener("focusout",K),z.addEventListener("keypress",(L)=>{if(L.key==="Enter")K()})},Z=(B,D)=>B.replace(new RegExp(`[?&]${D}=1\\b(?!&)|\\b${D}=1&`),"");return{version:"8.6.3",init(B){const E=(B instanceof Element?B:document).querySelectorAll("[data-pagy]");for(let z of E)try{const G=Uint8Array.from(atob(z.getAttribute("data-pagy")),(L)=>L.charCodeAt(0)),[F,...K]=JSON.parse((new TextDecoder()).decode(G));if(F==="nav")x(z,K);else if(F==="combo")A(z,K);else if(F==="selector")C(z,K);else console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",z,F)}catch(G){console.warn("Skipped Pagy.init() for: %o\n%s",z,G)}}}})();
|
2
|
-
|
3
|
-
//# debugId=B9DC02765C7A5B6764756E2164756E21
|
4
|
-
//# sourceMappingURL=pagy.min.js.map
|
@@ -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
|
data/lib/pagy/extras/items.rb
DELETED
@@ -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
|