pagy 5.6.10 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/javascripts/pagy.js.map +1 -1
- data/lib/pagy/extras/bootstrap.rb +4 -3
- data/lib/pagy/extras/bulma.rb +4 -3
- data/lib/pagy/extras/foundation.rb +4 -3
- data/lib/pagy/extras/materialize.rb +4 -3
- data/lib/pagy/extras/navs.rb +4 -3
- data/lib/pagy/extras/semantic.rb +4 -3
- data/lib/pagy/extras/uikit.rb +4 -3
- data/lib/pagy.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dff2343464e636499952ed82e91f9691f8855630a77d6bcfffee985ae7ff443f
|
4
|
+
data.tar.gz: 6659996eb14375576d033ab5da3faaead938e9145b67fba2e625aa2b91a3a4a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b404bb256a2070c382f536a007972cce2fcfad6a22010221194a043dba3fee525a86c00a85ea7b2a8f93da5882f8651752b7dd6f2a99a5a5038094445c5c7e79
|
7
|
+
data.tar.gz: 8c5263db5dd2d2cec869236fd37bcdfed67dc68c643fba2c520677829c6adc22dbd5eba88e36ba3014b2dd71466f9f102b1c5b88a3cf99a2c56add4b4f88cd17
|
data/lib/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (5.
|
3
|
+
# Pagy initializer file (5.7.0)
|
4
4
|
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
|
5
5
|
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
6
6
|
|
data/lib/javascripts/pagy.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
"use strict";function
|
1
|
+
"use strict";function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f=[],g=!0,h=!1;try{for(c=c.call(a);!(g=(d=c.next()).done)&&(f.push(d.value),!(b&&f.length===b));g=!0);}catch(a){h=!0,e=a}finally{try{g||null==c["return"]||c["return"]()}finally{if(h)throw e}}return f}}function _toArray(a){return _arrayWithHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}var Pagy={version:"5.7.0",init:function init(a){var b,c=a instanceof Element?a:document,d=c.querySelectorAll("[data-pagy-json]"),e=function(a,b){return console.warn("Pagy.init() skipped element: %o\n%s",a,b)},f=_createForOfIteratorHelper(d);try{for(f.s();!(b=f.n()).done;){var g=b.value,h=g.getAttribute("data-pagy-json");try{var i=JSON.parse(h),j=_toArray(i),k=j[0],l=j.slice(1);"nav"===k?Pagy.initNav(g,l):"combo_nav"===k?Pagy.initComboNav(g,l):"items_selector"===k?Pagy.initItemsSelector(g,l):e(g,"Illegal PagyJSON keyword: expected \"nav\"|\"combo_nav\"|\"items_selector\" got \"".concat(k,"\""))}catch(a){e(g,a)}}}catch(a){f.e(a)}finally{f.f()}},initNav:function initNav(a,b){var c=_slicedToArray(b,4),d=c[0],e=c[1],f=c[2],g=c[3],h=a.parentElement||a,j=Object.getOwnPropertyNames(e).map(function(a){return parseInt(a)}).sort(function(c,a){return a-c}),k=-1,l=function(a,b,c){return a.replace(/__pagy_page__/g,b).replace(/__pagy_label__/g,c)};(a.pagyRender=function(){var b=j.find(function(a){return a<h.clientWidth})||0;if(b!==k){var c=d.before,m=e[b.toString()],n=null===f?m.map(function(a){return a.toString()}):f[b.toString()];for(var q in m){var o=m[q],p=n[q];if("string"==typeof g&&1===o){var i=l(d.link,o.toString(),p);c+=Pagy.trim(i,g)}else c+="number"==typeof o?l(d.link,o.toString(),p):"gap"===o?d.gap:l(d.active,o,p)}c+=d.after,a.innerHTML="",a.insertAdjacentHTML("afterbegin",c),k=b}})(),a.classList.contains("pagy-rjs")&&Pagy.rjsObserver.observe(h)},rjsObserver:new ResizeObserver(function(a){a.filter(function(a){return a.contentBoxSize}).forEach(function(a){return a.target.querySelectorAll(".pagy-rjs").forEach(function(a){return a.pagyRender()})})}),initComboNav:function initComboNav(a,b){var c=_slicedToArray(b,2),d=c[0],e=c[1],f=a.querySelector("input"),g=f.value;Pagy.initInput(f,function(){if(Pagy.validValueFor(f,g)){var b=d.replace(/__pagy_page__/,f.value);Pagy.finalizeAction(a,b,f.value,e)}})},initItemsSelector:function initItemsSelector(a,b){var c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2],g=a.querySelector("input"),h=g.value;Pagy.initInput(g,function(){var b=Math.max,c=Math.ceil;if(Pagy.validValueFor(g,h)){var i=b(c(d/parseInt(g.value)),1).toString(),j=e.replace(/__pagy_page__/,i).replace(/__pagy_items__/,g.value);Pagy.finalizeAction(a,j,i,f)}})},initInput:function initInput(a,b){["change","focus"].forEach(function(b){return a.addEventListener(b,a.select)}),a.addEventListener("focusout",b),a.addEventListener("keypress",function(a){"Enter"===a.key&&b()})},validValueFor:function validValueFor(a,b){if(a.value===b)return!1;var c=[a.min,a.value,a.max].map(function(a){return parseInt(a)||0}),d=_slicedToArray(c,3),e=d[0],f=d[1],g=d[2];return!!(f>=e&&f<=g)||(a.value=b,a.select(),!1)},finalizeAction:function finalizeAction(a,b,c,d){"string"==typeof d&&"1"===c&&(b=Pagy.trim(b,d)),a.insertAdjacentHTML("afterbegin",b),a.querySelector("a").click()},trim:function trim(a,b){return a.replace(new RegExp("[?&]".concat(b,"=1\\b(?!&)|\\b").concat(b,"=1&")),"")}};
|
2
2
|
|
3
3
|
//# sourceMappingURL=pagy.js.map
|
data/lib/javascripts/pagy.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/pagy.ts"],"names":[],"mappings":"mrDAkCA,GAAM,CAAA,IAAI,CAAG,CACT,OAAO,CAAE,QADA,CAIT,IAJS,eAIJ,CAJI,CAI6B,OAC5B,CAAM,CAAG,CAAG,WAAY,CAAA,WAAf,CAA6B,CAA7B,CAAmC,QADhB,CAE5B,CAAQ,CAAG,CAAM,CAAC,gBAAP,CAAwB,kBAAxB,CAFiB,8BAGZ,CAHY,MAGlC,2BAAgC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gBAAN,CAAuB,UAAvB,CAAmC,CAAnC,CAJ0D,CAM1D,CAAK,CAAC,gBAAN,CAAuB,UAAvB,CAAmC,SAAA,CAAC,CAAI,CAAgB,OAAV,GAAA,CAAC,CAAC,GAAR,EAA2B,CAAQ,EAAM,CAAjF,CACH,CArIQ,CAuIT,IAAI,CAAE,cAAC,CAAD,CAAc,CAAd,QACI,CAAA,CAAI,CAAC,OAAL,CAAa,GAAI,CAAA,MAAJ,eAAkB,CAAlB,0BAAwC,CAAxC,QAAb,CAAkE,EAAlE,CADJ,CAvIG,CAAb","file":"pagy.js","sourcesContent":["// This file is the source that generates pagy.js, polyfilled with the `@babel/preset-env` `\"useBuiltIns\": \"entry\"`.\n// You can generate a custom targeted javascript file for the browsers you need by changing that settings in package.json,\n// then compile it with `npm run compile -w src`.\n\n// Args types from data-pagy-json\ntype NavArgs = [NavTags, NavSequels, null|NavLabelSequels, string]\ntype ComboNavArgs = [string, string, string]\ntype ItemsSelectorArgs = [number, string, string]\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavTags {\n readonly before:string;\n readonly link:string;\n readonly active:string;\n readonly gap:string;\n readonly after:string;\n}\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavSequels {\n readonly [width:string]:(string|number|\"gap\")[];\n}\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavLabelSequels {\n [width:string]:string[];\n}\n\n// Add pagyRender to Element\ninterface Element {\n pagyRender():void;\n}\n\n// The Pagy object\nconst Pagy = {\n version: \"5.6.10\",\n\n // Scan for \"data-pagy-json\" elements, parse their JSON content and apply their functions\n init(arg?:HTMLElement|Document|Event) {\n const target = arg instanceof HTMLElement ? arg : document;\n const elements = target.querySelectorAll(\"[data-pagy-json]\");\n for (const element of elements) {\n const json = element.getAttribute(\"data-pagy-json\") as string;\n try {\n const args = JSON.parse(json);\n const fname = args.shift() as \"nav\"|\"combo_nav\"|\"items_selector\";\n if (fname === \"nav\") {\n Pagy.nav(element, ...args as NavArgs);\n } else if (fname === \"combo_nav\") {\n Pagy.comboNav(element, ...args as ComboNavArgs);\n } else if (fname === \"items_selector\") {\n Pagy.itemsSelector(element, ...args as ItemsSelectorArgs);\n }\n } catch (err) {\n console.warn(\"Pagy.init() skipped element: %o\\n%s\", element, err);\n }\n }\n },\n\n // Power the *_nav_js helpers\n nav(pagyEl:Element, tags:NavTags, sequels:NavSequels, optLabelSequels:null|NavLabelSequels, trimParam?:string) {\n let labelSequels = {} as NavLabelSequels;\n // Handle null labelSequels\n if (optLabelSequels === null) {\n for (const width in sequels) {\n labelSequels[width] = sequels[width].map(item => item.toString());\n }\n } else {\n labelSequels = optLabelSequels;\n }\n // Set and sort the widths as number[]\n const widths = Object.getOwnPropertyNames(sequels)\n .map(w => parseInt(w))\n .sort((a, b) => b - a);\n let lastWidth:number;\n const fillIn = (string:string, item:string, label:string):string =>\n string.replace(/__pagy_page__/g, item)\n .replace(/__pagy_label__/g, label);\n\n pagyEl.pagyRender = function () {\n // Find the width that fits in parent\n const width = widths.find(w => pagyEl.parentElement !== null && pagyEl.parentElement.clientWidth > w) || 0;\n // Only if the width changed\n if (width !== lastWidth) {\n let html = tags.before;\n const series = sequels[width.toString()];\n const labels = labelSequels[width.toString()];\n for (const i in series) {\n const item = series[i];\n const label = labels[i];\n if (typeof trimParam === \"string\" && item === 1) {\n const link = fillIn(tags.link, item.toString(), label);\n html += Pagy.trim(link, trimParam);\n } else if (typeof item === \"number\") {\n html += fillIn(tags.link, item.toString(), label);\n } else if (item === \"gap\") {\n html += tags.gap;\n } else { // active page\n html += fillIn(tags.active, item, label);\n }\n }\n html += tags.after;\n pagyEl.innerHTML = \"\";\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n }\n };\n pagyEl.pagyRender();\n // If there is a window object then add a single throttled \"resize\" event listener\n if (typeof window !== \"undefined\") {\n let tid = 0;\n window.addEventListener(\"resize\", () => {\n clearTimeout(tid);\n tid = window.setTimeout(Pagy.renderNavs, 100);\n }, true);\n }\n },\n\n // Render all *nav_js helpers (i.e. all the elements of class \"pagy-njs\")\n renderNavs() {\n const navs = document.getElementsByClassName(\"pagy-njs\");\n Array.from(navs).forEach(nav => nav.pagyRender());\n },\n\n // Power the *_combo_nav_js helpers\n comboNav(pagyEl:Element, page:string, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n Pagy.addInputBehavior(input, () => {\n if (page !== input.value) {\n let html = link.replace(/__pagy_page__/, input.value);\n if (typeof trimParam === \"string\" && input.value === \"1\") {\n html = Pagy.trim(html, trimParam);\n }\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n pagyEl.getElementsByTagName(\"a\")[0].click();\n }\n });\n },\n\n // Power the pagy_items_selector_js helper\n itemsSelector(pagyEl:Element, from:number, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n const current = input.value;\n Pagy.addInputBehavior(input, () => {\n const items = input.value;\n if (items === \"0\" || items === \"\") { return }\n if (current !== items) {\n const page = Math.max(Math.ceil(from / parseInt(items)), 1).toString();\n let html = link.replace(/__pagy_page__/, page)\n .replace(/__pagy_items__/, items);\n if (typeof trimParam === \"string\" && page === \"1\") {\n html = Pagy.trim(html, trimParam);\n }\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n pagyEl.getElementsByTagName(\"a\")[0].click();\n }\n });\n },\n\n // Add behavior to input fields\n addInputBehavior(input:HTMLInputElement, goToPage:() => void) {\n // select the content on click: easier for direct typing\n input.addEventListener(\"click\", input.select);\n // goToPage when the input loses focus\n input.addEventListener(\"focusout\", goToPage);\n // goToPage when pressing enter while the input has focus\n input.addEventListener(\"keypress\", e => { if (e.key === \"Enter\") { goToPage() } });\n },\n\n trim: (link:string, param:string):string =>\n link.replace(new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`), \"\")\n};\n"]}
|
1
|
+
{"version":3,"sources":["../../src/pagy.ts"],"names":[],"mappings":"8mEAsBA,GAAM,CAAA,IAAI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AkG6B,CAlG7B,CAkGqD,CAC1D,GAAI,CAAK,CAAC,KAAN,GAAgB,CAApB,CAA+B,SAC/B,MAAwB,CAAC,CAAK,CAAC,GAAP,CAAY,CAAK,CAAC,KAAlB,CAAyB,CAAK,CAAC,GAA/B,EAAoC,GAApC,CAAwC,SAAA,CAAC,QAAI,CAAA,QAAQ,CAAC,CAAD,CAAR,EAAe,CAAnB,CAAzC,CAAxB,uBAAO,CAAP,MAAY,CAAZ,MAAiB,CAAjB,MAF0D,SAGtD,CAAG,EAAI,CAAP,EAAc,CAAG,EAAI,CAHiC,IAI1D,CAAK,CAAC,KAAN,CAAc,CAJ4C,CAK1D,CAAK,CAAC,MAAN,EAL0D,IAO7D,CAzGQ,CA4GT,cA5GS,yBA4GM,CA5GN,CA4GkB,CA5GlB,CA4G+B,CA5G/B,CA4G4C,CA5G5C,CA4G+D,CAC3C,QAArB,QAAO,CAAA,CAAP,EAA0C,GAAT,GAAA,CAD+B,GACf,CAAI,CAAG,IAAI,CAAC,IAAL,CAAU,CAAV,CAAgB,CAAhB,CADQ,EAEpE,CAAE,CAAC,kBAAH,CAAsB,YAAtB,CAAoC,CAApC,CAFoE,CAGnE,CAAE,CAAC,aAAH,CAAiB,GAAjB,CAAD,CAA6C,KAA7C,EACH,CAhHQ,CAmHT,IAAI,CAAE,cAAC,CAAD,CAAc,CAAd,QAA+B,CAAA,CAAI,CAAC,OAAL,CAAa,GAAI,CAAA,MAAJ,eAAkB,CAAlB,0BAAwC,CAAxC,QAAb,CAAkE,EAAlE,CAA/B,CAnHG,CAAb","file":"pagy.js","sourcesContent":["// This file is the source that generates pagy.js, polyfilled with the `@babel/preset-env` `\"useBuiltIns\": \"entry\"`.\n// You can generate a custom targeted javascript file for the browsers you need by changing that settings in package.json,\n// then compile it with `npm run compile -w src`.\n\n// Args types and interfaces from data-pagy-json\ntype PagyJSON = readonly [\"nav\", ...NavArgs] | [\"combo_nav\", ...ComboNavArgs] | [\"items_selector\", ...ItemsSelectorArgs]\ntype NavArgs = readonly [NavTags, NavSequels, null|NavLabelSequels, string?]\ntype ComboNavArgs = readonly [string, string?]\ntype ItemsSelectorArgs = readonly [number, string, string?]\n\ninterface NavTags {\n readonly before: string\n readonly link: string\n readonly active: string\n readonly gap: string\n readonly after: string\n}\ninterface NavSequels { readonly [width:string]: (string|number|\"gap\")[] }\ninterface NavLabelSequels { readonly [width:string]: string[] }\ninterface Element { pagyRender(): void }\n\n// The Pagy object\nconst Pagy = {\n version: \"5.7.0\",\n\n // Scan for \"data-pagy-json\" elements, parse their JSON content and call their init functions\n init(arg?:Element|never) {\n const target = arg instanceof Element ? arg : document;\n const elements = target.querySelectorAll(\"[data-pagy-json]\");\n const warn = (el:Element, err:unknown) => console.warn(\"Pagy.init() skipped element: %o\\n%s\", el, err);\n for (const element of elements) {\n const json = element.getAttribute(\"data-pagy-json\") as string;\n try {\n const [keyword, ...args] = JSON.parse(json) as PagyJSON;\n if (keyword === \"nav\") {\n Pagy.initNav(element, args as NavArgs);\n } else if (keyword === \"combo_nav\") {\n Pagy.initComboNav(element, args as ComboNavArgs);\n } else if (keyword === \"items_selector\") {\n Pagy.initItemsSelector(element, args as ItemsSelectorArgs);\n } else {\n warn(element, `Illegal PagyJSON keyword: expected \"nav\"|\"combo_nav\"|\"items_selector\" got \"${keyword}\"`);\n }\n } catch (err) { warn(element, err) }\n }\n },\n\n // Init the *_nav_js helpers\n initNav(el:Element, [tags, sequels, labelSequels, trimParam]:NavArgs) {\n const container = el.parentElement || el;\n const widths = Object.getOwnPropertyNames(sequels).map(w => parseInt(w)).sort((a, b) => b - a);\n let lastWidth = -1;\n const fillIn = (string:string, item:string, label:string):string =>\n string.replace(/__pagy_page__/g, item).replace(/__pagy_label__/g, label);\n (el.pagyRender = function () {\n const width = widths.find(w => w < container.clientWidth) || 0;\n if (width === lastWidth) { return } // no change: abort\n let html = tags.before;\n const series = sequels[width.toString()];\n const labels = labelSequels === null ? series.map(l => l.toString()) : labelSequels[width.toString()];\n for (const i in series) {\n const item = series[i];\n const label = labels[i];\n if (typeof trimParam === \"string\" && item === 1) {\n const link = fillIn(tags.link, item.toString(), label);\n html += Pagy.trim(link, trimParam);\n } else if (typeof item === \"number\") {\n html += fillIn(tags.link, item.toString(), label);\n } else if (item === \"gap\") {\n html += tags.gap;\n } else { // active page\n html += fillIn(tags.active, item, label);\n }\n }\n html += tags.after;\n el.innerHTML = \"\";\n el.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n })();\n if (el.classList.contains(\"pagy-rjs\")) { Pagy.rjsObserver.observe(container) }\n },\n\n // The observer instance for responsive navs\n rjsObserver: new ResizeObserver(entries => {\n entries.filter(e => e.contentBoxSize)\n .forEach(e => e.target.querySelectorAll(\".pagy-rjs\")\n .forEach(rjs => rjs.pagyRender()));\n }),\n\n // Init the *_combo_nav_js helpers\n initComboNav(el:Element, [link, trimParam]:ComboNavArgs) {\n const input = el.querySelector(\"input\") as HTMLInputElement;\n const initial = input.value;\n Pagy.initInput(input, () => {\n if (!Pagy.validValueFor(input, initial)) { return } // abort action\n const html = link.replace(/__pagy_page__/, input.value);\n Pagy.finalizeAction(el, html, input.value, trimParam);\n });\n },\n\n // Init the pagy_items_selector_js helper\n initItemsSelector(el:Element, [from, link, trimParam]:ItemsSelectorArgs) {\n const input = el.querySelector(\"input\") as HTMLInputElement;\n const initial = input.value;\n Pagy.initInput(input, () => {\n if (!Pagy.validValueFor(input, initial)) { return } // abort action\n const page = Math.max(Math.ceil(from / parseInt(input.value)), 1).toString();\n const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, input.value);\n Pagy.finalizeAction(el, html, page, trimParam);\n });\n },\n\n // Init input field\n initInput(input:HTMLInputElement, action:() => void) {\n [\"change\", \"focus\"].forEach(e => input.addEventListener(e, input.select)); // auto-select\n input.addEventListener(\"focusout\", action); // trigger action\n input.addEventListener(\"keypress\", e => { if (e.key === \"Enter\") { action() } }); // trigger action\n },\n\n // Check for valid value or reset it\n validValueFor(input:HTMLInputElement, initial:string):boolean {\n if (input.value === initial) { return false } // not changed\n const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);\n if (val >= min && val <= max) { return true } // in range\n input.value = initial; // reset invalid/out-of-range\n input.select();\n return false;\n },\n\n // Finalize the input action\n finalizeAction(el:Element, html:string, page:string, trimParam?:string) {\n if (typeof trimParam === \"string\" && page === \"1\") { html = Pagy.trim(html, trimParam) }\n el.insertAdjacentHTML(\"afterbegin\", html);\n (el.querySelector(\"a\") as HTMLAnchorElement).click();\n },\n\n // Trim the ${page-param}=1 params in links\n trim: (link:string, param:string) => link.replace(new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`), \"\")\n};\n"]}
|
@@ -31,6 +31,7 @@ class Pagy # :nodoc:
|
|
31
31
|
|
32
32
|
# Javascript pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
33
33
|
def pagy_bootstrap_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
34
|
+
sequels = pagy.sequels(**vars)
|
34
35
|
p_id = %( id="#{pagy_id}") if pagy_id
|
35
36
|
link = pagy_link_proc(pagy, link_extra: %(class="page-link" #{link_extra}))
|
36
37
|
tags = { 'before' => %(<ul class="pagination">#{pagy_bootstrap_prev_html pagy, link}),
|
@@ -39,8 +40,8 @@ class Pagy # :nodoc:
|
|
39
40
|
'gap' => %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t 'pagy.nav.gap'}</a></li>),
|
40
41
|
'after' => %(#{pagy_bootstrap_next_html pagy, link}</ul>) }
|
41
42
|
|
42
|
-
%(<nav#{p_id} class="pagy-
|
43
|
-
pagy_json_attr(pagy, :nav, tags,
|
43
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-bootstrap-nav-js" aria-label="pager" #{
|
44
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
44
45
|
end
|
45
46
|
|
46
47
|
# Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -54,7 +55,7 @@ class Pagy # :nodoc:
|
|
54
55
|
p_pages.to_s.length + 1}rem;">)
|
55
56
|
|
56
57
|
%(<nav#{p_id} class="pagy-bootstrap-combo-nav-js pagination" aria-label="pager"><div class="btn-group" role="group" #{
|
57
|
-
pagy_json_attr pagy, :combo_nav,
|
58
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
|
58
59
|
if (p_prev = pagy.prev)
|
59
60
|
link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous" class="prev btn btn-primary"'
|
60
61
|
else
|
data/lib/pagy/extras/bulma.rb
CHANGED
@@ -31,6 +31,7 @@ class Pagy # :nodoc:
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def pagy_bulma_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
34
|
+
sequels = pagy.sequels(**vars)
|
34
35
|
p_id = %( id="#{pagy_id}") if pagy_id
|
35
36
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
36
37
|
tags = { 'before' => %(#{pagy_bulma_prev_next_html(pagy, link)}<ul class="pagination-list">),
|
@@ -42,8 +43,8 @@ class Pagy # :nodoc:
|
|
42
43
|
'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.nav.gap'}</span></li>),
|
43
44
|
'after' => '</ul>' }
|
44
45
|
|
45
|
-
%(<nav#{p_id} class="pagy-
|
46
|
-
pagy_json_attr(pagy, :nav, tags,
|
46
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-bulma-nav-js pagination is-centered" aria-label="pagination" #{
|
47
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
47
48
|
end
|
48
49
|
|
49
50
|
# Javascript combo pagination for Bulma: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -57,7 +58,7 @@ class Pagy # :nodoc:
|
|
57
58
|
|
58
59
|
html = %(<nav#{p_id} class="pagy-bulma-combo-nav-js" aria-label="pagination">)
|
59
60
|
%(#{html}<div class="field is-grouped is-grouped-centered" role="group" #{
|
60
|
-
pagy_json_attr pagy, :combo_nav,
|
61
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
|
61
62
|
if (p_prev = pagy.prev)
|
62
63
|
%(<p class="control">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'class="button" aria-label="previous page"'}</p>)
|
63
64
|
else
|
@@ -28,6 +28,7 @@ class Pagy # :nodoc:
|
|
28
28
|
|
29
29
|
# Javascript pagination for foundation: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
30
30
|
def pagy_foundation_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
31
|
+
sequels = pagy.sequels(**vars)
|
31
32
|
p_id = %( id="#{pagy_id}") if pagy_id
|
32
33
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
33
34
|
tags = { 'before' => %(<ul class="pagination">#{pagy_foundation_prev_html pagy, link}),
|
@@ -36,8 +37,8 @@ class Pagy # :nodoc:
|
|
36
37
|
'gap' => %(<li class="ellipsis gap" aria-hidden="true"></li>),
|
37
38
|
'after' => %(#{pagy_foundation_next_html pagy, link}</ul>) }
|
38
39
|
|
39
|
-
%(<nav#{p_id} class="pagy-
|
40
|
-
pagy_json_attr(pagy, :nav, tags,
|
40
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-foundation-nav-js" aria-label="Pagination" #{
|
41
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
41
42
|
end
|
42
43
|
|
43
44
|
# Javascript combo pagination for Foundation: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -51,7 +52,7 @@ class Pagy # :nodoc:
|
|
51
52
|
p_pages.to_s.length + 1}rem; padding: 0 0.3rem; margin: 0 0.3rem;">)
|
52
53
|
|
53
54
|
%(<nav#{p_id} class="pagy-foundation-combo-nav-js" aria-label="Pagination"><div class="input-group" #{
|
54
|
-
pagy_json_attr pagy, :combo_nav,
|
55
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
|
55
56
|
if (p_prev = pagy.prev)
|
56
57
|
link.call p_prev, pagy_t('pagy.nav.prev'),
|
57
58
|
'style="margin-bottom: 0" aria-label="previous" class="prev button primary"'
|
@@ -28,6 +28,7 @@ class Pagy # :nodoc:
|
|
28
28
|
|
29
29
|
# Javascript pagination for materialize: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
30
30
|
def pagy_materialize_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
31
|
+
sequels = pagy.sequels(**vars)
|
31
32
|
p_id = %( id="#{pagy_id}") if pagy_id
|
32
33
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
33
34
|
|
@@ -37,8 +38,8 @@ class Pagy # :nodoc:
|
|
37
38
|
'gap' => %(<li class="gap disabled"><a href="#">#{pagy_t 'pagy.nav.gap'}</a></li>),
|
38
39
|
'after' => %(#{pagy_materialize_next_html pagy, link}</ul>) }
|
39
40
|
|
40
|
-
%(<div#{p_id} class="pagy-
|
41
|
-
pagy_json_attr(pagy, :nav, tags,
|
41
|
+
%(<div#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-materialize-nav-js" role="navigation" aria-label="pager" #{
|
42
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></div>)
|
42
43
|
end
|
43
44
|
|
44
45
|
# Javascript combo pagination for materialize: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -53,7 +54,7 @@ class Pagy # :nodoc:
|
|
53
54
|
|
54
55
|
html = %(<ul#{p_id} class="pagy-materialize-combo-nav-js pagination chip" role="navigation")
|
55
56
|
%(#{html} aria-label="pager" style="padding-right: 0" #{
|
56
|
-
pagy_json_attr pagy, :combo_nav,
|
57
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
|
57
58
|
pagy_materialize_prev_html pagy, link, style}<li class="pagy-combo-input">#{
|
58
59
|
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}</li>#{
|
59
60
|
pagy_materialize_next_html pagy, link, style}</ul>)
|
data/lib/pagy/extras/navs.rb
CHANGED
@@ -9,6 +9,7 @@ class Pagy # :nodoc:
|
|
9
9
|
module NavsExtra
|
10
10
|
# Javascript pagination: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
11
11
|
def pagy_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
12
|
+
sequels = pagy.sequels(**vars)
|
12
13
|
p_id = %( id="#{pagy_id}") if pagy_id
|
13
14
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
14
15
|
tags = { 'before' => pagy_nav_prev_html(pagy, link),
|
@@ -17,8 +18,8 @@ class Pagy # :nodoc:
|
|
17
18
|
'gap' => %(<span class="page gap">#{pagy_t 'pagy.nav.gap'}</span> ),
|
18
19
|
'after' => pagy_nav_next_html(pagy, link) }
|
19
20
|
|
20
|
-
%(<nav#{p_id} class="pagy-
|
21
|
-
pagy_json_attr(pagy, :nav, tags,
|
21
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-nav-js pagination" aria-label="pager" #{
|
22
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
22
23
|
end
|
23
24
|
|
24
25
|
# Javascript combo pagination: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -31,7 +32,7 @@ class Pagy # :nodoc:
|
|
31
32
|
p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem;">)
|
32
33
|
|
33
34
|
%(<nav#{p_id} class="pagy-combo-nav-js pagination" aria-label="pager" #{
|
34
|
-
pagy_json_attr pagy, :combo_nav,
|
35
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
|
35
36
|
pagy_nav_prev_html pagy, link
|
36
37
|
}<span class="pagy-combo-input" style="margin: 0 0.6rem;">#{
|
37
38
|
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
|
data/lib/pagy/extras/semantic.rb
CHANGED
@@ -28,6 +28,7 @@ class Pagy # :nodoc:
|
|
28
28
|
|
29
29
|
# Javascript pagination for semantic: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
30
30
|
def pagy_semantic_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
31
|
+
sequels = pagy.sequels(**vars)
|
31
32
|
p_id = %( id="#{pagy_id}") if pagy_id
|
32
33
|
link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}))
|
33
34
|
tags = { 'before' => pagy_semantic_prev_html(pagy, link),
|
@@ -36,8 +37,8 @@ class Pagy # :nodoc:
|
|
36
37
|
'gap' => %(<div class="disabled item">#{pagy_t('pagy.nav.gap')}</div>),
|
37
38
|
'after' => pagy_semantic_next_html(pagy, link) }
|
38
39
|
|
39
|
-
%(<div#{p_id} class="pagy-
|
40
|
-
pagy_json_attr(pagy, :nav, tags,
|
40
|
+
%(<div#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-semantic-nav-js ui pagination menu" role="navigation" #{
|
41
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></div>)
|
41
42
|
end
|
42
43
|
|
43
44
|
# Combo pagination for semantic: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -50,7 +51,7 @@ class Pagy # :nodoc:
|
|
50
51
|
p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem; margin: 0 0.3rem">)
|
51
52
|
|
52
53
|
%(<div#{p_id} class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" #{
|
53
|
-
pagy_json_attr pagy, :combo_nav,
|
54
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)}>#{
|
54
55
|
pagy_semantic_prev_html pagy, link
|
55
56
|
}<div class="pagy-combo-input item">#{
|
56
57
|
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
|
data/lib/pagy/extras/uikit.rb
CHANGED
@@ -27,6 +27,7 @@ class Pagy # :nodoc:
|
|
27
27
|
|
28
28
|
# Javascript pagination for uikit: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
29
29
|
def pagy_uikit_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
30
|
+
sequels = pagy.sequels(**vars)
|
30
31
|
p_id = %( id="#{pagy_id}") if pagy_id
|
31
32
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
32
33
|
tags = { 'before' => pagy_uikit_prev_html(pagy, link),
|
@@ -35,8 +36,8 @@ class Pagy # :nodoc:
|
|
35
36
|
'gap' => %(<li class="uk-disabled"><span>#{pagy_t 'pagy.nav.gap'}</span></li>),
|
36
37
|
'after' => pagy_uikit_next_html(pagy, link) }
|
37
38
|
|
38
|
-
%(<ul#{p_id} class="pagy-
|
39
|
-
pagy_json_attr(pagy, :nav, tags,
|
39
|
+
%(<ul#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-uikit-nav-js uk-pagination uk-flex-center" #{
|
40
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></ul>)
|
40
41
|
end
|
41
42
|
|
42
43
|
# Javascript combo pagination for uikit: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
|
@@ -49,7 +50,7 @@ class Pagy # :nodoc:
|
|
49
50
|
p_page}" style="text-align: center; width: #{p_pages.to_s.length + 1}rem;">)
|
50
51
|
|
51
52
|
%(<ul#{p_id} class="pagy-uikit-combo-nav-js uk-button-group uk-pagination uk-flex-center" #{
|
52
|
-
pagy_json_attr pagy, :combo_nav,
|
53
|
+
pagy_json_attr pagy, :combo_nav, pagy_marked_link(link)
|
53
54
|
}>#{
|
54
55
|
pagy_uikit_prev_html pagy, link
|
55
56
|
}<li>#{
|
data/lib/pagy.rb
CHANGED
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: 5.
|
4
|
+
version: 5.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|