@inc2734/unitone-css 0.61.4 → 0.61.5
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/library.js +47 -12
package/dist/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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,o=new Array(e);n<e;n++)o[n]=t[n];return o}function o(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 o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?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 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 o=0,r=function(){};return{s:r,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:r}}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 a,u=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){l=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(l)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}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){var e=t.getAttribute("data-unitone-layout")||"",n=e.split(" ");t.classList.contains("unitone-empty")?t.remove():(n=o(n.filter((function(t){return!["-bol","-linewrap"," "].includes(t)}))).join(" ")||"")!==e&&t.setAttribute("data-unitone-layout",n)})),[].slice.call(t.children).forEach((function(t){var e,n=i.getBoundingClientRect(),a=null===(e=r)||void 0===e?void 0:e.getBoundingClientRect(),u=t.getAttribute("data-unitone-layout")||"",l=u.split(" ");if((i===t||(null==a?void 0:a.top)<t.getBoundingClientRect().top)&&(l.includes("-bol")||(l=[].concat(o(l),["-bol"]))),(null==a?void 0:a.top)<t.getBoundingClientRect().top){var d=document.createElement("div");d.classList.add("unitone-empty"),t.before(d),(null==a?void 0:a.top)<d.getBoundingClientRect().top&&d.remove()}n.top<t.getBoundingClientRect().top&&(l.includes("-linewrap")||(l=[].concat(o(l),["-linewrap"]))),(l=l.filter(Boolean).join(" ")||"")!==u&&t.setAttribute("data-unitone-layout",l),r=t})))},l=function(t){var e,n,o=null===(e=[].slice.call(null!==(n=null==t?void 0:t.children)&&void 0!==n?n:[]))||void 0===e?void 0:e[0];if(o){var r,i=0,a=i;[].slice.call(t.children).forEach((function(t){var e,n=window.getComputedStyle(t).getPropertyValue("position");if("absolute"!==n&&"fixed"!==n){t.style.setProperty("--unitone--stairs-step","");var u=null===(e=r)||void 0===e?void 0:e.getBoundingClientRect(),l=t.getBoundingClientRect();o===t||null!=u&&u.left&&u.left>=l.left?(i=0,t.style.setProperty("--unitone--stairs-step",i)):(i++,t.style.setProperty("--unitone--stairs-step",i)),r=t,i>a&&(a=i)}})),t.getAttribute("data-unitone-layout").match(/-stairs-up:right/)?t.style.setProperty("--unitone--stairs-step",a):t.style.setProperty("--unitone--stairs-step",i)}},d=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 o=document.createElement("div");o.setAttribute("data-unitone-layout","vertical-writing__thresholder"),t.appendChild(o);var r=o.offsetWidth>=t.offsetWidth;if(t.removeChild(o),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))return e=t,!0})),e){var i=!1;t.getBoundingClientRect().left>e.getBoundingClientRect().left&&(t.style.columnCount=2,i=!0),setTimeout((function(){var n=t.getBoundingClientRect().top+t.getBoundingClientRect().height,o=e.getBoundingClientRect().top+e.getBoundingClientRect().height;n!==o&&(t.parentNode.style.height="".concat(Math.ceil(o-t.getBoundingClientRect().top),"px"))}),i?250:0)}};return e.dividersResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var n,o=r(t);try{for(o.s();!(n=o.n()).done;){var i,a=n.value,l=null===(i=a.borderBoxSize)||void 0===i?void 0:i[0].inlineSize;l!==e&&(u(a.target),e=l)}}catch(t){o.e(t)}finally{o.f()}})).observe(t),new MutationObserver((function(t){var e,n=r(t);try{var o=function(){var t=e.value;if("attributes"===t.type&&"data-unitone-layout"===t.attributeName){var n,o,r=null!==(n=t.target.getAttribute(t.attributeName))&&void 0!==n?n:"",i=null!==(o=t.oldValue)&&void 0!==o?o:"";if(["-bol","-linewrap"].forEach((function(t){r=r.replace(t,"").trim(),i=i.replace(t,"").trim()})),r!==i)return u(t.target),1}};for(n.s();!(e=n.n()).done;)o()}catch(t){n.e(t)}finally{n.f()}})).observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0})},e.fluidFontSizeResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var n,o=r(t);try{for(o.s();!(n=o.n()).done;){var i,u=n.value,l=null===(i=u.borderBoxSize)||void 0===i?void 0:i[0].inlineSize;l!==e&&(a(u.target),e=l)}}catch(t){o.e(t)}finally{o.f()}})).observe(t)},e.setDividerLinewrap=u,e.stairsResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var n,o=r(t);try{for(o.s();!(n=o.n()).done;){var i,a=n.value,u=null===(i=a.borderBoxSize)||void 0===i?void 0:i[0].inlineSize;u!==e&&(l(a.target),e=u)}}catch(t){o.e(t)}finally{o.f()}})).observe(t)},e.verticalsResizeObserver=function(t){var e=0;t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -initialized"));var n=new ResizeObserver((function(o,i){var a,u=r(o);try{var l=function(){var o,r=a.value,u=null===(o=r.contentRect)||void 0===o?void 0:o.width;parseInt(u)!==parseInt(e)&&(e=u,n.unobserve(t),i.unobserve(r.target),r.target.parentNode.style.height="",d(r.target),setTimeout((function(){i.observe(r.target)}),500))};for(u.s();!(a=u.n()).done;)l()}catch(t){u.e(t)}finally{u.f()}}));n.observe(t);var o,i={attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0};new MutationObserver((function(e,r){if(clearTimeout(o),0<e.length){var a,u,l=e[0],c=null===(a=l.addedNodes)||void 0===a?void 0:a[0],s=null===(u=l.removedNodes)||void 0===u?void 0:u[0];if((null==c?void 0:c.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===c.getAttribute("data-unitone-layout")||(null==s?void 0:s.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===s.getAttribute("data-unitone-layout"))return;r.disconnect(),n.unobserve(t),o=setTimeout((function(){d(t),setTimeout((function(){r.observe(t,i),n.observe(t)}),500)}),500)}})).observe(t,i)},e}();document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,o=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout~="-fluid-typography"]');null==o||o.forEach((function(t){n.fluidFontSizeResizeObserver(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,o=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout*="-divider:"]');null==o||o.forEach((function(t){n.dividersResizeObserver(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,o=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout*="-stairs:"]');null==o||o.forEach((function(t){n.stairsResizeObserver(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,o=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout~="vertical-writing"]');null==o||o.forEach((function(t){n.verticalsResizeObserver(t)}))}))}))})).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,i=new Array(e);n<e;n++)i[n]=t[n];return i}function i(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 i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?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 o(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 r(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)?r(t,e):void 0}}(t))||e){n&&(t=n);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},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 a,u=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){l=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(l)throw a}}}}function r(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}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,o,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){var e=t.getAttribute("data-unitone-layout")||"",n=e.split(" ");t.classList.contains("unitone-empty")?t.remove():(n=i(n.filter((function(t){return!["-bol","-linewrap"," "].includes(t)}))).join(" ")||"")!==e&&t.setAttribute("data-unitone-layout",n)})),[].slice.call(t.children).forEach((function(t){var e,n=r.getBoundingClientRect(),a=null===(e=o)||void 0===e?void 0:e.getBoundingClientRect(),u=t.getAttribute("data-unitone-layout")||"",l=u.split(" ");if((r===t||(null==a?void 0:a.top)<t.getBoundingClientRect().top)&&(l.includes("-bol")||(l=[].concat(i(l),["-bol"]))),(null==a?void 0:a.top)<t.getBoundingClientRect().top){var d=document.createElement("div");d.classList.add("unitone-empty"),t.before(d),(null==a?void 0:a.top)<d.getBoundingClientRect().top&&d.remove()}n.top<t.getBoundingClientRect().top&&(l.includes("-linewrap")||(l=[].concat(i(l),["-linewrap"]))),(l=l.filter(Boolean).join(" ")||"")!==u&&t.setAttribute("data-unitone-layout",l),o=t})))},l=function(t){var e,n,i=null===(e=[].slice.call(null!==(n=null==t?void 0:t.children)&&void 0!==n?n:[]))||void 0===e?void 0:e[0];if(i){var o,r=0,a=r;[].slice.call(t.children).forEach((function(t){var e,n=window.getComputedStyle(t).getPropertyValue("position");if("absolute"!==n&&"fixed"!==n){t.style.setProperty("--unitone--stairs-step","");var u=null===(e=o)||void 0===e?void 0:e.getBoundingClientRect(),l=t.getBoundingClientRect();i===t||null!=u&&u.left&&u.left>=l.left?(r=0,t.style.setProperty("--unitone--stairs-step",r)):(r++,t.style.setProperty("--unitone--stairs-step",r)),o=t,r>a&&(a=r)}})),t.getAttribute("data-unitone-layout").match(/-stairs-up:right/)?t.style.setProperty("--unitone--stairs-step",a):t.style.setProperty("--unitone--stairs-step",r)}},d=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 o=i.offsetWidth>=t.offsetWidth;if(t.removeChild(i),o)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))return e=t,!0})),e){var r=!1;t.getBoundingClientRect().left>e.getBoundingClientRect().left&&(t.style.columnCount=2,r=!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"))}),r?250:0)}};return e.dividersResizeObserver=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,r=new ResizeObserver((function(t){var e,i=o(t);try{for(i.s();!(e=i.n()).done;){var r,a=e.value,l=null===(r=a.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;l!==n&&(u(a.target),n=l)}}catch(t){i.e(t)}finally{i.f()}})),a={attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0},l=new MutationObserver((function(t){var n,r=o(t);try{var a=function(){var t=n.value;if("attributes"===t.type&&"data-unitone-layout"===t.attributeName){var o,r,a,l,d=[].concat(i(null!==(o=null==e||null===(r=e.ignore)||void 0===r?void 0:r.layout)&&void 0!==o?o:[]),["-bol","-linewrap"]);(null!==(a=t.target.getAttribute(t.attributeName))&&void 0!==a?a:"").split(" ").filter((function(t){return!d.includes(t)})).join(" ")!==(null!==(l=t.oldValue)&&void 0!==l?l:"").split(" ").filter((function(t){return!d.includes(t)})).join(" ")&&u(t.target)}else if("attributes"===t.type&&"class"===t.attributeName){var c,s,v,f,y=i(null!==(c=null==e||null===(s=e.ignore)||void 0===s?void 0:s.className)&&void 0!==c?c:[]);(null!==(v=t.target.getAttribute(t.attributeName))&&void 0!==v?v:"").split(" ").filter((function(t){return!y.includes(t)})).join(" ")!==(null!==(f=t.oldValue)&&void 0!==f?f:"").split(" ").filter((function(t){return!y.includes(t)})).join(" ")&&u(t.target)}else"attributes"===t.type&&"style"===t.attributeName&&u(t.target)};for(r.s();!(n=r.n()).done;)a()}catch(t){r.e(t)}finally{r.f()}})),d=new IntersectionObserver((function(t,e){t.forEach((function(t){var n=t.target;t.isIntersecting&&(e.unobserve(n),r.observe(n),l.observe(n,a))}))}),{rootMargin:"100px 0px"});d.observe(t)},e.fluidFontSizeResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var n,i=o(t);try{for(i.s();!(n=i.n()).done;){var r,u=n.value,l=null===(r=u.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;l!==e&&(a(u.target),e=l)}}catch(t){i.e(t)}finally{i.f()}})).observe(t)},e.setDividerLinewrap=u,e.stairsResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var n,i=o(t);try{for(i.s();!(n=i.n()).done;){var r,a=n.value,u=null===(r=a.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;u!==e&&(l(a.target),e=u)}}catch(t){i.e(t)}finally{i.f()}})).observe(t)},e.verticalsResizeObserver=function(t){var e=0;t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -initialized"));var n=new ResizeObserver((function(i,r){var a,u=o(i);try{var l=function(){var i,o=a.value,u=null===(i=o.contentRect)||void 0===i?void 0:i.width;parseInt(u)!==parseInt(e)&&(e=u,n.unobserve(t),r.unobserve(o.target),o.target.parentNode.style.height="",d(o.target),setTimeout((function(){r.observe(o.target)}),500))};for(u.s();!(a=u.n()).done;)l()}catch(t){u.e(t)}finally{u.f()}}));n.observe(t);var i,r={attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0};new MutationObserver((function(e,o){if(clearTimeout(i),0<e.length){var a,u,l=e[0],c=null===(a=l.addedNodes)||void 0===a?void 0:a[0],s=null===(u=l.removedNodes)||void 0===u?void 0:u[0];if((null==c?void 0:c.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===c.getAttribute("data-unitone-layout")||(null==s?void 0:s.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===s.getAttribute("data-unitone-layout"))return;o.disconnect(),n.unobserve(t),i=setTimeout((function(){d(t),setTimeout((function(){o.observe(t,r),n.observe(t)}),500)}),500)}})).observe(t,r)},e}();document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,i=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout~="-fluid-typography"]');null==i||i.forEach((function(t){n.fluidFontSizeResizeObserver(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,i=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout*="-divider:"]');null==i||i.forEach((function(t){n.dividersResizeObserver(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,i=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout*="-stairs:"]');null==i||i.forEach((function(t){n.stairsResizeObserver(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){var e,i=null===(e=t.parentNode)||void 0===e?void 0:e.querySelectorAll('[data-unitone-layout~="vertical-writing"]');null==i||i.forEach((function(t){n.verticalsResizeObserver(t)}))}))}))})).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,
|
|
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,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,i=Array(e);n<e;n++)i[n]=t[n];return i}var r=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)},o=function(t){var n,i,r,o=null===(n=[].slice.call(null!==(i=null==t?void 0:t.children)&&void 0!==i?i:[]))||void 0===n?void 0:n[0];o&&([].slice.call(t.children).forEach((function(t){var n=t.getAttribute("data-unitone-layout")||"",i=n.split(" ");t.classList.contains("unitone-empty")?t.remove():(i=e(i.filter((function(t){return!["-bol","-linewrap"," "].includes(t)}))).join(" ")||"")!==n&&t.setAttribute("data-unitone-layout",i)})),[].slice.call(t.children).forEach((function(t){var n,i=o.getBoundingClientRect(),l=null===(n=r)||void 0===n?void 0:n.getBoundingClientRect(),a=t.getAttribute("data-unitone-layout")||"",u=a.split(" ");if((o===t||(null==l?void 0:l.top)<t.getBoundingClientRect().top)&&(u.includes("-bol")||(u=[].concat(e(u),["-bol"]))),(null==l?void 0:l.top)<t.getBoundingClientRect().top){var s=document.createElement("div");s.classList.add("unitone-empty"),t.before(s),(null==l?void 0:l.top)<s.getBoundingClientRect().top&&s.remove()}i.top<t.getBoundingClientRect().top&&(u.includes("-linewrap")||(u=[].concat(e(u),["-linewrap"]))),(u=u.filter(Boolean).join(" ")||"")!==a&&t.setAttribute("data-unitone-layout",u),r=t})))},l=function(t){var e,n,i=null===(e=[].slice.call(null!==(n=null==t?void 0:t.children)&&void 0!==n?n:[]))||void 0===e?void 0:e[0];if(i){var r,o=0,l=o;[].slice.call(t.children).forEach((function(t){var e,n=window.getComputedStyle(t).getPropertyValue("position");if("absolute"!==n&&"fixed"!==n){t.style.setProperty("--unitone--stairs-step","");var a=null===(e=r)||void 0===e?void 0:e.getBoundingClientRect(),u=t.getBoundingClientRect();i===t||null!=a&&a.left&&a.left>=u.left?(o=0,t.style.setProperty("--unitone--stairs-step",o)):(o++,t.style.setProperty("--unitone--stairs-step",o)),r=t,o>l&&(l=o)}})),t.getAttribute("data-unitone-layout").match(/-stairs-up:right/)?t.style.setProperty("--unitone--stairs-step",l):t.style.setProperty("--unitone--stairs-step",o)}},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))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.dividersResizeObserver=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,l=new ResizeObserver((function(t){var e,i=n(t);try{for(i.s();!(e=i.n()).done;){var l,a=e.value,u=null===(l=a.borderBoxSize)||void 0===l?void 0:l[0].inlineSize;u!==r&&(o(a.target),r=u)}}catch(t){i.e(t)}finally{i.f()}})),a={attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0},u=new MutationObserver((function(t){var r,l=n(t);try{var a=function(){var t=r.value;if("attributes"===t.type&&"data-unitone-layout"===t.attributeName){var n,l,a,u,s=[].concat(e(null!==(n=null==i||null===(l=i.ignore)||void 0===l?void 0:l.layout)&&void 0!==n?n:[]),["-bol","-linewrap"]);(null!==(a=t.target.getAttribute(t.attributeName))&&void 0!==a?a:"").split(" ").filter((function(t){return!s.includes(t)})).join(" ")!==(null!==(u=t.oldValue)&&void 0!==u?u:"").split(" ").filter((function(t){return!s.includes(t)})).join(" ")&&o(t.target)}else if("attributes"===t.type&&"class"===t.attributeName){var c,d,v,f,y=e(null!==(c=null==i||null===(d=i.ignore)||void 0===d?void 0:d.className)&&void 0!==c?c:[]);(null!==(v=t.target.getAttribute(t.attributeName))&&void 0!==v?v:"").split(" ").filter((function(t){return!y.includes(t)})).join(" ")!==(null!==(f=t.oldValue)&&void 0!==f?f:"").split(" ").filter((function(t){return!y.includes(t)})).join(" ")&&o(t.target)}else"attributes"===t.type&&"style"===t.attributeName&&o(t.target)};for(l.s();!(r=l.n()).done;)a()}catch(t){l.e(t)}finally{l.f()}})),s=new IntersectionObserver((function(t,e){t.forEach((function(t){var n=t.target;t.isIntersecting&&(e.unobserve(n),l.observe(n),u.observe(n,a))}))}),{rootMargin:"100px 0px"});s.observe(t)},exports.fluidFontSizeResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var i,o=n(t);try{for(o.s();!(i=o.n()).done;){var l,a=i.value,u=null===(l=a.borderBoxSize)||void 0===l?void 0:l[0].inlineSize;u!==e&&(r(a.target),e=u)}}catch(t){o.e(t)}finally{o.f()}})).observe(t)},exports.setDividerLinewrap=o,exports.stairsResizeObserver=function(t){var e=0;new ResizeObserver((function(t){var i,r=n(t);try{for(r.s();!(i=r.n()).done;){var o,a=i.value,u=null===(o=a.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;u!==e&&(l(a.target),e=u)}}catch(t){r.e(t)}finally{r.f()}})).observe(t)},exports.verticalsResizeObserver=function(t){var e=0;t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -initialized"));var i=new ResizeObserver((function(r,o){var l,u=n(r);try{var s=function(){var n,r=l.value,u=null===(n=r.contentRect)||void 0===n?void 0:n.width;parseInt(u)!==parseInt(e)&&(e=u,i.unobserve(t),o.unobserve(r.target),r.target.parentNode.style.height="",a(r.target),setTimeout((function(){o.observe(r.target)}),500))};for(u.s();!(l=u.n()).done;)s()}catch(t){u.e(t)}finally{u.f()}}));i.observe(t);var r,o={attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0};new MutationObserver((function(e,n){if(clearTimeout(r),0<e.length){var l,u,s=e[0],c=null===(l=s.addedNodes)||void 0===l?void 0:l[0],d=null===(u=s.removedNodes)||void 0===u?void 0:u[0];if((null==c?void 0:c.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===c.getAttribute("data-unitone-layout")||(null==d?void 0:d.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===d.getAttribute("data-unitone-layout"))return;n.disconnect(),i.unobserve(t),r=setTimeout((function(){a(t),setTimeout((function(){n.observe(t,o),i.observe(t)}),500)}),500)}})).observe(t,o)};
|
package/package.json
CHANGED
package/src/library.js
CHANGED
|
@@ -84,7 +84,7 @@ export const setDividerLinewrap = (target) => {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
export const dividersResizeObserver = (target) => {
|
|
87
|
+
export const dividersResizeObserver = (target, args = {}) => {
|
|
88
88
|
let prevWidth = 0;
|
|
89
89
|
|
|
90
90
|
const observer = new ResizeObserver((entries) => {
|
|
@@ -97,8 +97,6 @@ export const dividersResizeObserver = (target) => {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
observer.observe(target);
|
|
101
|
-
|
|
102
100
|
const mObserverArgs = {
|
|
103
101
|
attributes: true,
|
|
104
102
|
attributeFilter: ['style', 'data-unitone-layout', 'class'],
|
|
@@ -110,24 +108,61 @@ export const dividersResizeObserver = (target) => {
|
|
|
110
108
|
const mObserver = new MutationObserver((entries) => {
|
|
111
109
|
for (const entry of entries) {
|
|
112
110
|
if ('attributes' === entry.type && 'data-unitone-layout' === entry.attributeName) {
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
const ignoreUnitoneLayouts = [...(args?.ignore?.layout ?? []), ...['-bol', '-linewrap']];
|
|
112
|
+
|
|
113
|
+
const current = (entry.target.getAttribute(entry.attributeName) ?? '')
|
|
114
|
+
.split(' ')
|
|
115
|
+
.filter((v) => !ignoreUnitoneLayouts.includes(v))
|
|
116
|
+
.join(' ');
|
|
117
|
+
|
|
118
|
+
const old = (entry.oldValue ?? '')
|
|
119
|
+
.split(' ')
|
|
120
|
+
.filter((v) => !ignoreUnitoneLayouts.includes(v))
|
|
121
|
+
.join(' ');
|
|
122
|
+
|
|
123
|
+
if (current !== old) {
|
|
124
|
+
setDividerLinewrap(entry.target);
|
|
125
|
+
}
|
|
126
|
+
} else if ('attributes' === entry.type && 'class' === entry.attributeName) {
|
|
127
|
+
const ignoreClassNames = [...(args?.ignore?.className ?? [])];
|
|
128
|
+
|
|
129
|
+
const current = (entry.target.getAttribute(entry.attributeName) ?? '')
|
|
130
|
+
.split(' ')
|
|
131
|
+
.filter((v) => !ignoreClassNames.includes(v))
|
|
132
|
+
.join(' ');
|
|
115
133
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
} );
|
|
134
|
+
const old = (entry.oldValue ?? '')
|
|
135
|
+
.split(' ')
|
|
136
|
+
.filter((v) => !ignoreClassNames.includes(v))
|
|
137
|
+
.join(' ');
|
|
121
138
|
|
|
122
139
|
if (current !== old) {
|
|
123
140
|
setDividerLinewrap(entry.target);
|
|
124
|
-
continue;
|
|
125
141
|
}
|
|
142
|
+
} else if ('attributes' === entry.type && 'style' === entry.attributeName) {
|
|
143
|
+
setDividerLinewrap(entry.target);
|
|
126
144
|
}
|
|
127
145
|
}
|
|
128
146
|
});
|
|
129
147
|
|
|
130
|
-
|
|
148
|
+
const iObserver = new IntersectionObserver(
|
|
149
|
+
(entries, _observer) => {
|
|
150
|
+
entries.forEach((entry) => {
|
|
151
|
+
const target = entry.target;
|
|
152
|
+
|
|
153
|
+
if (entry.isIntersecting) {
|
|
154
|
+
_observer.unobserve(target);
|
|
155
|
+
observer.observe(target);
|
|
156
|
+
mObserver.observe(target, mObserverArgs);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
rootMargin: '100px 0px',
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
iObserver.observe(target);
|
|
131
166
|
};
|
|
132
167
|
|
|
133
168
|
const setStairsStep = (target) => {
|