number-flow 0.5.7 → 0.5.8
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/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-CzDvSY_4.mjs → lite-BTIaQdTe.mjs} +11 -11
- package/dist/{lite-B8p0lZvR.js → lite-DyshwcGq.js} +1 -1
- package/dist/lite.js +1 -1
- package/dist/lite.mjs +1 -1
- package/package.json +1 -1
package/dist/group.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./lite-
|
|
1
|
+
"use strict";const n=require("./lite-DyshwcGq.js"),t=require("./index.js");class i extends n.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(r=>{r.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()}}n.define("number-flow-group",i);module.exports=i;
|
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-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./lite-DyshwcGq.js"),l=require("./plugins.js"),n="number-flow-connect",s="number-flow-update",f=(r,{locales:t,format:o,numberPrefix:a,numberSuffix:u}={})=>{const c=e.formatToData(r,new Intl.NumberFormat(t,o),a,u);return e.renderInnerHTML(c)};class i extends e.NumberFlowLite{constructor(){super(...arguments),this.connected=!1}connectedCallback(){this.connected=!0,this.dispatchEvent(new Event(n,{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(s,{bubbles:!0})),this.data=e.formatToData(this._value,this._formatter,this.numberPrefix,this.numberSuffix)}}e.define("number-flow",i);exports.Digit=e.Digit;exports.canAnimate=e.canAnimate;exports.define=e.define;exports.formatToData=e.formatToData;exports.prefersReducedMotion=e.prefersReducedMotion;exports.continuous=l.continuous;exports.CONNECT_EVENT=n;exports.UPDATE_EVENT=s;exports.default=i;exports.renderInnerHTML=f;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as i, N as u, f as r, r as c } from "./lite-
|
|
2
|
-
import { D as _, c as v, p as E } from "./lite-
|
|
1
|
+
import { d as i, N as u, f as r, r as c } from "./lite-BTIaQdTe.mjs";
|
|
2
|
+
import { D as _, c as v, p as E } from "./lite-BTIaQdTe.mjs";
|
|
3
3
|
import { continuous as N } from "./plugins.mjs";
|
|
4
4
|
const l = "number-flow-connect", m = "number-flow-update", d = (t, { locales: e, format: s, numberPrefix: n, numberSuffix: a } = {}) => {
|
|
5
5
|
const o = r(t, new Intl.NumberFormat(e, s), n, a);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BROWSER as _ } from "esm-env";
|
|
2
2
|
import "./plugins.mjs";
|
|
3
|
-
const
|
|
3
|
+
const u = (n, t, e) => {
|
|
4
4
|
const i = document.createElement(n), [s, a] = Array.isArray(t) ? [void 0, t] : [t, e];
|
|
5
5
|
return s && Object.assign(i, s), a == null || a.forEach((r) => i.appendChild(r)), i;
|
|
6
6
|
}, F = (n, t) => {
|
|
7
7
|
var e;
|
|
8
8
|
return t === "left" ? n.offsetLeft : (((e = n.offsetParent instanceof HTMLElement ? n.offsetParent : null) == null ? void 0 : e.offsetWidth) ?? 0) - n.offsetWidth - n.offsetLeft;
|
|
9
9
|
}, H = (n) => n.offsetWidth > 0 && n.offsetHeight > 0, st = (n, t) => {
|
|
10
|
-
_ && customElements.get(n)
|
|
10
|
+
_ && !customElements.get(n) && customElements.define(n, t);
|
|
11
11
|
};
|
|
12
12
|
function X(n, t, { reverse: e = !1 } = {}) {
|
|
13
13
|
const i = n.length;
|
|
@@ -87,7 +87,7 @@ const I = String.raw, V = String.raw, O = _ && (() => {
|
|
|
87
87
|
} catch {
|
|
88
88
|
return !1;
|
|
89
89
|
}
|
|
90
|
-
})(), P = "var(--number-flow-char-height, 1em)", f = "var(--number-flow-mask-height, 0.25em)", k = `calc(${f} / 2)`, E = "var(--number-flow-mask-width, 0.5em)",
|
|
90
|
+
})(), P = "var(--number-flow-char-height, 1em)", f = "var(--number-flow-mask-height, 0.25em)", k = `calc(${f} / 2)`, E = "var(--number-flow-mask-width, 0.5em)", m = `calc(${E} / var(--scale-x))`, w = "#000 0, transparent 71%", M = V`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${P} !important}.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(${U}) / var(--width));transform:translateX(var(${S})) scaleX(var(--scale-x));margin:0 calc(-1 * ${E});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${m},#000 calc(100% - ${m}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${f},#000 calc(100% - ${f}),transparent 100% ),radial-gradient(at bottom right,${w}),radial-gradient(at bottom left,${w}),radial-gradient(at top left,${w}),radial-gradient(at top right,${w});-webkit-mask-size:100% calc(100% - ${f} * 2),calc(100% - ${m} * 2) 100%,${m} ${f},${m} ${f},${m} ${f},${m} ${f};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${k} ${E};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(${j})}.digit__num,.number .section::after{padding:${k} 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(${$}))}`, G = _ ? HTMLElement : class {
|
|
91
91
|
}, K = V`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:${P} !important}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${k} 0}.symbol{white-space:pre}`, Z = (n) => `<span class="${n.type === "integer" || n.type === "fraction" ? "digit" : "symbol"}" part="${n.type === "integer" || n.type === "fraction" ? `digit ${n.type}-digit` : `symbol ${n.type}`}">${n.value}</span>`, v = (n, t) => `<span part="${t}">${n.reduce((e, i) => e + Z(i), "")}</span>`, at = (n) => (
|
|
92
92
|
// shadowroot="open" non-standard attribute for old Chrome:
|
|
93
93
|
I`<template shadowroot="open" shadowrootmode="open"
|
|
@@ -198,9 +198,9 @@ class Q {
|
|
|
198
198
|
}), this._fraction = new L(t, i, {
|
|
199
199
|
justify: "left",
|
|
200
200
|
part: "fraction"
|
|
201
|
-
}), this._inner =
|
|
201
|
+
}), this._inner = u("span", {
|
|
202
202
|
className: "number__inner"
|
|
203
|
-
}, [this._integer.el, this._fraction.el]), this.el =
|
|
203
|
+
}, [this._integer.el, this._fraction.el]), this.el = u("span", {
|
|
204
204
|
...a,
|
|
205
205
|
part: "number",
|
|
206
206
|
className: `number ${s ?? ""}`
|
|
@@ -231,7 +231,7 @@ class W {
|
|
|
231
231
|
this.children.delete(c);
|
|
232
232
|
}, this.justify = i;
|
|
233
233
|
const o = e.map((c) => this.addChar(c).el);
|
|
234
|
-
this.el =
|
|
234
|
+
this.el = u("span", {
|
|
235
235
|
...a,
|
|
236
236
|
className: `section section--justify-${i} ${s ?? ""}`
|
|
237
237
|
}, r ? r(o) : o);
|
|
@@ -348,11 +348,11 @@ class D extends B {
|
|
|
348
348
|
constructor(t, e, i, s, a) {
|
|
349
349
|
var d, p;
|
|
350
350
|
const r = (((p = (d = t.flow.digits) == null ? void 0 : d[s]) == null ? void 0 : p.max) ?? 9) + 1, o = Array.from({ length: r }).map((x, g) => {
|
|
351
|
-
const y =
|
|
351
|
+
const y = u("span", { className: "digit__num" }, [
|
|
352
352
|
document.createTextNode(String(g))
|
|
353
353
|
]);
|
|
354
354
|
return g !== i && y.setAttribute("inert", ""), y.style.setProperty("--n", String(g)), y;
|
|
355
|
-
}), c =
|
|
355
|
+
}), c = u("span", {
|
|
356
356
|
part: `digit ${e}-digit`,
|
|
357
357
|
className: "digit"
|
|
358
358
|
}, o);
|
|
@@ -399,11 +399,11 @@ class D extends B {
|
|
|
399
399
|
}
|
|
400
400
|
class tt extends B {
|
|
401
401
|
constructor(t, e, i, s) {
|
|
402
|
-
const a =
|
|
402
|
+
const a = u("span", {
|
|
403
403
|
className: "symbol__value",
|
|
404
404
|
textContent: i
|
|
405
405
|
});
|
|
406
|
-
super(t, i,
|
|
406
|
+
super(t, i, u("span", {
|
|
407
407
|
part: `symbol ${e}`,
|
|
408
408
|
className: "symbol"
|
|
409
409
|
}, [a]), s), this.type = e, this._children = /* @__PURE__ */ new Map(), this._onChildRemove = (r) => () => {
|
|
@@ -426,7 +426,7 @@ class tt extends B {
|
|
|
426
426
|
if (i)
|
|
427
427
|
i.present = !0;
|
|
428
428
|
else {
|
|
429
|
-
const s =
|
|
429
|
+
const s = u("span", {
|
|
430
430
|
className: "symbol__value",
|
|
431
431
|
textContent: t
|
|
432
432
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const _=require("esm-env");require("./plugins.js");const u=(n,t,e)=>{const i=document.createElement(n),[s,a]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),a==null||a.forEach(r=>i.appendChild(r)),i},I=(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},X=n=>n.offsetWidth>0&&n.offsetHeight>0,z=(n,t)=>{_.BROWSER
|
|
1
|
+
"use strict";const _=require("esm-env");require("./plugins.js");const u=(n,t,e)=>{const i=document.createElement(n),[s,a]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),a==null||a.forEach(r=>i.appendChild(r)),i},I=(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},X=n=>n.offsetWidth>0&&n.offsetHeight>0,z=(n,t)=>{_.BROWSER&&!customElements.get(n)&&customElements.define(n,t)};function q(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 Y(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const a=[],r=[],o=[],c=[],d={},p=h=>`${h}:${d[h]=(d[h]??-1)+1}`;let x="",g=!1,y=!1;for(const h of s){x+=h.value;const l=h.type==="minusSign"||h.type==="plusSign"?"sign":h.type;l==="integer"?(g=!0,r.push(...h.value.split("").map(R=>({type:l,value:parseInt(R)})))):l==="group"?r.push({type:l,value:h.value}):l==="decimal"?(y=!0,o.push({type:l,value:h.value,key:p(l)})):l==="fraction"?o.push(...h.value.split("").map(R=>({type:l,value:parseInt(R),key:p(l),pos:-1-d[l]}))):(g||y?c:a).push({type:l,value:h.value,key:p(l)})}const P=[];for(let h=r.length-1;h>=0;h--){const l=r[h];P.unshift(l.type==="integer"?{...l,key:p(l.type),pos:d[l.type]}:{...l,key:p(l.type)})}return{pre:a,integer:P,fraction:o,post:c,valueAsString:x,value:typeof n=="string"?parseFloat(n):n}}const G=String.raw,V=String.raw,K=_.BROWSER&&(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),Z=_.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),$=_.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,S="--_number-flow-d-opacity",U="--_number-flow-d-width",E="--_number-flow-dx",j="--_number-flow-d",J=(()=>{try{return CSS.registerProperty({name:S,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:E,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:j,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),T="var(--number-flow-char-height, 1em)",f="var(--number-flow-mask-height, 0.25em)",C=`calc(${f} / 2)`,A="var(--number-flow-mask-width, 0.5em)",m=`calc(${A} / var(--scale-x))`,v="#000 0, transparent 71%",L=V`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${T} !important}.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(${U}) / var(--width));transform:translateX(var(${E})) scaleX(var(--scale-x));margin:0 calc(-1 * ${A});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${m},#000 calc(100% - ${m}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${f},#000 calc(100% - ${f}),transparent 100% ),radial-gradient(at bottom right,${v}),radial-gradient(at bottom left,${v}),radial-gradient(at top left,${v}),radial-gradient(at top right,${v});-webkit-mask-size:100% calc(100% - ${f} * 2),calc(100% - ${m} * 2) 100%,${m} ${f},${m} ${f},${m} ${f},${m} ${f};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${C} ${A};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${E})))}: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(${j})}.digit__num,.number .section::after{padding:${C} 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(${S}))}`,B=_.BROWSER?HTMLElement:class{},Q=V`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:${T} !important}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${C} 0}.symbol{white-space:pre}`,tt=n=>`<span class="${n.type==="integer"||n.type==="fraction"?"digit":"symbol"}" part="${n.type==="integer"||n.type==="fraction"?`digit ${n.type}-digit`:`symbol ${n.type}`}">${n.value}</span>`,w=(n,t)=>`<span part="${t}">${n.reduce((e,i)=>e+tt(i),"")}</span>`,et=n=>G`<template shadowroot="open" shadowrootmode="open"
|
|
2
2
|
><style>
|
|
3
3
|
${Q}</style
|
|
4
4
|
><span role="img" aria-label="${n.valueAsString}"
|
package/dist/lite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./lite-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./lite-DyshwcGq.js"),t=require("./plugins.js");exports.Digit=e.Digit;exports.canAnimate=e.canAnimate;exports.default=e.NumberFlowLite;exports.define=e.define;exports.formatToData=e.formatToData;exports.prefersReducedMotion=e.prefersReducedMotion;exports.renderInnerHTML=e.renderInnerHTML;exports.continuous=t.continuous;
|
package/dist/lite.mjs
CHANGED