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
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Laminar
|
|
2
|
+
|
|
3
|
+
React Native morphing text and number animation.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Laminar } from "react-native-laminar";
|
|
7
|
+
|
|
8
|
+
<Laminar text="$1,234.56" variant="number" />;
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package source lives in `src`. The demo app in the repository imports from the package boundary instead of package internals.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDisplayUnits = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _displayUnits = require("../model/display-units");
|
|
9
|
+
const useDisplayUnits = (value, enabled = true) => (0, _react.useMemo)(() =>
|
|
10
|
+
// skip unit work when auto size is off
|
|
11
|
+
enabled ? (0, _displayUnits.splitDisplayUnits)(value).map(_displayUnits.normalizeDisplayUnit) : [], [enabled, value]);
|
|
12
|
+
exports.useDisplayUnits = useDisplayUnits;
|
|
13
|
+
//# sourceMappingURL=use-display-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_displayUnits","useDisplayUnits","value","enabled","useMemo","splitDisplayUnits","map","normalizeDisplayUnit","exports"],"sourceRoot":"../../../src","sources":["hooks/use-display-units.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKO,MAAME,eAAe,GAAGA,CAC7BC,KAAa,EACbC,OAAO,GAAG,IAAI,KAEd,IAAAC,cAAO,EACL;AACE;AACAD,OAAO,GACH,IAAAE,+BAAiB,EAACH,KAAK,CAAC,CAACI,GAAG,CAACC,kCAAoB,CAAC,GAClD,EAAE,EACR,CAACJ,OAAO,EAAED,KAAK,CACjB,CAAC;AAACM,OAAA,CAAAP,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useInlineAutoWidth = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
const useInlineAutoWidth = ({
|
|
10
|
+
enabled,
|
|
11
|
+
driveToWidth
|
|
12
|
+
}) => {
|
|
13
|
+
const widthValue = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
14
|
+
const measuredWidthRef = (0, _react.useRef)(null);
|
|
15
|
+
const bootstrappedRef = (0, _react.useRef)(false);
|
|
16
|
+
const [hasBootstrappedWidth, setHasBootstrappedWidth] = (0, _react.useState)(false);
|
|
17
|
+
const captureLayout = (0, _react.useCallback)(event => {
|
|
18
|
+
if (!enabled) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
|
|
22
|
+
if (measuredWidthRef.current === nextWidth) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
measuredWidthRef.current = nextWidth;
|
|
26
|
+
|
|
27
|
+
// snap the first width so mount does not animate from zero
|
|
28
|
+
if (!bootstrappedRef.current) {
|
|
29
|
+
bootstrappedRef.current = true;
|
|
30
|
+
widthValue.value = nextWidth;
|
|
31
|
+
setHasBootstrappedWidth(true);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
widthValue.value = driveToWidth(nextWidth);
|
|
35
|
+
}, [driveToWidth, enabled, widthValue]);
|
|
36
|
+
const animatedWidthStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => enabled && hasBootstrappedWidth ? {
|
|
37
|
+
width: widthValue.value
|
|
38
|
+
} : {}, [enabled, hasBootstrappedWidth]);
|
|
39
|
+
return {
|
|
40
|
+
captureLayout,
|
|
41
|
+
animatedWidthStyle
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.useInlineAutoWidth = useInlineAutoWidth;
|
|
45
|
+
//# sourceMappingURL=use-inline-auto-width.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeReanimated","useInlineAutoWidth","enabled","driveToWidth","widthValue","useSharedValue","measuredWidthRef","useRef","bootstrappedRef","hasBootstrappedWidth","setHasBootstrappedWidth","useState","captureLayout","useCallback","event","nextWidth","Math","max","ceil","nativeEvent","layout","width","current","value","animatedWidthStyle","useAnimatedStyle","exports"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AAOO,MAAME,kBAAkB,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAqB,CAAC,KAAK;EACvE,MAAMC,UAAU,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EACpC,MAAMC,gBAAgB,GAAG,IAAAC,aAAM,EAAgB,IAAI,CAAC;EACpD,MAAMC,eAAe,GAAG,IAAAD,aAAM,EAAC,KAAK,CAAC;EACrC,MAAM,CAACE,oBAAoB,EAAEC,uBAAuB,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAEvE,MAAMC,aAAa,GAAG,IAAAC,kBAAW,EAC9BC,KAAwB,IAAK;IAC5B,IAAI,CAACZ,OAAO,EAAE;MACZ;IACF;IAEA,MAAMa,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,IAAI,CAACJ,KAAK,CAACK,WAAW,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC;IAExE,IAAIf,gBAAgB,CAACgB,OAAO,KAAKP,SAAS,EAAE;MAC1C;IACF;IAEAT,gBAAgB,CAACgB,OAAO,GAAGP,SAAS;;IAEpC;IACA,IAAI,CAACP,eAAe,CAACc,OAAO,EAAE;MAC5Bd,eAAe,CAACc,OAAO,GAAG,IAAI;MAC9BlB,UAAU,CAACmB,KAAK,GAAGR,SAAS;MAC5BL,uBAAuB,CAAC,IAAI,CAAC;MAC7B;IACF;IAEAN,UAAU,CAACmB,KAAK,GAAGpB,YAAY,CAACY,SAAS,CAAC;EAC5C,CAAC,EACD,CAACZ,YAAY,EAAED,OAAO,EAAEE,UAAU,CACpC,CAAC;EAED,MAAMoB,kBAAkB,GAAG,IAAAC,uCAAgB,EACzC,MACEvB,OAAO,IAAIO,oBAAoB,GAC3B;IACEY,KAAK,EAAEjB,UAAU,CAACmB;EACpB,CAAC,GACD,CAAC,CAAC,EACR,CAACrB,OAAO,EAAEO,oBAAoB,CAChC,CAAC;EAED,OAAO;IACLG,aAAa;IACbY;EACF,CAAC;AACH,CAAC;AAACE,OAAA,CAAAzB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMorphMotion = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _presetMap = require("../motion/preset-map");
|
|
9
|
+
const useMorphMotion = ({
|
|
10
|
+
variant,
|
|
11
|
+
animationPreset,
|
|
12
|
+
animationDuration,
|
|
13
|
+
stagger
|
|
14
|
+
}) => {
|
|
15
|
+
// numbers feel better with snappy unless you pick something else
|
|
16
|
+
const resolvedPreset = animationPreset ?? (variant === "text" ? "default" : "snappy");
|
|
17
|
+
const motionRecipe = (0, _react.useMemo)(() => (0, _presetMap.resolveMotionRecipe)(resolvedPreset, animationDuration), [animationDuration, resolvedPreset]);
|
|
18
|
+
return {
|
|
19
|
+
motionRecipe,
|
|
20
|
+
staggerMs: Math.round(stagger * 1000)
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.useMorphMotion = useMorphMotion;
|
|
24
|
+
//# sourceMappingURL=use-morph-motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_presetMap","useMorphMotion","variant","animationPreset","animationDuration","stagger","resolvedPreset","motionRecipe","useMemo","resolveMotionRecipe","staggerMs","Math","round","exports"],"sourceRoot":"../../../src","sources":["hooks/use-morph-motion.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAmBO,MAAME,cAAc,GAAGA,CAAC;EAC7BC,OAAO;EACPC,eAAe;EACfC,iBAAiB;EACjBC;AACM,CAAC,KAAkB;EACzB;EACA,MAAMC,cAAc,GAClBH,eAAe,KAAKD,OAAO,KAAK,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;EAEhE,MAAMK,YAAY,GAAG,IAAAC,cAAO,EAC1B,MAAM,IAAAC,8BAAmB,EAACH,cAAc,EAAEF,iBAAiB,CAAC,EAC5D,CAACA,iBAAiB,EAAEE,cAAc,CACpC,CAAC;EAED,OAAO;IACLC,YAAY;IACZG,SAAS,EAAEC,IAAI,CAACC,KAAK,CAACP,OAAO,GAAG,IAAI;EACtC,CAAC;AACH,CAAC;AAACQ,OAAA,CAAAZ,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMorphTextStyle = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const useMorphTextStyle = ({
|
|
9
|
+
fontSize,
|
|
10
|
+
color,
|
|
11
|
+
fontStyle,
|
|
12
|
+
style
|
|
13
|
+
}) => {
|
|
14
|
+
const baseTextStyle = (0, _react.useMemo)(() => {
|
|
15
|
+
const nextStyle = {
|
|
16
|
+
includeFontPadding: false
|
|
17
|
+
};
|
|
18
|
+
if (fontSize !== undefined) {
|
|
19
|
+
nextStyle.fontSize = fontSize;
|
|
20
|
+
}
|
|
21
|
+
if (color !== undefined) {
|
|
22
|
+
nextStyle.color = color;
|
|
23
|
+
}
|
|
24
|
+
return nextStyle;
|
|
25
|
+
}, [color, fontSize]);
|
|
26
|
+
const textStyle = (0, _react.useMemo)(() => [baseTextStyle, fontStyle, style], [baseTextStyle, fontStyle, style]);
|
|
27
|
+
return {
|
|
28
|
+
textStyle
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.useMorphTextStyle = useMorphTextStyle;
|
|
32
|
+
//# sourceMappingURL=use-morph-text-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","useMorphTextStyle","fontSize","color","fontStyle","style","baseTextStyle","useMemo","nextStyle","includeFontPadding","undefined","textStyle","exports"],"sourceRoot":"../../../src","sources":["hooks/use-morph-text-style.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAcO,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC;AACM,CAAC,KAAqB;EAC5B,MAAMC,aAAa,GAAG,IAAAC,cAAO,EAAC,MAAM;IAClC,MAAMC,SAAoB,GAAG;MAC3BC,kBAAkB,EAAE;IACtB,CAAC;IAED,IAAIP,QAAQ,KAAKQ,SAAS,EAAE;MAC1BF,SAAS,CAACN,QAAQ,GAAGA,QAAQ;IAC/B;IAEA,IAAIC,KAAK,KAAKO,SAAS,EAAE;MACvBF,SAAS,CAACL,KAAK,GAAGA,KAAK;IACzB;IAEA,OAAOK,SAAS;EAClB,CAAC,EAAE,CAACL,KAAK,EAAED,QAAQ,CAAC,CAAC;EAErB,MAAMS,SAAS,GAAG,IAAAJ,cAAO,EACvB,MAAM,CAACD,aAAa,EAAEF,SAAS,EAAEC,KAAK,CAAC,EACvC,CAACC,aAAa,EAAEF,SAAS,EAAEC,KAAK,CAClC,CAAC;EAED,OAAO;IACLM;EACF,CAAC;AACH,CAAC;AAACC,OAAA,CAAAX,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useNumericLanes = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _displayUnits = require("../model/display-units");
|
|
9
|
+
var _numericLanes = require("../model/numeric-lanes");
|
|
10
|
+
const useNumericLanes = value => {
|
|
11
|
+
const units = (0, _react.useMemo)(() => (0, _displayUnits.splitDisplayUnits)(value), [value]);
|
|
12
|
+
const ledgerRef = (0, _react.useRef)({
|
|
13
|
+
previousValue: value,
|
|
14
|
+
laneKeys: units.map((_, index) => index),
|
|
15
|
+
nextSeed: units.length,
|
|
16
|
+
direction: 0
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// keep lane ids in a ref so the number can reflow without remounting everything
|
|
20
|
+
if (value !== ledgerRef.current.previousValue) {
|
|
21
|
+
const nextLedger = (0, _numericLanes.reconcileNumericLanes)(ledgerRef.current.previousValue, value, ledgerRef.current.laneKeys, ledgerRef.current.nextSeed);
|
|
22
|
+
ledgerRef.current = {
|
|
23
|
+
previousValue: value,
|
|
24
|
+
laneKeys: nextLedger.laneKeys,
|
|
25
|
+
nextSeed: nextLedger.nextSeed,
|
|
26
|
+
direction: nextLedger.direction
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
units,
|
|
31
|
+
laneKeys: ledgerRef.current.laneKeys,
|
|
32
|
+
direction: ledgerRef.current.direction,
|
|
33
|
+
leadLength: (0, _displayUnits.findNumericLeadLength)(units)
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.useNumericLanes = useNumericLanes;
|
|
37
|
+
//# sourceMappingURL=use-numeric-lanes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_displayUnits","_numericLanes","useNumericLanes","value","units","useMemo","splitDisplayUnits","ledgerRef","useRef","previousValue","laneKeys","map","_","index","nextSeed","length","direction","current","nextLedger","reconcileNumericLanes","leadLength","findNumericLeadLength","exports"],"sourceRoot":"../../../src","sources":["hooks/use-numeric-lanes.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD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
|
|
5
|
+
});
|
|
6
|
+
exports.useTextGlyphs = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _displayUnits = require("../model/display-units");
|
|
9
|
+
var _textKeys = require("../model/text-keys");
|
|
10
|
+
const useTextGlyphs = (value, namespace) => {
|
|
11
|
+
const units = (0, _react.useMemo)(() => (0, _displayUnits.splitDisplayUnits)(value), [value]);
|
|
12
|
+
const ledgerRef = (0, _react.useRef)({
|
|
13
|
+
previousValue: value,
|
|
14
|
+
previousUnits: units,
|
|
15
|
+
glyphKeys: units.map((_, index) => `${namespace}:c${index}`),
|
|
16
|
+
nextSeed: units.length
|
|
17
|
+
});
|
|
18
|
+
if (value !== ledgerRef.current.previousValue) {
|
|
19
|
+
// keep ids stable so unchanged glyphs stay mounted between updates
|
|
20
|
+
const nextLedger = (0, _textKeys.reconcileTextGlyphKeys)(ledgerRef.current.previousUnits, units, ledgerRef.current.glyphKeys, ledgerRef.current.nextSeed, namespace);
|
|
21
|
+
ledgerRef.current = {
|
|
22
|
+
previousValue: value,
|
|
23
|
+
previousUnits: units,
|
|
24
|
+
glyphKeys: nextLedger.glyphKeys,
|
|
25
|
+
nextSeed: nextLedger.nextSeed
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const glyphKeys = ledgerRef.current.glyphKeys;
|
|
29
|
+
return (0, _react.useMemo)(() => units.map((unit, index) => ({
|
|
30
|
+
id: glyphKeys[index],
|
|
31
|
+
value: (0, _displayUnits.normalizeDisplayUnit)(unit)
|
|
32
|
+
})), [glyphKeys, units]);
|
|
33
|
+
};
|
|
34
|
+
exports.useTextGlyphs = useTextGlyphs;
|
|
35
|
+
//# sourceMappingURL=use-text-glyphs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_displayUnits","_textKeys","useTextGlyphs","value","namespace","units","useMemo","splitDisplayUnits","ledgerRef","useRef","previousValue","previousUnits","glyphKeys","map","_","index","nextSeed","length","current","nextLedger","reconcileTextG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,EAAEV,SAAS,CAACG,KAAK,CAAC;IACpBZ,KAAK,EAAE,IAAAoB,kCAAoB,EAACF,IAAI;EAClC,CAAC,CAAC,CAAC,EACL,CAACT,SAAS,EAAEP,KAAK,CACnB,CAAC;AACH,CAAC;AAACmB,OAAA,CAAAtB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.MorphingText = exports.Laminar = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _useInlineAutoWidth = require("./hooks/use-inline-auto-width");
|
|
10
|
+
var _useMorphMotion = require("./hooks/use-morph-motion");
|
|
11
|
+
var _useMorphTextStyle = require("./hooks/use-morph-text-style");
|
|
12
|
+
var _displayUnits = require("./model/display-units");
|
|
13
|
+
var _morphViewport = require("./view/morph-viewport");
|
|
14
|
+
var _numberRun = require("./view/number-run");
|
|
15
|
+
var _textRun = require("./view/text-run");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Laminar({
|
|
19
|
+
text,
|
|
20
|
+
variant = "text",
|
|
21
|
+
fontSize,
|
|
22
|
+
color,
|
|
23
|
+
style,
|
|
24
|
+
containerStyle,
|
|
25
|
+
fontStyle,
|
|
26
|
+
animationDuration,
|
|
27
|
+
animationPreset,
|
|
28
|
+
stagger = 0.02,
|
|
29
|
+
autoSize = true,
|
|
30
|
+
clipToBounds = false
|
|
31
|
+
}) {
|
|
32
|
+
const resolvedValue = String(text ?? "");
|
|
33
|
+
const {
|
|
34
|
+
motionRecipe,
|
|
35
|
+
staggerMs
|
|
36
|
+
} = (0, _useMorphMotion.useMorphMotion)({
|
|
37
|
+
variant,
|
|
38
|
+
animationPreset,
|
|
39
|
+
animationDuration,
|
|
40
|
+
stagger
|
|
41
|
+
});
|
|
42
|
+
const {
|
|
43
|
+
textStyle
|
|
44
|
+
} = (0, _useMorphTextStyle.useMorphTextStyle)({
|
|
45
|
+
fontSize,
|
|
46
|
+
color,
|
|
47
|
+
fontStyle,
|
|
48
|
+
style
|
|
49
|
+
});
|
|
50
|
+
const {
|
|
51
|
+
captureLayout,
|
|
52
|
+
animatedWidthStyle
|
|
53
|
+
} = (0, _useInlineAutoWidth.useInlineAutoWidth)({
|
|
54
|
+
enabled: autoSize,
|
|
55
|
+
driveToWidth: motionRecipe.driveNumber
|
|
56
|
+
});
|
|
57
|
+
const measuredValue = _react.default.useMemo(() => {
|
|
58
|
+
if (!autoSize) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
return (0, _displayUnits.splitDisplayUnits)(resolvedValue).map(_displayUnits.normalizeDisplayUnit).join("");
|
|
62
|
+
}, [autoSize, resolvedValue]);
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_morphViewport.MorphViewport, {
|
|
64
|
+
autoSize: autoSize,
|
|
65
|
+
clipToBounds: clipToBounds,
|
|
66
|
+
containerStyle: containerStyle,
|
|
67
|
+
animatedWidthStyle: animatedWidthStyle,
|
|
68
|
+
measurement: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
69
|
+
numberOfLines: 1,
|
|
70
|
+
onLayout: captureLayout,
|
|
71
|
+
style: textStyle,
|
|
72
|
+
children: measuredValue
|
|
73
|
+
}),
|
|
74
|
+
children: variant === "number" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_numberRun.NumberRun, {
|
|
75
|
+
value: resolvedValue,
|
|
76
|
+
motionRecipe: motionRecipe,
|
|
77
|
+
fontSize: fontSize,
|
|
78
|
+
textStyle: textStyle,
|
|
79
|
+
staggerMs: staggerMs
|
|
80
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_textRun.TextRun, {
|
|
81
|
+
value: resolvedValue,
|
|
82
|
+
motionRecipe: motionRecipe,
|
|
83
|
+
textStyle: textStyle
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
const MorphingText = exports.MorphingText = Laminar;
|
|
88
|
+
var _default = exports.default = Laminar;
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_useInlineAutoWidth","_useMorphMotion","_useMorphTextStyle","_displayUnits","_morphViewport","_numberRun","_textRun","_jsxRuntime","e","__esModule","default","Laminar","exports","React","memo","text","variant","fontSize","color","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","motionRecipe","staggerMs","useMorphMotion","textStyle","useMorphTextStyle","captureLayout","animatedWidthStyle","useInlineAutoWidth","enabled","driveToWidth","driveNumber","measuredValue","useMemo","splitDisplayUnits","map","normalizeDisplayUnit","join","jsx","MorphViewport","measurement","Text","numberOfLines","onLayout","children","NumberRun","value","TextRun","MorphingText","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAKA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAA0C,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAD,uBAAAW,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEn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AAEA,kBAAmB;IACvCa,WAAW,eACT,IAAAzC,WAAA,CAAAuC,GAAA,EAAC/C,YAAA,CAAAkD,IAAI;MACHC,aAAa,EAAE,CAAE;MACjBC,QAAQ,EAAEjB,aAAc;MACxBf,KAAK,EAAEa,SAAU;MAAAoB,QAAA,EAEhBZ;IAAa,CACV,CACP;IAAAY,QAAA,EAEApC,OAAO,KAAK,QAAQ,gBACnB,IAAAT,WAAA,CAAAuC,GAAA,EAACzC,UAAA,CAAAgD,SAAS;MACRC,KAAK,EAAE3B,aAAc;MACrBE,YAAY,EAAEA,YAAa;MAC3BZ,QAAQ,EAAEA,QAAS;MACnBe,SAAS,EAAEA,SAAU;MACrBF,SAAS,EAAEA;IAAU,CACtB,CAAC,gBAEF,IAAAvB,WAAA,CAAAuC,GAAA,EAACxC,QAAA,CAAAiD,OAAO;MACND,KAAK,EAAE3B,aAAc;MACrBE,YAAY,EAAEA,YAAa;MAC3BG,SAAS,EAAEA;IAAU,CACtB;EACJ,CACY,CAAC;AAElB,CAAC,CAAC;AAEG,MAAMwB,YAAY,GAAA5C,OAAA,CAAA4C,YAAA,GAAG7C,OAAO;AAAC,IAAA8C,QAAA,GAAA7C,OAAA,CAAAF,OAAA,GAErBC,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.splitDisplayUnits = exports.normalizeDisplayUnit = exports.isAsciiDigit = exports.findNumericLeadLength = void 0;
|
|
7
|
+
const NBSP = "\u00A0";
|
|
8
|
+
const graphemeSegmenter = typeof Intl !== "undefined" && typeof Intl.Segmenter === "function" ? new Intl.Segmenter(undefined, {
|
|
9
|
+
granularity: "grapheme"
|
|
10
|
+
}) : null;
|
|
11
|
+
const splitDisplayUnits = input => {
|
|
12
|
+
if (graphemeSegmenter) {
|
|
13
|
+
return Array.from(graphemeSegmenter.segment(input), part => part.segment);
|
|
14
|
+
}
|
|
15
|
+
return Array.from(input);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// swap plain spaces so measured text keeps its width
|
|
19
|
+
exports.splitDisplayUnits = splitDisplayUnits;
|
|
20
|
+
const normalizeDisplayUnit = unit => unit === " " ? NBSP : unit;
|
|
21
|
+
exports.normalizeDisplayUnit = normalizeDisplayUnit;
|
|
22
|
+
const isAsciiDigit = unit => unit >= "0" && unit <= "9";
|
|
23
|
+
exports.isAsciiDigit = isAsciiDigit;
|
|
24
|
+
const findNumericLeadLength = units => {
|
|
25
|
+
const firstDigitIndex = units.findIndex(isAsciiDigit);
|
|
26
|
+
return firstDigitIndex === -1 ? units.length : firstDigitIndex;
|
|
27
|
+
};
|
|
28
|
+
exports.findNumericLeadLength = findNumericLeadLength;
|
|
29
|
+
//# sourceMappingURL=display-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NBSP","graphemeSegmenter","Intl","Segmenter","undefined","granularity","splitDisplayUnits","input","Array","from","segment","part","exports","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;AAEH,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;AAAAK,OAAA,CAAAN,iBAAA,GAAAA,iBAAA;AACO,MAAMO,oBAAoB,GAAIC,IAAY,IAC/CA,IAAI,KAAK,GAAG,GAAGd,IAAI,GAAGc,IAAI;AAACF,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AAEtB,MAAME,YAAY,GAAID,IAAY,IAAKA,IAAI,IAAI,GAAG,IAAIA,IAAI,IAAI,GAAG;AAACF,OAAA,CAAAG,YAAA,GAAAA,YAAA;AAElE,MAAMC,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;AAACN,OAAA,CAAAI,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reconcileNumericLanes = void 0;
|
|
7
|
+
var _displayUnits = require("./display-units");
|
|
8
|
+
const readNumericMagnitude = input => parseFloat(input.replace(/[^0-9.-]/g, "")) || 0;
|
|
9
|
+
const deriveFlowDirection = (previousValue, nextValue) => Math.sign(readNumericMagnitude(nextValue) - readNumericMagnitude(previousValue));
|
|
10
|
+
const reconcileNumericLanes = (previousValue, nextValue, previousKeys, seed) => {
|
|
11
|
+
const previousUnits = (0, _displayUnits.splitDisplayUnits)(previousValue);
|
|
12
|
+
const nextUnits = (0, _displayUnits.splitDisplayUnits)(nextValue);
|
|
13
|
+
const nextLaneKeys = new Array(nextUnits.length);
|
|
14
|
+
let nextSeed = seed;
|
|
15
|
+
const nextLeadLength = (0, _displayUnits.findNumericLeadLength)(nextUnits);
|
|
16
|
+
const previousLeadLength = (0, _displayUnits.findNumericLeadLength)(previousUnits);
|
|
17
|
+
const sharedLeadLength = Math.min(nextLeadLength, previousLeadLength);
|
|
18
|
+
for (let index = 0; index < nextLeadLength; index += 1) {
|
|
19
|
+
nextLaneKeys[index] = index < sharedLeadLength && nextUnits[index] === previousUnits[index] ? previousKeys[index] : nextSeed++;
|
|
20
|
+
}
|
|
21
|
+
const previousTailUnits = previousUnits.slice(previousLeadLength);
|
|
22
|
+
const nextTailUnits = nextUnits.slice(nextLeadLength);
|
|
23
|
+
const previousTailKeys = previousKeys.slice(previousLeadLength);
|
|
24
|
+
const laneCount = Math.max(previousTailUnits.length, nextTailUnits.length);
|
|
25
|
+
const leftPaddedPreviousUnits = [...Array(Math.max(0, laneCount - previousTailUnits.length)).fill(""), ...previousTailUnits];
|
|
26
|
+
const leftPaddedNextUnits = [...Array(Math.max(0, laneCount - nextTailUnits.length)).fill(""), ...nextTailUnits];
|
|
27
|
+
const leftPaddedPreviousKeys = [...Array(Math.max(0, laneCount - previousTailKeys.length)).fill(-1), ...previousTailKeys];
|
|
28
|
+
|
|
29
|
+
// pad from the left so the rightmost digits keep their place value lanes
|
|
30
|
+
const nextTailOffset = laneCount - nextTailUnits.length;
|
|
31
|
+
for (let index = 0; index < nextTailUnits.length; index += 1) {
|
|
32
|
+
const paddedIndex = nextTailOffset + index;
|
|
33
|
+
const nextUnit = leftPaddedNextUnits[paddedIndex];
|
|
34
|
+
const previousUnit = leftPaddedPreviousUnits[paddedIndex];
|
|
35
|
+
const previousKey = leftPaddedPreviousKeys[paddedIndex];
|
|
36
|
+
nextLaneKeys[nextLeadLength + index] = nextUnit === previousUnit && previousKey >= 0 ? previousKey : nextSeed++;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
laneKeys: nextLaneKeys,
|
|
40
|
+
nextSeed,
|
|
41
|
+
direction: deriveFlowDirection(previousValue, nextValue)
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.reconcileNumericLanes = reconcileNumericLanes;
|
|
45
|
+
//# sourceMappingURL=numeric-lanes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_displayUnits","require","readNumericMagnitude","input","parseFloat","replace","deriveFlowDirection","previousValue","nextValue","Math","sign","reconcileNumericLanes","previousKeys","seed","previousUnits","splitDisplayUnits","nextUnits","nextLaneKeys","Array","length","nextSeed","nextLeadLength","findNumericLeadLength","previousLeadLength","sharedLeadLength","min","index","previousTailUnits","slice","nextTailUnits","previousTailKeys","laneCount","max","leftPaddedPreviousUnits","fill","leftPaddedNextUnits","leftPaddedPreviousKeys","nextTailOffset","paddedIndex","nextUnit","previousUnit","previousKey","laneKeys","direction","exports"],"sourceRoot":"../../../src","sources":["model/numeric-lanes.ts"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAKA,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,CAACC,IAAI,CAACR,oBAAoB,CAACM,SAAS,CAAC,GAAGN,oBAAoB,CAACK,aAAa,CAAC,CAAyB;AAQnG,MAAMI,qBAAqB,GAAGA,CACnCJ,aAAqB,EACrBC,SAAiB,EACjBI,YAA+B,EAC/BC,IAAY,KACY;EACxB,MAAMC,aAAa,GAAG,IAAAC,+BAAiB,EAACR,aAAa,CAAC;EACtD,MAAMS,SAAS,GAAG,IAAAD,+BAAiB,EAACP,SAAS,CAAC;EAC9C,MAAMS,YAAY,GAAG,IAAIC,KAAK,CAACF,SAAS,CAACG,MAAM,CAAC;EAChD,IAAIC,QAAQ,GAAGP,IAAI;EAEnB,MAAMQ,cAAc,GAAG,IAAAC,mCAAqB,EAACN,SAAS,CAAC;EACvD,MAAMO,kBAAkB,GAAG,IAAAD,mCAAqB,EAACR,aAAa,CAAC;EAC/D,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AAGJ,gBAAgB,CACpB;;EAED;EACA,MAAMO,cAAc,GAAGN,SAAS,GAAGF,aAAa,CAACV,MAAM;EAEvD,KAAK,IAAIO,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGG,aAAa,CAACV,MAAM,EAAEO,KAAK,IAAI,CAAC,EAAE;IAC5D,MAAMY,WAAW,GAAGD,cAAc,GAAGX,KAAK;IAC1C,MAAMa,QAAQ,GAAGJ,mBAAmB,CAACG,WAAW,CAAC;IACjD,MAAME,YAAY,GAAGP,uBAAuB,CAACK,WAAW,CAAC;IACzD,MAAMG,WAAW,GAAGL,sBAAsB,CAACE,WAAW,CAAC;IAEvDrB,YAAY,CAACI,cAAc,GAAGK,KAAK,CAAC,GAClCa,QAAQ,KAAKC,YAAY,IAAIC,WAAW,IAAI,CAAC,GAAGA,WAAW,GAAGrB,QAAQ,EAAE;EAC5E;EAEA,OAAO;IACLsB,QAAQ,EAAEzB,YAAY;IACtBG,QAAQ;IACRuB,SAAS,EAAErC,mBAAmB,CAACC,aAAa,EAAEC,SAAS;EACzD,CAAC;AACH,CAAC;AAACoC,OAAA,CAAAjC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reconcileTextGlyphKeys = void 0;
|
|
7
|
+
const computeLcsPairs = (previousUnits, nextUnits) => {
|
|
8
|
+
const previousLength = previousUnits.length;
|
|
9
|
+
const nextLength = nextUnits.length;
|
|
10
|
+
if (previousLength === 0 || nextLength === 0) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const dp = Array.from({
|
|
14
|
+
length: previousLength + 1
|
|
15
|
+
}, () => new Array(nextLength + 1).fill(0));
|
|
16
|
+
for (let previousIndex = 1; previousIndex <= previousLength; previousIndex += 1) {
|
|
17
|
+
for (let nextIndex = 1; nextIndex <= nextLength; nextIndex += 1) {
|
|
18
|
+
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]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const pairs = [];
|
|
22
|
+
let previousIndex = previousLength;
|
|
23
|
+
let nextIndex = nextLength;
|
|
24
|
+
while (previousIndex > 0 && nextIndex > 0) {
|
|
25
|
+
if (previousUnits[previousIndex - 1] === nextUnits[nextIndex - 1]) {
|
|
26
|
+
pairs.push([previousIndex - 1, nextIndex - 1]);
|
|
27
|
+
previousIndex -= 1;
|
|
28
|
+
nextIndex -= 1;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (dp[previousIndex - 1][nextIndex] > dp[previousIndex][nextIndex - 1] || dp[previousIndex - 1][nextIndex] === dp[previousIndex][nextIndex - 1] && previousIndex >= nextIndex) {
|
|
32
|
+
previousIndex -= 1;
|
|
33
|
+
} else {
|
|
34
|
+
nextIndex -= 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
pairs.reverse();
|
|
38
|
+
return pairs;
|
|
39
|
+
};
|
|
40
|
+
const reconcileTextGlyphKeys = (previousUnits, nextUnits, previousKeys, seed, namespace) => {
|
|
41
|
+
const previousLength = previousUnits.length;
|
|
42
|
+
const nextLength = nextUnits.length;
|
|
43
|
+
const nextGlyphKeys = new Array(nextUnits.length).fill("");
|
|
44
|
+
let nextSeed = seed;
|
|
45
|
+
let sharedPrefixLength = 0;
|
|
46
|
+
while (sharedPrefixLength < previousLength && sharedPrefixLength < nextLength && previousUnits[sharedPrefixLength] === nextUnits[sharedPrefixLength]) {
|
|
47
|
+
nextGlyphKeys[sharedPrefixLength] = previousKeys[sharedPrefixLength] ?? `${namespace}:c${nextSeed++}`;
|
|
48
|
+
sharedPrefixLength += 1;
|
|
49
|
+
}
|
|
50
|
+
let sharedSuffixLength = 0;
|
|
51
|
+
while (sharedSuffixLength < previousLength - sharedPrefixLength && sharedSuffixLength < nextLength - sharedPrefixLength && previousUnits[previousLength - 1 - sharedSuffixLength] === nextUnits[nextLength - 1 - sharedSuffixLength]) {
|
|
52
|
+
const previousIndex = previousLength - 1 - sharedSuffixLength;
|
|
53
|
+
const nextIndex = nextLength - 1 - sharedSuffixLength;
|
|
54
|
+
nextGlyphKeys[nextIndex] = previousKeys[previousIndex] ?? `${namespace}:c${nextSeed++}`;
|
|
55
|
+
sharedSuffixLength += 1;
|
|
56
|
+
}
|
|
57
|
+
const previousMiddleEnd = previousLength - sharedSuffixLength;
|
|
58
|
+
const nextMiddleEnd = nextLength - sharedSuffixLength;
|
|
59
|
+
const previousMiddleUnits = previousUnits.slice(sharedPrefixLength, previousMiddleEnd);
|
|
60
|
+
const nextMiddleUnits = nextUnits.slice(sharedPrefixLength, nextMiddleEnd);
|
|
61
|
+
|
|
62
|
+
// lcs keeps shared middle glyphs in place when the text changes
|
|
63
|
+
const matches = computeLcsPairs(previousMiddleUnits, nextMiddleUnits);
|
|
64
|
+
for (const [previousIndex, nextIndex] of matches) {
|
|
65
|
+
const absolutePreviousIndex = previousIndex + sharedPrefixLength;
|
|
66
|
+
const absoluteNextIndex = nextIndex + sharedPrefixLength;
|
|
67
|
+
nextGlyphKeys[absoluteNextIndex] = previousKeys[absolutePreviousIndex] ?? `${namespace}:c${nextSeed++}`;
|
|
68
|
+
}
|
|
69
|
+
for (let nextIndex = 0; nextIndex < nextGlyphKeys.length; nextIndex += 1) {
|
|
70
|
+
if (!nextGlyphKeys[nextIndex]) {
|
|
71
|
+
nextGlyphKeys[nextIndex] = `${namespace}:c${nextSeed++}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
glyphKeys: nextGlyphKeys,
|
|
76
|
+
nextSeed
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.reconcileTextGlyphKeys = reconcileTextGlyphKeys;
|
|
80
|
+
//# 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","exports"],"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,EAAE;IAC/E,KAAK,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,IAAIN,UAAU,EAAEM,SAAS,IAAI,CAAC,EAAE;MAC/DL,EAAE,CAACI,aAAa,CAAC,CAACC,SAAS,CAAC,GAC1BV,aAAa,CAACS,aAAa,GAAG,CAAC,CAAC,KAAKR,SAAS,CAACS,SAAS,GAAG,CAAC,CAAC,GACzDL,EAAE,CAACI,aAAa,GAAG,CAAC,CAAC,CAACC,SAAS,GAAG,CAAC,CAA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G,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;AAACY,OAAA,CAAAjB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createShiftTransition = void 0;
|
|
7
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
|
+
const createShiftTransition = ({
|
|
9
|
+
delayMs = 0,
|
|
10
|
+
durationMs,
|
|
11
|
+
easing,
|
|
12
|
+
fromOpacity,
|
|
13
|
+
toOpacity,
|
|
14
|
+
fromTranslateY,
|
|
15
|
+
toTranslateY,
|
|
16
|
+
fromScale,
|
|
17
|
+
toScale
|
|
18
|
+
}) => {
|
|
19
|
+
return () => {
|
|
20
|
+
"worklet";
|
|
21
|
+
|
|
22
|
+
// drive opacity and transforms from one timing path
|
|
23
|
+
const animate = toValue => delayMs > 0 ? (0, _reactNativeReanimated.withDelay)(delayMs, (0, _reactNativeReanimated.withTiming)(toValue, {
|
|
24
|
+
duration: durationMs,
|
|
25
|
+
easing
|
|
26
|
+
})) : (0, _reactNativeReanimated.withTiming)(toValue, {
|
|
27
|
+
duration: durationMs,
|
|
28
|
+
easing
|
|
29
|
+
});
|
|
30
|
+
const initialValues = {
|
|
31
|
+
opacity: fromOpacity,
|
|
32
|
+
transform: [{
|
|
33
|
+
translateY: fromTranslateY
|
|
34
|
+
}, {
|
|
35
|
+
scale: fromScale
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
const animations = {
|
|
39
|
+
opacity: animate(toOpacity),
|
|
40
|
+
transform: [{
|
|
41
|
+
translateY: animate(toTranslateY)
|
|
42
|
+
}, {
|
|
43
|
+
scale: animate(toScale)
|
|
44
|
+
}]
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
initialValues: {
|
|
48
|
+
...initialValues
|
|
49
|
+
},
|
|
50
|
+
animations: {
|
|
51
|
+
...animations
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.createShiftTransition = createShiftTransition;
|
|
57
|
+
//# sourceMappingURL=entry-exit-builders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeReanimated","require","createShiftTransition","delayMs","durationMs","easing","fromOpacity","toOpacity","fromTranslateY","toTranslateY","fromScale","toScale","animate","toValue","withDelay","withTiming","duration","initialValues","opacity","transform","translateY","scale","animations","exports"],"sourceRoot":"../../../src","sources":["motion/entry-exit-builders.ts"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAmBO,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,GACP,IAAAW,gCAAS,EACPX,OAAO,EACP,IAAAY,iCAAU,EAACF,OAAO,EAAE;MAClBG,QAAQ,EAAEZ,UAAU;MACpBC;IACF,CAAC,CACH,CAAC,GACD,IAAAU,iCAAU,EAACF,OAAO,EAAE;MAClBG,QAAQ,EAAEZ,UAAU;MACpBC;IACF,CAAC,CAAC;IAER,MAAMY,aAAsC,GAAG;MAC7CC,OAAO,EAAEZ,WAAW;MACpBa,SAAS,EAAE,CACT;QAAEC,UAAU,EAAEZ;MAAe,CAAC,EAC9B;QAAEa,KAAK,EAAEX;MAAU,CAAC;IAExB,CAAC;IAED,MAAMY,UAAmC,GAAG;MAC1CJ,OAAO,EAAEN,OAAO,CAACL,SAAS,CAAC;MAC3BY,SAAS,EAAE,CACT;QAAEC,UAAU,EAAER,OAAO,CAACH,YAAY;MAAE,CAAC,EACrC;QAAEY,KAAK,EAAET,OAAO,CAACD,OAAO;MAAE,CAAC;IAE/B,CAAC;IAED,OAAO;MACLM,aAAa,EAAE;QACb,GAAGA;MACL,CAAC;MACDK,UAAU,EAAE;QACV,GAAGA;MACL;IACF,CAAC;EACH,CAAC;AACH,CAAC;AAACC,OAAA,CAAArB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|