MCPcopy Create free account
hub / github.com/anus-dev/ANUS / visitBoxRow

Function visitBoxRow

packages/cli/src/ui/components/shared/MaxSizedBox.tsx:251–379  ·  view source on GitHub ↗

* Flattens the child elements of MaxSizedBox into an array of `Row` objects. * * This function expects a specific child structure to function correctly: * 1. The top-level child of `MaxSizedBox` should be a single ` `. This * outer box is primarily for structure and is not directly render

(element: React.ReactNode)

Source from the content-addressed store, hash-verified

249 * @returns An array of `Row` objects.
250 */
251function visitBoxRow(element: React.ReactNode): Row {
252 if (
253 !React.isValidElement<{ children?: React.ReactNode }>(element) ||
254 element.type !== Box
255 ) {
256 debugReportError(
257 `All children of MaxSizedBox must be <Box> elements`,
258 element,
259 );
260 return {
261 noWrapSegments: [{ text: '<ERROR>', props: {} }],
262 segments: [],
263 };
264 }
265
266 if (enableDebugLog) {
267 const boxProps = element.props as {
268 children?: React.ReactNode | undefined;
269 readonly flexDirection?:
270 | 'row'
271 | 'column'
272 | 'row-reverse'
273 | 'column-reverse'
274 | undefined;
275 };
276 // Ensure the Box has no props other than the default ones and key.
277 let maxExpectedProps = 4;
278 if (boxProps.children !== undefined) {
279 // Allow the key prop, which is automatically added by React.
280 maxExpectedProps += 1;
281 }
282 if (
283 boxProps.flexDirection !== undefined &&
284 boxProps.flexDirection !== 'row'
285 ) {
286 debugReportError(
287 'MaxSizedBox children must have flexDirection="row".',
288 element,
289 );
290 }
291 if (Object.keys(boxProps).length > maxExpectedProps) {
292 debugReportError(
293 `Boxes inside MaxSizedBox must not have additional props. ${Object.keys(
294 boxProps,
295 ).join(', ')}`,
296 element,
297 );
298 }
299 }
300
301 const row: Row = {
302 noWrapSegments: [],
303 segments: [],
304 };
305
306 let hasSeenWrapped = false;
307
308 function visitRowChild(

Callers 1

Calls 2

debugReportErrorFunction · 0.85
visitRowChildFunction · 0.85

Tested by

no test coverage detected