@hozo/primitives 0.1.0

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 (218) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -0
  3. package/dist/flat-list.native.d.ts +17 -0
  4. package/dist/flat-list.native.d.ts.map +1 -0
  5. package/dist/flat-list.native.js +89 -0
  6. package/dist/flat-list.native.js.map +1 -0
  7. package/dist/foundation.d.ts +104 -0
  8. package/dist/foundation.d.ts.map +1 -0
  9. package/dist/foundation.js +115 -0
  10. package/dist/foundation.js.map +1 -0
  11. package/dist/foundation.native.d.ts +59 -0
  12. package/dist/foundation.native.d.ts.map +1 -0
  13. package/dist/foundation.native.js +40 -0
  14. package/dist/foundation.native.js.map +1 -0
  15. package/dist/generated/animated.d.ts +2 -0
  16. package/dist/generated/animated.d.ts.map +1 -0
  17. package/dist/generated/animated.js +3 -0
  18. package/dist/generated/animated.js.map +1 -0
  19. package/dist/generated/backdrop-filter.d.ts +2 -0
  20. package/dist/generated/backdrop-filter.d.ts.map +1 -0
  21. package/dist/generated/backdrop-filter.js +3 -0
  22. package/dist/generated/backdrop-filter.js.map +1 -0
  23. package/dist/generated/container.d.ts +2 -0
  24. package/dist/generated/container.d.ts.map +1 -0
  25. package/dist/generated/container.js +3 -0
  26. package/dist/generated/container.js.map +1 -0
  27. package/dist/generated/flat-list.d.ts +2 -0
  28. package/dist/generated/flat-list.d.ts.map +1 -0
  29. package/dist/generated/flat-list.js +2 -0
  30. package/dist/generated/flat-list.js.map +1 -0
  31. package/dist/generated/flat-list.native.d.ts +3 -0
  32. package/dist/generated/flat-list.native.d.ts.map +1 -0
  33. package/dist/generated/flat-list.native.js +2 -0
  34. package/dist/generated/flat-list.native.js.map +1 -0
  35. package/dist/generated/grid.d.ts +3 -0
  36. package/dist/generated/grid.d.ts.map +1 -0
  37. package/dist/generated/grid.js +4 -0
  38. package/dist/generated/grid.js.map +1 -0
  39. package/dist/generated/link.d.ts +2 -0
  40. package/dist/generated/link.d.ts.map +1 -0
  41. package/dist/generated/link.js +2 -0
  42. package/dist/generated/link.js.map +1 -0
  43. package/dist/generated/link.native.d.ts +2 -0
  44. package/dist/generated/link.native.d.ts.map +1 -0
  45. package/dist/generated/link.native.js +2 -0
  46. package/dist/generated/link.native.js.map +1 -0
  47. package/dist/generated/pressable.d.ts +2 -0
  48. package/dist/generated/pressable.d.ts.map +1 -0
  49. package/dist/generated/pressable.js +2 -0
  50. package/dist/generated/pressable.js.map +1 -0
  51. package/dist/generated/pressable.native.d.ts +2 -0
  52. package/dist/generated/pressable.native.d.ts.map +1 -0
  53. package/dist/generated/pressable.native.js +2 -0
  54. package/dist/generated/pressable.native.js.map +1 -0
  55. package/dist/generated/refresh-control.d.ts +2 -0
  56. package/dist/generated/refresh-control.d.ts.map +1 -0
  57. package/dist/generated/refresh-control.js +2 -0
  58. package/dist/generated/refresh-control.js.map +1 -0
  59. package/dist/generated/refresh-control.native.d.ts +2 -0
  60. package/dist/generated/refresh-control.native.d.ts.map +1 -0
  61. package/dist/generated/refresh-control.native.js +2 -0
  62. package/dist/generated/refresh-control.native.js.map +1 -0
  63. package/dist/generated/scroll-view.d.ts +2 -0
  64. package/dist/generated/scroll-view.d.ts.map +1 -0
  65. package/dist/generated/scroll-view.js +2 -0
  66. package/dist/generated/scroll-view.js.map +1 -0
  67. package/dist/generated/scroll-view.native.d.ts +2 -0
  68. package/dist/generated/scroll-view.native.d.ts.map +1 -0
  69. package/dist/generated/scroll-view.native.js +2 -0
  70. package/dist/generated/scroll-view.native.js.map +1 -0
  71. package/dist/generated/spaced.d.ts +2 -0
  72. package/dist/generated/spaced.d.ts.map +1 -0
  73. package/dist/generated/spaced.js +3 -0
  74. package/dist/generated/spaced.js.map +1 -0
  75. package/dist/generated/text-input.d.ts +2 -0
  76. package/dist/generated/text-input.d.ts.map +1 -0
  77. package/dist/generated/text-input.js +2 -0
  78. package/dist/generated/text-input.js.map +1 -0
  79. package/dist/generated/text-input.native.d.ts +2 -0
  80. package/dist/generated/text-input.native.d.ts.map +1 -0
  81. package/dist/generated/text-input.native.js +2 -0
  82. package/dist/generated/text-input.native.js.map +1 -0
  83. package/dist/generated/text-size.d.ts +2 -0
  84. package/dist/generated/text-size.d.ts.map +1 -0
  85. package/dist/generated/text-size.js +3 -0
  86. package/dist/generated/text-size.js.map +1 -0
  87. package/dist/generated/text.d.ts +2 -0
  88. package/dist/generated/text.d.ts.map +1 -0
  89. package/dist/generated/text.js +5 -0
  90. package/dist/generated/text.js.map +1 -0
  91. package/dist/generated/view.d.ts +2 -0
  92. package/dist/generated/view.d.ts.map +1 -0
  93. package/dist/generated/view.js +2 -0
  94. package/dist/generated/view.js.map +1 -0
  95. package/dist/generated/view.native.d.ts +2 -0
  96. package/dist/generated/view.native.d.ts.map +1 -0
  97. package/dist/generated/view.native.js +2 -0
  98. package/dist/generated/view.native.js.map +1 -0
  99. package/dist/index.d.ts +188 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +718 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/index.native.d.ts +22 -0
  104. package/dist/index.native.d.ts.map +1 -0
  105. package/dist/index.native.js +8 -0
  106. package/dist/index.native.js.map +1 -0
  107. package/dist/link.d.ts +320 -0
  108. package/dist/link.d.ts.map +1 -0
  109. package/dist/link.js +69 -0
  110. package/dist/link.js.map +1 -0
  111. package/dist/link.native.d.ts +33 -0
  112. package/dist/link.native.d.ts.map +1 -0
  113. package/dist/link.native.js +44 -0
  114. package/dist/link.native.js.map +1 -0
  115. package/dist/pressable.d.ts +65 -0
  116. package/dist/pressable.d.ts.map +1 -0
  117. package/dist/pressable.js +202 -0
  118. package/dist/pressable.js.map +1 -0
  119. package/dist/pressable.native.d.ts +55 -0
  120. package/dist/pressable.native.d.ts.map +1 -0
  121. package/dist/pressable.native.js +405 -0
  122. package/dist/pressable.native.js.map +1 -0
  123. package/dist/runtime-backdrop.native.d.ts +8 -0
  124. package/dist/runtime-backdrop.native.d.ts.map +1 -0
  125. package/dist/runtime-backdrop.native.js +12 -0
  126. package/dist/runtime-backdrop.native.js.map +1 -0
  127. package/dist/runtime-container.native.d.ts +41 -0
  128. package/dist/runtime-container.native.d.ts.map +1 -0
  129. package/dist/runtime-container.native.js +61 -0
  130. package/dist/runtime-container.native.js.map +1 -0
  131. package/dist/runtime-grid.d.ts +37 -0
  132. package/dist/runtime-grid.d.ts.map +1 -0
  133. package/dist/runtime-grid.js +139 -0
  134. package/dist/runtime-grid.js.map +1 -0
  135. package/dist/runtime-grid.native.d.ts +26 -0
  136. package/dist/runtime-grid.native.d.ts.map +1 -0
  137. package/dist/runtime-grid.native.js +76 -0
  138. package/dist/runtime-grid.native.js.map +1 -0
  139. package/dist/runtime-measured.d.ts +20 -0
  140. package/dist/runtime-measured.d.ts.map +1 -0
  141. package/dist/runtime-measured.js +42 -0
  142. package/dist/runtime-measured.js.map +1 -0
  143. package/dist/runtime-spacing.d.ts +9 -0
  144. package/dist/runtime-spacing.d.ts.map +1 -0
  145. package/dist/runtime-spacing.js +35 -0
  146. package/dist/runtime-spacing.js.map +1 -0
  147. package/dist/runtime-spacing.native.d.ts +12 -0
  148. package/dist/runtime-spacing.native.d.ts.map +1 -0
  149. package/dist/runtime-spacing.native.js +64 -0
  150. package/dist/runtime-spacing.native.js.map +1 -0
  151. package/dist/runtime-text-size.native.d.ts +29 -0
  152. package/dist/runtime-text-size.native.d.ts.map +1 -0
  153. package/dist/runtime-text-size.native.js +51 -0
  154. package/dist/runtime-text-size.native.js.map +1 -0
  155. package/dist/runtime-transition.native.d.ts +15 -0
  156. package/dist/runtime-transition.native.d.ts.map +1 -0
  157. package/dist/runtime-transition.native.js +156 -0
  158. package/dist/runtime-transition.native.js.map +1 -0
  159. package/dist/text-input.d.ts +40 -0
  160. package/dist/text-input.d.ts.map +1 -0
  161. package/dist/text-input.js +54 -0
  162. package/dist/text-input.js.map +1 -0
  163. package/dist/view.d.ts +42 -0
  164. package/dist/view.d.ts.map +1 -0
  165. package/dist/view.js +84 -0
  166. package/dist/view.js.map +1 -0
  167. package/dist/view.native.d.ts +8 -0
  168. package/dist/view.native.d.ts.map +1 -0
  169. package/dist/view.native.js +5 -0
  170. package/dist/view.native.js.map +1 -0
  171. package/dist/windowing.d.ts +149 -0
  172. package/dist/windowing.d.ts.map +1 -0
  173. package/dist/windowing.js +336 -0
  174. package/dist/windowing.js.map +1 -0
  175. package/package.json +160 -0
  176. package/src/flat-list.native.tsx +158 -0
  177. package/src/foundation.native.tsx +179 -0
  178. package/src/foundation.tsx +323 -0
  179. package/src/generated/animated.ts +6 -0
  180. package/src/generated/backdrop-filter.ts +5 -0
  181. package/src/generated/container.ts +7 -0
  182. package/src/generated/flat-list.native.ts +6 -0
  183. package/src/generated/flat-list.ts +7 -0
  184. package/src/generated/grid.ts +4 -0
  185. package/src/generated/link.native.ts +1 -0
  186. package/src/generated/link.ts +1 -0
  187. package/src/generated/pressable.native.ts +5 -0
  188. package/src/generated/pressable.ts +5 -0
  189. package/src/generated/refresh-control.native.ts +4 -0
  190. package/src/generated/refresh-control.ts +1 -0
  191. package/src/generated/scroll-view.native.ts +4 -0
  192. package/src/generated/scroll-view.ts +1 -0
  193. package/src/generated/spaced.ts +2 -0
  194. package/src/generated/text-input.native.ts +4 -0
  195. package/src/generated/text-input.ts +1 -0
  196. package/src/generated/text-size.ts +7 -0
  197. package/src/generated/text.ts +8 -0
  198. package/src/generated/view.native.ts +1 -0
  199. package/src/generated/view.ts +1 -0
  200. package/src/index.native.ts +24 -0
  201. package/src/index.ts +1111 -0
  202. package/src/link.native.tsx +77 -0
  203. package/src/link.ts +125 -0
  204. package/src/pressable.native.tsx +538 -0
  205. package/src/pressable.ts +358 -0
  206. package/src/runtime-backdrop.native.tsx +22 -0
  207. package/src/runtime-container.native.tsx +105 -0
  208. package/src/runtime-grid.native.tsx +143 -0
  209. package/src/runtime-grid.ts +198 -0
  210. package/src/runtime-measured.ts +42 -0
  211. package/src/runtime-spacing.native.tsx +75 -0
  212. package/src/runtime-spacing.ts +37 -0
  213. package/src/runtime-text-size.native.tsx +79 -0
  214. package/src/runtime-transition.native.tsx +183 -0
  215. package/src/text-input.ts +129 -0
  216. package/src/view.native.ts +7 -0
  217. package/src/view.ts +165 -0
  218. package/src/windowing.ts +415 -0
@@ -0,0 +1,139 @@
1
+ export function gridLayout(items, columnCount) {
2
+ if (columnCount <= 0)
3
+ return [];
4
+ const occupied = [];
5
+ const placed = [];
6
+ let cursorRow = 0;
7
+ let cursorColumn = 0;
8
+ const free = (row, column, width, height) => {
9
+ for (let y = row; y < row + height; y += 1) {
10
+ for (let x = column; x < column + width; x += 1) {
11
+ if (occupied[y]?.[x])
12
+ return false;
13
+ }
14
+ }
15
+ return true;
16
+ };
17
+ items.forEach((item, child) => {
18
+ const columnSpan = Math.min(columnCount, Math.max(1, Math.trunc(item.span)));
19
+ const rowSpan = Math.max(1, Math.trunc(item.rowSpan ?? 1));
20
+ let row = Math.max(0, Math.trunc(item.rowStart ?? cursorRow));
21
+ let column = item.columnStart === undefined
22
+ ? item.rowStart === undefined
23
+ ? cursorColumn
24
+ : 0
25
+ : Math.min(columnCount - columnSpan, Math.max(0, Math.trunc(item.columnStart)));
26
+ while (column + columnSpan > columnCount || !free(row, column, columnSpan, rowSpan)) {
27
+ if (item.columnStart !== undefined) {
28
+ row += 1;
29
+ }
30
+ else {
31
+ column += 1;
32
+ if (column + columnSpan > columnCount) {
33
+ row += 1;
34
+ column = 0;
35
+ }
36
+ }
37
+ }
38
+ for (let y = row; y < row + rowSpan; y += 1) {
39
+ const cells = (occupied[y] ??= []);
40
+ for (let x = column; x < column + columnSpan; x += 1)
41
+ cells[x] = true;
42
+ }
43
+ placed.push({ child, column, columnSpan, row, rowSpan });
44
+ cursorRow = row;
45
+ cursorColumn = column + columnSpan;
46
+ if (cursorColumn >= columnCount) {
47
+ cursorRow += 1;
48
+ cursorColumn = 0;
49
+ }
50
+ });
51
+ return placed;
52
+ }
53
+ /** Pure row auto-placement. Explicit coordinates/dense can replace this step later. */
54
+ export function gridRows(items, tracks) {
55
+ if (tracks.length === 0 || items.length === 0)
56
+ return [];
57
+ const layout = gridLayout(items, tracks.length);
58
+ const rowCount = Math.max(0, ...layout.map((item) => item.row + item.rowSpan));
59
+ const rows = Array.from({ length: rowCount }, () => []);
60
+ for (let row = 0; row < rowCount; row += 1) {
61
+ // Read once: `rows` was built with exactly `rowCount` entries, so this
62
+ // index is in range by construction.
63
+ const cells = rows[row];
64
+ let column = 0;
65
+ const starts = layout.filter((item) => item.row === row).sort((a, b) => a.column - b.column);
66
+ for (const item of starts) {
67
+ while (column < item.column) {
68
+ cells.push({ child: null, tracks: tracks.slice(column, column + 1) });
69
+ column += 1;
70
+ }
71
+ cells.push({ child: item.child, tracks: tracks.slice(column, column + item.columnSpan) });
72
+ column += item.columnSpan;
73
+ }
74
+ while (column < tracks.length) {
75
+ cells.push({ child: null, tracks: tracks.slice(column, column + 1) });
76
+ column += 1;
77
+ }
78
+ }
79
+ return rows;
80
+ }
81
+ export function gridCellStyle(tracks, internalGap = 0) {
82
+ const fr = tracks.reduce((sum, track) => sum + (track.kind === 'fr' || track.kind === 'minmax' ? track.value : 0), 0);
83
+ const points = tracks.reduce((sum, track) => sum + (track.kind === 'points' ? track.value : track.kind === 'minmax' ? track.min : 0), Math.max(0, tracks.length - 1) * internalGap);
84
+ return { flexBasis: points, flexGrow: fr, flexShrink: fr > 0 ? 1 : 0 };
85
+ }
86
+ export function gridTrackSizes(tracks, width, gap) {
87
+ const fixed = tracks.reduce((sum, track) => sum + (track.kind === 'points' ? track.value : track.kind === 'minmax' ? track.min : 0), 0);
88
+ const fr = tracks.reduce((sum, track) => sum + (track.kind === 'fr' || track.kind === 'minmax' ? track.value : 0), 0);
89
+ const free = Math.max(0, width - fixed - Math.max(0, tracks.length - 1) * gap);
90
+ return tracks.map((track) => {
91
+ if (track.kind === 'points')
92
+ return track.value;
93
+ const share = fr === 0 ? 0 : (free * track.value) / fr;
94
+ return track.kind === 'minmax' ? track.min + share : share;
95
+ });
96
+ }
97
+ export function gridRowSizes(layout, measuredHeights, rowGap, explicitTracks = []) {
98
+ const count = Math.max(explicitTracks.length, 0, ...layout.map((item) => item.row + item.rowSpan));
99
+ const rows = Array.from({ length: count }, (_, row) => explicitTracks[row]?.kind === 'points'
100
+ ? explicitTracks[row].value
101
+ : explicitTracks[row]?.kind === 'minmax'
102
+ ? explicitTracks[row].min
103
+ : 0);
104
+ for (const item of layout.filter((item) => item.rowSpan === 1)) {
105
+ const track = explicitTracks[item.row];
106
+ if (track?.kind === 'points')
107
+ continue;
108
+ const factor = track?.kind === 'fr' || track?.kind === 'minmax' ? track.value : 1;
109
+ const intrinsic = Math.max(0, (measuredHeights[item.child] ?? 0) - (track?.kind === 'minmax' ? track.min : 0));
110
+ const unit = intrinsic / factor;
111
+ if (track?.kind === 'fr' || track?.kind === 'minmax') {
112
+ for (let row = 0; row < explicitTracks.length; row += 1) {
113
+ const candidate = explicitTracks[row];
114
+ if (candidate.kind === 'fr')
115
+ rows[row] = Math.max(rows[row], unit * candidate.value);
116
+ if (candidate.kind === 'minmax') {
117
+ rows[row] = Math.max(rows[row], candidate.min + unit * candidate.value);
118
+ }
119
+ }
120
+ }
121
+ else {
122
+ rows[item.row] = Math.max(rows[item.row] ?? 0, measuredHeights[item.child] ?? 0);
123
+ }
124
+ }
125
+ for (const item of [...layout].sort((a, b) => a.rowSpan - b.rowSpan)) {
126
+ if (item.rowSpan === 1)
127
+ continue;
128
+ const current = rows.slice(item.row, item.row + item.rowSpan).reduce((a, b) => a + b, 0) +
129
+ (item.rowSpan - 1) * rowGap;
130
+ const deficit = Math.max(0, (measuredHeights[item.child] ?? 0) - current);
131
+ const flexible = Array.from({ length: item.rowSpan }, (_, offset) => item.row + offset).filter((row) => explicitTracks[row]?.kind !== 'points');
132
+ const targets = flexible.length > 0 ? flexible : [];
133
+ for (const row of targets) {
134
+ rows[row] = (rows[row] ?? 0) + deficit / targets.length;
135
+ }
136
+ }
137
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AC,CAAC,MAAM,CAC5F,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,IAAI,KAAK,QAAQ,CAChD,CAAA;QACD,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;QACnD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;QACzD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type GridTrack } from './runtime-grid.ts';
3
+ interface Props {
4
+ tracks: readonly GridTrack[];
5
+ rowTracks?: readonly GridTrack[];
6
+ columnGap?: number;
7
+ rowGap?: number;
8
+ children?: ReactNode;
9
+ }
10
+ /**
11
+ * The first renderer for Hozo's grid solver boundary. It needs no
12
+ * measurement: fixed tracks and fr tracks are solved by one Yoga flex row.
13
+ * Empty cells preserve track widths on the final row.
14
+ */
15
+ export declare function HozoGrid({ tracks, rowTracks, columnGap, rowGap, children, }: Props): ReactNode;
16
+ interface ItemProps {
17
+ columnSpan?: number;
18
+ columnStart?: number;
19
+ rowSpan?: number;
20
+ rowStart?: number;
21
+ children?: ReactNode;
22
+ }
23
+ /** Compiler marker consumed by HozoGrid; outside one it is an identity wrapper. */
24
+ export declare function HozoGridItem({ children }: ItemProps): ReactNode;
25
+ export {};
26
+ //# sourceMappingURL=runtime-grid.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-grid.native.d.ts","sourceRoot":"","sources":["../src/runtime-grid.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAE1E,OAAO,EACL,KAAK,SAAS,EAMf,MAAM,mBAAmB,CAAA;AAG1B,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IAC5B,SAAS,CAAC,EAAE,SAAS,SAAS,EAAE,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,SAAc,EACd,SAAa,EACb,MAAU,EACV,QAAQ,GACT,EAAE,KAAK,GAAG,SAAS,CA4FnB;AAED,UAAU,SAAS;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,SAAS,GAAG,SAAS,CAE/D"}
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, isValidElement, useState } from 'react';
3
+ import { View } from 'react-native';
4
+ import { gridCellStyle, gridLayout, gridRowSizes, gridRows, gridTrackSizes, } from './runtime-grid.js';
5
+ import { keepIfSettled } from './runtime-measured.js';
6
+ /**
7
+ * The first renderer for Hozo's grid solver boundary. It needs no
8
+ * measurement: fixed tracks and fr tracks are solved by one Yoga flex row.
9
+ * Empty cells preserve track widths on the final row.
10
+ */
11
+ export function HozoGrid({ tracks, rowTracks = [], columnGap = 0, rowGap = 0, children, }) {
12
+ const [width, setWidth] = useState(0);
13
+ const [heights, setHeights] = useState([]);
14
+ const list = Children.toArray(children);
15
+ const placements = list.map((child) => isValidElement(child) && child.type === HozoGridItem
16
+ ? {
17
+ span: child.props.columnSpan ?? 1,
18
+ columnStart: child.props.columnStart,
19
+ rowSpan: child.props.rowSpan,
20
+ rowStart: child.props.rowStart,
21
+ }
22
+ : { span: 1 });
23
+ const layout = gridLayout(placements, tracks.length);
24
+ const measured = rowTracks.length > 0 ||
25
+ placements.some((item) => (item.rowSpan ?? 1) > 1 || item.rowStart !== undefined);
26
+ if (measured) {
27
+ const columns = gridTrackSizes(tracks, width, columnGap);
28
+ const rows = gridRowSizes(layout, heights, rowGap, rowTracks);
29
+ const offsets = (sizes, gap) => sizes.map((_, index) => sizes.slice(0, index).reduce((a, b) => a + b, 0) + index * gap);
30
+ const left = offsets(columns, columnGap);
31
+ const top = offsets(rows, rowGap);
32
+ const totalHeight = rows.reduce((a, b) => a + b, 0) + Math.max(0, rows.length - 1) * rowGap;
33
+ const rememberHeight = (child) => (event) => {
34
+ const height = event.nativeEvent.layout.height;
35
+ setHeights((current) => {
36
+ const kept = keepIfSettled(current[child], height);
37
+ return kept === current[child] ? current : Object.assign([...current], { [child]: kept });
38
+ });
39
+ };
40
+ return (_jsx(View, { style: { position: 'relative', alignSelf: 'stretch', height: totalHeight },
41
+ // Guarded, and its sibling above always was. This one was not,
42
+ // and that asymmetry is the whole bug: the container height is
43
+ // derived from the measured heights, so every height change
44
+ // relaid the container out and fired this again. With the same
45
+ // integer width React bails and it stops; with a width that
46
+ // wobbles in the last decimal it never does.
47
+ onLayout: (event) => {
48
+ const next = event.nativeEvent.layout.width;
49
+ setWidth((current) => keepIfSettled(current, next));
50
+ }, children: layout.map((item) => {
51
+ const cellWidth = columns.slice(item.column, item.column + item.columnSpan).reduce((a, b) => a + b, 0) +
52
+ (item.columnSpan - 1) * columnGap;
53
+ const cellHeight = rows.slice(item.row, item.row + item.rowSpan).reduce((a, b) => a + b, 0) +
54
+ (item.rowSpan - 1) * rowGap;
55
+ return (_jsx(View, { onLayout: rememberHeight(item.child), style: {
56
+ position: 'absolute',
57
+ left: left[item.column],
58
+ top: top[item.row],
59
+ width: cellWidth,
60
+ ...(cellHeight > 0 ? { height: cellHeight } : {}),
61
+ }, children: unwrapGridItem(list[item.child]) }, item.child));
62
+ }) }));
63
+ }
64
+ const rows = gridRows(placements, tracks);
65
+ return rows.map((cells, row) => (_jsx(View, { style: { flexDirection: 'row', columnGap }, children: cells.map((cell, column) => (_jsx(View, { style: gridCellStyle(cell.tracks, columnGap), children: cell.child === null ? null : unwrapGridItem(list[cell.child]) }, column))) }, row)));
66
+ }
67
+ /** Compiler marker consumed by HozoGrid; outside one it is an identity wrapper. */
68
+ export function HozoGridItem({ children }) {
69
+ return children;
70
+ }
71
+ function unwrapGridItem(child) {
72
+ return isValidElement(child) && child.type === HozoGridItem
73
+ ? child.props.children
74
+ : child;
75
+ }
76
+ //# sourceMappingURL=runtime-grid.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-grid.native.js","sourceRoot":"","sources":["../src/runtime-grid.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAkB,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,EAA0B,IAAI,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAEL,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,GACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAUrD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,MAAM,EACN,SAAS,GAAG,EAAE,EACd,SAAS,GAAG,CAAC,EACb,MAAM,GAAG,CAAC,EACV,QAAQ,GACF;IACN,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACrC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAA;IACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvC,MAAM,UAAU,GAAG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AAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAEzC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAK9B,KAAC,IAAI,IAAW,KAAK,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,YACvD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAK3B,KAAC,IAAI,IAAc,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,YAC5D,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IADrD,MAAM,CAEV,CACR,CAAC,IATO,GAAG,CAUP,CACR,CAAC,CAAA;AACJ,CAAC;AAUD,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAa;IAClD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,cAAc,CAAC,KAAgB;IACtC,OAAO,cAAc,CAAY,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;QACpE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ;QACtB,CAAC,CAAC,KAAK,CAAA;AACX,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * How far a measurement has to move before it counts as having moved.
3
+ *
4
+ * Half a device pixel: below anything a track size or a container query can
5
+ * express, and above the noise a Yoga pass produces.
6
+ */
7
+ export declare const SETTLED = 0.5;
8
+ /**
9
+ * The value to keep, given what is stored and what was just measured.
10
+ *
11
+ * Returns `current` when the two are the same size, so React bails out of
12
+ * the render rather than starting the next lap. A tolerance rather than a
13
+ * lock: a rotation moves a width by hundreds of pixels and the layout still
14
+ * has to follow it.
15
+ *
16
+ * `undefined` and `NaN` both count as moved, which is what an unmeasured
17
+ * box should do -- it has no size yet, so any size is news.
18
+ */
19
+ export declare function keepIfSettled(current: number | undefined, measured: number): number;
20
+ //# sourceMappingURL=runtime-measured.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-measured.d.ts","sourceRoot":"","sources":["../src/runtime-measured.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,eAAO,MAAM,OAAO,MAAM,CAAA;AAE1B;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGnF"}
@@ -0,0 +1,42 @@
1
+ // When a measurement has moved, for a layout that feeds its own input.
2
+ //
3
+ // `HozoGrid` and `HozoContainer` both read a box back from `onLayout` and
4
+ // store it, and both then render something whose size depends on what they
5
+ // stored. That loop is fine while the number comes back the same. It does
6
+ // not always: `onLayout` reports floats, and 372.99998 and 373.00002 are
7
+ // different numbers to `===` and the same width to everyone else.
8
+ //
9
+ // The grid found this the hard way. On an emulator its screen never
10
+ // stopped drawing -- `uiautomator dump` could not find an idle window
11
+ // across six attempts and the frame counter climbed by about twenty-four a
12
+ // second with nobody touching it -- and a screenshot showed the screen
13
+ // half-built, stopped inside the grid. The guard existed on the heights it
14
+ // measured and not on the width, two adjacent lines apart.
15
+ //
16
+ // So the rule lives here rather than as a constant copied into each. Both
17
+ // components had their own idea of what "unchanged" meant, and one of them
18
+ // was wrong; a second copy of the fix would be the same bet again.
19
+ /**
20
+ * How far a measurement has to move before it counts as having moved.
21
+ *
22
+ * Half a device pixel: below anything a track size or a container query can
23
+ * express, and above the noise a Yoga pass produces.
24
+ */
25
+ export const SETTLED = 0.5;
26
+ /**
27
+ * The value to keep, given what is stored and what was just measured.
28
+ *
29
+ * Returns `current` when the two are the same size, so React bails out of
30
+ * the render rather than starting the next lap. A tolerance rather than a
31
+ * lock: a rotation moves a width by hundreds of pixels and the layout still
32
+ * has to follow it.
33
+ *
34
+ * `undefined` and `NaN` both count as moved, which is what an unmeasured
35
+ * box should do -- it has no size yet, so any size is news.
36
+ */
37
+ export function keepIfSettled(current, measured) {
38
+ if (current === undefined)
39
+ return measured;
40
+ return Math.abs(current - measured) < SETTLED ? current : measured;
41
+ }
42
+ //# sourceMappingURL=runtime-measured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-measured.js","sourceRoot":"","sources":["../src/runtime-measured.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,yEAAyE;AACzE,kEAAkE;AAClE,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,2EAA2E;AAC3E,uEAAuE;AACvE,2EAA2E;AAC3E,2DAA2D;AAC3D,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,mEAAmE;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B,EAAE,QAAgB;IACzE,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAA;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAA;AACpE,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The indices of `children` that should receive the spacing style: every
3
+ * element except the last one.
4
+ *
5
+ * `isElement` is passed in rather than imported so this stays testable --
6
+ * it's `React.isValidElement` at the call site.
7
+ */
8
+ export declare function spacingTargets(children: readonly unknown[], isElement: (child: unknown) => boolean): number[];
9
+ //# sourceMappingURL=runtime-spacing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-spacing.d.ts","sourceRoot":"","sources":["../src/runtime-spacing.ts"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GACrC,MAAM,EAAE,CAQV"}
@@ -0,0 +1,35 @@
1
+ // Which children `space-*` and `divide-*` reach.
2
+ //
3
+ // On Web these compile to `:where(.cls > :not(:last-child))` and the browser
4
+ // answers the question at match time. React Native has no selector engine,
5
+ // so the answer has to be computed -- and computed the same way, or the two
6
+ // backends lay out differently from the same source.
7
+ //
8
+ // The subtlety worth having a testable function for is what counts as a
9
+ // child. `:not(:last-child)` is an *element* selector: a text node at the
10
+ // end of the parent is not `:last-child`, so the last element still gets no
11
+ // margin. `React.Children.toArray` keeps strings in the array, so taking
12
+ // "everything but the final entry" would disagree with Web exactly when a
13
+ // component ends with a stray line of text -- which is easy to write and
14
+ // hard to notice.
15
+ //
16
+ // Kept free of `react` imports so it can be tested without one; the glue
17
+ // lives in `./spacing.native.tsx`.
18
+ /**
19
+ * The indices of `children` that should receive the spacing style: every
20
+ * element except the last one.
21
+ *
22
+ * `isElement` is passed in rather than imported so this stays testable --
23
+ * it's `React.isValidElement` at the call site.
24
+ */
25
+ export function spacingTargets(children, isElement) {
26
+ const elements = [];
27
+ for (const [index, child] of children.entries()) {
28
+ if (isElement(child))
29
+ elements.push(index);
30
+ }
31
+ // Nothing to space if there's one element or none: on Web the sole
32
+ // element *is* `:last-child` and matches nothing.
33
+ return elements.slice(0, -1);
34
+ }
35
+ //# sourceMappingURL=runtime-spacing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-spacing.js","sourceRoot":"","sources":["../src/runtime-spacing.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,qDAAqD;AACrD,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,yEAAyE;AACzE,kBAAkB;AAClB,EAAE;AACF,yEAAyE;AACzE,mCAAmC;AAEnC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,QAA4B,EAC5B,SAAsC;IAEtC,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAChD,IAAI,SAAS,CAAC,KAAK,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IACD,mEAAmE;IACnE,kDAAkD;IAClD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type ReactNode } from 'react';
2
+ interface Props {
3
+ /**
4
+ * The style each spaced child receives -- a `StyleSheet` entry the
5
+ * compiler generated from the parent's `space-*`/`divide-*` utilities.
6
+ */
7
+ style: unknown;
8
+ children?: ReactNode;
9
+ }
10
+ export declare function HozoSpaced({ style, children }: Props): ReactNode;
11
+ export {};
12
+ //# sourceMappingURL=runtime-spacing.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-spacing.native.d.ts","sourceRoot":"","sources":["../src/runtime-spacing.native.tsx"],"names":[],"mappings":"AAOA,OAAO,EAA6D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjG,UAAU,KAAK;IACb;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AA2CD,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,GAAG,SAAS,CAahE"}
@@ -0,0 +1,64 @@
1
+ // The React glue for `./spacing.ts`. Thin on purpose -- everything worth
2
+ // testing is there, free of `react` imports; this file is the part that can
3
+ // only be verified by running an app, same division as `./hooks.native.ts`.
4
+ //
5
+ // Generated components render this; nothing here is meant to be written by
6
+ // hand.
7
+ import { Children, cloneElement, isValidElement } from 'react';
8
+ import { spacingTargets } from './runtime-spacing.js';
9
+ /**
10
+ * Applies a parent's `space-*`/`divide-*` to its children.
11
+ *
12
+ * Renders no host view: it returns its children rather than an element, so
13
+ * Yoga sees exactly the same tree it would without this in it, and the
14
+ * parent's flex layout is unchanged.
15
+ *
16
+ * The style is merged *behind* each child's own, matching the `:where()`
17
+ * wrapper the Web rule uses to hold specificity at zero -- a child's own
18
+ * `mt-8` beats the parent's `space-y-4` on both backends.
19
+ *
20
+ * Compile-time resolution isn't possible in general and that is why this
21
+ * exists: `{items.map(...)}` is one child as far as the compiler can see
22
+ * and any number of them at runtime, so the count that decides which child
23
+ * is last is only known here.
24
+ */
25
+ /**
26
+ * The parent spacing behind a child's own style, in whatever shape the
27
+ * child's style has.
28
+ *
29
+ * A Pressable's style can be a *callback*, and the compiler emits one for
30
+ * any element with a state variant -- `hover:`, `focus-visible:`,
31
+ * `active:`. Putting a function in an array does not compose it with
32
+ * anything: React Native flattens the array, finds a function where a
33
+ * style object belongs, and skips it. The child then renders with the
34
+ * spacing and nothing else -- no background, no padding, no radius.
35
+ *
36
+ * That is what made the acceptance screen's Continue button invisible
37
+ * (#357), and it was not the button. Six probes on a screen whose
38
+ * container uses `gap-*` all drew, including one copied prop for prop;
39
+ * the difference was the `space-y-4` on the container.
40
+ *
41
+ * So a callback stays a callback, with the spacing behind whatever it
42
+ * returns for the state it is called with.
43
+ */
44
+ function spaced(parent, own) {
45
+ if (typeof own !== 'function')
46
+ return [parent, own];
47
+ const resolve = own;
48
+ return (state) => [parent, resolve(state)];
49
+ }
50
+ export function HozoSpaced({ style, children }) {
51
+ // `toArray` flattens nested arrays and drops null/undefined/booleans, so
52
+ // a conditional child that renders nothing doesn't take the last slot and
53
+ // silently swallow the spacing -- the same way an unrendered element
54
+ // wouldn't be `:last-child` on Web.
55
+ const list = Children.toArray(children);
56
+ const targets = new Set(spacingTargets(list, isValidElement));
57
+ return list.map((child, index) => {
58
+ if (!targets.has(index))
59
+ return child;
60
+ const element = child;
61
+ return cloneElement(element, { style: spaced(style, element.props.style) });
62
+ });
63
+ }
64
+ //# sourceMappingURL=runtime-spacing.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-spacing.native.js","sourceRoot":"","sources":["../src/runtime-spacing.native.tsx"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,EAAE;AACF,2EAA2E;AAC3E,QAAQ;AAER,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAqC,MAAM,OAAO,CAAA;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAWrD;;;;;;;;;;;;;;;GAeG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAS,MAAM,CAAC,MAAe,EAAE,GAAY;IAC3C,IAAI,OAAO,GAAG,KAAK,UAAU;QAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,GAAkC,CAAA;IAClD,OAAO,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AACrD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAS;IACnD,yEAAyE;IACzE,0EAA0E;IAC1E,qEAAqE;IACrE,oCAAoC;IACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAA;IAE7D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QACrC,MAAM,OAAO,GAAG,KAA0C,CAAA;QAC1D,OAAO,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC7E,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StyleProp, type TextProps, type TextStyle } from 'react-native';
3
+ export interface HozoTextSizeProps extends Omit<TextProps, 'style'> {
4
+ children?: ReactNode;
5
+ style?: StyleProp<TextStyle>;
6
+ }
7
+ /**
8
+ * A `Text` that says what size it resolved to.
9
+ *
10
+ * Emitted for an element whose style the compiler could not read and
11
+ * which has something below it that scales against the size. `flatten`
12
+ * is what React Native itself does with a style array, so this reads the
13
+ * value that applied rather than one of the values that contributed.
14
+ */
15
+ export declare function HozoTextSize({ children, style, ...props }: HozoTextSizeProps): import("react").JSX.Element;
16
+ export interface HozoRelativeTextProps extends HozoTextSizeProps {
17
+ /** The multiplier, from the compiler's own table. */
18
+ hozoRelative: number;
19
+ }
20
+ /**
21
+ * A `Text` sized as a fraction of the text around it.
22
+ *
23
+ * Publishes what it resolved to as well as reading it, so `<Small>`
24
+ * inside a `<Small>` compounds the way `small small` does in a browser.
25
+ * An explicit size in `style` still wins: it is later in the array, which
26
+ * is how React Native resolves the two.
27
+ */
28
+ export declare function HozoRelativeText({ children, hozoRelative, style, ...props }: HozoRelativeTextProps): import("react").JSX.Element;
29
+ //# sourceMappingURL=runtime-text-size.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-text-size.native.d.ts","sourceRoot":"","sources":["../src/runtime-text-size.native.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAE/F,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC;IACjE,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,+BAW5E;AAED,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,GAAG,KAAK,EACT,EAAE,qBAAqB,+BAWvB"}
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // The size a relative one scales against, where the compiler could not
3
+ // resolve it.
4
+ //
5
+ // React Native offers nothing for this. Its `fontSize` is a number of
6
+ // points with no `em`, a nested `Text` inherits visually but cannot read
7
+ // what it inherited, and the only ancestor context the platform exposes --
8
+ // `TextAncestorContext` -- is a boolean saying whether there is a `Text`
9
+ // above at all.
10
+ //
11
+ // So Hozo resolves it, and prefers to do so at build time: a `<Small>`
12
+ // under a `text-xl` compiles to a plain `<Text>` with a number in a
13
+ // stylesheet, and neither of these components appears. They are for the
14
+ // case the compiler cannot see -- an author's `style={{ fontSize: 20 }}`
15
+ // or a `{...spread}`, which is a size that exists only once React Native
16
+ // has evaluated it.
17
+ //
18
+ // The same pattern `HozoGrid` and `HozoSpaced` already follow: static
19
+ // where the answer is knowable, a component where it is not.
20
+ import { HozoTextSizeContext } from '@hozo/engine';
21
+ import { useContext } from 'react';
22
+ import { StyleSheet, Text } from 'react-native';
23
+ /**
24
+ * A `Text` that says what size it resolved to.
25
+ *
26
+ * Emitted for an element whose style the compiler could not read and
27
+ * which has something below it that scales against the size. `flatten`
28
+ * is what React Native itself does with a style array, so this reads the
29
+ * value that applied rather than one of the values that contributed.
30
+ */
31
+ export function HozoTextSize({ children, style, ...props }) {
32
+ const inherited = useContext(HozoTextSizeContext);
33
+ const size = StyleSheet.flatten(style)?.fontSize;
34
+ const resolved = typeof size === 'number' ? size : inherited;
35
+ return (_jsx(HozoTextSizeContext.Provider, { value: resolved, children: _jsx(Text, { style: style, ...props, children: children }) }));
36
+ }
37
+ /**
38
+ * A `Text` sized as a fraction of the text around it.
39
+ *
40
+ * Publishes what it resolved to as well as reading it, so `<Small>`
41
+ * inside a `<Small>` compounds the way `small small` does in a browser.
42
+ * An explicit size in `style` still wins: it is later in the array, which
43
+ * is how React Native resolves the two.
44
+ */
45
+ export function HozoRelativeText({ children, hozoRelative, style, ...props }) {
46
+ const base = useContext(HozoTextSizeContext);
47
+ const resolved = Math.round(base * hozoRelative);
48
+ const flattened = StyleSheet.flatten(style)?.fontSize;
49
+ return (_jsx(HozoTextSizeContext.Provider, { value: typeof flattened === 'number' ? flattened : resolved, children: _jsx(Text, { style: [{ fontSize: resolved }, style], ...props, children: children }) }));
50
+ }
51
+ //# sourceMappingURL=runtime-text-size.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-text-size.native.js","sourceRoot":"","sources":["../src/runtime-text-size.native.tsx"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,cAAc;AACd,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,gBAAgB;AAChB,EAAE;AACF,uEAAuE;AACvE,oEAAoE;AACpE,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,oBAAoB;AACpB,EAAE;AACF,sEAAsE;AACtE,6DAA6D;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAkB,UAAU,EAAE,IAAI,EAAkC,MAAM,cA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ozoTransitionSpec {
4
+ duration: number;
5
+ delay?: number;
6
+ easing: 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
7
+ }
8
+ export interface HozoAnimatedProps {
9
+ style?: StyleProp<ViewStyle>;
10
+ hozoTransition?: HozoTransitionSpec;
11
+ children?: ReactNode;
12
+ [key: string]: unknown;
13
+ }
14
+ export declare function HozoAnimated({ style, hozoTransition, children, ...props }: HozoAnimatedProps): import("react").JSX.Element;
15
+ //# sourceMappingURL=runtime-transition.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-transition.native.d.ts","sourceRoot":"","sources":["../src/runtime-transition.native.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAAE,KAAK,SAAS,EAA8B,MAAM,OAAO,CAAA;AAClE,OAAO,EAAoB,KAAK,SAAS,EAAc,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAE3F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAA;CAC1D;AA6BD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,cAAc,CAAC,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,+BAoG5F"}