{"version":3,"file":"MonthPickerInput.cjs","names":["pickCalendarProps","useDatesInput","PickerInputBase","MonthPicker","getDefaultClampedDate"],"sources":["../../../src/components/MonthPickerInput/MonthPickerInput.tsx"],"sourcesContent":["import {\n  __InputStylesNames,\n  BoxProps,\n  factory,\n  Factory,\n  InputVariant,\n  MantineComponentStaticProperties,\n  StylesApiProps,\n  useProps,\n  useResolvedStylesApi,\n} from '@mantine/core';\nimport { useDatesInput } from '../../hooks';\nimport { DatePickerType } from '../../types';\nimport { getDefaultClampedDate } from '../../utils';\nimport { pickCalendarProps } from '../Calendar';\nimport { MonthPicker, MonthPickerBaseProps, MonthPickerStylesNames } from '../MonthPicker';\nimport { DateInputSharedProps, PickerInputBase } from '../PickerInputBase';\n\nexport type MonthPickerInputStylesNames =\n  | __InputStylesNames\n  | 'placeholder'\n  | MonthPickerStylesNames;\n\nexport interface MonthPickerInputProps<Type extends DatePickerType = 'default'>\n  extends\n    BoxProps,\n    DateInputSharedProps,\n    MonthPickerBaseProps<Type>,\n    StylesApiProps<MonthPickerInputFactory> {\n  /** `dayjs` format for input value @default \"MMMM YYYY\" */\n  valueFormat?: string;\n}\n\nexport type MonthPickerInputFactory = Factory<{\n  props: MonthPickerInputProps;\n  ref: HTMLButtonElement;\n  stylesNames: MonthPickerInputStylesNames;\n  variant: InputVariant;\n}>;\n\nconst defaultProps = {\n  type: 'default',\n  size: 'sm',\n  valueFormat: 'MMMM YYYY',\n  closeOnChange: true,\n  sortDates: true,\n  dropdownType: 'popover',\n} satisfies Partial<MonthPickerInputProps>;\n\ntype MonthPickerInputComponent = (<Type extends DatePickerType = 'default'>(\n  props: MonthPickerInputProps<Type> & { ref?: React.Ref<HTMLButtonElement> }\n) => React.JSX.Element) & {\n  displayName?: string;\n} & MantineComponentStaticProperties<MonthPickerInputFactory>;\n\nexport const MonthPickerInput: MonthPickerInputComponent = factory<MonthPickerInputFactory>(\n  (_props) => {\n    const props = useProps(['Input', 'InputWrapper', 'MonthPickerInput'], defaultProps, _props);\n    const {\n      type,\n      value,\n      defaultValue,\n      onChange,\n      valueFormat,\n      labelSeparator,\n      locale,\n      classNames,\n      styles,\n      unstyled,\n      closeOnChange,\n      size,\n      variant,\n      dropdownType,\n      sortDates,\n      minDate,\n      maxDate,\n      vars,\n      valueFormatter,\n      presets,\n      attributes,\n      ...rest\n    } = props;\n\n    const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<MonthPickerInputFactory>({\n      classNames,\n      styles,\n      props,\n    });\n\n    const { calendarProps, others } = pickCalendarProps(rest);\n\n    const {\n      _value,\n      setValue,\n      formattedValue,\n      dropdownHandlers,\n      dropdownOpened,\n      onClear,\n      shouldClear,\n    } = useDatesInput({\n      type: type as any,\n      value,\n      defaultValue,\n      onChange: onChange as any,\n      locale,\n      format: valueFormat,\n      labelSeparator,\n      closeOnChange,\n      sortDates,\n      valueFormatter,\n    });\n\n    return (\n      <PickerInputBase\n        formattedValue={formattedValue}\n        dropdownOpened={dropdownOpened}\n        dropdownHandlers={dropdownHandlers}\n        classNames={resolvedClassNames}\n        styles={resolvedStyles}\n        unstyled={unstyled}\n        onClear={onClear}\n        shouldClear={shouldClear}\n        value={_value}\n        size={size}\n        variant={variant}\n        dropdownType={dropdownType}\n        {...others}\n        attributes={attributes}\n        type={type as any}\n        __staticSelector=\"MonthPickerInput\"\n      >\n        <MonthPicker\n          {...calendarProps}\n          size={size}\n          variant={variant}\n          type={type}\n          value={_value}\n          defaultDate={\n            calendarProps.defaultDate ||\n            (Array.isArray(_value)\n              ? _value[0] || getDefaultClampedDate({ maxDate, minDate })\n              : _value || getDefaultClampedDate({ maxDate, minDate }))\n          }\n          onChange={setValue}\n          locale={locale}\n          classNames={resolvedClassNames}\n          styles={resolvedStyles}\n          unstyled={unstyled}\n          __staticSelector=\"MonthPickerInput\"\n          __stopPropagation={dropdownType === 'popover'}\n          minDate={minDate}\n          maxDate={maxDate}\n          presets={presets}\n          attributes={attributes}\n        />\n      </PickerInputBase>\n    );\n  }\n) as any;\n\nMonthPickerInput.classes = { ...PickerInputBase.classes, ...MonthPicker.classes };\nMonthPickerInput.displayName = '@mantine/dates/MonthPickerInput';\n\nexport namespace MonthPickerInput {\n  export type Props<Type extends DatePickerType = 'default'> = MonthPickerInputProps<Type>;\n  export type StylesNames = MonthPickerInputStylesNames;\n  export type Factory = MonthPickerInputFactory;\n}\n"],"mappings":";;;;;;;;;AAwCA,MAAM,eAAe;CACnB,MAAM;CACN,MAAM;CACN,aAAa;CACb,eAAe;CACf,WAAW;CACX,cAAc;AAChB;AAQA,MAAa,oBAAA,GAAA,cAAA,QAAA,EACV,WAAW;CACV,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB;EAAC;EAAS;EAAgB;CAAkB,GAAG,cAAc,MAAM;CAC1F,MAAM,EACJ,MACA,OACA,cACA,UACA,aACA,gBACA,QACA,YACA,QACA,UACA,eACA,MACA,SACA,cACA,WACA,SACA,SACA,MACA,gBACA,SACA,YACA,GAAG,SACD;CAEJ,MAAM,EAAE,oBAAoB,oBAAA,GAAA,cAAA,qBAAA,CAAiE;EAC3F;EACA;EACA;CACF,CAAC;CAED,MAAM,EAAE,eAAe,WAAWA,mCAAAA,kBAAkB,IAAI;CAExD,MAAM,EACJ,QACA,UACA,gBACA,kBACA,gBACA,SACA,gBACEC,wBAAAA,cAAc;EACV;EACN;EACA;EACU;EACV;EACA,QAAQ;EACR;EACA;EACA;EACA;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,iBAAD;EACkB;EACA;EACE;EAClB,YAAY;EACZ,QAAQ;EACE;EACD;EACI;EACb,OAAO;EACD;EACG;EACK;EACd,GAAI;EACQ;EACN;EACN,kBAAiB;YAEjB,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,aAAD;GACE,GAAI;GACE;GACG;GACH;GACN,OAAO;GACP,aACE,cAAc,gBACb,MAAM,QAAQ,MAAM,IACjB,OAAO,MAAMC,iCAAAA,sBAAsB;IAAE;IAAS;GAAQ,CAAC,IACvD,UAAUA,iCAAAA,sBAAsB;IAAE;IAAS;GAAQ,CAAC;GAE1D,UAAU;GACF;GACR,YAAY;GACZ,QAAQ;GACE;GACV,kBAAiB;GACjB,mBAAmB,iBAAiB;GAC3B;GACA;GACA;GACG;EACb,CAAA;CACc,CAAA;AAErB,CACF;AAEA,iBAAiB,UAAU;CAAE,GAAGF,wBAAAA,gBAAgB;CAAS,GAAGC,oBAAAA,YAAY;AAAQ;AAChF,iBAAiB,cAAc"}