@verifiedinc-public/shared-ui-elements 12.24.1 → 12.24.2-rc.91
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/components/animation/DiffusiveText/DiffusiveText.d.ts +20 -0
- package/dist/components/animation/DiffusiveText/DiffusiveText.mjs +1 -0
- package/dist/components/animation/DiffusiveText/index.d.ts +1 -0
- package/dist/components/animation/DiffusiveText/morph.d.ts +35 -0
- package/dist/components/animation/DiffusiveText/morph.mjs +1 -0
- package/dist/components/animation/index.d.ts +1 -0
- package/dist/components/animation/index.mjs +1 -1
- package/fonts/VerifiedMorph-Black-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Bold-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Hairline-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Heavy-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Light-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Medium-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Regular-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Semibold-latin.woff2 +0 -0
- package/fonts/VerifiedMorph-Thin-latin.woff2 +0 -0
- package/fonts/verified-morph.css +100 -0
- package/package.json +8 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MorphTiming } from './morph';
|
|
2
|
+
export type DiffusiveTextTiming = MorphTiming;
|
|
3
|
+
/** The timing `DiffusiveText` uses for anything its `timing` prop leaves out. */
|
|
4
|
+
export declare const defaultDiffusiveTextTiming: DiffusiveTextTiming;
|
|
5
|
+
/** The family `fonts/verified-morph.css` declares. */
|
|
6
|
+
export declare const verifiedMorphFontFamily = "\"Verified Morph\"";
|
|
7
|
+
export type DiffusiveTextProps = {
|
|
8
|
+
/** `X` an uppercase letter, `x` a lowercase one, `#` a digit; anything else shows as is (`##/##/####`). */
|
|
9
|
+
template: string;
|
|
10
|
+
value: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Verified Morph's CSS family: `verifiedMorphFontFamily` once the app imports
|
|
13
|
+
* `@verifiedinc-public/shared-ui-elements/fonts/verified-morph.css`, or the family a framework
|
|
14
|
+
* font loader (`next/font/local`) gives it.
|
|
15
|
+
*/
|
|
16
|
+
fontFamily: string;
|
|
17
|
+
/** Overrides part of `defaultDiffusiveTextTiming`. Read when the scramble starts. */
|
|
18
|
+
timing?: Partial<DiffusiveTextTiming>;
|
|
19
|
+
};
|
|
20
|
+
export declare function DiffusiveText({ template, value, fontFamily, timing, }: Readonly<DiffusiveTextProps>): React.ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useRef as M,useState as y,useEffect as F}from"react";import{Box as $}from"@mui/material";import{useReducedMotion as E}from"framer-motion";import{createMorph as S}from"./morph.mjs";import{jsx as V}from"react/jsx-runtime";const w={swapMs:40,lockMs:600,monoEaseMs:2e3},d=new Map;function k(s,e){const n=`${s}|${e}`,f=d.get(n);if(f)return f;const o=`${e} 100px ${s}`,t=document.createElement("canvas").getContext("2d"),r=new Map,i=u=>{if(!t)return 1;const m=r.get(u)??t.measureText(u).width;return r.set(u,m),m};return t&&(t.font=o),d.set(n,i),document.fonts&&!document.fonts.check(o)&&document.fonts.load(o).then(()=>{d.get(n)===i&&d.delete(n)}).catch(()=>{}),i}const j='"Verified Morph"';function q({template:s,value:e,fontFamily:n,timing:f}){const o=M(null),t=M(null),r=E(),[i,u]=y(e!==void 0),[m,A]=y(0);i&&e===void 0&&(u(!1),A(a=>a+1)),F(()=>{var a;if(i||r)return;((a=t.current)==null?void 0:a.run)!==m&&(t.current={run:m,morph:S(s,performance.now(),{...w,...f})});const C=o.current?getComputedStyle(o.current).fontWeight:"400";let p=0;const h=T=>{var g;const c=o.current,x=(g=t.current)==null?void 0:g.morph;if(!c||!x)return;const v=x.frame(T,k(n,C));c.firstChild&&(c.firstChild.nodeValue=v.text),c.style.setProperty("--mono",v.mono.toFixed(4)),v.done?(c.style.setProperty("--mono","0"),u(!0)):p=requestAnimationFrame(h)};return p=requestAnimationFrame(h),()=>cancelAnimationFrame(p)},[i,r,s,n,m]),F(()=>{var a;e!==void 0&&((a=t.current)==null||a.morph.arrive(e,performance.now()))},[e]);const l=i||r===!0&&e!==void 0;return V($,{component:"span",ref:o,"aria-hidden":l?void 0:!0,sx:{fontFamily:n,fontVariationSettings:'"MONO" var(--mono, 0)',fontVariantLigatures:"none",verticalAlign:"top","--mono":l||r===!0?0:1,opacity:!l&&r?.3:void 0},children:l?e:s.replaceAll("#","0")})}export{q as DiffusiveText,w as defaultDiffusiveTextTiming,j as verifiedMorphFontFamily};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiffusiveText';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type MorphTiming = {
|
|
2
|
+
/** How often a scrambling letter changes, in ms. */
|
|
3
|
+
swapMs: number;
|
|
4
|
+
/** Once the value arrives, every letter locks in within this window, in ms, most of them early. */
|
|
5
|
+
lockMs: number;
|
|
6
|
+
/** About how long `MONO` takes to ease from monospace toward Lato while waiting, in ms. */
|
|
7
|
+
monoEaseMs: number;
|
|
8
|
+
};
|
|
9
|
+
declare const sets: {
|
|
10
|
+
readonly U: "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
11
|
+
readonly L: "abcdefghijklmnopqrstuvwxyz";
|
|
12
|
+
readonly D: "0123456789";
|
|
13
|
+
};
|
|
14
|
+
type GlyphClass = keyof typeof sets;
|
|
15
|
+
/** A character's class; spaces, punctuation and symbols (`•`) never scramble. */
|
|
16
|
+
export declare function classOf(c: string): GlyphClass | null;
|
|
17
|
+
/** Glyph widths in Lato, for picking lookalikes. */
|
|
18
|
+
export type MeasureWidth = (c: string) => number;
|
|
19
|
+
type Random = () => number;
|
|
20
|
+
/** A plausible fake value in the template's shape: placeholders become random glyphs. */
|
|
21
|
+
export declare function fakeFrom(template: string, random: Random): string[];
|
|
22
|
+
export type MorphFrame = {
|
|
23
|
+
text: string;
|
|
24
|
+
mono: number;
|
|
25
|
+
done: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type Morph = {
|
|
28
|
+
/** The value arrived at `now` (ms): the text takes its width, and the letters lock in. */
|
|
29
|
+
arrive: (value: string, now: number) => void;
|
|
30
|
+
/** The text and `MONO` at `now` (ms); `done` once it shows the value in plain Lato. */
|
|
31
|
+
frame: (now: number, width: MeasureWidth) => MorphFrame;
|
|
32
|
+
};
|
|
33
|
+
/** Starts scrambling `template` at `start` (ms). */
|
|
34
|
+
export declare function createMorph(template: string, start: number, timing: MorphTiming, random?: Random): Morph;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const C={U:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",L:"abcdefghijklmnopqrstuvwxyz",D:"0123456789"},D={X:"U",x:"L","#":"D"};function E(t){return/\d/.test(t)?"D":t.toLowerCase()!==t.toUpperCase()?t===t.toUpperCase()?"U":"L":null}const F=new WeakMap,q={waiting:.06,arrived:.02};function y(t,r,n,a){const o=t+r+a,l=q[a];let s=F.get(n);s||(s=new Map,F.set(n,s));const f=s.get(o);if(f)return f;const i=n(t),g=[...C[r]].sort((u,k)=>Math.abs(n(u)-i)-Math.abs(n(k)-i)),h=g.filter(u=>Math.abs(n(u)-i)<=i*l);let c=h;return a==="waiting"&&h.length<3?c=g.slice(0,3):h.length===0&&(c=[t]),s.set(o,c),c}const O=(t,r)=>t[Math.floor(r()*t.length)];function W(t,r){return[...t].map(n=>{const a=D[n];return a?O(C[a],r):n})}function N(t,r,n,a){for(let o=0;o<a;o+=4){const l=Math.min(4,a-o)/1e3;t.v+=(n*n*(r-t.x)-2*n*t.v)*l,t.x+=t.v*l}}function R(t,r,n,a=Math.random){const o=W(t,a),l=[...t].map(e=>D[e]??null),s=[...o],{swapMs:f,lockMs:i,monoEaseMs:g}=n,h=4400/g,c=o.map(()=>r+a()*f),u={x:1,v:0};let k=r,w=null;const L=(e,m,p,x,U)=>((s[e]===void 0||x>=c[e])&&(s[e]=O(y(m,p,U,w?"arrived":"waiting"),a),c[e]=x+f*(.7+.6*a())),s[e]);return{arrive(e,m){const p=[...e];s.length=0,c.length=0,w={at:m,real:p,lock:p.map(()=>a()**2*i)}},frame(e,m){if(!w)return N(u,.1,h,Math.min(50,Math.max(0,e-k))),k=e,{text:o.map((M,d)=>{const v=l[d];return v?L(d,M,v,e,m):M}).join(""),mono:u.x,done:!1};const{at:p,real:x,lock:U}=w,X=e-p;let j=!1;const b=x.map((M,d)=>{const v=E(M);return!v||X>=U[d]?M:(j=!0,L(d,M,v,e,m))});return j?{text:b.join(""),mono:0,done:!1}:{text:x.join(""),mono:0,done:!0}}}}export{E as classOf,R as createMorph,W as fakeFrom};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Counter as o}from"./Counter.mjs";import{MotionBox as
|
|
1
|
+
"use strict";import{Counter as o}from"./Counter.mjs";import{MotionBox as i,MotionButton as a,MotionStack as t,MotionTableCell as s,MotionTableRow as e,MotionTbody as n,MotionTypography as r}from"./motions.mjs";import{AnimateHeight as f}from"./AnimatedHeight.mjs";import{DiffusiveText as M,defaultDiffusiveTextTiming as m,verifiedMorphFontFamily as T}from"./DiffusiveText/DiffusiveText.mjs";export{f as AnimateHeight,o as Counter,M as DiffusiveText,i as MotionBox,a as MotionButton,t as MotionStack,s as MotionTableCell,e as MotionTableRow,n as MotionTbody,r as MotionTypography,m as defaultDiffusiveTextTiming,T as verifiedMorphFontFamily};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* Verified Morph: Lato 2.0 with a MONO axis (1 = every letter the same width, 0 = exactly Lato). Latin, upright, 100-900. Lato is under the SIL Open Font License. */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: 'Verified Morph';
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-weight: 100;
|
|
6
|
+
font-display: swap;
|
|
7
|
+
src: url('./VerifiedMorph-Hairline-latin.woff2') format('woff2');
|
|
8
|
+
unicode-range:
|
|
9
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
10
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
11
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
12
|
+
}
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: 'Verified Morph';
|
|
15
|
+
font-style: normal;
|
|
16
|
+
font-weight: 200;
|
|
17
|
+
font-display: swap;
|
|
18
|
+
src: url('./VerifiedMorph-Thin-latin.woff2') format('woff2');
|
|
19
|
+
unicode-range:
|
|
20
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
21
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
22
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
23
|
+
}
|
|
24
|
+
@font-face {
|
|
25
|
+
font-family: 'Verified Morph';
|
|
26
|
+
font-style: normal;
|
|
27
|
+
font-weight: 300;
|
|
28
|
+
font-display: swap;
|
|
29
|
+
src: url('./VerifiedMorph-Light-latin.woff2') format('woff2');
|
|
30
|
+
unicode-range:
|
|
31
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
32
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
33
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
34
|
+
}
|
|
35
|
+
@font-face {
|
|
36
|
+
font-family: 'Verified Morph';
|
|
37
|
+
font-style: normal;
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
font-display: swap;
|
|
40
|
+
src: url('./VerifiedMorph-Regular-latin.woff2') format('woff2');
|
|
41
|
+
unicode-range:
|
|
42
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
43
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
44
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
45
|
+
}
|
|
46
|
+
@font-face {
|
|
47
|
+
font-family: 'Verified Morph';
|
|
48
|
+
font-style: normal;
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
font-display: swap;
|
|
51
|
+
src: url('./VerifiedMorph-Medium-latin.woff2') format('woff2');
|
|
52
|
+
unicode-range:
|
|
53
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
54
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
55
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
56
|
+
}
|
|
57
|
+
@font-face {
|
|
58
|
+
font-family: 'Verified Morph';
|
|
59
|
+
font-style: normal;
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
font-display: swap;
|
|
62
|
+
src: url('./VerifiedMorph-Semibold-latin.woff2') format('woff2');
|
|
63
|
+
unicode-range:
|
|
64
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
65
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
66
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
67
|
+
}
|
|
68
|
+
@font-face {
|
|
69
|
+
font-family: 'Verified Morph';
|
|
70
|
+
font-style: normal;
|
|
71
|
+
font-weight: 700;
|
|
72
|
+
font-display: swap;
|
|
73
|
+
src: url('./VerifiedMorph-Bold-latin.woff2') format('woff2');
|
|
74
|
+
unicode-range:
|
|
75
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
76
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
77
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
78
|
+
}
|
|
79
|
+
@font-face {
|
|
80
|
+
font-family: 'Verified Morph';
|
|
81
|
+
font-style: normal;
|
|
82
|
+
font-weight: 800;
|
|
83
|
+
font-display: swap;
|
|
84
|
+
src: url('./VerifiedMorph-Heavy-latin.woff2') format('woff2');
|
|
85
|
+
unicode-range:
|
|
86
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
87
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
88
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
89
|
+
}
|
|
90
|
+
@font-face {
|
|
91
|
+
font-family: 'Verified Morph';
|
|
92
|
+
font-style: normal;
|
|
93
|
+
font-weight: 900;
|
|
94
|
+
font-display: swap;
|
|
95
|
+
src: url('./VerifiedMorph-Black-latin.woff2') format('woff2');
|
|
96
|
+
unicode-range:
|
|
97
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
98
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
99
|
+
U+2215, U+FEFF, U+FFFD, U+0300-036F;
|
|
100
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verifiedinc-public/shared-ui-elements",
|
|
3
|
-
"version": "12.24.
|
|
3
|
+
"version": "12.24.2-rc.91",
|
|
4
4
|
"description": "A set of UI components, utilities that is shareable with the core apps.",
|
|
5
5
|
"private": false,
|
|
6
|
-
"sideEffects":
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css"
|
|
8
|
+
],
|
|
7
9
|
"keywords": [],
|
|
8
10
|
"author": "VerifiedInc",
|
|
9
11
|
"engines": {
|
|
@@ -13,7 +15,8 @@
|
|
|
13
15
|
"main": "/dist/index.mjs",
|
|
14
16
|
"types": "/dist/index.d.ts",
|
|
15
17
|
"files": [
|
|
16
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"fonts"
|
|
17
20
|
],
|
|
18
21
|
"exports": {
|
|
19
22
|
".": {
|
|
@@ -55,7 +58,8 @@
|
|
|
55
58
|
"./utils/*": {
|
|
56
59
|
"types": "./dist/utils/*/index.d.ts",
|
|
57
60
|
"import": "./dist/utils/*/index.mjs"
|
|
58
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"./fonts/verified-morph.css": "./fonts/verified-morph.css"
|
|
59
63
|
},
|
|
60
64
|
"scripts": {
|
|
61
65
|
"test": "npm run vitest",
|