@carbon/react 1.24.0-rc.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/ListBox/ListBoxMenuItem.d.ts +2 -2
- package/es/components/Menu/Menu.js +0 -4
- package/es/components/Menu/MenuContext.js +3 -6
- package/es/components/Popover/index.d.ts +51 -0
- package/es/components/Popover/index.js +28 -24
- package/es/components/Slider/Slider.Skeleton.d.ts +2 -2
- package/es/components/Slider/Slider.d.ts +355 -0
- package/es/components/Slider/Slider.js +63 -35
- package/es/components/TextInput/TextInput.d.ts +106 -0
- package/es/components/TextInput/TextInput.js +3 -2
- package/es/internal/useMergedRefs.d.ts +13 -0
- package/es/internal/useMergedRefs.js +2 -5
- package/es/internal/useNormalizedInputProps.js +1 -0
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +2 -2
- package/lib/components/Menu/Menu.js +0 -4
- package/lib/components/Menu/MenuContext.js +3 -6
- package/lib/components/Popover/index.d.ts +51 -0
- package/lib/components/Popover/index.js +28 -24
- package/lib/components/Slider/Slider.Skeleton.d.ts +2 -2
- package/lib/components/Slider/Slider.d.ts +355 -0
- package/lib/components/Slider/Slider.js +62 -34
- package/lib/components/TextInput/TextInput.d.ts +106 -0
- package/lib/components/TextInput/TextInput.js +3 -2
- package/lib/internal/useMergedRefs.d.ts +13 -0
- package/lib/internal/useMergedRefs.js +2 -5
- package/lib/internal/useNormalizedInputProps.js +1 -0
- package/package.json +10 -10
|
@@ -16,9 +16,9 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLDivElement> {
|
|
|
16
16
|
*/
|
|
17
17
|
isHighlighted?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export type ListBoxMenuItemForwardedRef = ForwardedRef<HTMLDivElement> & {
|
|
19
|
+
export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLDivElement> & {
|
|
20
20
|
menuItemOptionRef?: React.Ref<HTMLDivElement>;
|
|
21
|
-
} | null;
|
|
21
|
+
}) | null;
|
|
22
22
|
export type ListBoxMenuItemComponent = ForwardRefReturn<ListBoxMenuItemForwardedRef, ListBoxMenuItemProps>;
|
|
23
23
|
declare const _default: ListBoxMenuItemComponent;
|
|
24
24
|
export default _default;
|
|
@@ -25,12 +25,9 @@ function menuReducer(state, action) {
|
|
|
25
25
|
|
|
26
26
|
case 'registerItem':
|
|
27
27
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
28
|
-
items: [].concat(_toConsumableArray(state.items), [action.payload])
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case 'clearRegisteredItems':
|
|
32
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
33
|
-
items: []
|
|
28
|
+
items: [].concat(_toConsumableArray(state.items), [action.payload]).filter(function (item) {
|
|
29
|
+
return item.ref.current !== null;
|
|
30
|
+
})
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
33
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { PolymorphicProps } from '../../types/common';
|
|
9
|
+
export type PopoverAlignment = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-bottom' | 'left-top' | 'right' | 'right-bottom' | 'right-top';
|
|
10
|
+
interface PopoverBaseProps {
|
|
11
|
+
/**
|
|
12
|
+
* Specify how the popover should align with the trigger element
|
|
13
|
+
*/
|
|
14
|
+
align?: PopoverAlignment;
|
|
15
|
+
/**
|
|
16
|
+
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to futurue changes.
|
|
17
|
+
*/
|
|
18
|
+
autoAlign?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Specify whether a caret should be rendered
|
|
21
|
+
*/
|
|
22
|
+
caret?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Provide elements to be rendered inside of the component
|
|
25
|
+
*/
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
29
|
+
* component
|
|
30
|
+
*/
|
|
31
|
+
className?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Specify whether a drop shadow should be rendered on the popover
|
|
34
|
+
*/
|
|
35
|
+
dropShadow?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Render the component using the high-contrast variant
|
|
38
|
+
*/
|
|
39
|
+
highContrast?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Specify whether the component is currently open or closed
|
|
42
|
+
*/
|
|
43
|
+
open: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type PopoverProps<T extends React.ElementType> = PolymorphicProps<T, PopoverBaseProps>;
|
|
46
|
+
declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverBaseProps & Omit<any, "as"> & {
|
|
47
|
+
as?: React.ElementType<any> | undefined;
|
|
48
|
+
}, string | number | symbol> & React.RefAttributes<Element>>;
|
|
49
|
+
export type PopoverContentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
50
|
+
declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLSpanElement>>;
|
|
51
|
+
export { Popover, PopoverContent };
|
|
@@ -20,29 +20,28 @@ var PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
|
20
20
|
current: null
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
var Popover = /*#__PURE__*/React__default.forwardRef(function
|
|
23
|
+
var Popover = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardRef) {
|
|
24
24
|
var _cx;
|
|
25
25
|
|
|
26
|
-
var
|
|
27
|
-
align =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
26
|
+
var _ref$align = _ref.align,
|
|
27
|
+
align = _ref$align === void 0 ? 'bottom' : _ref$align,
|
|
28
|
+
as = _ref.as,
|
|
29
|
+
_ref$autoAlign = _ref.autoAlign,
|
|
30
|
+
autoAlign = _ref$autoAlign === void 0 ? false : _ref$autoAlign,
|
|
31
|
+
_ref$caret = _ref.caret,
|
|
32
|
+
caret = _ref$caret === void 0 ? true : _ref$caret,
|
|
33
|
+
customClassName = _ref.className,
|
|
34
|
+
children = _ref.children,
|
|
35
|
+
_ref$dropShadow = _ref.dropShadow,
|
|
36
|
+
dropShadow = _ref$dropShadow === void 0 ? true : _ref$dropShadow,
|
|
37
|
+
_ref$highContrast = _ref.highContrast,
|
|
38
|
+
highContrast = _ref$highContrast === void 0 ? false : _ref$highContrast,
|
|
39
|
+
open = _ref.open,
|
|
40
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
42
41
|
|
|
43
42
|
var prefix = usePrefix();
|
|
44
|
-
var floating = useRef();
|
|
45
|
-
var popover = useRef();
|
|
43
|
+
var floating = useRef(null);
|
|
44
|
+
var popover = useRef(null);
|
|
46
45
|
var value = useMemo(function () {
|
|
47
46
|
return {
|
|
48
47
|
floating: floating
|
|
@@ -60,7 +59,7 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, for
|
|
|
60
59
|
autoAlignment = _useState4[0],
|
|
61
60
|
setAutoAlignment = _useState4[1];
|
|
62
61
|
|
|
63
|
-
var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(autoAlignment), autoAligned), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), !autoAligned),
|
|
62
|
+
var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(autoAlignment), autoAligned), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), !autoAligned), _cx), customClassName);
|
|
64
63
|
useIsomorphicEffect(function () {
|
|
65
64
|
if (!open) {
|
|
66
65
|
return;
|
|
@@ -108,6 +107,10 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, for
|
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
function isVisible(alignment) {
|
|
110
|
+
if (!popover.current || !floating.current) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
111
114
|
popover.current.classList.add("".concat(prefix, "--popover--").concat(alignment));
|
|
112
115
|
var rect = floating.current.getBoundingClientRect(); // Check if popover is not visible to the left of the screen
|
|
113
116
|
|
|
@@ -154,6 +157,7 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, for
|
|
|
154
157
|
setAutoAlignment(alignment);
|
|
155
158
|
}
|
|
156
159
|
}, [autoAligned, align, autoAlign, prefix, open]);
|
|
160
|
+
var BaseComponent = as !== null && as !== void 0 ? as : 'span';
|
|
157
161
|
return /*#__PURE__*/React__default.createElement(PopoverContext.Provider, {
|
|
158
162
|
value: value
|
|
159
163
|
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
@@ -215,10 +219,10 @@ Popover.propTypes = {
|
|
|
215
219
|
*/
|
|
216
220
|
open: PropTypes.bool.isRequired
|
|
217
221
|
};
|
|
218
|
-
var PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverContent(
|
|
219
|
-
var className =
|
|
220
|
-
children =
|
|
221
|
-
rest = _objectWithoutProperties(
|
|
222
|
+
var PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverContent(_ref2, forwardRef) {
|
|
223
|
+
var className = _ref2.className,
|
|
224
|
+
children = _ref2.children,
|
|
225
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
222
226
|
|
|
223
227
|
var prefix = usePrefix();
|
|
224
228
|
|
|
@@ -8,8 +8,8 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { HTMLAttributes } from 'react';
|
|
9
9
|
export interface SliderSkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Specify an optional className to add to the form item wrapper.
|
|
12
|
+
*/
|
|
13
13
|
className?: string;
|
|
14
14
|
/**
|
|
15
15
|
* Specify whether the label should be hidden, or not
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { KeyboardEventHandler, PureComponent } from 'react';
|
|
8
|
+
import PropTypes, { ReactNodeLike } from 'prop-types';
|
|
9
|
+
type ExcludedAttributes = 'onChange' | 'onBlur';
|
|
10
|
+
export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
11
|
+
/**
|
|
12
|
+
* The `ariaLabel` for the `<input>`.
|
|
13
|
+
*/
|
|
14
|
+
ariaLabelInput?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The child nodes.
|
|
17
|
+
*/
|
|
18
|
+
children?: ReactNodeLike;
|
|
19
|
+
/**
|
|
20
|
+
* The CSS class name for the slider.
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* `true` to disable this slider.
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The callback to format the label associated with the minimum/maximum value.
|
|
29
|
+
*/
|
|
30
|
+
formatLabel?: (value: number, label: string | undefined) => string;
|
|
31
|
+
/**
|
|
32
|
+
* `true` to hide the number input box.
|
|
33
|
+
*/
|
|
34
|
+
hideTextInput?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The ID of the `<input>`.
|
|
37
|
+
*/
|
|
38
|
+
id?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The `type` attribute of the `<input>`.
|
|
41
|
+
*/
|
|
42
|
+
inputType?: string;
|
|
43
|
+
/**
|
|
44
|
+
* `true` to specify if the control is invalid.
|
|
45
|
+
*/
|
|
46
|
+
invalid?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The label for the slider.
|
|
49
|
+
*/
|
|
50
|
+
labelText?: ReactNodeLike;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated
|
|
53
|
+
* `true` to use the light version.
|
|
54
|
+
*/
|
|
55
|
+
light?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The maximum value.
|
|
58
|
+
*/
|
|
59
|
+
max: number;
|
|
60
|
+
/**
|
|
61
|
+
* The label associated with the maximum value.
|
|
62
|
+
*/
|
|
63
|
+
maxLabel?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The minimum value.
|
|
66
|
+
*/
|
|
67
|
+
min: number;
|
|
68
|
+
/**
|
|
69
|
+
* The label associated with the minimum value.
|
|
70
|
+
*/
|
|
71
|
+
minLabel?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The `name` attribute of the `<input>`.
|
|
74
|
+
*/
|
|
75
|
+
name?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Provide an optional function to be called when the input element
|
|
78
|
+
* loses focus
|
|
79
|
+
*/
|
|
80
|
+
onBlur?: (data: {
|
|
81
|
+
value: string;
|
|
82
|
+
}) => void;
|
|
83
|
+
/**
|
|
84
|
+
* The callback to get notified of change in value.
|
|
85
|
+
* `({ value}) => void`
|
|
86
|
+
// * @param {{ value }}
|
|
87
|
+
*/
|
|
88
|
+
onChange?: (data: {
|
|
89
|
+
value: SliderProps['value'];
|
|
90
|
+
}) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Provide an optional function to be called when a key is pressed in the number input
|
|
93
|
+
*/
|
|
94
|
+
onInputKeyUp?: KeyboardEventHandler<HTMLInputElement>;
|
|
95
|
+
/**
|
|
96
|
+
* The callback to get notified of value on handle release.
|
|
97
|
+
*/
|
|
98
|
+
onRelease?: (data: {
|
|
99
|
+
value: SliderProps['value'];
|
|
100
|
+
}) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the slider should be read-only
|
|
103
|
+
*/
|
|
104
|
+
readOnly?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* `true` to specify if the control is required.
|
|
107
|
+
*/
|
|
108
|
+
required?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* A value determining how much the value should increase/decrease by moving the thumb by mouse. If a value other than 1 is provided and the input is *not* hidden, the new step requirement should be added to a visible label. Values outside of the `step` increment will be considered invalid.
|
|
111
|
+
*/
|
|
112
|
+
step?: number;
|
|
113
|
+
/**
|
|
114
|
+
* A value determining how much the value should increase/decrease by Shift+arrow keys,
|
|
115
|
+
* which will be `(max - min) / stepMultiplier`.
|
|
116
|
+
*/
|
|
117
|
+
stepMultiplier?: number;
|
|
118
|
+
/**
|
|
119
|
+
* The value.
|
|
120
|
+
*/
|
|
121
|
+
value: number;
|
|
122
|
+
}
|
|
123
|
+
interface CalcValueProps {
|
|
124
|
+
clientX?: number;
|
|
125
|
+
value?: number;
|
|
126
|
+
useRawValue?: boolean;
|
|
127
|
+
}
|
|
128
|
+
export default class Slider extends PureComponent<SliderProps> {
|
|
129
|
+
static propTypes: {
|
|
130
|
+
/**
|
|
131
|
+
* The `ariaLabel` for the `<input>`.
|
|
132
|
+
*/
|
|
133
|
+
ariaLabelInput: PropTypes.Requireable<string>;
|
|
134
|
+
/**
|
|
135
|
+
* The child nodes.
|
|
136
|
+
*/
|
|
137
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
138
|
+
/**
|
|
139
|
+
* The CSS class name for the slider.
|
|
140
|
+
*/
|
|
141
|
+
className: PropTypes.Requireable<string>;
|
|
142
|
+
/**
|
|
143
|
+
* `true` to disable this slider.
|
|
144
|
+
*/
|
|
145
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
146
|
+
/**
|
|
147
|
+
* The callback to format the label associated with the minimum/maximum value.
|
|
148
|
+
*/
|
|
149
|
+
formatLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
150
|
+
/**
|
|
151
|
+
* `true` to hide the number input box.
|
|
152
|
+
*/
|
|
153
|
+
hideTextInput: PropTypes.Requireable<boolean>;
|
|
154
|
+
/**
|
|
155
|
+
* The ID of the `<input>`.
|
|
156
|
+
*/
|
|
157
|
+
id: PropTypes.Requireable<string>;
|
|
158
|
+
/**
|
|
159
|
+
* The `type` attribute of the `<input>`.
|
|
160
|
+
*/
|
|
161
|
+
inputType: PropTypes.Requireable<string>;
|
|
162
|
+
/**
|
|
163
|
+
* `true` to specify if the control is invalid.
|
|
164
|
+
*/
|
|
165
|
+
invalid: PropTypes.Requireable<boolean>;
|
|
166
|
+
/**
|
|
167
|
+
* The label for the slider.
|
|
168
|
+
*/
|
|
169
|
+
labelText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
170
|
+
/**
|
|
171
|
+
* `true` to use the light version.
|
|
172
|
+
*/
|
|
173
|
+
light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
174
|
+
/**
|
|
175
|
+
* The maximum value.
|
|
176
|
+
*/
|
|
177
|
+
max: PropTypes.Validator<number>;
|
|
178
|
+
/**
|
|
179
|
+
* The label associated with the maximum value.
|
|
180
|
+
*/
|
|
181
|
+
maxLabel: PropTypes.Requireable<string>;
|
|
182
|
+
/**
|
|
183
|
+
* The minimum value.
|
|
184
|
+
*/
|
|
185
|
+
min: PropTypes.Validator<number>;
|
|
186
|
+
/**
|
|
187
|
+
* The label associated with the minimum value.
|
|
188
|
+
*/
|
|
189
|
+
minLabel: PropTypes.Requireable<string>;
|
|
190
|
+
/**
|
|
191
|
+
* The `name` attribute of the `<input>`.
|
|
192
|
+
*/
|
|
193
|
+
name: PropTypes.Requireable<string>;
|
|
194
|
+
/**
|
|
195
|
+
* Provide an optional function to be called when the input element
|
|
196
|
+
* loses focus
|
|
197
|
+
*/
|
|
198
|
+
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
199
|
+
/**
|
|
200
|
+
* The callback to get notified of change in value.
|
|
201
|
+
*/
|
|
202
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
203
|
+
/**
|
|
204
|
+
* Provide an optional function to be called when a key is pressed in the number input
|
|
205
|
+
*/
|
|
206
|
+
onInputKeyUp: PropTypes.Requireable<(...args: any[]) => any>;
|
|
207
|
+
/**
|
|
208
|
+
* The callback to get notified of value on handle release.
|
|
209
|
+
*/
|
|
210
|
+
onRelease: PropTypes.Requireable<(...args: any[]) => any>;
|
|
211
|
+
/**
|
|
212
|
+
* Whether the slider should be read-only
|
|
213
|
+
*/
|
|
214
|
+
readOnly: PropTypes.Requireable<boolean>;
|
|
215
|
+
/**
|
|
216
|
+
* `true` to specify if the control is required.
|
|
217
|
+
*/
|
|
218
|
+
required: PropTypes.Requireable<boolean>;
|
|
219
|
+
/**
|
|
220
|
+
* A value determining how much the value should increase/decrease by moving the thumb by mouse. If a value other than 1 is provided and the input is *not* hidden, the new step requirement should be added to a visible label. Values outside of the `step` increment will be considered invalid.
|
|
221
|
+
*/
|
|
222
|
+
step: PropTypes.Requireable<number>;
|
|
223
|
+
/**
|
|
224
|
+
* A value determining how much the value should increase/decrease by Shift+arrow keys,
|
|
225
|
+
* which will be `(max - min) / stepMultiplier`.
|
|
226
|
+
*/
|
|
227
|
+
stepMultiplier: PropTypes.Requireable<number>;
|
|
228
|
+
/**
|
|
229
|
+
* The value.
|
|
230
|
+
*/
|
|
231
|
+
value: PropTypes.Validator<number>;
|
|
232
|
+
};
|
|
233
|
+
static defaultProps: {
|
|
234
|
+
hideTextInput: boolean;
|
|
235
|
+
step: number;
|
|
236
|
+
stepMultiplier: number;
|
|
237
|
+
disabled: boolean;
|
|
238
|
+
minLabel: string;
|
|
239
|
+
maxLabel: string;
|
|
240
|
+
inputType: string;
|
|
241
|
+
ariaLabelInput: string | undefined;
|
|
242
|
+
readOnly: boolean;
|
|
243
|
+
};
|
|
244
|
+
static contextType: React.Context<any>;
|
|
245
|
+
state: {
|
|
246
|
+
value: number;
|
|
247
|
+
left: number;
|
|
248
|
+
needsOnRelease: boolean;
|
|
249
|
+
isValid: boolean;
|
|
250
|
+
};
|
|
251
|
+
thumbRef: React.RefObject<HTMLDivElement>;
|
|
252
|
+
filledTrackRef: React.RefObject<HTMLDivElement>;
|
|
253
|
+
element: HTMLDivElement | null;
|
|
254
|
+
inputId: string;
|
|
255
|
+
track: HTMLDivElement | null | undefined;
|
|
256
|
+
constructor(props: any);
|
|
257
|
+
/**
|
|
258
|
+
* Sets up initial slider position and value in response to component mount.
|
|
259
|
+
*/
|
|
260
|
+
componentDidMount(): void;
|
|
261
|
+
/**
|
|
262
|
+
* Handles firing of `onChange` and `onRelease` callbacks to parent in
|
|
263
|
+
* response to state changes.
|
|
264
|
+
*
|
|
265
|
+
* @param {*} prevProps prevProps
|
|
266
|
+
* @param {*} prevState The previous Slider state, used to see if callbacks
|
|
267
|
+
* should be called.
|
|
268
|
+
*/
|
|
269
|
+
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
270
|
+
/**
|
|
271
|
+
* Synonymous to ECMA2017+ `Math.clamp`.
|
|
272
|
+
*
|
|
273
|
+
* @param {number} val
|
|
274
|
+
* @param {number} min
|
|
275
|
+
* @param {number} max
|
|
276
|
+
*
|
|
277
|
+
* @returns `val` if `max>=val>=min`; `min` if `val<min`; `max` if `val>max`.
|
|
278
|
+
*/
|
|
279
|
+
clamp(val: any, min: any, max: any): number;
|
|
280
|
+
/**
|
|
281
|
+
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
282
|
+
* started on somewhere other than the thumb without a corresponding "move"
|
|
283
|
+
* event.
|
|
284
|
+
*
|
|
285
|
+
* @param {Event} evt The event.
|
|
286
|
+
*/
|
|
287
|
+
onDragStart: (evt: any) => void;
|
|
288
|
+
/**
|
|
289
|
+
* Unregisters "drag" and "drag stop" event handlers and calls sets the flag
|
|
290
|
+
* indicating that the `onRelease` callback should be called.
|
|
291
|
+
*/
|
|
292
|
+
onDragStop: () => void;
|
|
293
|
+
/**
|
|
294
|
+
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
295
|
+
* accordingly.
|
|
296
|
+
*
|
|
297
|
+
* @param {Event} evt The event.
|
|
298
|
+
*/
|
|
299
|
+
_onDrag: (evt: any) => void;
|
|
300
|
+
/**
|
|
301
|
+
* Throttles calls to `this._onDrag` by limiting events to being processed at
|
|
302
|
+
* most once every `EVENT_THROTTLE` milliseconds.
|
|
303
|
+
*/
|
|
304
|
+
onDrag: any;
|
|
305
|
+
/**
|
|
306
|
+
* Handles a `keydown` event by recalculating the value/thumb and setting
|
|
307
|
+
* state accordingly.
|
|
308
|
+
*
|
|
309
|
+
* @param {Event} evt The event.
|
|
310
|
+
*/
|
|
311
|
+
onKeyDown: (evt: any) => void;
|
|
312
|
+
/**
|
|
313
|
+
* Provides the two-way binding for the input field of the Slider. It also
|
|
314
|
+
* Handles a change to the input field by recalculating the value/thumb and
|
|
315
|
+
* setting state accordingly.
|
|
316
|
+
*
|
|
317
|
+
* @param {Event} evt The event.
|
|
318
|
+
*/
|
|
319
|
+
onChange: (evt: any) => void;
|
|
320
|
+
/**
|
|
321
|
+
* Checks for validity of input value after clicking out of the input. It also
|
|
322
|
+
* Handles state change to isValid state.
|
|
323
|
+
*
|
|
324
|
+
* @param {Event} evt The event.
|
|
325
|
+
*/
|
|
326
|
+
onBlur: (evt: React.FocusEvent<HTMLInputElement>) => void;
|
|
327
|
+
/**
|
|
328
|
+
* Calculates a new Slider `value` and `left` (thumb offset) given a `clientX`,
|
|
329
|
+
* `value`, or neither of those.
|
|
330
|
+
* - If `clientX` is specified, it will be used in
|
|
331
|
+
* conjunction with the Slider's bounding rectangle to calculate the new
|
|
332
|
+
* values.
|
|
333
|
+
* - If `clientX` is not specified and `value` is, it will be used to
|
|
334
|
+
* calculate new values as though it were the current value of the Slider.
|
|
335
|
+
* - If neither `clientX` nor `value` are specified, `this.props.value` will
|
|
336
|
+
* be used to calculate the new values as though it were the current value
|
|
337
|
+
* of the Slider.
|
|
338
|
+
*
|
|
339
|
+
* @param {object} params
|
|
340
|
+
* @param {number} [params.clientX] Optional clientX value expected to be from
|
|
341
|
+
* an event fired by one of the Slider's `DRAG_EVENT_TYPES` events.
|
|
342
|
+
* @param {number} [params.value] Optional value use during calculations if
|
|
343
|
+
* clientX is not provided.
|
|
344
|
+
* @param {boolean} [params.useRawValue=false] `true` to use the given value as-is.
|
|
345
|
+
*/
|
|
346
|
+
calcValue: ({ clientX, value, useRawValue }: CalcValueProps) => {
|
|
347
|
+
value: number | undefined;
|
|
348
|
+
left: number;
|
|
349
|
+
};
|
|
350
|
+
static getDerivedStateFromProps(props: any, state: any): {
|
|
351
|
+
isValid: boolean;
|
|
352
|
+
} | null;
|
|
353
|
+
render(): JSX.Element;
|
|
354
|
+
}
|
|
355
|
+
export {};
|