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.
Files changed (147) hide show
  1. package/README.md +75 -2
  2. package/lib/commonjs/hooks/use-display-units.js +1 -0
  3. package/lib/commonjs/hooks/use-display-units.js.map +1 -1
  4. package/lib/commonjs/hooks/use-inline-auto-width.js +43 -10
  5. package/lib/commonjs/hooks/use-inline-auto-width.js.map +1 -1
  6. package/lib/commonjs/hooks/use-morph-motion.js +2 -1
  7. package/lib/commonjs/hooks/use-morph-motion.js.map +1 -1
  8. package/lib/commonjs/hooks/use-morph-text-style.js +4 -0
  9. package/lib/commonjs/hooks/use-morph-text-style.js.map +1 -1
  10. package/lib/commonjs/hooks/use-numeric-lanes.js +1 -0
  11. package/lib/commonjs/hooks/use-numeric-lanes.js.map +1 -1
  12. package/lib/commonjs/hooks/use-text-glyphs.js +28 -7
  13. package/lib/commonjs/hooks/use-text-glyphs.js.map +1 -1
  14. package/lib/commonjs/index.js +54 -11
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/model/display-units.js +7 -1
  17. package/lib/commonjs/model/display-units.js.map +1 -1
  18. package/lib/commonjs/model/numeric-lanes.js +4 -0
  19. package/lib/commonjs/model/numeric-lanes.js.map +1 -1
  20. package/lib/commonjs/model/text-keys.js +4 -0
  21. package/lib/commonjs/model/text-keys.js.map +1 -1
  22. package/lib/commonjs/motion/entry-exit-builders.js +78 -1
  23. package/lib/commonjs/motion/entry-exit-builders.js.map +1 -1
  24. package/lib/commonjs/motion/preset-map.js +7 -0
  25. package/lib/commonjs/motion/preset-map.js.map +1 -1
  26. package/lib/commonjs/view/glyph-run.js +21 -2
  27. package/lib/commonjs/view/glyph-run.js.map +1 -1
  28. package/lib/commonjs/view/morph-viewport.js +4 -0
  29. package/lib/commonjs/view/morph-viewport.js.map +1 -1
  30. package/lib/commonjs/view/number-lane.js +5 -1
  31. package/lib/commonjs/view/number-lane.js.map +1 -1
  32. package/lib/commonjs/view/number-run.js +4 -0
  33. package/lib/commonjs/view/number-run.js.map +1 -1
  34. package/lib/commonjs/view/slots-run.js +258 -0
  35. package/lib/commonjs/view/slots-run.js.map +1 -0
  36. package/lib/commonjs/view/text-run.js +35 -3
  37. package/lib/commonjs/view/text-run.js.map +1 -1
  38. package/lib/module/hooks/use-display-units.js +2 -0
  39. package/lib/module/hooks/use-display-units.js.map +1 -1
  40. package/lib/module/hooks/use-inline-auto-width.js +44 -11
  41. package/lib/module/hooks/use-inline-auto-width.js.map +1 -1
  42. package/lib/module/hooks/use-morph-motion.js +2 -1
  43. package/lib/module/hooks/use-morph-motion.js.map +1 -1
  44. package/lib/module/hooks/use-morph-text-style.js +4 -0
  45. package/lib/module/hooks/use-morph-text-style.js.map +1 -1
  46. package/lib/module/hooks/use-numeric-lanes.js +1 -0
  47. package/lib/module/hooks/use-numeric-lanes.js.map +1 -1
  48. package/lib/module/hooks/use-text-glyphs.js +28 -7
  49. package/lib/module/hooks/use-text-glyphs.js.map +1 -1
  50. package/lib/module/index.js +56 -12
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/module/model/display-units.js +7 -1
  53. package/lib/module/model/display-units.js.map +1 -1
  54. package/lib/module/model/numeric-lanes.js +5 -0
  55. package/lib/module/model/numeric-lanes.js.map +1 -1
  56. package/lib/module/model/text-keys.js +4 -0
  57. package/lib/module/model/text-keys.js.map +1 -1
  58. package/lib/module/motion/entry-exit-builders.js +75 -0
  59. package/lib/module/motion/entry-exit-builders.js.map +1 -1
  60. package/lib/module/motion/preset-map.js +7 -0
  61. package/lib/module/motion/preset-map.js.map +1 -1
  62. package/lib/module/view/glyph-run.js +21 -2
  63. package/lib/module/view/glyph-run.js.map +1 -1
  64. package/lib/module/view/morph-viewport.js +4 -0
  65. package/lib/module/view/morph-viewport.js.map +1 -1
  66. package/lib/module/view/number-lane.js +5 -1
  67. package/lib/module/view/number-lane.js.map +1 -1
  68. package/lib/module/view/number-run.js +4 -0
  69. package/lib/module/view/number-run.js.map +1 -1
  70. package/lib/module/view/slots-run.js +253 -0
  71. package/lib/module/view/slots-run.js.map +1 -0
  72. package/lib/module/view/text-run.js +36 -4
  73. package/lib/module/view/text-run.js.map +1 -1
  74. package/lib/typescript/commonjs/hooks/use-display-units.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts +3 -1
  76. package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/hooks/use-morph-motion.d.ts.map +1 -1
  78. package/lib/typescript/commonjs/hooks/use-morph-text-style.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/hooks/use-numeric-lanes.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts +2 -1
  81. package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/index.d.ts +1 -3
  83. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/model/display-units.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/model/numeric-lanes.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/model/text-keys.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts +13 -0
  88. package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/motion/preset-map.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/types.d.ts +12 -2
  91. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/view/glyph-run.d.ts +5 -2
  93. package/lib/typescript/commonjs/view/glyph-run.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/view/morph-viewport.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/view/number-lane.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/view/number-run.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/view/slots-run.d.ts +15 -0
  98. package/lib/typescript/commonjs/view/slots-run.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/view/text-run.d.ts +5 -1
  100. package/lib/typescript/commonjs/view/text-run.d.ts.map +1 -1
  101. package/lib/typescript/module/hooks/use-display-units.d.ts.map +1 -1
  102. package/lib/typescript/module/hooks/use-inline-auto-width.d.ts +3 -1
  103. package/lib/typescript/module/hooks/use-inline-auto-width.d.ts.map +1 -1
  104. package/lib/typescript/module/hooks/use-morph-motion.d.ts.map +1 -1
  105. package/lib/typescript/module/hooks/use-morph-text-style.d.ts.map +1 -1
  106. package/lib/typescript/module/hooks/use-numeric-lanes.d.ts.map +1 -1
  107. package/lib/typescript/module/hooks/use-text-glyphs.d.ts +2 -1
  108. package/lib/typescript/module/hooks/use-text-glyphs.d.ts.map +1 -1
  109. package/lib/typescript/module/index.d.ts +1 -3
  110. package/lib/typescript/module/index.d.ts.map +1 -1
  111. package/lib/typescript/module/model/display-units.d.ts.map +1 -1
  112. package/lib/typescript/module/model/numeric-lanes.d.ts.map +1 -1
  113. package/lib/typescript/module/model/text-keys.d.ts.map +1 -1
  114. package/lib/typescript/module/motion/entry-exit-builders.d.ts +13 -0
  115. package/lib/typescript/module/motion/entry-exit-builders.d.ts.map +1 -1
  116. package/lib/typescript/module/motion/preset-map.d.ts.map +1 -1
  117. package/lib/typescript/module/types.d.ts +12 -2
  118. package/lib/typescript/module/types.d.ts.map +1 -1
  119. package/lib/typescript/module/view/glyph-run.d.ts +5 -2
  120. package/lib/typescript/module/view/glyph-run.d.ts.map +1 -1
  121. package/lib/typescript/module/view/morph-viewport.d.ts.map +1 -1
  122. package/lib/typescript/module/view/number-lane.d.ts.map +1 -1
  123. package/lib/typescript/module/view/number-run.d.ts.map +1 -1
  124. package/lib/typescript/module/view/slots-run.d.ts +15 -0
  125. package/lib/typescript/module/view/slots-run.d.ts.map +1 -0
  126. package/lib/typescript/module/view/text-run.d.ts +5 -1
  127. package/lib/typescript/module/view/text-run.d.ts.map +1 -1
  128. package/package.json +11 -2
  129. package/src/hooks/use-display-units.ts +1 -0
  130. package/src/hooks/use-inline-auto-width.ts +55 -12
  131. package/src/hooks/use-morph-motion.ts +2 -1
  132. package/src/hooks/use-morph-text-style.ts +3 -0
  133. package/src/hooks/use-numeric-lanes.ts +1 -0
  134. package/src/hooks/use-text-glyphs.ts +48 -10
  135. package/src/index.tsx +98 -17
  136. package/src/model/display-units.ts +4 -1
  137. package/src/model/numeric-lanes.ts +3 -0
  138. package/src/model/text-keys.ts +3 -0
  139. package/src/motion/entry-exit-builders.ts +73 -0
  140. package/src/motion/preset-map.ts +4 -0
  141. package/src/types.ts +14 -2
  142. package/src/view/glyph-run.tsx +38 -13
  143. package/src/view/morph-viewport.tsx +3 -0
  144. package/src/view/number-lane.tsx +7 -2
  145. package/src/view/number-run.tsx +3 -0
  146. package/src/view/slots-run.tsx +385 -0
  147. package/src/view/text-run.tsx +77 -6
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SlotsRun = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _useNumericLanes = require("../hooks/use-numeric-lanes");
11
+ var _displayUnits = require("../model/display-units");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ const rowStyle = {
15
+ flexDirection: "row",
16
+ alignItems: "center",
17
+ alignSelf: "flex-start"
18
+ };
19
+ const rowAlignStyles = {
20
+ left: {
21
+ alignSelf: "flex-start"
22
+ },
23
+ center: {
24
+ alignSelf: "center"
25
+ },
26
+ right: {
27
+ alignSelf: "flex-end"
28
+ }
29
+ };
30
+ const slotFrameStyle = {
31
+ position: "relative",
32
+ alignSelf: "flex-start",
33
+ overflow: "hidden"
34
+ };
35
+ const slotProbeStyle = {
36
+ opacity: 0
37
+ };
38
+ const slotDigitStyle = {
39
+ textAlign: "center"
40
+ };
41
+ const REEL_MIN = -12;
42
+ const REEL_MAX = 22;
43
+ const REEL_POSITIONS = Array.from({
44
+ length: 30
45
+ }, (_, index) => index - 10);
46
+
47
+ // wrap reel positions so a bounded strip can represent an endless digit wheel
48
+ const mod = (value, divisor) => (value % divisor + divisor) % divisor;
49
+ // compare flattened style values without treating a new array as a visual change
50
+ const equalStyleValue = (left, right) => left === right || Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => value === right[index]);
51
+
52
+ // prevent every parent update from rebuilding the thirty-text reel
53
+ const areSlotReelPropsEqual = (previous, next) => {
54
+ if (previous.current !== next.current || previous.slotHeight !== next.slotHeight || previous.className !== next.className) {
55
+ return false;
56
+ }
57
+ const previousStyle = _reactNative.StyleSheet.flatten(previous.textStyle) ?? {};
58
+ const nextStyle = _reactNative.StyleSheet.flatten(next.textStyle) ?? {};
59
+ const previousKeys = Object.keys(previousStyle);
60
+ const nextKeys = Object.keys(nextStyle);
61
+ return previousKeys.length === nextKeys.length && previousKeys.every(key => equalStyleValue(previousStyle[key], nextStyle[key]));
62
+ };
63
+ const SlotReel = /*#__PURE__*/_react.default.memo(function SlotReel({
64
+ current,
65
+ slotHeight,
66
+ textStyle,
67
+ className
68
+ }) {
69
+ // translate one bounded reel instead of mounting a new animated digit per update
70
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
71
+ transform: [{
72
+ translateY: (-10 - current.value) * slotHeight
73
+ }]
74
+ }), [slotHeight]);
75
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
76
+ pointerEvents: "none",
77
+ style: [{
78
+ position: "absolute",
79
+ top: 0,
80
+ left: 0,
81
+ right: 0
82
+ }, animatedStyle],
83
+ children: REEL_POSITIONS.map((position, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
84
+ numberOfLines: 1,
85
+ style: [textStyle, slotDigitStyle, {
86
+ position: "absolute",
87
+ top: index * slotHeight,
88
+ left: 0,
89
+ right: 0,
90
+ height: slotHeight,
91
+ lineHeight: slotHeight
92
+ }],
93
+ className: className,
94
+ children: mod(position, 10)
95
+ }, position))
96
+ });
97
+ }, areSlotReelPropsEqual);
98
+ function SlotColumn({
99
+ digit,
100
+ direction,
101
+ delayMs,
102
+ animateIn,
103
+ motionRecipe,
104
+ slotHeight,
105
+ textStyle,
106
+ className
107
+ }) {
108
+ // cumulative positions let the reel move across digit wraparound without jumps
109
+ const spinInDistance = Math.max(digit, 1);
110
+ const initialDirection = direction || 1;
111
+ const initialValue = animateIn ? digit - spinInDistance * initialDirection : digit;
112
+ const current = (0, _reactNativeReanimated.useSharedValue)(initialValue);
113
+ const cumulativeRef = (0, _react.useRef)(digit);
114
+ const previousDigitRef = (0, _react.useRef)(digit);
115
+ const initialRef = (0, _react.useRef)(true);
116
+ const exitStateRef = (0, _react.useRef)({
117
+ digit,
118
+ direction,
119
+ motionRecipe,
120
+ target: digit
121
+ });
122
+ if (digit !== previousDigitRef.current) {
123
+ const previousDigit = previousDigitRef.current;
124
+ let digitDelta;
125
+ if (direction > 0) {
126
+ digitDelta = digit >= previousDigit ? digit - previousDigit : 10 - previousDigit + digit;
127
+ } else if (direction < 0) {
128
+ digitDelta = previousDigit >= digit ? -(previousDigit - digit) : -(10 - digit + previousDigit);
129
+ } else {
130
+ digitDelta = digit - previousDigit;
131
+ }
132
+ cumulativeRef.current += digitDelta;
133
+ previousDigitRef.current = digit;
134
+ }
135
+ exitStateRef.current = {
136
+ digit,
137
+ direction,
138
+ motionRecipe,
139
+ target: cumulativeRef.current
140
+ };
141
+ (0, _react.useEffect)(() => {
142
+ // continue the current reel from its last committed target when the column exits
143
+ return () => {
144
+ const exitState = exitStateRef.current;
145
+ const spinOutDistance = Math.max(exitState.digit, 1);
146
+ const exitDirection = exitState.direction || 1;
147
+ current.value = exitState.motionRecipe.driveNumber(exitState.target + spinOutDistance * exitDirection);
148
+ };
149
+ }, [current]);
150
+ (0, _react.useEffect)(() => {
151
+ // keep the reel bounded by recentring after enough cumulative turns
152
+ if (initialRef.current) {
153
+ initialRef.current = false;
154
+ if (!animateIn) {
155
+ return;
156
+ }
157
+ }
158
+ let target = cumulativeRef.current;
159
+ if (target < REEL_MIN + 4 || target > REEL_MAX - 4) {
160
+ const shift = Math.trunc(target / 10) * 10;
161
+ if (shift !== 0) {
162
+ target -= shift;
163
+ cumulativeRef.current = target;
164
+ current.value -= shift;
165
+ }
166
+ }
167
+ exitStateRef.current = {
168
+ digit,
169
+ direction,
170
+ motionRecipe,
171
+ target
172
+ };
173
+ current.value = motionRecipe.driveNumber(target, delayMs);
174
+ }, [animateIn, current, delayMs, digit, direction, motionRecipe]);
175
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
176
+ style: slotFrameStyle,
177
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
178
+ style: [textStyle, slotProbeStyle, {
179
+ lineHeight: slotHeight
180
+ }],
181
+ className: className,
182
+ children: "0"
183
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SlotReel, {
184
+ current: current,
185
+ slotHeight: slotHeight,
186
+ textStyle: textStyle,
187
+ className: className
188
+ })]
189
+ });
190
+ }
191
+ // render text prefixes beside reusable digit reels
192
+ const SlotsRun = exports.SlotsRun = /*#__PURE__*/_react.default.memo(({
193
+ value,
194
+ motionRecipe,
195
+ align,
196
+ fontSize,
197
+ textStyle,
198
+ staggerMs,
199
+ className
200
+ }) => {
201
+ // numeric lane identity decides which columns stay mounted as values change
202
+ const {
203
+ units,
204
+ direction,
205
+ leadLength
206
+ } = (0, _useNumericLanes.useNumericLanes)(value);
207
+ const lastValueRef = (0, _react.useRef)(value);
208
+ const hasAnimatedRef = (0, _react.useRef)(false);
209
+ // derive one stable row height so every reel position shares the same baseline
210
+ const slotHeight = (0, _react.useMemo)(() => {
211
+ const flattenedStyle = _reactNative.StyleSheet.flatten(textStyle);
212
+ const resolvedLineHeight = typeof flattenedStyle?.lineHeight === "number" ? flattenedStyle.lineHeight : undefined;
213
+ const resolvedFontSize = typeof flattenedStyle?.fontSize === "number" ? flattenedStyle.fontSize : fontSize;
214
+ return Math.max(12, Math.ceil(resolvedLineHeight ?? (resolvedFontSize ?? 16) * 1.18));
215
+ }, [fontSize, textStyle]);
216
+ if (value !== lastValueRef.current) {
217
+ hasAnimatedRef.current = true;
218
+ lastValueRef.current = value;
219
+ }
220
+ const digitCount = units.filter(_displayUnits.isAsciiDigit).length;
221
+ let digitIndex = 0;
222
+ const hasAnimated = hasAnimatedRef.current;
223
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
224
+ style: [rowStyle, rowAlignStyles[align]],
225
+ children: units.map((unit, index) => {
226
+ const inLead = index < leadLength;
227
+ const laneKey = inLead ? `lead:${index}` : `slot:${units.length - 1 - index}`;
228
+ if (inLead || !(0, _displayUnits.isAsciiDigit)(unit)) {
229
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.Text, {
230
+ layout: hasAnimated ? motionRecipe.layoutTransition : undefined,
231
+ exiting: !inLead ? motionRecipe.exitTransition : undefined,
232
+ style: textStyle,
233
+ className: className,
234
+ children: unit
235
+ }, laneKey);
236
+ }
237
+ const delayMs = (digitCount - 1 - digitIndex) * staggerMs;
238
+ digitIndex += 1;
239
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
240
+ layout: hasAnimated ? motionRecipe.layoutTransition : undefined,
241
+ entering: hasAnimated ? motionRecipe.enterTransition : undefined,
242
+ exiting: motionRecipe.exitTransition,
243
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SlotColumn, {
244
+ digit: Number(unit),
245
+ direction: direction,
246
+ delayMs: delayMs,
247
+ animateIn: hasAnimated,
248
+ motionRecipe: motionRecipe,
249
+ slotHeight: slotHeight,
250
+ textStyle: textStyle,
251
+ className: className
252
+ })
253
+ }, laneKey);
254
+ })
255
+ });
256
+ });
257
+ SlotsRun.displayName = "SlotsRun";
258
+ //# sourceMappingURL=slots-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_useNumericLanes","_displayUnits","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","rowStyle","flexDirection","alignItems","alignSelf","rowAlignStyles","left","center","right","slotFrameStyle","position","overflow","slotProbeStyle","opacity","slotDigitStyle","textAlign","REEL_MIN","REEL_MAX","REEL_POSITIONS","Array","from","length","_","index","mod","value","divisor","equalStyleValue","isArray","every","areSlotReelPropsEqual","previous","next","current","slotHeight","className","previousStyle","StyleSheet","flatten","textStyle","nextStyle","previousKeys","keys","nextKeys","key","SlotReel","React","memo","animatedStyle","useAnimatedStyle","transform","translateY","jsx","View","pointerEvents","style","top","children","map","Text","numberOfLines","height","lineHeight","SlotColumn","digit","direction","delayMs","animateIn","motionRecipe","spinInDistance","Math","max","initialDirection","initialValue","useSharedValue","cumulativeRef","useRef","previousDigitRef","initialRef","exitStateRef","target","previousDigit","digitDelta","useEffect","exitState","spinOutDistance","exitDirection","driveNumber","shift","trunc","jsxs","SlotsRun","exports","align","fontSize","staggerMs","units","leadLength","useNumericLanes","lastValueRef","hasAnimatedRef","useMemo","flattenedStyle","resolvedLineHeight","undefined","resolvedFontSize","ceil","digitCount","filter","isAsciiDigit","digitIndex","hasAnimated","unit","inLead","laneKey","layout","layoutTransition","exiting","exitTransition","entering","enterTransition","Number","displayName"],"sourceRoot":"../../../src","sources":["view/slots-run.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAKA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAAsD,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,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAA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IAAI,CAAC;MAEf,oBACE,IAAAjI,WAAA,CAAAuE,GAAA,EAAC1E,sBAAA,CAAAc,OAAQ,CAAC6D,IAAI;QAEZ8D,MAAM,EACJJ,WAAW,GAAG3C,YAAY,CAACgD,gBAAgB,GAAGZ,SAC/C;QACDe,QAAQ,EACNR,WAAW,GAAG3C,YAAY,CAACoD,eAAe,GAAGhB,SAC9C;QACDa,OAAO,EACLjD,YAAY,CAACkD,cACd;QAAA7D,QAAA,eAED,IAAA5E,WAAA,CAAAuE,GAAA,EAACW,UAAU;UACTC,KAAK,EAAEyD,MAAM,CAACT,IAAI,CAAE;UACpB/C,SAAS,EAAEA,SAAU;UACrBC,OAAO,EAAEA,OAAQ;UACjBC,SAAS,EAAE4C,WAAY;UACvB3C,YAAY,EAAEA,YAAa;UAC3BlC,UAAU,EAAEA,UAAW;UACvBK,SAAS,EAAEA,SAAU;UACrBJ,SAAS,EAAEA;QAAU,CACtB;MAAC,GApBG+E,OAqBQ,CAAC;IAEpB,CAAC;EAAC,CACE,CAAC;AAEX,CACF,CAAC;AAEDvB,QAAQ,CAAC+B,WAAW,GAAG,UAAU","ignoreList":[]}
@@ -5,31 +5,63 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TextRun = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNativeReanimated = require("react-native-reanimated");
8
9
  var _useTextGlyphs = require("../hooks/use-text-glyphs");
10
+ var _entryExitBuilders = require("../motion/entry-exit-builders");
9
11
  var _glyphRun = require("./glyph-run");
10
12
  var _jsxRuntime = require("react/jsx-runtime");
11
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ // connect text identity, leading transitions, and glyph layout into one run
12
15
  const TextRun = exports.TextRun = /*#__PURE__*/_react.default.memo(({
13
16
  value,
14
17
  motionRecipe,
15
18
  align,
19
+ leading,
20
+ leadingKey,
21
+ leadingGap = 0,
16
22
  textStyle,
17
23
  className
18
24
  }) => {
19
25
  // namespace ids per instance so repeated strings do not collide
20
26
  const scopeId = (0, _react.useId)();
21
- const glyphs = (0, _useTextGlyphs.useTextGlyphs)(value, scopeId);
22
27
  const lastValueRef = (0, _react.useRef)(value);
28
+ const lastLeadingPresenceRef = (0, _react.useRef)(Boolean(leading));
29
+ const lastLeadingKeyRef = (0, _react.useRef)(leadingKey);
23
30
  const hasAnimatedRef = (0, _react.useRef)(false);
24
- if (value !== lastValueRef.current) {
31
+ const isLeadingSwap = Boolean(leading) && lastLeadingPresenceRef.current && leadingKey !== lastLeadingKeyRef.current;
32
+ // update the worklet flag after commit so render never writes a shared value
33
+ const leadingSwapProgress = (0, _reactNativeReanimated.useSharedValue)(0);
34
+ (0, _react.useLayoutEffect)(() => {
35
+ leadingSwapProgress.value = isLeadingSwap ? 1 : 0;
36
+ }, [isLeadingSwap, leadingSwapProgress]);
37
+ const glyphs = (0, _useTextGlyphs.useTextGlyphs)(value, scopeId, leading, leadingKey);
38
+ const elementEnterTransition = (0, _react.useMemo)(() => (0, _entryExitBuilders.createLeadingEnterTransition)({
39
+ durationMs: motionRecipe.durationMs,
40
+ easing: motionRecipe.easing
41
+ }), [motionRecipe.durationMs, motionRecipe.easing]);
42
+ const elementExitTransition = (0, _react.useMemo)(() => (0, _entryExitBuilders.createLeadingExitTransition)({
43
+ durationMs: motionRecipe.durationMs,
44
+ easing: motionRecipe.easing,
45
+ leadingGap,
46
+ scale: leadingSwapProgress
47
+ }), [leadingGap, leadingSwapProgress, motionRecipe.durationMs, motionRecipe.easing]);
48
+
49
+ // mark the first value as settled and later changes as eligible for motion
50
+ if (value !== lastValueRef.current || Boolean(leading) !== lastLeadingPresenceRef.current || leadingKey !== lastLeadingKeyRef.current) {
25
51
  hasAnimatedRef.current = true;
26
52
  lastValueRef.current = value;
53
+ lastLeadingPresenceRef.current = Boolean(leading);
54
+ lastLeadingKeyRef.current = leadingKey;
27
55
  }
56
+ const hasAnimated = hasAnimatedRef.current;
28
57
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_glyphRun.GlyphRun, {
29
58
  glyphs: glyphs,
30
- layoutTransition: motionRecipe.layoutTransition,
59
+ layoutTransition: hasAnimated ? motionRecipe.layoutTransition : undefined,
31
60
  enterTransition: hasAnimatedRef.current ? motionRecipe.enterTransition : undefined,
61
+ elementEnterTransition: isLeadingSwap ? elementEnterTransition : undefined,
32
62
  exitTransition: motionRecipe.exitTransition,
63
+ elementExitTransition: elementExitTransition,
64
+ leadingGap: leadingGap,
33
65
  align: align,
34
66
  textStyle: textStyle,
35
67
  className: className
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_useTextGlyphs","_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","textStyle","className","scopeId","useId","glyphs","useTextGlyphs","lastValueRef","useRef","hasAnimatedRef","current","jsx","GlyphRun","layoutTransition","enterTransition","undefined","exitTransition","displayName"],"sourceRoot":"../../../src","sources":["view/text-run.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAAuC,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,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AAG,IAAAD,aAAM,EAAC,KAAK,CAAC;EAEpC,IAAIV,KAAK,KAAKS,YAAY,CAACG,OAAO,EAAE;IAClCD,cAAc,CAACC,OAAO,GAAG,IAAI;IAC7BH,YAAY,CAACG,OAAO,GAAGZ,KAAK;EAC9B;EAEA,oBACE,IAAAxB,WAAA,CAAAqC,GAAA,EAACtC,SAAA,CAAAuC,QAAQ;IACPP,MAAM,EAAEA,MAAO;IACfQ,gBAAgB,EAAEd,YAAY,CAACc,gBAAiB;IAChDC,eAAe,EACbL,cAAc,CAACC,OAAO,GAAGX,YAAY,CAACe,eAAe,GAAGC,SACzD;IACDC,cAAc,EAAEjB,YAAY,CAACiB,cAAe;IAC5ChB,KAAK,EAAEA,KAAM;IACbC,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CACF,CAAC;AAEDR,OAAO,CAACuB,WAAW,GAAG,SAAS","ignoreList":[]}
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","lastValueRef","useRef","lastLeadingPresenceRef","Boolean","lastLeadingKeyRef","hasAnimatedRef","isLeadingSwap","current","leadingSwapProgress","useSharedValue","useLayoutEffect","glyphs","useTextGlyphs","elementEnterTransition","useMemo","createLeadingEnterTransition","durationMs","easing","elementExitTransition","createLeadingExitTransition","scale","hasAnimated","jsx","GlyphRun","layoutTransition","undefined","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,O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CAAC,CAAC,EACJ,CACEb,UAAU,EACVa,mBAAmB,EACnBjB,YAAY,CAACyB,UAAU,EACvBzB,YAAY,CAAC0B,MAAM,CAEvB,CAAC;;EAED;EACA,IACE3B,KAAK,KAAKU,YAAY,CAACO,OAAO,IAC9BJ,OAAO,CAACV,OAAO,CAAC,KAAKS,sBAAsB,CAACK,OAAO,IACnDb,UAAU,KAAKU,iBAAiB,CAACG,OAAO,EACxC;IACAF,cAAc,CAACE,OAAO,GAAG,IAAI;IAC7BP,YAAY,CAACO,OAAO,GAAGjB,KAAK;IAC5BY,sBAAsB,CAACK,OAAO,GAAGJ,OAAO,CAACV,OAAO,CAAC;IACjDW,iBAAiB,CAACG,OAAO,GAAGb,UAAU;EACxC;EAEA,MAAM2B,WAAW,GAAGhB,cAAc,CAACE,OAAO;EAE1C,oBACE,IAAAzC,WAAA,CAAAwD,GAAA,EAACzD,SAAA,CAAA0D,QAAQ;IACPZ,MAAM,EAAEA,MAAO;IACfa,gBAAgB,EACdH,WAAW,GAAG9B,YAAY,CAACiC,gBAAgB,GAAGC,SAC/C;IACDC,eAAe,EACbrB,cAAc,CAACE,OAAO,GAClBhB,YAAY,CAACmC,eAAe,GAC5BD,SACL;IACDZ,sBAAsB,EACpBP,aAAa,GAAGO,sBAAsB,GAAGY,SAC1C;IACDE,cAAc,EAAEpC,YAAY,CAACoC,cAAe;IAC5CT,qBAAqB,EAAEA,qBAAsB;IAC7CvB,UAAU,EAAEA,UAAW;IACvBH,KAAK,EAAEA,KAAM;IACbI,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CACF,CAAC;AAEDX,OAAO,CAAC0C,WAAW,GAAG,SAAS","ignoreList":[]}
@@ -2,6 +2,8 @@
2
2
 
3
3
  import { useMemo } from "react";
4
4
  import { normalizeDisplayUnit, splitDisplayUnits } from "../model/display-units.js";
5
+
6
+ // normalize the same units used by rendering before measurement reads them
5
7
  export const useDisplayUnits = (value, enabled = true) => useMemo(() =>
6
8
  // skip unit work when auto size is off
7
9
  enabled ? splitDisplayUnits(value).map(normalizeDisplayUnit) : [], [enabled, value]);
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","normalizeDisplayUnit","splitDisplayUnits","useDisplayUnits","value","enabled","map"],"sourceRoot":"../../../src","sources":["hooks/use-display-units.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,oBAAoB,EACpBC,iBAAiB,QACZ,2BAAwB;AAE/B,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,KAAa,EACbC,OAAO,GAAG,IAAI,KAEdL,OAAO,CACL;AACE;AACAK,OAAO,GACHH,iBAAiB,CAACE,KAAK,CAAC,CAACE,GAAG,CAACL,oBAAoB,CAAC,GAClD,EAAE,EACR,CAACI,OAAO,EAAED,KAAK,CACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","normalizeDisplayUnit","splitDisplayUnits","useDisplayUnits","value","enabled","map"],"sourceRoot":"../../../src","sources":["hooks/use-display-units.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SACEC,oBAAoB,EACpBC,iBAAiB,QACZ,2BAAwB;;AAE/B;AACA,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,KAAa,EACbC,OAAO,GAAG,IAAI,KAEdL,OAAO,CACL;AACE;AACAK,OAAO,GACHH,iBAAiB,CAACE,KAAK,CAAC,CAACE,GAAG,CAACL,oBAAoB,CAAC,GAClD,EAAE,EACR,CAACI,OAAO,EAAED,KAAK,CACjB,CAAC","ignoreList":[]}
@@ -1,26 +1,27 @@
1
1
  "use strict";
2
2
 
3
- import { useCallback, useRef, useState } from "react";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
5
+ const WIDTH_CACHE_LIMIT = 64;
6
+
7
+ // measure each content signature once and drive later changes through one width value
5
8
  export const useInlineAutoWidth = ({
6
9
  enabled,
7
- driveToWidth
10
+ driveToWidth,
11
+ measurementKey
8
12
  }) => {
9
13
  const widthValue = useSharedValue(0);
10
14
  const measuredWidthRef = useRef(null);
11
15
  const bootstrappedRef = useRef(false);
16
+ const widthCacheRef = useRef(new Map());
12
17
  const [hasBootstrappedWidth, setHasBootstrappedWidth] = useState(false);
13
- const captureLayout = useCallback(event => {
14
- if (!enabled) {
15
- return;
16
- }
17
- const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
18
+
19
+ // the first measurement establishes the shell without animating from zero
20
+ const applyWidth = useCallback(nextWidth => {
18
21
  if (measuredWidthRef.current === nextWidth) {
19
22
  return;
20
23
  }
21
24
  measuredWidthRef.current = nextWidth;
22
-
23
- // snap the first width so mount does not animate from zero
24
25
  if (!bootstrappedRef.current) {
25
26
  bootstrappedRef.current = true;
26
27
  widthValue.value = nextWidth;
@@ -28,13 +29,45 @@ export const useInlineAutoWidth = ({
28
29
  return;
29
30
  }
30
31
  widthValue.value = driveToWidth(nextWidth);
31
- }, [driveToWidth, enabled, widthValue]);
32
+ }, [driveToWidth, widthValue]);
33
+ const captureLayout = useCallback(event => {
34
+ if (!enabled) {
35
+ return;
36
+ }
37
+
38
+ // round up so fractional native measurements cannot clip the final glyph
39
+ const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
40
+
41
+ // delete before setting so a repeated key moves to the most recent position
42
+ widthCacheRef.current.delete(measurementKey);
43
+ if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
44
+ // map insertion order gives the lru entry at the front
45
+ const oldestKey = widthCacheRef.current.keys().next().value;
46
+ if (oldestKey !== undefined) {
47
+ widthCacheRef.current.delete(oldestKey);
48
+ }
49
+ }
50
+ widthCacheRef.current.set(measurementKey, nextWidth);
51
+ applyWidth(nextWidth);
52
+ }, [applyWidth, enabled, measurementKey]);
53
+ const cachedWidth = widthCacheRef.current.get(measurementKey);
54
+
55
+ // a cached width can restore the shell before the hidden probe renders again
56
+ useEffect(() => {
57
+ if (enabled && cachedWidth !== undefined) {
58
+ // promote cache hits so active states stay available longer
59
+ widthCacheRef.current.delete(measurementKey);
60
+ widthCacheRef.current.set(measurementKey, cachedWidth);
61
+ applyWidth(cachedWidth);
62
+ }
63
+ }, [applyWidth, cachedWidth, enabled, measurementKey]);
32
64
  const animatedWidthStyle = useAnimatedStyle(() => enabled && hasBootstrappedWidth ? {
33
65
  width: widthValue.value
34
66
  } : {}, [enabled, hasBootstrappedWidth]);
35
67
  return {
36
68
  captureLayout,
37
- animatedWidthStyle
69
+ animatedWidthStyle,
70
+ shouldMeasure: enabled && cachedWidth === undefined
38
71
  };
39
72
  };
40
73
  //# sourceMappingURL=use-inline-auto-width.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useRef","useState","useAnimatedStyle","useSharedValue","useInlineAutoWidth","enabled","driveToWidth","widthValue","measuredWidthRef","bootstrappedRef","hasBootstrappedWidth","setHasBootstrappedWidth","captureLayout","event","nextWidth","Math","max","ceil","nativeEvent","layout","width","current","value","animatedWidthStyle"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAErD,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,yBAAyB;AAO1E,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAqB,CAAC,KAAK;EACvE,MAAMC,UAAU,GAAGJ,cAAc,CAAC,CAAC,CAAC;EACpC,MAAMK,gBAAgB,GAAGR,MAAM,CAAgB,IAAI,CAAC;EACpD,MAAMS,eAAe,GAAGT,MAAM,CAAC,KAAK,CAAC;EACrC,MAAM,CAACU,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGV,QAAQ,CAAC,KAAK,CAAC;EAEvE,MAAMW,aAAa,GAAGb,WAAW,CAC9Bc,KAAwB,IAAK;IAC5B,IAAI,CAACR,OAAO,EAAE;MACZ;IACF;IAEA,MAAMS,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,IAAI,CAACJ,KAAK,CAACK,WAAW,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC;IAExE,IAAIZ,gBAAgB,CAACa,OAAO,KAAKP,SAAS,EAAE;MAC1C;IACF;IAEAN,gBAAgB,CAACa,OAAO,GAAGP,SAAS;;IAEpC;IACA,IAAI,CAACL,eAAe,CAACY,OAAO,EAAE;MAC5BZ,eAAe,CAACY,OAAO,GAAG,IAAI;MAC9Bd,UAAU,CAACe,KAAK,GAAGR,SAAS;MAC5BH,uBAAuB,CAAC,IAAI,CAAC;MAC7B;IACF;IAEAJ,UAAU,CAACe,KAAK,GAAGhB,YAAY,CAACQ,SAAS,CAAC;EAC5C,CAAC,EACD,CAACR,YAAY,EAAED,OAAO,EAAEE,UAAU,CACpC,CAAC;EAED,MAAMgB,kBAAkB,GAAGrB,gBAAgB,CACzC,MACEG,OAAO,IAAIK,oBAAoB,GAC3B;IACEU,KAAK,EAAEb,UAAU,CAACe;EACpB,CAAC,GACD,CAAC,CAAC,EACR,CAACjB,OAAO,EAAEK,oBAAoB,CAChC,CAAC;EAED,OAAO;IACLE,aAAa;IACbW;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useEffect","useRef","useState","useAnimatedStyle","useSharedValue","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","measuredWidthRef","bootstrappedRef","widthCacheRef","Map","hasBootstrappedWidth","setHasBootstrappedWidth","applyWidth","nextWidth","current","value","captureLayout","event","Math","max","ceil","nativeEvent","layout","width","delete","size","oldestKey","keys","next","undefined","set","cachedWidth","get","animatedWidthStyle","shouldMeasure"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,gBAAgB,EA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"react";
4
4
  import { resolveMotionRecipe } from "../motion/preset-map.js";
5
+ // resolve one motion recipe and one shared stagger unit for a render tree
5
6
  export const useMorphMotion = ({
6
7
  variant,
7
8
  animationPreset,
8
9
  animationDuration,
9
10
  stagger
10
11
  }) => {
11
- // numbers feel better with snappy unless you pick something else
12
+ // numeric variants need a quicker default because their lanes update often
12
13
  const resolvedPreset = animationPreset ?? (variant === "text" ? "default" : "snappy");
13
14
  const motionRecipe = useMemo(() => resolveMotionRecipe(resolvedPreset, animationDuration), [animationDuration, resolvedPreset]);
14
15
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","resolveMotionRecipe","useMorphMotion","variant","animationPreset","animationDuration","stagger","resolvedPreset","motionRecipe","staggerMs","Math","round"],"sourceRoot":"../../../src","sources":["hooks/use-morph-motion.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,mBAAmB,QAAQ,yBAAsB;AAmB1D,OAAO,MAAMC,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,GAAGR,OAAO,CAC1B,MAAMC,mBAAmB,CAACM,cAAc,EAAEF,iBAAiB,CAAC,EAC5D,CAACA,iBAAiB,EAAEE,cAAc,CACpC,CAAC;EAED,OAAO;IACLC,YAAY;IACZC,SAAS,EAAEC,IAAI,CAACC,KAAK,CAACL,OAAO,GAAG,IAAI;EACtC,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","resolveMotionRecipe","useMorphMotion","variant","animationPreset","animationDuration","stagger","resolvedPreset","motionRecipe","staggerMs","Math","round"],"sourceRoot":"../../../src","sources":["hooks/use-morph-motion.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,mBAAmB,QAAQ,yBAAsB;AAmB1D;AACA,OAAO,MAAMC,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,GAAGR,OAAO,CAC1B,MAAMC,mBAAmB,CAACM,cAAc,EAAEF,iBAAiB,CAAC,EAC5D,CAACA,iBAAiB,EAAEE,cAAc,CACpC,CAAC;EAED,OAAO;IACLC,YAAY;IACZC,SAAS,EAAEC,IAAI,CAACC,KAAK,CAACL,OAAO,GAAG,IAAI;EACtC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  import { useMemo } from "react";
4
+ // compose the public style layers into the style passed to every glyph
4
5
  export const useMorphTextStyle = ({
5
6
  fontSize,
6
7
  color,
7
8
  fontStyle,
8
9
  style
9
10
  }) => {
11
+ // keep the base layer small so caller styles can override it predictably
10
12
  const baseTextStyle = useMemo(() => {
11
13
  const nextStyle = {
12
14
  includeFontPadding: false
@@ -19,6 +21,8 @@ export const useMorphTextStyle = ({
19
21
  }
20
22
  return nextStyle;
21
23
  }, [color, fontSize]);
24
+
25
+ // preserve the merge order used by the public style contract
22
26
  const textStyle = useMemo(() => [baseTextStyle, fontStyle, style], [baseTextStyle, fontStyle, style]);
23
27
  return {
24
28
  textStyle
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useMorphTextStyle","fontSize","color","fontStyle","style","baseTextStyle","nextStyle","includeFontPadding","undefined","textStyle"],"sourceRoot":"../../../src","sources":["hooks/use-morph-text-style.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAc/B,OAAO,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC;AACM,CAAC,KAAqB;EAC5B,MAAMC,aAAa,GAAGN,OAAO,CAAC,MAAM;IAClC,MAAMO,SAAoB,GAAG;MAC3BC,kBAAkB,EAAE;IACtB,CAAC;IAED,IAAIN,QAAQ,KAAKO,SAAS,EAAE;MAC1BF,SAAS,CAACL,QAAQ,GAAGA,QAAQ;IAC/B;IAEA,IAAIC,KAAK,KAAKM,SAAS,EAAE;MACvBF,SAAS,CAACJ,KAAK,GAAGA,KAAK;IACzB;IAEA,OAAOI,SAAS;EAClB,CAAC,EAAE,CAACJ,KAAK,EAAED,QAAQ,CAAC,CAAC;EAErB,MAAMQ,SAAS,GAAGV,OAAO,CACvB,MAAM,CAACM,aAAa,EAAEF,SAAS,EAAEC,KAAK,CAAC,EACvC,CAACC,aAAa,EAAEF,SAAS,EAAEC,KAAK,CAClC,CAAC;EAED,OAAO;IACLK;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","useMorphTextStyle","fontSize","color","fontStyle","style","baseTextStyle","nextStyle","includeFontPadding","undefined","textStyle"],"sourceRoot":"../../../src","sources":["hooks/use-morph-text-style.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAc/B;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC;AACM,CAAC,KAAqB;EAC5B;EACA,MAAMC,aAAa,GAAGN,OAAO,CAAC,MAAM;IAClC,MAAMO,SAAoB,GAAG;MAC3BC,kBAAkB,EAAE;IACtB,CAAC;IAED,IAAIN,QAAQ,KAAKO,SAAS,EAAE;MAC1BF,SAAS,CAACL,QAAQ,GAAGA,QAAQ;IAC/B;IAEA,IAAIC,KAAK,KAAKM,SAAS,EAAE;MACvBF,SAAS,CAACJ,KAAK,GAAGA,KAAK;IACzB;IAEA,OAAOI,SAAS;EAClB,CAAC,EAAE,CAACJ,KAAK,EAAED,QAAQ,CAAC,CAAC;;EAErB;EACA,MAAMQ,SAAS,GAAGV,OAAO,CACvB,MAAM,CAACM,aAAa,EAAEF,SAAS,EAAEC,KAAK,CAAC,EACvC,CAACC,aAAa,EAAEF,SAAS,EAAEC,KAAK,CAClC,CAAC;EAED,OAAO;IACLK;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -3,6 +3,7 @@
3
3
  import { useMemo, useRef } from "react";
4
4
  import { findNumericLeadLength, splitDisplayUnits } from "../model/display-units.js";
5
5
  import { reconcileNumericLanes } from "../model/numeric-lanes.js";
6
+ // retain numeric lane identity across value changes without storing it in state
6
7
  export const useNumericLanes = value => {
7
8
  const units = useMemo(() => splitDisplayUnits(value), [value]);
8
9
  const ledgerRef = useRef({
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useRef","findNumericLeadLength","splitDisplayUnits","reconcileNumericLanes","useNumericLanes","value","units","ledgerRef","previousValue","laneKeys","map","_","index","nextSeed","length","direction","current","nextLedger","leadLength"],"sourceRoot":"../../../src","sources":["hooks/use-numeric-lanes.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAEvC,SACEC,qBAAqB,EACrBC,iBAAiB,QACZ,2BAAwB;AAC/B,SAASC,qBAAqB,QAAQ,2BAAwB;AAgB9D,OAAO,MAAMC,eAAe,GAAIC,KAAa,IAA0B;EACrE,MAAMC,KAAK,GAAGP,OAAO,CAAC,MAAMG,iBAAiB,CAACG,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAC9D,MAAME,SAAS,GAAGP,MAAM,CAAgB;IACtCQ,aAAa,EAAEH,KAAK;IACpBI,QAAQ,EAAEH,KAAK,CAACI,GAAG,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAKA,KAAK,CAAC;IACxCC,QAAQ,EAAEP,KAAK,CAACQ,MAAM;IACtBC,SAAS,EAAE;EACb,CAAC,CAAC;;EAEF;EACA,IAAIV,KAAK,KAAKE,SAAS,CAACS,OAAO,CAACR,aAAa,EAAE;IAC7C,MAAMS,UAAU,GAAGd,qBAAqB,CACtCI,SAAS,CAACS,OAAO,CAACR,aAAa,EAC/BH,KAAK,EACLE,SAAS,CAACS,OAAO,CAACP,QAAQ,EAC1BF,SAAS,CAACS,OAAO,CAACH,QACpB,CAAC;IAEDN,SAAS,CAACS,OAAO,GAAG;MAClBR,aAAa,EAAEH,KAAK;MACpBI,QAAQ,EAAEQ,UAAU,CAACR,QAAQ;MAC7BI,QAAQ,EAAEI,UAAU,CAACJ,QAAQ;MAC7BE,SAAS,EAAEE,UAAU,CAACF;IACxB,CAAC;EACH;EAEA,OAAO;IACLT,KAAK;IACLG,QAAQ,EAAEF,SAAS,CAACS,OAAO,CAACP,QAAQ;IACpCM,SAAS,EAAER,SAAS,CAACS,OAAO,CAACD,SAAS;IACtCG,UAAU,EAAEjB,qBAAqB,CAACK,KAAK;EACzC,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","useRef","findNumericLeadLength","splitDisplayUnits","reconcileNumericLanes","useNumericLanes","value","units","ledgerRef","previousValue","laneKeys","map","_","index","nextSeed","length","direction","current","nextLedger","leadLength"],"sourceRoot":"../../../src","sources":["hooks/use-numeric-lanes.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAEvC,SACEC,qBAAqB,EACrBC,iBAAiB,QACZ,2BAAwB;AAC/B,SAASC,qBAAqB,QAAQ,2BAAwB;AAgB9D;AACA,OAAO,MAAMC,eAAe,GAAIC,KAAa,IAA0B;EACrE,MAAMC,KAAK,GAAGP,OAAO,CAAC,MAAMG,iBAAiB,CAACG,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAC9D,MAAME,SAAS,GAAGP,MAAM,CAAgB;IACtCQ,aAAa,EAAEH,KAAK;IACpBI,QAAQ,EAAEH,KAAK,CAACI,GAAG,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAKA,KAAK,CAAC;IACxCC,QAAQ,EAAEP,KAAK,CAACQ,MAAM;IACtBC,SAAS,EAAE;EACb,CAAC,CAAC;;EAEF;EACA,IAAIV,KAAK,KAAKE,SAAS,CAACS,OAAO,CAACR,aAAa,EAAE;IAC7C,MAAMS,UAAU,GAAGd,qBAAqB,CACtCI,SAAS,CAACS,OAAO,CAACR,aAAa,EAC/BH,KAAK,EACLE,SAAS,CAACS,OAAO,CAACP,QAAQ,EAC1BF,SAAS,CAACS,OAAO,CAACH,QACpB,CAAC;IAEDN,SAAS,CAACS,OAAO,GAAG;MAClBR,aAAa,EAAEH,KAAK;MACpBI,QAAQ,EAAEQ,UAAU,CAACR,QAAQ;MAC7BI,QAAQ,EAAEI,UAAU,CAACJ,QAAQ;MAC7BE,SAAS,EAAEE,UAAU,CAACF;IACxB,CAAC;EACH;EAEA,OAAO;IACLT,KAAK;IACLG,QAAQ,EAAEF,SAAS,CAACS,OAAO,CAACP,QAAQ;IACpCM,SAAS,EAAER,SAAS,CAACS,OAAO,CAACD,SAAS;IACtCG,UAAU,EAAEjB,qBAAqB,CAACK,KAAK;EACzC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -3,28 +3,49 @@
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
- export const useTextGlyphs = (value, namespace) => {
7
- const units = useMemo(() => splitDisplayUnits(value), [value]);
6
+ // build the inline token stream that lets text and leading content share one ledger
7
+ export const useTextGlyphs = (value, namespace, leading, leadingKey) => {
8
+ const units = useMemo(() => [
9
+ // the map key becomes the identity when leading content is state keyed
10
+ ...(leading ? [{
11
+ kind: "element",
12
+ signature: `leading:${String(leadingKey ?? "default")}`,
13
+ element: leading
14
+ }] : []), ...splitDisplayUnits(value).map(unit => ({
15
+ kind: "text",
16
+ signature: `text:${unit}`,
17
+ value: unit
18
+ }))], [leading, leadingKey, value]);
19
+ const signatures = units.map(unit => unit.signature);
8
20
  const ledgerRef = useRef({
9
21
  previousValue: value,
10
- previousUnits: units,
22
+ previousSignatures: signatures,
11
23
  glyphKeys: units.map((_, index) => `${namespace}:c${index}`),
12
24
  nextSeed: units.length
13
25
  });
14
- if (value !== ledgerRef.current.previousValue) {
26
+
27
+ // reconcile only when a token signature changes so stable glyphs keep their views
28
+ if (value !== ledgerRef.current.previousValue || signatures.length !== ledgerRef.current.previousSignatures.length || signatures.some((signature, index) => signature !== ledgerRef.current.previousSignatures[index])) {
15
29
  // keep ids stable so unchanged glyphs stay mounted between updates
16
- const nextLedger = reconcileTextGlyphKeys(ledgerRef.current.previousUnits, units, ledgerRef.current.glyphKeys, ledgerRef.current.nextSeed, namespace);
30
+ const nextLedger = reconcileTextGlyphKeys(ledgerRef.current.previousSignatures, signatures, ledgerRef.current.glyphKeys, ledgerRef.current.nextSeed, namespace);
17
31
  ledgerRef.current = {
18
32
  previousValue: value,
19
- previousUnits: units,
33
+ previousSignatures: signatures,
20
34
  glyphKeys: nextLedger.glyphKeys,
21
35
  nextSeed: nextLedger.nextSeed
22
36
  };
23
37
  }
24
38
  const glyphKeys = ledgerRef.current.glyphKeys;
39
+
40
+ // normalize spaces at the edge where tokens become renderable glyphs
25
41
  return useMemo(() => units.map((unit, index) => ({
26
42
  id: glyphKeys[index],
27
- value: normalizeDisplayUnit(unit)
43
+ kind: unit.kind,
44
+ ...(unit.kind === "text" ? {
45
+ value: normalizeDisplayUnit(unit.value)
46
+ } : {
47
+ element: unit.element
48
+ })
28
49
  })), [glyphKeys, units]);
29
50
  };
30
51
  //# sourceMappingURL=use-text-glyphs.js.map