@carbon/utilities 0.15.0 → 0.16.0

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.
@@ -1 +1 @@
1
- import{registerSwipeEvents as x}from"./swipeEvents";const ne=(i,C)=>{const r="carousel";let n=[0],m=[0];const l={},h=4,{onViewChangeStart:S,onViewChangeEnd:v,excludeSwipeSupport:E,useMaxHeight:k}=C||{},$=(e,t)=>{l[e]=t},V=(e,t)=>{if(e.querySelector(`.${t}`))return;const o=document.createElement("div");for(o.classList.add(`${t}`);e.firstChild;)o.appendChild(e.firstChild);e.appendChild(o)},A=()=>n.map(e=>({id:e,elem:l[e]})),L=()=>{const e=Object.keys(l).length,t=l[e-1],o=A();return{currentIndex:n[0],lastIndex:parseInt(t?.dataset.index||n[0].toString(),10),totalViews:e,historyStack:o}},H=()=>{m=[...n];const e=L();S?.(e)},T=e=>{if(!e)return;const t=e.dataset.index;if(t&&n[0]===parseInt(t,10)){const o=L();v?.(o)}},R=e=>{const o=Object.keys(l).length-1;return Math.max(0,Math.min(e,o))},_=e=>{const t=R(e);n[0]!==t&&(H(),n=[t,...n],u(!1))},w=e=>{T(e)},I=(e,t,o,s,a)=>{e.classList.add(`${r}__view`),e.classList.toggle(`${r}__view-in-stack`,t&&!o),e.classList.toggle(`${r}__view-active`,t&&o),a&&!s&&e.classList.add(`${r}__view-recycle-in`),!a&&s&&e.classList.add(`${r}__view-recycle-out`)},W=e=>{e.classList.remove(`${r}__view-recycle-in`,`${r}__view-recycle-out`)},M=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),y=e=>{const t=M(h);if(i.clientHeight<t){e<t&&(e=t);const s=i.querySelector(`.${r}__itemsWrapper`);s&&(s.style.blockSize=`${e}px`)}},u=e=>{let t=0,o=0;Array.from(g).forEach((s,a)=>{const N=n.findIndex(c=>c===a),b=m.filter(c=>c===a).length,P=m.length>n.length&&m[0]===a&&b>0,B=m.length<n.length&&n[0]===a&&b>0,G=N>-1,J=a===n[0];if(I(s,G,J,P,B),e){$(a,s),setTimeout(()=>{if(k){const p=Array.from(g).map(K=>K.scrollHeight);o=Math.max(...p),s.style.position="absolute",y(o)}else(!t||s.offsetHeight<t&&t>M(h))&&(t=s.offsetHeight),s.style.position="absolute",y(t)});const c=p=>{W(s),p.target===l[n[0]]&&w(s)};s._carouselListener=c,s.addEventListener("animationend",c),s.addEventListener("transitionend",c),s.setAttribute("data-index",a.toString())}}),e&&T(Array.from(g)[0])},d=()=>{const e=n[0]+1;_(e)},f=()=>{n.length-1>=1&&(H(),n=n.slice(1),u(!1))},q=e=>{_(e)},z=()=>({index:n[0],item:l[n[0]]}),j=()=>{n=[0],u(!1)},D=()=>{Object.values(l).forEach(e=>{const t=e;e&&t._carouselListener&&(e.removeEventListener("animationend",t._carouselListener),e.removeEventListener("transitionend",t._carouselListener))}),E||x(i,d,f,!0)},O=e=>{const t=e.querySelector("slot");return t?t.assignedElements({flatten:!0}):Array.from(e.children)};V(i,`${r}__itemsWrapper`);const F=i.querySelector(`.${r}__itemsWrapper`),g=O(F);return i.classList.add(`${r}__view-stack`),u(!0),E||x(i,d,f,!1),{next:d,prev:f,reset:j,goToIndex:q,getActiveItem:z,destroyEvents:D,allViews:l}};export{ne as initCarousel};
1
+ import{registerSwipeEvents as C}from"./swipeEvents";const ne=(i,S)=>{const r="carousel";let n=[0],m=[0];const l={},h=4,{onViewChangeStart:v,onViewChangeEnd:k,excludeSwipeSupport:E,useMaxHeight:$}=S||{},V=(e,t)=>{l[e]=t},A=(e,t)=>{if(e.querySelector(`.${t}`))return;const o=document.createElement("div");for(o.classList.add(`${t}`);e.firstChild;)o.appendChild(e.firstChild);e.appendChild(o)},R=()=>n.map(e=>({id:e,elem:l[e]})),L=()=>{const e=Object.keys(l).length,t=l[e-1],o=R();return{currentIndex:n[0],lastIndex:parseInt(t?.dataset.index||n[0].toString(),10),totalViews:e,historyStack:o}},H=()=>{m=[...n];const e=L();v?.(e)},T=e=>{if(!e)return;const t=e.dataset.index;if(t&&n[0]===parseInt(t,10)){const o=L();k?.(o)}},w=e=>{const o=Object.keys(l).length-1;return Math.max(0,Math.min(e,o))},M=e=>{const t=w(e);n[0]!==t&&(H(),n=[t,...n],u(!1))},I=e=>{T(e)},W=(e,t,o,s,a)=>{e.classList.add(`${r}__view`),e.classList.toggle(`${r}__view-in-stack`,t&&!o),e.classList.toggle(`${r}__view-active`,t&&o),a&&!s&&e.classList.add(`${r}__view-recycle-in`),!a&&s&&e.classList.add(`${r}__view-recycle-out`)},_=e=>{e.classList.remove(`${r}__view-recycle-in`,`${r}__view-recycle-out`)},y=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),b=e=>{const t=y(h);if(i.clientHeight<t){e<t&&(e=t);const s=i.querySelector(`.${r}__itemsWrapper`);s&&(s.style.blockSize=`${e}px`)}},u=e=>{let t=0,o=0;Array.from(d).forEach((s,a)=>{const N=n.findIndex(c=>c===a),x=m.filter(c=>c===a).length,P=m.length>n.length&&m[0]===a&&x>0,B=m.length<n.length&&n[0]===a&&x>0,G=N>-1,J=a===n[0];if(W(s,G,J,P,B),e){V(a,s),setTimeout(()=>{if($){const p=Array.from(d).map(K=>K.scrollHeight);o=Math.max(...p),s.style.position="absolute",b(o)}else(!t||s.offsetHeight<t&&t>y(h))&&(t=s.offsetHeight),s.style.position="absolute",b(t)});const c=p=>{_(s),p.target===l[n[0]]&&I(s)};s._carouselListener=c,s.addEventListener("animationend",c),s.addEventListener("transitionend",c),s.setAttribute("data-index",a.toString())}}),e&&T(Array.from(d)[0])},f=()=>{const e=n[0]+1;M(e)},g=()=>{n.length-1>=1&&(H(),n=n.slice(1),u(!1))},q=e=>{M(e)},z=()=>({index:n[0],item:l[n[0]]}),j=()=>{Array.from(d).forEach(e=>{_(e)}),m=[0],n=[0],u(!1)},D=()=>{Object.values(l).forEach(e=>{const t=e;e&&t._carouselListener&&(e.removeEventListener("animationend",t._carouselListener),e.removeEventListener("transitionend",t._carouselListener))}),E||C(i,f,g,!0)},O=e=>{const t=e.querySelector("slot");return t?t.assignedElements({flatten:!0}):Array.from(e.children)};A(i,`${r}__itemsWrapper`);const F=i.querySelector(`.${r}__itemsWrapper`),d=O(F);return i.classList.add(`${r}__view-stack`),u(!0),E||C(i,f,g,!1),{next:f,prev:g,reset:j,goToIndex:q,getActiveItem:z,destroyEvents:D,allViews:l}};export{ne as initCarousel};
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(a,l)=>{for(var o in l)E(a,o,{get:l[o],enumerable:!0})},ee=(a,l,o,n)=>{if(l&&typeof l=="object"||typeof l=="function")for(let i of X(l))!Y.call(a,i)&&i!==o&&E(a,i,{get:()=>l[i],enumerable:!(n=U(l,i))||n.enumerable});return a};var te=a=>ee(E({},"__esModule",{value:!0}),a);var se={};Z(se,{initCarousel:()=>ne});module.exports=te(se);var L=require("./swipeEvents");const ne=(a,l)=>{const o="carousel";let n=[0],i=[0];const m={},H=4,{onViewChangeStart:v,onViewChangeEnd:k,excludeSwipeSupport:T,useMaxHeight:$}=l||{},V=(e,t)=>{m[e]=t},A=(e,t)=>{if(e.querySelector(`.${t}`))return;const r=document.createElement("div");for(r.classList.add(`${t}`);e.firstChild;)r.appendChild(e.firstChild);e.appendChild(r)},R=()=>n.map(e=>({id:e,elem:m[e]})),_=()=>{const e=Object.keys(m).length,t=m[e-1],r=R();return{currentIndex:n[0],lastIndex:parseInt(t?.dataset.index||n[0].toString(),10),totalViews:e,historyStack:r}},M=()=>{i=[...n];const e=_();v?.(e)},y=e=>{if(!e)return;const t=e.dataset.index;if(t&&n[0]===parseInt(t,10)){const r=_();k?.(r)}},w=e=>{const r=Object.keys(m).length-1;return Math.max(0,Math.min(e,r))},b=e=>{const t=w(e);n[0]!==t&&(M(),n=[t,...n],d(!1))},I=e=>{y(e)},W=(e,t,r,s,c)=>{e.classList.add(`${o}__view`),e.classList.toggle(`${o}__view-in-stack`,t&&!r),e.classList.toggle(`${o}__view-active`,t&&r),c&&!s&&e.classList.add(`${o}__view-recycle-in`),!c&&s&&e.classList.add(`${o}__view-recycle-out`)},q=e=>{e.classList.remove(`${o}__view-recycle-in`,`${o}__view-recycle-out`)},x=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),C=e=>{const t=x(H);if(a.clientHeight<t){e<t&&(e=t);const s=a.querySelector(`.${o}__itemsWrapper`);s&&(s.style.blockSize=`${e}px`)}},d=e=>{let t=0,r=0;Array.from(p).forEach((s,c)=>{const P=n.findIndex(u=>u===c),S=i.filter(u=>u===c).length,B=i.length>n.length&&i[0]===c&&S>0,G=i.length<n.length&&n[0]===c&&S>0,J=P>-1,K=c===n[0];if(W(s,J,K,B,G),e){V(c,s),setTimeout(()=>{if($){const h=Array.from(p).map(Q=>Q.scrollHeight);r=Math.max(...h),s.style.position="absolute",C(r)}else(!t||s.offsetHeight<t&&t>x(H))&&(t=s.offsetHeight),s.style.position="absolute",C(t)});const u=h=>{q(s),h.target===m[n[0]]&&I(s)};s._carouselListener=u,s.addEventListener("animationend",u),s.addEventListener("transitionend",u),s.setAttribute("data-index",c.toString())}}),e&&y(Array.from(p)[0])},f=()=>{const e=n[0]+1;b(e)},g=()=>{n.length-1>=1&&(M(),n=n.slice(1),d(!1))},z=e=>{b(e)},j=()=>({index:n[0],item:m[n[0]]}),D=()=>{n=[0],d(!1)},O=()=>{Object.values(m).forEach(e=>{const t=e;e&&t._carouselListener&&(e.removeEventListener("animationend",t._carouselListener),e.removeEventListener("transitionend",t._carouselListener))}),T||(0,L.registerSwipeEvents)(a,f,g,!0)},F=e=>{const t=e.querySelector("slot");return t?t.assignedElements({flatten:!0}):Array.from(e.children)};A(a,`${o}__itemsWrapper`);const N=a.querySelector(`.${o}__itemsWrapper`),p=F(N);return a.classList.add(`${o}__view-stack`),d(!0),T||(0,L.registerSwipeEvents)(a,f,g,!1),{next:f,prev:g,reset:D,goToIndex:z,getActiveItem:j,destroyEvents:O,allViews:m}};
1
+ "use strict";var E=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(a,i)=>{for(var o in i)E(a,o,{get:i[o],enumerable:!0})},ee=(a,i,o,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of X(i))!Y.call(a,l)&&l!==o&&E(a,l,{get:()=>i[l],enumerable:!(n=U(i,l))||n.enumerable});return a};var te=a=>ee(E({},"__esModule",{value:!0}),a);var se={};Z(se,{initCarousel:()=>ne});module.exports=te(se);var L=require("./swipeEvents");const ne=(a,i)=>{const o="carousel";let n=[0],l=[0];const m={},H=4,{onViewChangeStart:k,onViewChangeEnd:$,excludeSwipeSupport:T,useMaxHeight:V}=i||{},A=(e,t)=>{m[e]=t},R=(e,t)=>{if(e.querySelector(`.${t}`))return;const r=document.createElement("div");for(r.classList.add(`${t}`);e.firstChild;)r.appendChild(e.firstChild);e.appendChild(r)},w=()=>n.map(e=>({id:e,elem:m[e]})),M=()=>{const e=Object.keys(m).length,t=m[e-1],r=w();return{currentIndex:n[0],lastIndex:parseInt(t?.dataset.index||n[0].toString(),10),totalViews:e,historyStack:r}},_=()=>{l=[...n];const e=M();k?.(e)},y=e=>{if(!e)return;const t=e.dataset.index;if(t&&n[0]===parseInt(t,10)){const r=M();$?.(r)}},I=e=>{const r=Object.keys(m).length-1;return Math.max(0,Math.min(e,r))},b=e=>{const t=I(e);n[0]!==t&&(_(),n=[t,...n],d(!1))},W=e=>{y(e)},q=(e,t,r,s,c)=>{e.classList.add(`${o}__view`),e.classList.toggle(`${o}__view-in-stack`,t&&!r),e.classList.toggle(`${o}__view-active`,t&&r),c&&!s&&e.classList.add(`${o}__view-recycle-in`),!c&&s&&e.classList.add(`${o}__view-recycle-out`)},x=e=>{e.classList.remove(`${o}__view-recycle-in`,`${o}__view-recycle-out`)},C=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),S=e=>{const t=C(H);if(a.clientHeight<t){e<t&&(e=t);const s=a.querySelector(`.${o}__itemsWrapper`);s&&(s.style.blockSize=`${e}px`)}},d=e=>{let t=0,r=0;Array.from(f).forEach((s,c)=>{const P=n.findIndex(u=>u===c),v=l.filter(u=>u===c).length,B=l.length>n.length&&l[0]===c&&v>0,G=l.length<n.length&&n[0]===c&&v>0,J=P>-1,K=c===n[0];if(q(s,J,K,B,G),e){A(c,s),setTimeout(()=>{if(V){const h=Array.from(f).map(Q=>Q.scrollHeight);r=Math.max(...h),s.style.position="absolute",S(r)}else(!t||s.offsetHeight<t&&t>C(H))&&(t=s.offsetHeight),s.style.position="absolute",S(t)});const u=h=>{x(s),h.target===m[n[0]]&&W(s)};s._carouselListener=u,s.addEventListener("animationend",u),s.addEventListener("transitionend",u),s.setAttribute("data-index",c.toString())}}),e&&y(Array.from(f)[0])},g=()=>{const e=n[0]+1;b(e)},p=()=>{n.length-1>=1&&(_(),n=n.slice(1),d(!1))},z=e=>{b(e)},j=()=>({index:n[0],item:m[n[0]]}),D=()=>{Array.from(f).forEach(e=>{x(e)}),l=[0],n=[0],d(!1)},O=()=>{Object.values(m).forEach(e=>{const t=e;e&&t._carouselListener&&(e.removeEventListener("animationend",t._carouselListener),e.removeEventListener("transitionend",t._carouselListener))}),T||(0,L.registerSwipeEvents)(a,g,p,!0)},F=e=>{const t=e.querySelector("slot");return t?t.assignedElements({flatten:!0}):Array.from(e.children)};R(a,`${o}__itemsWrapper`);const N=a.querySelector(`.${o}__itemsWrapper`),f=F(N);return a.classList.add(`${o}__view-stack`),d(!0),T||(0,L.registerSwipeEvents)(a,g,p,!1),{next:g,prev:p,reset:D,goToIndex:z,getActiveItem:j,destroyEvents:O,allViews:m}};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/utilities",
3
3
  "description": "Utilities and helpers to drive consistency across software products using the Carbon Design System",
4
- "version": "0.15.0",
4
+ "version": "0.16.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -49,5 +49,5 @@
49
49
  "@ibm/telemetry-js": "^1.6.1",
50
50
  "@internationalized/number": "^3.6.1"
51
51
  },
52
- "gitHead": "f366448449df3d81c9bb63a8a842772d734c163a"
52
+ "gitHead": "6dde90f9edfb378e1585f1954c92484a37f22f02"
53
53
  }