pagy 5.7.0 → 5.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dff2343464e636499952ed82e91f9691f8855630a77d6bcfffee985ae7ff443f
4
- data.tar.gz: 6659996eb14375576d033ab5da3faaead938e9145b67fba2e625aa2b91a3a4a1
3
+ metadata.gz: 4f7ef3c45fb44b6427e511d09b5f19594fb13cfc7cc9f251e87dd48a6e9ecc85
4
+ data.tar.gz: 82d248fcb0d28951940fde7bdbe07a01aa027fd24b67b52d08ba33a1c3520dc9
5
5
  SHA512:
6
- metadata.gz: b404bb256a2070c382f536a007972cce2fcfad6a22010221194a043dba3fee525a86c00a85ea7b2a8f93da5882f8651752b7dd6f2a99a5a5038094445c5c7e79
7
- data.tar.gz: 8c5263db5dd2d2cec869236fd37bcdfed67dc68c643fba2c520677829c6adc22dbd5eba88e36ba3014b2dd71466f9f102b1c5b88a3cf99a2c56add4b4f88cd17
6
+ metadata.gz: 356a47a45a5390f236488e02e434e4eb0672be73a0933dd5dd2505c2641d9f340eb4cb4a8bf081add014bc96d335d5febc80537f1ac480e25fba2598ad092d6a
7
+ data.tar.gz: ad0f24ec5e7acd68d39a4984b0b4e424d1707ceab71a14f67c081afab792facd931424a2f97cfe1ae7cde4dd87a61a50cb60ecc65a374809bed7be248afda6a8
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (5.7.0)
3
+ # Pagy initializer file (5.7.1)
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
 
@@ -1,3 +1,3 @@
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&")),"")}};
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.1",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,d=_slicedToArray(b,4),e=d[0],f=d[1],g=d[2],h=d[3],container=null!==(c=a.parentElement)&&void 0!==c?c:a,j=Object.getOwnPropertyNames(f).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,c=j.find(function(a){return a<container.clientWidth})||0;if(c!==k){var d=e.before,m=f[c.toString()],n=null!==(b=null===g||void 0===g?void 0:g[c.toString()])&&void 0!==b?b:m.map(function(a){return a.toString()});for(var q in m){var o=m[q],p=n[q];d+="string"==typeof h&&1===o?Pagy.trim(l(e.link,o.toString(),p),h):"number"==typeof o?l(e.link,o.toString(),p):"gap"===o?e.gap:l(e.active,o,p)}d+=e.after,a.innerHTML="",a.insertAdjacentHTML("afterbegin",d),k=c}})(),a.classList.contains("pagy-rjs")&&Pagy.rjsObserver.observe(container)},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];Pagy.initInput(a,function(a){return[a,d.replace(/__pagy_page__/,a)]},e)},initItemsSelector:function initItemsSelector(a,b){var c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2];Pagy.initInput(a,function(a){var b=Math.max(Math.ceil(d/parseInt(a)),1).toString(),c=e.replace(/__pagy_page__/,b).replace(/__pagy_items__/,a);return[b,c]},f)},initInput:function initInput(a,b,c){var d=a.querySelector("input"),e=d.value,f=function(){if(d.value!==e){var f=[d.min,d.value,d.max].map(function(a){return parseInt(a)||0}),g=_slicedToArray(f,3),h=g[0],i=g[1],j=g[2];if(i<h||i>j)return d.value=e,void d.select();var k=b(d.value),l=_slicedToArray(k,2),m=l[0],n=l[1];"string"==typeof c&&"1"===m&&(n=Pagy.trim(n,c)),a.insertAdjacentHTML("afterbegin",n),a.querySelector("a").click()}};["change","focus"].forEach(function(a){return d.addEventListener(a,d.select)}),d.addEventListener("focusout",f),d.addEventListener("keypress",function(a){"Enter"===a.key&&f()})},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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pagy.ts"],"names":[],"mappings":"8mEAsBA,GAAM,CAAA,IAAI,CAAG,CACT,OAAO,CAAE,OADA,CAIT,IAJS,eAIJ,CAJI,CAIgB,OACf,CAAM,CAAK,CAAG,WAAY,CAAA,OAAf,CAAyB,CAAzB,CAA+B,QAD3B,CAEf,CAAQ,CAAG,CAAM,CAAC,gBAAP,CAAwB,kBAAxB,CAFI,CAGf,CAAI,CAAO,SAAC,CAAD,CAAa,CAAb,QAA6B,CAAA,OAAO,CAAC,IAAR,CAAa,qCAAb,CAAoD,CAApD,CAAwD,CAAxD,CAA7B,CAHI,8BAIC,CAJD,MAIrB,2BAAgC,IAArB,CAAA,CAAqB,SACtB,CAAI,CAAG,CAAO,CAAC,YAAR,CAAqB,gBAArB,CADe,CAE5B,GAAI,CACA,MAA2B,IAAI,CAAC,KAAL,CAAW,CAAX,CAA3B,eAAO,CAAP,MAAmB,CAAnB,YACgB,KAAZ,GAAA,CAFJ,CAGI,IAAI,CAAC,OAAL,CAAa,CAAb,CAAsB,CAAtB,CAHJ,CAIuB,WAAZ,GAAA,CAJX,CAKI,IAAI,CAAC,YAAL,CAAkB,CAAlB,CAA2B,CAA3B,CALJ,CAMuB,gBAAZ,GAAA,CANX,CAOI,IAAI,CAAC,iBAAL,CAAuB,CAAvB,CAAgC,CAAhC,CAPJ,CASI,CAAI,CAAC,CAAD,6FAAwF,CAAxF,OAEX,CAAC,MAAO,CAAP,CAAY,CAAE,CAAI,CAAC,CAAD,CAAU,CAAV,CAAgB,CACvC,CAlBoB,+BAmBxB,CAvBQ,CA0BT,OA1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AxC,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"]}
1
+ {"version":3,"sources":["../../src/pagy.ts"],"names":[],"mappings":"8mEAsBA,GAAM,CAAA,IAAI,CAAG,CACT,OAAO,CAAE,OADA,CAIT,IAJS,eAIJ,CAJI,CAIgB,OACf,CAAM,CAAK,CAAG,WAAY,CAAA,OAAf,CAAyB,CAAzB,CAA+B,QAD3B,CAEf,CAAQ,CAAG,CAAM,CAAC,gBAAP,CAAwB,kBAAxB,CAFI,CAGf,CAAI,CAAO,SAAC,CAAD,CAAa,CAAb,QAA6B,CAAA,OAAO,CAAC,IAAR,CAAa,qCAAb,CAAoD,CAApD,CAAwD,CAAxD,CAA7B,CAHI,8BAIC,CAJD,MAIrB,2BAAgC,IAArB,CAAA,CAAqB,SACtB,CAAI,CAAG,CAAO,CAAC,YAAR,CAAqB,gBA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,CAAxC,QAAb,CAAkE,EAAlE,CAA/B,CAvGG,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.1\",\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 = (link:string, page:string, label:string):string =>\n link.replace(/__pagy_page__/g, page).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?.[width.toString()] ?? series.map(l => l.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 html += Pagy.trim(fillIn(tags.link, item.toString(), label), 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; // eslint-disable-line align-assignments/align-assignments\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 Pagy.initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);\n },\n\n // Init the items_selector_js helper\n initItemsSelector(el:Element, [from, link, trimParam]:ItemsSelectorArgs) {\n Pagy.initInput(el, inputValue => {\n const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();\n const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);\n return [page, html];\n }, trimParam);\n },\n\n // Init the input element\n initInput(el:Element, getVars:(v:string)=>[string, string], trimParam?:string) {\n const input = el.querySelector(\"input\") as HTMLInputElement;\n const initial = input.value;\n const action = function() {\n if (input.value === initial) { return } // not changed\n const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);\n if (val < min || val > max) { // reset invalid/out-of-range\n input.value = initial;\n input.select();\n return;\n }\n let [page, html] = getVars(input.value); // eslint-disable-line prefer-const\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 [\"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 // 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"]}
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # Core class
7
7
  class Pagy
8
- VERSION = '5.7.0'
8
+ VERSION = '5.7.1'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
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.7.0
4
+ version: 5.7.1
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-07 00:00:00.000000000 Z
11
+ date: 2022-01-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
14
  email: