{"version":3,"file":"chunk-Layout.mjs","names":["ScrollArea.Root","ScrollArea.Viewport"],"sources":["../../src/layout/layout.ts","../../src/layout/Grid/Grid.tsx","../../src/layout/Columns/Columns.tsx","../../src/layout/Flex/Flex.tsx","../../src/namespaces/Layout.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n/**\n * Gap steps, named for the spacing ramp in `ui-theme/src/css/theme/spacing.css`\n * (4/8/12/16/24/32) plus the two semantic form aliases. Numeric Tailwind gaps (`gap-2`, `gap-3`) are\n * deliberately not members: the union steers callers onto the ramp. It does not fence them — a\n * `gap-*` literal passed through `classNames` still applies.\n */\nexport type Gap = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'form' | 'form-section';\n\nexport const gapClasses: Record<Gap, string> = {\n  'none': 'gap-0',\n  'xs': 'gap-trim-xs',\n  'sm': 'gap-trim-sm',\n  'md': 'gap-trim-md',\n  'lg': 'gap-trim-lg',\n  'xl': 'gap-trim-xl',\n  '2xl': 'gap-trim-2xl',\n  'form': 'gap-form-gap',\n  'form-section': 'gap-form-section-gap',\n};\n\nexport type Align = 'start' | 'center' | 'end' | 'baseline' | 'stretch';\n\nexport const alignClasses: Record<Align, string> = {\n  start: 'items-start',\n  center: 'items-center',\n  end: 'items-end',\n  baseline: 'items-baseline',\n  stretch: 'items-stretch',\n};\n\nexport type Justify = 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';\n\nexport const justifyClasses: Record<Justify, string> = {\n  start: 'justify-start',\n  center: 'justify-center',\n  end: 'justify-end',\n  between: 'justify-between',\n  around: 'justify-around',\n  evenly: 'justify-evenly',\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { ark } from '@ark-ui/react/factory';\nimport React from 'react';\n\nimport { mx } from '@dxos/ui-theme';\n\nimport { composableProps, slottable } from '../../util/slots.ts';\nimport { type Align, type Gap, alignClasses, gapClasses } from '../layout.ts';\n\n/** A fixed track size, passed through as written. */\nexport type GridLength =\n  | `${number}${'rem' | 'em' | 'px' | 'ch' | '%' | 'vw' | 'vh'}`\n  | `var(--${string})`\n  | `calc(${string})`\n  | `minmax(${string})`;\n\n/**\n * One track: `fill` takes the remaining space and may shrink below its content (`minmax(0, 1fr)`), a number is a\n * share of it (`minmax(0, <n>fr)`), `min`/`max`/`auto` size to the content, and a length is fixed.\n */\nexport type GridTrack = 'fill' | 'min' | 'max' | 'auto' | number | GridLength;\n\n/** Track definition: a count of equal `fill` tracks, a list of tracks, or `subgrid` to adopt the parent grid's. */\nexport type GridTracks = number | 'subgrid' | readonly GridTrack[];\n\nexport type GridProps = {\n  cols?: GridTracks;\n  rows?: GridTracks;\n  gap?: Gap;\n  align?: Align;\n  /** Center children on both axes (`place-items-center`). */\n  center?: boolean;\n  /** Fill and clip the parent (`dx-expand`); off by default, as `Flex`'s is, so a grid sizes to its content. */\n  grow?: boolean;\n  /**\n   * Collapse the wrapper to `display: contents`, so children join the parent grid directly. For a\n   * wrapper that exists only conditionally — an unconditional pass-through wants `asChild`.\n   */\n  contents?: boolean;\n};\n\n/**\n * CSS grid container.\n *\n * `cols`/`rows` take a count for equal tracks, or a list of tokens for anything asymmetric: `cols={['fill', 'min']}` is\n * `grid-cols-[1fr_min-content]`, with the flexible track allowed to shrink so long content truncates rather than\n * widening the grid. The tokens are typed, so a misspelt track is a compile error rather than an invalid template.\n *\n * `subgrid` adopts the parent's tracks and spans them (`grid-column: 1 / -1`), which is the only\n * way it is ever useful; the parent must actually define those tracks. Check `Column.Row` and\n * `Card.Row` first — both already are 3-track subgrid rows.\n *\n * `gap` is restricted to the named steps of the theme spacing ramp (see {@link Gap}). As with\n * `Flex`, padding, sizing, and colour go through `classNames` rather than growing props here.\n *\n * @example\n * ```tsx\n * <Grid cols={3} gap='sm'>…</Grid>\n * <Grid cols={['fill', 'auto']} gap='md' align='center'>…</Grid>\n * <Grid cols={['18rem', 'fill']}>…</Grid>\n * <Grid cols='subgrid' gap='sm' align='center'>…</Grid>\n * ```\n */\nexport const Grid = slottable<HTMLDivElement, GridProps>(\n  (\n    { children, asChild, style, role, cols, rows, gap, align, center, grow = false, contents, ...props },\n    forwardedRef,\n  ) => {\n    const { className, ...rest } = composableProps<HTMLDivElement>(props);\n\n    return (\n      <ark.div\n        asChild={asChild}\n        ref={forwardedRef}\n        {...rest}\n        role={role ?? 'none'}\n        className={\n          contents\n            ? mx('contents', className)\n            : mx(\n                'grid',\n                // `dx-expand` already clips; a non-growing grid must not, or converting a plain\n                // wrapper would silently start cutting off overflow (focus rings, popovers).\n                grow && 'dx-expand',\n                cols === 'subgrid' && 'col-span-full',\n                rows === 'subgrid' && 'row-span-full',\n                gap && gapClasses[gap],\n                center && 'place-items-center',\n                align && alignClasses[align],\n                className,\n              )\n        }\n        style={\n          contents\n            ? style\n            : {\n                gridTemplateColumns: cols !== undefined ? trackList(cols) : undefined,\n                gridTemplateRows: rows !== undefined ? trackList(rows) : undefined,\n                ...style,\n              }\n        }\n      >\n        {children}\n      </ark.div>\n    );\n  },\n);\n\nconst TRACK_SIZES: Record<'fill' | 'min' | 'max' | 'auto', string> = {\n  fill: 'minmax(0, 1fr)',\n  min: 'min-content',\n  max: 'max-content',\n  auto: 'auto',\n};\n\nconst trackSize = (track: GridTrack): string =>\n  typeof track === 'number'\n    ? `minmax(0, ${track}fr)`\n    : track === 'fill' || track === 'min' || track === 'max' || track === 'auto'\n      ? TRACK_SIZES[track]\n      : track;\n\nconst trackList = (tracks: GridTracks): string =>\n  typeof tracks === 'number'\n    ? `repeat(${tracks}, minmax(0, 1fr))`\n    : tracks === 'subgrid'\n      ? 'subgrid'\n      : tracks.map(trackSize).join(' ');\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { Children, type PropsWithChildren, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nimport * as ScrollArea from '../../components/ScrollArea/ScrollArea.tsx';\nimport { composable } from '../../util/slots.ts';\nimport { usePx } from '../../util/usePx.ts';\nimport { Grid, type GridLength } from '../Grid/Grid.tsx';\n\n// A horizontal run of columns sized to the space it has: as many as fit at their minimum width, each an exact share of\n// the width, so the visible columns always fill it; past that the run scrolls a column at a time.\n\nexport type ColumnsProps = PropsWithChildren<{\n  /** The narrowest a column may be, in rem; the count is however many fit at this width. */\n  minColumnWidth?: number;\n  /** The most columns shown at once, however wide the space. */\n  maxColumns?: number;\n  /** Space between columns, in rem. */\n  gap?: number;\n  /** When a column is added, scroll so the newest is in view (a Finder-style drill-down). */\n  follow?: boolean;\n}>;\n\n/** How many columns of at least `minPx` (with `gapPx` between) fit in `widthPx`, and how wide each is then. */\nexport const fitColumns = (widthPx: number, minPx: number, gapPx: number, maxColumns?: number) => {\n  const fits = Math.max(1, Math.floor((widthPx + gapPx) / (minPx + gapPx)));\n  const count = maxColumns === undefined ? fits : Math.max(1, Math.min(fits, maxColumns));\n  return { count, width: (widthPx - (count - 1) * gapPx) / count };\n};\n\n// Composable, so a host's `Panel.Body asChild` makes the scroll frame its growing row.\nexport const Columns = composable<HTMLDivElement, ColumnsProps>(\n  ({ minColumnWidth = 24, maxColumns, gap = 0, follow = true, children, ...props }, forwardedRef) => {\n    const minPx = usePx(minColumnWidth);\n    const gapPx = usePx(gap);\n    const viewportRef = useRef<HTMLDivElement>(null);\n    const [widthPx, setWidthPx] = useState(0);\n    const columns = Children.toArray(children).length;\n\n    // The viewport's content width decides the column width, so it is measured before paint and on every resize.\n    useLayoutEffect(() => {\n      const viewport = viewportRef.current;\n      if (!viewport) {\n        return;\n      }\n      const measure = () => setWidthPx(viewport.clientWidth);\n      measure();\n      const observer = new ResizeObserver(measure);\n      observer.observe(viewport);\n      return () => observer.disconnect();\n    }, []);\n\n    useEffect(() => {\n      if (follow) {\n        viewportRef.current?.scrollTo({ left: viewportRef.current.scrollWidth, behavior: 'smooth' });\n      }\n    }, [follow, columns]);\n\n    const { width } = fitColumns(widthPx, minPx, gapPx, maxColumns);\n    const track: GridLength = widthPx > 0 ? `${width}px` : `${minColumnWidth}rem`;\n    return (\n      <ScrollArea.Root {...props} orientation='horizontal' snap autoHide={false} ref={forwardedRef}>\n        <ScrollArea.Viewport ref={viewportRef}>\n          <Grid\n            cols={Children.map(children, () => track) ?? []}\n            rows={['fill']}\n            style={{ columnGap: gapPx }}\n            // Each column snaps to the viewport's start, so scrolling moves a whole column at a time.\n            classNames='h-full [&>*]:snap-start'\n          >\n            {children}\n          </Grid>\n        </ScrollArea.Viewport>\n      </ScrollArea.Root>\n    );\n  },\n);\n\nColumns.displayName = 'Columns';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { ark } from '@ark-ui/react/factory';\nimport React from 'react';\n\nimport { mx } from '@dxos/ui-theme';\n\nimport { composableProps, slottable } from '../../util/slots.ts';\nimport { type Align, type Gap, type Justify, alignClasses, gapClasses, justifyClasses } from '../layout.ts';\n\nexport type FlexProps = {\n  /** Stack on the block axis instead of the inline axis. */\n  column?: boolean;\n  gap?: Gap;\n  align?: Align;\n  justify?: Justify;\n  wrap?: boolean;\n  /** Absorb slack from the parent track (`flex-1`) and clip rather than push it wider. */\n  grow?: boolean;\n  /** Center on both axes; equivalent to `align='center' justify='center'`. */\n  center?: boolean;\n};\n\n/**\n * One-axis layout box: the primitive that replaces hand-written `flex …` wrapper divs.\n *\n * `gap` is restricted to the named steps of the theme spacing ramp (see {@link Gap}), which is the\n * point of the prop — an off-ramp `gap-2`/`gap-3` literal in a container is the drift it prevents.\n * Anything the props don't cover (padding, sizing, overflow, colour) goes through `classNames`; the\n * component deliberately grows no padding or colour props, since components own their own spacing.\n *\n * There is no implicit `align`. Row-centering is the common case, but defaulting it would silently\n * restyle any consumer relying on the CSS `stretch` initial value.\n *\n * Use `asChild` to project the layout onto a semantic element (`<header>`, `<ul>`, `<a>`).\n *\n * @example\n * ```tsx\n * <Flex column gap='sm'>…</Flex>\n * <Flex gap='sm' justify='end'>…</Flex>\n * <Flex center classNames='h-full text-fg-subtle' role='status'>{t('empty.message')}</Flex>\n * ```\n */\nexport const Flex = slottable<HTMLDivElement, FlexProps>(\n  ({ children, asChild, column, gap, align, justify, wrap, grow, center, ...props }, forwardedRef) => {\n    const { className, ...rest } = composableProps(props);\n    return (\n      <ark.div\n        asChild={asChild}\n        ref={forwardedRef}\n        {...rest}\n        className={mx(\n          'flex',\n          column && 'flex-col',\n          gap && gapClasses[gap],\n          center && 'items-center justify-center',\n          align && alignClasses[align],\n          justify && justifyClasses[justify],\n          wrap && 'flex-wrap',\n          grow && 'flex-1 overflow-hidden',\n          className,\n        )}\n      >\n        {children}\n      </ark.div>\n    );\n  },\n);\n\nFlex.displayName = 'Flex';\n\nexport * from '../layout.ts';\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport * from '../layout/Columns/Columns.tsx';\nexport * from '../layout/Flex/Flex.tsx';\nexport * from '../layout/Grid/Grid.tsx';\nexport * from '../components/Block/Block.tsx';\nexport * from '../components/Container/Container.tsx';\nexport * from '../components/Separator/Separator.tsx';\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,aAAkC;CAC7C,QAAQ;CACR,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,gBAAgB;AAClB;AAIA,IAAa,eAAsC;CACjD,OAAO;CACP,QAAQ;CACR,KAAK;CACL,UAAU;CACV,SAAS;AACX;AAIA,IAAa,iBAA0C;CACrD,OAAO;CACP,QAAQ;CACR,KAAK;CACL,SAAS;CACT,QAAQ;CACR,QAAQ;AACV;;;;;;;;;;;;;;;;;;;;;;;;;ACuBA,IAAa,OAAO,WAEhB,EAAE,UAAU,SAAS,OAAO,MAAM,MAAM,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAO,UAAU,GAAG,SAC7F,iBACG;CACH,MAAM,EAAE,WAAW,GAAG,SAAS,gBAAgC,KAAK;CAEpE,OACE,oBAAC,IAAI,KAAL;EACW;EACT,KAAK;EACL,GAAI;EACJ,MAAM,QAAQ;EACd,WACE,WACI,GAAG,YAAY,SAAS,IACxB,GACE,QAGA,QA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