@inc2734/unitone-css 0.68.1 → 0.68.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -1
- package/dist/library.js +1 -1
- package/package.json +1 -1
- package/src/app.js +40 -30
- package/src/library.js +63 -50
package/dist/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t={};var n=function(){if(e)return t;function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function o(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e))||t){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}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 l,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,l=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw l}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}e=1;var l=function(e){var t=parseFloat(window.getComputedStyle(document.documentElement).getPropertyValue("font-size")),n=parseFloat(window.getComputedStyle(e).getPropertyValue("font-size"));e.style.setProperty("--unitone--fluid-font-size-magnification",n/t)},u=function(e){var t,n,o,i=null===(t=[].slice.call(null!==(n=null==e?void 0:e.children)&&void 0!==n?n:[]))||void 0===t?void 0:t[0];i&&(console.log("setDividerLinewrap"),console.log(e),[].slice.call(e.children).forEach((function(e){if(e.classList.contains("unitone-empty"))e.remove();else{var t=e.getAttribute("data-unitone-layout")||"",n=t.split(" ").filter((function(e){return!["-bol","-linewrap"," "].includes(e)})).join(" ");n!==t&&e.setAttribute("data-unitone-layout",n)}})),[].slice.call(e.children).forEach((function(e){var t,n=i.getBoundingClientRect(),r=null===(t=o)||void 0===t?void 0:t.getBoundingClientRect(),l=e.getBoundingClientRect(),u=e.getAttribute("data-unitone-layout")||"",a=u.split(" ");if((i===e||(null==r?void 0:r.top)<l.top&&(null==r?void 0:r.left)>=l.left)&&(a.includes("-bol")||a.push("-bol")),(null==r?void 0:r.top)<l.top){var d=document.createElement("div");d.classList.add("unitone-empty"),e.before(d),(null==r?void 0:r.top)<d.getBoundingClientRect().top&&d.remove()}n.top<l.top&&(a.includes("-linewrap")||a.push("-linewrap")),a!==u&&e.setAttribute("data-unitone-layout",a.filter(Boolean).join(" ")||""),o=e})))},a=function(e){var t,n,o,i=[].slice.call(e.children),r=null==i?void 0:i[0];if(r){e.style.removeProperty("--unitone--stairs-step-overflow-volume"),e.style.removeProperty("--unitone--max-stairs-step"),[].slice.call(null!==(t=null==e?void 0:e.children)&&void 0!==t?t:[]).forEach((function(e){e.style.removeProperty("--unitone--stairs-step")}));var l,u=e.getBoundingClientRect(),a=[],d=0,s=d;i.forEach((function(e){var t,n=window.getComputedStyle(e).getPropertyValue("position"),o=window.getComputedStyle(e).getPropertyValue("display");"absolute"!==n&&"fixed"!==n&&"none"!==o&&(a.push(e),r===e||(null===(t=l)||void 0===t||null===(t=t.getBoundingClientRect())||void 0===t?void 0:t.left)>=e.getBoundingClientRect().left?(d=0,e.style.setProperty("--unitone--stairs-step",d)):(d++,e.style.setProperty("--unitone--stairs-step",d)),l=e,d>s&&(s=d))})),e.style.setProperty("--unitone--max-stairs-step",s);var c=a.reduce((function(e,t){var n=null!=e&&e.childrenTop?Math.min(null==e?void 0:e.childrenTop,t.getBoundingClientRect().top):t.getBoundingClientRect().top,o=t.getBoundingClientRect().bottom-n;return{childrenTop:n,childrenHeight:Math.max(null==e?void 0:e.childrenHeight,o)}}),{childrenTop:null==a||null===(n=a[0])||void 0===n||null===(n=n.getBoundingClientRect())||void 0===n?void 0:n.top,childrenHeight:null==a||null===(o=a[0])||void 0===o||null===(o=o.getBoundingClientRect())||void 0===o?void 0:o.height}).childrenHeight;e.style.setProperty("--unitone--stairs-step-overflow-volume",c-u.height)}},d=function(e){e.style.columnCount="",e.setAttribute("data-unitone-layout",e.getAttribute("data-unitone-layout").replace(" -force-switch",""));var t,n=getComputedStyle(e);if(String(n.getPropertyValue("--unitone--threshold")).trim()){var o=document.createElement("div");o.setAttribute("data-unitone-layout","vertical-writing__thresholder"),e.appendChild(o);var i=o.offsetWidth>=e.offsetWidth;if(e.removeChild(o),i)return void e.setAttribute("data-unitone-layout","".concat(e.getAttribute("data-unitone-layout")," -force-switch"))}if([].slice.call(e.children).reverse().some((function(e){if(!["absolute","fixed"].includes(getComputedStyle(e).position)&&"none"!==getComputedStyle(e).display)return t=e,!0})),t){var r=!1;e.getBoundingClientRect().left>t.getBoundingClientRect().left&&(e.style.columnCount=2,r=!0),setTimeout((function(){var n=e.getBoundingClientRect().top+e.getBoundingClientRect().height,o=t.getBoundingClientRect().top+t.getBoundingClientRect().height;n!==o&&(e.parentNode.style.height="".concat(Math.ceil(o-e.getBoundingClientRect().top),"px"))}),r?250:0)}};return t.dividersResizeObserver=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,r=new ResizeObserver((function(e){requestAnimationFrame((function(){var t,o=i(e);try{for(o.s();!(t=o.n()).done;){var r,l=t.value,a=null===(r=l.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;a!==n&&(console.log("ResizeObserver"),console.log(l.target),u(l.target),n=a)}}catch(e){o.e(e)}finally{o.f()}}))})),l=new MutationObserver((function(n){var r,l=i(n);try{var a=function(){var n=r.value;if("attributes"===n.type&&"data-unitone-layout"===n.attributeName){var i,l,a,d,s=[].concat(o(null!==(i=null==t||null===(l=t.ignore)||void 0===l?void 0:l.layout)&&void 0!==i?i:[]),["-bol","-linewrap"]);(null!==(a=n.target.getAttribute(n.attributeName))&&void 0!==a?a:"").split(" ").filter((function(e){return!s.includes(e)})).join(" ")!==(null!==(d=n.oldValue)&&void 0!==d?d:"").split(" ").filter((function(e){return!s.includes(e)})).join(" ")&&(console.log("MutationObserver"),console.log(n.target),u(e))}else if("attributes"===n.type&&"class"===n.attributeName){var c,v,f,y,g=o(null!==(c=null==t||null===(v=t.ignore)||void 0===v?void 0:v.className)&&void 0!==c?c:["unitone-empty"]);(null!==(f=n.target.getAttribute(n.attributeName))&&void 0!==f?f:"").split(" ").filter((function(e){return!g.includes(e)})).join(" ")!==(null!==(y=n.oldValue)&&void 0!==y?y:"").split(" ").filter((function(e){return!g.includes(e)})).join(" ")&&(console.log("MutationObserver 2"),console.log(n.target),u(e))}else"attributes"===n.type&&"style"===n.attributeName&&(console.log("MutationObserver 3"),console.log(n.target),u(e))};for(l.s();!(r=l.n()).done;)a()}catch(e){l.e(e)}finally{l.f()}}));return r.observe(e),l.observe(e,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:r,mutationObserver:l}},t.fluidFontSizeResizeObserver=function(e){var t=0;new ResizeObserver((function(e){requestAnimationFrame((function(){var n,o=i(e);try{for(o.s();!(n=o.n()).done;){var r,u=n.value,a=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;a!==t&&(l(u.target),t=a)}}catch(e){o.e(e)}finally{o.f()}}))})).observe(e)},t.setDividerLinewrap=u,t.setStairsStep=a,t.stairsResizeObserver=function(e){var t=0,n=new ResizeObserver((function(e){requestAnimationFrame((function(){var n,o=i(e);try{for(o.s();!(n=o.n()).done;){var r,l=n.value,u=null===(r=l.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;u!==t&&(a(l.target),t=u)}}catch(e){o.e(e)}finally{o.f()}}))}));return n.observe(e),n},t.verticalsResizeObserver=function(e){var t=0;e.setAttribute("data-unitone-layout","".concat(e.getAttribute("data-unitone-layout")," -initialized"));var n=new ResizeObserver((function(e){requestAnimationFrame((function(){var n,o=i(e);try{for(o.s();!(n=o.n()).done;){var r,l=n.value,u=null===(r=l.contentRect)||void 0===r?void 0:r.width;parseInt(u)!==parseInt(t)&&(t=u,l.target.parentNode.style.height="",d(l.target))}}catch(e){o.e(e)}finally{o.f()}}))}));n.observe(e);var o=new MutationObserver((function(t){requestAnimationFrame((function(){if(0<t.length){var n,o,i=t[0],r=null===(n=i.addedNodes)||void 0===n?void 0:n[0],l=null===(o=i.removedNodes)||void 0===o?void 0:o[0];if((null==r?void 0:r.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===r.getAttribute("data-unitone-layout")||(null==l?void 0:l.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===l.getAttribute("data-unitone-layout"))return;d(e)}}))}));return o.observe(e,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:n,mutationObserver:o}},t}();document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){var t,o=null===(t=e.parentNode)||void 0===t?void 0:t.querySelectorAll('[data-unitone-layout~="-fluid-typography"]');null==o||o.forEach((function(e){n.fluidFontSizeResizeObserver(e)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){var t,o=null===(t=e.parentNode)||void 0===t?void 0:t.querySelectorAll('[data-unitone-layout*="-divider:"]');null==o||o.forEach((function(e){n.dividersResizeObserver(e)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){var t,o=null===(t=e.parentNode)||void 0===t?void 0:t.querySelectorAll('[data-unitone-layout*="-stairs:"]');null==o||o.forEach((function(e){n.stairsResizeObserver(e)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){var t,o=null===(t=e.parentNode)||void 0===t?void 0:t.querySelectorAll('[data-unitone-layout~="vertical-writing"]');null==o||o.forEach((function(e){n.verticalsResizeObserver(e)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})}));
|
|
1
|
+
"use strict";var t,e={};var n=function(){if(t)return e;function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function r(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}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 l,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,l=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw l}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function l(t,e){var n,r=this;return function(){for(var i=arguments.length,o=new Array(i),l=0;l<i;l++)o[l]=arguments[l];clearTimeout(n),n=setTimeout((function(){t.apply(r,o)}),e)}}t=1;var a=function(t){var e=parseFloat(window.getComputedStyle(document.documentElement).getPropertyValue("font-size")),n=parseFloat(window.getComputedStyle(t).getPropertyValue("font-size"));t.style.setProperty("--unitone--fluid-font-size-magnification",n/e)},u=function(t){var e,n,r,i=null===(e=[].slice.call(null!==(n=null==t?void 0:t.children)&&void 0!==n?n:[]))||void 0===e?void 0:e[0];i&&([].slice.call(t.children).forEach((function(t){if(t.classList.contains("unitone-empty"))t.remove();else{var e=t.getAttribute("data-unitone-layout")||"",n=e.split(" ").filter((function(t){return!["-bol","-linewrap"," "].includes(t)})).join(" ");n!==e&&t.setAttribute("data-unitone-layout",n)}})),[].slice.call(t.children).forEach((function(t){var e,n=i.getBoundingClientRect(),o=null===(e=r)||void 0===e?void 0:e.getBoundingClientRect(),l=t.getBoundingClientRect(),a=t.getAttribute("data-unitone-layout")||"",u=a.split(" ");if((i===t||(null==o?void 0:o.top)<l.top&&(null==o?void 0:o.left)>=l.left)&&(u.includes("-bol")||u.push("-bol")),(null==o?void 0:o.top)<l.top){var d=document.createElement("div");d.classList.add("unitone-empty"),t.before(d),(null==o?void 0:o.top)<d.getBoundingClientRect().top&&d.remove()}n.top<l.top&&(u.includes("-linewrap")||u.push("-linewrap")),u!==a&&t.setAttribute("data-unitone-layout",u.filter(Boolean).join(" ")||""),r=t})))},d=function(t){var e,n,r,i=[].slice.call(t.children),o=null==i?void 0:i[0];if(o){t.style.removeProperty("--unitone--stairs-step-overflow-volume"),t.style.removeProperty("--unitone--max-stairs-step"),[].slice.call(null!==(e=null==t?void 0:t.children)&&void 0!==e?e:[]).forEach((function(t){t.style.removeProperty("--unitone--stairs-step")}));var l,a=t.getBoundingClientRect(),u=[],d=0,c=d;i.forEach((function(t){var e,n=window.getComputedStyle(t).getPropertyValue("position"),r=window.getComputedStyle(t).getPropertyValue("display");"absolute"!==n&&"fixed"!==n&&"none"!==r&&(u.push(t),o===t||(null===(e=l)||void 0===e||null===(e=e.getBoundingClientRect())||void 0===e?void 0:e.left)>=t.getBoundingClientRect().left?(d=0,t.style.setProperty("--unitone--stairs-step",d)):(d++,t.style.setProperty("--unitone--stairs-step",d)),l=t,d>c&&(c=d))})),t.style.setProperty("--unitone--max-stairs-step",c);var s=u.reduce((function(t,e){var n=null!=t&&t.childrenTop?Math.min(null==t?void 0:t.childrenTop,e.getBoundingClientRect().top):e.getBoundingClientRect().top,r=e.getBoundingClientRect().bottom-n;return{childrenTop:n,childrenHeight:Math.max(null==t?void 0:t.childrenHeight,r)}}),{childrenTop:null==u||null===(n=u[0])||void 0===n||null===(n=n.getBoundingClientRect())||void 0===n?void 0:n.top,childrenHeight:null==u||null===(r=u[0])||void 0===r||null===(r=r.getBoundingClientRect())||void 0===r?void 0:r.height}).childrenHeight;t.style.setProperty("--unitone--stairs-step-overflow-volume",s-a.height)}},c=function(t){t.style.columnCount="",t.setAttribute("data-unitone-layout",t.getAttribute("data-unitone-layout").replace(" -force-switch",""));var e,n=getComputedStyle(t);if(String(n.getPropertyValue("--unitone--threshold")).trim()){var r=document.createElement("div");r.setAttribute("data-unitone-layout","vertical-writing__thresholder"),t.appendChild(r);var i=r.offsetWidth>=t.offsetWidth;if(t.removeChild(r),i)return void t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -force-switch"))}if([].slice.call(t.children).reverse().some((function(t){if(!["absolute","fixed"].includes(getComputedStyle(t).position)&&"none"!==getComputedStyle(t).display)return e=t,!0})),e){var o=!1;t.getBoundingClientRect().left>e.getBoundingClientRect().left&&(t.style.columnCount=2,o=!0),setTimeout((function(){var n=t.getBoundingClientRect().top+t.getBoundingClientRect().height,r=e.getBoundingClientRect().top+e.getBoundingClientRect().height;n!==r&&(t.parentNode.style.height="".concat(Math.ceil(r-t.getBoundingClientRect().top),"px"))}),o?250:0)}};return e.debounce=l,e.dividersResizeObserver=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,o=new ResizeObserver(l((function(t){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){var o,l=e.value,a=null===(o=l.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;a!==n&&(u(l.target),n=a)}}catch(t){r.e(t)}finally{r.f()}}),250)),a=new MutationObserver((function(n){requestAnimationFrame((function(){var o,l=i(n);try{var a=function(){var n=o.value;if("attributes"===n.type&&"data-unitone-layout"===n.attributeName){var i,l,a,d,c=[].concat(r(null!==(i=null==e||null===(l=e.ignore)||void 0===l?void 0:l.layout)&&void 0!==i?i:[]),["-bol","-linewrap"]);(null!==(a=n.target.getAttribute(n.attributeName))&&void 0!==a?a:"").split(" ").filter((function(t){return!c.includes(t)})).join(" ")!==(null!==(d=n.oldValue)&&void 0!==d?d:"").split(" ").filter((function(t){return!c.includes(t)})).join(" ")&&u(t)}else if("attributes"===n.type&&"class"===n.attributeName){var s,f,v,y,p=r(null!==(s=null==e||null===(f=e.ignore)||void 0===f?void 0:f.className)&&void 0!==s?s:["unitone-empty"]);(null!==(v=n.target.getAttribute(n.attributeName))&&void 0!==v?v:"").split(" ").filter((function(t){return!p.includes(t)})).join(" ")!==(null!==(y=n.oldValue)&&void 0!==y?y:"").split(" ").filter((function(t){return!p.includes(t)})).join(" ")&&u(t)}else"attributes"===n.type&&"style"===n.attributeName&&u(t)};for(l.s();!(o=l.n()).done;)a()}catch(t){l.e(t)}finally{l.f()}}))}));return o.observe(t),a.observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:o,mutationObserver:a}},e.fluidFontSizeResizeObserver=function(t){var e=0;new ResizeObserver(l((function(t){var n,r=i(t);try{for(r.s();!(n=r.n()).done;){var o,l=n.value,u=null===(o=l.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;u!==e&&(a(l.target),e=u)}}catch(t){r.e(t)}finally{r.f()}}),250)).observe(t)},e.setDividerLinewrap=u,e.setStairsStep=d,e.stairsResizeObserver=function(t){var e=0,n=new ResizeObserver(l((function(t){var n,r=i(t);try{for(r.s();!(n=r.n()).done;){var o,l=n.value,a=null===(o=l.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;a!==e&&(d(l.target),e=a)}}catch(t){r.e(t)}finally{r.f()}}),250));return n.observe(t),n},e.throttle=function(t,e){var n=this,r=Date.now()-e;return function(){if(r+e<Date.now()){r=Date.now();for(var i=arguments.length,o=new Array(i),l=0;l<i;l++)o[l]=arguments[l];t.apply(n,o)}}},e.verticalsResizeObserver=function(t){var e=0;t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -initialized"));var n=new ResizeObserver(l((function(t){var n,r=i(t);try{for(r.s();!(n=r.n()).done;){var o,l=n.value,a=null===(o=l.contentRect)||void 0===o?void 0:o.width;parseInt(a)!==parseInt(e)&&(e=a,l.target.parentNode.style.height="",c(l.target))}}catch(t){r.e(t)}finally{r.f()}}),250));n.observe(t);var r=new MutationObserver((function(e){requestAnimationFrame((function(){if(0<e.length){var n,r,i=e[0],o=null===(n=i.addedNodes)||void 0===n?void 0:n[0],l=null===(r=i.removedNodes)||void 0===r?void 0:r[0];if((null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===o.getAttribute("data-unitone-layout")||(null==l?void 0:l.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===l.getAttribute("data-unitone-layout"))return;c(t)}}))}));return r.observe(t,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:n,mutationObserver:r}},e}();function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}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 l,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,l=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw l}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,i=r(t);try{for(i.s();!(e=i.n()).done;){e.value.addedNodes.forEach((function(t){var e,r=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout~="-fluid-typography"]');null==r||r.forEach((function(t){n.fluidFontSizeResizeObserver(t)}))}))}}catch(t){i.e(t)}finally{i.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,i=r(t);try{for(i.s();!(e=i.n()).done;){e.value.addedNodes.forEach((function(t){var e,r=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout*="-divider:"]');null==r||r.forEach((function(t){n.dividersResizeObserver(t)}))}))}}catch(t){i.e(t)}finally{i.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,i=r(t);try{for(i.s();!(e=i.n()).done;){e.value.addedNodes.forEach((function(t){var e,r=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout*="-stairs:"]');null==r||r.forEach((function(t){n.stairsResizeObserver(t)}))}))}}catch(t){i.e(t)}finally{i.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,i=r(t);try{for(i.s();!(e=i.n()).done;){e.value.addedNodes.forEach((function(t){var e,r=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout~="vertical-writing"]');null==r||r.forEach((function(t){n.verticalsResizeObserver(t)}))}))}}catch(t){i.e(t)}finally{i.f()}}))})).observe(document.body,{childList:!0,subtree:!0})}));
|
package/dist/library.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t))||e){n&&(t=n);var
|
|
1
|
+
"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t))||e){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}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 l,u=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){a=!0,l=t},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw l}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function r(t,e){var n,i=this;return function(){for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];clearTimeout(n),n=setTimeout((function(){t.apply(i,o)}),e)}}var o=function(t){var e=parseFloat(window.getComputedStyle(document.documentElement).getPropertyValue("font-size")),n=parseFloat(window.getComputedStyle(t).getPropertyValue("font-size"));t.style.setProperty("--unitone--fluid-font-size-magnification",n/e)},l=function(t){var e,n,i,r=null===(e=[].slice.call(null!==(n=null==t?void 0:t.children)&&void 0!==n?n:[]))||void 0===e?void 0:e[0];r&&([].slice.call(t.children).forEach((function(t){if(t.classList.contains("unitone-empty"))t.remove();else{var e=t.getAttribute("data-unitone-layout")||"",n=e.split(" ").filter((function(t){return!["-bol","-linewrap"," "].includes(t)})).join(" ");n!==e&&t.setAttribute("data-unitone-layout",n)}})),[].slice.call(t.children).forEach((function(t){var e,n=r.getBoundingClientRect(),o=null===(e=i)||void 0===e?void 0:e.getBoundingClientRect(),l=t.getBoundingClientRect(),u=t.getAttribute("data-unitone-layout")||"",a=u.split(" ");if((r===t||(null==o?void 0:o.top)<l.top&&(null==o?void 0:o.left)>=l.left)&&(a.includes("-bol")||a.push("-bol")),(null==o?void 0:o.top)<l.top){var s=document.createElement("div");s.classList.add("unitone-empty"),t.before(s),(null==o?void 0:o.top)<s.getBoundingClientRect().top&&s.remove()}n.top<l.top&&(a.includes("-linewrap")||a.push("-linewrap")),a!==u&&t.setAttribute("data-unitone-layout",a.filter(Boolean).join(" ")||""),i=t})))},u=function(t){var e,n,i,r=[].slice.call(t.children),o=null==r?void 0:r[0];if(o){t.style.removeProperty("--unitone--stairs-step-overflow-volume"),t.style.removeProperty("--unitone--max-stairs-step"),[].slice.call(null!==(e=null==t?void 0:t.children)&&void 0!==e?e:[]).forEach((function(t){t.style.removeProperty("--unitone--stairs-step")}));var l,u=t.getBoundingClientRect(),a=[],s=0,d=s;r.forEach((function(t){var e,n=window.getComputedStyle(t).getPropertyValue("position"),i=window.getComputedStyle(t).getPropertyValue("display");"absolute"!==n&&"fixed"!==n&&"none"!==i&&(a.push(t),o===t||(null===(e=l)||void 0===e||null===(e=e.getBoundingClientRect())||void 0===e?void 0:e.left)>=t.getBoundingClientRect().left?(s=0,t.style.setProperty("--unitone--stairs-step",s)):(s++,t.style.setProperty("--unitone--stairs-step",s)),l=t,s>d&&(d=s))})),t.style.setProperty("--unitone--max-stairs-step",d);var c=a.reduce((function(t,e){var n=null!=t&&t.childrenTop?Math.min(null==t?void 0:t.childrenTop,e.getBoundingClientRect().top):e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom-n;return{childrenTop:n,childrenHeight:Math.max(null==t?void 0:t.childrenHeight,i)}}),{childrenTop:null==a||null===(n=a[0])||void 0===n||null===(n=n.getBoundingClientRect())||void 0===n?void 0:n.top,childrenHeight:null==a||null===(i=a[0])||void 0===i||null===(i=i.getBoundingClientRect())||void 0===i?void 0:i.height}).childrenHeight;t.style.setProperty("--unitone--stairs-step-overflow-volume",c-u.height)}},a=function(t){t.style.columnCount="",t.setAttribute("data-unitone-layout",t.getAttribute("data-unitone-layout").replace(" -force-switch",""));var e,n=getComputedStyle(t);if(String(n.getPropertyValue("--unitone--threshold")).trim()){var i=document.createElement("div");i.setAttribute("data-unitone-layout","vertical-writing__thresholder"),t.appendChild(i);var r=i.offsetWidth>=t.offsetWidth;if(t.removeChild(i),r)return void t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -force-switch"))}if([].slice.call(t.children).reverse().some((function(t){if(!["absolute","fixed"].includes(getComputedStyle(t).position)&&"none"!==getComputedStyle(t).display)return e=t,!0})),e){var o=!1;t.getBoundingClientRect().left>e.getBoundingClientRect().left&&(t.style.columnCount=2,o=!0),setTimeout((function(){var n=t.getBoundingClientRect().top+t.getBoundingClientRect().height,i=e.getBoundingClientRect().top+e.getBoundingClientRect().height;n!==i&&(t.parentNode.style.height="".concat(Math.ceil(i-t.getBoundingClientRect().top),"px"))}),o?250:0)}};exports.debounce=r,exports.dividersResizeObserver=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=0,u=new ResizeObserver(r((function(t){var e,i=n(t);try{for(i.s();!(e=i.n()).done;){var r,u=e.value,a=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;a!==o&&(l(u.target),o=a)}}catch(t){i.e(t)}finally{i.f()}}),250)),a=new MutationObserver((function(r){requestAnimationFrame((function(){var o,u=n(r);try{var a=function(){var n=o.value;if("attributes"===n.type&&"data-unitone-layout"===n.attributeName){var r,u,a,s,d=[].concat(e(null!==(r=null==i||null===(u=i.ignore)||void 0===u?void 0:u.layout)&&void 0!==r?r:[]),["-bol","-linewrap"]);(null!==(a=n.target.getAttribute(n.attributeName))&&void 0!==a?a:"").split(" ").filter((function(t){return!d.includes(t)})).join(" ")!==(null!==(s=n.oldValue)&&void 0!==s?s:"").split(" ").filter((function(t){return!d.includes(t)})).join(" ")&&l(t)}else if("attributes"===n.type&&"class"===n.attributeName){var c,v,f,p,y=e(null!==(c=null==i||null===(v=i.ignore)||void 0===v?void 0:v.className)&&void 0!==c?c:["unitone-empty"]);(null!==(f=n.target.getAttribute(n.attributeName))&&void 0!==f?f:"").split(" ").filter((function(t){return!y.includes(t)})).join(" ")!==(null!==(p=n.oldValue)&&void 0!==p?p:"").split(" ").filter((function(t){return!y.includes(t)})).join(" ")&&l(t)}else"attributes"===n.type&&"style"===n.attributeName&&l(t)};for(u.s();!(o=u.n()).done;)a()}catch(t){u.e(t)}finally{u.f()}}))}));return u.observe(t),a.observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:u,mutationObserver:a}},exports.fluidFontSizeResizeObserver=function(t){var e=0;new ResizeObserver(r((function(t){var i,r=n(t);try{for(r.s();!(i=r.n()).done;){var l,u=i.value,a=null===(l=u.borderBoxSize)||void 0===l?void 0:l[0].inlineSize;a!==e&&(o(u.target),e=a)}}catch(t){r.e(t)}finally{r.f()}}),250)).observe(t)},exports.setDividerLinewrap=l,exports.setStairsStep=u,exports.stairsResizeObserver=function(t){var e=0,i=new ResizeObserver(r((function(t){var i,r=n(t);try{for(r.s();!(i=r.n()).done;){var o,l=i.value,a=null===(o=l.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;a!==e&&(u(l.target),e=a)}}catch(t){r.e(t)}finally{r.f()}}),250));return i.observe(t),i},exports.throttle=function(t,e){var n=this,i=Date.now()-e;return function(){if(i+e<Date.now()){i=Date.now();for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];t.apply(n,o)}}},exports.verticalsResizeObserver=function(t){var e=0;t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -initialized"));var i=new ResizeObserver(r((function(t){var i,r=n(t);try{for(r.s();!(i=r.n()).done;){var o,l=i.value,u=null===(o=l.contentRect)||void 0===o?void 0:o.width;parseInt(u)!==parseInt(e)&&(e=u,l.target.parentNode.style.height="",a(l.target))}}catch(t){r.e(t)}finally{r.f()}}),250));i.observe(t);var o=new MutationObserver((function(e){requestAnimationFrame((function(){if(0<e.length){var n,i,r=e[0],o=null===(n=r.addedNodes)||void 0===n?void 0:n[0],l=null===(i=r.removedNodes)||void 0===i?void 0:i[0];if((null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===o.getAttribute("data-unitone-layout")||(null==l?void 0:l.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===l.getAttribute("data-unitone-layout"))return;a(t)}}))}));return o.observe(t,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:i,mutationObserver:o}};
|
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -7,15 +7,17 @@ import {
|
|
|
7
7
|
|
|
8
8
|
document.addEventListener('DOMContentLoaded', () => {
|
|
9
9
|
const observer = new MutationObserver((entries) => {
|
|
10
|
-
|
|
11
|
-
entry
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
requestAnimationFrame(() => {
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
entry.addedNodes.forEach((addedNode) => {
|
|
13
|
+
const targets = addedNode.parentNode?.querySelectorAll(
|
|
14
|
+
'[data-unitone-layout~="-fluid-typography"]',
|
|
15
|
+
);
|
|
16
|
+
targets?.forEach((target) => {
|
|
17
|
+
fluidFontSizeResizeObserver(target);
|
|
18
|
+
});
|
|
17
19
|
});
|
|
18
|
-
}
|
|
20
|
+
}
|
|
19
21
|
});
|
|
20
22
|
});
|
|
21
23
|
|
|
@@ -27,15 +29,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
27
29
|
|
|
28
30
|
document.addEventListener('DOMContentLoaded', () => {
|
|
29
31
|
const observer = new MutationObserver((entries) => {
|
|
30
|
-
|
|
31
|
-
entry
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
requestAnimationFrame(() => {
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
entry.addedNodes.forEach((addedNode) => {
|
|
35
|
+
const targets = addedNode.parentNode?.querySelectorAll(
|
|
36
|
+
'[data-unitone-layout*="-divider:"]',
|
|
37
|
+
);
|
|
38
|
+
targets?.forEach((target) => {
|
|
39
|
+
dividersResizeObserver(target);
|
|
40
|
+
});
|
|
37
41
|
});
|
|
38
|
-
}
|
|
42
|
+
}
|
|
39
43
|
});
|
|
40
44
|
});
|
|
41
45
|
|
|
@@ -47,13 +51,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
47
51
|
|
|
48
52
|
document.addEventListener('DOMContentLoaded', () => {
|
|
49
53
|
const observer = new MutationObserver((entries) => {
|
|
50
|
-
|
|
51
|
-
entry
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
requestAnimationFrame(() => {
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
entry.addedNodes.forEach((addedNode) => {
|
|
57
|
+
const targets = addedNode.parentNode?.querySelectorAll(
|
|
58
|
+
'[data-unitone-layout*="-stairs:"]',
|
|
59
|
+
);
|
|
60
|
+
targets?.forEach((target) => {
|
|
61
|
+
stairsResizeObserver(target);
|
|
62
|
+
});
|
|
55
63
|
});
|
|
56
|
-
}
|
|
64
|
+
}
|
|
57
65
|
});
|
|
58
66
|
});
|
|
59
67
|
|
|
@@ -65,15 +73,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
65
73
|
|
|
66
74
|
document.addEventListener('DOMContentLoaded', () => {
|
|
67
75
|
const observer = new MutationObserver((entries) => {
|
|
68
|
-
|
|
69
|
-
entry
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
requestAnimationFrame(() => {
|
|
77
|
+
for (const entry of entries) {
|
|
78
|
+
entry.addedNodes.forEach((addedNode) => {
|
|
79
|
+
const targets = addedNode.parentNode?.querySelectorAll(
|
|
80
|
+
'[data-unitone-layout~="vertical-writing"]',
|
|
81
|
+
);
|
|
82
|
+
targets?.forEach((target) => {
|
|
83
|
+
verticalsResizeObserver(target);
|
|
84
|
+
});
|
|
75
85
|
});
|
|
76
|
-
}
|
|
86
|
+
}
|
|
77
87
|
});
|
|
78
88
|
});
|
|
79
89
|
|
package/src/library.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export function debounce(fn, delay) {
|
|
2
|
+
let timer;
|
|
3
|
+
|
|
4
|
+
return (...args) => {
|
|
5
|
+
clearTimeout(timer);
|
|
6
|
+
timer = setTimeout(() => {
|
|
7
|
+
fn.apply(this, args);
|
|
8
|
+
}, delay);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
const setFluidFontSizeMagnification = (target) => {
|
|
2
13
|
const baseFontSize = parseFloat(
|
|
3
14
|
window.getComputedStyle(document.documentElement).getPropertyValue('font-size'),
|
|
@@ -9,8 +20,8 @@ const setFluidFontSizeMagnification = (target) => {
|
|
|
9
20
|
export const fluidFontSizeResizeObserver = (target) => {
|
|
10
21
|
let prevWidth = 0;
|
|
11
22
|
|
|
12
|
-
const observer = new ResizeObserver(
|
|
13
|
-
|
|
23
|
+
const observer = new ResizeObserver(
|
|
24
|
+
debounce((entries) => {
|
|
14
25
|
for (const entry of entries) {
|
|
15
26
|
const width = entry.borderBoxSize?.[0].inlineSize;
|
|
16
27
|
if (width !== prevWidth) {
|
|
@@ -18,8 +29,8 @@ export const fluidFontSizeResizeObserver = (target) => {
|
|
|
18
29
|
prevWidth = width;
|
|
19
30
|
}
|
|
20
31
|
}
|
|
21
|
-
})
|
|
22
|
-
|
|
32
|
+
}, 250),
|
|
33
|
+
);
|
|
23
34
|
|
|
24
35
|
observer.observe(target);
|
|
25
36
|
};
|
|
@@ -92,8 +103,8 @@ export const setDividerLinewrap = (target) => {
|
|
|
92
103
|
export const dividersResizeObserver = (target, args = {}) => {
|
|
93
104
|
let prevWidth = 0;
|
|
94
105
|
|
|
95
|
-
const observer = new ResizeObserver(
|
|
96
|
-
|
|
106
|
+
const observer = new ResizeObserver(
|
|
107
|
+
debounce((entries) => {
|
|
97
108
|
for (const entry of entries) {
|
|
98
109
|
const width = entry.borderBoxSize?.[0].inlineSize;
|
|
99
110
|
if (width !== prevWidth) {
|
|
@@ -101,8 +112,8 @@ export const dividersResizeObserver = (target, args = {}) => {
|
|
|
101
112
|
prevWidth = width;
|
|
102
113
|
}
|
|
103
114
|
}
|
|
104
|
-
})
|
|
105
|
-
|
|
115
|
+
}, 250),
|
|
116
|
+
);
|
|
106
117
|
|
|
107
118
|
const mObserverArgs = {
|
|
108
119
|
attributes: true,
|
|
@@ -113,43 +124,45 @@ export const dividersResizeObserver = (target, args = {}) => {
|
|
|
113
124
|
};
|
|
114
125
|
|
|
115
126
|
const mObserver = new MutationObserver((entries) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
127
|
+
requestAnimationFrame(() => {
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
if ('attributes' === entry.type && 'data-unitone-layout' === entry.attributeName) {
|
|
130
|
+
const ignoreUnitoneLayouts = [...(args?.ignore?.layout ?? []), ...['-bol', '-linewrap']];
|
|
131
|
+
|
|
132
|
+
const current = (entry.target.getAttribute(entry.attributeName) ?? '')
|
|
133
|
+
.split(' ')
|
|
134
|
+
.filter((v) => !ignoreUnitoneLayouts.includes(v))
|
|
135
|
+
.join(' ');
|
|
136
|
+
|
|
137
|
+
const old = (entry.oldValue ?? '')
|
|
138
|
+
.split(' ')
|
|
139
|
+
.filter((v) => !ignoreUnitoneLayouts.includes(v))
|
|
140
|
+
.join(' ');
|
|
141
|
+
|
|
142
|
+
if (current !== old) {
|
|
143
|
+
setDividerLinewrap(target);
|
|
144
|
+
}
|
|
145
|
+
} else if ('attributes' === entry.type && 'class' === entry.attributeName) {
|
|
146
|
+
const ignoreClassNames = [...(args?.ignore?.className ?? ['unitone-empty'])];
|
|
147
|
+
|
|
148
|
+
const current = (entry.target.getAttribute(entry.attributeName) ?? '')
|
|
149
|
+
.split(' ')
|
|
150
|
+
.filter((v) => !ignoreClassNames.includes(v))
|
|
151
|
+
.join(' ');
|
|
152
|
+
|
|
153
|
+
const old = (entry.oldValue ?? '')
|
|
154
|
+
.split(' ')
|
|
155
|
+
.filter((v) => !ignoreClassNames.includes(v))
|
|
156
|
+
.join(' ');
|
|
157
|
+
|
|
158
|
+
if (current !== old) {
|
|
159
|
+
setDividerLinewrap(target);
|
|
160
|
+
}
|
|
161
|
+
} else if ('attributes' === entry.type && 'style' === entry.attributeName) {
|
|
147
162
|
setDividerLinewrap(target);
|
|
148
163
|
}
|
|
149
|
-
} else if ('attributes' === entry.type && 'style' === entry.attributeName) {
|
|
150
|
-
setDividerLinewrap(target);
|
|
151
164
|
}
|
|
152
|
-
}
|
|
165
|
+
});
|
|
153
166
|
});
|
|
154
167
|
|
|
155
168
|
observer.observe(target);
|
|
@@ -239,8 +252,8 @@ export const setStairsStep = (target) => {
|
|
|
239
252
|
export const stairsResizeObserver = (target) => {
|
|
240
253
|
let prevWidth = 0;
|
|
241
254
|
|
|
242
|
-
const observer = new ResizeObserver(
|
|
243
|
-
|
|
255
|
+
const observer = new ResizeObserver(
|
|
256
|
+
debounce((entries) => {
|
|
244
257
|
for (const entry of entries) {
|
|
245
258
|
const width = entry.borderBoxSize?.[0].inlineSize;
|
|
246
259
|
if (width !== prevWidth) {
|
|
@@ -248,8 +261,8 @@ export const stairsResizeObserver = (target) => {
|
|
|
248
261
|
prevWidth = width;
|
|
249
262
|
}
|
|
250
263
|
}
|
|
251
|
-
})
|
|
252
|
-
|
|
264
|
+
}, 250),
|
|
265
|
+
);
|
|
253
266
|
|
|
254
267
|
observer.observe(target);
|
|
255
268
|
|
|
@@ -329,8 +342,8 @@ export const verticalsResizeObserver = (target) => {
|
|
|
329
342
|
`${target.getAttribute('data-unitone-layout')} -initialized`,
|
|
330
343
|
);
|
|
331
344
|
|
|
332
|
-
const observer = new ResizeObserver(
|
|
333
|
-
|
|
345
|
+
const observer = new ResizeObserver(
|
|
346
|
+
debounce((entries) => {
|
|
334
347
|
for (const entry of entries) {
|
|
335
348
|
const width = entry.contentRect?.width;
|
|
336
349
|
if (parseInt(width) !== parseInt(prevWidth)) {
|
|
@@ -339,8 +352,8 @@ export const verticalsResizeObserver = (target) => {
|
|
|
339
352
|
setColumnCountForVertical(entry.target);
|
|
340
353
|
}
|
|
341
354
|
}
|
|
342
|
-
})
|
|
343
|
-
|
|
355
|
+
}, 250),
|
|
356
|
+
);
|
|
344
357
|
|
|
345
358
|
observer.observe(target);
|
|
346
359
|
|