@grahlnn/comps 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -3701,6 +3701,9 @@ function resolveActivationBootstrapText(isActivated, previousText, nextText) {
|
|
|
3701
3701
|
}
|
|
3702
3702
|
return null;
|
|
3703
3703
|
}
|
|
3704
|
+
function shouldDeferTargetMeasurement(committedMeasurement, pendingBootstrapText, text) {
|
|
3705
|
+
return committedMeasurement === null && pendingBootstrapText !== null && pendingBootstrapText !== text;
|
|
3706
|
+
}
|
|
3704
3707
|
function getOverlayStyle(plan) {
|
|
3705
3708
|
return {
|
|
3706
3709
|
...OVERLAY_STYLE,
|
|
@@ -3806,17 +3809,23 @@ function useMorphTransition(text, className, bootstrapText = null) {
|
|
|
3806
3809
|
if (sessionRef.current.animating) {
|
|
3807
3810
|
measurementHint = sessionRef.current.target ?? sessionRef.current.committed;
|
|
3808
3811
|
}
|
|
3809
|
-
const measurementRequest = useMemo(() => createMorphMeasurementRequest({
|
|
3810
|
-
text,
|
|
3811
|
-
layoutContext,
|
|
3812
|
-
layoutHint: measurementHint
|
|
3813
|
-
}), [text, layoutContext, measurementHint]);
|
|
3814
3812
|
let pendingBootstrapText = null;
|
|
3815
3813
|
if (sessionRef.current.committed === null) {
|
|
3816
3814
|
pendingBootstrapText = pendingBootstrapTextRef.current;
|
|
3817
3815
|
}
|
|
3816
|
+
const isBootstrapping = shouldDeferTargetMeasurement(sessionRef.current.committed, pendingBootstrapText, text);
|
|
3817
|
+
const measurementRequest = useMemo(() => {
|
|
3818
|
+
if (isBootstrapping) {
|
|
3819
|
+
return null;
|
|
3820
|
+
}
|
|
3821
|
+
return createMorphMeasurementRequest({
|
|
3822
|
+
text,
|
|
3823
|
+
layoutContext,
|
|
3824
|
+
layoutHint: measurementHint
|
|
3825
|
+
});
|
|
3826
|
+
}, [text, layoutContext, measurementHint, isBootstrapping]);
|
|
3818
3827
|
const bootstrapMeasurementRequest = useMemo(() => {
|
|
3819
|
-
if (pendingBootstrapText === null) {
|
|
3828
|
+
if (!isBootstrapping || pendingBootstrapText === null) {
|
|
3820
3829
|
return null;
|
|
3821
3830
|
}
|
|
3822
3831
|
return createMorphMeasurementRequest({
|
|
@@ -3824,7 +3833,7 @@ function useMorphTransition(text, className, bootstrapText = null) {
|
|
|
3824
3833
|
layoutContext,
|
|
3825
3834
|
layoutHint: null
|
|
3826
3835
|
});
|
|
3827
|
-
}, [pendingBootstrapText, layoutContext]);
|
|
3836
|
+
}, [pendingBootstrapText, layoutContext, isBootstrapping]);
|
|
3828
3837
|
const renderText = measurementRequest?.renderText ?? text;
|
|
3829
3838
|
const useContentInlineSize = measurementRequest?.useContentInlineSize ?? false;
|
|
3830
3839
|
const measurementBackend = measurementRequest?.measurementBackend ?? null;
|
|
@@ -3852,7 +3861,7 @@ function useMorphTransition(text, className, bootstrapText = null) {
|
|
|
3852
3861
|
});
|
|
3853
3862
|
return;
|
|
3854
3863
|
}
|
|
3855
|
-
if (
|
|
3864
|
+
if (isBootstrapping && bootstrapMeasurementRequest !== null) {
|
|
3856
3865
|
let bootstrapDomSnapshot = null;
|
|
3857
3866
|
if (bootstrapMeasurementRequest.domMeasurementKey !== null && canCacheMeasurementLayerSnapshot(bootstrapMeasurementRequest.measurementBackend)) {
|
|
3858
3867
|
bootstrapDomSnapshot = readCachedMorphSnapshot(domMeasurementSnapshotCacheRef.current, bootstrapMeasurementRequest.domMeasurementKey);
|
|
@@ -3968,6 +3977,7 @@ function useMorphTransition(text, className, bootstrapText = null) {
|
|
|
3968
3977
|
layoutContext,
|
|
3969
3978
|
measurementBackend,
|
|
3970
3979
|
measurementRequest,
|
|
3980
|
+
isBootstrapping,
|
|
3971
3981
|
pendingBootstrapText,
|
|
3972
3982
|
bootstrapMeasurementRequest,
|
|
3973
3983
|
domMeasurementKey,
|
|
@@ -4121,6 +4131,7 @@ function Torph({
|
|
|
4121
4131
|
}
|
|
4122
4132
|
export {
|
|
4123
4133
|
supportsIntrinsicWidthLock,
|
|
4134
|
+
shouldDeferTargetMeasurement,
|
|
4124
4135
|
resolveVisibleFlowText,
|
|
4125
4136
|
resolveMorphFrameBounds,
|
|
4126
4137
|
resolveFlowText,
|
|
@@ -97,6 +97,7 @@ export declare function getMeasurementLayerStyle(layoutContext: LayoutContext |
|
|
|
97
97
|
export declare function resolveFlowText(committedMeasurement: MorphMeasurement | null, stateMeasurement: MorphMeasurement | null, text: string): string;
|
|
98
98
|
export declare function resolveVisibleFlowText(pendingBootstrapText: string | null, committedMeasurement: MorphMeasurement | null, stateMeasurement: MorphMeasurement | null, text: string): string;
|
|
99
99
|
export declare function resolveActivationBootstrapText(isActivated: boolean, previousText: string, nextText: string): string | null;
|
|
100
|
+
export declare function shouldDeferTargetMeasurement(committedMeasurement: MorphMeasurement | null, pendingBootstrapText: string | null, text: string): boolean;
|
|
100
101
|
export declare function Torph({ text, className, }: {
|
|
101
102
|
text: string;
|
|
102
103
|
className?: string;
|