react-native-laminar 1.4.2 → 1.4.4
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/lib/commonjs/hooks/use-inline-auto-width.js +105 -18
- package/lib/commonjs/hooks/use-inline-auto-width.js.map +1 -1
- package/lib/commonjs/hooks/use-text-glyphs.js +24 -21
- package/lib/commonjs/hooks/use-text-glyphs.js.map +1 -1
- package/lib/commonjs/index.js +6 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/view/glyph-run.js +38 -19
- package/lib/commonjs/view/glyph-run.js.map +1 -1
- package/lib/commonjs/view/morph-viewport.js +2 -0
- package/lib/commonjs/view/morph-viewport.js.map +1 -1
- package/lib/commonjs/view/text-run.js +34 -12
- package/lib/commonjs/view/text-run.js.map +1 -1
- package/lib/module/hooks/use-inline-auto-width.js +106 -19
- package/lib/module/hooks/use-inline-auto-width.js.map +1 -1
- package/lib/module/hooks/use-text-glyphs.js +24 -21
- package/lib/module/hooks/use-text-glyphs.js.map +1 -1
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/view/glyph-run.js +39 -20
- package/lib/module/view/glyph-run.js.map +1 -1
- package/lib/module/view/morph-viewport.js +2 -0
- package/lib/module/view/morph-viewport.js.map +1 -1
- package/lib/module/view/text-run.js +34 -12
- package/lib/module/view/text-run.js.map +1 -1
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts +2 -0
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/glyph-run.d.ts +3 -1
- package/lib/typescript/commonjs/view/glyph-run.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/morph-viewport.d.ts +3 -2
- package/lib/typescript/commonjs/view/morph-viewport.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/text-run.d.ts +3 -1
- package/lib/typescript/commonjs/view/text-run.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts +2 -0
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/view/glyph-run.d.ts +3 -1
- package/lib/typescript/module/view/glyph-run.d.ts.map +1 -1
- package/lib/typescript/module/view/morph-viewport.d.ts +3 -2
- package/lib/typescript/module/view/morph-viewport.d.ts.map +1 -1
- package/lib/typescript/module/view/text-run.d.ts +3 -1
- package/lib/typescript/module/view/text-run.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/use-inline-auto-width.ts +160 -18
- package/src/hooks/use-text-glyphs.ts +35 -28
- package/src/index.tsx +11 -1
- package/src/view/glyph-run.tsx +62 -33
- package/src/view/morph-viewport.tsx +7 -2
- package/src/view/text-run.tsx +59 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_useTextGlyphs","_entryExitBuilders","_glyphRun","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TextRun","exports","React","memo","value","motionRecipe","align","leading","leadingKey","leadingGap","textStyle","className","scopeId","useId","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_useTextGlyphs","_entryExitBuilders","_glyphRun","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TextRun","exports","React","memo","value","motionRecipe","align","leading","leadingLayoutGroup","leadingKey","leadingGap","ready","textStyle","className","scopeId","useId","hasDisplayedRef","useRef","displayedValueRef","displayedLeadingRef","displayedLeadingKeyRef","displayedLeadingGapRef","shouldDisplayTarget","current","visibleValue","visibleLeading","visibleLeadingKey","visibleLeadingGap","lastValueRef","lastLeadingPresenceRef","Boolean","lastLeadingKeyRef","hasAnimatedRef","isLeadingSwap","isLeadingChange","leadingSwapProgress","useSharedValue","useLayoutEffect","glyphs","useTextGlyphs","elementEnterTransition","useMemo","createLeadingEnterTransition","durationMs","easing","elementExitTransition","createLeadingExitTransition","scale","hasAnimated","jsx","GlyphRun","layoutTransition","undefined","leadingLayoutTransition","enterTransition","exitTransition","displayName"],"sourceRoot":"../../../src","sources":["view/text-run.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AAAuC,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD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Z,sBAAsB,EACpBP,aAAa,GAAGO,sBAAsB,GAAGY,SAC1C;IACDG,cAAc,EAAElD,YAAY,CAACkD,cAAe;IAC5CV,qBAAqB,EAAEA,qBAAsB;IAC7CnC,UAAU,EAAEiB,iBAAkB;IAC9BrB,KAAK,EAAEA,KAAM;IACbM,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CACF,CAAC;AAEDb,OAAO,CAACwD,WAAW,GAAG,SAAS","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
5
5
|
const WIDTH_CACHE_LIMIT = 64;
|
|
6
6
|
|
|
@@ -11,10 +11,19 @@ export const useInlineAutoWidth = ({
|
|
|
11
11
|
measurementKey
|
|
12
12
|
}) => {
|
|
13
13
|
const widthValue = useSharedValue(0);
|
|
14
|
+
const hasBootstrappedWidth = useSharedValue(false);
|
|
14
15
|
const measuredWidthRef = useRef(null);
|
|
15
16
|
const bootstrappedRef = useRef(false);
|
|
16
17
|
const widthCacheRef = useRef(new Map());
|
|
17
|
-
const
|
|
18
|
+
const hasCapturedVisibleLayoutRef = useRef(false);
|
|
19
|
+
const initialMeasurementKeyRef = useRef(null);
|
|
20
|
+
const firstProbeRef = useRef(null);
|
|
21
|
+
const latestProbeRef = useRef(null);
|
|
22
|
+
const bootstrapTimerRef = useRef(null);
|
|
23
|
+
const [readyMeasurementKey, setReadyMeasurementKey] = useState(null);
|
|
24
|
+
const markMeasurementReady = useCallback(key => {
|
|
25
|
+
setReadyMeasurementKey(currentKey => currentKey === key ? currentKey : key);
|
|
26
|
+
}, []);
|
|
18
27
|
|
|
19
28
|
// the first measurement establishes the shell without animating from zero
|
|
20
29
|
const applyWidth = useCallback(nextWidth => {
|
|
@@ -25,11 +34,62 @@ export const useInlineAutoWidth = ({
|
|
|
25
34
|
if (!bootstrappedRef.current) {
|
|
26
35
|
bootstrappedRef.current = true;
|
|
27
36
|
widthValue.value = nextWidth;
|
|
28
|
-
|
|
37
|
+
hasBootstrappedWidth.value = true;
|
|
29
38
|
return;
|
|
30
39
|
}
|
|
31
40
|
widthValue.value = driveToWidth(nextWidth);
|
|
32
41
|
}, [driveToWidth, widthValue]);
|
|
42
|
+
const bootstrapFromProbe = useCallback(() => {
|
|
43
|
+
bootstrapTimerRef.current = null;
|
|
44
|
+
if (hasCapturedVisibleLayoutRef.current) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const firstProbe = firstProbeRef.current;
|
|
48
|
+
if (!firstProbe) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The visible layout did not arrive in time, so use the first probe as a
|
|
53
|
+
// safe fallback. A later probe can still animate from this baseline.
|
|
54
|
+
hasCapturedVisibleLayoutRef.current = true;
|
|
55
|
+
initialMeasurementKeyRef.current = firstProbe.key;
|
|
56
|
+
applyWidth(firstProbe.width);
|
|
57
|
+
const latestProbe = latestProbeRef.current;
|
|
58
|
+
if (latestProbe && latestProbe.key !== firstProbe.key) {
|
|
59
|
+
// The target width is already cached. Defer its animation until the
|
|
60
|
+
// ready render so the shell and the new glyph row start together.
|
|
61
|
+
markMeasurementReady(latestProbe.key);
|
|
62
|
+
} else {
|
|
63
|
+
markMeasurementReady(firstProbe.key);
|
|
64
|
+
}
|
|
65
|
+
}, [applyWidth, markMeasurementReady]);
|
|
66
|
+
const captureVisibleLayout = useCallback(event => {
|
|
67
|
+
if (!enabled || hasCapturedVisibleLayoutRef.current) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (bootstrapTimerRef.current !== null) {
|
|
71
|
+
clearTimeout(bootstrapTimerRef.current);
|
|
72
|
+
bootstrapTimerRef.current = null;
|
|
73
|
+
}
|
|
74
|
+
hasCapturedVisibleLayoutRef.current = true;
|
|
75
|
+
// bootstrap from the visible tree so the first explicit width matches
|
|
76
|
+
// the geometry that was already painted to the user
|
|
77
|
+
const nextWidth = Math.max(0, event.nativeEvent.layout.width);
|
|
78
|
+
// retain the visible width for the initial key so a later cache hit does
|
|
79
|
+
// not reintroduce the probe-to-visible mismatch
|
|
80
|
+
widthCacheRef.current.delete(measurementKey);
|
|
81
|
+
widthCacheRef.current.set(measurementKey, nextWidth);
|
|
82
|
+
const firstProbe = firstProbeRef.current;
|
|
83
|
+
if (firstProbe && firstProbe.key !== measurementKey) {
|
|
84
|
+
initialMeasurementKeyRef.current = firstProbe.key;
|
|
85
|
+
applyWidth(firstProbe.width);
|
|
86
|
+
markMeasurementReady(measurementKey);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
initialMeasurementKeyRef.current = measurementKey;
|
|
90
|
+
applyWidth(nextWidth);
|
|
91
|
+
markMeasurementReady(measurementKey);
|
|
92
|
+
}, [applyWidth, enabled, markMeasurementReady, measurementKey]);
|
|
33
93
|
const captureLayout = useCallback(event => {
|
|
34
94
|
if (!enabled) {
|
|
35
95
|
return;
|
|
@@ -37,36 +97,63 @@ export const useInlineAutoWidth = ({
|
|
|
37
97
|
|
|
38
98
|
// round up so fractional native measurements cannot clip the final glyph
|
|
39
99
|
const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
100
|
+
const isInitialMeasurement = initialMeasurementKeyRef.current === measurementKey;
|
|
101
|
+
if (!isInitialMeasurement) {
|
|
102
|
+
// delete before setting so a repeated key moves to the most recent position
|
|
103
|
+
widthCacheRef.current.delete(measurementKey);
|
|
104
|
+
if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
|
|
105
|
+
// map insertion order gives the lru entry at the front
|
|
106
|
+
const oldestKey = widthCacheRef.current.keys().next().value;
|
|
107
|
+
if (oldestKey !== undefined) {
|
|
108
|
+
widthCacheRef.current.delete(oldestKey);
|
|
109
|
+
}
|
|
48
110
|
}
|
|
111
|
+
widthCacheRef.current.set(measurementKey, nextWidth);
|
|
49
112
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
113
|
+
const probe = {
|
|
114
|
+
key: measurementKey,
|
|
115
|
+
width: nextWidth
|
|
116
|
+
};
|
|
117
|
+
if (!firstProbeRef.current) {
|
|
118
|
+
firstProbeRef.current = probe;
|
|
119
|
+
}
|
|
120
|
+
latestProbeRef.current = probe;
|
|
121
|
+
if (!hasCapturedVisibleLayoutRef.current && bootstrapTimerRef.current === null) {
|
|
122
|
+
bootstrapTimerRef.current = setTimeout(bootstrapFromProbe, 0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Do not let the initial probe override the visible first frame.
|
|
126
|
+
if (hasCapturedVisibleLayoutRef.current && !isInitialMeasurement) {
|
|
127
|
+
// captureLayout only records the target. The cache effect applies the
|
|
128
|
+
// animation during the render that releases the new glyph row.
|
|
129
|
+
markMeasurementReady(measurementKey);
|
|
130
|
+
}
|
|
131
|
+
}, [applyWidth, bootstrapFromProbe, enabled, markMeasurementReady, measurementKey]);
|
|
53
132
|
const cachedWidth = widthCacheRef.current.get(measurementKey);
|
|
54
133
|
|
|
55
134
|
// a cached width can restore the shell before the hidden probe renders again
|
|
56
|
-
|
|
57
|
-
if (enabled && cachedWidth !== undefined) {
|
|
135
|
+
useLayoutEffect(() => {
|
|
136
|
+
if (enabled && cachedWidth !== undefined && hasCapturedVisibleLayoutRef.current) {
|
|
58
137
|
// promote cache hits so active states stay available longer
|
|
59
138
|
widthCacheRef.current.delete(measurementKey);
|
|
60
139
|
widthCacheRef.current.set(measurementKey, cachedWidth);
|
|
61
140
|
applyWidth(cachedWidth);
|
|
141
|
+
markMeasurementReady(measurementKey);
|
|
142
|
+
}
|
|
143
|
+
}, [applyWidth, cachedWidth, enabled, markMeasurementReady, measurementKey]);
|
|
144
|
+
useEffect(() => () => {
|
|
145
|
+
if (bootstrapTimerRef.current !== null) {
|
|
146
|
+
clearTimeout(bootstrapTimerRef.current);
|
|
62
147
|
}
|
|
63
|
-
}, [
|
|
64
|
-
const animatedWidthStyle = useAnimatedStyle(() => enabled && hasBootstrappedWidth ? {
|
|
148
|
+
}, []);
|
|
149
|
+
const animatedWidthStyle = useAnimatedStyle(() => enabled && hasBootstrappedWidth.value ? {
|
|
65
150
|
width: widthValue.value
|
|
66
|
-
} : {}, [enabled
|
|
151
|
+
} : {}, [enabled]);
|
|
67
152
|
return {
|
|
68
153
|
captureLayout,
|
|
154
|
+
captureVisibleLayout,
|
|
69
155
|
animatedWidthStyle,
|
|
156
|
+
isReady: !enabled || cachedWidth !== undefined || readyMeasurementKey === measurementKey,
|
|
70
157
|
shouldMeasure: enabled && cachedWidth === undefined
|
|
71
158
|
};
|
|
72
159
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useRef","useState","useAnimatedStyle","useSharedValue","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","measuredWidthRef","bootstrappedRef","widthCacheRef","Map","
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useLayoutEffect","useRef","useState","useAnimatedStyle","useSharedValue","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","hasBootstrappedWidth","measuredWidthRef","bootstrappedRef","widthCacheRef","Map","hasCapturedVisibleLayoutRef","initialMeasurementKeyRef","firstProbeRef","latestProbeRef","bootstrapTimerRef","readyMeasurementKey","setReadyMeasurementKey","markMeasurementReady","key","currentKey","applyWidth","nextWidth","current","value","bootstrapFromProbe","firstProbe","width","latestProbe","captureVisibleLayout","event","clearTimeout","Math","max","nativeEvent","layout","delete","set","captureLayout","ceil","isInitialMeasurement","size","oldestKey","keys","next","undefined","probe","setTimeout","cachedWidth","get","animatedWidthStyle","isReady","shouldMeasure"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;AAAA,SACEA,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,yBAAyB;AAa1E,MAAMC,iBAAiB,GAAG,EAAE;;AAE5B;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,OAAO;EACPC,YAAY;EACZC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAGN,cAAc,CAAC,CAAC,CAAC;EACpC,MAAMO,oBAAoB,GAAGP,cAAc,CAAC,KAAK,CAAC;EAClD,MAAMQ,gBAAgB,GAAGX,MAAM,CAAgB,IAAI,CAAC;EACpD,MAAMY,eAAe,GAAGZ,MAAM,CAAC,KAAK,CAAC;EACrC,MAAMa,aAAa,GAAGb,MAAM,CAAC,IAAIc,GAAG,CAAiB,CAAC,CAAC;EACvD,MAAMC,2BAA2B,GAAGf,MAAM,CAAC,KAAK,CAAC;EACjD,MAAMgB,wBAAwB,GAAGhB,MAAM,CAAgB,IAAI,CAAC;EAC5D,MAAMiB,aAAa,GAAGjB,MAAM,CAAsB,IAAI,CAAC;EACvD,MAAMkB,cAAc,GAAGlB,MAAM,CAAsB,IAAI,CAAC;EACxD,MAAMmB,iBAAiB,GAAGnB,MAAM,CAAuC,IAAI,CAAC;EAC5E,MAAM,CAACoB,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGpB,QAAQ,CAC5D,IACF,CAAC;EAED,MAAMqB,oBAAoB,GAAGzB,WAAW,CAAE0B,GAAW,IAAK;IACxDF,sBAAsB,CAAEG,UAAU,IAChCA,UAAU,KAAKD,GAAG,GAAGC,UAAU,GAAGD,GACpC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA,MAAME,UAAU,GAAG5B,WAAW,CAC3B6B,SAAiB,IAAK;IAC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MACA;MACAd,aAAa,CAACc,OAAO,CAACa,MAAM,CAAChC,cAAc,CAAC;MAC5CK,aAAa,CAACc,OAAO,CAACc,GAAG,CAACjC,cAAc,EAAE4C,WAAW,CAAC;MACtD3B,UAAU,CAAC2B,WAAW,CAAC;MACvB9B,oBAAoB,CAACd,cAAc,CAAC;IACtC;EACF,CAAC,EAAE,CACDiB,UAAU,EACV2B,WAAW,EACX9C,OAAO,EACPgB,oBAAoB,EACpBd,cAAc,CACf,CAAC;EAEFV,SAAS,CACP,MAAM,MAAM;IACV,IAAIqB,iBAAiB,CAACQ,OAAO,KAAK,IAAI,EAAE;MACtCQ,YAAY,CAAChB,iBAAiB,CAACQ,OAAO,CAAC;IACzC;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAM2B,kBAAkB,GAAGpD,gBAAgB,CACzC,MACEI,OAAO,IAAII,oBAAoB,CAACkB,KAAK,GACjC;IACEG,KAAK,EAAEtB,UAAU,CAACmB;EACpB,CAAC,GACD,CAAC,CAAC,EACR,CAACtB,OAAO,CACV,CAAC;EAED,OAAO;IACLoC,aAAa;IACbT,oBAAoB;IACpBqB,kBAAkB;IAClBC,OAAO,EACL,CAACjD,OAAO,IACR8C,WAAW,KAAKH,SAAS,IACzB7B,mBAAmB,KAAKZ,cAAc;IACxCgD,aAAa,EAAElD,OAAO,IAAI8C,WAAW,KAAKH;EAC5C,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -3,25 +3,21 @@
|
|
|
3
3
|
import { useMemo, useRef } from "react";
|
|
4
4
|
import { normalizeDisplayUnit, splitDisplayUnits } from "../model/display-units.js";
|
|
5
5
|
import { reconcileTextGlyphKeys } from "../model/text-keys.js";
|
|
6
|
-
// build
|
|
6
|
+
// build text glyphs independently, then prepend a separately keyed leading token
|
|
7
7
|
export const useTextGlyphs = (value, namespace, leading, leadingKey) => {
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
...(
|
|
11
|
-
kind: "element",
|
|
12
|
-
signature: `leading:${String(leadingKey ?? "default")}`,
|
|
13
|
-
element: leading
|
|
14
|
-
}] : []), ...splitDisplayUnits(value).map(unit => ({
|
|
8
|
+
// Reconcile text independently so inserting/removing a leading token cannot
|
|
9
|
+
// change which repeated text glyphs the LCS ledger preserves.
|
|
10
|
+
const textUnits = useMemo(() => [...splitDisplayUnits(value).map(unit => ({
|
|
15
11
|
kind: "text",
|
|
16
12
|
signature: `text:${unit}`,
|
|
17
13
|
value: unit
|
|
18
|
-
}))], [
|
|
19
|
-
const signatures =
|
|
14
|
+
}))], [value]);
|
|
15
|
+
const signatures = textUnits.map(unit => unit.signature);
|
|
20
16
|
const ledgerRef = useRef({
|
|
21
17
|
previousValue: value,
|
|
22
18
|
previousSignatures: signatures,
|
|
23
|
-
glyphKeys:
|
|
24
|
-
nextSeed:
|
|
19
|
+
glyphKeys: textUnits.map((_, index) => `${namespace}:c${index}`),
|
|
20
|
+
nextSeed: textUnits.length
|
|
25
21
|
});
|
|
26
22
|
|
|
27
23
|
// reconcile only when a token signature changes so stable glyphs keep their views
|
|
@@ -37,15 +33,22 @@ export const useTextGlyphs = (value, namespace, leading, leadingKey) => {
|
|
|
37
33
|
}
|
|
38
34
|
const glyphKeys = ledgerRef.current.glyphKeys;
|
|
39
35
|
|
|
40
|
-
// normalize spaces at the edge where tokens become renderable glyphs
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
// normalize spaces at the edge where tokens become renderable glyphs, then
|
|
37
|
+
// prepend the leading token with an identity that is independent of text
|
|
38
|
+
return useMemo(() => {
|
|
39
|
+
const textGlyphs = textUnits.map((unit, index) => ({
|
|
40
|
+
id: glyphKeys[index],
|
|
41
|
+
kind: "text",
|
|
45
42
|
value: normalizeDisplayUnit(unit.value)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
}));
|
|
44
|
+
if (!leading) {
|
|
45
|
+
return textGlyphs;
|
|
46
|
+
}
|
|
47
|
+
return [{
|
|
48
|
+
id: `${namespace}:leading:${String(leadingKey ?? "default")}`,
|
|
49
|
+
kind: "element",
|
|
50
|
+
element: leading
|
|
51
|
+
}, ...textGlyphs];
|
|
52
|
+
}, [glyphKeys, leading, leadingKey, namespace, textUnits]);
|
|
50
53
|
};
|
|
51
54
|
//# sourceMappingURL=use-text-glyphs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useRef","normalizeDisplayUnit","splitDisplayUnits","reconcileTextGlyphKeys","useTextGlyphs","value","namespace","leading","leadingKey","
|
|
1
|
+
{"version":3,"names":["useMemo","useRef","normalizeDisplayUnit","splitDisplayUnits","reconcileTextGlyphKeys","useTextGlyphs","value","namespace","leading","leadingKey","textUnits","map","unit","kind","signature","signatures","ledgerRef","previousValue","previousSignatures","glyphKeys","_","index","nextSeed","length","current","some","nextLedger","textGlyphs","id","String","element"],"sourceRoot":"../../../src","sources":["hooks/use-text-glyphs.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,MAAM,QAAwB,OAAO;AACvD,SACEC,oBAAoB,EACpBC,iBAAiB,QACZ,2BAAwB;AAC/B,SAASC,sBAAsB,QAAQ,uBAAoB;AAgB3D;AACA,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,KAAa,EACbC,SAAiB,EACjBC,OAAmB,EACnBC,UAA4B,KACF;EAC1B;EACA;EACA,MAAMC,SAAS,GAAGV,OAAO,CACvB,MAAM,CACJ,GAAGG,iBAAiB,CAACG,KAAK,CAAC,CAACK,GAAG,CAAEC,IAAI,KAAM;IACzCC,IAAI,EAAE,MAAe;IACrBC,SAAS,EAAE,QAAQF,IAAI,EAAE;IACzBN,KAAK,EAAEM;EACT,CAAC,CAAC,CAAC,CACJ,EACD,CAACN,KAAK,CACR,CAAC;EACD,MAAMS,UAAU,GAAGL,SAAS,CAACC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACE,SAAS,CAAC;EAC1D,MAAME,SAAS,GAAGf,MAAM,CAAkB;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,EAAE;MACZ,OAAOmB,UAAU;IACnB;IAEA,OAAO,CACL;MACEC,EAAE,EAAE,GAAGrB,SAAS,YAAYsB,MAAM,CAACpB,UAAU,IAAI,SAAS,CAAC,EAAE;MAC7DI,IAAI,EAAE,SAAkB;MACxBiB,OAAO,EAAEtB;IACX,CAAC,EACD,GAAGmB,UAAU,CACd;EACH,CAAC,EACD,CAACR,SAAS,EAAEX,OAAO,EAAEC,UAAU,EAAEF,SAAS,EAAEG,SAAS,CACvD,CAAC;AACH,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -62,7 +62,9 @@ export const Laminar = /*#__PURE__*/React.memo(function Laminar({
|
|
|
62
62
|
}, [leadingGap, resolvedLeading, resolvedLeadingKey, resolvedValue, textStyle, variant]);
|
|
63
63
|
const {
|
|
64
64
|
captureLayout,
|
|
65
|
+
captureVisibleLayout,
|
|
65
66
|
animatedWidthStyle,
|
|
67
|
+
isReady: isAutoSizeReady,
|
|
66
68
|
shouldMeasure
|
|
67
69
|
} = useInlineAutoWidth({
|
|
68
70
|
enabled: autoSize,
|
|
@@ -82,6 +84,7 @@ export const Laminar = /*#__PURE__*/React.memo(function Laminar({
|
|
|
82
84
|
align: align,
|
|
83
85
|
containerStyle: containerStyle,
|
|
84
86
|
animatedWidthStyle: animatedWidthStyle,
|
|
87
|
+
onVisibleLayout: autoSize ? captureVisibleLayout : undefined,
|
|
85
88
|
measurement: shouldMeasure ? /*#__PURE__*/_jsxs(View, {
|
|
86
89
|
onLayout: captureLayout,
|
|
87
90
|
style: {
|
|
@@ -99,7 +102,7 @@ export const Laminar = /*#__PURE__*/React.memo(function Laminar({
|
|
|
99
102
|
style: textStyle,
|
|
100
103
|
children: normalizeDisplayUnit(unit)
|
|
101
104
|
}, `${unit}-${index}`))]
|
|
102
|
-
}) : undefined,
|
|
105
|
+
}, measurementKey) : undefined,
|
|
103
106
|
children: variant === "slots" ? /*#__PURE__*/_jsx(SlotsRun, {
|
|
104
107
|
value: resolvedValue,
|
|
105
108
|
motionRecipe: motionRecipe,
|
|
@@ -121,8 +124,10 @@ export const Laminar = /*#__PURE__*/React.memo(function Laminar({
|
|
|
121
124
|
motionRecipe: motionRecipe,
|
|
122
125
|
align: align,
|
|
123
126
|
leading: resolvedLeading,
|
|
127
|
+
leadingLayoutGroup: Boolean(leading),
|
|
124
128
|
leadingKey: resolvedLeadingKey,
|
|
125
129
|
leadingGap: leadingGap,
|
|
130
|
+
ready: !autoSize || isAutoSizeReady,
|
|
126
131
|
textStyle: textStyle,
|
|
127
132
|
className: className
|
|
128
133
|
})
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyleSheet","Text","View","useInlineAutoWidth","useMorphMotion","useMorphTextStyle","normalizeDisplayUnit","splitDisplayUnits","MorphViewport","NumberRun","SlotsRun","TextRun","jsx","_jsx","jsxs","_jsxs","Laminar","memo","text","variant","fontSize","color","align","className","leading","leadingKey","leadingGap","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","leadingMap","isLeadingMap","undefined","resolvedLeading","resolvedLeadingKey","motionRecipe","staggerMs","textStyle","measurementKey","useMemo","flattenedStyle","flatten","JSON","stringify","fontFamily","fontWeight","fontVariant","letterSpacing","lineHeight","textTransform","Boolean","captureLayout","animatedWidthStyle","shouldMeasure","enabled","driveToWidth","driveNumber","measuredValue","map","join","measurement","onLayout","flexDirection","alignSelf","children","alignItems","justifyContent","marginRight","unit","index","value","isValidElement","Array","isArray"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACrD,SAASC,kBAAkB,QAAQ,kCAA+B;AAClE,SAASC,cAAc,QAAQ,6BAA0B;AACzD,SAASC,iBAAiB,QAAQ,iCAA8B;AAChE,SACEC,oBAAoB,EACpBC,iBAAiB,QACZ,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AACgD,OAAO,CAACJ,SAAS,CAAC;IAEpD,OAAOK,IAAI,CAACC,SAAS,CAAC,CACpBf,aAAa,EACbY,cAAc,EAAEI,UAAU,EAC1BJ,cAAc,EAAE3B,QAAQ,EACxB2B,cAAc,EAAElB,SAAS,EACzBkB,cAAc,EAAEK,UAAU,EAC1BL,cAAc,EAAEM,WAAW,EAC3BN,cAAc,EAAEO,aAAa,EAC7BP,cAAc,EAAEQ,UAAU,EAC1BR,cAAc,EAAES,aAAa,EAC7BrC,OAAO,KAAK,MAAM,IAAIsC,OAAO,CAACjB,eAAe,CAAC,EAC9CrB,OAAO,KAAK,MAAM,GAAGsB,kBAAkB,GAAGF,SAAS,EACnDpB,OAAO,KAAK,MAAM,GAAGO,UAAU,GAAG,CAAC,CACpC,CAAC;EACJ,CAAC,EAAE,CACDA,UAAU,EACVc,eAAe,EACfC,kBAAkB,EAClBN,aAAa,EACbS,SAAS,EACTzB,OAAO,CACR,CAAC;EACF,MAAM;
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","Text","View","useInlineAutoWidth","useMorphMotion","useMorphTextStyle","normalizeDisplayUnit","splitDisplayUnits","MorphViewport","NumberRun","SlotsRun","TextRun","jsx","_jsx","jsxs","_jsxs","Laminar","memo","text","variant","fontSize","color","align","className","leading","leadingKey","leadingGap","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","leadingMap","isLeadingMap","undefined","resolvedLeading","resolvedLeadingKey","motionRecipe","staggerMs","textStyle","measurementKey","useMemo","flattenedStyle","flatten","JSON","stringify","fontFamily","fontWeight","fontVariant","letterSpacing","lineHeight","textTransform","Boolean","captureLayout","captureVisibleLayout","animatedWidthStyle","isReady","isAutoSizeReady","shouldMeasure","enabled","driveToWidth","driveNumber","measuredValue","map","join","onVisibleLayout","measurement","onLayout","flexDirection","alignSelf","children","alignItems","justifyContent","marginRight","unit","index","value","leadingLayoutGroup","ready","isValidElement","Array","isArray"],"sourceRoot":"../../src","sources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AAEA,SAAU;MACrBD,SAAS,EAAEA,SAAU;MACrBpB,SAAS,EAAEA;IAAU,CACtB,CAAC,GACAJ,OAAO,KAAK,QAAQ,gBACtBN,IAAA,CAACJ,SAAS;MACRwE,KAAK,EAAE9C,aAAc;MACrBO,YAAY,EAAEA,YAAa;MAC3BpB,KAAK,EAAEA,KAAM;MACbF,QAAQ,EAAEA,QAAS;MACnBwB,SAAS,EAAEA,SAAU;MACrBD,SAAS,EAAEA,SAAU;MACrBpB,SAAS,EAAEA;IAAU,CACtB,CAAC,gBAEFV,IAAA,CAACF,OAAO;MACNsE,KAAK,EAAE9C,aAAc;MACrBO,YAAY,EAAEA,YAAa;MAC3BpB,KAAK,EAAEA,KAAM;MACbE,OAAO,EAAEgB,eAAgB;MACzB0C,kBAAkB,EAAEzB,OAAO,CAACjC,OAAO,CAAE;MACrCC,UAAU,EAAEgB,kBAAmB;MAC/Bf,UAAU,EAAEA,UAAW;MACvByD,KAAK,EAAE,CAAClD,QAAQ,IAAI6B,eAAgB;MACpClB,SAAS,EAAEA,SAAU;MACrBrB,SAAS,EAAEA;IAAU,CACtB;EACJ,CACY,CAAC;AAElB,CAAC,CAAC;AAEJ,SAASe,YAAYA,CACnB2C,KAAmC,EACP;EAC5B;EACA,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,eAAClF,KAAK,CAACqF,cAAc,CAACH,KAAK,CAAC,IAC5B,CAACI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC;AAEzB","ignoreList":[]}
|
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import Animated from "react-native-reanimated";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
const rowStyle = {
|
|
8
8
|
flexDirection: "row",
|
|
9
9
|
alignItems: "center",
|
|
10
10
|
alignSelf: "flex-start"
|
|
11
11
|
};
|
|
12
|
+
const textRowStyle = {
|
|
13
|
+
flexDirection: "row",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
alignSelf: "flex-start"
|
|
16
|
+
};
|
|
12
17
|
const rowAlignStyles = {
|
|
13
18
|
left: {
|
|
14
19
|
alignSelf: "flex-start"
|
|
@@ -25,6 +30,8 @@ const rowAlignStyles = {
|
|
|
25
30
|
export const GlyphRun = /*#__PURE__*/React.memo(({
|
|
26
31
|
glyphs,
|
|
27
32
|
layoutTransition,
|
|
33
|
+
leadingLayoutTransition,
|
|
34
|
+
leadingLayoutGroup = false,
|
|
28
35
|
enterTransition,
|
|
29
36
|
elementEnterTransition,
|
|
30
37
|
exitTransition,
|
|
@@ -33,30 +40,42 @@ export const GlyphRun = /*#__PURE__*/React.memo(({
|
|
|
33
40
|
align,
|
|
34
41
|
textStyle,
|
|
35
42
|
className
|
|
36
|
-
}) =>
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
entering: elementEnterTransition ?? enterTransition,
|
|
44
|
-
exiting: elementExitTransition ?? exitTransition,
|
|
45
|
-
style: [{
|
|
46
|
-
alignItems: "center",
|
|
47
|
-
justifyContent: "center"
|
|
48
|
-
}, glyphIndex === 0 && (leadingGap ?? 0) > 0 ? {
|
|
49
|
-
marginRight: leadingGap
|
|
50
|
-
} : undefined],
|
|
51
|
-
children: glyph.element
|
|
52
|
-
}, glyph.id) : /*#__PURE__*/_jsx(Animated.Text, {
|
|
43
|
+
}) => {
|
|
44
|
+
// The leading token is always first. Keep it outside the text row so its
|
|
45
|
+
// appearance moves the text as one unit instead of reflowing every glyph.
|
|
46
|
+
const leadingGlyph = glyphs[0]?.kind === "element" ? glyphs[0] : undefined;
|
|
47
|
+
const textGlyphs = leadingGlyph ? glyphs.slice(1) : glyphs;
|
|
48
|
+
const shouldGroupText = Boolean(leadingGlyph) || Boolean(leadingLayoutTransition) || leadingLayoutGroup;
|
|
49
|
+
const renderTextGlyph = glyph => glyph.kind === "text" ? /*#__PURE__*/_jsx(Animated.Text, {
|
|
53
50
|
layout: layoutTransition,
|
|
54
51
|
entering: enterTransition,
|
|
55
52
|
exiting: exitTransition,
|
|
56
53
|
style: textStyle,
|
|
57
54
|
className: className,
|
|
58
55
|
children: glyph.value
|
|
59
|
-
}, glyph.id)
|
|
60
|
-
|
|
56
|
+
}, glyph.id) : null;
|
|
57
|
+
const textRow = /*#__PURE__*/_jsx(Animated.View, {
|
|
58
|
+
layout: leadingLayoutTransition,
|
|
59
|
+
style: textRowStyle,
|
|
60
|
+
children: textGlyphs.map(renderTextGlyph)
|
|
61
|
+
}, "text-row");
|
|
62
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
63
|
+
style: [rowStyle, rowAlignStyles[align]],
|
|
64
|
+
children: [leadingGlyph ? /*#__PURE__*/_jsx(Animated.View, {
|
|
65
|
+
// leading elements own their enter/exit geometry; generic layout
|
|
66
|
+
// motion here would compete with those transitions
|
|
67
|
+
layout: undefined,
|
|
68
|
+
entering: elementEnterTransition ?? enterTransition,
|
|
69
|
+
exiting: elementExitTransition ?? exitTransition,
|
|
70
|
+
style: [{
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
justifyContent: "center"
|
|
73
|
+
}, (leadingGap ?? 0) > 0 ? {
|
|
74
|
+
marginRight: leadingGap
|
|
75
|
+
} : undefined],
|
|
76
|
+
children: leadingGlyph.element
|
|
77
|
+
}, leadingGlyph.id) : null, shouldGroupText ? textRow : textGlyphs.map(renderTextGlyph)]
|
|
78
|
+
});
|
|
79
|
+
});
|
|
61
80
|
GlyphRun.displayName = "GlyphRun";
|
|
62
81
|
//# sourceMappingURL=glyph-run.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","Animated","jsx","_jsx","rowStyle","flexDirection","alignItems","alignSelf","rowAlignStyles","left","center","right","GlyphRun","memo","glyphs","layoutTransition","enterTransition","elementEnterTransition","exitTransition","elementExitTransition","leadingGap","align","textStyle","className","
|
|
1
|
+
{"version":3,"names":["React","View","Animated","jsx","_jsx","jsxs","_jsxs","rowStyle","flexDirection","alignItems","alignSelf","textRowStyle","rowAlignStyles","left","center","right","GlyphRun","memo","glyphs","layoutTransition","leadingLayoutTransition","leadingLayoutGroup","enterTransition","elementEnterTransition","exitTransition","elementExitTransition","leadingGap","align","textStyle","className","leadingGlyph","kind","undefined","textGlyphs","slice","shouldGroupText","Boolean","renderTextGlyph","glyph","Text","layout","entering","exiting","style","children","value","id","textRow","map","justifyContent","marginRight","element","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,EAAAC,IAAA,IAAAC,KAAA;AAO/C,MAAMC,QAAQ,GAAG;EACfC,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,YAAY,GAAG;EACnBH,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAME,cAAc,GAAG;EACrBC,IAAI,EAAE;IAAEH,SAAS,EAAE;EAAa,CAAC;EACjCI,MAAM,EAAE;IAAEJ,SAAS,EAAE;EAAS,CAAC;EAC/BK,KAAK,EAAE;IAAEL,SAAS,EAAE;EAAW;AACjC,CAAU;;AAEV;AACA,OAAO,MAAMM,QAAQ,gBAAGhB,KAAK,CAACiB,IAAI,CAChC,CAAC;EACCC,MAAM;EACNC,gBAAgB;EAChBC,uBAAuB;EACvBC,kBAAkB,GAAG,KAAK;EAC1BC,eAAe;EACfC,sBAAsB;EACtBC,cAAc;EACdC,qBAAqB;EACrBC,UAAU;EACVC,KAAK;EACLC,SAAS;EACTC;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;QAAEwC,cAAc,EAAE;MAAS,CAAC,EAClD,CAACvB,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG;QAAEwB,WAAW,EAAExB;MAAW,CAAC,GAAGM,SAAS,CAC/D;MAAAY,QAAA,EAEDd,YAAY,CAACqB;IAAO,GAXhBrB,YAAY,CAACgB,EAYL,CAAC,GACd,IAAI,EACPX,eAAe,GAAGY,OAAO,GAAGd,UAAU,CAACe,GAAG,CAACX,eAAe,CAAC;EAAA,CACxD,CAAC;AAEX,CACF,CAAC;AAEDrB,QAAQ,CAACoC,WAAW,GAAG,UAAU","ignoreList":[]}
|
|
@@ -57,6 +57,7 @@ export const MorphViewport = /*#__PURE__*/React.memo(({
|
|
|
57
57
|
align,
|
|
58
58
|
containerStyle,
|
|
59
59
|
animatedWidthStyle,
|
|
60
|
+
onVisibleLayout,
|
|
60
61
|
measurement,
|
|
61
62
|
children
|
|
62
63
|
}) => {
|
|
@@ -75,6 +76,7 @@ export const MorphViewport = /*#__PURE__*/React.memo(({
|
|
|
75
76
|
style: measuredContentStyle,
|
|
76
77
|
children: measurement
|
|
77
78
|
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
79
|
+
onLayout: onVisibleLayout,
|
|
78
80
|
style: [resolvedViewportStyle, animatedWidthStyle],
|
|
79
81
|
children: children
|
|
80
82
|
})]
|
|
@@ -1 +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","fullWidthViewportStyle","width","shellAlignStyles","center","right","viewportAlignStyles","alignItems","MorphViewport","memo","autoSize","clipToBounds","align","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;AAG/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;AAED,MAAME,sBAAiC,GAAG;EACxCC,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,gBAAiD,GAAG;EACxDT,IAAI,EAAE;IAAEH,SAAS,EAAE;EAAa,CAAC;EACjCa,MAAM,EAAE;IAAEb,SAAS,EAAE;EAAS,CAAC;EAC/Bc,KAAK,EAAE;IAAEd,SAAS,EAAE;EAAW;AACjC,CAAC;AAED,MAAMe,mBAAoD,GAAG;EAC3DZ,IAAI,EAAE;IAAEa,UAAU,EAAE;EAAa,CAAC;EAClCH,MAAM,EAAE;IAAEG,UAAU,EAAE;EAAS,CAAC;EAChCF,KAAK,EAAE;IAAEE,UAAU,EAAE;EAAW;AAClC,CAAC;
|
|
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","fullWidthViewportStyle","width","shellAlignStyles","center","right","viewportAlignStyles","alignItems","MorphViewport","memo","autoSize","clipToBounds","align","containerStyle","animatedWidthStyle","onVisibleLayout","measurement","children","resolvedViewportStyle","style","accessibilityElementsHidden","collapsable","importantForAccessibility","pointerEvents","onLayout","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;AAG/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;AAED,MAAME,sBAAiC,GAAG;EACxCC,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,gBAAiD,GAAG;EACxDT,IAAI,EAAE;IAAEH,SAAS,EAAE;EAAa,CAAC;EACjCa,MAAM,EAAE;IAAEb,SAAS,EAAE;EAAS,CAAC;EAC/Bc,KAAK,EAAE;IAAEd,SAAS,EAAE;EAAW;AACjC,CAAC;AAED,MAAMe,mBAAoD,GAAG;EAC3DZ,IAAI,EAAE;IAAEa,UAAU,EAAE;EAAa,CAAC;EAClCH,MAAM,EAAE;IAAEG,UAAU,EAAE;EAAS,CAAC;EAChCF,KAAK,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URE__*/React.memo(({
|
|
|
12
12
|
motionRecipe,
|
|
13
13
|
align,
|
|
14
14
|
leading,
|
|
15
|
+
leadingLayoutGroup = false,
|
|
15
16
|
leadingKey,
|
|
16
17
|
leadingGap = 0,
|
|
18
|
+
ready = true,
|
|
17
19
|
textStyle,
|
|
18
20
|
className
|
|
19
21
|
}) => {
|
|
20
22
|
// namespace ids per instance so repeated strings do not collide
|
|
21
23
|
const scopeId = useId();
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
24
|
+
const hasDisplayedRef = useRef(false);
|
|
25
|
+
const displayedValueRef = useRef(value);
|
|
26
|
+
const displayedLeadingRef = useRef(leading);
|
|
27
|
+
const displayedLeadingKeyRef = useRef(leadingKey);
|
|
28
|
+
const displayedLeadingGapRef = useRef(leadingGap);
|
|
29
|
+
const shouldDisplayTarget = ready || !hasDisplayedRef.current;
|
|
30
|
+
const visibleValue = shouldDisplayTarget ? value : displayedValueRef.current;
|
|
31
|
+
const visibleLeading = shouldDisplayTarget ? leading : displayedLeadingRef.current;
|
|
32
|
+
const visibleLeadingKey = shouldDisplayTarget ? leadingKey : displayedLeadingKeyRef.current;
|
|
33
|
+
const visibleLeadingGap = shouldDisplayTarget ? leadingGap : displayedLeadingGapRef.current;
|
|
34
|
+
if (shouldDisplayTarget) {
|
|
35
|
+
hasDisplayedRef.current = true;
|
|
36
|
+
displayedValueRef.current = value;
|
|
37
|
+
displayedLeadingRef.current = leading;
|
|
38
|
+
displayedLeadingKeyRef.current = leadingKey;
|
|
39
|
+
displayedLeadingGapRef.current = leadingGap;
|
|
40
|
+
}
|
|
41
|
+
const lastValueRef = useRef(visibleValue);
|
|
42
|
+
const lastLeadingPresenceRef = useRef(Boolean(visibleLeading));
|
|
43
|
+
const lastLeadingKeyRef = useRef(visibleLeadingKey);
|
|
25
44
|
const hasAnimatedRef = useRef(false);
|
|
26
|
-
const isLeadingSwap = Boolean(
|
|
45
|
+
const isLeadingSwap = Boolean(visibleLeading) && lastLeadingPresenceRef.current && visibleLeadingKey !== lastLeadingKeyRef.current;
|
|
46
|
+
const isLeadingChange = Boolean(visibleLeading) !== lastLeadingPresenceRef.current || Boolean(visibleLeading) && visibleLeadingKey !== lastLeadingKeyRef.current;
|
|
27
47
|
// update the worklet flag after commit so render never writes a shared value
|
|
28
48
|
const leadingSwapProgress = useSharedValue(0);
|
|
29
49
|
useLayoutEffect(() => {
|
|
30
50
|
leadingSwapProgress.value = isLeadingSwap ? 1 : 0;
|
|
31
51
|
}, [isLeadingSwap, leadingSwapProgress]);
|
|
32
|
-
const glyphs = useTextGlyphs(
|
|
52
|
+
const glyphs = useTextGlyphs(visibleValue, scopeId, visibleLeading, visibleLeadingKey);
|
|
33
53
|
const elementEnterTransition = useMemo(() => createLeadingEnterTransition({
|
|
34
54
|
durationMs: motionRecipe.durationMs,
|
|
35
55
|
easing: motionRecipe.easing
|
|
@@ -37,26 +57,28 @@ export const TextRun = /*#__PURE__*/React.memo(({
|
|
|
37
57
|
const elementExitTransition = useMemo(() => createLeadingExitTransition({
|
|
38
58
|
durationMs: motionRecipe.durationMs,
|
|
39
59
|
easing: motionRecipe.easing,
|
|
40
|
-
leadingGap,
|
|
60
|
+
leadingGap: visibleLeadingGap,
|
|
41
61
|
scale: leadingSwapProgress
|
|
42
|
-
}), [
|
|
62
|
+
}), [visibleLeadingGap, leadingSwapProgress, motionRecipe.durationMs, motionRecipe.easing]);
|
|
43
63
|
|
|
44
64
|
// mark the first value as settled and later changes as eligible for motion
|
|
45
|
-
if (
|
|
65
|
+
if (visibleValue !== lastValueRef.current || Boolean(visibleLeading) !== lastLeadingPresenceRef.current || visibleLeadingKey !== lastLeadingKeyRef.current) {
|
|
46
66
|
hasAnimatedRef.current = true;
|
|
47
|
-
lastValueRef.current =
|
|
48
|
-
lastLeadingPresenceRef.current = Boolean(
|
|
49
|
-
lastLeadingKeyRef.current =
|
|
67
|
+
lastValueRef.current = visibleValue;
|
|
68
|
+
lastLeadingPresenceRef.current = Boolean(visibleLeading);
|
|
69
|
+
lastLeadingKeyRef.current = visibleLeadingKey;
|
|
50
70
|
}
|
|
51
71
|
const hasAnimated = hasAnimatedRef.current;
|
|
52
72
|
return /*#__PURE__*/_jsx(GlyphRun, {
|
|
53
73
|
glyphs: glyphs,
|
|
54
74
|
layoutTransition: hasAnimated ? motionRecipe.layoutTransition : undefined,
|
|
75
|
+
leadingLayoutTransition: isLeadingChange ? motionRecipe.layoutTransition : undefined,
|
|
76
|
+
leadingLayoutGroup: leadingLayoutGroup,
|
|
55
77
|
enterTransition: hasAnimatedRef.current ? motionRecipe.enterTransition : undefined,
|
|
56
78
|
elementEnterTransition: isLeadingSwap ? elementEnterTransition : undefined,
|
|
57
79
|
exitTransition: motionRecipe.exitTransition,
|
|
58
80
|
elementExitTransition: elementExitTransition,
|
|
59
|
-
leadingGap:
|
|
81
|
+
leadingGap: visibleLeadingGap,
|
|
60
82
|
align: align,
|
|
61
83
|
textStyle: textStyle,
|
|
62
84
|
className: className
|