{"version":3,"file":"chunk-Input2.mjs","names":["SystemButton.Clipboard","Fieldset.useFieldsetDisabled","FieldPrimitive"],"sources":["../../src/components/ControlFrame/ControlFrame.tsx","../../src/components/Input/Input.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type CSSProperties, type ReactNode } from 'react';\n\nimport { recipes } from '../../recipes.ts';\nimport { composable, composableProps } from '../../util/slots.ts';\nimport { type CSSVariables } from '../Container/Container.tsx';\n\nexport type ControlFrameVariant = 'default' | 'subdued' | 'mono' | 'plain' | 'title';\n\nexport type ControlFrameProps = {\n  'data-testid'?: string;\n  /** Leading content inside the frame (an Icon, or short text such as a currency). */\n  'start'?: ReactNode;\n  /** Trailing content inside the frame (an Icon, a unit, or icon-only Buttons). */\n  'end'?: ReactNode;\n  /**\n   * `subdued` drops the well; `mono` sets the frame's text in the monospace font; `plain` drops the well and the inset,\n   * for text edited in place on a page; `title` is `plain` at the size of a page's title.\n   */\n  'variant'?: ControlFrameVariant;\n  /** Dims the frame, for content (an editor) that has no `disabled` state of its own. */\n  'disabled'?: boolean;\n  /** The `data-scope` a control built on the frame reports for it (decision 10); `control-frame` otherwise. */\n  'scope'?: string;\n  /**\n   * A multi-line frame (a markdown editor) at least this many lines tall, growing with its content like an\n   * auto-resizing Textarea, its first line where a single-line control's text sits and its adornments at the top.\n   */\n  'rows'?: number;\n};\n\n/**\n * The control-tall well of an Input with optional adornments either side of its content: an Input's `start`/`end`\n * render one around a bare input, and editors or custom controls use it directly around their own element. The focus\n * ring follows whatever inside it, other than an adornment, has focus.\n */\nexport const ControlFrame = composable<HTMLDivElement, ControlFrameProps>(\n  ({ children, start, end, variant = 'default', disabled, scope = 'control-frame', rows, ...props }, forwardedRef) => {\n    const { className, style, ...rest } = composableProps<HTMLDivElement>(props, {\n      classNames: recipes.controlFrame(),\n    });\n    const rowsStyle: CSSProperties & CSSVariables = rows ? { '--dx-rows': String(rows) } : {};\n    return (\n      <div\n        {...rest}\n        style={{ ...rowsStyle, ...style }}\n        data-scope={scope}\n        data-part='root'\n        data-variant={variant}\n        data-rows={rows ? '' : undefined}\n        data-disabled={disabled ? '' : undefined}\n        className={className}\n        ref={forwardedRef}\n      >\n        {start != null && (\n          <span data-scope={scope} data-part='start' className={recipes.inputAdornment()}>\n            {start}\n          </span>\n        )}\n        {children}\n        {end != null && (\n          <span data-scope={scope} data-part='end' className={recipes.inputAdornment()}>\n            {end}\n          </span>\n        )}\n      </div>\n    );\n  },\n);\n\nControlFrame.displayName = 'ControlFrame';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { Field as FieldPrimitive } from '@ark-ui/react/field';\nimport React, { type InputHTMLAttributes, type ReactNode, useRef } from 'react';\n\nimport { useComposedRefs } from '@dxos/react-hooks';\n\nimport { recipes } from '../../recipes.ts';\nimport { composable, composableProps } from '../../util/slots.ts';\nimport { ControlFrame, type ControlFrameVariant } from '../ControlFrame/ControlFrame.tsx';\nimport * as Fieldset from '../Fieldset/Fieldset.tsx';\nimport * as SystemButton from '../SystemButton/SystemButton.tsx';\nimport { useToolbarItem } from '../Toolbar/toolbar-context.ts';\n\nexport type InputProps = InputHTMLAttributes<HTMLInputElement> & {\n  'data-testid'?: string;\n  /** `subdued` drops the well, for an input on a surface that already reads as editable; `mono` is for keys and ids. */\n  'variant'?: ControlFrameVariant;\n  /** Ask password managers not to offer autofill (`data-1p-ignore`), e.g. for a search box. */\n  'noAutoFill'?: boolean;\n  /** Leading content inside the control row (an Icon, or short text such as a currency). */\n  'start'?: ReactNode;\n  /** Trailing content inside the control row (an Icon, a unit, or an icon-only Button). */\n  'end'?: ReactNode;\n  /** Trails the input with a copy button for its current value (e.g. a read-only id); replaces `end`. */\n  'copyable'?: boolean;\n};\n\n/**\n * Text input at control size; inside a `Field.Root` it takes the field's id, label and description wiring. With\n * `start` or `end` it renders a `ControlFrame` holding the adornments and a bare input; `data-testid` and classes then\n * go to the frame, the ref to the input.\n */\nexport const Input = composable<HTMLInputElement, InputProps>(\n  (\n    {\n      type = 'text',\n      variant = 'default',\n      noAutoFill,\n      start,\n      end: endProp,\n      copyable,\n      disabled,\n      onFocus,\n      'data-testid': testId,\n      ...props\n    },\n    forwardedRef,\n  ) => {\n    const inputRef = useRef<HTMLInputElement>(null);\n    const ref = useComposedRefs(forwardedRef, inputRef);\n    // Reads the element rather than `value`, so an uncontrolled input copies what it shows.\n    const end = copyable ? (\n      <SystemButton.Clipboard iconOnly variant='ghost' onCopy={() => inputRef.current?.value ?? ''} />\n    ) : (\n      endProp\n    );\n    const fieldsetDisabled = Fieldset.useFieldsetDisabled(disabled);\n    const toolbarItem = useToolbarItem(fieldsetDisabled);\n    const adorned = start != null || end != null;\n    const { className, style, ...rest } = composableProps<HTMLInputElement>(props, {\n      classNames: adorned ? undefined : recipes.input(),\n    });\n    const input = (\n      <FieldPrimitive.Input\n        {...rest}\n        style={adorned ? undefined : style}\n        disabled={fieldsetDisabled}\n        data-testid={adorned ? undefined : testId}\n        {...toolbarItem}\n        onFocus={(event) => {\n          onFocus?.(event);\n          toolbarItem?.onFocus();\n        }}\n        type={type}\n        data-1p-ignore={noAutoFill ? '' : undefined}\n        data-scope='input'\n        data-part={adorned ? 'input' : 'root'}\n        data-variant={adorned ? undefined : variant}\n        className={adorned ? recipes.inputField() : className}\n        ref={ref}\n      />\n    );\n    if (!adorned) {\n      return input;\n    }\n\n    return (\n      <ControlFrame\n        scope='input'\n        start={start}\n        end={end}\n        variant={variant}\n        data-testid={testId}\n        classNames={className}\n        style={style}\n      >\n        {input}\n      </ControlFrame>\n    );\n  },\n);\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,IAAa,eAAe,YACzB,EAAE,UAAU,OAAO,KAAK,UAAU,WAAW,UAAU,QAAQ,iBAAiB,MAAM,GAAG,SAAS,iBAAiB;CAClH,MAAM,EAAE,WAAW,OAAO,GAAG,SAAS,gBAAgC,OAAO,EAC3E,YAAY,QAAQ,aAAa,EACnC,CAAC;CACD,MAAM,YA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