{"version":3,"file":"Input.cjs","names":["createVarsResolver","getSize","getFontSize","getRadius","rem","polymorphicFactory","useProps","extractStyleProps","InputWrapperContext","useStyles","Loader","InputClearSection","InputContext","Box","classes","InputWrapper","InputLabel","InputError","InputSuccess","InputDescription","InputPlaceholder","InputClearButton"],"sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import { use } from 'react';\nimport {\n  Box,\n  BoxProps,\n  createVarsResolver,\n  DataAttributes,\n  extractStyleProps,\n  getFontSize,\n  getRadius,\n  getSize,\n  MantineRadius,\n  MantineSize,\n  polymorphicFactory,\n  PolymorphicFactory,\n  rem,\n  StylesApiProps,\n  useProps,\n  useStyles,\n} from '../../core';\nimport { Loader } from '../Loader/Loader';\nimport { InputContext } from './Input.context';\nimport {\n  InputClearButton,\n  type InputClearButtonProps,\n  type InputClearButtonFactory,\n} from './InputClearButton/InputClearButton';\nimport {\n  ClearSectionMode,\n  InputClearSection,\n  type InputClearSectionProps,\n} from './InputClearSection/InputClearSection';\nimport {\n  InputDescription,\n  type InputDescriptionProps,\n  type InputDescriptionStylesNames,\n  type InputDescriptionCssVariables,\n  type InputDescriptionFactory,\n} from './InputDescription/InputDescription';\nimport {\n  InputError,\n  type InputErrorProps,\n  type InputErrorStylesNames,\n  type InputErrorCssVariables,\n  type InputErrorFactory,\n} from './InputError/InputError';\nimport {\n  InputLabel,\n  type InputLabelProps,\n  type InputLabelStylesNames,\n  type InputLabelCssVariables,\n  type InputLabelFactory,\n} from './InputLabel/InputLabel';\nimport {\n  InputPlaceholder,\n  type InputPlaceholderProps,\n  type InputPlaceholderStylesNames,\n  type InputPlaceholderFactory,\n} from './InputPlaceholder/InputPlaceholder';\nimport { InputSuccess } from './InputSuccess/InputSuccess';\nimport { InputWrapperContext } from './InputWrapper.context';\nimport {\n  __InputWrapperProps,\n  InputWrapper,\n  InputWrapperStylesNames,\n  type InputWrapperProps,\n  type InputWrapperFactory,\n} from './InputWrapper/InputWrapper';\nimport classes from './Input.module.css';\n// Required to be a separate type for docgen script\ntype WrapperProps = React.ComponentProps<'div'> & DataAttributes;\n\nexport interface __BaseInputProps extends __InputWrapperProps, __InputProps {\n  /** Props passed down to the root element */\n  wrapperProps?: WrapperProps;\n}\n\nexport type __InputStylesNames = InputStylesNames | InputWrapperStylesNames;\n\nexport type InputStylesNames = 'input' | 'wrapper' | 'section' | 'bottomSection';\nexport type InputVariant = 'default' | 'filled' | 'unstyled';\nexport type InputCssVariables = {\n  wrapper:\n    | '--input-height'\n    | '--input-fz'\n    | '--input-radius'\n    | '--input-left-section-width'\n    | '--input-right-section-width'\n    | '--input-left-section-pointer-events'\n    | '--input-right-section-pointer-events'\n    | '--input-padding-y'\n    | '--input-margin-top'\n    | '--input-margin-bottom';\n};\n\nexport interface InputStylesCtx {\n  offsetTop: boolean | undefined;\n  offsetBottom: boolean | undefined;\n}\n\nexport interface __InputProps {\n  /** Content section displayed on the left side of the input */\n  leftSection?: React.ReactNode;\n\n  /** Left section width, used to set `width` of the section and input `padding-left`, by default equals to the input height */\n  leftSectionWidth?: React.CSSProperties['width'];\n\n  /** Props passed down to the `leftSection` element */\n  leftSectionProps?: React.ComponentProps<'div'>;\n\n  /** Sets `pointer-events` styles on the `leftSection` element. Use `'all'` when section contains interactive elements (buttons, links). @default 'none' */\n  leftSectionPointerEvents?: React.CSSProperties['pointerEvents'];\n\n  /** Content section displayed on the right side of the input */\n  rightSection?: React.ReactNode;\n\n  /** Right section width, used to set `width` of the section and input `padding-right`, by default equals to the input height */\n  rightSectionWidth?: React.CSSProperties['width'];\n\n  /** Props passed down to the `rightSection` element */\n  rightSectionProps?: React.ComponentProps<'div'>;\n\n  /** Sets `pointer-events` styles on the `rightSection` element. Use `'all'` when section contains interactive elements (buttons, links). @default 'none' */\n  rightSectionPointerEvents?: React.CSSProperties['pointerEvents'];\n\n  /** Sets `required` attribute on the `input` element */\n  required?: boolean;\n\n  /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n  radius?: MantineRadius;\n\n  /** Sets `disabled` attribute on the `input` element */\n  disabled?: boolean;\n\n  /** Controls input `height`, horizontal `padding`, and `font-size` @default 'sm' */\n  size?: MantineSize | (string & {});\n\n  /** Determines whether the input should have `cursor: pointer` style. Use when input acts as a button-like trigger (e.g., `component=\"button\"` for Select/DatePicker). @default false */\n  pointer?: boolean;\n\n  /** Determines whether the input should have red border and red text color when the `error` prop is set @default true */\n  withErrorStyles?: boolean;\n\n  /** Determines whether the input should have green border when the `success` prop is set @default true */\n  withSuccessStyles?: boolean;\n\n  /** HTML `size` attribute for the input element (number of visible characters) */\n  inputSize?: string;\n\n  /** Section to be displayed when the input is `__clearable` and `rightSection` is not defined */\n  __clearSection?: React.ReactNode;\n\n  /** Determines whether the `__clearSection` should be displayed if it is passed to the component, has no effect if `rightSection` is defined */\n  __clearable?: boolean;\n\n  /** Determines how the clear button and rightSection are rendered @default 'both' */\n  __clearSectionMode?: ClearSectionMode;\n\n  /** Right section displayed when both `__clearSection` and `rightSection` are not defined */\n  __defaultRightSection?: React.ReactNode;\n\n  /** Displays loading indicator in the left or right section @default false */\n  loading?: boolean;\n\n  /** Position of the loading indicator @default 'right' */\n  loadingPosition?: 'left' | 'right';\n\n  /** Content section displayed at the bottom of the input, inside the border */\n  __bottomSection?: React.ReactNode;\n\n  /** Props passed down to the `__bottomSection` element */\n  __bottomSectionProps?: React.ComponentProps<'div'>;\n}\n\nexport interface InputProps extends BoxProps, __InputProps, StylesApiProps<InputFactory> {\n  __staticSelector?: string;\n\n  /** Props passed to Styles API context, replaces `Input.Wrapper` props */\n  __stylesApiProps?: Record<string, any>;\n\n  /** Determines whether the input should have error styles and `aria-invalid` attribute */\n  error?: React.ReactNode;\n\n  /** Determines whether the input should have success styles */\n  success?: React.ReactNode;\n\n  /** Adjusts padding and sizing calculations for multiline inputs (use with `component=\"textarea\"`). Does not make the input multiline by itself. @default false */\n  multiline?: boolean;\n\n  /** Input element id */\n  id?: string;\n\n  /** Determines whether `aria-` and other accessibility attributes should be added to the input. Only disable when implementing custom accessibility handling. @default true */\n  withAria?: boolean;\n\n  /** Props passed down to the root element of the `Input` component */\n  wrapperProps?: WrapperProps;\n\n  /** Root element ref */\n  rootRef?: React.Ref<HTMLDivElement>;\n}\n\nexport type InputFactory = PolymorphicFactory<{\n  props: InputProps;\n  defaultRef: HTMLInputElement;\n  defaultComponent: 'input';\n  stylesNames: InputStylesNames;\n  variant: InputVariant;\n  vars: InputCssVariables;\n  ctx: InputStylesCtx;\n  staticComponents: {\n    Label: typeof InputLabel;\n    Error: typeof InputError;\n    Success: typeof InputSuccess;\n    Description: typeof InputDescription;\n    Placeholder: typeof InputPlaceholder;\n    Wrapper: typeof InputWrapper;\n    ClearButton: typeof InputClearButton;\n  };\n}>;\n\nconst defaultProps = {\n  variant: 'default',\n  leftSectionPointerEvents: 'none',\n  rightSectionPointerEvents: 'none',\n  withAria: true,\n  withErrorStyles: true,\n  withSuccessStyles: true,\n  size: 'sm',\n  loading: false,\n  loadingPosition: 'right',\n} satisfies Partial<InputProps>;\n\nconst varsResolver = createVarsResolver<InputFactory>((_, props, ctx) => ({\n  wrapper: {\n    '--input-margin-top': ctx.offsetTop ? 'calc(var(--mantine-spacing-xs) / 2)' : undefined,\n    '--input-margin-bottom': ctx.offsetBottom ? 'calc(var(--mantine-spacing-xs) / 2)' : undefined,\n    '--input-height': getSize(props.size, 'input-height'),\n    '--input-fz': getFontSize(props.size),\n    '--input-radius': props.radius === undefined ? undefined : getRadius(props.radius),\n    '--input-left-section-width':\n      props.leftSectionWidth !== undefined ? rem(props.leftSectionWidth) : undefined,\n    '--input-right-section-width':\n      props.rightSectionWidth !== undefined ? rem(props.rightSectionWidth) : undefined,\n    '--input-padding-y': props.multiline ? getSize(props.size, 'input-padding-y') : undefined,\n    '--input-left-section-pointer-events': props.leftSectionPointerEvents,\n    '--input-right-section-pointer-events': props.rightSectionPointerEvents,\n  },\n}));\n\nexport const Input = polymorphicFactory<InputFactory>((_props) => {\n  const props = useProps('Input', defaultProps, _props);\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    unstyled,\n    required,\n    __staticSelector,\n    __stylesApiProps,\n    size,\n    wrapperProps,\n    error,\n    success,\n    disabled,\n    leftSection,\n    leftSectionProps,\n    leftSectionWidth,\n    rightSection,\n    rightSectionProps,\n    rightSectionWidth,\n    rightSectionPointerEvents,\n    leftSectionPointerEvents,\n    variant,\n    vars,\n    pointer,\n    multiline,\n    radius,\n    id,\n    withAria,\n    withErrorStyles,\n    withSuccessStyles,\n    mod,\n    inputSize,\n    attributes,\n    __clearSection,\n    __clearable,\n    __clearSectionMode,\n    __defaultRightSection,\n    loading,\n    loadingPosition,\n    __bottomSection,\n    __bottomSectionProps,\n    rootRef,\n    dir,\n    ...others\n  } = props as typeof props & Pick<React.HTMLAttributes<HTMLDivElement>, 'dir'>;\n\n  const { styleProps, rest } = extractStyleProps(others);\n  const ctx = use(InputWrapperContext);\n  const stylesCtx: InputStylesCtx = { offsetBottom: ctx?.offsetBottom, offsetTop: ctx?.offsetTop };\n\n  const getStyles = useStyles<InputFactory>({\n    name: ['Input', __staticSelector],\n    props: __stylesApiProps || props,\n    classes,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    attributes,\n    stylesCtx,\n    rootSelector: 'wrapper',\n    vars,\n    varsResolver,\n  });\n\n  const ariaAttributes = withAria\n    ? {\n        required,\n        disabled,\n        'aria-invalid': error ? true : undefined,\n        'aria-describedby': ctx?.describedBy,\n        id: ctx?.inputId || id,\n      }\n    : {};\n\n  const loadingIndicator = loading ? (\n    <Loader\n      size={\n        loadingPosition === 'left'\n          ? 'calc(var(--input-left-section-size) / 2)'\n          : 'calc(var(--input-right-section-size) / 2)'\n      }\n    />\n  ) : null;\n\n  const _leftSection = loading && loadingPosition === 'left' ? loadingIndicator : leftSection;\n  const _rightSection: React.ReactNode = InputClearSection({\n    __clearable,\n    __clearSection,\n    rightSection: loading && loadingPosition === 'right' ? loadingIndicator : rightSection,\n    __defaultRightSection,\n    size,\n    __clearSectionMode,\n  });\n\n  return (\n    <InputContext value={{ size: size || 'sm' }}>\n      <Box\n        ref={rootRef}\n        dir={dir}\n        {...getStyles('wrapper')}\n        {...styleProps}\n        {...wrapperProps}\n        mod={[\n          {\n            error: !!error && withErrorStyles,\n            success: !!success && !error && withSuccessStyles,\n            pointer,\n            disabled,\n            multiline,\n            'data-with-right-section': !!_rightSection,\n            'data-with-left-section': !!_leftSection,\n            'data-with-bottom-section': !!__bottomSection,\n          },\n          mod,\n        ]}\n        variant={variant}\n        size={size}\n      >\n        {_leftSection && (\n          <div\n            {...leftSectionProps}\n            data-position=\"left\"\n            {...getStyles('section', {\n              className: leftSectionProps?.className,\n              style: leftSectionProps?.style,\n            })}\n          >\n            {_leftSection}\n          </div>\n        )}\n\n        <Box\n          component=\"input\"\n          {...rest}\n          {...ariaAttributes}\n          required={required}\n          mod={{\n            disabled,\n            error: !!error && withErrorStyles,\n            success: !!success && !error && withSuccessStyles,\n          }}\n          variant={variant}\n          __size={inputSize}\n          {...getStyles('input')}\n        />\n\n        {__bottomSection && (\n          <div\n            {...__bottomSectionProps}\n            {...getStyles('bottomSection', {\n              className: __bottomSectionProps?.className,\n              style: __bottomSectionProps?.style,\n            })}\n          >\n            {__bottomSection}\n          </div>\n        )}\n\n        {_rightSection && (\n          <div\n            {...rightSectionProps}\n            data-position=\"right\"\n            {...getStyles('section', {\n              className: rightSectionProps?.className,\n              style: rightSectionProps?.style,\n            })}\n          >\n            {_rightSection}\n          </div>\n        )}\n      </Box>\n    </InputContext>\n  );\n});\n\nInput.classes = classes;\nInput.varsResolver = varsResolver;\nInput.Wrapper = InputWrapper;\nInput.Label = InputLabel;\nInput.Error = InputError;\nInput.Success = InputSuccess;\nInput.Description = InputDescription;\nInput.Placeholder = InputPlaceholder;\nInput.ClearButton = InputClearButton;\nInput.displayName = '@mantine/core/Input';\n\nexport namespace Input {\n  export type Props = InputProps;\n  export type StylesNames = InputStylesNames;\n  export type CssVariables = InputCssVariables;\n  export type Factory = InputFactory;\n\n  export namespace Wrapper {\n    export type Props = InputWrapperProps;\n    export type StylesNames = InputWrapperStylesNames;\n    export type Factory = InputWrapperFactory;\n  }\n\n  export namespace Description {\n    export type Props = InputDescriptionProps;\n    export type StylesNames = InputDescriptionStylesNames;\n    export type CssVariables = InputDescriptionCssVariables;\n    export type Factory = InputDescriptionFactory;\n  }\n\n  export namespace Error {\n    export type Props = InputErrorProps;\n    export type StylesNames = InputErrorStylesNames;\n    export type CssVariables = InputErrorCssVariables;\n    export type Factory = InputErrorFactory;\n  }\n\n  export namespace Label {\n    export type Props = InputLabelProps;\n    export type StylesNames = InputLabelStylesNames;\n    export type CssVariables = InputLabelCssVariables;\n    export type Factory = InputLabelFactory;\n  }\n\n  export namespace Placeholder {\n    export type Props = InputPlaceholderProps;\n    export type StylesNames = InputPlaceholderStylesNames;\n    export type Factory = InputPlaceholderFactory;\n  }\n\n  export namespace ClearButton {\n    export type Props = InputClearButtonProps;\n    export type Factory = InputClearButtonFactory;\n  }\n\n  export namespace ClearSection {\n    export type Props = InputClearSectionProps;\n    export type Mode = ClearSectionMode;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4NA,MAAM,eAAe;CACnB,SAAS;CACT,0BAA0B;CAC1B,2BAA2B;CAC3B,UAAU;CACV,iBAAiB;CACjB,mBAAmB;CACnB,MAAM;CACN,SAAS;CACT,iBAAiB;AACnB;AAEA,MAAM,eAAeA,6BAAAA,oBAAkC,GAAG,OAAO,SAAS,EACxE,SAAS;CACP,sBAAsB,IAAI,YAAY,wCAAwC,KAAA;CAC9E,yBAAyB,IAAI,eAAe,wCAAwC,KAAA;CACpF,kBAAkBC,iBAAAA,QAAQ,MAAM,MAAM,cAAc;CACpD,cAAcC,iBAAAA,YAAY,MAAM,IAAI;CACpC,kBAAkB,MAAM,WAAW,KAAA,IAAY,KAAA,IAAYC,iBAAAA,UAAU,MAAM,MAAM;CACjF,8BACE,MAAM,qBAAqB,KAAA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