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
package/README.md
CHANGED
|
@@ -73,6 +73,35 @@ export default function Counter() {
|
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
### Slots
|
|
77
|
+
|
|
78
|
+
Use `variant="slots"` when each digit should roll through a vertical reel.
|
|
79
|
+
Prefixes and separators remain ordinary text content.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import React, { useState } from "react";
|
|
83
|
+
import { Button, View } from "react-native";
|
|
84
|
+
import { Laminar } from "react-native-laminar";
|
|
85
|
+
|
|
86
|
+
export default function SlotCounter() {
|
|
87
|
+
const [value, setValue] = useState("07:42");
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View style={{ alignItems: "center", gap: 16 }}>
|
|
91
|
+
<Laminar
|
|
92
|
+
text={value}
|
|
93
|
+
variant="slots"
|
|
94
|
+
fontSize={48}
|
|
95
|
+
animationPreset="snappy"
|
|
96
|
+
clipToBounds
|
|
97
|
+
style={{ color: "#000000", fontVariant: ["tabular-nums"] }}
|
|
98
|
+
/>
|
|
99
|
+
<Button title="Change" onPress={() => setValue("08:15")} />
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
76
105
|
### Inside a button with auto-sizing
|
|
77
106
|
|
|
78
107
|
```tsx
|
|
@@ -86,6 +115,43 @@ export default function Counter() {
|
|
|
86
115
|
</Pressable>
|
|
87
116
|
```
|
|
88
117
|
|
|
118
|
+
### Auto-sized button with leading icons
|
|
119
|
+
|
|
120
|
+
Pass a text-keyed `leading` map when the button changes between visual states.
|
|
121
|
+
Laminar selects the matching entry and animates icon-to-icon replacements.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { ActivityIndicator, Pressable, Text } from "react-native";
|
|
125
|
+
import { Laminar } from "react-native-laminar";
|
|
126
|
+
|
|
127
|
+
const leading = {
|
|
128
|
+
"Sending Request": <ActivityIndicator color="#ffffff" />,
|
|
129
|
+
"Request Sent!": <Text style={{ color: "#ffffff", fontSize: 20 }}>✓</Text>,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
<Pressable
|
|
133
|
+
style={{
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
backgroundColor: "#007aff",
|
|
136
|
+
borderRadius: 36,
|
|
137
|
+
justifyContent: "center",
|
|
138
|
+
paddingHorizontal: 24,
|
|
139
|
+
paddingVertical: 12,
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<Laminar
|
|
143
|
+
text={status}
|
|
144
|
+
leading={leading}
|
|
145
|
+
leadingGap={5}
|
|
146
|
+
autoSize
|
|
147
|
+
style={{ color: "#ffffff", fontSize: 18, fontWeight: "700" }}
|
|
148
|
+
/>
|
|
149
|
+
</Pressable>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The map key must match the current `text` value. A missing entry means no
|
|
153
|
+
leading element, so the icon fades out when the button returns to a plain label.
|
|
154
|
+
|
|
89
155
|
### Centered text in a fixed-width container
|
|
90
156
|
|
|
91
157
|
Use `align` when the parent owns the width and Laminar should place the animated row inside that space.
|
|
@@ -134,10 +200,13 @@ Use `autoSize={false}` when the parent already defines the space and you only wa
|
|
|
134
200
|
```ts
|
|
135
201
|
type LaminarProps = {
|
|
136
202
|
text: string | number;
|
|
137
|
-
variant?: "text" | "number";
|
|
203
|
+
variant?: "text" | "number" | "slots";
|
|
138
204
|
fontSize?: number;
|
|
139
205
|
color?: string;
|
|
140
206
|
align?: "left" | "center" | "right";
|
|
207
|
+
leading?: ReactNode | Readonly<Record<string, ReactNode>>;
|
|
208
|
+
leadingKey?: string | number;
|
|
209
|
+
leadingGap?: number;
|
|
141
210
|
style?: StyleProp<TextStyle>;
|
|
142
211
|
containerStyle?: StyleProp<ViewStyle>;
|
|
143
212
|
fontStyle?: StyleProp<TextStyle>;
|
|
@@ -152,10 +221,13 @@ type LaminarProps = {
|
|
|
152
221
|
| Prop | Default | Description |
|
|
153
222
|
| ------------------- | ------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
154
223
|
| `text` | Required | The value to display. Numbers are converted to strings internally. |
|
|
155
|
-
| `variant` | `"text"` | `"text"` uses LCS glyph reconciliation. `"number"` uses right-aligned digit lanes. |
|
|
224
|
+
| `variant` | `"text"` | `"text"` uses LCS glyph reconciliation. `"number"` uses right-aligned digit lanes. `"slots"` rolls digits through slot columns using the same lanes. |
|
|
156
225
|
| `fontSize` | Undefined | Convenience prop merged into the text style. |
|
|
157
226
|
| `color` | Undefined | Convenience prop merged into the text style. |
|
|
158
227
|
| `align` | `"left"` | Visual alignment for Laminar's viewport and animated glyph row. |
|
|
228
|
+
| `leading` | Undefined | Optional inline element, or text-keyed leading content, rendered in text mode. |
|
|
229
|
+
| `leadingKey` | Undefined | Advanced identity override for a direct leading element. |
|
|
230
|
+
| `leadingGap` | `0` | Spacing between the leading element and the first text glyph. |
|
|
159
231
|
| `style` | Undefined | Text style applied after `fontSize` and `color`. |
|
|
160
232
|
| `containerStyle` | Undefined | Advanced style override for the outer viewport shell. |
|
|
161
233
|
| `fontStyle` | Undefined | Additional text style merged before `style`. |
|
|
@@ -179,6 +251,7 @@ type LaminarProps = {
|
|
|
179
251
|
```tsx
|
|
180
252
|
<Laminar text={word} animationPreset="smooth" />
|
|
181
253
|
<Laminar text={count} variant="number" animationPreset="snappy" />
|
|
254
|
+
<Laminar text={count} variant="slots" animationPreset="snappy" />
|
|
182
255
|
|
|
183
256
|
// Override duration
|
|
184
257
|
<Laminar text={word} animationPreset="default" animationDuration={520} />
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useDisplayUnits = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _displayUnits = require("../model/display-units");
|
|
9
|
+
// normalize the same units used by rendering before measurement reads them
|
|
9
10
|
const useDisplayUnits = (value, enabled = true) => (0, _react.useMemo)(() =>
|
|
10
11
|
// skip unit work when auto size is off
|
|
11
12
|
enabled ? (0, _displayUnits.splitDisplayUnits)(value).map(_displayUnits.normalizeDisplayUnit) : [], [enabled, value]);
|
|
@@ -1 +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;
|
|
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;AAKA;AACO,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":[]}
|
|
@@ -6,25 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useInlineAutoWidth = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
const WIDTH_CACHE_LIMIT = 64;
|
|
10
|
+
|
|
11
|
+
// measure each content signature once and drive later changes through one width value
|
|
9
12
|
const useInlineAutoWidth = ({
|
|
10
13
|
enabled,
|
|
11
|
-
driveToWidth
|
|
14
|
+
driveToWidth,
|
|
15
|
+
measurementKey
|
|
12
16
|
}) => {
|
|
13
17
|
const widthValue = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
14
18
|
const measuredWidthRef = (0, _react.useRef)(null);
|
|
15
19
|
const bootstrappedRef = (0, _react.useRef)(false);
|
|
20
|
+
const widthCacheRef = (0, _react.useRef)(new Map());
|
|
16
21
|
const [hasBootstrappedWidth, setHasBootstrappedWidth] = (0, _react.useState)(false);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
|
|
22
|
+
|
|
23
|
+
// the first measurement establishes the shell without animating from zero
|
|
24
|
+
const applyWidth = (0, _react.useCallback)(nextWidth => {
|
|
22
25
|
if (measuredWidthRef.current === nextWidth) {
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
28
|
measuredWidthRef.current = nextWidth;
|
|
26
|
-
|
|
27
|
-
// snap the first width so mount does not animate from zero
|
|
28
29
|
if (!bootstrappedRef.current) {
|
|
29
30
|
bootstrappedRef.current = true;
|
|
30
31
|
widthValue.value = nextWidth;
|
|
@@ -32,13 +33,45 @@ const useInlineAutoWidth = ({
|
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
widthValue.value = driveToWidth(nextWidth);
|
|
35
|
-
}, [driveToWidth,
|
|
36
|
+
}, [driveToWidth, widthValue]);
|
|
37
|
+
const captureLayout = (0, _react.useCallback)(event => {
|
|
38
|
+
if (!enabled) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// round up so fractional native measurements cannot clip the final glyph
|
|
43
|
+
const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
|
|
44
|
+
|
|
45
|
+
// delete before setting so a repeated key moves to the most recent position
|
|
46
|
+
widthCacheRef.current.delete(measurementKey);
|
|
47
|
+
if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
|
|
48
|
+
// map insertion order gives the lru entry at the front
|
|
49
|
+
const oldestKey = widthCacheRef.current.keys().next().value;
|
|
50
|
+
if (oldestKey !== undefined) {
|
|
51
|
+
widthCacheRef.current.delete(oldestKey);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
widthCacheRef.current.set(measurementKey, nextWidth);
|
|
55
|
+
applyWidth(nextWidth);
|
|
56
|
+
}, [applyWidth, enabled, measurementKey]);
|
|
57
|
+
const cachedWidth = widthCacheRef.current.get(measurementKey);
|
|
58
|
+
|
|
59
|
+
// a cached width can restore the shell before the hidden probe renders again
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
if (enabled && cachedWidth !== undefined) {
|
|
62
|
+
// promote cache hits so active states stay available longer
|
|
63
|
+
widthCacheRef.current.delete(measurementKey);
|
|
64
|
+
widthCacheRef.current.set(measurementKey, cachedWidth);
|
|
65
|
+
applyWidth(cachedWidth);
|
|
66
|
+
}
|
|
67
|
+
}, [applyWidth, cachedWidth, enabled, measurementKey]);
|
|
36
68
|
const animatedWidthStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => enabled && hasBootstrappedWidth ? {
|
|
37
69
|
width: widthValue.value
|
|
38
70
|
} : {}, [enabled, hasBootstrappedWidth]);
|
|
39
71
|
return {
|
|
40
72
|
captureLayout,
|
|
41
|
-
animatedWidthStyle
|
|
73
|
+
animatedWidthStyle,
|
|
74
|
+
shouldMeasure: enabled && cachedWidth === undefined
|
|
42
75
|
};
|
|
43
76
|
};
|
|
44
77
|
exports.useInlineAutoWidth = useInlineAutoWidth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNativeReanimated","useInlineAutoWidth","enabled","driveToWidth","widthValue","useSharedValue","measuredWidthRef","useRef","bootstrappedRef","hasBootstrappedWidth","setHasBootstrappedWidth","useState","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeReanimated","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","useSharedValue","measuredWidthRef","useRef","bootstrappedRef","widthCacheRef","Map","hasBootstrappedWidth","setHasBootstrappedWidth","useState","applyWidth","useCallback","nextWidth","current","value","captureLayout","event","Math","max","ceil","nativeEvent","layout","width","delete","size","oldestKey","keys","next","undefined","set","cachedWidth","get","useEffect","animatedWidthStyle","useAnimatedStyle","shouldMeasure","exports"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AAQA,MAAME,iBAAiB,GAAG,EAAE;;AAE5B;AACO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,OAAO;EACPC,YAAY;EACZC;AACM,CAAC,KAAK;EACZ,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,MAAME,aAAa,GAAG,IAAAF,aAAM,EAAC,IAAIG,GAAG,CAAiB,CAAC,CAAC;EACvD,MAAM,CAACC,oBAAoB,EAAEC,uBAAuB,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;;EAEvE;EACA,MAAMC,UAAU,GAAG,IAAAC,kBAAW,EAC3BC,SAAiB,IAAK;IACrB,IAAIV,gBAAgB,CAACW,OAAO,KAAKD,SAAS,EAAE;MAC1C;IACF;IAEAV,gBAAgB,CAACW,OAAO,GAAGD,SAAS;IAEpC,IAAI,CAACR,eAAe,CAACS,OAAO,EAAE;MAC5BT,eAAe,CAACS,OAAO,GAAG,IAAI;MAC9Bb,UAAU,CAACc,KAAK,GAAGF,SAAS;MAC5BJ,uBAAuB,CAAC,IAAI,CAAC;MAC7B;IACF;IAEAR,UAA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B;EACF,CAAC,EAAE,CAACpB,UAAU,EAAEoB,WAAW,EAAEjC,OAAO,EAAEE,cAAc,CAAC,CAAC;EAEtD,MAAMkC,kBAAkB,GAAG,IAAAC,uCAAgB,EACzC,MACErC,OAAO,IAAIU,oBAAoB,GAC3B;IACEe,KAAK,EAAEtB,UAAU,CAACc;EACpB,CAAC,GACD,CAAC,CAAC,EACR,CAACjB,OAAO,EAAEU,oBAAoB,CAChC,CAAC;EAED,OAAO;IACLQ,aAAa;IACbkB,kBAAkB;IAClBE,aAAa,EAAEtC,OAAO,IAAIiC,WAAW,KAAKF;EAC5C,CAAC;AACH,CAAC;AAACQ,OAAA,CAAAxC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useMorphMotion = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _presetMap = require("../motion/preset-map");
|
|
9
|
+
// resolve one motion recipe and one shared stagger unit for a render tree
|
|
9
10
|
const useMorphMotion = ({
|
|
10
11
|
variant,
|
|
11
12
|
animationPreset,
|
|
12
13
|
animationDuration,
|
|
13
14
|
stagger
|
|
14
15
|
}) => {
|
|
15
|
-
//
|
|
16
|
+
// numeric variants need a quicker default because their lanes update often
|
|
16
17
|
const resolvedPreset = animationPreset ?? (variant === "text" ? "default" : "snappy");
|
|
17
18
|
const motionRecipe = (0, _react.useMemo)(() => (0, _presetMap.resolveMotionRecipe)(resolvedPreset, animationDuration), [animationDuration, resolvedPreset]);
|
|
18
19
|
return {
|
|
@@ -1 +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;
|
|
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;AAmBA;AACO,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":[]}
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useMorphTextStyle = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
// compose the public style layers into the style passed to every glyph
|
|
8
9
|
const useMorphTextStyle = ({
|
|
9
10
|
fontSize,
|
|
10
11
|
color,
|
|
11
12
|
fontStyle,
|
|
12
13
|
style
|
|
13
14
|
}) => {
|
|
15
|
+
// keep the base layer small so caller styles can override it predictably
|
|
14
16
|
const baseTextStyle = (0, _react.useMemo)(() => {
|
|
15
17
|
const nextStyle = {
|
|
16
18
|
includeFontPadding: false
|
|
@@ -23,6 +25,8 @@ const useMorphTextStyle = ({
|
|
|
23
25
|
}
|
|
24
26
|
return nextStyle;
|
|
25
27
|
}, [color, fontSize]);
|
|
28
|
+
|
|
29
|
+
// preserve the merge order used by the public style contract
|
|
26
30
|
const textStyle = (0, _react.useMemo)(() => [baseTextStyle, fontStyle, style], [baseTextStyle, fontStyle, style]);
|
|
27
31
|
return {
|
|
28
32
|
textStyle
|
|
@@ -1 +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;
|
|
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;AAcA;AACO,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC;AACM,CAAC,KAAqB;EAC5B;EACA,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;EACA,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":[]}
|
|
@@ -7,6 +7,7 @@ exports.useNumericLanes = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _displayUnits = require("../model/display-units");
|
|
9
9
|
var _numericLanes = require("../model/numeric-lanes");
|
|
10
|
+
// retain numeric lane identity across value changes without storing it in state
|
|
10
11
|
const useNumericLanes = value => {
|
|
11
12
|
const units = (0, _react.useMemo)(() => (0, _displayUnits.splitDisplayUnits)(value), [value]);
|
|
12
13
|
const ledgerRef = (0, _react.useRef)({
|
|
@@ -1 +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,OAAA;AAIA,IAAAE,aAAA,GAAAF,OAAA;
|
|
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,OAAA;AAIA,IAAAE,aAAA,GAAAF,OAAA;AAgBA;AACO,MAAMG,eAAe,GAAIC,KAAa,IAA0B;EACrE,MAAMC,KAAK,GAAG,IAAAC,cAAO,EAAC,MAAM,IAAAC,+BAAiB,EAACH,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAC9D,MAAMI,SAAS,GAAG,IAAAC,aAAM,EAAgB;IACtCC,aAAa,EAAEN,KAAK;IACpBO,QAAQ,EAAEN,KAAK,CAACO,GAAG,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAKA,KAAK,CAAC;IACxCC,QAAQ,EAAEV,KAAK,CAACW,MAAM;IACtBC,SAAS,EAAE;EACb,CAAC,CAAC;;EAEF;EACA,IAAIb,KAAK,KAAKI,SAAS,CAACU,OAAO,CAACR,aAAa,EAAE;IAC7C,MAAMS,UAAU,GAAG,IAAAC,mCAAqB,EACtCZ,SAAS,CAACU,OAAO,CAACR,aAAa,EAC/BN,KAAK,EACLI,SAAS,CAACU,OAAO,CAACP,QAAQ,EAC1BH,SAAS,CAACU,OAAO,CAACH,QACpB,CAAC;IAEDP,SAAS,CAACU,OAAO,GAAG;MAClBR,aAAa,EAAEN,KAAK;MACpBO,QAAQ,EAAEQ,UAAU,CAACR,QAAQ;MAC7BI,QAAQ,EAAEI,UAAU,CAACJ,QAAQ;MAC7BE,SAAS,EAAEE,UAAU,CAACF;IACxB,CAAC;EACH;EAEA,OAAO;IACLZ,KAAK;IACLM,QAAQ,EAAEH,SAAS,CAACU,OAAO,CAACP,QAAQ;IACpCM,SAAS,EAAET,SAAS,CAACU,OAAO,CAACD,SAAS;IACtCI,UAAU,EAAE,IAAAC,mCAAqB,EAACjB,KAAK;EACzC,CAAC;AACH,CAAC;AAACkB,OAAA,CAAApB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -7,28 +7,49 @@ exports.useTextGlyphs = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _displayUnits = require("../model/display-units");
|
|
9
9
|
var _textKeys = require("../model/text-keys");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// build the inline token stream that lets text and leading content share one ledger
|
|
11
|
+
const useTextGlyphs = (value, namespace, leading, leadingKey) => {
|
|
12
|
+
const units = (0, _react.useMemo)(() => [
|
|
13
|
+
// the map key becomes the identity when leading content is state keyed
|
|
14
|
+
...(leading ? [{
|
|
15
|
+
kind: "element",
|
|
16
|
+
signature: `leading:${String(leadingKey ?? "default")}`,
|
|
17
|
+
element: leading
|
|
18
|
+
}] : []), ...(0, _displayUnits.splitDisplayUnits)(value).map(unit => ({
|
|
19
|
+
kind: "text",
|
|
20
|
+
signature: `text:${unit}`,
|
|
21
|
+
value: unit
|
|
22
|
+
}))], [leading, leadingKey, value]);
|
|
23
|
+
const signatures = units.map(unit => unit.signature);
|
|
12
24
|
const ledgerRef = (0, _react.useRef)({
|
|
13
25
|
previousValue: value,
|
|
14
|
-
|
|
26
|
+
previousSignatures: signatures,
|
|
15
27
|
glyphKeys: units.map((_, index) => `${namespace}:c${index}`),
|
|
16
28
|
nextSeed: units.length
|
|
17
29
|
});
|
|
18
|
-
|
|
30
|
+
|
|
31
|
+
// reconcile only when a token signature changes so stable glyphs keep their views
|
|
32
|
+
if (value !== ledgerRef.current.previousValue || signatures.length !== ledgerRef.current.previousSignatures.length || signatures.some((signature, index) => signature !== ledgerRef.current.previousSignatures[index])) {
|
|
19
33
|
// keep ids stable so unchanged glyphs stay mounted between updates
|
|
20
|
-
const nextLedger = (0, _textKeys.reconcileTextGlyphKeys)(ledgerRef.current.
|
|
34
|
+
const nextLedger = (0, _textKeys.reconcileTextGlyphKeys)(ledgerRef.current.previousSignatures, signatures, ledgerRef.current.glyphKeys, ledgerRef.current.nextSeed, namespace);
|
|
21
35
|
ledgerRef.current = {
|
|
22
36
|
previousValue: value,
|
|
23
|
-
|
|
37
|
+
previousSignatures: signatures,
|
|
24
38
|
glyphKeys: nextLedger.glyphKeys,
|
|
25
39
|
nextSeed: nextLedger.nextSeed
|
|
26
40
|
};
|
|
27
41
|
}
|
|
28
42
|
const glyphKeys = ledgerRef.current.glyphKeys;
|
|
43
|
+
|
|
44
|
+
// normalize spaces at the edge where tokens become renderable glyphs
|
|
29
45
|
return (0, _react.useMemo)(() => units.map((unit, index) => ({
|
|
30
46
|
id: glyphKeys[index],
|
|
31
|
-
|
|
47
|
+
kind: unit.kind,
|
|
48
|
+
...(unit.kind === "text" ? {
|
|
49
|
+
value: (0, _displayUnits.normalizeDisplayUnit)(unit.value)
|
|
50
|
+
} : {
|
|
51
|
+
element: unit.element
|
|
52
|
+
})
|
|
32
53
|
})), [glyphKeys, units]);
|
|
33
54
|
};
|
|
34
55
|
exports.useTextGlyphs = useTextGlyphs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_displayUnits","_textKeys","useTextGlyphs","value","namespace","units","useMemo","splitDisplayUnits","ledgerRef","useRef","previousValue","
|
|
1
|
+
{"version":3,"names":["_react","require","_displayUnits","_textKeys","useTextGlyphs","value","namespace","leading","leadingKey","units","useMemo","kind","signature","String","element","splitDisplayUnits","map","unit","signatures","ledgerRef","useRef","previousValue","previousSignatures","glyphKeys","_","index","nextSeed","length","current","some","nextLedger","reconcileTextGlyphKeys","id","normalizeDisplayUnit","exports"],"sourceRoot":"../../../src","sources":["hooks/use-text-glyphs.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAIA,IAAAE,SAAA,GAAAF,OAAA;AAcA;AACO,MAAMG,aAAa,GAAGA,CAC3BC,KAAa,EACbC,SAAiB,EACjBC,OAAmB,EACnBC,UAA4B,KACF;EAC1B,MAAMC,KAAK,GAAG,IAAAC,cAAO,EACnB,MAAM;EACJ;EACA,IAAIH,OAAO,GACP,CACE;IACEI,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,WAAWC,MAAM,CAACL,UAAU,IAAI,SAAS,CAAC,EAAE;IACvDM,OAAO,EAAEP;EACX,CAAC,CACF,GACD,EAAE,CAAC,EACP,GAAG,IAAAQ,+BAAiB,EAACV,KAAK,CAAC,CAACW,GAAG,CAAEC,IAAI,KAAM;IACzCN,IAAI,EAAE,MAAe;IACrBC,SAAS,EAAE,QAAQK,IAAI,EAAE;IACzBZ,KAAK,EAAEY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AC,CAACC,IAAI,EAAEQ,KAAK,MAAM;IAC1BO,EAAE,EAAET,SAAS,CAACE,KAAK,CAAC;IACpBd,IAAI,EAAEM,IAAI,CAACN,IAAI;IACf,IAAIM,IAAI,CAACN,IAAI,KAAK,MAAM,GACpB;MAAEN,KAAK,EAAE,IAAA4B,kCAAoB,EAAChB,IAAI,CAACZ,KAAK;IAAE,CAAC,GAC3C;MAAES,OAAO,EAAEG,IAAI,CAACH;IAAQ,CAAC;EAC/B,CAAC,CAAC,CAAC,EACL,CAACS,SAAS,EAAEd,KAAK,CACnB,CAAC;AACH,CAAC;AAACyB,OAAA,CAAA9B,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Laminar = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _useInlineAutoWidth = require("./hooks/use-inline-auto-width");
|
|
@@ -12,9 +12,11 @@ var _useMorphTextStyle = require("./hooks/use-morph-text-style");
|
|
|
12
12
|
var _displayUnits = require("./model/display-units");
|
|
13
13
|
var _morphViewport = require("./view/morph-viewport");
|
|
14
14
|
var _numberRun = require("./view/number-run");
|
|
15
|
+
var _slotsRun = require("./view/slots-run");
|
|
15
16
|
var _textRun = require("./view/text-run");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
// choose the content variant and connect it to the shared viewport and measurement flow
|
|
18
20
|
const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Laminar({
|
|
19
21
|
text,
|
|
20
22
|
variant = "text",
|
|
@@ -22,6 +24,9 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
|
|
|
22
24
|
color,
|
|
23
25
|
align = "left",
|
|
24
26
|
className,
|
|
27
|
+
leading,
|
|
28
|
+
leadingKey,
|
|
29
|
+
leadingGap = 0,
|
|
25
30
|
style,
|
|
26
31
|
containerStyle,
|
|
27
32
|
fontStyle,
|
|
@@ -32,6 +37,10 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
|
|
|
32
37
|
clipToBounds = false
|
|
33
38
|
}) {
|
|
34
39
|
const resolvedValue = String(text ?? "");
|
|
40
|
+
// resolve state keyed leading content before measurement and token reconciliation
|
|
41
|
+
const leadingMap = isLeadingMap(leading) ? leading : undefined;
|
|
42
|
+
const resolvedLeading = leadingMap ? leadingMap[resolvedValue] : leading;
|
|
43
|
+
const resolvedLeadingKey = leadingMap ? resolvedValue : leadingKey;
|
|
35
44
|
const {
|
|
36
45
|
motionRecipe,
|
|
37
46
|
staggerMs
|
|
@@ -49,13 +58,22 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
|
|
|
49
58
|
fontStyle,
|
|
50
59
|
style
|
|
51
60
|
});
|
|
61
|
+
|
|
62
|
+
// invalidate the probe when text style, leading content, or leading spacing changes
|
|
63
|
+
const measurementKey = _react.default.useMemo(() => {
|
|
64
|
+
const flattenedStyle = _reactNative.StyleSheet.flatten(textStyle);
|
|
65
|
+
return JSON.stringify([resolvedValue, flattenedStyle?.fontFamily, flattenedStyle?.fontSize, flattenedStyle?.fontStyle, flattenedStyle?.fontWeight, flattenedStyle?.fontVariant, flattenedStyle?.letterSpacing, flattenedStyle?.lineHeight, flattenedStyle?.textTransform, variant === "text" && Boolean(resolvedLeading), variant === "text" ? resolvedLeadingKey : undefined, variant === "text" ? leadingGap : 0]);
|
|
66
|
+
}, [leadingGap, resolvedLeading, resolvedLeadingKey, resolvedValue, textStyle, variant]);
|
|
52
67
|
const {
|
|
53
68
|
captureLayout,
|
|
54
|
-
animatedWidthStyle
|
|
69
|
+
animatedWidthStyle,
|
|
70
|
+
shouldMeasure
|
|
55
71
|
} = (0, _useInlineAutoWidth.useInlineAutoWidth)({
|
|
56
72
|
enabled: autoSize,
|
|
57
|
-
driveToWidth: motionRecipe.driveNumber
|
|
73
|
+
driveToWidth: motionRecipe.driveNumber,
|
|
74
|
+
measurementKey
|
|
58
75
|
});
|
|
76
|
+
// measurement uses the same normalized units as the visible text row
|
|
59
77
|
const measuredValue = _react.default.useMemo(() => {
|
|
60
78
|
if (!autoSize) {
|
|
61
79
|
return "";
|
|
@@ -68,13 +86,33 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
|
|
|
68
86
|
align: align,
|
|
69
87
|
containerStyle: containerStyle,
|
|
70
88
|
animatedWidthStyle: animatedWidthStyle,
|
|
71
|
-
measurement: /*#__PURE__*/(0, _jsxRuntime.
|
|
72
|
-
numberOfLines: 1,
|
|
89
|
+
measurement: shouldMeasure ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
73
90
|
onLayout: captureLayout,
|
|
74
|
-
style:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
style: {
|
|
92
|
+
flexDirection: "row",
|
|
93
|
+
alignSelf: "flex-start"
|
|
94
|
+
},
|
|
95
|
+
children: [variant === "text" && resolvedLeading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
96
|
+
style: {
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
justifyContent: "center",
|
|
99
|
+
marginRight: leadingGap
|
|
100
|
+
},
|
|
101
|
+
children: resolvedLeading
|
|
102
|
+
}) : null, (0, _displayUnits.splitDisplayUnits)(measuredValue).map((unit, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
103
|
+
style: textStyle,
|
|
104
|
+
children: (0, _displayUnits.normalizeDisplayUnit)(unit)
|
|
105
|
+
}, `${unit}-${index}`))]
|
|
106
|
+
}) : undefined,
|
|
107
|
+
children: variant === "slots" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_slotsRun.SlotsRun, {
|
|
108
|
+
value: resolvedValue,
|
|
109
|
+
motionRecipe: motionRecipe,
|
|
110
|
+
align: align,
|
|
111
|
+
fontSize: fontSize,
|
|
112
|
+
textStyle: textStyle,
|
|
113
|
+
staggerMs: staggerMs,
|
|
114
|
+
className: className
|
|
115
|
+
}) : variant === "number" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_numberRun.NumberRun, {
|
|
78
116
|
value: resolvedValue,
|
|
79
117
|
motionRecipe: motionRecipe,
|
|
80
118
|
align: align,
|
|
@@ -86,11 +124,16 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
|
|
|
86
124
|
value: resolvedValue,
|
|
87
125
|
motionRecipe: motionRecipe,
|
|
88
126
|
align: align,
|
|
127
|
+
leading: resolvedLeading,
|
|
128
|
+
leadingKey: resolvedLeadingKey,
|
|
129
|
+
leadingGap: leadingGap,
|
|
89
130
|
textStyle: textStyle,
|
|
90
131
|
className: className
|
|
91
132
|
})
|
|
92
133
|
});
|
|
93
134
|
});
|
|
94
|
-
|
|
95
|
-
|
|
135
|
+
function isLeadingMap(value) {
|
|
136
|
+
// react elements are objects too, so exclude them before treating a value as a map
|
|
137
|
+
return typeof value === "object" && value !== null && ! /*#__PURE__*/_react.default.isValidElement(value) && !Array.isArray(value);
|
|
138
|
+
}
|
|
96
139
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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","align","className","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","motionRecipe","staggerMs","useMorphMotion","textStyle","useMorphTextStyle","captureLayout","animatedWidthStyle","useInlineAutoWidth","enabled","driveToWidth","driveNumber","measuredValue","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_useInlineAutoWidth","_useMorphMotion","_useMorphTextStyle","_displayUnits","_morphViewport","_numberRun","_slotsRun","_textRun","_jsxRuntime","e","__esModule","default","Laminar","exports","React","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","useMorphMotion","textStyle","useMorphTextStyle","measurementKey","useMemo","flattenedStyle","StyleSheet","flatten","JSON","stringify","fontFamily","fontWeight","fontVariant","letterSpacing","lineHeight","textTransform","Boolean","captureLayout","animatedWidthStyle","shouldMeasure","useInlineAutoWidth","enabled","driveToWidth","driveNumber","measuredValue","splitDisplayUnits","map","normalizeDisplayUnit","join","jsx","MorphViewport","measurement","jsxs","View","onLayout","flexDirection","alignSelf","children","alignItems","justifyContent","marginRight","unit","index","Text","SlotsRun","value","NumberRun","TextRun","isValidElement","Array","isArray"],"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,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAA0C,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAD,uBAAAY,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C;AACO,MAAMG,OAAO,GAAAC,O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A+D,GAAA,EAAChE,QAAA,CAAAkF,OAAO;MACNF,KAAK,EAAEtD,aAAc;MACrBO,YAAY,EAAEA,YAAa;MAC3BpB,KAAK,EAAEA,KAAM;MACbE,OAAO,EAAEgB,eAAgB;MACzBf,UAAU,EAAEgB,kBAAmB;MAC/Bf,UAAU,EAAEA,UAAW;MACvBmB,SAAS,EAAEA,SAAU;MACrBtB,SAAS,EAAEA;IAAU,CACtB;EACJ,CACY,CAAC;AAElB,CAAC,CAAC;AAEJ,SAASe,YAAYA,CACnBmD,KAAmC,EACP;EAC5B;EACA,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,eAACzE,cAAK,CAAC4E,cAAc,CAACH,KAAK,CAAC,IAC5B,CAACI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC;AAEzB","ignoreList":[]}
|
|
@@ -8,6 +8,8 @@ const NBSP = "\u00A0";
|
|
|
8
8
|
const graphemeSegmenter = typeof Intl !== "undefined" && typeof Intl.Segmenter === "function" ? new Intl.Segmenter(undefined, {
|
|
9
9
|
granularity: "grapheme"
|
|
10
10
|
}) : null;
|
|
11
|
+
|
|
12
|
+
// segment graphemes when the runtime supports them so emoji and combining marks stay whole
|
|
11
13
|
const splitDisplayUnits = input => {
|
|
12
14
|
if (graphemeSegmenter) {
|
|
13
15
|
return Array.from(graphemeSegmenter.segment(input), part => part.segment);
|
|
@@ -15,11 +17,15 @@ const splitDisplayUnits = input => {
|
|
|
15
17
|
return Array.from(input);
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
//
|
|
20
|
+
// replace plain spaces because native text measurement can collapse them
|
|
19
21
|
exports.splitDisplayUnits = splitDisplayUnits;
|
|
20
22
|
const normalizeDisplayUnit = unit => unit === " " ? NBSP : unit;
|
|
23
|
+
|
|
24
|
+
// numeric lanes only treat ascii digits as place-value columns
|
|
21
25
|
exports.normalizeDisplayUnit = normalizeDisplayUnit;
|
|
22
26
|
const isAsciiDigit = unit => unit >= "0" && unit <= "9";
|
|
27
|
+
|
|
28
|
+
// leading symbols and punctuation stay attached to the left side of a number
|
|
23
29
|
exports.isAsciiDigit = isAsciiDigit;
|
|
24
30
|
const findNumericLeadLength = units => {
|
|
25
31
|
const firstDigitIndex = units.findIndex(isAsciiDigit);
|
|
@@ -1 +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;
|
|
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;;AAEV;AACO,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;;AAE5B;AAAAF,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AACO,MAAME,YAAY,GAAID,IAAY,IAAKA,IAAI,IAAI,GAAG,IAAIA,IAAI,IAAI,GAAG;;AAExE;AAAAF,OAAA,CAAAG,YAAA,GAAAA,YAAA;AACO,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":[]}
|
|
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.reconcileNumericLanes = void 0;
|
|
7
7
|
var _displayUnits = require("./display-units");
|
|
8
|
+
// strip formatting before comparing values so direction follows the displayed number
|
|
8
9
|
const readNumericMagnitude = input => parseFloat(input.replace(/[^0-9.-]/g, "")) || 0;
|
|
10
|
+
|
|
11
|
+
// the sign controls which side of each digit lane enters and exits
|
|
9
12
|
const deriveFlowDirection = (previousValue, nextValue) => Math.sign(readNumericMagnitude(nextValue) - readNumericMagnitude(previousValue));
|
|
13
|
+
// preserve right-aligned place values while allowing prefixes to grow or shrink
|
|
10
14
|
const reconcileNumericLanes = (previousValue, nextValue, previousKeys, seed) => {
|
|
11
15
|
const previousUnits = (0, _displayUnits.splitDisplayUnits)(previousValue);
|
|
12
16
|
const nextUnits = (0, _displayUnits.splitDisplayUnits)(nextValue);
|
|
@@ -1 +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;
|
|
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;AACA,MAAMC,oBAAoB,GAAIC,KAAa,IACzCC,UAAU,CAACD,KAAK,CAACE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;;AAEjD;AACA,MAAMC,mBAAmB,GAAGA,CAC1BC,aAAqB,EACrBC,SAAiB,KAEjBC,IAA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