react-native-laminar 1.0.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.
- package/README.md +11 -0
- package/lib/commonjs/hooks/use-display-units.js +13 -0
- package/lib/commonjs/hooks/use-display-units.js.map +1 -0
- package/lib/commonjs/hooks/use-inline-auto-width.js +45 -0
- package/lib/commonjs/hooks/use-inline-auto-width.js.map +1 -0
- package/lib/commonjs/hooks/use-morph-motion.js +24 -0
- package/lib/commonjs/hooks/use-morph-motion.js.map +1 -0
- package/lib/commonjs/hooks/use-morph-text-style.js +32 -0
- package/lib/commonjs/hooks/use-morph-text-style.js.map +1 -0
- package/lib/commonjs/hooks/use-numeric-lanes.js +37 -0
- package/lib/commonjs/hooks/use-numeric-lanes.js.map +1 -0
- package/lib/commonjs/hooks/use-text-glyphs.js +35 -0
- package/lib/commonjs/hooks/use-text-glyphs.js.map +1 -0
- package/lib/commonjs/index.js +89 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/model/display-units.js +29 -0
- package/lib/commonjs/model/display-units.js.map +1 -0
- package/lib/commonjs/model/numeric-lanes.js +45 -0
- package/lib/commonjs/model/numeric-lanes.js.map +1 -0
- package/lib/commonjs/model/text-keys.js +80 -0
- package/lib/commonjs/model/text-keys.js.map +1 -0
- package/lib/commonjs/motion/entry-exit-builders.js +57 -0
- package/lib/commonjs/motion/entry-exit-builders.js.map +1 -0
- package/lib/commonjs/motion/preset-map.js +91 -0
- package/lib/commonjs/motion/preset-map.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/view/glyph-run.js +34 -0
- package/lib/commonjs/view/glyph-run.js.map +1 -0
- package/lib/commonjs/view/morph-viewport.js +64 -0
- package/lib/commonjs/view/morph-viewport.js.map +1 -0
- package/lib/commonjs/view/number-lane.js +85 -0
- package/lib/commonjs/view/number-lane.js.map +1 -0
- package/lib/commonjs/view/number-run.js +61 -0
- package/lib/commonjs/view/number-run.js.map +1 -0
- package/lib/commonjs/view/text-run.js +35 -0
- package/lib/commonjs/view/text-run.js.map +1 -0
- package/lib/module/hooks/use-display-units.js +8 -0
- package/lib/module/hooks/use-display-units.js.map +1 -0
- package/lib/module/hooks/use-inline-auto-width.js +40 -0
- package/lib/module/hooks/use-inline-auto-width.js.map +1 -0
- package/lib/module/hooks/use-morph-motion.js +19 -0
- package/lib/module/hooks/use-morph-motion.js.map +1 -0
- package/lib/module/hooks/use-morph-text-style.js +27 -0
- package/lib/module/hooks/use-morph-text-style.js.map +1 -0
- package/lib/module/hooks/use-numeric-lanes.js +32 -0
- package/lib/module/hooks/use-numeric-lanes.js.map +1 -0
- package/lib/module/hooks/use-text-glyphs.js +30 -0
- package/lib/module/hooks/use-text-glyphs.js.map +1 -0
- package/lib/module/index.js +84 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/model/display-units.js +21 -0
- package/lib/module/model/display-units.js.map +1 -0
- package/lib/module/model/numeric-lanes.js +40 -0
- package/lib/module/model/numeric-lanes.js.map +1 -0
- package/lib/module/model/text-keys.js +75 -0
- package/lib/module/model/text-keys.js.map +1 -0
- package/lib/module/motion/entry-exit-builders.js +52 -0
- package/lib/module/motion/entry-exit-builders.js.map +1 -0
- package/lib/module/motion/preset-map.js +86 -0
- package/lib/module/motion/preset-map.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/view/glyph-run.js +29 -0
- package/lib/module/view/glyph-run.js.map +1 -0
- package/lib/module/view/morph-viewport.js +58 -0
- package/lib/module/view/morph-viewport.js.map +1 -0
- package/lib/module/view/number-lane.js +79 -0
- package/lib/module/view/number-lane.js.map +1 -0
- package/lib/module/view/number-run.js +56 -0
- package/lib/module/view/number-run.js.map +1 -0
- package/lib/module/view/text-run.js +30 -0
- package/lib/module/view/text-run.js.map +1 -0
- package/lib/typescript/commonjs/hooks/use-display-units.d.ts +2 -0
- package/lib/typescript/commonjs/hooks/use-display-units.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts +15 -0
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-morph-motion.d.ts +14 -0
- package/lib/typescript/commonjs/hooks/use-morph-motion.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-morph-text-style.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/use-morph-text-style.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-numeric-lanes.d.ts +10 -0
- package/lib/typescript/commonjs/hooks/use-numeric-lanes.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +7 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/model/display-units.d.ts +5 -0
- package/lib/typescript/commonjs/model/display-units.d.ts.map +1 -0
- package/lib/typescript/commonjs/model/numeric-lanes.d.ts +9 -0
- package/lib/typescript/commonjs/model/numeric-lanes.d.ts.map +1 -0
- package/lib/typescript/commonjs/model/text-keys.d.ts +7 -0
- package/lib/typescript/commonjs/model/text-keys.d.ts.map +1 -0
- package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts +15 -0
- package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts.map +1 -0
- package/lib/typescript/commonjs/motion/preset-map.d.ts +4 -0
- package/lib/typescript/commonjs/motion/preset-map.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types.d.ts +43 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/glyph-run.d.ts +12 -0
- package/lib/typescript/commonjs/view/glyph-run.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/morph-viewport.d.ts +14 -0
- package/lib/typescript/commonjs/view/morph-viewport.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/number-lane.d.ts +17 -0
- package/lib/typescript/commonjs/view/number-lane.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/number-run.d.ts +13 -0
- package/lib/typescript/commonjs/view/number-run.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/text-run.d.ts +11 -0
- package/lib/typescript/commonjs/view/text-run.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-display-units.d.ts +2 -0
- package/lib/typescript/module/hooks/use-display-units.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts +15 -0
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-morph-motion.d.ts +14 -0
- package/lib/typescript/module/hooks/use-morph-motion.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-morph-text-style.d.ts +13 -0
- package/lib/typescript/module/hooks/use-morph-text-style.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-numeric-lanes.d.ts +10 -0
- package/lib/typescript/module/hooks/use-numeric-lanes.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts +3 -0
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +7 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/model/display-units.d.ts +5 -0
- package/lib/typescript/module/model/display-units.d.ts.map +1 -0
- package/lib/typescript/module/model/numeric-lanes.d.ts +9 -0
- package/lib/typescript/module/model/numeric-lanes.d.ts.map +1 -0
- package/lib/typescript/module/model/text-keys.d.ts +7 -0
- package/lib/typescript/module/model/text-keys.d.ts.map +1 -0
- package/lib/typescript/module/motion/entry-exit-builders.d.ts +15 -0
- package/lib/typescript/module/motion/entry-exit-builders.d.ts.map +1 -0
- package/lib/typescript/module/motion/preset-map.d.ts +4 -0
- package/lib/typescript/module/motion/preset-map.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types.d.ts +43 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/view/glyph-run.d.ts +12 -0
- package/lib/typescript/module/view/glyph-run.d.ts.map +1 -0
- package/lib/typescript/module/view/morph-viewport.d.ts +14 -0
- package/lib/typescript/module/view/morph-viewport.d.ts.map +1 -0
- package/lib/typescript/module/view/number-lane.d.ts +17 -0
- package/lib/typescript/module/view/number-lane.d.ts.map +1 -0
- package/lib/typescript/module/view/number-run.d.ts +13 -0
- package/lib/typescript/module/view/number-run.d.ts.map +1 -0
- package/lib/typescript/module/view/text-run.d.ts +11 -0
- package/lib/typescript/module/view/text-run.d.ts.map +1 -0
- package/package.json +61 -0
- package/src/hooks/use-display-units.ts +18 -0
- package/src/hooks/use-inline-auto-width.ts +57 -0
- package/src/hooks/use-morph-motion.ts +40 -0
- package/src/hooks/use-morph-text-style.ts +45 -0
- package/src/hooks/use-numeric-lanes.ts +55 -0
- package/src/hooks/use-text-glyphs.ts +56 -0
- package/src/index.tsx +98 -0
- package/src/model/display-units.ts +28 -0
- package/src/model/numeric-lanes.ts +80 -0
- package/src/model/text-keys.ts +123 -0
- package/src/motion/entry-exit-builders.ts +74 -0
- package/src/motion/preset-map.ts +127 -0
- package/src/types.ts +60 -0
- package/src/view/glyph-run.tsx +47 -0
- package/src/view/morph-viewport.tsx +83 -0
- package/src/view/number-lane.tsx +128 -0
- package/src/view/number-run.tsx +73 -0
- package/src/view/text-run.tsx +40 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Text } from "react-native";
|
|
5
|
+
import { useInlineAutoWidth } from "./hooks/use-inline-auto-width.js";
|
|
6
|
+
import { useMorphMotion } from "./hooks/use-morph-motion.js";
|
|
7
|
+
import { useMorphTextStyle } from "./hooks/use-morph-text-style.js";
|
|
8
|
+
import { normalizeDisplayUnit, splitDisplayUnits } from "./model/display-units.js";
|
|
9
|
+
import { MorphViewport } from "./view/morph-viewport.js";
|
|
10
|
+
import { NumberRun } from "./view/number-run.js";
|
|
11
|
+
import { TextRun } from "./view/text-run.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export const Laminar = /*#__PURE__*/React.memo(function Laminar({
|
|
14
|
+
text,
|
|
15
|
+
variant = "text",
|
|
16
|
+
fontSize,
|
|
17
|
+
color,
|
|
18
|
+
style,
|
|
19
|
+
containerStyle,
|
|
20
|
+
fontStyle,
|
|
21
|
+
animationDuration,
|
|
22
|
+
animationPreset,
|
|
23
|
+
stagger = 0.02,
|
|
24
|
+
autoSize = true,
|
|
25
|
+
clipToBounds = false
|
|
26
|
+
}) {
|
|
27
|
+
const resolvedValue = String(text ?? "");
|
|
28
|
+
const {
|
|
29
|
+
motionRecipe,
|
|
30
|
+
staggerMs
|
|
31
|
+
} = useMorphMotion({
|
|
32
|
+
variant,
|
|
33
|
+
animationPreset,
|
|
34
|
+
animationDuration,
|
|
35
|
+
stagger
|
|
36
|
+
});
|
|
37
|
+
const {
|
|
38
|
+
textStyle
|
|
39
|
+
} = useMorphTextStyle({
|
|
40
|
+
fontSize,
|
|
41
|
+
color,
|
|
42
|
+
fontStyle,
|
|
43
|
+
style
|
|
44
|
+
});
|
|
45
|
+
const {
|
|
46
|
+
captureLayout,
|
|
47
|
+
animatedWidthStyle
|
|
48
|
+
} = useInlineAutoWidth({
|
|
49
|
+
enabled: autoSize,
|
|
50
|
+
driveToWidth: motionRecipe.driveNumber
|
|
51
|
+
});
|
|
52
|
+
const measuredValue = React.useMemo(() => {
|
|
53
|
+
if (!autoSize) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
return splitDisplayUnits(resolvedValue).map(normalizeDisplayUnit).join("");
|
|
57
|
+
}, [autoSize, resolvedValue]);
|
|
58
|
+
return /*#__PURE__*/_jsx(MorphViewport, {
|
|
59
|
+
autoSize: autoSize,
|
|
60
|
+
clipToBounds: clipToBounds,
|
|
61
|
+
containerStyle: containerStyle,
|
|
62
|
+
animatedWidthStyle: animatedWidthStyle,
|
|
63
|
+
measurement: /*#__PURE__*/_jsx(Text, {
|
|
64
|
+
numberOfLines: 1,
|
|
65
|
+
onLayout: captureLayout,
|
|
66
|
+
style: textStyle,
|
|
67
|
+
children: measuredValue
|
|
68
|
+
}),
|
|
69
|
+
children: variant === "number" ? /*#__PURE__*/_jsx(NumberRun, {
|
|
70
|
+
value: resolvedValue,
|
|
71
|
+
motionRecipe: motionRecipe,
|
|
72
|
+
fontSize: fontSize,
|
|
73
|
+
textStyle: textStyle,
|
|
74
|
+
staggerMs: staggerMs
|
|
75
|
+
}) : /*#__PURE__*/_jsx(TextRun, {
|
|
76
|
+
value: resolvedValue,
|
|
77
|
+
motionRecipe: motionRecipe,
|
|
78
|
+
textStyle: textStyle
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
export const MorphingText = Laminar;
|
|
83
|
+
export default Laminar;
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Text","useInlineAutoWidth","useMorphMotion","useMorphTextStyle","normalizeDisplayUnit","splitDisplayUnits","MorphViewport","NumberRun","TextRun","jsx","_jsx","Laminar","memo","text","variant","fontSize","color","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","motionRecipe","staggerMs","textStyle","captureLayout","animatedWidthStyle","enabled","driveToWidth","driveNumber","measuredValue","useMemo","map","join","measurement","numberOfLines","onLayout","children","value","MorphingText"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,kBAAkB,QAAQ,kCAA+B;AAClE,SAASC,cAAc,QAAQ,6BAA0B;AACzD,SAASC,iBAAiB,QAAQ,iCAA8B;AAChE,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aAAa;IACZiB,QAAQ,EAAEA,QAAS;IACnBC,YAAY,EAAEA,YAAa;IAC3BN,cAAc,EAAEA,cAAe;IAC/Ba,kBAAkB,EAAEA,kBAAmB;IACvCQ,WAAW,eACT7B,IAAA,CAACV,IAAI;MACHwC,aAAa,EAAE,CAAE;MACjBC,QAAQ,EAAEX,aAAc;MACxBb,KAAK,EAAEY,SAAU;MAAAa,QAAA,EAEhBP;IAAa,CACV,CACP;IAAAO,QAAA,EAEA5B,OAAO,KAAK,QAAQ,gBACnBJ,IAAA,CAACH,SAAS;MACRoC,KAAK,EAAElB,aAAc;MACrBE,YAAY,EAAEA,YAAa;MAC3BZ,QAAQ,EAAEA,QAAS;MACnBc,SAAS,EAAEA,SAAU;MACrBD,SAAS,EAAEA;IAAU,CACtB,CAAC,gBAEFlB,IAAA,CAACF,OAAO;MACNmC,KAAK,EAAElB,aAAc;MACrBE,YAAY,EAAEA,YAAa;MAC3BE,SAAS,EAAEA;IAAU,CACtB;EACJ,CACY,CAAC;AAElB,CAAC,CAAC;AAEJ,OAAO,MAAMe,YAAY,GAAGjC,OAAO;AAEnC,eAAeA,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const NBSP = "\u00A0";
|
|
4
|
+
const graphemeSegmenter = typeof Intl !== "undefined" && typeof Intl.Segmenter === "function" ? new Intl.Segmenter(undefined, {
|
|
5
|
+
granularity: "grapheme"
|
|
6
|
+
}) : null;
|
|
7
|
+
export const splitDisplayUnits = input => {
|
|
8
|
+
if (graphemeSegmenter) {
|
|
9
|
+
return Array.from(graphemeSegmenter.segment(input), part => part.segment);
|
|
10
|
+
}
|
|
11
|
+
return Array.from(input);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// swap plain spaces so measured text keeps its width
|
|
15
|
+
export const normalizeDisplayUnit = unit => unit === " " ? NBSP : unit;
|
|
16
|
+
export const isAsciiDigit = unit => unit >= "0" && unit <= "9";
|
|
17
|
+
export const findNumericLeadLength = units => {
|
|
18
|
+
const firstDigitIndex = units.findIndex(isAsciiDigit);
|
|
19
|
+
return firstDigitIndex === -1 ? units.length : firstDigitIndex;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=display-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NBSP","graphemeSegmenter","Intl","Segmenter","undefined","granularity","splitDisplayUnits","input","Array","from","segment","part","normalizeDisplayUnit","unit","isAsciiDigit","findNumericLeadLength","units","firstDigitIndex","findIndex","length"],"sourceRoot":"../../../src","sources":["model/display-units.ts"],"mappings":";;AAAA,MAAMA,IAAI,GAAG,QAAQ;AACrB,MAAMC,iBAAiB,GACrB,OAAOC,IAAI,KAAK,WAAW,IAAI,OAAOA,IAAI,CAACC,SAAS,KAAK,UAAU,GAC/D,IAAID,IAAI,CAACC,SAAS,CAACC,SAAS,EAAE;EAAEC,WAAW,EAAE;AAAW,CAAC,CAAC,GAC1D,IAAI;AAEV,OAAO,MAAMC,iBAAiB,GAAIC,KAAa,IAAe;EAC5D,IAAIN,iBAAiB,EAAE;IACrB,OAAOO,KAAK,CAACC,IAAI,CACfR,iBAAiB,CAACS,OAAO,CAACH,KAAK,CAAC,EAC/BI,IAAI,IAAKA,IAAI,CAACD,OACjB,CAAC;EACH;EAEA,OAAOF,KAAK,CAACC,IAAI,CAACF,KAAK,CAAC;AAC1B,CAAC;;AAED;AACA,OAAO,MAAMK,oBAAoB,GAAIC,IAAY,IAC/CA,IAAI,KAAK,GAAG,GAAGb,IAAI,GAAGa,IAAI;AAE5B,OAAO,MAAMC,YAAY,GAAID,IAAY,IAAKA,IAAI,IAAI,GAAG,IAAIA,IAAI,IAAI,GAAG;AAExE,OAAO,MAAME,qBAAqB,GAAIC,KAAwB,IAAK;EACjE,MAAMC,eAAe,GAAGD,KAAK,CAACE,SAAS,CAACJ,YAAY,CAAC;EAErD,OAAOG,eAAe,KAAK,CAAC,CAAC,GAAGD,KAAK,CAACG,MAAM,GAAGF,eAAe;AAChE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { findNumericLeadLength, splitDisplayUnits } from "./display-units.js";
|
|
4
|
+
const readNumericMagnitude = input => parseFloat(input.replace(/[^0-9.-]/g, "")) || 0;
|
|
5
|
+
const deriveFlowDirection = (previousValue, nextValue) => Math.sign(readNumericMagnitude(nextValue) - readNumericMagnitude(previousValue));
|
|
6
|
+
export const reconcileNumericLanes = (previousValue, nextValue, previousKeys, seed) => {
|
|
7
|
+
const previousUnits = splitDisplayUnits(previousValue);
|
|
8
|
+
const nextUnits = splitDisplayUnits(nextValue);
|
|
9
|
+
const nextLaneKeys = new Array(nextUnits.length);
|
|
10
|
+
let nextSeed = seed;
|
|
11
|
+
const nextLeadLength = findNumericLeadLength(nextUnits);
|
|
12
|
+
const previousLeadLength = findNumericLeadLength(previousUnits);
|
|
13
|
+
const sharedLeadLength = Math.min(nextLeadLength, previousLeadLength);
|
|
14
|
+
for (let index = 0; index < nextLeadLength; index += 1) {
|
|
15
|
+
nextLaneKeys[index] = index < sharedLeadLength && nextUnits[index] === previousUnits[index] ? previousKeys[index] : nextSeed++;
|
|
16
|
+
}
|
|
17
|
+
const previousTailUnits = previousUnits.slice(previousLeadLength);
|
|
18
|
+
const nextTailUnits = nextUnits.slice(nextLeadLength);
|
|
19
|
+
const previousTailKeys = previousKeys.slice(previousLeadLength);
|
|
20
|
+
const laneCount = Math.max(previousTailUnits.length, nextTailUnits.length);
|
|
21
|
+
const leftPaddedPreviousUnits = [...Array(Math.max(0, laneCount - previousTailUnits.length)).fill(""), ...previousTailUnits];
|
|
22
|
+
const leftPaddedNextUnits = [...Array(Math.max(0, laneCount - nextTailUnits.length)).fill(""), ...nextTailUnits];
|
|
23
|
+
const leftPaddedPreviousKeys = [...Array(Math.max(0, laneCount - previousTailKeys.length)).fill(-1), ...previousTailKeys];
|
|
24
|
+
|
|
25
|
+
// pad from the left so the rightmost digits keep their place value lanes
|
|
26
|
+
const nextTailOffset = laneCount - nextTailUnits.length;
|
|
27
|
+
for (let index = 0; index < nextTailUnits.length; index += 1) {
|
|
28
|
+
const paddedIndex = nextTailOffset + index;
|
|
29
|
+
const nextUnit = leftPaddedNextUnits[paddedIndex];
|
|
30
|
+
const previousUnit = leftPaddedPreviousUnits[paddedIndex];
|
|
31
|
+
const previousKey = leftPaddedPreviousKeys[paddedIndex];
|
|
32
|
+
nextLaneKeys[nextLeadLength + index] = nextUnit === previousUnit && previousKey >= 0 ? previousKey : nextSeed++;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
laneKeys: nextLaneKeys,
|
|
36
|
+
nextSeed,
|
|
37
|
+
direction: deriveFlowDirection(previousValue, nextValue)
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=numeric-lanes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["findNumericLeadLength","splitDisplayUnits","readNumericMagnitude","input","parseFloat","replace","deriveFlowDirection","previousValue","nextValue","Math","sign","reconcileNumericLanes","previousKeys","seed","previousUnits","nextUnits","nextLaneKeys","Array","length","nextSeed","nextLeadLength","previousLeadLength","sharedLeadLength","min","index","previousTailUnits","slice","nextTailUnits","previousTailKeys","laneCount","max","leftPaddedPreviousUnits","fill","leftPaddedNextUnits","leftPaddedPreviousKeys","nextTailOffset","paddedIndex","nextUnit","previousUnit","previousKey","laneKeys","direction"],"sourceRoot":"../../../src","sources":["model/numeric-lanes.ts"],"mappings":";;AACA,SACEA,qBAAqB,EACrBC,iBAAiB,QACZ,oBAAiB;AAExB,MAAMC,oBAAoB,GAAIC,KAAa,IACzCC,UAAU,CAACD,KAAK,CAACE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;AAEjD,MAAMC,mBAAmB,GAAGA,CAC1BC,aAAqB,EACrBC,SAAiB,KAEjBC,IAAI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
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const computeLcsPairs = (previousUnits, nextUnits) => {
|
|
4
|
+
const previousLength = previousUnits.length;
|
|
5
|
+
const nextLength = nextUnits.length;
|
|
6
|
+
if (previousLength === 0 || nextLength === 0) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const dp = Array.from({
|
|
10
|
+
length: previousLength + 1
|
|
11
|
+
}, () => new Array(nextLength + 1).fill(0));
|
|
12
|
+
for (let previousIndex = 1; previousIndex <= previousLength; previousIndex += 1) {
|
|
13
|
+
for (let nextIndex = 1; nextIndex <= nextLength; nextIndex += 1) {
|
|
14
|
+
dp[previousIndex][nextIndex] = previousUnits[previousIndex - 1] === nextUnits[nextIndex - 1] ? dp[previousIndex - 1][nextIndex - 1] + 1 : Math.max(dp[previousIndex - 1][nextIndex], dp[previousIndex][nextIndex - 1]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const pairs = [];
|
|
18
|
+
let previousIndex = previousLength;
|
|
19
|
+
let nextIndex = nextLength;
|
|
20
|
+
while (previousIndex > 0 && nextIndex > 0) {
|
|
21
|
+
if (previousUnits[previousIndex - 1] === nextUnits[nextIndex - 1]) {
|
|
22
|
+
pairs.push([previousIndex - 1, nextIndex - 1]);
|
|
23
|
+
previousIndex -= 1;
|
|
24
|
+
nextIndex -= 1;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (dp[previousIndex - 1][nextIndex] > dp[previousIndex][nextIndex - 1] || dp[previousIndex - 1][nextIndex] === dp[previousIndex][nextIndex - 1] && previousIndex >= nextIndex) {
|
|
28
|
+
previousIndex -= 1;
|
|
29
|
+
} else {
|
|
30
|
+
nextIndex -= 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
pairs.reverse();
|
|
34
|
+
return pairs;
|
|
35
|
+
};
|
|
36
|
+
export const reconcileTextGlyphKeys = (previousUnits, nextUnits, previousKeys, seed, namespace) => {
|
|
37
|
+
const previousLength = previousUnits.length;
|
|
38
|
+
const nextLength = nextUnits.length;
|
|
39
|
+
const nextGlyphKeys = new Array(nextUnits.length).fill("");
|
|
40
|
+
let nextSeed = seed;
|
|
41
|
+
let sharedPrefixLength = 0;
|
|
42
|
+
while (sharedPrefixLength < previousLength && sharedPrefixLength < nextLength && previousUnits[sharedPrefixLength] === nextUnits[sharedPrefixLength]) {
|
|
43
|
+
nextGlyphKeys[sharedPrefixLength] = previousKeys[sharedPrefixLength] ?? `${namespace}:c${nextSeed++}`;
|
|
44
|
+
sharedPrefixLength += 1;
|
|
45
|
+
}
|
|
46
|
+
let sharedSuffixLength = 0;
|
|
47
|
+
while (sharedSuffixLength < previousLength - sharedPrefixLength && sharedSuffixLength < nextLength - sharedPrefixLength && previousUnits[previousLength - 1 - sharedSuffixLength] === nextUnits[nextLength - 1 - sharedSuffixLength]) {
|
|
48
|
+
const previousIndex = previousLength - 1 - sharedSuffixLength;
|
|
49
|
+
const nextIndex = nextLength - 1 - sharedSuffixLength;
|
|
50
|
+
nextGlyphKeys[nextIndex] = previousKeys[previousIndex] ?? `${namespace}:c${nextSeed++}`;
|
|
51
|
+
sharedSuffixLength += 1;
|
|
52
|
+
}
|
|
53
|
+
const previousMiddleEnd = previousLength - sharedSuffixLength;
|
|
54
|
+
const nextMiddleEnd = nextLength - sharedSuffixLength;
|
|
55
|
+
const previousMiddleUnits = previousUnits.slice(sharedPrefixLength, previousMiddleEnd);
|
|
56
|
+
const nextMiddleUnits = nextUnits.slice(sharedPrefixLength, nextMiddleEnd);
|
|
57
|
+
|
|
58
|
+
// lcs keeps shared middle glyphs in place when the text changes
|
|
59
|
+
const matches = computeLcsPairs(previousMiddleUnits, nextMiddleUnits);
|
|
60
|
+
for (const [previousIndex, nextIndex] of matches) {
|
|
61
|
+
const absolutePreviousIndex = previousIndex + sharedPrefixLength;
|
|
62
|
+
const absoluteNextIndex = nextIndex + sharedPrefixLength;
|
|
63
|
+
nextGlyphKeys[absoluteNextIndex] = previousKeys[absolutePreviousIndex] ?? `${namespace}:c${nextSeed++}`;
|
|
64
|
+
}
|
|
65
|
+
for (let nextIndex = 0; nextIndex < nextGlyphKeys.length; nextIndex += 1) {
|
|
66
|
+
if (!nextGlyphKeys[nextIndex]) {
|
|
67
|
+
nextGlyphKeys[nextIndex] = `${namespace}:c${nextSeed++}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
glyphKeys: nextGlyphKeys,
|
|
72
|
+
nextSeed
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=text-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["computeLcsPairs","previousUnits","nextUnits","previousLength","length","nextLength","dp","Array","from","fill","previousIndex","nextIndex","Math","max","pairs","push","reverse","reconcileTextGlyphKeys","previousKeys","seed","namespace","nextGlyphKeys","nextSeed","sharedPrefixLength","sharedSuffixLength","previousMiddleEnd","nextMiddleEnd","previousMiddleUnits","slice","nextMiddleUnits","matches","absolutePreviousIndex","absoluteNextIndex","glyphKeys"],"sourceRoot":"../../../src","sources":["model/text-keys.ts"],"mappings":";;AAAA,MAAMA,eAAe,GAAGA,CACtBC,aAAgC,EAChCC,SAA4B,KACI;EAChC,MAAMC,cAAc,GAAGF,aAAa,CAACG,MAAM;EAC3C,MAAMC,UAAU,GAAGH,SAAS,CAACE,MAAM;EAEnC,IAAID,cAAc,KAAK,CAAC,IAAIE,UAAU,KAAK,CAAC,EAAE;IAC5C,OAAO,EAAE;EACX;EAEA,MAAMC,EAAE,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEJ,MAAM,EAAED,cAAc,GAAG;EAAE,CAAC,EAAE,MACpD,IAAII,KAAK,CAASF,UAAU,GAAG,CAAC,CAAC,CAACI,IAAI,CAAC,CAAC,CAC1C,CAAC;EAED,KAAK,IAAIC,aAAa,GAAG,CAAC,EAAEA,aAAa,IAAIP,cAAc,EAAEO,aAAa,IAAI,CAAC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,KAAKE,QAAQ,EAAE,EAAE;IAC9DE,kBAAkB,IAAI,CAAC;EACzB;EAEA,MAAMC,iBAAiB,GAAGtB,cAAc,GAAGqB,kBAAkB;EAC7D,MAAME,aAAa,GAAGrB,UAAU,GAAGmB,kBAAkB;EACrD,MAAMG,mBAAmB,GAAG1B,aAAa,CAAC2B,KAAK,CAC7CL,kBAAkB,EAClBE,iBACF,CAAC;EACD,MAAMI,eAAe,GAAG3B,SAAS,CAAC0B,KAAK,CAACL,kBAAkB,EAAEG,aAAa,CAAC;;EAE1E;EACA,MAAMI,OAAO,GAAG9B,eAAe,CAAC2B,mBAAmB,EAAEE,eAAe,CAAC;EAErE,KAAK,MAAM,CAACnB,aAAa,EAAEC,SAAS,CAAC,IAAImB,OAAO,EAAE;IAChD,MAAMC,qBAAqB,GAAGrB,aAAa,GAAGa,kBAAkB;IAChE,MAAMS,iBAAiB,GAAGrB,SAAS,GAAGY,kBAAkB;IAExDF,aAAa,CAACW,iBAAiB,CAAC,GAC9Bd,YAAY,CAACa,qBAAqB,CAAC,IAAI,GAAGX,SAAS,KAAKE,QAAQ,EAAE,EAAE;EACxE;EAEA,KAAK,IAAIX,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAGU,aAAa,CAACjB,MAAM,EAAEO,SAAS,IAAI,CAAC,EAAE;IACxE,IAAI,CAACU,aAAa,CAACV,SAAS,CAAC,EAAE;MAC7BU,aAAa,CAACV,SAAS,CAAC,GAAG,GAAGS,SAAS,KAAKE,QAAQ,EAAE,EAAE;IAC1D;EACF;EAEA,OAAO;IACLW,SAAS,EAAEZ,aAAa;IACxBC;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { withDelay, withTiming } from "react-native-reanimated";
|
|
4
|
+
export const createShiftTransition = ({
|
|
5
|
+
delayMs = 0,
|
|
6
|
+
durationMs,
|
|
7
|
+
easing,
|
|
8
|
+
fromOpacity,
|
|
9
|
+
toOpacity,
|
|
10
|
+
fromTranslateY,
|
|
11
|
+
toTranslateY,
|
|
12
|
+
fromScale,
|
|
13
|
+
toScale
|
|
14
|
+
}) => {
|
|
15
|
+
return () => {
|
|
16
|
+
"worklet";
|
|
17
|
+
|
|
18
|
+
// drive opacity and transforms from one timing path
|
|
19
|
+
const animate = toValue => delayMs > 0 ? withDelay(delayMs, withTiming(toValue, {
|
|
20
|
+
duration: durationMs,
|
|
21
|
+
easing
|
|
22
|
+
})) : withTiming(toValue, {
|
|
23
|
+
duration: durationMs,
|
|
24
|
+
easing
|
|
25
|
+
});
|
|
26
|
+
const initialValues = {
|
|
27
|
+
opacity: fromOpacity,
|
|
28
|
+
transform: [{
|
|
29
|
+
translateY: fromTranslateY
|
|
30
|
+
}, {
|
|
31
|
+
scale: fromScale
|
|
32
|
+
}]
|
|
33
|
+
};
|
|
34
|
+
const animations = {
|
|
35
|
+
opacity: animate(toOpacity),
|
|
36
|
+
transform: [{
|
|
37
|
+
translateY: animate(toTranslateY)
|
|
38
|
+
}, {
|
|
39
|
+
scale: animate(toScale)
|
|
40
|
+
}]
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
initialValues: {
|
|
44
|
+
...initialValues
|
|
45
|
+
},
|
|
46
|
+
animations: {
|
|
47
|
+
...animations
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=entry-exit-builders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withDelay","withTiming","createShiftTransition","delayMs","durationMs","easing","fromOpacity","toOpacity","fromTranslateY","toTranslateY","fromScale","toScale","animate","toValue","duration","initialValues","opacity","transform","translateY","scale","animations"],"sourceRoot":"../../../src","sources":["motion/entry-exit-builders.ts"],"mappings":";;AAAA,SAGEA,SAAS,EACTC,UAAU,QACL,yBAAyB;AAchC,OAAO,MAAMC,qBAAqB,GAAGA,CAAC;EACpCC,OAAO,GAAG,CAAC;EACXC,UAAU;EACVC,MAAM;EACNC,WAAW;EACXC,SAAS;EACTC,cAAc;EACdC,YAAY;EACZC,SAAS;EACTC;AACgB,CAAC,KAAiC;EAClD,OAAO,MAAM;IACX,SAAS;;IAET;IACA,MAAMC,OAAO,GAAIC,OAAe,IAC9BV,OAAO,GAAG,CAAC,GACPH,SAAS,CACPG,OAAO,EACPF,UAAU,CAACY,OAAO,EAAE;MAClBC,QAAQ,EAAEV,UAAU;MACpBC;IACF,CAAC,CACH,CAAC,GACDJ,UAAU,CAACY,OAAO,EAAE;MAClBC,QAAQ,EAAEV,UAAU;MACpBC;IACF,CAAC,CAAC;IAER,MAAMU,aAAsC,GAAG;MAC7CC,OAAO,EAAEV,WAAW;MACpBW,SAAS,EAAE,CACT;QAAEC,UAAU,EAAEV;MAAe,CAAC,EAC9B;QAAEW,KAAK,EAAET;MAAU,CAAC;IAExB,CAAC;IAED,MAAMU,UAAmC,GAAG;MAC1CJ,OAAO,EAAEJ,OAAO,CAACL,SAAS,CAAC;MAC3BU,SAAS,EAAE,CACT;QAAEC,UAAU,EAAEN,OAAO,CAACH,YAAY;MAAE,CAAC,EACrC;QAAEU,KAAK,EAAEP,OAAO,CAACD,OAAO;MAAE,CAAC;IAE/B,CAAC;IAED,OAAO;MACLI,aAAa,EAAE;QACb,GAAGA;MACL,CAAC;MACDK,UAAU,EAAE;QACV,GAAGA;MACL;IACF,CAAC;EACH,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Easing, LinearTransition, withDelay, withSpring, withTiming } from "react-native-reanimated";
|
|
4
|
+
const DEFAULT_CURVE = [0.19, 1, 0.22, 1];
|
|
5
|
+
export const MOTION_PRESETS = {
|
|
6
|
+
default: {
|
|
7
|
+
duration: 0.38,
|
|
8
|
+
ease: DEFAULT_CURVE
|
|
9
|
+
},
|
|
10
|
+
smooth: {
|
|
11
|
+
type: "spring",
|
|
12
|
+
duration: 0.4,
|
|
13
|
+
bounce: 0
|
|
14
|
+
},
|
|
15
|
+
snappy: {
|
|
16
|
+
type: "spring",
|
|
17
|
+
duration: 0.35,
|
|
18
|
+
bounce: 0.15
|
|
19
|
+
},
|
|
20
|
+
bouncy: {
|
|
21
|
+
type: "spring",
|
|
22
|
+
duration: 0.5,
|
|
23
|
+
bounce: 0.3
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const toMilliseconds = seconds => Math.round(seconds * 1000);
|
|
27
|
+
const toDampingRatio = bounce => Math.max(0.55, Math.min(1, 1 - bounce));
|
|
28
|
+
const createOpacityTransition = (fromOpacity, toOpacity, durationMs, easing) => {
|
|
29
|
+
return () => {
|
|
30
|
+
"worklet";
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
initialValues: {
|
|
34
|
+
opacity: fromOpacity
|
|
35
|
+
},
|
|
36
|
+
animations: {
|
|
37
|
+
opacity: withTiming(toOpacity, {
|
|
38
|
+
duration: durationMs,
|
|
39
|
+
easing
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export const resolveMotionRecipe = (presetName = "default", durationOverride) => {
|
|
46
|
+
const preset = MOTION_PRESETS[presetName];
|
|
47
|
+
const durationMs = durationOverride ?? toMilliseconds(preset.duration);
|
|
48
|
+
if ("type" in preset && preset.type === "spring") {
|
|
49
|
+
const dampingRatio = toDampingRatio(preset.bounce);
|
|
50
|
+
const easing = Easing.bezier(...DEFAULT_CURVE);
|
|
51
|
+
return {
|
|
52
|
+
durationMs,
|
|
53
|
+
easing,
|
|
54
|
+
// keep layout on timing so width and reflow stay predictable
|
|
55
|
+
layoutTransition: LinearTransition.duration(durationMs).easing(easing.factory()),
|
|
56
|
+
enterTransition: createOpacityTransition(0, 1, durationMs, easing),
|
|
57
|
+
exitTransition: createOpacityTransition(1, 0, durationMs, easing),
|
|
58
|
+
driveNumber: (toValue, delayMs = 0) => {
|
|
59
|
+
const animation = withSpring(toValue, {
|
|
60
|
+
duration: durationMs,
|
|
61
|
+
dampingRatio,
|
|
62
|
+
overshootClamping: preset.bounce === 0
|
|
63
|
+
});
|
|
64
|
+
return delayMs > 0 ? withDelay(delayMs, animation) : animation;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const timingPreset = preset;
|
|
69
|
+
const [x1, y1, x2, y2] = timingPreset.ease;
|
|
70
|
+
const easing = Easing.bezier(x1, y1, x2, y2);
|
|
71
|
+
return {
|
|
72
|
+
durationMs,
|
|
73
|
+
easing,
|
|
74
|
+
layoutTransition: LinearTransition.duration(durationMs).easing(easing.factory()),
|
|
75
|
+
enterTransition: createOpacityTransition(0, 1, durationMs, easing),
|
|
76
|
+
exitTransition: createOpacityTransition(1, 0, durationMs, easing),
|
|
77
|
+
driveNumber: (toValue, delayMs = 0) => {
|
|
78
|
+
const animation = withTiming(toValue, {
|
|
79
|
+
duration: durationMs,
|
|
80
|
+
easing
|
|
81
|
+
});
|
|
82
|
+
return delayMs > 0 ? withDelay(delayMs, animation) : animation;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=preset-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Easing","LinearTransition","withDelay","withSpring","withTiming","DEFAULT_CURVE","MOTION_PRESETS","default","duration","ease","smooth","type","bounce","snappy","bouncy","toMilliseconds","seconds","Math","round","toDampingRatio","max","min","createOpacityTransition","fromOpacity","toOpacity","durationMs","easing","initialValues","opacity","animations","resolveMotionRecipe","presetName","durationOverride","preset","dampingRatio","bezier","layoutTransition","factory","enterTransition","exitTransition","driveNumber","toValue","delayMs","animation","overshootClamping","timingPreset","x1","y1","x2","y2"],"sourceRoot":"../../../src","sources":["motion/preset-map.ts"],"mappings":";;AAAA,SACEA,MAAM,EACNC,gBAAgB,EAGhBC,SAAS,EACTC,UA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AM;IACNU,gBAAgB,EAAEnC,gBAAgB,CAACO,QAAQ,CAACiB,UAAU,CAAC,CAACC,MAAM,CAC5DA,MAAM,CAACW,OAAO,CAAC,CACjB,CAAC;IACDC,eAAe,EAAEhB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAEG,UAAU,EAAEC,MAAM,CAAC;IAClEa,cAAc,EAAEjB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAEG,UAAU,EAAEC,MAAM,CAAC;IACjEc,WAAW,EAAEA,CAACC,OAAO,EAAEC,OAAO,GAAG,CAAC,KAAK;MACrC,MAAMC,SAAS,GAAGvC,UAAU,CAACqC,OAAO,EAAE;QACpCjC,QAAQ,EAAEiB,UAAU;QACpBC;MACF,CAAC,CAAC;MAEF,OAAOgB,OAAO,GAAG,CAAC,GAAGxC,SAAS,CAACwC,OAAO,EAAEC,SAAS,CAAC,GAAGA,SAAS;IAChE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import Animated from "react-native-reanimated";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const rowStyle = {
|
|
8
|
+
flexDirection: "row",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
alignSelf: "flex-start"
|
|
11
|
+
};
|
|
12
|
+
export const GlyphRun = /*#__PURE__*/React.memo(({
|
|
13
|
+
glyphs,
|
|
14
|
+
layoutTransition,
|
|
15
|
+
enterTransition,
|
|
16
|
+
exitTransition,
|
|
17
|
+
textStyle
|
|
18
|
+
}) => /*#__PURE__*/_jsx(View, {
|
|
19
|
+
style: rowStyle,
|
|
20
|
+
children: glyphs.map(glyph => /*#__PURE__*/_jsx(Animated.Text, {
|
|
21
|
+
layout: layoutTransition,
|
|
22
|
+
entering: enterTransition,
|
|
23
|
+
exiting: exitTransition,
|
|
24
|
+
style: textStyle,
|
|
25
|
+
children: glyph.value
|
|
26
|
+
}, glyph.id))
|
|
27
|
+
}));
|
|
28
|
+
GlyphRun.displayName = "GlyphRun";
|
|
29
|
+
//# sourceMappingURL=glyph-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","Animated","jsx","_jsx","rowStyle","flexDirection","alignItems","alignSelf","GlyphRun","memo","glyphs","layoutTransition","enterTransition","exitTransition","textStyle","style","children","map","glyph","Text","layout","entering","exiting","value","id","displayName"],"sourceRoot":"../../../src","sources":["view/glyph-run.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAyCC,IAAI,QAAQ,cAAc;AACnE,OAAOC,QAAQ,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO/C,MAAMC,QAAQ,GAAG;EACfC,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,OAAO,MAAMC,QAAQ,gBAAGT,KAAK,CAACU,IAAI,CAChC,CAAC;EACCC,MAAM;EACNC,gBAAgB;EAChBC,eAAe;EACfC,cAAc;EACdC;AAOD,CAAC,kBACEX,IAAA,CAACH,IAAI;EAACe,KAAK,EAAEX,QAAS;EAAAY,QAAA,EAEnBN,MAAM,CAACO,GAAG,CAAEC,KAAK,iBAChBf,IAAA,CAACF,QAAQ,CAACkB,IAAI;IAEZC,MAAM,EAAET,gBAAiB;IACzBU,QAAQ,EAAET,eAAgB;IAC1BU,OAAO,EAAET,cAAe;IACxBE,KAAK,EAAED,SAAU;IAAAE,QAAA,EAEhBE,KAAK,CAACK;EAAK,GANPL,KAAK,CAACM,EAOE,CAChB;AAAC,CACE,CAEZ,CAAC;AAEDhB,QAAQ,CAACiB,WAAW,GAAG,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import Animated from "react-native-reanimated";
|
|
6
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const shellStyle = {
|
|
8
|
+
position: "relative",
|
|
9
|
+
alignSelf: "flex-start"
|
|
10
|
+
};
|
|
11
|
+
const viewportStyle = {
|
|
12
|
+
alignSelf: "flex-start"
|
|
13
|
+
};
|
|
14
|
+
const measuredContentStyle = {
|
|
15
|
+
position: "absolute",
|
|
16
|
+
left: 0,
|
|
17
|
+
top: 0,
|
|
18
|
+
opacity: 0,
|
|
19
|
+
alignSelf: "flex-start",
|
|
20
|
+
flexShrink: 0
|
|
21
|
+
};
|
|
22
|
+
const clippedViewportStyle = {
|
|
23
|
+
overflow: "hidden"
|
|
24
|
+
};
|
|
25
|
+
const unclippedViewportStyle = {
|
|
26
|
+
overflow: "visible"
|
|
27
|
+
};
|
|
28
|
+
export const MorphViewport = /*#__PURE__*/React.memo(({
|
|
29
|
+
autoSize,
|
|
30
|
+
clipToBounds,
|
|
31
|
+
containerStyle,
|
|
32
|
+
animatedWidthStyle,
|
|
33
|
+
measurement,
|
|
34
|
+
children
|
|
35
|
+
}) => {
|
|
36
|
+
const resolvedViewportStyle = useMemo(() => [viewportStyle, clipToBounds ? clippedViewportStyle : unclippedViewportStyle], [clipToBounds]);
|
|
37
|
+
return /*#__PURE__*/_jsx(View, {
|
|
38
|
+
style: [shellStyle, containerStyle],
|
|
39
|
+
children: autoSize ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
40
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
41
|
+
accessibilityElementsHidden: true,
|
|
42
|
+
collapsable: false,
|
|
43
|
+
importantForAccessibility: "no-hide-descendants",
|
|
44
|
+
pointerEvents: "none",
|
|
45
|
+
style: measuredContentStyle,
|
|
46
|
+
children: measurement
|
|
47
|
+
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
48
|
+
style: [resolvedViewportStyle, animatedWidthStyle],
|
|
49
|
+
children: children
|
|
50
|
+
})]
|
|
51
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
52
|
+
style: resolvedViewportStyle,
|
|
53
|
+
children: children
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
MorphViewport.displayName = "MorphViewport";
|
|
58
|
+
//# sourceMappingURL=morph-viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","View","Animated","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","shellStyle","position","alignSelf","viewportStyle","measuredContentStyle","left","top","opacity","flexShrink","clippedViewportStyle","overflow","unclippedViewportStyle","MorphViewport","memo","autoSize","clipToBounds","containerStyle","animatedWidthStyle","measurement","children","resolvedViewportStyle","style","accessibilityElementsHidden","collapsable","importantForAccessibility","pointerEvents","displayName"],"sourceRoot":"../../../src","sources":["view/morph-viewport.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,QAAQ,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE/C,MAAMC,UAAU,GAAG;EACjBC,QAAQ,EAAE,UAAU;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,aAAa,GAAG;EACpBD,SAAS,EAAE;AACb,CAAU;AAEV,MAAME,oBAA+B,GAAG;EACtCH,QAAQ,EAAE,UAAU;EACpBI,IAAI,EAAE,CAAC;EACPC,GAAG,EAAE,CAAC;EACNC,OAAO,EAAE,CAAC;EACVL,SAAS,EAAE,YAAY;EACvBM,UAAU,EAAE;AACd,CAAC;AAED,MAAMC,oBAA+B,GAAG;EACtCC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,sBAAiC,GAAG;EACxCD,QAAQ,EAAE;AACZ,CAAC;AAWD,OAAO,MAAME,aAAa,gBAAGtB,KAAK,CAACuB,IAAI,CACrC,CAAC;EACCC,QAAQ;EACRC,YAAY;EACZC,cAAc;EACdC,kBAAkB;EAClBC,WAAW;EACXC;AACkB,CAAC,KAAK;EACxB,MAAMC,qBAAqB,GAAG7B,OAAO,CACnC,MAAM,CACJY,aAAa,EACbY,YAAY,GAAGN,oBAAoB,GAAGE,sBAAsB,CAC7D,EACD,CAACI,YAAY,CACf,CAAC;EAED,oBACEpB,IAAA,CAACH,IAAI;IAAC6B,KAAK,EAAE,CAACrB,UAAU,EAAEgB,cAAc,CAAE;IAAAG,QAAA,EACvCL,QAAQ,gBACPf,KAAA,CAAAF,SAAA;MAAAsB,QAAA,gBACExB,IAAA,CAACH,IAAI;QACH8B,2BAA2B;QAC3BC,WAAW,EAAE,KAAM;QACnBC,yBAAyB,EAAC,qBAAqB;QAC/CC,aAAa,EAAC,MAAM;QACpBJ,KAAK,EAAEjB,oBAAqB;QAAAe,QAAA,EAE3BD;MAAW,CACR,CAAC,eACPvB,IAAA,CAACF,QAAQ,CAACD,IAAI;QAAC6B,KAAK,EAAE,CAACD,qBAAqB,EAAEH,kBAAkB,CAAE;QAAAE,QAAA,EAC/DA;MAAQ,CACI,CAAC;IAAA,CAChB,CAAC,gBAEHxB,IAAA,CAACH,IAAI;MAAC6B,KAAK,EAAED,qBAAsB;MAAAD,QAAA,EAAEA;IAAQ,CAAO;EACrD,CACG,CAAC;AAEX,CACF,CAAC;AAEDP,aAAa,CAACc,WAAW,GAAG,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { Text } from "react-native";
|
|
5
|
+
import Animated from "react-native-reanimated";
|
|
6
|
+
import { isAsciiDigit } from "../model/display-units.js";
|
|
7
|
+
import { createShiftTransition } from "../motion/entry-exit-builders.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const laneStyle = {
|
|
10
|
+
position: "relative",
|
|
11
|
+
alignSelf: "flex-start"
|
|
12
|
+
};
|
|
13
|
+
const laneProbeStyle = {
|
|
14
|
+
opacity: 0
|
|
15
|
+
};
|
|
16
|
+
const laneTokenStyle = {
|
|
17
|
+
position: "absolute",
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0
|
|
20
|
+
};
|
|
21
|
+
export const NumberLane = /*#__PURE__*/React.memo(({
|
|
22
|
+
unit,
|
|
23
|
+
tokenKey,
|
|
24
|
+
isLead,
|
|
25
|
+
hasAnimated,
|
|
26
|
+
delayMs,
|
|
27
|
+
direction,
|
|
28
|
+
travelDistance,
|
|
29
|
+
motionRecipe,
|
|
30
|
+
textStyle
|
|
31
|
+
}) => {
|
|
32
|
+
const usesDigitTravel = isAsciiDigit(unit);
|
|
33
|
+
const verticalOffset = direction > 0 ? travelDistance : direction < 0 ? -travelDistance : 0;
|
|
34
|
+
const enterTransition = useMemo(() => createShiftTransition({
|
|
35
|
+
delayMs,
|
|
36
|
+
durationMs: motionRecipe.durationMs,
|
|
37
|
+
easing: motionRecipe.easing,
|
|
38
|
+
fromOpacity: 0,
|
|
39
|
+
toOpacity: 1,
|
|
40
|
+
fromTranslateY: usesDigitTravel ? verticalOffset : 0,
|
|
41
|
+
toTranslateY: 0,
|
|
42
|
+
fromScale: 0.6,
|
|
43
|
+
toScale: 1
|
|
44
|
+
}), [delayMs, motionRecipe.durationMs, motionRecipe.easing, usesDigitTravel, verticalOffset]);
|
|
45
|
+
const exitTransition = useMemo(() => createShiftTransition({
|
|
46
|
+
delayMs,
|
|
47
|
+
durationMs: motionRecipe.durationMs,
|
|
48
|
+
easing: motionRecipe.easing,
|
|
49
|
+
fromOpacity: 1,
|
|
50
|
+
toOpacity: 0,
|
|
51
|
+
fromTranslateY: 0,
|
|
52
|
+
toTranslateY: usesDigitTravel ? -verticalOffset : 0,
|
|
53
|
+
fromScale: 1,
|
|
54
|
+
toScale: 0.6
|
|
55
|
+
}), [delayMs, motionRecipe.durationMs, motionRecipe.easing, usesDigitTravel, verticalOffset]);
|
|
56
|
+
if (isLead) {
|
|
57
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
58
|
+
style: textStyle,
|
|
59
|
+
children: unit
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/_jsxs(Animated.View, {
|
|
63
|
+
layout: motionRecipe.layoutTransition,
|
|
64
|
+
entering: hasAnimated ? motionRecipe.enterTransition : undefined,
|
|
65
|
+
exiting: motionRecipe.exitTransition,
|
|
66
|
+
style: laneStyle,
|
|
67
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
68
|
+
style: [textStyle, laneProbeStyle],
|
|
69
|
+
children: unit
|
|
70
|
+
}), /*#__PURE__*/_jsx(Animated.Text, {
|
|
71
|
+
entering: hasAnimated ? enterTransition : undefined,
|
|
72
|
+
exiting: exitTransition,
|
|
73
|
+
style: [textStyle, laneTokenStyle],
|
|
74
|
+
children: unit
|
|
75
|
+
}, `token:${tokenKey}`)]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
NumberLane.displayName = "NumberLane";
|
|
79
|
+
//# sourceMappingURL=number-lane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","Text","Animated","isAsciiDigit","createShiftTransition","jsx","_jsx","jsxs","_jsxs","laneStyle","position","alignSelf","laneProbeStyle","opacity","laneTokenStyle","top","left","NumberLane","memo","unit","tokenKey","isLead","hasAnimated","delayMs","direction","travelDistance","motionRecipe","textStyle","usesDigitTravel","verticalOffset","enterTransition","durationMs","easing","fromOpacity","toOpacity","fromTranslateY","toTranslateY","fromScale","toScale","exitTransition","style","children","View","layout","layoutTransition","entering","undefined","exiting","displayName"],"sourceRoot":"../../../src","sources":["view/number-lane.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,IAAI,QAAwC,cAAc;AACnE,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,YAAY,QAAQ,2BAAwB;AACrD,SAASC,qBAAqB,QAAQ,kCAA+B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGtE,MAAMC,SAAS,GAAG;EAChBC,QAAQ,EAAE,UAAU;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,cAAc,GAAG;EACrBC,OAAO,EAAE;AACX,CAAU;AAEV,MAAMC,cAAc,GAAG;EACrBJ,QAAQ,EAAE,UAAU;EACpBK,GAAG,EAAE,CAAC;EACNC,IAAI,EAAE;AACR,CAAU;AAcV,OAAO,MAAMC,UAAU,gBAAGlB,KAAK,CAACmB,IAAI,CAClC,CAAC;EACCC,IAAI;EACJC,QAAQ;EACRC,MAAM;EACNC,WAAW;EACXC,OAAO;EACPC,SAAS;EACTC,cAAc;EACdC,YAAY;EACZC;AACe,CAAC,KAAK;EACrB,MAAMC,eAAe,GAAGzB,YAAY,CAACgB,IAAI,CAAC;EAC1C,MAAMU,cAAc,GAClBL,SAAS,GAAG,CAAC,GACTC,cAAc,GACdD,SAAS,GAAG,CAAC,GACX,CAACC,cAAc,GACf,CAAC;EAET,MAAMK,eAAe,GAAG9B,OAAO,CAC7B,MACEI,qBAAqB,CAAC;IACpBmB,OAAO;IACPQ,UAAU,EAAEL,YAAY,CAACK,UAAU;IACnCC,MAAM,EAAEN,YAAY,CAACM,MAAM;IAC3BC,WAAW,EAAE,CAAC;IACdC,SAAS,EAAE,CAAC;IACZC,cAAc,EAAEP,eAAe,GAAGC,cAAc,GAAG,CAAC;IACpDO,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE,GAAG;IACdC,OAA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