InputNumber.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { ValueType } from '@rc-component/mini-decimal';
  2. import * as React from 'react';
  3. import { BaseInputProps } from 'rc-input/lib/interface';
  4. import { InputFocusOptions } from 'rc-input/lib/utils/commonUtils';
  5. export type { ValueType };
  6. export interface InputNumberRef extends HTMLInputElement {
  7. focus: (options?: InputFocusOptions) => void;
  8. blur: () => void;
  9. nativeElement: HTMLElement;
  10. }
  11. export interface InputNumberProps<T extends ValueType = ValueType> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onInput' | 'onChange' | 'prefix' | 'suffix'> {
  12. /** value will show as string */
  13. stringMode?: boolean;
  14. defaultValue?: T;
  15. value?: T | null;
  16. prefixCls?: string;
  17. className?: string;
  18. style?: React.CSSProperties;
  19. min?: T;
  20. max?: T;
  21. step?: ValueType;
  22. tabIndex?: number;
  23. controls?: boolean;
  24. prefix?: React.ReactNode;
  25. suffix?: React.ReactNode;
  26. addonBefore?: React.ReactNode;
  27. addonAfter?: React.ReactNode;
  28. classNames?: BaseInputProps['classNames'] & {
  29. input?: string;
  30. };
  31. upHandler?: React.ReactNode;
  32. downHandler?: React.ReactNode;
  33. keyboard?: boolean;
  34. changeOnWheel?: boolean;
  35. /** Parse display value to validate number */
  36. parser?: (displayValue: string | undefined) => T;
  37. /** Transform `value` to display value show in input */
  38. formatter?: (value: T | undefined, info: {
  39. userTyping: boolean;
  40. input: string;
  41. }) => string;
  42. /** Syntactic sugar of `formatter`. Config precision of display. */
  43. precision?: number;
  44. /** Syntactic sugar of `formatter`. Config decimal separator of display. */
  45. decimalSeparator?: string;
  46. onInput?: (text: string) => void;
  47. onChange?: (value: T | null) => void;
  48. onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
  49. onStep?: (value: T, info: {
  50. offset: ValueType;
  51. type: 'up' | 'down';
  52. }) => void;
  53. /**
  54. * Trigger change onBlur event.
  55. * If disabled, user must press enter or click handler to confirm the value update
  56. */
  57. changeOnBlur?: boolean;
  58. }
  59. declare const InputNumber: (<T extends ValueType = ValueType>(props: InputNumberProps<T> & {
  60. children?: React.ReactNode;
  61. } & {
  62. ref?: React.Ref<HTMLInputElement>;
  63. }) => React.ReactElement) & {
  64. displayName?: string;
  65. };
  66. export default InputNumber;