{"version":3,"file":"chunk-Fieldset.mjs","names":["FieldsetPrimitive"],"sources":["../../src/components/Fieldset/Fieldset.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { Fieldset as FieldsetPrimitive, useFieldsetContext } from '@ark-ui/react/fieldset';\nimport React, { forwardRef } from 'react';\n\nimport { mx } from '@dxos/ui-theme';\nimport { type ThemedClassName } from '@dxos/ui-types';\n\nimport { recipes } from '../../recipes.ts';\nimport { type Size } from '../../sizes.ts';\nimport {\n  DefaultGutterProvider,\n  type Level,\n  type Span,\n  containerAttributes,\n  spanAttributes,\n} from '../Container/Container.tsx';\n\n//\n// Root\n//\n\ntype FieldsetRootProps = ThemedClassName<FieldsetPrimitive.RootProps> & {\n  /** Tracks the set spans in its parent Container. */\n  span?: Span;\n  /**\n   * `inherit` makes the set a subgrid of the enclosing Container, as an inheriting Container is, so nested sets keep\n   * the parent's tracks at any depth; without it the set is a flex stack of its own.\n   */\n  gutter?: 'inherit';\n  /** A rung for the set's surface, as on Container; only applies with `gutter='inherit'`. */\n  level?: Level;\n  /**\n   * A nested group (with `gutter='inherit'`): bordered and indented one step inside the parent's content track, on its\n   * host's surface, its fields still sharing the parent's columns.\n   */\n  inset?: boolean;\n};\n\n/**\n * A `group` stacking its Fields with the container gap, named by its Legend; `disabled` and `invalid` reach every\n * child control through context. Not a `<fieldset>`, whose anonymous content box cannot take part in a parent's grid;\n * with `gutter='inherit'` it is a subgrid of its parent.\n */\nconst FieldsetRoot = forwardRef<HTMLDivElement, FieldsetRootProps>(\n  ({ classNames, span, gutter, level, inset, style, disabled, children, ...props }, forwardedRef) => {\n    const { style: spanStyle, ...spanAttrs } = spanAttributes(span);\n    const { style: gridStyle, ...grid } = gutter ? containerAttributes({ gutter, level }) : { style: undefined };\n    return (\n      <FieldsetPrimitive.Root\n        {...props}\n        {...spanAttrs}\n        {...grid}\n        data-inset={gutter && inset ? '' : undefined}\n        disabled={disabled}\n        asChild\n        style={{ ...spanStyle, ...gridStyle, ...style }}\n        className={mx(recipes.fieldsetRoot(), gutter && recipes.container(), classNames)}\n      >\n        <div role='group' aria-disabled={disabled ? true : undefined} ref={forwardedRef}>\n          {gutter ? <DefaultGutterProvider gutter={undefined}>{children}</DefaultGutterProvider> : children}\n        </div>\n      </FieldsetPrimitive.Root>\n    );\n  },\n);\n\nFieldsetRoot.displayName = 'Fieldset.Root';\n\n//\n// Legend\n//\n\ntype FieldsetLegendProps = ThemedClassName<FieldsetPrimitive.LegendProps> & {\n  /** A size of its own makes the legend a heading row; by default it takes the set's size, in its label step. */\n  size?: Size;\n  /** `section` is a top-level section's title: content-coloured, at text-lg. */\n  variant?: 'section';\n};\n\n/** The set's label row, like `Field.Header`: legend text followed by optional trailing Blocks or icon-only Buttons. */\nconst FieldsetLegend = forwardRef<HTMLDivElement, FieldsetLegendProps>(\n  ({ classNames, size, variant, children, ...props }, forwardedRef) => (\n    <FieldsetPrimitive.Legend\n      {...props}\n      asChild\n      data-size={size}\n      data-variant={variant}\n      className={mx(recipes.fieldsetLegend(), classNames)}\n    >\n      <div ref={forwardedRef}>{children}</div>\n    </FieldsetPrimitive.Legend>\n  ),\n);\n\nFieldsetLegend.displayName = 'Fieldset.Legend';\n\n//\n// HelperText\n//\n\ntype FieldsetHelperTextProps = ThemedClassName<FieldsetPrimitive.HelperTextProps>;\n\nconst FieldsetHelperText = forwardRef<HTMLSpanElement, FieldsetHelperTextProps>(\n  ({ classNames, ...props }, forwardedRef) => (\n    <FieldsetPrimitive.HelperText {...props} className={mx(recipes.fieldHelper(), classNames)} ref={forwardedRef} />\n  ),\n);\n\nFieldsetHelperText.displayName = 'Fieldset.HelperText';\n\n//\n// ErrorText\n//\n\ntype FieldsetErrorTextProps = ThemedClassName<FieldsetPrimitive.ErrorTextProps>;\n\n/** Rendered only while the root is `invalid`. */\nconst FieldsetErrorText = forwardRef<HTMLSpanElement, FieldsetErrorTextProps>(\n  ({ classNames, ...props }, forwardedRef) => (\n    <FieldsetPrimitive.ErrorText {...props} className={mx(recipes.fieldError(), classNames)} ref={forwardedRef} />\n  ),\n);\n\nFieldsetErrorText.displayName = 'Fieldset.ErrorText';\n\n/**\n * A control's `disabled`, or else its enclosing Fieldset's: the set is a `div`, so the browser no longer disables its\n * controls.\n */\nexport const useFieldsetDisabled = (disabled?: boolean): boolean | undefined => {\n  const fieldset = useFieldsetContext();\n  return disabled ?? (fieldset?.disabled || undefined);\n};\nexport type {\n  FieldsetErrorTextProps as ErrorTextProps,\n  FieldsetHelperTextProps as HelperTextProps,\n  FieldsetLegendProps as LegendProps,\n  FieldsetRootProps as RootProps,\n};\n\nexport {\n  FieldsetErrorText as ErrorText,\n  FieldsetHelperText as HelperText,\n  FieldsetLegend as Legend,\n  FieldsetRoot as Root,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,IAAM,eAAe,YAClB,EAAE,YAAY,MAAM,QAAQ,OAAO,OAAO,OAAO,UAAU,UAAU,GAAG,SAAS,iBAAiB;CACjG,MAAM,EAAE,OAAO,WAAW,GAAG,cAAc,eAAe,IAAI;CAC9D,MAAM,EAAE,OAAO,WAAW,GAAG,SAAS,SAAS,oBAAoB;EAAE;EAAQ;CAAM,CAAC,IAAI,EAAE,OAAO,KAAA,EAAU;CAC3G,OACE,oBAACA,SAAkB,MAAnB;EACE,GAAI;EACJ,GAAI;EACJ,GAAI;EACJ,cAAY,UAAU,QAAQ,KAAK,KAAA;EACzB;EACV,SAAA;EACA,OAAO;GAAE,GAAG;GAAW,GAAG;GAAW,GAAG;EAAM;EAC9C,WAAW,GAAG,QAAQ,aAAa,GAAG,UAAU,QAAQ,UAAU,GAAG,UAAU;EAE/E,UAAA,oBAAC,OAAD;GAAK,MAAK;GAAQ,iBAAe,WAAW,OAAO,KAAA;GAAW,KAAK;GAChE,UAAA,SAAS,oBAAC,uBAAD;IAAuB,QAAQ,KAAA;IAAY;GAAgC,CAAA,IAAI;EACtF,CAAA;CACiB,CAAA;AAE5B,CACF;AA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