react-native-laminar 1.2.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -2
- package/lib/commonjs/hooks/use-display-units.js +1 -0
- package/lib/commonjs/hooks/use-display-units.js.map +1 -1
- package/lib/commonjs/hooks/use-inline-auto-width.js +43 -10
- package/lib/commonjs/hooks/use-inline-auto-width.js.map +1 -1
- package/lib/commonjs/hooks/use-morph-motion.js +2 -1
- package/lib/commonjs/hooks/use-morph-motion.js.map +1 -1
- package/lib/commonjs/hooks/use-morph-text-style.js +4 -0
- package/lib/commonjs/hooks/use-morph-text-style.js.map +1 -1
- package/lib/commonjs/hooks/use-numeric-lanes.js +1 -0
- package/lib/commonjs/hooks/use-numeric-lanes.js.map +1 -1
- package/lib/commonjs/hooks/use-text-glyphs.js +28 -7
- package/lib/commonjs/hooks/use-text-glyphs.js.map +1 -1
- package/lib/commonjs/index.js +54 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/model/display-units.js +7 -1
- package/lib/commonjs/model/display-units.js.map +1 -1
- package/lib/commonjs/model/numeric-lanes.js +4 -0
- package/lib/commonjs/model/numeric-lanes.js.map +1 -1
- package/lib/commonjs/model/text-keys.js +4 -0
- package/lib/commonjs/model/text-keys.js.map +1 -1
- package/lib/commonjs/motion/entry-exit-builders.js +78 -1
- package/lib/commonjs/motion/entry-exit-builders.js.map +1 -1
- package/lib/commonjs/motion/preset-map.js +7 -0
- package/lib/commonjs/motion/preset-map.js.map +1 -1
- package/lib/commonjs/view/glyph-run.js +21 -2
- package/lib/commonjs/view/glyph-run.js.map +1 -1
- package/lib/commonjs/view/morph-viewport.js +4 -0
- package/lib/commonjs/view/morph-viewport.js.map +1 -1
- package/lib/commonjs/view/number-lane.js +5 -1
- package/lib/commonjs/view/number-lane.js.map +1 -1
- package/lib/commonjs/view/number-run.js +4 -0
- package/lib/commonjs/view/number-run.js.map +1 -1
- package/lib/commonjs/view/slots-run.js +258 -0
- package/lib/commonjs/view/slots-run.js.map +1 -0
- package/lib/commonjs/view/text-run.js +35 -3
- package/lib/commonjs/view/text-run.js.map +1 -1
- package/lib/module/hooks/use-display-units.js +2 -0
- package/lib/module/hooks/use-display-units.js.map +1 -1
- package/lib/module/hooks/use-inline-auto-width.js +44 -11
- package/lib/module/hooks/use-inline-auto-width.js.map +1 -1
- package/lib/module/hooks/use-morph-motion.js +2 -1
- package/lib/module/hooks/use-morph-motion.js.map +1 -1
- package/lib/module/hooks/use-morph-text-style.js +4 -0
- package/lib/module/hooks/use-morph-text-style.js.map +1 -1
- package/lib/module/hooks/use-numeric-lanes.js +1 -0
- package/lib/module/hooks/use-numeric-lanes.js.map +1 -1
- package/lib/module/hooks/use-text-glyphs.js +28 -7
- package/lib/module/hooks/use-text-glyphs.js.map +1 -1
- package/lib/module/index.js +56 -12
- package/lib/module/index.js.map +1 -1
- package/lib/module/model/display-units.js +7 -1
- package/lib/module/model/display-units.js.map +1 -1
- package/lib/module/model/numeric-lanes.js +5 -0
- package/lib/module/model/numeric-lanes.js.map +1 -1
- package/lib/module/model/text-keys.js +4 -0
- package/lib/module/model/text-keys.js.map +1 -1
- package/lib/module/motion/entry-exit-builders.js +75 -0
- package/lib/module/motion/entry-exit-builders.js.map +1 -1
- package/lib/module/motion/preset-map.js +7 -0
- package/lib/module/motion/preset-map.js.map +1 -1
- package/lib/module/view/glyph-run.js +21 -2
- package/lib/module/view/glyph-run.js.map +1 -1
- package/lib/module/view/morph-viewport.js +4 -0
- package/lib/module/view/morph-viewport.js.map +1 -1
- package/lib/module/view/number-lane.js +5 -1
- package/lib/module/view/number-lane.js.map +1 -1
- package/lib/module/view/number-run.js +4 -0
- package/lib/module/view/number-run.js.map +1 -1
- package/lib/module/view/slots-run.js +253 -0
- package/lib/module/view/slots-run.js.map +1 -0
- package/lib/module/view/text-run.js +36 -4
- package/lib/module/view/text-run.js.map +1 -1
- package/lib/typescript/commonjs/hooks/use-display-units.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts +3 -1
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-morph-motion.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-morph-text-style.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts +2 -1
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -3
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/model/display-units.d.ts.map +1 -1
- package/lib/typescript/commonjs/model/numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/commonjs/model/text-keys.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts +13 -0
- package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/preset-map.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +12 -2
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/glyph-run.d.ts +5 -2
- package/lib/typescript/commonjs/view/glyph-run.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/morph-viewport.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/number-lane.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/number-run.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/slots-run.d.ts +15 -0
- package/lib/typescript/commonjs/view/slots-run.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/text-run.d.ts +5 -1
- package/lib/typescript/commonjs/view/text-run.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-display-units.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts +3 -1
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-morph-motion.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-morph-text-style.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts +2 -1
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -3
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/model/display-units.d.ts.map +1 -1
- package/lib/typescript/module/model/numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/module/model/text-keys.d.ts.map +1 -1
- package/lib/typescript/module/motion/entry-exit-builders.d.ts +13 -0
- package/lib/typescript/module/motion/entry-exit-builders.d.ts.map +1 -1
- package/lib/typescript/module/motion/preset-map.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +12 -2
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/view/glyph-run.d.ts +5 -2
- package/lib/typescript/module/view/glyph-run.d.ts.map +1 -1
- package/lib/typescript/module/view/morph-viewport.d.ts.map +1 -1
- package/lib/typescript/module/view/number-lane.d.ts.map +1 -1
- package/lib/typescript/module/view/number-run.d.ts.map +1 -1
- package/lib/typescript/module/view/slots-run.d.ts +15 -0
- package/lib/typescript/module/view/slots-run.d.ts.map +1 -0
- package/lib/typescript/module/view/text-run.d.ts +5 -1
- package/lib/typescript/module/view/text-run.d.ts.map +1 -1
- package/package.json +11 -2
- package/src/hooks/use-display-units.ts +1 -0
- package/src/hooks/use-inline-auto-width.ts +55 -12
- package/src/hooks/use-morph-motion.ts +2 -1
- package/src/hooks/use-morph-text-style.ts +3 -0
- package/src/hooks/use-numeric-lanes.ts +1 -0
- package/src/hooks/use-text-glyphs.ts +48 -10
- package/src/index.tsx +98 -17
- package/src/model/display-units.ts +4 -1
- package/src/model/numeric-lanes.ts +3 -0
- package/src/model/text-keys.ts +3 -0
- package/src/motion/entry-exit-builders.ts +73 -0
- package/src/motion/preset-map.ts +4 -0
- package/src/types.ts +14 -2
- package/src/view/glyph-run.tsx +38 -13
- package/src/view/morph-viewport.tsx +3 -0
- package/src/view/number-lane.tsx +7 -2
- package/src/view/number-run.tsx +3 -0
- package/src/view/slots-run.tsx +385 -0
- package/src/view/text-run.tsx +77 -6
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
2
3
|
import type { StyleProp, TextStyle } from "react-native";
|
|
3
4
|
import type { LaminarAlign, MotionRecipe } from "../types";
|
|
4
5
|
type TextRunProps = {
|
|
5
6
|
readonly value: string;
|
|
6
7
|
readonly motionRecipe: MotionRecipe;
|
|
7
8
|
readonly align: LaminarAlign;
|
|
9
|
+
readonly leading?: ReactNode;
|
|
10
|
+
readonly leadingKey?: string | number;
|
|
11
|
+
readonly leadingGap?: number;
|
|
8
12
|
readonly textStyle?: StyleProp<TextStyle>;
|
|
9
13
|
readonly className?: string;
|
|
10
14
|
};
|
|
11
|
-
export declare const TextRun: React.MemoExoticComponent<({ value, motionRecipe, align, textStyle, className }: TextRunProps) => React.JSX.Element>;
|
|
15
|
+
export declare const TextRun: React.MemoExoticComponent<({ value, motionRecipe, align, leading, leadingKey, leadingGap, textStyle, className, }: TextRunProps) => React.JSX.Element>;
|
|
12
16
|
export {};
|
|
13
17
|
//# sourceMappingURL=text-run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-run.d.ts","sourceRoot":"","sources":["../../../../src/view/text-run.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"text-run.d.ts","sourceRoot":"","sources":["../../../../src/view/text-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAGF,eAAO,MAAM,OAAO,qHAUf,YAAY,uBA8EhB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-display-units.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-display-units.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-display-units.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-display-units.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,iBAAc,KACb,SAAS,MAAM,EAQf,CAAC"}
|
|
@@ -2,14 +2,16 @@ import type { LayoutChangeEvent } from "react-native";
|
|
|
2
2
|
type Params = {
|
|
3
3
|
enabled: boolean;
|
|
4
4
|
driveToWidth: (toValue: number) => number;
|
|
5
|
+
measurementKey: string;
|
|
5
6
|
};
|
|
6
|
-
export declare const useInlineAutoWidth: ({ enabled, driveToWidth }: Params) => {
|
|
7
|
+
export declare const useInlineAutoWidth: ({ enabled, driveToWidth, measurementKey, }: Params) => {
|
|
7
8
|
captureLayout: (event: LayoutChangeEvent) => void;
|
|
8
9
|
animatedWidthStyle: {
|
|
9
10
|
width: number;
|
|
10
11
|
} | {
|
|
11
12
|
width?: undefined;
|
|
12
13
|
};
|
|
14
|
+
shouldMeasure: boolean;
|
|
13
15
|
};
|
|
14
16
|
export {};
|
|
15
17
|
//# sourceMappingURL=use-inline-auto-width.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-inline-auto-width.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-inline-auto-width.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,KAAK,MAAM,GAAG;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"use-inline-auto-width.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-inline-auto-width.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,KAAK,MAAM,GAAG;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAKF,eAAO,MAAM,kBAAkB,GAAI,4CAIhC,MAAM;2BA6BG,iBAAiB;;;;;;;CAqD5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-morph-motion.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-morph-motion.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,KAAK,MAAM,GAAG;IACZ,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-morph-motion.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-morph-motion.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,KAAK,MAAM,GAAG;IACZ,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAGF,eAAO,MAAM,cAAc,GAAI,2DAK5B,MAAM,KAAG,WAcX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-morph-text-style.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-morph-text-style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,KAAK,MAAM,GAAG;IACZ,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACvC,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC1C,CAAC;
|
|
1
|
+
{"version":3,"file":"use-morph-text-style.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-morph-text-style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,KAAK,MAAM,GAAG;IACZ,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACvC,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC1C,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAI,wCAK/B,MAAM,KAAG,cA2BX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-numeric-lanes.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-numeric-lanes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAcrD,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-numeric-lanes.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-numeric-lanes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAcrD,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAGF,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,mBAgC/C,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import type { GlyphToken } from "../types";
|
|
2
|
-
export declare const useTextGlyphs: (value: string, namespace: string) => readonly GlyphToken[];
|
|
3
|
+
export declare const useTextGlyphs: (value: string, namespace: string, leading?: ReactNode, leadingKey?: string | number) => readonly GlyphToken[];
|
|
3
4
|
//# sourceMappingURL=use-text-glyphs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-text-glyphs.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-text-glyphs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-text-glyphs.d.ts","sourceRoot":"","sources":["../../../../src/hooks/use-text-glyphs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAc3C,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,UAAU,SAAS,EACnB,aAAa,MAAM,GAAG,MAAM,KAC3B,SAAS,UAAU,EAoErB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MorphingTextProps } from "./types";
|
|
3
3
|
export declare const Laminar: React.NamedExoticComponent<Readonly<MorphingTextProps>>;
|
|
4
|
-
export
|
|
5
|
-
export default Laminar;
|
|
6
|
-
export type { LaminarAlign, LaminarProps, MorphAnimationPresetName, MorphContentVariant, MorphingTextProps, } from "./types";
|
|
4
|
+
export type { LaminarAlign, LaminarLeadingMap, LaminarProps, MorphAnimationPresetName, MorphContentVariant, MorphingTextProps, } from "./types";
|
|
7
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAOpE,eAAO,MAAM,OAAO,yDAqJhB,CAAC;AAcL,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-units.d.ts","sourceRoot":"","sources":["../../../../src/model/display-units.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"display-units.d.ts","sourceRoot":"","sources":["../../../../src/model/display-units.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MAAM,EASvD,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,WACrB,CAAC;AAG7B,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,YAA+B,CAAC;AAGzE,eAAO,MAAM,qBAAqB,GAAI,OAAO,SAAS,MAAM,EAAE,WAI7D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numeric-lanes.d.ts","sourceRoot":"","sources":["../../../../src/model/numeric-lanes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"numeric-lanes.d.ts","sourceRoot":"","sources":["../../../../src/model/numeric-lanes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAiBrD,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;CAC1C,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAChC,eAAe,MAAM,EACrB,WAAW,MAAM,EACjB,cAAc,SAAS,MAAM,EAAE,EAC/B,MAAM,MAAM,KACX,mBAqDF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-keys.d.ts","sourceRoot":"","sources":["../../../../src/model/text-keys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-keys.d.ts","sourceRoot":"","sources":["../../../../src/model/text-keys.ts"],"names":[],"mappings":"AAqDA,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAGF,eAAO,MAAM,sBAAsB,GACjC,eAAe,SAAS,MAAM,EAAE,EAChC,WAAW,SAAS,MAAM,EAAE,EAC5B,cAAc,SAAS,MAAM,EAAE,EAC/B,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB,wBA4DF,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EntryExitAnimationFunction, type WithTimingConfig } from "react-native-reanimated";
|
|
2
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
2
3
|
type TransitionParams = {
|
|
3
4
|
readonly delayMs?: number;
|
|
4
5
|
readonly durationMs: number;
|
|
@@ -10,6 +11,18 @@ type TransitionParams = {
|
|
|
10
11
|
readonly fromScale: number;
|
|
11
12
|
readonly toScale: number;
|
|
12
13
|
};
|
|
14
|
+
type LeadingExitTransitionParams = {
|
|
15
|
+
readonly durationMs: number;
|
|
16
|
+
readonly easing: NonNullable<WithTimingConfig["easing"]>;
|
|
17
|
+
readonly leadingGap: number;
|
|
18
|
+
readonly scale?: boolean | SharedValue<number>;
|
|
19
|
+
};
|
|
20
|
+
type LeadingEnterTransitionParams = {
|
|
21
|
+
readonly durationMs: number;
|
|
22
|
+
readonly easing: NonNullable<WithTimingConfig["easing"]>;
|
|
23
|
+
};
|
|
24
|
+
export declare const createLeadingEnterTransition: ({ durationMs, easing, }: LeadingEnterTransitionParams) => EntryExitAnimationFunction;
|
|
13
25
|
export declare const createShiftTransition: ({ delayMs, durationMs, easing, fromOpacity, toOpacity, fromTranslateY, toTranslateY, fromScale, toScale, }: TransitionParams) => EntryExitAnimationFunction;
|
|
26
|
+
export declare const createLeadingExitTransition: ({ durationMs, easing, leadingGap, scale, }: LeadingExitTransitionParams) => EntryExitAnimationFunction;
|
|
14
27
|
export {};
|
|
15
28
|
//# sourceMappingURL=entry-exit-builders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-exit-builders.d.ts","sourceRoot":"","sources":["../../../../src/motion/entry-exit-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,
|
|
1
|
+
{"version":3,"file":"entry-exit-builders.d.ts","sourceRoot":"","sources":["../../../../src/motion/entry-exit-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAE/B,KAAK,gBAAgB,EAGtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,KAAK,gBAAgB,GAAG;IACtB,QAAQ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,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"preset-map.d.ts","sourceRoot":"","sources":["../../../../src/motion/preset-map.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAKlB,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,wBAAwB,EACxB,oBAAoB,CAqBZ,CAAC;AAiCX,eAAO,MAAM,mBAAmB,GAC9B,aAAY,wBAAoC,EAChD,mBAAmB,MAAM,KACxB,YAqDF,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import type { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
2
3
|
import type { ComplexAnimationBuilder, EntryExitAnimationFunction, WithTimingConfig } from "react-native-reanimated";
|
|
3
4
|
export type MorphAnimationPresetName = "default" | "smooth" | "snappy" | "bouncy";
|
|
4
|
-
export type MorphContentVariant = "text" | "number";
|
|
5
|
+
export type MorphContentVariant = "text" | "number" | "slots";
|
|
5
6
|
export type LaminarAlign = "left" | "center" | "right";
|
|
7
|
+
export type LaminarLeadingMap = Readonly<Record<string, ReactNode>>;
|
|
6
8
|
type CubicBezierTuple = readonly [number, number, number, number];
|
|
7
9
|
export type MorphAnimationPreset = {
|
|
8
10
|
readonly duration: number;
|
|
@@ -14,7 +16,9 @@ export type MorphAnimationPreset = {
|
|
|
14
16
|
};
|
|
15
17
|
export type GlyphToken = {
|
|
16
18
|
readonly id: string;
|
|
17
|
-
readonly
|
|
19
|
+
readonly kind: "text" | "element";
|
|
20
|
+
readonly value?: string;
|
|
21
|
+
readonly element?: ReactNode;
|
|
18
22
|
};
|
|
19
23
|
export type NumericFlowDirection = -1 | 0 | 1;
|
|
20
24
|
export type MotionRecipe = {
|
|
@@ -32,6 +36,12 @@ export type MorphingTextProps = {
|
|
|
32
36
|
readonly color?: string;
|
|
33
37
|
readonly align?: LaminarAlign;
|
|
34
38
|
readonly className?: string;
|
|
39
|
+
/** optional inline element reconciled and animated as the leading token */
|
|
40
|
+
readonly leading?: ReactNode | LaminarLeadingMap;
|
|
41
|
+
/** identity for swapping one leading element for another */
|
|
42
|
+
readonly leadingKey?: string | number;
|
|
43
|
+
/** spacing between the leading element and the first text glyph */
|
|
44
|
+
readonly leadingGap?: number;
|
|
35
45
|
readonly style?: StyleProp<TextStyle>;
|
|
36
46
|
readonly containerStyle?: StyleProp<ViewStyle>;
|
|
37
47
|
readonly fontStyle?: StyleProp<TextStyle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,wBAAwB,GAChC,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,wBAAwB,GAChC,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,O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ilder, EntryExitAnimationFunction } from "react-native-reanimated";
|
|
4
4
|
import type { GlyphToken, LaminarAlign } from "../types";
|
|
5
|
-
export declare const GlyphRun: React.MemoExoticComponent<({ glyphs, layoutTransition, enterTransition, exitTransition, align, textStyle, className, }: Readonly<{
|
|
5
|
+
export declare const GlyphRun: React.MemoExoticComponent<({ glyphs, layoutTransition, enterTransition, elementEnterTransition, exitTransition, elementExitTransition, leadingGap, align, textStyle, className, }: Readonly<{
|
|
6
6
|
glyphs: readonly GlyphToken[];
|
|
7
|
-
layoutTransition
|
|
7
|
+
layoutTransition?: ComplexAnimationBuilder;
|
|
8
8
|
enterTransition?: EntryExitAnimationFunction;
|
|
9
|
+
elementEnterTransition?: EntryExitAnimationFunction;
|
|
9
10
|
exitTransition?: EntryExitAnimationFunction;
|
|
11
|
+
elementExitTransition?: EntryExitAnimationFunction;
|
|
12
|
+
leadingGap?: number;
|
|
10
13
|
align: LaminarAlign;
|
|
11
14
|
textStyle?: StyleProp<TextStyle>;
|
|
12
15
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glyph-run.d.ts","sourceRoot":"","sources":["../../../../src/view/glyph-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAQ,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EACV,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"glyph-run.d.ts","sourceRoot":"","sources":["../../../../src/view/glyph-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAQ,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EACV,uBAAu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C,OAAO,CAAC,CAAC;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC,CAAC;
|
|
1
|
+
{"version":3,"file":"morph-viewport.d.ts","sourceRoot":"","sources":["../../../../src/view/morph-viewport.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA4C7C,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC,CAAC;AAGF,eAAO,MAAM,aAAa,4HASrB,kBAAkB,uBAqCtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-lane.d.ts","sourceRoot":"","sources":["../../../../src/view/number-lane.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAIpE,OAAO,KAAK,EAAE,YAAY,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,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAGF,eAAO,MAAM,UAAU,+IAYlB,eAAe,uBAqFnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-run.d.ts","sourceRoot":"","sources":["../../../../src/view/number-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAQ,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAe3D,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"number-run.d.ts","sourceRoot":"","sources":["../../../../src/view/number-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAQ,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAe3D,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAGF,eAAO,MAAM,SAAS,yGASjB,QAAQ,CAAC,cAAc,CAAC,uBA8C5B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, type TextStyle } from "react-native";
|
|
3
|
+
import type { LaminarAlign, MotionRecipe } from "../types";
|
|
4
|
+
type SlotsRunProps = {
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly motionRecipe: MotionRecipe;
|
|
7
|
+
readonly align: LaminarAlign;
|
|
8
|
+
readonly fontSize?: number;
|
|
9
|
+
readonly textStyle?: StyleProp<TextStyle>;
|
|
10
|
+
readonly staggerMs: number;
|
|
11
|
+
readonly className?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const SlotsRun: React.MemoExoticComponent<({ value, motionRecipe, align, fontSize, textStyle, staggerMs, className, }: Readonly<SlotsRunProps>) => React.JSX.Element>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=slots-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots-run.d.ts","sourceRoot":"","sources":["../../../../src/view/slots-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AAQtB,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAwB,MAAM,UAAU,CAAC;AAmQjF,KAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAGF,eAAO,MAAM,QAAQ,yGAShB,QAAQ,CAAC,aAAa,CAAC,uBAwF3B,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
2
3
|
import type { StyleProp, TextStyle } from "react-native";
|
|
3
4
|
import type { LaminarAlign, MotionRecipe } from "../types";
|
|
4
5
|
type TextRunProps = {
|
|
5
6
|
readonly value: string;
|
|
6
7
|
readonly motionRecipe: MotionRecipe;
|
|
7
8
|
readonly align: LaminarAlign;
|
|
9
|
+
readonly leading?: ReactNode;
|
|
10
|
+
readonly leadingKey?: string | number;
|
|
11
|
+
readonly leadingGap?: number;
|
|
8
12
|
readonly textStyle?: StyleProp<TextStyle>;
|
|
9
13
|
readonly className?: string;
|
|
10
14
|
};
|
|
11
|
-
export declare const TextRun: React.MemoExoticComponent<({ value, motionRecipe, align, textStyle, className }: TextRunProps) => React.JSX.Element>;
|
|
15
|
+
export declare const TextRun: React.MemoExoticComponent<({ value, motionRecipe, align, leading, leadingKey, leadingGap, textStyle, className, }: TextRunProps) => React.JSX.Element>;
|
|
12
16
|
export {};
|
|
13
17
|
//# sourceMappingURL=text-run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-run.d.ts","sourceRoot":"","sources":["../../../../src/view/text-run.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"text-run.d.ts","sourceRoot":"","sources":["../../../../src/view/text-run.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAGF,eAAO,MAAM,OAAO,qHAUf,YAAY,uBA8EhB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-laminar",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "A React Native component for morphing text and numbers with character-level identity.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"react-native": "./src/index.tsx",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
+
"react-native": "./src/index.tsx",
|
|
25
|
+
"source": "./src/index.tsx",
|
|
24
26
|
"import": {
|
|
25
27
|
"types": "./lib/typescript/module/index.d.ts",
|
|
26
28
|
"default": "./lib/module/index.js"
|
|
@@ -37,7 +39,14 @@
|
|
|
37
39
|
],
|
|
38
40
|
"scripts": {
|
|
39
41
|
"build": "bob build",
|
|
40
|
-
"prepare": "bob build"
|
|
42
|
+
"prepare": "bob build",
|
|
43
|
+
"test": "jest --config jest.config.js --runInBand",
|
|
44
|
+
"test:watch": "jest --config jest.config.js --watch",
|
|
45
|
+
"test:coverage": "jest --config jest.config.js --runInBand --coverage && node scripts/check-coverage.js",
|
|
46
|
+
"test:ci": "jest --config jest.config.js --runInBand --ci --coverage && node scripts/check-coverage.js",
|
|
47
|
+
"typecheck": "tsc --project tsconfig.test.json --noEmit",
|
|
48
|
+
"pack:check": "npm pack --dry-run --cache ./coverage/npm-cache",
|
|
49
|
+
"quality": "npm run typecheck && npm run test:ci && npm run build && npm run pack:check"
|
|
41
50
|
},
|
|
42
51
|
"sideEffects": false,
|
|
43
52
|
"peerDependencies": {
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { useCallback, useRef, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import type { LayoutChangeEvent } from "react-native";
|
|
3
3
|
import { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
4
4
|
|
|
5
5
|
type Params = {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
driveToWidth: (toValue: number) => number;
|
|
8
|
+
measurementKey: string;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const WIDTH_CACHE_LIMIT = 64;
|
|
12
|
+
|
|
13
|
+
// measure each content signature once and drive later changes through one width value
|
|
14
|
+
export const useInlineAutoWidth = ({
|
|
15
|
+
enabled,
|
|
16
|
+
driveToWidth,
|
|
17
|
+
measurementKey,
|
|
18
|
+
}: Params) => {
|
|
11
19
|
const widthValue = useSharedValue(0);
|
|
12
20
|
const measuredWidthRef = useRef<number | null>(null);
|
|
13
21
|
const bootstrappedRef = useRef(false);
|
|
22
|
+
const widthCacheRef = useRef(new Map<string, number>());
|
|
14
23
|
const [hasBootstrappedWidth, setHasBootstrappedWidth] = useState(false);
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
|
|
23
|
-
|
|
25
|
+
// the first measurement establishes the shell without animating from zero
|
|
26
|
+
const applyWidth = useCallback(
|
|
27
|
+
(nextWidth: number) => {
|
|
24
28
|
if (measuredWidthRef.current === nextWidth) {
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
measuredWidthRef.current = nextWidth;
|
|
29
33
|
|
|
30
|
-
// snap the first width so mount does not animate from zero
|
|
31
34
|
if (!bootstrappedRef.current) {
|
|
32
35
|
bootstrappedRef.current = true;
|
|
33
36
|
widthValue.value = nextWidth;
|
|
@@ -37,9 +40,48 @@ export const useInlineAutoWidth = ({ enabled, driveToWidth }: Params) => {
|
|
|
37
40
|
|
|
38
41
|
widthValue.value = driveToWidth(nextWidth);
|
|
39
42
|
},
|
|
40
|
-
[driveToWidth,
|
|
43
|
+
[driveToWidth, widthValue]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const captureLayout = useCallback(
|
|
47
|
+
(event: LayoutChangeEvent) => {
|
|
48
|
+
if (!enabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// round up so fractional native measurements cannot clip the final glyph
|
|
53
|
+
const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
|
|
54
|
+
|
|
55
|
+
// delete before setting so a repeated key moves to the most recent position
|
|
56
|
+
widthCacheRef.current.delete(measurementKey);
|
|
57
|
+
|
|
58
|
+
if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
|
|
59
|
+
// map insertion order gives the lru entry at the front
|
|
60
|
+
const oldestKey = widthCacheRef.current.keys().next().value;
|
|
61
|
+
|
|
62
|
+
if (oldestKey !== undefined) {
|
|
63
|
+
widthCacheRef.current.delete(oldestKey);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
widthCacheRef.current.set(measurementKey, nextWidth);
|
|
68
|
+
applyWidth(nextWidth);
|
|
69
|
+
},
|
|
70
|
+
[applyWidth, enabled, measurementKey]
|
|
41
71
|
);
|
|
42
72
|
|
|
73
|
+
const cachedWidth = widthCacheRef.current.get(measurementKey);
|
|
74
|
+
|
|
75
|
+
// a cached width can restore the shell before the hidden probe renders again
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (enabled && cachedWidth !== undefined) {
|
|
78
|
+
// promote cache hits so active states stay available longer
|
|
79
|
+
widthCacheRef.current.delete(measurementKey);
|
|
80
|
+
widthCacheRef.current.set(measurementKey, cachedWidth);
|
|
81
|
+
applyWidth(cachedWidth);
|
|
82
|
+
}
|
|
83
|
+
}, [applyWidth, cachedWidth, enabled, measurementKey]);
|
|
84
|
+
|
|
43
85
|
const animatedWidthStyle = useAnimatedStyle(
|
|
44
86
|
() =>
|
|
45
87
|
enabled && hasBootstrappedWidth
|
|
@@ -53,5 +95,6 @@ export const useInlineAutoWidth = ({ enabled, driveToWidth }: Params) => {
|
|
|
53
95
|
return {
|
|
54
96
|
captureLayout,
|
|
55
97
|
animatedWidthStyle,
|
|
98
|
+
shouldMeasure: enabled && cachedWidth === undefined,
|
|
56
99
|
};
|
|
57
100
|
};
|
|
@@ -18,13 +18,14 @@ type MorphMotion = {
|
|
|
18
18
|
readonly staggerMs: number;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// resolve one motion recipe and one shared stagger unit for a render tree
|
|
21
22
|
export const useMorphMotion = ({
|
|
22
23
|
variant,
|
|
23
24
|
animationPreset,
|
|
24
25
|
animationDuration,
|
|
25
26
|
stagger,
|
|
26
27
|
}: Params): MorphMotion => {
|
|
27
|
-
//
|
|
28
|
+
// numeric variants need a quicker default because their lanes update often
|
|
28
29
|
const resolvedPreset =
|
|
29
30
|
animationPreset ?? (variant === "text" ? "default" : "snappy");
|
|
30
31
|
|
|
@@ -12,12 +12,14 @@ type MorphTextStyle = {
|
|
|
12
12
|
readonly textStyle: StyleProp<TextStyle>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// compose the public style layers into the style passed to every glyph
|
|
15
16
|
export const useMorphTextStyle = ({
|
|
16
17
|
fontSize,
|
|
17
18
|
color,
|
|
18
19
|
fontStyle,
|
|
19
20
|
style,
|
|
20
21
|
}: Params): MorphTextStyle => {
|
|
22
|
+
// keep the base layer small so caller styles can override it predictably
|
|
21
23
|
const baseTextStyle = useMemo(() => {
|
|
22
24
|
const nextStyle: TextStyle = {
|
|
23
25
|
includeFontPadding: false,
|
|
@@ -34,6 +36,7 @@ export const useMorphTextStyle = ({
|
|
|
34
36
|
return nextStyle;
|
|
35
37
|
}, [color, fontSize]);
|
|
36
38
|
|
|
39
|
+
// preserve the merge order used by the public style contract
|
|
37
40
|
const textStyle = useMemo(
|
|
38
41
|
() => [baseTextStyle, fontStyle, style],
|
|
39
42
|
[baseTextStyle, fontStyle, style]
|
|
@@ -20,6 +20,7 @@ type NumericLaneSnapshot = {
|
|
|
20
20
|
readonly leadLength: number;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// retain numeric lane identity across value changes without storing it in state
|
|
23
24
|
export const useNumericLanes = (value: string): NumericLaneSnapshot => {
|
|
24
25
|
const units = useMemo(() => splitDisplayUnits(value), [value]);
|
|
25
26
|
const ledgerRef = useRef<NumericLedger>({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo, useRef } from "react";
|
|
1
|
+
import { useMemo, useRef, type ReactNode } from "react";
|
|
2
2
|
import {
|
|
3
3
|
normalizeDisplayUnit,
|
|
4
4
|
splitDisplayUnits,
|
|
@@ -8,28 +8,62 @@ import type { GlyphToken } from "../types";
|
|
|
8
8
|
|
|
9
9
|
type TextGlyphLedger = {
|
|
10
10
|
previousValue: string;
|
|
11
|
-
|
|
11
|
+
previousSignatures: readonly string[];
|
|
12
12
|
glyphKeys: readonly string[];
|
|
13
13
|
nextSeed: number;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
type TextGlyphUnit =
|
|
17
|
+
| { readonly kind: "text"; readonly signature: string; readonly value: string }
|
|
18
|
+
| { readonly kind: "element"; readonly signature: string; readonly element: ReactNode };
|
|
19
|
+
|
|
20
|
+
// build the inline token stream that lets text and leading content share one ledger
|
|
16
21
|
export const useTextGlyphs = (
|
|
17
22
|
value: string,
|
|
18
|
-
namespace: string
|
|
23
|
+
namespace: string,
|
|
24
|
+
leading?: ReactNode,
|
|
25
|
+
leadingKey?: string | number
|
|
19
26
|
): readonly GlyphToken[] => {
|
|
20
|
-
const units = useMemo
|
|
27
|
+
const units = useMemo<readonly TextGlyphUnit[]>(
|
|
28
|
+
() => [
|
|
29
|
+
// the map key becomes the identity when leading content is state keyed
|
|
30
|
+
...(leading
|
|
31
|
+
? [
|
|
32
|
+
{
|
|
33
|
+
kind: "element",
|
|
34
|
+
signature: `leading:${String(leadingKey ?? "default")}`,
|
|
35
|
+
element: leading,
|
|
36
|
+
} as const,
|
|
37
|
+
]
|
|
38
|
+
: []),
|
|
39
|
+
...splitDisplayUnits(value).map((unit) => ({
|
|
40
|
+
kind: "text" as const,
|
|
41
|
+
signature: `text:${unit}`,
|
|
42
|
+
value: unit,
|
|
43
|
+
})),
|
|
44
|
+
],
|
|
45
|
+
[leading, leadingKey, value]
|
|
46
|
+
);
|
|
47
|
+
const signatures = units.map((unit) => unit.signature);
|
|
21
48
|
const ledgerRef = useRef<TextGlyphLedger>({
|
|
22
49
|
previousValue: value,
|
|
23
|
-
|
|
50
|
+
previousSignatures: signatures,
|
|
24
51
|
glyphKeys: units.map((_, index) => `${namespace}:c${index}`),
|
|
25
52
|
nextSeed: units.length,
|
|
26
53
|
});
|
|
27
54
|
|
|
28
|
-
|
|
55
|
+
// reconcile only when a token signature changes so stable glyphs keep their views
|
|
56
|
+
if (
|
|
57
|
+
value !== ledgerRef.current.previousValue ||
|
|
58
|
+
signatures.length !== ledgerRef.current.previousSignatures.length ||
|
|
59
|
+
signatures.some(
|
|
60
|
+
(signature, index) => signature !== ledgerRef.current.previousSignatures[index]
|
|
61
|
+
)
|
|
62
|
+
) {
|
|
29
63
|
// keep ids stable so unchanged glyphs stay mounted between updates
|
|
30
64
|
const nextLedger = reconcileTextGlyphKeys(
|
|
31
|
-
ledgerRef.current.
|
|
32
|
-
|
|
65
|
+
ledgerRef.current.previousSignatures,
|
|
66
|
+
signatures,
|
|
33
67
|
ledgerRef.current.glyphKeys,
|
|
34
68
|
ledgerRef.current.nextSeed,
|
|
35
69
|
namespace
|
|
@@ -37,7 +71,7 @@ export const useTextGlyphs = (
|
|
|
37
71
|
|
|
38
72
|
ledgerRef.current = {
|
|
39
73
|
previousValue: value,
|
|
40
|
-
|
|
74
|
+
previousSignatures: signatures,
|
|
41
75
|
glyphKeys: nextLedger.glyphKeys,
|
|
42
76
|
nextSeed: nextLedger.nextSeed,
|
|
43
77
|
};
|
|
@@ -45,11 +79,15 @@ export const useTextGlyphs = (
|
|
|
45
79
|
|
|
46
80
|
const glyphKeys = ledgerRef.current.glyphKeys;
|
|
47
81
|
|
|
82
|
+
// normalize spaces at the edge where tokens become renderable glyphs
|
|
48
83
|
return useMemo(
|
|
49
84
|
() =>
|
|
50
85
|
units.map((unit, index) => ({
|
|
51
86
|
id: glyphKeys[index],
|
|
52
|
-
|
|
87
|
+
kind: unit.kind,
|
|
88
|
+
...(unit.kind === "text"
|
|
89
|
+
? { value: normalizeDisplayUnit(unit.value) }
|
|
90
|
+
: { element: unit.element }),
|
|
53
91
|
})),
|
|
54
92
|
[glyphKeys, units]
|
|
55
93
|
);
|