{"version":3,"file":"PillsInputField.cjs","names":["factory","useProps","PillsInputContext","InputWrapperContext","useStyles","Box","classes"],"sources":["../../../../src/components/PillsInput/PillsInputField/PillsInputField.tsx"],"sourcesContent":["import { use } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport {\n  Box,\n  BoxProps,\n  ElementProps,\n  factory,\n  Factory,\n  StylesApiProps,\n  useProps,\n  useStyles,\n} from '../../../core';\nimport { InputWrapperContext } from '../../Input';\nimport { PillsInputContext } from '../PillsInput.context';\nimport classes from '../PillsInput.module.css';\n\nexport type PillsInputFieldStylesNames = 'field';\n\nexport interface PillsInputFieldProps\n  extends BoxProps, StylesApiProps<PillsInputFieldFactory>, ElementProps<'input', 'type'> {\n  /** Controls input styles when focused. If `auto` the input is hidden when not focused. If `visible` the input will always remain visible. @default 'visible' */\n  type?: 'auto' | 'visible' | 'hidden';\n\n  /** If set, cursor is changed to pointer */\n  pointer?: boolean;\n}\n\nexport type PillsInputFieldFactory = Factory<{\n  props: PillsInputFieldProps;\n  ref: HTMLInputElement;\n  stylesNames: PillsInputFieldStylesNames;\n}>;\n\nconst defaultProps = {\n  type: 'visible',\n} satisfies Partial<PillsInputFieldProps>;\n\nexport const PillsInputField = factory<PillsInputFieldFactory>((_props) => {\n  const props = useProps('PillsInputField', defaultProps, _props);\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    unstyled,\n    vars,\n    type,\n    disabled,\n    id,\n    pointer,\n    mod,\n    attributes,\n    ref,\n    ...others\n  } = props;\n  const ctx = use(PillsInputContext);\n  const inputWrapperCtx = use(InputWrapperContext);\n\n  const getStyles = useStyles<PillsInputFieldFactory>({\n    name: 'PillsInputField',\n    classes,\n    props,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    attributes,\n    rootSelector: 'field',\n  });\n\n  const _disabled = disabled || ctx?.disabled;\n\n  return (\n    <Box\n      component=\"input\"\n      ref={useMergedRef(ref, ctx?.fieldRef)}\n      data-type={type}\n      disabled={_disabled}\n      mod={[{ disabled: _disabled, pointer }, mod]}\n      {...getStyles('field')}\n      {...others}\n      id={inputWrapperCtx?.inputId || id}\n      aria-invalid={ctx?.hasError}\n      aria-describedby={inputWrapperCtx?.describedBy}\n      type=\"text\"\n      onMouseDown={(event) => !pointer && event.stopPropagation()}\n    />\n  );\n});\n\nPillsInputField.classes = classes;\nPillsInputField.displayName = '@mantine/core/PillsInputField';\n"],"mappings":";;;;;;;;;;;;;AAiCA,MAAM,eAAe,EACnB,MAAM,WACP;AAED,MAAa,kBAAkBA,gBAAAA,SAAiC,WAAW;CACzE,MAAM,QAAQC,kBAAAA,SAAS,mBAAmB,cAAc,OAAO;CAC/D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,UACA,IACA,SACA,KACA,YACA,KACA,GAAG,WACD;CACJ,MAAM,OAAA,GAAA,MAAA,KAAUC,2BAAAA,kBAAkB;CAClC,MAAM,mBAAA,GAAA,MAAA,KAAsBC,6BAAAA,oBAAoB;CAEhD,MAAM,YAAYC,mBAAAA,UAAkC;EAClD,MAAM;EACN,SAAA,0BAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACf,CAAC;CAEF,MAAM,YAAY,YAAY,KAAK;AAEnC,QACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EACE,WAAU;EACV,MAAA,GAAA,eAAA,cAAkB,KAAK,KAAK,SAAS;EACrC,aAAW;EACX,UAAU;EACV,KAAK,CAAC;GAAE,UAAU;GAAW;GAAS,EAAE,IAAI;EAC5C,GAAI,UAAU,QAAQ;EACtB,GAAI;EACJ,IAAI,iBAAiB,WAAW;EAChC,gBAAc,KAAK;EACnB,oBAAkB,iBAAiB;EACnC,MAAK;EACL,cAAc,UAAU,CAAC,WAAW,MAAM,iBAAiB;EAC3D,CAAA;EAEJ;AAEF,gBAAgB,UAAUC,0BAAAA;AAC1B,gBAAgB,cAAc"}