UNPKG

3.43 kBTypeScriptView Raw
1import React from 'react';
2import { Localizer } from './Localization';
3import { WidgetProps } from './Widget';
4import { WidgetHTMLProps } from './shared';
5export interface NumberPickerProps extends WidgetHTMLProps, Omit<WidgetProps, 'onChange'> {
6 /**
7 * @example ['valuePicker', [ [1, null] ]]
8 */
9 value?: number | undefined;
10 /**
11 * @example ['onChangePicker', [ [1, null] ]]
12 */
13 onChange?: (nextValue: number | null, ctx: {
14 rawValue: number;
15 originalEvent: React.SyntheticEvent<HTMLDivElement | HTMLButtonElement> | null;
16 lastValue: number | undefined;
17 }) => void;
18 /**
19 * The minimum number that the NumberPicker value.
20 * @example ['prop', ['min', 0]]
21 */
22 min?: number;
23 /**
24 * The maximum number that the NumberPicker value.
25 *
26 * @example ['prop', ['max', 0]]
27 */
28 max?: number;
29 /**
30 * Amount to increase or decrease value when using the spinner buttons.
31 *
32 * @example ['prop', ['step', 5]]
33 */
34 step?: number;
35 /**
36 * Specify the decimal precision of the value when incrementing or decrementing by the
37 * `step` value. This may be necessary to work around rounding issues due to
38 * floating point math. By default the precision value used will be inferred
39 * from the `step` and `value`, rounding the result to that.
40 */
41 precision?: number | 'auto';
42 /**
43 * A format string used to display the number value. Localizer dependent, read [localization](./localization) for more info.
44 *
45 * @example ['prop', { max: 1, min: -1 , defaultValue: 0.2585, format: "{ style: 'percent' }" }]
46 */
47 format?: string;
48 /**
49 * Determines how the NumberPicker parses a number from the localized string representation.
50 *
51 * ```jsx live
52 * import NumberPicker from 'react-widgets/NumberPicker';
53 *
54 * <NumberPicker
55 * parse={(strValue, localizer) => {
56 * return localizer.parseNumber(strValue.replace('_', ''))
57 * }}
58 * />
59 * ```
60 *
61 * @example false
62 */
63 parse?: (str: string, localizer: Localizer) => number;
64 incrementIcon?: React.ReactNode;
65 decrementIcon?: React.ReactNode;
66 /** @ignore */
67 tabIndex?: number;
68 name?: string;
69 placeholder?: string;
70 onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
71 onKeyPress?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
72 onKeyUp?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
73 autoFocus?: boolean;
74 /**
75 * @example ['disabled', ['1']]
76 */
77 disabled?: boolean;
78 /**
79 * @example ['readOnly', ['1.5']]
80 */
81 readOnly?: boolean;
82 /** Adds a css class to the input container element. */
83 containerClassName?: string;
84 inputProps?: React.HtmlHTMLAttributes<HTMLInputElement>;
85 messages?: {
86 increment?: string;
87 decrement?: string;
88 };
89 /** @ignore */
90 localizer?: Localizer;
91}
92/**
93 * ---
94 * localized: true
95 * shortcuts:
96 * - { key: down arrow, label: decrement value }
97 * - { key: up arrow, label: increment value }
98 * - { key: home, label: set value to minimum value, if finite }
99 * - { key: end, label: set value to maximum value, if finite }
100 * ---
101 *
102 * @public
103 */
104declare function NumberPicker(uncontrolledProps: NumberPickerProps): JSX.Element;
105export default NumberPicker;
106//# sourceMappingURL=NumberPicker.d.ts.map
\No newline at end of file