@inc2734/unitone-css 0.83.0 → 0.83.2

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 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,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 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 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 i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},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 o(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 a(t,e){var n,i=this;return function(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];clearTimeout(n),n=setTimeout((function(){t.apply(i,o)}),e)}}t=1;var u=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=i.getBoundingClientRect();t.setAttribute("data-unitone-layout",t.getAttribute("data-unitone-layout").split(" ").filter((function(t){return!["divider:initialized","-stack"].includes(t)})).join(" "));var a=[].slice.call(t.children).filter((function(t){var e=window.getComputedStyle(t).getPropertyValue("position"),n=window.getComputedStyle(t).getPropertyValue("display");return"absolute"!==e&&"fixed"!==e&&"none"!==n}));a.forEach((function(t){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)})),a.forEach((function(t,e){var n,i=null===(n=r)||void 0===n?void 0:n.getBoundingClientRect(),a=t.getBoundingClientRect(),u=t.getAttribute("data-unitone-layout")||"",l=u.split(" ");(0===e||(null==i?void 0:i.top)<a.top&&(null==i?void 0:i.left)>=a.left)&&(l.includes("-bol")||l.push("-bol")),0<e&&o.top<a.top&&(l.includes("-linewrap")||l.push("-linewrap")),l!==u&&t.setAttribute("data-unitone-layout",l.filter(Boolean).join(" ")||""),r=t})),[].slice.call(a).every((function(t){return t.getBoundingClientRect().left===o.left}))&&t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -stack")),t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," divider:initialized"))}},l=function(t){var e,n=[].slice.call(t.children),i=null==n?void 0:n[0];if(i){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 r,o=[],a=0,u=a,l=window.getComputedStyle(t).getPropertyValue("flex-direction");n.forEach((function(t){var e,n,d=window.getComputedStyle(t).getPropertyValue("position"),c=window.getComputedStyle(t).getPropertyValue("display");if("absolute"!==d&&"fixed"!==d&&"none"!==c){o.push(t);var s="row-reverse"===l?(null===(e=r)||void 0===e||null===(e=e.getBoundingClientRect())||void 0===e?void 0:e.left)<=t.getBoundingClientRect().left:(null===(n=r)||void 0===n||null===(n=n.getBoundingClientRect())||void 0===n?void 0:n.left)>=t.getBoundingClientRect().left;i===t||s?(a=0,t.style.setProperty("--unitone--stairs-step",a)):(a++,t.style.setProperty("--unitone--stairs-step",a)),r=t,a>u&&(u=a)}})),t.style.setProperty("--unitone--max-stairs-step",u);var d=t.getBoundingClientRect().bottom,c=o.reduce((function(t,e){var n=e.getBoundingClientRect().bottom-d;return t>n?t:n}),0);t.style.setProperty("--unitone--stairs-step-overflow-volume",c)}},d=function(t){t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout").replaceAll("vertical-writing:initialized","").trim())),t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout").replaceAll("vertical-writing:safari","").trim())),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"))}[].slice.call(t.children).reverse().some((function(t){if(!["absolute","fixed"].includes(getComputedStyle(t).position)&&"none"!==getComputedStyle(t).display)return e=t,!0})),e&&(t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," vertical-writing:initialized")),t.getBoundingClientRect().left>e.getBoundingClientRect().left&&t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," vertical-writing:safari")),requestAnimationFrame((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"))})))};return e.debounce=a,e.dividersResizeObserver=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,o=new ResizeObserver(a((function(t){var e,i=r(t);try{for(i.s();!(e=i.n()).done;){var o,a=e.value,l=null===(o=a.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;l!==n&&(u(a.target),n=l)}}catch(t){i.e(t)}finally{i.f()}}),250)),l=new MutationObserver((function(n){requestAnimationFrame((function(){var o,a=r(n);try{var l=function(){var n=o.value;if("attributes"===n.type&&"data-unitone-layout"===n.attributeName){var r,a,l,d,c=[].concat(i(null!==(r=null==e||null===(a=e.ignore)||void 0===a?void 0:a.layout)&&void 0!==r?r:[]),["divider:initialized","-bol","-linewrap","-stack"]);(null!==(l=n.target.getAttribute(n.attributeName))&&void 0!==l?l:"").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,b=i(null!==(s=null==e||null===(f=e.ignore)||void 0===f?void 0:f.className)&&void 0!==s?s:[]);(null!==(v=n.target.getAttribute(n.attributeName))&&void 0!==v?v:"").split(" ").filter((function(t){return!b.includes(t)})).join(" ")!==(null!==(y=n.oldValue)&&void 0!==y?y:"").split(" ").filter((function(t){return!b.includes(t)})).join(" ")&&u(t)}else"attributes"===n.type&&"style"===n.attributeName&&u(t)};for(a.s();!(o=a.n()).done;)l()}catch(t){a.e(t)}finally{a.f()}}))}));return o.observe(t),l.observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:o,mutationObserver:l}},e.setColumnCountForVertical=d,e.setDividerLinewrap=u,e.setStairsStep=l,e.stairsResizeObserver=function(t){var e=new ResizeObserver(a((function(t){var e,n=r(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;l(i.target)}}catch(t){n.e(t)}finally{n.f()}}),250));return e.observe(t),e},e.verticalsResizeObserver=function(t){var e=0,n=new ResizeObserver(a((function(t){var n,i=r(t);try{for(i.s();!(n=i.n()).done;){var o,a=n.value,u=null===(o=a.contentRect)||void 0===o?void 0:o.width;parseInt(u)!==parseInt(e)&&(e=u,a.target.parentNode.style.height="",d(a.target))}}catch(t){i.e(t)}finally{i.f()}}),250));n.observe(t);var i=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],a=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==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===a.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===o.getAttribute("data-unitone-layout")||(null==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===a.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===o.getAttribute("data-unitone-layout")||(null==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===a.getAttribute("data-unitone-layout"))return;d(t)}}))}));return i.observe(t,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:n,mutationObserver:i}},e}();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 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}document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){e.value.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)}))}))}}catch(t){r.e(t)}finally{r.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){e.value.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)}))}))}}catch(t){r.e(t)}finally{r.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){e.value.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)}))}))}}catch(t){r.e(t)}finally{r.f()}}))})).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 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 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 i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},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,l=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==n.return||n.return()}finally{if(u)throw a}}}}function o(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 a(t,e){var n,i=this;return function(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];clearTimeout(n),n=setTimeout((function(){t.apply(i,o)}),e)}}t=1;var 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];if(r){var o,a=r.getBoundingClientRect(),l=(null!==(i=t.getAttribute("data-unitone-layout"))&&void 0!==i?i:"").split(/\s+/);l.some((function(t){return["divider:initialized","-stack"].includes(t)}))&&(l=l.filter((function(t){return!["divider:initialized","-stack"].includes(t)})),t.setAttribute("data-unitone-layout",l.join(" ")));var u=[].slice.call(t.children).filter((function(t){var e=window.getComputedStyle(t).getPropertyValue("position"),n=window.getComputedStyle(t).getPropertyValue("display");return"absolute"!==e&&"fixed"!==e&&"none"!==n}));u.forEach((function(t,e){var n,i,r=(null!==(n=t.getAttribute("data-unitone-layout"))&&void 0!==n?n:"").split(/\s+/);r.some((function(t){return["-bol","-linewrap"].includes(t)}))&&(r=r.filter((function(t){return!["-bol","-linewrap"].includes(t)})),t.setAttribute("data-unitone-layout",r.join(" ")));var l=null===(i=o)||void 0===i?void 0:i.getBoundingClientRect(),u=t.getBoundingClientRect(),d=!1;(0===e||(null==l?void 0:l.top)<u.top&&(null==l?void 0:l.left)>=u.left)&&(r.push("-bol"),d=!0),0<e&&a.top<u.top&&(r.push("-linewrap"),d=!0),d&&t.setAttribute("data-unitone-layout",r.join(" ")),o=t})),[].slice.call(u).every((function(t){return t.getBoundingClientRect().left===a.left}))&&l.push("-stack"),l.push("divider:initialized"),t.setAttribute("data-unitone-layout",l.join(" "))}},u=function(t){var e,n=[].slice.call(t.children),i=null==n?void 0:n[0];if(i){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 r,o=[],a=0,l=a,u=window.getComputedStyle(t).getPropertyValue("flex-direction");n.forEach((function(t){var e,n,d=window.getComputedStyle(t).getPropertyValue("position"),s=window.getComputedStyle(t).getPropertyValue("display");if("absolute"!==d&&"fixed"!==d&&"none"!==s){o.push(t);var c="row-reverse"===u?(null===(e=r)||void 0===e||null===(e=e.getBoundingClientRect())||void 0===e?void 0:e.left)<=t.getBoundingClientRect().left:(null===(n=r)||void 0===n||null===(n=n.getBoundingClientRect())||void 0===n?void 0:n.left)>=t.getBoundingClientRect().left;i===t||c?(a=0,t.style.setProperty("--unitone--stairs-step",a)):(a++,t.style.setProperty("--unitone--stairs-step",a)),r=t,a>l&&(l=a)}})),t.style.setProperty("--unitone--max-stairs-step",l);var d=t.getBoundingClientRect().bottom,s=o.reduce((function(t,e){var n=e.getBoundingClientRect().bottom-d;return t>n?t:n}),0);t.style.setProperty("--unitone--stairs-step-overflow-volume",s)}},d=function(t){var e,n=(null!==(e=t.getAttribute("data-unitone-layout"))&&void 0!==e?e:"").split(/\s+/);n.some((function(t){return["vertical-writing:initialized","vertical-writing:safari","-force-switch"].includes(t)}))&&(n=n.filter((function(t){return!["vertical-writing:initialized","vertical-writing:safari","-force-switch"].includes(t)})),t.setAttribute("data-unitone-layout",n.join(" ")));var i,r=getComputedStyle(t);if(String(r.getPropertyValue("--unitone--threshold")).trim()){var o=document.createElement("div");o.setAttribute("data-unitone-layout","vertical-writing__thresholder"),t.appendChild(o);var a=o.offsetWidth>=t.offsetWidth;t.removeChild(o),a&&(n.push("-force-switch"),t.setAttribute("data-unitone-layout",n.join(" ")))}[].slice.call(t.children).reverse().some((function(t){if(!["absolute","fixed"].includes(getComputedStyle(t).position)&&"none"!==getComputedStyle(t).display)return i=t,!0})),i&&(n.push("vertical-writing:initialized"),t.getBoundingClientRect().left>i.getBoundingClientRect().left&&n.push("vertical-writing:safari"),t.setAttribute("data-unitone-layout",n.join(" ")),requestAnimationFrame((function(){var e=t.getBoundingClientRect().top+t.getBoundingClientRect().height,n=i.getBoundingClientRect().top+i.getBoundingClientRect().height;e!==n&&(t.parentNode.style.height="".concat(Math.ceil(n-t.getBoundingClientRect().top),"px"))})))};return e.debounce=a,e.dividersResizeObserver=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,o=new ResizeObserver(a((function(t){var e,i=r(t);try{for(i.s();!(e=i.n()).done;){var o,a=e.value,u=null===(o=a.borderBoxSize)||void 0===o?void 0:o[0].inlineSize;u!==n&&(l(a.target),n=u)}}catch(t){i.e(t)}finally{i.f()}}),250)),u=new MutationObserver((function(n){requestAnimationFrame((function(){var o,a=r(n);try{var u=function(){var n=o.value;if("attributes"===n.type&&"data-unitone-layout"===n.attributeName){var r,a,u,d,s=[].concat(i(null!==(r=null==e||null===(a=e.ignore)||void 0===a?void 0:a.layout)&&void 0!==r?r:[]),["divider:initialized","-bol","-linewrap","-stack"]);(null!==(u=n.target.getAttribute(n.attributeName))&&void 0!==u?u:"").split(" ").filter((function(t){return!s.includes(t)})).join(" ")!==(null!==(d=n.oldValue)&&void 0!==d?d:"").split(" ").filter((function(t){return!s.includes(t)})).join(" ")&&l(t)}else if("attributes"===n.type&&"class"===n.attributeName){var c,v,f,y,g=i(null!==(c=null==e||null===(v=e.ignore)||void 0===v?void 0:v.className)&&void 0!==c?c:[]);(null!==(f=n.target.getAttribute(n.attributeName))&&void 0!==f?f:"").split(" ").filter((function(t){return!g.includes(t)})).join(" ")!==(null!==(y=n.oldValue)&&void 0!==y?y:"").split(" ").filter((function(t){return!g.includes(t)})).join(" ")&&l(t)}else"attributes"===n.type&&"style"===n.attributeName&&l(t)};for(a.s();!(o=a.n()).done;)u()}catch(t){a.e(t)}finally{a.f()}}))}));return o.observe(t),u.observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:o,mutationObserver:u}},e.setColumnCountForVertical=d,e.setDividerLinewrap=l,e.setStairsStep=u,e.stairsResizeObserver=function(t){var e=new ResizeObserver(a((function(t){var e,n=r(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;u(i.target)}}catch(t){n.e(t)}finally{n.f()}}),250));return e.observe(t),e},e.verticalsResizeObserver=function(t){var e=0,n=new ResizeObserver(a((function(t){var n,i=r(t);try{for(i.s();!(n=i.n()).done;){var o,a=n.value,l=null===(o=a.contentRect)||void 0===o?void 0:o.width;parseInt(l)!==parseInt(e)&&(e=l,a.target.parentNode.style.height="",d(a.target))}}catch(t){i.e(t)}finally{i.f()}}),250));n.observe(t);var i=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],a=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==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===a.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===o.getAttribute("data-unitone-layout")||(null==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===a.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===o.getAttribute("data-unitone-layout")||(null==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===a.getAttribute("data-unitone-layout"))return;d(t)}}))}));return i.observe(t,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:n,mutationObserver:i}},e}();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 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,l=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==n.return||n.return()}finally{if(u)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}document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){e.value.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)}))}))}}catch(t){r.e(t)}finally{r.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){e.value.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)}))}))}}catch(t){r.e(t)}finally{r.f()}}))})).observe(document.body,{childList:!0,subtree:!0})})),document.addEventListener("DOMContentLoaded",(function(){new MutationObserver((function(t){requestAnimationFrame((function(){var e,r=i(t);try{for(r.s();!(e=r.n()).done;){e.value.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)}))}))}}catch(t){r.e(t)}finally{r.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 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 a,l=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==n.return||n.return()}finally{if(u)throw a}}}}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),a=0;a<r;a++)o[a]=arguments[a];clearTimeout(n),n=setTimeout((function(){t.apply(i,o)}),e)}}var o=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=i.getBoundingClientRect();t.setAttribute("data-unitone-layout",t.getAttribute("data-unitone-layout").split(" ").filter((function(t){return!["divider:initialized","-stack"].includes(t)})).join(" "));var a=[].slice.call(t.children).filter((function(t){var e=window.getComputedStyle(t).getPropertyValue("position"),n=window.getComputedStyle(t).getPropertyValue("display");return"absolute"!==e&&"fixed"!==e&&"none"!==n}));a.forEach((function(t){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)})),a.forEach((function(t,e){var n,i=null===(n=r)||void 0===n?void 0:n.getBoundingClientRect(),a=t.getBoundingClientRect(),l=t.getAttribute("data-unitone-layout")||"",u=l.split(" ");(0===e||(null==i?void 0:i.top)<a.top&&(null==i?void 0:i.left)>=a.left)&&(u.includes("-bol")||u.push("-bol")),0<e&&o.top<a.top&&(u.includes("-linewrap")||u.push("-linewrap")),u!==l&&t.setAttribute("data-unitone-layout",u.filter(Boolean).join(" ")||""),r=t})),[].slice.call(a).every((function(t){return t.getBoundingClientRect().left===o.left}))&&t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," -stack")),t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," divider:initialized"))}},a=function(t){var e,n=[].slice.call(t.children),i=null==n?void 0:n[0];if(i){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 r,o=[],a=0,l=a,u=window.getComputedStyle(t).getPropertyValue("flex-direction");n.forEach((function(t){var e,n,d=window.getComputedStyle(t).getPropertyValue("position"),s=window.getComputedStyle(t).getPropertyValue("display");if("absolute"!==d&&"fixed"!==d&&"none"!==s){o.push(t);var c="row-reverse"===u?(null===(e=r)||void 0===e||null===(e=e.getBoundingClientRect())||void 0===e?void 0:e.left)<=t.getBoundingClientRect().left:(null===(n=r)||void 0===n||null===(n=n.getBoundingClientRect())||void 0===n?void 0:n.left)>=t.getBoundingClientRect().left;i===t||c?(a=0,t.style.setProperty("--unitone--stairs-step",a)):(a++,t.style.setProperty("--unitone--stairs-step",a)),r=t,a>l&&(l=a)}})),t.style.setProperty("--unitone--max-stairs-step",l);var d=t.getBoundingClientRect().bottom,s=o.reduce((function(t,e){var n=e.getBoundingClientRect().bottom-d;return t>n?t:n}),0);t.style.setProperty("--unitone--stairs-step-overflow-volume",s)}},l=function(t){t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout").replaceAll("vertical-writing:initialized","").trim())),t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout").replaceAll("vertical-writing:safari","").trim())),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"))}([].slice.call(t.children).reverse().some((function(t){if(!["absolute","fixed"].includes(getComputedStyle(t).position)&&"none"!==getComputedStyle(t).display)return e=t,!0})),e)&&(t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," vertical-writing:initialized")),t.getBoundingClientRect().left>e.getBoundingClientRect().left&&t.setAttribute("data-unitone-layout","".concat(t.getAttribute("data-unitone-layout")," vertical-writing:safari")),requestAnimationFrame((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"))})))};exports.debounce=r,exports.dividersResizeObserver=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=0,l=new ResizeObserver(r((function(t){var e,i=n(t);try{for(i.s();!(e=i.n()).done;){var r,l=e.value,u=null===(r=l.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;u!==a&&(o(l.target),a=u)}}catch(t){i.e(t)}finally{i.f()}}),250)),u=new MutationObserver((function(r){requestAnimationFrame((function(){var a,l=n(r);try{var u=function(){var n=a.value;if("attributes"===n.type&&"data-unitone-layout"===n.attributeName){var r,l,u,d,s=[].concat(e(null!==(r=null==i||null===(l=i.ignore)||void 0===l?void 0:l.layout)&&void 0!==r?r:[]),["divider:initialized","-bol","-linewrap","-stack"]);(null!==(u=n.target.getAttribute(n.attributeName))&&void 0!==u?u:"").split(" ").filter((function(t){return!s.includes(t)})).join(" ")!==(null!==(d=n.oldValue)&&void 0!==d?d:"").split(" ").filter((function(t){return!s.includes(t)})).join(" ")&&o(t)}else if("attributes"===n.type&&"class"===n.attributeName){var c,v,f,y,g=e(null!==(c=null==i||null===(v=i.ignore)||void 0===v?void 0:v.className)&&void 0!==c?c:[]);(null!==(f=n.target.getAttribute(n.attributeName))&&void 0!==f?f:"").split(" ").filter((function(t){return!g.includes(t)})).join(" ")!==(null!==(y=n.oldValue)&&void 0!==y?y:"").split(" ").filter((function(t){return!g.includes(t)})).join(" ")&&o(t)}else"attributes"===n.type&&"style"===n.attributeName&&o(t)};for(l.s();!(a=l.n()).done;)u()}catch(t){l.e(t)}finally{l.f()}}))}));return l.observe(t),u.observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:l,mutationObserver:u}},exports.setColumnCountForVertical=l,exports.setDividerLinewrap=o,exports.setStairsStep=a,exports.stairsResizeObserver=function(t){var e=new ResizeObserver(r((function(t){var e,i=n(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;a(r.target)}}catch(t){i.e(t)}finally{i.f()}}),250));return e.observe(t),e},exports.verticalsResizeObserver=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,a=i.value,u=null===(o=a.contentRect)||void 0===o?void 0:o.width;parseInt(u)!==parseInt(e)&&(e=u,a.target.parentNode.style.height="",l(a.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],a=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==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing__thresholder"===a.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===o.getAttribute("data-unitone-layout")||(null==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===a.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===o.getAttribute("data-unitone-layout")||(null==a?void 0:a.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===a.getAttribute("data-unitone-layout"))return;l(t)}}))}));return o.observe(t,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:i,mutationObserver:o}};
1
+ "use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}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,i){if(e){if("string"==typeof e)return t(e,i);var n=Object.prototype.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)?t(e,i):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(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return n(t,e);var i={}.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))||e){i&&(t=i);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(){i=i.call(t)},n:function(){var t=i.next();return a=t.done,t},e:function(t){u=!0,l=t},f:function(){try{a||null==i.return||i.return()}finally{if(u)throw l}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function r(t,e){var i,n=this;return function(){for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];clearTimeout(i),i=setTimeout((function(){t.apply(n,o)}),e)}}var o=function(t){var e,i,n,r=null===(e=[].slice.call(null!==(i=null==t?void 0:t.children)&&void 0!==i?i:[]))||void 0===e?void 0:e[0];if(r){var o,l=r.getBoundingClientRect(),a=(null!==(n=t.getAttribute("data-unitone-layout"))&&void 0!==n?n:"").split(/\s+/);a.some((function(t){return["divider:initialized","-stack"].includes(t)}))&&(a=a.filter((function(t){return!["divider:initialized","-stack"].includes(t)})),t.setAttribute("data-unitone-layout",a.join(" ")));var u=[].slice.call(t.children).filter((function(t){var e=window.getComputedStyle(t).getPropertyValue("position"),i=window.getComputedStyle(t).getPropertyValue("display");return"absolute"!==e&&"fixed"!==e&&"none"!==i}));u.forEach((function(t,e){var i,n,r=(null!==(i=t.getAttribute("data-unitone-layout"))&&void 0!==i?i:"").split(/\s+/);r.some((function(t){return["-bol","-linewrap"].includes(t)}))&&(r=r.filter((function(t){return!["-bol","-linewrap"].includes(t)})),t.setAttribute("data-unitone-layout",r.join(" ")));var a=null===(n=o)||void 0===n?void 0:n.getBoundingClientRect(),u=t.getBoundingClientRect(),s=!1;(0===e||(null==a?void 0:a.top)<u.top&&(null==a?void 0:a.left)>=u.left)&&(r.push("-bol"),s=!0),0<e&&l.top<u.top&&(r.push("-linewrap"),s=!0),s&&t.setAttribute("data-unitone-layout",r.join(" ")),o=t})),[].slice.call(u).every((function(t){return t.getBoundingClientRect().left===l.left}))&&a.push("-stack"),a.push("divider:initialized"),t.setAttribute("data-unitone-layout",a.join(" "))}},l=function(t){var e,i=[].slice.call(t.children),n=null==i?void 0:i[0];if(n){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 r,o=[],l=0,a=l,u=window.getComputedStyle(t).getPropertyValue("flex-direction");i.forEach((function(t){var e,i,s=window.getComputedStyle(t).getPropertyValue("position"),d=window.getComputedStyle(t).getPropertyValue("display");if("absolute"!==s&&"fixed"!==s&&"none"!==d){o.push(t);var c="row-reverse"===u?(null===(e=r)||void 0===e||null===(e=e.getBoundingClientRect())||void 0===e?void 0:e.left)<=t.getBoundingClientRect().left:(null===(i=r)||void 0===i||null===(i=i.getBoundingClientRect())||void 0===i?void 0:i.left)>=t.getBoundingClientRect().left;n===t||c?(l=0,t.style.setProperty("--unitone--stairs-step",l)):(l++,t.style.setProperty("--unitone--stairs-step",l)),r=t,l>a&&(a=l)}})),t.style.setProperty("--unitone--max-stairs-step",a);var s=t.getBoundingClientRect().bottom,d=o.reduce((function(t,e){var i=e.getBoundingClientRect().bottom-s;return t>i?t:i}),0);t.style.setProperty("--unitone--stairs-step-overflow-volume",d)}},a=function(t){var e,i=(null!==(e=t.getAttribute("data-unitone-layout"))&&void 0!==e?e:"").split(/\s+/);i.some((function(t){return["vertical-writing:initialized","vertical-writing:safari","-force-switch"].includes(t)}))&&(i=i.filter((function(t){return!["vertical-writing:initialized","vertical-writing:safari","-force-switch"].includes(t)})),t.setAttribute("data-unitone-layout",i.join(" ")));var n,r=getComputedStyle(t);if(String(r.getPropertyValue("--unitone--threshold")).trim()){var o=document.createElement("div");o.setAttribute("data-unitone-layout","vertical-writing__thresholder"),t.appendChild(o);var l=o.offsetWidth>=t.offsetWidth;t.removeChild(o),l&&(i.push("-force-switch"),t.setAttribute("data-unitone-layout",i.join(" ")))}([].slice.call(t.children).reverse().some((function(t){if(!["absolute","fixed"].includes(getComputedStyle(t).position)&&"none"!==getComputedStyle(t).display)return n=t,!0})),n)&&(i.push("vertical-writing:initialized"),t.getBoundingClientRect().left>n.getBoundingClientRect().left&&i.push("vertical-writing:safari"),t.setAttribute("data-unitone-layout",i.join(" ")),requestAnimationFrame((function(){var e=t.getBoundingClientRect().top+t.getBoundingClientRect().height,i=n.getBoundingClientRect().top+n.getBoundingClientRect().height;e!==i&&(t.parentNode.style.height="".concat(Math.ceil(i-t.getBoundingClientRect().top),"px"))})))};exports.debounce=r,exports.dividersResizeObserver=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=0,a=new ResizeObserver(r((function(t){var e,n=i(t);try{for(n.s();!(e=n.n()).done;){var r,a=e.value,u=null===(r=a.borderBoxSize)||void 0===r?void 0:r[0].inlineSize;u!==l&&(o(a.target),l=u)}}catch(t){n.e(t)}finally{n.f()}}),250)),u=new MutationObserver((function(r){requestAnimationFrame((function(){var l,a=i(r);try{var u=function(){var i=l.value;if("attributes"===i.type&&"data-unitone-layout"===i.attributeName){var r,a,u,s,d=[].concat(e(null!==(r=null==n||null===(a=n.ignore)||void 0===a?void 0:a.layout)&&void 0!==r?r:[]),["divider:initialized","-bol","-linewrap","-stack"]);(null!==(u=i.target.getAttribute(i.attributeName))&&void 0!==u?u:"").split(" ").filter((function(t){return!d.includes(t)})).join(" ")!==(null!==(s=i.oldValue)&&void 0!==s?s:"").split(" ").filter((function(t){return!d.includes(t)})).join(" ")&&o(t)}else if("attributes"===i.type&&"class"===i.attributeName){var c,v,f,y,p=e(null!==(c=null==n||null===(v=n.ignore)||void 0===v?void 0:v.className)&&void 0!==c?c:[]);(null!==(f=i.target.getAttribute(i.attributeName))&&void 0!==f?f:"").split(" ").filter((function(t){return!p.includes(t)})).join(" ")!==(null!==(y=i.oldValue)&&void 0!==y?y:"").split(" ").filter((function(t){return!p.includes(t)})).join(" ")&&o(t)}else"attributes"===i.type&&"style"===i.attributeName&&o(t)};for(a.s();!(l=a.n()).done;)u()}catch(t){a.e(t)}finally{a.f()}}))}));return a.observe(t),u.observe(t,{attributes:!0,attributeFilter:["style","data-unitone-layout","class"],attributeOldValue:!0,subtree:!0,characterData:!0}),{resizeObserver:a,mutationObserver:u}},exports.setColumnCountForVertical=a,exports.setDividerLinewrap=o,exports.setStairsStep=l,exports.stairsResizeObserver=function(t){var e=new ResizeObserver(r((function(t){var e,n=i(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;l(r.target)}}catch(t){n.e(t)}finally{n.f()}}),250));return e.observe(t),e},exports.verticalsResizeObserver=function(t){var e=0,n=new ResizeObserver(r((function(t){var n,r=i(t);try{for(r.s();!(n=r.n()).done;){var o,l=n.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));n.observe(t);var o=new MutationObserver((function(e){requestAnimationFrame((function(){if(0<e.length){var i,n,r=e[0],o=null===(i=r.addedNodes)||void 0===i?void 0:i[0],l=null===(n=r.removedNodes)||void 0===n?void 0:n[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")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===o.getAttribute("data-unitone-layout")||(null==l?void 0:l.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:initialized"===l.getAttribute("data-unitone-layout")||(null==o?void 0:o.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===o.getAttribute("data-unitone-layout")||(null==l?void 0:l.nodeType)===Node.ELEMENT_NODE&&"vertical-writing:safari"===l.getAttribute("data-unitone-layout"))return;a(t)}}))}));return o.observe(t,{attributes:!0,attributeFilter:["style"],childList:!0,subtree:!0}),{resizeObserver:n,mutationObserver:o}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inc2734/unitone-css",
3
- "version": "0.83.0",
3
+ "version": "0.83.2",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=20.10.0",
package/src/library.js CHANGED
@@ -14,17 +14,17 @@ export const setDividerLinewrap = (target) => {
14
14
  if (!firstChild) {
15
15
  return;
16
16
  }
17
+
17
18
  let prevChild;
18
19
  const baseRect = firstChild.getBoundingClientRect();
19
20
 
20
- target.setAttribute(
21
- 'data-unitone-layout',
22
- target
23
- .getAttribute('data-unitone-layout')
24
- .split(' ')
25
- .filter((value) => !['divider:initialized', '-stack'].includes(value))
26
- .join(' '),
27
- );
21
+ let currentLayoutArray = (target.getAttribute('data-unitone-layout') ?? '').split(/\s+/);
22
+ if (currentLayoutArray.some((value) => ['divider:initialized', '-stack'].includes(value))) {
23
+ currentLayoutArray = currentLayoutArray.filter(
24
+ (value) => !['divider:initialized', '-stack'].includes(value),
25
+ );
26
+ target.setAttribute('data-unitone-layout', currentLayoutArray.join(' '));
27
+ }
28
28
 
29
29
  const targetChildren = [].slice.call(target.children).filter((child) => {
30
30
  const position = window.getComputedStyle(child).getPropertyValue('position');
@@ -32,39 +32,32 @@ export const setDividerLinewrap = (target) => {
32
32
  return 'absolute' !== position && 'fixed' !== position && 'none' !== display;
33
33
  });
34
34
 
35
- targetChildren.forEach((child) => {
36
- const currentLayout = child.getAttribute('data-unitone-layout') || '';
37
- const newLayout = currentLayout
38
- .split(' ')
39
- .filter((value) => !['-bol', '-linewrap'].includes(value))
40
- .join(' ');
41
-
42
- if (newLayout !== currentLayout) {
43
- child.setAttribute('data-unitone-layout', newLayout);
35
+ targetChildren.forEach((child, index) => {
36
+ let childCurrentLayoutArray = (child.getAttribute('data-unitone-layout') ?? '').split(/\s+/);
37
+ if (childCurrentLayoutArray.some((value) => ['-bol', '-linewrap'].includes(value))) {
38
+ childCurrentLayoutArray = childCurrentLayoutArray.filter(
39
+ (value) => !['-bol', '-linewrap'].includes(value),
40
+ );
41
+ child.setAttribute('data-unitone-layout', childCurrentLayoutArray.join(' '));
44
42
  }
45
- });
46
43
 
47
- targetChildren.forEach((child, index) => {
48
44
  const prevRect = prevChild?.getBoundingClientRect();
49
45
  const childRect = child.getBoundingClientRect();
50
46
 
51
- const currentLayout = child.getAttribute('data-unitone-layout') || '';
52
- const newLayout = currentLayout.split(' ');
47
+ let shouldUpdate = false;
53
48
 
54
49
  if (0 === index || (prevRect?.top < childRect.top && prevRect?.left >= childRect.left)) {
55
- if (!newLayout.includes('-bol')) {
56
- newLayout.push('-bol');
57
- }
50
+ childCurrentLayoutArray.push('-bol');
51
+ shouldUpdate = true;
58
52
  }
59
53
 
60
54
  if (0 < index && baseRect.top < childRect.top) {
61
- if (!newLayout.includes('-linewrap')) {
62
- newLayout.push('-linewrap');
63
- }
55
+ childCurrentLayoutArray.push('-linewrap');
56
+ shouldUpdate = true;
64
57
  }
65
58
 
66
- if (newLayout !== currentLayout) {
67
- child.setAttribute('data-unitone-layout', newLayout.filter(Boolean).join(' ') || '');
59
+ if (shouldUpdate) {
60
+ child.setAttribute('data-unitone-layout', childCurrentLayoutArray.join(' '));
68
61
  }
69
62
 
70
63
  prevChild = child;
@@ -74,16 +67,11 @@ export const setDividerLinewrap = (target) => {
74
67
  .call(targetChildren)
75
68
  .every((child) => child.getBoundingClientRect().left === baseRect.left);
76
69
  if (isStack) {
77
- target.setAttribute(
78
- 'data-unitone-layout',
79
- `${target.getAttribute('data-unitone-layout')} -stack`,
80
- );
70
+ currentLayoutArray.push('-stack');
81
71
  }
82
72
 
83
- target.setAttribute(
84
- 'data-unitone-layout',
85
- `${target.getAttribute('data-unitone-layout')} divider:initialized`,
86
- );
73
+ currentLayoutArray.push('divider:initialized');
74
+ target.setAttribute('data-unitone-layout', currentLayoutArray.join(' '));
87
75
  };
88
76
 
89
77
  export const dividersResizeObserver = (target, args = {}) => {
@@ -241,21 +229,22 @@ export const stairsResizeObserver = (target) => {
241
229
  };
242
230
 
243
231
  export const setColumnCountForVertical = (target) => {
244
- target.setAttribute(
245
- 'data-unitone-layout',
246
- `${target.getAttribute('data-unitone-layout').replaceAll('vertical-writing:initialized', '').trim()}`,
247
- );
248
-
249
- target.setAttribute(
250
- 'data-unitone-layout',
251
- `${target.getAttribute('data-unitone-layout').replaceAll('vertical-writing:safari', '').trim()}`,
252
- );
232
+ let currentLayoutArray = (target.getAttribute('data-unitone-layout') ?? '').split(/\s+/);
233
+ if (
234
+ currentLayoutArray.some((value) =>
235
+ ['vertical-writing:initialized', 'vertical-writing:safari', '-force-switch'].includes(value),
236
+ )
237
+ ) {
238
+ currentLayoutArray = currentLayoutArray.filter(
239
+ (value) =>
240
+ !['vertical-writing:initialized', 'vertical-writing:safari', '-force-switch'].includes(
241
+ value,
242
+ ),
243
+ );
244
+ target.setAttribute('data-unitone-layout', currentLayoutArray.join(' '));
245
+ }
253
246
 
254
247
  // Process of the threshold
255
- target.setAttribute(
256
- 'data-unitone-layout',
257
- target.getAttribute('data-unitone-layout').replace(' -force-switch', ''),
258
- );
259
248
  const computedStyle = getComputedStyle(target);
260
249
  const threshold = String(computedStyle.getPropertyValue('--unitone--threshold')).trim();
261
250
  if (!!threshold) {
@@ -265,11 +254,8 @@ export const setColumnCountForVertical = (target) => {
265
254
  const forceSwitch = thresholder.offsetWidth >= target.offsetWidth;
266
255
  target.removeChild(thresholder);
267
256
  if (forceSwitch) {
268
- target.setAttribute(
269
- 'data-unitone-layout',
270
- `${target.getAttribute('data-unitone-layout')} -force-switch`,
271
- );
272
- return;
257
+ currentLayoutArray.push('-force-switch');
258
+ target.setAttribute('data-unitone-layout', currentLayoutArray.join(' '));
273
259
  }
274
260
  }
275
261
 
@@ -291,20 +277,16 @@ export const setColumnCountForVertical = (target) => {
291
277
  return;
292
278
  }
293
279
 
294
- target.setAttribute(
295
- 'data-unitone-layout',
296
- `${target.getAttribute('data-unitone-layout')} vertical-writing:initialized`,
297
- );
280
+ currentLayoutArray.push('vertical-writing:initialized');
298
281
 
299
282
  // For Safari
300
283
  const maybeSafari = target.getBoundingClientRect().left > lastChild.getBoundingClientRect().left;
301
284
  if (maybeSafari) {
302
- target.setAttribute(
303
- 'data-unitone-layout',
304
- `${target.getAttribute('data-unitone-layout')} vertical-writing:safari`,
305
- );
285
+ currentLayoutArray.push('vertical-writing:safari');
306
286
  }
307
287
 
288
+ target.setAttribute('data-unitone-layout', currentLayoutArray.join(' '));
289
+
308
290
  requestAnimationFrame(() => {
309
291
  const targetY = target.getBoundingClientRect().top + target.getBoundingClientRect().height;
310
292
  const lastChildY =