number-flow 0.6.0 → 0.6.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/csp.js +1 -1
- package/dist/csp.mjs +1 -1
- package/dist/group.js +1 -1
- package/dist/group.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/lite.d.ts +1 -0
- package/dist/lite.js +1 -1
- package/dist/lite.mjs +55 -54
- package/dist/{ssr-CG0bH5A-.js → ssr-B-DD5oSO.js} +3 -3
- package/dist/{ssr-Cre0Q1Ju.mjs → ssr-DvIINv8w.mjs} +9 -9
- package/package.json +1 -1
package/dist/csp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ssr-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ssr-B-DD5oSO.js"),t=s=>[e.styles,e.renderFallbackStyles(s),e.styles$1];exports.buildStyles=t;
|
package/dist/csp.mjs
CHANGED
package/dist/group.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("./lite.js"),a=require("./ssr-
|
|
1
|
+
"use strict";const r=require("./lite.js"),a=require("./ssr-B-DD5oSO.js"),t=require("./index.js");class n extends a.ServerSafeHTMLElement{constructor(){super(...arguments),this._flows=new Set,this._addDescendant=e=>{e.batched=!0,this._flows.add(e)},this._removeDescendant=e=>{e.batched=!1,this._flows.delete(e)},this._onDescendantConnected=e=>{this._addDescendant(e.target)},this._updating=!1,this._onDescendantUpdate=()=>{this._updating||(this._updating=!0,this._flows.forEach(e=>{e.created&&(e.willUpdate(),queueMicrotask(()=>{e.connected&&e.didUpdate()}))}),queueMicrotask(()=>{this._updating=!1}))}}connectedCallback(){this.querySelectorAll("number-flow").forEach(e=>{this._addDescendant(e)}),this.addEventListener(t.CONNECT_EVENT,this._onDescendantConnected),this.addEventListener(t.UPDATE_EVENT,this._onDescendantUpdate),this._mutationObserver??(this._mutationObserver=new MutationObserver(e=>{e.forEach(i=>{i.removedNodes.forEach(s=>{s instanceof t.default&&this._removeDescendant(s)})})})),this._mutationObserver.observe(this,{childList:!0,subtree:!0})}disconnectedCallback(){var e;this.removeEventListener(t.CONNECT_EVENT,this._onDescendantConnected),this.removeEventListener(t.UPDATE_EVENT,this._onDescendantUpdate),(e=this._mutationObserver)==null||e.disconnect()}}r.define("number-flow-group",n);module.exports=n;
|
package/dist/group.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./lite.js"),n=require("./ssr-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./lite.js"),n=require("./ssr-B-DD5oSO.js"),d=require("./csp.js"),m=require("./plugins.js"),h=d.buildStyles(),s="number-flow-connect",i="number-flow-update",b=(r,{locales:t,format:a,numberPrefix:u,numberSuffix:c,nonce:l}={})=>{const f=e.formatToData(r,new Intl.NumberFormat(t,a),u,c);return n.renderInnerHTML(f,{nonce:l})};class o extends e.default{constructor(){super(...arguments),this.connected=!1}connectedCallback(){this.connected=!0,this.dispatchEvent(new Event(s,{bubbles:!0}))}disconnectedCallback(){this.connected=!1}get value(){return this._value}update(t){(!this._formatter||this._prevFormat!==this.format||this._prevLocales!==this.locales)&&(this._formatter=new Intl.NumberFormat(this.locales,this.format),this._prevFormat=this.format,this._prevLocales=this.locales),t!=null&&(this._value=t),this.dispatchEvent(new Event(i,{bubbles:!0})),this.data=e.formatToData(this._value,this._formatter,this.numberPrefix,this.numberSuffix)}}e.define("number-flow",o);exports.Digit=e.Digit;exports.canAnimate=e.canAnimate;exports.define=e.define;exports.formatToData=e.formatToData;exports.prefersReducedMotion=n.prefersReducedMotion;exports.continuous=m.continuous;exports.CONNECT_EVENT=s;exports.UPDATE_EVENT=i;exports.default=o;exports.renderInnerHTML=b;exports.styles=h;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import u, { define as l, formatToData as r } from "./lite.mjs";
|
|
2
2
|
import { Digit as N, canAnimate as T } from "./lite.mjs";
|
|
3
|
-
import { r as m } from "./ssr-
|
|
4
|
-
import { p as L } from "./ssr-
|
|
3
|
+
import { r as m } from "./ssr-DvIINv8w.mjs";
|
|
4
|
+
import { p as L } from "./ssr-DvIINv8w.mjs";
|
|
5
5
|
import { buildStyles as c } from "./csp.mjs";
|
|
6
6
|
import { continuous as I } from "./plugins.mjs";
|
|
7
7
|
const v = c(), f = "number-flow-connect", h = "number-flow-update", E = (e, { locales: t, format: s, numberPrefix: n, numberSuffix: o, nonce: i } = {}) => {
|
package/dist/lite.d.ts
CHANGED
package/dist/lite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("esm-env"),f=require("./ssr-CG0bH5A-.js"),T=require("./plugins.js"),u=(n,t,e)=>{const i=document.createElement(n),[s,o]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),o==null||o.forEach(r=>i.appendChild(r)),i},S=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},M=n=>n.offsetWidth>0&&n.offsetHeight>0,L=(n,t)=>{j.BROWSER&&!customElements.get(n)&&customElements.define(n,t)};function P(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function N(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const o=[],r=[],a=[],d=[],c={},p=l=>`${l}:${c[l]=(c[l]??-1)+1}`;let m="",g=!1,_=!1;for(const l of s){m+=l.value;const h=l.type==="minusSign"||l.type==="plusSign"?"sign":l.type;h==="integer"?(g=!0,r.push(...l.value.split("").map(y=>({type:h,value:parseInt(y)})))):h==="group"?r.push({type:h,value:l.value}):h==="decimal"?(_=!0,a.push({type:h,value:l.value,key:p(h)})):h==="fraction"?a.push(...l.value.split("").map(y=>({type:h,value:parseInt(y),key:p(h),pos:-1-c[h]}))):(g||_?d:o).push({type:h,value:l.value,key:p(h)})}const b=[];for(let l=r.length-1;l>=0;l--){const h=r[l];b.unshift(h.type==="integer"?{...h,key:p(h.type),pos:c[h.type]}:{...h,key:p(h.type)})}return{pre:o,integer:b,fraction:a,post:d,valueAsString:m,value:typeof n=="string"?parseFloat(n):n}}const R=f.supportsMod&&f.supportsLinear&&f.supportsAtProperty;class C extends f.ServerSafeHTMLElement{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var a,d;if(t==null)return;const{pre:e,integer:i,fraction:s,post:o,value:r}=t;if(this.created){const c=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(c.value,r):this.trend,this.computedAnimated=R&&this._animated&&(!this.respectMotionPreference||!((a=f.prefersReducedMotion)!=null&&a.matches))&&M(this)&&this.ownerDocument.visibilityState==="visible",(d=this.plugins)==null||d.forEach(p=>{var m;return(m=p.onUpdate)==null?void 0:m.call(p,t,c,this)}),this.batched||this.willUpdate(),this._pre.update(e),this._num.update({integer:i,fraction:s}),this._post.update(o),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}const c=document.createElement("style");this.nonce&&(c.nonce=this.nonce),c.textContent=f.styles$1,this.shadowRoot.appendChild(c),this._pre=new E(this,e,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new $(this,i,s),this.shadowRoot.appendChild(this._num.el),this._post=new E(this,o,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}C.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class ${constructor(t,e,i,{className:s,...o}={}){this.flow=t,this._integer=new A(t,e,{justify:"right",part:"integer"}),this._fraction=new A(t,i,{justify:"left",part:"fraction"}),this._inner=u("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=u("span",{...o,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[f.dxVar]:[`${e}px`,"0px"],[f.widthDeltaVar]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class U{constructor(t,e,{justify:i,className:s,...o},r){this.flow=t,this.children=new Map,this.onCharRemove=d=>()=>{this.children.delete(d)},this.justify=i;const a=e.map(d=>this.addChar(d).el);this.el=u("span",{...o,className:`section section--justify-${i} ${s??""}`},r?r(a):a)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new w(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new D(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${S(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",o=s?"prepend":"append";if(P(t,r=>{let a;this.children.has(r.key)?(a=this.children.get(r.key),i.set(r,a),this.unpop(a),a.present=!0):(a=this.addChar(r,{startDigitsAtZero:!0,animateIn:!0}),e.set(r,a)),this.el[o](a.el)},{reverse:s}),this.flow.computedAnimated){const r=this.el.getBoundingClientRect();e.forEach(a=>{a.willUpdate(r)})}e.forEach((r,a)=>{r.update(a.value)}),i.forEach((r,a)=>{r.update(a.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class A extends U{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(o=>o.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof w&&i.update(0)}),this.pop(e)}}class E extends U{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(o=>o.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class v{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var o;this.el.remove(),(o=this._onRemove)==null||o.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[f.opacityDeltaVar]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[f.opacityDeltaVar]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class x extends v{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class w extends x{constructor(t,e,i,s,o){var c,p;const r=(((p=(c=t.flow.digits)==null?void 0:c[s])==null?void 0:p.max)??9)+1,a=Array.from({length:r}).map((m,g)=>{const _=u("span",{className:"digit__num"},[document.createTextNode(String(g))]);return g!==i&&_.setAttribute("inert",""),_.style.setProperty("--n",String(g)),_}),d=u("span",{part:`digit ${e}-digit`,className:"digit"},a);d.style.setProperty("--current",String(i)),d.style.setProperty("--length",String(r)),super(t,i,d,o),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=a,this.length=r}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,o=this.section.justify==="left"?i+s:i-s,r=this._prevCenter-o;r&&this.el.animate({transform:[`translateX(${r}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const a=this.getDelta();a&&(this.el.classList.add("is-spinning"),this.el.animate({[f.deltaVar]:[-a,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var i;if(this.flow.plugins)for(const s of this.flow.plugins){const o=(i=s.getDelta)==null?void 0:i.call(s,this.value,this._prevValue,this);if(o!=null)return o}const t=this.value-this._prevValue,e=this.flow.computedTrend||Math.sign(t);return e<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:e>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:t}}class D extends x{constructor(t,e,i,s){const o=u("span",{className:"symbol__value",textContent:i});super(t,i,u("span",{part:`symbol ${e}`,className:"symbol"},[o]),s),this.type=e,this._children=new Map,this._onChildRemove=r=>()=>{this._children.delete(r)},this._children.set(i,new v(this.flow,o,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=u("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new v(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const i=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],s=this._prevOffset-i;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}exports.prefersReducedMotion=f.prefersReducedMotion;exports.renderInnerHTML=f.renderInnerHTML;exports.continuous=T.continuous;exports.Digit=w;exports.canAnimate=R;exports.default=C;exports.define=L;exports.formatToData=N;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("esm-env"),d=require("./ssr-B-DD5oSO.js"),T=require("./plugins.js"),u=(n,t,e)=>{const i=document.createElement(n),[s,o]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),o==null||o.forEach(r=>i.appendChild(r)),i},M=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},S=n=>n.offsetWidth>0&&n.offsetHeight>0,L=(n,t)=>{j.BROWSER&&typeof HTMLElement<"u"&&typeof customElements<"u"&&!customElements.get(n)&&customElements.define(n,t)};function P(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function N(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const o=[],r=[],a=[],f=[],c={},p=l=>`${l}:${c[l]=(c[l]??-1)+1}`;let m="",g=!1,_=!1;for(const l of s){m+=l.value;const h=l.type==="minusSign"||l.type==="plusSign"?"sign":l.type;h==="integer"?(g=!0,r.push(...l.value.split("").map(y=>({type:h,value:parseInt(y)})))):h==="group"?r.push({type:h,value:l.value}):h==="decimal"?(_=!0,a.push({type:h,value:l.value,key:p(h)})):h==="fraction"?a.push(...l.value.split("").map(y=>({type:h,value:parseInt(y),key:p(h),pos:-1-c[h]}))):(g||_?f:o).push({type:h,value:l.value,key:p(h)})}const E=[];for(let l=r.length-1;l>=0;l--){const h=r[l];E.unshift(h.type==="integer"?{...h,key:p(h.type),pos:c[h.type]}:{...h,key:p(h.type)})}return{pre:o,integer:E,fraction:a,post:f,valueAsString:m,value:typeof n=="string"?parseFloat(n):n}}const v=d.supportsMod&&d.supportsLinear&&d.supportsAtProperty;class U extends d.ServerSafeHTMLElement{constructor(){super(),this.created=!1,this.batched=!1,this._preUpdated=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var a,f;if(t==null||t===this._data)return;const{pre:e,integer:i,fraction:s,post:o,value:r}=t;if(this.created){const c=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(c.value,r):this.trend,this.computedAnimated=v&&this._animated&&(!this.respectMotionPreference||!((a=d.prefersReducedMotion)!=null&&a.matches))&&S(this)&&this.ownerDocument.visibilityState==="visible",(f=this.plugins)==null||f.forEach(p=>{var m;return(m=p.onUpdate)==null?void 0:m.call(p,t,c,this)}),this.batched||this.willUpdate(),this._pre.update(e),this._num.update({integer:i,fraction:s}),this._post.update(o),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}const c=document.createElement("style");this.nonce&&(c.nonce=this.nonce),c.textContent=d.styles$1,this.shadowRoot.appendChild(c),this._pre=new R(this,e,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new D(this,i,s),this.shadowRoot.appendChild(this._num.el),this._post=new R(this,o,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){var t;this._preUpdated=v&&this._animated&&(!this.respectMotionPreference||!((t=d.prefersReducedMotion)!=null&&t.matches))&&this.ownerDocument.visibilityState==="visible",this._preUpdated&&(this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate())}didUpdate(){if(!this.computedAnimated||!this._preUpdated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}U.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class D{constructor(t,e,i,{className:s,...o}={}){this.flow=t,this._integer=new A(t,e,{justify:"right",part:"integer"}),this._fraction=new A(t,i,{justify:"left",part:"fraction"}),this._inner=u("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=u("span",{...o,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[d.dxVar]:[`${e}px`,"0px"],[d.widthDeltaVar]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class C{constructor(t,e,{justify:i,className:s,...o},r){this.flow=t,this.children=new Map,this.onCharRemove=f=>()=>{this.children.delete(f)},this.justify=i;const a=e.map(f=>this.addChar(f).el);this.el=u("span",{...o,className:`section section--justify-${i} ${s??""}`},r?r(a):a)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new b(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new $(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${M(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",o=s?"prepend":"append";if(P(t,r=>{let a;this.children.has(r.key)?(a=this.children.get(r.key),i.set(r,a),this.unpop(a),a.present=!0):(a=this.addChar(r,{startDigitsAtZero:!0,animateIn:!0}),e.set(r,a)),this.el[o](a.el)},{reverse:s}),this.flow.computedAnimated){const r=this.el.getBoundingClientRect();e.forEach(a=>{a.willUpdate(r)})}e.forEach((r,a)=>{r.update(a.value)}),i.forEach((r,a)=>{r.update(a.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class A extends C{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(o=>o.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof b&&i.update(0)}),this.pop(e)}}class R extends C{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(o=>o.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class w{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var o;this.el.remove(),(o=this._onRemove)==null||o.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[d.opacityDeltaVar]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[d.opacityDeltaVar]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class x extends w{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class b extends x{constructor(t,e,i,s,o){var c,p;const r=(((p=(c=t.flow.digits)==null?void 0:c[s])==null?void 0:p.max)??9)+1,a=Array.from({length:r}).map((m,g)=>{const _=u("span",{className:"digit__num"},[document.createTextNode(String(g))]);return g!==i&&_.setAttribute("inert",""),_.style.setProperty("--n",String(g)),_}),f=u("span",{part:`digit ${e}-digit`,className:"digit"},a);f.style.setProperty("--current",String(i)),f.style.setProperty("--length",String(r)),super(t,i,f,o),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=a,this.length=r}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,o=this.section.justify==="left"?i+s:i-s,r=this._prevCenter-o;r&&this.el.animate({transform:[`translateX(${r}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const a=this.getDelta();a&&(this.el.classList.add("is-spinning"),this.el.animate({[d.deltaVar]:[-a,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var i;if(this.flow.plugins)for(const s of this.flow.plugins){const o=(i=s.getDelta)==null?void 0:i.call(s,this.value,this._prevValue,this);if(o!=null)return o}const t=this.value-this._prevValue,e=this.flow.computedTrend||Math.sign(t);return e<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:e>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:t}}class $ extends x{constructor(t,e,i,s){const o=u("span",{className:"symbol__value",textContent:i});super(t,i,u("span",{part:`symbol ${e}`,className:"symbol"},[o]),s),this.type=e,this._children=new Map,this._onChildRemove=r=>()=>{this._children.delete(r)},this._children.set(i,new w(this.flow,o,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=u("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new w(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const i=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],s=this._prevOffset-i;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}exports.prefersReducedMotion=d.prefersReducedMotion;exports.renderInnerHTML=d.renderInnerHTML;exports.continuous=T.continuous;exports.Digit=b;exports.canAnimate=v;exports.default=U;exports.define=L;exports.formatToData=N;
|
package/dist/lite.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BROWSER as
|
|
2
|
-
import { c as
|
|
3
|
-
import { r as q } from "./ssr-
|
|
1
|
+
import { BROWSER as j } from "esm-env";
|
|
2
|
+
import { c as S, d as T, e as L, S as M, b as P, p as w, f as N, w as $, g as V, o as b } from "./ssr-DvIINv8w.mjs";
|
|
3
|
+
import { r as q } from "./ssr-DvIINv8w.mjs";
|
|
4
4
|
import { continuous as J } from "./plugins.mjs";
|
|
5
|
-
const
|
|
5
|
+
const f = (n, t, e) => {
|
|
6
6
|
const i = document.createElement(n), [s, o] = Array.isArray(t) ? [void 0, t] : [t, e];
|
|
7
7
|
return s && Object.assign(i, s), o == null || o.forEach((a) => i.appendChild(a)), i;
|
|
8
|
-
},
|
|
8
|
+
}, D = (n, t) => {
|
|
9
9
|
var e;
|
|
10
10
|
return t === "left" ? n.offsetLeft : (((e = n.offsetParent instanceof HTMLElement ? n.offsetParent : null) == null ? void 0 : e.offsetWidth) ?? 0) - n.offsetWidth - n.offsetLeft;
|
|
11
11
|
}, W = (n) => n.offsetWidth > 0 && n.offsetHeight > 0, X = (n, t) => {
|
|
12
|
-
|
|
12
|
+
j && typeof HTMLElement < "u" && typeof customElements < "u" && !customElements.get(n) && customElements.define(n, t);
|
|
13
13
|
};
|
|
14
14
|
function k(n, t, { reverse: e = !1 } = {}) {
|
|
15
15
|
const i = n.length;
|
|
@@ -19,20 +19,20 @@ function k(n, t, { reverse: e = !1 } = {}) {
|
|
|
19
19
|
function z(n, t, e, i) {
|
|
20
20
|
const s = t.formatToParts(n);
|
|
21
21
|
e && s.unshift({ type: "prefix", value: e }), i && s.push({ type: "suffix", value: i });
|
|
22
|
-
const o = [], a = [], r = [], d = [], c = {},
|
|
22
|
+
const o = [], a = [], r = [], d = [], c = {}, p = (l) => `${l}:${c[l] = (c[l] ?? -1) + 1}`;
|
|
23
23
|
let u = "", m = !1, g = !1;
|
|
24
24
|
for (const l of s) {
|
|
25
25
|
u += l.value;
|
|
26
26
|
const h = l.type === "minusSign" || l.type === "plusSign" ? "sign" : l.type;
|
|
27
|
-
h === "integer" ? (m = !0, a.push(...l.value.split("").map((_) => ({ type: h, value: parseInt(_) })))) : h === "group" ? a.push({ type: h, value: l.value }) : h === "decimal" ? (g = !0, r.push({ type: h, value: l.value, key:
|
|
27
|
+
h === "integer" ? (m = !0, a.push(...l.value.split("").map((_) => ({ type: h, value: parseInt(_) })))) : h === "group" ? a.push({ type: h, value: l.value }) : h === "decimal" ? (g = !0, r.push({ type: h, value: l.value, key: p(h) })) : h === "fraction" ? r.push(...l.value.split("").map((_) => ({
|
|
28
28
|
type: h,
|
|
29
29
|
value: parseInt(_),
|
|
30
|
-
key:
|
|
30
|
+
key: p(h),
|
|
31
31
|
pos: -1 - c[h]
|
|
32
32
|
}))) : (m || g ? d : o).push({
|
|
33
33
|
type: h,
|
|
34
34
|
value: l.value,
|
|
35
|
-
key:
|
|
35
|
+
key: p(h)
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
const v = [];
|
|
@@ -40,11 +40,11 @@ function z(n, t, e, i) {
|
|
|
40
40
|
const h = a[l];
|
|
41
41
|
v.unshift(h.type === "integer" ? {
|
|
42
42
|
...h,
|
|
43
|
-
key:
|
|
43
|
+
key: p(h.type),
|
|
44
44
|
pos: c[h.type]
|
|
45
45
|
} : {
|
|
46
46
|
...h,
|
|
47
|
-
key:
|
|
47
|
+
key: p(h.type)
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
return {
|
|
@@ -56,10 +56,10 @@ function z(n, t, e, i) {
|
|
|
56
56
|
value: typeof n == "string" ? parseFloat(n) : n
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
class
|
|
59
|
+
const E = S && T && L;
|
|
60
|
+
class B extends M {
|
|
61
61
|
constructor() {
|
|
62
|
-
super(), this.created = !1, this.batched = !1;
|
|
62
|
+
super(), this.created = !1, this.batched = !1, this._preUpdated = !1;
|
|
63
63
|
const { animated: t, ...e } = this.constructor.defaultProps;
|
|
64
64
|
this._animated = this.computedAnimated = t, Object.assign(this, e);
|
|
65
65
|
}
|
|
@@ -75,16 +75,16 @@ class D extends T {
|
|
|
75
75
|
*/
|
|
76
76
|
set data(t) {
|
|
77
77
|
var r, d;
|
|
78
|
-
if (t == null)
|
|
78
|
+
if (t == null || t === this._data)
|
|
79
79
|
return;
|
|
80
80
|
const { pre: e, integer: i, fraction: s, post: o, value: a } = t;
|
|
81
81
|
if (this.created) {
|
|
82
82
|
const c = this._data;
|
|
83
|
-
this._data = t, this.computedTrend = typeof this.trend == "function" ? this.trend(c.value, a) : this.trend, this.computedAnimated =
|
|
83
|
+
this._data = t, this.computedTrend = typeof this.trend == "function" ? this.trend(c.value, a) : this.trend, this.computedAnimated = E && this._animated && (!this.respectMotionPreference || !((r = w) != null && r.matches)) && // https://github.com/barvian/number-flow/issues/9
|
|
84
84
|
W(this) && // https://github.com/barvian/number-flow/issues/165
|
|
85
|
-
this.ownerDocument.visibilityState === "visible", (d = this.plugins) == null || d.forEach((
|
|
85
|
+
this.ownerDocument.visibilityState === "visible", (d = this.plugins) == null || d.forEach((p) => {
|
|
86
86
|
var u;
|
|
87
|
-
return (u =
|
|
87
|
+
return (u = p.onUpdate) == null ? void 0 : u.call(p, t, c, this);
|
|
88
88
|
}), this.batched || this.willUpdate(), this._pre.update(e), this._num.update({ integer: i, fraction: s }), this._post.update(o), this.batched || this.didUpdate();
|
|
89
89
|
} else {
|
|
90
90
|
this._data = t, this.attachShadow({ mode: "open" });
|
|
@@ -93,10 +93,10 @@ class D extends T {
|
|
|
93
93
|
} catch {
|
|
94
94
|
}
|
|
95
95
|
const c = document.createElement("style");
|
|
96
|
-
this.nonce && (c.nonce = this.nonce), c.textContent =
|
|
96
|
+
this.nonce && (c.nonce = this.nonce), c.textContent = P, this.shadowRoot.appendChild(c), this._pre = new U(this, e, {
|
|
97
97
|
justify: "right",
|
|
98
98
|
part: "left"
|
|
99
|
-
}), this.shadowRoot.appendChild(this._pre.el), this._num = new F(this, i, s), this.shadowRoot.appendChild(this._num.el), this._post = new
|
|
99
|
+
}), this.shadowRoot.appendChild(this._pre.el), this._num = new F(this, i, s), this.shadowRoot.appendChild(this._num.el), this._post = new U(this, o, {
|
|
100
100
|
justify: "left",
|
|
101
101
|
part: "right"
|
|
102
102
|
}), this.shadowRoot.appendChild(this._post.el), this.created = !0;
|
|
@@ -110,13 +110,14 @@ class D extends T {
|
|
|
110
110
|
* @internal
|
|
111
111
|
*/
|
|
112
112
|
willUpdate() {
|
|
113
|
-
|
|
113
|
+
var t;
|
|
114
|
+
this._preUpdated = E && this._animated && (!this.respectMotionPreference || !((t = w) != null && t.matches)) && this.ownerDocument.visibilityState === "visible", this._preUpdated && (this._pre.willUpdate(), this._num.willUpdate(), this._post.willUpdate());
|
|
114
115
|
}
|
|
115
116
|
/**
|
|
116
117
|
* @internal
|
|
117
118
|
*/
|
|
118
119
|
didUpdate() {
|
|
119
|
-
if (!this.computedAnimated)
|
|
120
|
+
if (!this.computedAnimated || !this._preUpdated)
|
|
120
121
|
return;
|
|
121
122
|
this._abortAnimationsFinish ? this._abortAnimationsFinish.abort() : this.dispatchEvent(new Event("animationsstart")), this._pre.didUpdate(), this._num.didUpdate(), this._post.didUpdate();
|
|
122
123
|
const t = new AbortController();
|
|
@@ -125,7 +126,7 @@ class D extends T {
|
|
|
125
126
|
}), this._abortAnimationsFinish = t;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
+
B.defaultProps = {
|
|
129
130
|
transformTiming: {
|
|
130
131
|
duration: 900,
|
|
131
132
|
// Make sure to keep this minified:
|
|
@@ -141,15 +142,15 @@ D.defaultProps = {
|
|
|
141
142
|
};
|
|
142
143
|
class F {
|
|
143
144
|
constructor(t, e, i, { className: s, ...o } = {}) {
|
|
144
|
-
this.flow = t, this._integer = new
|
|
145
|
+
this.flow = t, this._integer = new A(t, e, {
|
|
145
146
|
justify: "right",
|
|
146
147
|
part: "integer"
|
|
147
|
-
}), this._fraction = new
|
|
148
|
+
}), this._fraction = new A(t, i, {
|
|
148
149
|
justify: "left",
|
|
149
150
|
part: "fraction"
|
|
150
|
-
}), this._inner =
|
|
151
|
+
}), this._inner = f("span", {
|
|
151
152
|
className: "number__inner"
|
|
152
|
-
}, [this._integer.el, this._fraction.el]), this.el =
|
|
153
|
+
}, [this._integer.el, this._fraction.el]), this.el = f("span", {
|
|
153
154
|
...o,
|
|
154
155
|
part: "number",
|
|
155
156
|
className: `number ${s ?? ""}`
|
|
@@ -166,27 +167,27 @@ class F {
|
|
|
166
167
|
this._integer.didUpdate(), this._fraction.didUpdate();
|
|
167
168
|
const e = this._prevLeft - t.left, i = this.el.offsetWidth, s = this._prevWidth - i;
|
|
168
169
|
this.el.style.setProperty("--width", String(i)), this.el.animate({
|
|
169
|
-
[
|
|
170
|
-
[
|
|
170
|
+
[N]: [`${e}px`, "0px"],
|
|
171
|
+
[$]: [s, 0]
|
|
171
172
|
}, {
|
|
172
173
|
...this.flow.transformTiming,
|
|
173
174
|
composite: "accumulate"
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
|
-
class
|
|
178
|
+
class R {
|
|
178
179
|
constructor(t, e, { justify: i, className: s, ...o }, a) {
|
|
179
180
|
this.flow = t, this.children = /* @__PURE__ */ new Map(), this.onCharRemove = (d) => () => {
|
|
180
181
|
this.children.delete(d);
|
|
181
182
|
}, this.justify = i;
|
|
182
183
|
const r = e.map((d) => this.addChar(d).el);
|
|
183
|
-
this.el =
|
|
184
|
+
this.el = f("span", {
|
|
184
185
|
...o,
|
|
185
186
|
className: `section section--justify-${i} ${s ?? ""}`
|
|
186
187
|
}, a ? a(r) : r);
|
|
187
188
|
}
|
|
188
189
|
addChar(t, { startDigitsAtZero: e = !1, ...i } = {}) {
|
|
189
|
-
const s = t.type === "integer" || t.type === "fraction" ? new
|
|
190
|
+
const s = t.type === "integer" || t.type === "fraction" ? new C(this, t.type, e ? 0 : t.value, t.pos, {
|
|
190
191
|
...i,
|
|
191
192
|
onRemove: this.onCharRemove(t.key)
|
|
192
193
|
}) : new I(this, t.type, t.value, {
|
|
@@ -200,7 +201,7 @@ class E {
|
|
|
200
201
|
}
|
|
201
202
|
pop(t) {
|
|
202
203
|
t.forEach((e) => {
|
|
203
|
-
e.el.style.top = `${e.el.offsetTop}px`, e.el.style[this.justify] = `${
|
|
204
|
+
e.el.style.top = `${e.el.offsetTop}px`, e.el.style[this.justify] = `${D(e.el, this.justify)}px`;
|
|
204
205
|
}), t.forEach((e) => {
|
|
205
206
|
e.el.setAttribute("inert", ""), e.present = !1;
|
|
206
207
|
});
|
|
@@ -238,17 +239,17 @@ class E {
|
|
|
238
239
|
});
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
|
-
class
|
|
242
|
+
class A extends R {
|
|
242
243
|
update(t) {
|
|
243
244
|
const e = /* @__PURE__ */ new Map();
|
|
244
245
|
this.children.forEach((i, s) => {
|
|
245
246
|
t.find((o) => o.key === s) || e.set(s, i), this.unpop(i);
|
|
246
247
|
}), this.addNewAndUpdateExisting(t), e.forEach((i) => {
|
|
247
|
-
i instanceof
|
|
248
|
+
i instanceof C && i.update(0);
|
|
248
249
|
}), this.pop(e);
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
|
-
class
|
|
252
|
+
class U extends R {
|
|
252
253
|
update(t) {
|
|
253
254
|
const e = /* @__PURE__ */ new Map();
|
|
254
255
|
this.children.forEach((i, s) => {
|
|
@@ -262,7 +263,7 @@ class y {
|
|
|
262
263
|
var o;
|
|
263
264
|
this.el.remove(), (o = this._onRemove) == null || o.call(this);
|
|
264
265
|
}, this.el.classList.add("animate-presence"), this.flow.computedAnimated && s && this.el.animate({
|
|
265
|
-
[
|
|
266
|
+
[b]: [-0.9999, 0]
|
|
266
267
|
}, {
|
|
267
268
|
...this.flow.opacityTiming,
|
|
268
269
|
composite: "accumulate"
|
|
@@ -278,7 +279,7 @@ class y {
|
|
|
278
279
|
return;
|
|
279
280
|
}
|
|
280
281
|
this.el.style.setProperty("--_number-flow-d-opacity", t ? "0" : "-.999"), this.el.animate({
|
|
281
|
-
[
|
|
282
|
+
[b]: t ? [-0.9999, 0] : [0.999, 0]
|
|
282
283
|
}, {
|
|
283
284
|
...this.flow.opacityTiming,
|
|
284
285
|
composite: "accumulate"
|
|
@@ -288,20 +289,20 @@ class y {
|
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
|
-
class
|
|
292
|
+
class x extends y {
|
|
292
293
|
constructor(t, e, i, s) {
|
|
293
294
|
super(t.flow, i, s), this.section = t, this.value = e, this.el = i;
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
|
-
class
|
|
297
|
+
class C extends x {
|
|
297
298
|
constructor(t, e, i, s, o) {
|
|
298
|
-
var c,
|
|
299
|
-
const a = (((
|
|
300
|
-
const g =
|
|
299
|
+
var c, p;
|
|
300
|
+
const a = (((p = (c = t.flow.digits) == null ? void 0 : c[s]) == null ? void 0 : p.max) ?? 9) + 1, r = Array.from({ length: a }).map((u, m) => {
|
|
301
|
+
const g = f("span", { className: "digit__num" }, [
|
|
301
302
|
document.createTextNode(String(m))
|
|
302
303
|
]);
|
|
303
304
|
return m !== i && g.setAttribute("inert", ""), g.style.setProperty("--n", String(m)), g;
|
|
304
|
-
}), d =
|
|
305
|
+
}), d = f("span", {
|
|
305
306
|
part: `digit ${e}-digit`,
|
|
306
307
|
className: "digit"
|
|
307
308
|
}, r);
|
|
@@ -328,7 +329,7 @@ class x extends R {
|
|
|
328
329
|
});
|
|
329
330
|
const r = this.getDelta();
|
|
330
331
|
r && (this.el.classList.add("is-spinning"), this.el.animate({
|
|
331
|
-
[
|
|
332
|
+
[V]: [-r, 0]
|
|
332
333
|
}, {
|
|
333
334
|
...this.flow.spinTiming ?? this.flow.transformTiming,
|
|
334
335
|
composite: "accumulate"
|
|
@@ -346,13 +347,13 @@ class x extends R {
|
|
|
346
347
|
return e < 0 && this.value > this._prevValue ? this.value - this.length - this._prevValue : e > 0 && this.value < this._prevValue ? this.length - this._prevValue + this.value : t;
|
|
347
348
|
}
|
|
348
349
|
}
|
|
349
|
-
class I extends
|
|
350
|
+
class I extends x {
|
|
350
351
|
constructor(t, e, i, s) {
|
|
351
|
-
const o =
|
|
352
|
+
const o = f("span", {
|
|
352
353
|
className: "symbol__value",
|
|
353
354
|
textContent: i
|
|
354
355
|
});
|
|
355
|
-
super(t, i,
|
|
356
|
+
super(t, i, f("span", {
|
|
356
357
|
part: `symbol ${e}`,
|
|
357
358
|
className: "symbol"
|
|
358
359
|
}, [o]), s), this.type = e, this._children = /* @__PURE__ */ new Map(), this._onChildRemove = (a) => () => {
|
|
@@ -375,7 +376,7 @@ class I extends R {
|
|
|
375
376
|
if (i)
|
|
376
377
|
i.present = !0;
|
|
377
378
|
else {
|
|
378
|
-
const s =
|
|
379
|
+
const s = f("span", {
|
|
379
380
|
className: "symbol__value",
|
|
380
381
|
textContent: t
|
|
381
382
|
});
|
|
@@ -397,12 +398,12 @@ class I extends R {
|
|
|
397
398
|
}
|
|
398
399
|
}
|
|
399
400
|
export {
|
|
400
|
-
|
|
401
|
-
|
|
401
|
+
C as Digit,
|
|
402
|
+
E as canAnimate,
|
|
402
403
|
J as continuous,
|
|
403
|
-
|
|
404
|
+
B as default,
|
|
404
405
|
X as define,
|
|
405
406
|
z as formatToData,
|
|
406
|
-
|
|
407
|
+
w as prefersReducedMotion,
|
|
407
408
|
q as renderInnerHTML
|
|
408
409
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";const l=require("esm-env"),b=String.raw,d=String.raw,$=l.BROWSER&&(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),w=l.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),v=l.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,m="--_number-flow-d-opacity",g="--_number-flow-d-width",s="--_number-flow-dx",u="--_number-flow-d",S=(()=>{try{return CSS.registerProperty({name:m,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:s,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:g,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:u,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),o="round(nearest, calc(var(--number-flow-mask-height, 0.25em) / 2), 1px)",t=`calc(${o} * 2)`,p="var(--number-flow-mask-width, 0.5em)",n=`calc(${p} / var(--scale-x))`,i="#000 0, transparent 71%",k=d`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:1}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${g}) / var(--width));transform:translateX(var(${s})) scaleX(var(--scale-x));margin:0 calc(-1 * ${p});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${n},#000 calc(100% - ${n}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${t},#000 calc(100% - ${t}),transparent 100% ),radial-gradient(at bottom right,${i}),radial-gradient(at bottom left,${i}),radial-gradient(at top left,${i}),radial-gradient(at top right,${i});-webkit-mask-size:100% calc(100% - ${t} * 2),calc(100% - ${n} * 2) 100%,${n} ${t},${n} ${t},${n} ${t},${n} ${t};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${o} ${p};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${s})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${u})}.digit__num,.number .section::after{padding:${o} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${m}))}`,_=l.BROWSER?HTMLElement:class{},
|
|
2
|
-
><style${r?` nonce="${r}"`:""}>${
|
|
1
|
+
"use strict";const l=require("esm-env"),b=String.raw,d=String.raw,$=l.BROWSER&&(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),w=l.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),v=l.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,m="--_number-flow-d-opacity",g="--_number-flow-d-width",s="--_number-flow-dx",u="--_number-flow-d",S=(()=>{try{return CSS.registerProperty({name:m,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:s,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:g,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:u,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),o="round(nearest, calc(var(--number-flow-mask-height, 0.25em) / 2), 1px)",t=`calc(${o} * 2)`,p="var(--number-flow-mask-width, 0.5em)",n=`calc(${p} / var(--scale-x))`,i="#000 0, transparent 71%",k=d`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:1}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${g}) / var(--width));transform:translateX(var(${s})) scaleX(var(--scale-x));margin:0 calc(-1 * ${p});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${n},#000 calc(100% - ${n}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${t},#000 calc(100% - ${t}),transparent 100% ),radial-gradient(at bottom right,${i}),radial-gradient(at bottom left,${i}),radial-gradient(at top left,${i}),radial-gradient(at top right,${i});-webkit-mask-size:100% calc(100% - ${t} * 2),calc(100% - ${n} * 2) 100%,${n} ${t},${n} ${t},${n} ${t},${n} ${t};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${o} ${p};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${s})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${u})}.digit__num,.number .section::after{padding:${o} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${m}))}`,_=l.BROWSER&&typeof HTMLElement<"u"?HTMLElement:class{},f=d`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:1}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${o} 0}.symbol{white-space:pre}`,x=e=>`<span class="${e.type==="integer"||e.type==="fraction"?"digit":"symbol"}" part="${e.type==="integer"||e.type==="fraction"?`digit ${e.type}-digit`:`symbol ${e.type}`}">${e.value}</span>`,a=(e,r)=>`<span part="${r}">${e.reduce((c,h)=>c+x(h),"")}</span>`,y=(e="")=>d`:where(number-flow${e}){line-height:1}number-flow${e} > span{font-kerning:none;display:inline-block;padding:${t} 0}`,M=(e,{nonce:r,elementSuffix:c}={})=>b`<template shadowroot="open" shadowrootmode="open"
|
|
2
|
+
><style${r?` nonce="${r}"`:""}>${f}</style
|
|
3
3
|
><span role="img" aria-label="${e.valueAsString}"
|
|
4
4
|
>${a(e.pre,"left")}<span part="number" class="number"
|
|
5
5
|
>${a(e.integer,"integer")}${a(e.fraction,"fraction")}</span
|
|
6
6
|
>${a(e.post,"right")}</span
|
|
7
7
|
></template
|
|
8
8
|
><style${r?` nonce="${r}"`:""}>${y(c)}</style
|
|
9
|
-
><span>${e.valueAsString}</span>`;exports.ServerSafeHTMLElement=_;exports.deltaVar=u;exports.dxVar=s;exports.opacityDeltaVar=m;exports.prefersReducedMotion=v;exports.renderFallbackStyles=y;exports.renderInnerHTML=M;exports.styles=
|
|
9
|
+
><span>${e.valueAsString}</span>`;exports.ServerSafeHTMLElement=_;exports.deltaVar=u;exports.dxVar=s;exports.opacityDeltaVar=m;exports.prefersReducedMotion=v;exports.renderFallbackStyles=y;exports.renderInnerHTML=M;exports.styles=f;exports.styles$1=k;exports.supportsAtProperty=S;exports.supportsLinear=$;exports.supportsMod=w;exports.widthDeltaVar=g;
|
|
@@ -32,18 +32,18 @@ const h = String.raw, m = String.raw, v = o && (() => {
|
|
|
32
32
|
} catch {
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
|
-
})(), s = "round(nearest, calc(var(--number-flow-mask-height, 0.25em) / 2), 1px)",
|
|
36
|
-
},
|
|
35
|
+
})(), s = "round(nearest, calc(var(--number-flow-mask-height, 0.25em) / 2), 1px)", t = `calc(${s} * 2)`, p = "var(--number-flow-mask-width, 0.5em)", n = `calc(${p} / var(--scale-x))`, r = "#000 0, transparent 71%", x = m`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:1}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${g}) / var(--width));transform:translateX(var(${c})) scaleX(var(--scale-x));margin:0 calc(-1 * ${p});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${n},#000 calc(100% - ${n}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${t},#000 calc(100% - ${t}),transparent 100% ),radial-gradient(at bottom right,${r}),radial-gradient(at bottom left,${r}),radial-gradient(at top left,${r}),radial-gradient(at top right,${r});-webkit-mask-size:100% calc(100% - ${t} * 2),calc(100% - ${n} * 2) 100%,${n} ${t},${n} ${t},${n} ${t},${n} ${t};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${s} ${p};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${c})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${u})}.digit__num,.number .section::after{padding:${s} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${d}))}`, M = o && typeof HTMLElement < "u" ? HTMLElement : class {
|
|
36
|
+
}, y = m`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:1}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${s} 0}.symbol{white-space:pre}`, b = (e) => `<span class="${e.type === "integer" || e.type === "fraction" ? "digit" : "symbol"}" part="${e.type === "integer" || e.type === "fraction" ? `digit ${e.type}-digit` : `symbol ${e.type}`}">${e.value}</span>`, i = (e, a) => `<span part="${a}">${e.reduce((l, f) => l + b(f), "")}</span>`, $ = (e = "") => m`:where(number-flow${e}){line-height:1}number-flow${e} > span{font-kerning:none;display:inline-block;padding:${t} 0}`, V = (e, { nonce: a, elementSuffix: l } = {}) => (
|
|
37
37
|
// shadowroot="open" non-standard attribute for old Chrome:
|
|
38
38
|
h`<template shadowroot="open" shadowrootmode="open"
|
|
39
|
-
><style${a ? ` nonce="${a}"` : ""}>${
|
|
40
|
-
><span role="img" aria-label="${
|
|
41
|
-
>${i(
|
|
42
|
-
>${i(
|
|
43
|
-
>${i(
|
|
39
|
+
><style${a ? ` nonce="${a}"` : ""}>${y}</style
|
|
40
|
+
><span role="img" aria-label="${e.valueAsString}"
|
|
41
|
+
>${i(e.pre, "left")}<span part="number" class="number"
|
|
42
|
+
>${i(e.integer, "integer")}${i(e.fraction, "fraction")}</span
|
|
43
|
+
>${i(e.post, "right")}</span
|
|
44
44
|
></template
|
|
45
45
|
><style${a ? ` nonce="${a}"` : ""}>${$(l)}</style
|
|
46
|
-
><span>${
|
|
46
|
+
><span>${e.valueAsString}</span>`
|
|
47
47
|
);
|
|
48
48
|
export {
|
|
49
49
|
M as S,
|
|
@@ -57,6 +57,6 @@ export {
|
|
|
57
57
|
d as o,
|
|
58
58
|
S as p,
|
|
59
59
|
V as r,
|
|
60
|
-
|
|
60
|
+
y as s,
|
|
61
61
|
g as w
|
|
62
62
|
};
|