@carbon/react 1.84.0 → 1.85.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +899 -829
- package/es/components/AILabel/index.js +6 -1
- package/es/components/Checkbox/Checkbox.d.ts +2 -2
- package/es/components/Checkbox/Checkbox.js +8 -8
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
- package/es/components/CheckboxGroup/CheckboxGroup.js +9 -8
- package/es/components/CodeSnippet/CodeSnippet.js +2 -4
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +8 -7
- package/es/components/ComposedModal/ComposedModal.d.ts +1 -1
- package/es/components/ComposedModal/ComposedModal.js +15 -10
- package/es/components/ContainedList/ContainedList.d.ts +1 -1
- package/es/components/ContainedList/ContainedList.js +4 -2
- package/es/components/ContentSwitcher/ContentSwitcher.js +6 -5
- package/es/components/DataTable/DataTable.js +3 -0
- package/es/components/DataTable/TableDecoratorRow.d.ts +2 -2
- package/es/components/DataTable/TableDecoratorRow.js +8 -8
- package/es/components/DataTable/TableExpandRow.d.ts +1 -1
- package/es/components/DataTable/TableExpandRow.js +15 -6
- package/es/components/DataTable/TableHeader.js +10 -10
- package/es/components/DataTable/TableRow.js +12 -4
- package/es/components/DataTable/tools/normalize.js +2 -1
- package/es/components/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +2 -2
- package/es/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
- package/es/components/DatePicker/plugins/appendToPlugin.js +9 -12
- package/es/components/DatePickerInput/DatePickerInput.js +8 -7
- package/es/components/Dialog/index.d.ts +5 -1
- package/es/components/Dialog/index.js +20 -0
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +8 -10
- package/es/components/FileUploader/FileUploaderButton.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.js +2 -2
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/Layer/index.d.ts +1 -3
- package/es/components/Layer/index.js +9 -8
- package/es/components/Menu/Menu.js +7 -8
- package/es/components/Menu/MenuItem.js +13 -2
- package/es/components/Modal/Modal.d.ts +2 -2
- package/es/components/Modal/Modal.js +20 -9
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +9 -8
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +8 -7
- package/es/components/MultiSelect/filter.d.ts +10 -0
- package/es/components/MultiSelect/filter.js +21 -0
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +9 -8
- package/es/components/PageHeader/PageHeader.js +2 -2
- package/es/components/Popover/index.js +2 -1
- package/es/components/RadioButton/RadioButton.d.ts +2 -2
- package/es/components/RadioButton/RadioButton.js +8 -8
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +9 -8
- package/es/components/RadioTile/RadioTile.d.ts +1 -1
- package/es/components/RadioTile/RadioTile.js +8 -7
- package/es/components/Select/Select.d.ts +2 -2
- package/es/components/Select/Select.js +8 -7
- package/es/components/Slider/Slider.d.ts +59 -198
- package/es/components/Slider/Slider.js +68 -120
- package/es/components/Tabs/usePressable.d.ts +19 -0
- package/es/components/Tabs/usePressable.js +19 -33
- package/es/components/Tag/DismissibleTag.d.ts +1 -1
- package/es/components/Tag/DismissibleTag.js +9 -8
- package/es/components/Tag/Tag.d.ts +1 -1
- package/es/components/Tag/Tag.js +9 -8
- package/es/components/TextArea/TextArea.js +8 -7
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +20 -9
- package/es/components/Tile/Tile.d.ts +2 -2
- package/es/components/Tile/Tile.js +30 -36
- package/es/components/Toggletip/index.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.js +1 -0
- package/es/components/Tooltip/Tooltip.d.ts +2 -2
- package/es/components/Tooltip/Tooltip.js +2 -2
- package/es/components/TreeView/TreeNode.d.ts +22 -0
- package/es/components/TreeView/TreeNode.js +119 -12
- package/es/components/TreeView/TreeView.js +3 -3
- package/es/components/UIShell/Content.d.ts +5 -3
- package/es/components/UIShell/HeaderPanel.d.ts +2 -2
- package/es/components/UIShell/HeaderPanel.js +9 -5
- package/es/internal/Selection.js +8 -3
- package/es/internal/environment.js +1 -12
- package/{lib/internal/__mocks__/mockHTMLElement.d.ts → es/internal/index.d.ts} +2 -4
- package/es/internal/useResizeObserver.d.ts +1 -1
- package/es/internal/utils.d.ts +14 -0
- package/es/internal/utils.js +18 -0
- package/es/tools/uniqueId.d.ts +1 -6
- package/lib/components/AILabel/index.js +6 -1
- package/lib/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/components/Checkbox/Checkbox.js +7 -7
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
- package/lib/components/CheckboxGroup/CheckboxGroup.js +8 -7
- package/lib/components/CodeSnippet/CodeSnippet.js +2 -4
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +11 -10
- package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +16 -11
- package/lib/components/ContainedList/ContainedList.d.ts +1 -1
- package/lib/components/ContainedList/ContainedList.js +4 -2
- package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -4
- package/lib/components/DataTable/DataTable.js +3 -0
- package/lib/components/DataTable/TableDecoratorRow.d.ts +2 -2
- package/lib/components/DataTable/TableDecoratorRow.js +8 -8
- package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
- package/lib/components/DataTable/TableExpandRow.js +14 -5
- package/lib/components/DataTable/TableHeader.js +9 -9
- package/lib/components/DataTable/TableRow.js +11 -3
- package/lib/components/DataTable/tools/normalize.js +2 -1
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
- package/lib/components/DatePicker/plugins/appendToPlugin.js +9 -12
- package/lib/components/DatePickerInput/DatePickerInput.js +7 -6
- package/lib/components/Dialog/index.d.ts +5 -1
- package/lib/components/Dialog/index.js +20 -0
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +12 -14
- package/lib/components/FileUploader/FileUploaderButton.js +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/Layer/index.d.ts +1 -3
- package/lib/components/Layer/index.js +9 -8
- package/lib/components/Menu/Menu.js +7 -8
- package/lib/components/Menu/MenuItem.js +13 -2
- package/lib/components/Modal/Modal.d.ts +2 -2
- package/lib/components/Modal/Modal.js +28 -17
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +13 -12
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +13 -12
- package/lib/components/MultiSelect/filter.d.ts +10 -0
- package/lib/components/MultiSelect/filter.js +25 -0
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +8 -7
- package/lib/components/PageHeader/PageHeader.js +2 -2
- package/lib/components/Popover/index.js +2 -1
- package/lib/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/components/RadioButton/RadioButton.js +7 -7
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +10 -9
- package/lib/components/RadioTile/RadioTile.d.ts +1 -1
- package/lib/components/RadioTile/RadioTile.js +7 -6
- package/lib/components/Select/Select.d.ts +2 -2
- package/lib/components/Select/Select.js +7 -6
- package/lib/components/Slider/Slider.d.ts +59 -198
- package/lib/components/Slider/Slider.js +67 -119
- package/lib/components/Tabs/usePressable.d.ts +19 -0
- package/lib/components/Tabs/usePressable.js +19 -33
- package/lib/components/Tag/DismissibleTag.d.ts +1 -1
- package/lib/components/Tag/DismissibleTag.js +8 -7
- package/lib/components/Tag/Tag.d.ts +1 -1
- package/lib/components/Tag/Tag.js +8 -7
- package/lib/components/TextArea/TextArea.js +7 -6
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +19 -8
- package/lib/components/Tile/Tile.d.ts +2 -2
- package/lib/components/Tile/Tile.js +29 -35
- package/lib/components/Toggletip/index.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
- package/lib/components/Tooltip/Tooltip.d.ts +2 -2
- package/lib/components/Tooltip/Tooltip.js +2 -2
- package/lib/components/TreeView/TreeNode.d.ts +22 -0
- package/lib/components/TreeView/TreeNode.js +118 -11
- package/lib/components/TreeView/TreeView.js +3 -3
- package/lib/components/UIShell/Content.d.ts +5 -3
- package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
- package/lib/components/UIShell/HeaderPanel.js +8 -4
- package/lib/internal/Selection.js +8 -3
- package/lib/internal/environment.js +1 -12
- package/{es/internal/__mocks__/mockHTMLElement.d.ts → lib/internal/index.d.ts} +2 -4
- package/lib/internal/useResizeObserver.d.ts +1 -1
- package/lib/internal/utils.d.ts +14 -0
- package/lib/internal/utils.js +22 -0
- package/lib/tools/uniqueId.d.ts +1 -6
- package/package.json +11 -20
- package/telemetry.yml +1 -0
- package/es/components/ComboBox/tools/filter.js +0 -18
- package/es/tools/uniqueId.js +0 -14
- package/lib/components/ComboBox/tools/filter.js +0 -22
- package/lib/tools/uniqueId.js +0 -18
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { useRef } from 'react';
|
|
10
|
+
import React, { useRef, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import '../Text/index.js';
|
|
13
13
|
import deprecate from '../../prop-types/deprecate.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { useId } from '../../internal/useId.js';
|
|
16
16
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
17
|
+
import { AILabel } from '../AILabel/index.js';
|
|
18
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
17
19
|
import { Text } from '../Text/Text.js';
|
|
18
20
|
|
|
19
21
|
const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
@@ -47,13 +49,11 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
47
49
|
[`${prefix}--radio-button-wrapper--decorator`]: decorator
|
|
48
50
|
});
|
|
49
51
|
const inputRef = useRef(null);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
}
|
|
52
|
+
const candidate = slug ?? decorator;
|
|
53
|
+
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
54
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
55
|
+
size: candidate.props?.['kind'] === 'inline' ? 'md' : 'mini'
|
|
56
|
+
}) : null;
|
|
57
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
58
58
|
className: wrapperClasses
|
|
59
59
|
}, /*#__PURE__*/React.createElement("input", _extends({}, rest, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
8
|
import type { RadioButtonProps } from '../RadioButton';
|
|
9
9
|
export declare const RadioButtonGroupContext: React.Context<null>;
|
|
10
10
|
type ExcludedAttributes = 'onChange';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { useState, useRef } from 'react';
|
|
10
|
+
import React, { useState, useRef, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Legend } from '../Text/index.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -15,6 +15,8 @@ import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
|
15
15
|
import deprecate from '../../prop-types/deprecate.js';
|
|
16
16
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
17
17
|
import { useId } from '../../internal/useId.js';
|
|
18
|
+
import { AILabel } from '../AILabel/index.js';
|
|
19
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
18
20
|
|
|
19
21
|
const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
20
22
|
const {
|
|
@@ -103,13 +105,12 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
103
105
|
const divRef = useRef(null);
|
|
104
106
|
|
|
105
107
|
// AILabel is always size `mini`
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
108
|
+
const candidate = slug ?? decorator;
|
|
109
|
+
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
110
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
111
|
+
size: 'mini',
|
|
112
|
+
kind: 'default'
|
|
113
|
+
}) : null;
|
|
113
114
|
return /*#__PURE__*/React.createElement("div", {
|
|
114
115
|
className: wrapperClasses,
|
|
115
116
|
ref: mergeRefs(divRef, ref)
|
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import { RadioButtonChecked, RadioButton, CheckmarkFilled } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React from 'react';
|
|
12
|
+
import React, { cloneElement } from 'react';
|
|
13
13
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { matches } from '../../internal/keyboard/match.js';
|
|
15
15
|
import { useFallbackId } from '../../internal/useId.js';
|
|
@@ -18,6 +18,8 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
18
18
|
import { noopFn } from '../../internal/noopFn.js';
|
|
19
19
|
import '../Text/index.js';
|
|
20
20
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
21
|
+
import { AILabel } from '../AILabel/index.js';
|
|
22
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
21
23
|
import { Text } from '../Text/Text.js';
|
|
22
24
|
|
|
23
25
|
var _RadioButtonChecked, _RadioButton, _CheckmarkFilled;
|
|
@@ -72,12 +74,11 @@ const RadioTile = /*#__PURE__*/React.forwardRef(function RadioTile({
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
// AILabel is always size `xs`
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
77
|
+
const candidate = slug ?? decorator;
|
|
78
|
+
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
79
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
80
|
+
size: 'xs'
|
|
81
|
+
}) : null;
|
|
81
82
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
|
|
82
83
|
checked: checked,
|
|
83
84
|
className: `${prefix}--tile-input`,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ChangeEventHandler, ComponentPropsWithRef, ReactNode } from 'react';
|
|
7
|
+
import React, { type ChangeEventHandler, type ComponentPropsWithRef, type ReactNode } from 'react';
|
|
8
8
|
type ExcludedAttributes = 'size';
|
|
9
9
|
export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttributes> {
|
|
10
10
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { useContext, useState } from 'react';
|
|
10
|
+
import React, { useContext, useState, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { ChevronDown, WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
13
13
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -17,6 +17,8 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
17
17
|
import { useId } from '../../internal/useId.js';
|
|
18
18
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
19
19
|
import '../Text/index.js';
|
|
20
|
+
import { AILabel } from '../AILabel/index.js';
|
|
21
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
20
22
|
import { Text } from '../Text/Text.js';
|
|
21
23
|
|
|
22
24
|
const Select = /*#__PURE__*/React.forwardRef(function Select({
|
|
@@ -134,12 +136,11 @@ const Select = /*#__PURE__*/React.forwardRef(function Select({
|
|
|
134
136
|
};
|
|
135
137
|
|
|
136
138
|
// AILabel always size `mini`
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
139
|
+
const candidate = slug ?? decorator;
|
|
140
|
+
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
141
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
142
|
+
size: 'mini'
|
|
143
|
+
}) : null;
|
|
143
144
|
const input = (() => {
|
|
144
145
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", _extends({}, other, ariaProps, {
|
|
145
146
|
id: id,
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type KeyboardEventHandler,
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
7
|
+
import React, { PureComponent, ReactNode, type ChangeEvent, type FocusEvent, type InputHTMLAttributes, type KeyboardEvent, type KeyboardEventHandler, type MouseEvent, type RefObject, type TouchEvent } from 'react';
|
|
9
8
|
import { TranslateWithId } from '../../types/common';
|
|
10
9
|
declare const translationIds: {
|
|
11
10
|
readonly autoCorrectAnnouncement: "carbon.slider.auto-correct-announcement";
|
|
@@ -14,15 +13,12 @@ declare const translationIds: {
|
|
|
14
13
|
* Message ids that will be passed to translateWithId().
|
|
15
14
|
*/
|
|
16
15
|
type TranslationKey = (typeof translationIds)[keyof typeof translationIds];
|
|
17
|
-
/**
|
|
18
|
-
* Distinguish two handles by lower and upper positions.
|
|
19
|
-
*/
|
|
20
16
|
declare enum HandlePosition {
|
|
21
17
|
LOWER = "lower",
|
|
22
18
|
UPPER = "upper"
|
|
23
19
|
}
|
|
24
20
|
type ExcludedAttributes = 'onChange' | 'onBlur';
|
|
25
|
-
export interface SliderProps extends Omit<
|
|
21
|
+
export interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey, {
|
|
26
22
|
correctedValue?: string;
|
|
27
23
|
}> {
|
|
28
24
|
/**
|
|
@@ -116,14 +112,13 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
116
112
|
}) => void;
|
|
117
113
|
/**
|
|
118
114
|
* The callback to get notified of change in value.
|
|
119
|
-
* `({ value: number, valueUpper?: number }) => void`
|
|
120
115
|
*/
|
|
121
116
|
onChange?: (data: {
|
|
122
117
|
value: SliderProps['value'];
|
|
123
118
|
valueUpper: SliderProps['unstable_valueUpper'];
|
|
124
119
|
}) => void;
|
|
125
120
|
/**
|
|
126
|
-
* Provide an optional function to be called when a key is pressed in the number input.
|
|
121
|
+
* Provide an optional function to be called when a key is pressed in the number input.
|
|
127
122
|
*/
|
|
128
123
|
onInputKeyUp?: KeyboardEventHandler<HTMLInputElement>;
|
|
129
124
|
/**
|
|
@@ -166,7 +161,7 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
166
161
|
/**
|
|
167
162
|
* Provide the text that is displayed when the control is in warning state
|
|
168
163
|
*/
|
|
169
|
-
warnText?:
|
|
164
|
+
warnText?: ReactNode;
|
|
170
165
|
}
|
|
171
166
|
interface CalcLeftPercentProps {
|
|
172
167
|
clientX?: number;
|
|
@@ -174,146 +169,8 @@ interface CalcLeftPercentProps {
|
|
|
174
169
|
range?: number;
|
|
175
170
|
}
|
|
176
171
|
declare class Slider extends PureComponent<SliderProps> {
|
|
177
|
-
static propTypes: {
|
|
178
|
-
/**
|
|
179
|
-
* The `ariaLabel` for the `<input>`.
|
|
180
|
-
*/
|
|
181
|
-
ariaLabelInput: PropTypes.Requireable<string>;
|
|
182
|
-
/**
|
|
183
|
-
* The child nodes.
|
|
184
|
-
*/
|
|
185
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
186
|
-
/**
|
|
187
|
-
* The CSS class name for the slider.
|
|
188
|
-
*/
|
|
189
|
-
className: PropTypes.Requireable<string>;
|
|
190
|
-
/**
|
|
191
|
-
* `true` to disable this slider.
|
|
192
|
-
*/
|
|
193
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
194
|
-
/**
|
|
195
|
-
* The callback to format the label associated with the minimum/maximum value.
|
|
196
|
-
*/
|
|
197
|
-
formatLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
198
|
-
/**
|
|
199
|
-
* `true` to hide the number input box.
|
|
200
|
-
*/
|
|
201
|
-
hideTextInput: PropTypes.Requireable<boolean>;
|
|
202
|
-
/**
|
|
203
|
-
* The ID of the `<input>`.
|
|
204
|
-
*/
|
|
205
|
-
id: PropTypes.Requireable<string>;
|
|
206
|
-
/**
|
|
207
|
-
* The `type` attribute of the `<input>`.
|
|
208
|
-
*/
|
|
209
|
-
inputType: PropTypes.Requireable<string>;
|
|
210
|
-
/**
|
|
211
|
-
* `Specify whether the Slider is currently invalid
|
|
212
|
-
*/
|
|
213
|
-
invalid: PropTypes.Requireable<boolean>;
|
|
214
|
-
/**
|
|
215
|
-
* Provide the text that is displayed when the Slider is in an invalid state
|
|
216
|
-
*/
|
|
217
|
-
invalidText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
218
|
-
/**
|
|
219
|
-
* The label for the slider.
|
|
220
|
-
*/
|
|
221
|
-
labelText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
222
|
-
/**
|
|
223
|
-
* Specify whether you want the underlying label to be visually hidden
|
|
224
|
-
*/
|
|
225
|
-
hideLabel: PropTypes.Requireable<boolean>;
|
|
226
|
-
/**
|
|
227
|
-
* `true` to use the light version.
|
|
228
|
-
*/
|
|
229
|
-
light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
230
|
-
/**
|
|
231
|
-
* The maximum value.
|
|
232
|
-
*/
|
|
233
|
-
max: PropTypes.Validator<number>;
|
|
234
|
-
/**
|
|
235
|
-
* The label associated with the maximum value.
|
|
236
|
-
*/
|
|
237
|
-
maxLabel: PropTypes.Requireable<string>;
|
|
238
|
-
/**
|
|
239
|
-
* The minimum value.
|
|
240
|
-
*/
|
|
241
|
-
min: PropTypes.Validator<number>;
|
|
242
|
-
/**
|
|
243
|
-
* The label associated with the minimum value.
|
|
244
|
-
*/
|
|
245
|
-
minLabel: PropTypes.Requireable<string>;
|
|
246
|
-
/**
|
|
247
|
-
* The `name` attribute of the `<input>`.
|
|
248
|
-
*/
|
|
249
|
-
name: PropTypes.Requireable<string>;
|
|
250
|
-
/**
|
|
251
|
-
* Provide an optional function to be called when the input element
|
|
252
|
-
* loses focus
|
|
253
|
-
*/
|
|
254
|
-
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
255
|
-
/**
|
|
256
|
-
* The callback to get notified of change in value.
|
|
257
|
-
*/
|
|
258
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
259
|
-
/**
|
|
260
|
-
* Provide an optional function to be called when a key is pressed in the number input
|
|
261
|
-
*/
|
|
262
|
-
onInputKeyUp: PropTypes.Requireable<(...args: any[]) => any>;
|
|
263
|
-
/**
|
|
264
|
-
* The callback to get notified of value on handle release.
|
|
265
|
-
*/
|
|
266
|
-
onRelease: PropTypes.Requireable<(...args: any[]) => any>;
|
|
267
|
-
/**
|
|
268
|
-
* Whether the slider should be read-only
|
|
269
|
-
*/
|
|
270
|
-
readOnly: PropTypes.Requireable<boolean>;
|
|
271
|
-
/**
|
|
272
|
-
* `true` to specify if the control is required.
|
|
273
|
-
*/
|
|
274
|
-
required: PropTypes.Requireable<boolean>;
|
|
275
|
-
/**
|
|
276
|
-
* 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 the `step` increment will be considered invalid.
|
|
277
|
-
*/
|
|
278
|
-
step: PropTypes.Requireable<number>;
|
|
279
|
-
/**
|
|
280
|
-
* A value determining how much the value should increase/decrease by Shift+arrow keys,
|
|
281
|
-
* which will be `(max - min) / stepMultiplier`.
|
|
282
|
-
*/
|
|
283
|
-
stepMultiplier: PropTypes.Requireable<number>;
|
|
284
|
-
/**
|
|
285
|
-
* Supply a method to translate internal strings with your i18n tool of
|
|
286
|
-
* choice. Translation keys are available on the `translationIds` field for
|
|
287
|
-
* this component.
|
|
288
|
-
*/
|
|
289
|
-
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
290
|
-
/**
|
|
291
|
-
* The `ariaLabel` for the upper bound `<input>` when there are two handles.
|
|
292
|
-
*/
|
|
293
|
-
unstable_ariaLabelInputUpper: PropTypes.Requireable<string>;
|
|
294
|
-
/**
|
|
295
|
-
* The `name` attribute of the upper bound `<input>` when there are two handles.
|
|
296
|
-
*/
|
|
297
|
-
unstable_nameUpper: PropTypes.Requireable<string>;
|
|
298
|
-
/**
|
|
299
|
-
* The upper bound when there are two handles.
|
|
300
|
-
*/
|
|
301
|
-
unstable_valueUpper: PropTypes.Requireable<number>;
|
|
302
|
-
/**
|
|
303
|
-
* The value of the slider. When there are two handles, value is the lower
|
|
304
|
-
* bound.
|
|
305
|
-
*/
|
|
306
|
-
value: PropTypes.Validator<number>;
|
|
307
|
-
/**
|
|
308
|
-
* `Specify whether the Slider is in a warn state
|
|
309
|
-
*/
|
|
310
|
-
warn: PropTypes.Requireable<boolean>;
|
|
311
|
-
/**
|
|
312
|
-
* Provide the text that is displayed when the Slider is in a warn state
|
|
313
|
-
*/
|
|
314
|
-
warnText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
315
|
-
};
|
|
316
172
|
static contextType: React.Context<any>;
|
|
173
|
+
static translationIds: "carbon.slider.auto-correct-announcement"[];
|
|
317
174
|
state: {
|
|
318
175
|
value: number;
|
|
319
176
|
valueUpper: number | undefined;
|
|
@@ -322,14 +179,14 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
322
179
|
needsOnRelease: boolean;
|
|
323
180
|
isValid: boolean;
|
|
324
181
|
isValidUpper: boolean;
|
|
325
|
-
activeHandle:
|
|
182
|
+
activeHandle: undefined;
|
|
326
183
|
correctedValue: null;
|
|
327
184
|
correctedPosition: null;
|
|
328
185
|
isRtl: boolean;
|
|
329
186
|
};
|
|
330
|
-
thumbRef:
|
|
331
|
-
thumbRefUpper:
|
|
332
|
-
filledTrackRef:
|
|
187
|
+
thumbRef: RefObject<HTMLDivElement | null>;
|
|
188
|
+
thumbRefUpper: RefObject<HTMLDivElement | null>;
|
|
189
|
+
filledTrackRef: RefObject<HTMLDivElement | null>;
|
|
333
190
|
element: HTMLDivElement | null;
|
|
334
191
|
inputId: string;
|
|
335
192
|
track: HTMLDivElement | null | undefined;
|
|
@@ -355,16 +212,15 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
355
212
|
* @returns The value rounded to the precision determined by the step.
|
|
356
213
|
*/
|
|
357
214
|
nearestStepValue(value?: number): number;
|
|
215
|
+
handleDrag: (event: Event) => void;
|
|
358
216
|
/**
|
|
359
217
|
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
360
218
|
* started on somewhere other than the thumb without a corresponding "move"
|
|
361
219
|
* event.
|
|
362
|
-
*
|
|
363
|
-
* @param {Event} evt The event.
|
|
364
220
|
*/
|
|
365
|
-
onDragStart: (evt:
|
|
221
|
+
onDragStart: (evt: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
|
|
366
222
|
/**
|
|
367
|
-
*
|
|
223
|
+
* Removes "drag" and "drag stop" event handlers and calls sets the flag
|
|
368
224
|
* indicating that the `onRelease` callback should be called.
|
|
369
225
|
*/
|
|
370
226
|
onDragStop: () => void;
|
|
@@ -372,40 +228,33 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
372
228
|
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
373
229
|
* accordingly.
|
|
374
230
|
*
|
|
375
|
-
* @param
|
|
376
|
-
* @param activeHandle
|
|
377
|
-
*
|
|
378
|
-
* which is to be used before state is used.
|
|
231
|
+
* @param evt The event.
|
|
232
|
+
* @param activeHandle The first drag event call, we may have an explicit
|
|
233
|
+
* activeHandle value, which is to be used before state is used.
|
|
379
234
|
*/
|
|
380
|
-
_onDrag: (evt:
|
|
235
|
+
_onDrag: (evt: globalThis.MouseEvent | globalThis.TouchEvent, activeHandle?: HandlePosition) => void;
|
|
381
236
|
/**
|
|
382
237
|
* Throttles calls to `this._onDrag` by limiting events to being processed at
|
|
383
238
|
* most once every `EVENT_THROTTLE` milliseconds.
|
|
384
239
|
*/
|
|
385
|
-
onDrag: import("es-toolkit/compat").DebouncedFunc<(evt:
|
|
240
|
+
onDrag: import("es-toolkit/compat").DebouncedFunc<(evt: globalThis.MouseEvent | globalThis.TouchEvent, activeHandle?: HandlePosition) => void>;
|
|
386
241
|
/**
|
|
387
242
|
* Handles a `keydown` event by recalculating the value/thumb and setting
|
|
388
243
|
* state accordingly.
|
|
389
|
-
*
|
|
390
|
-
* @param {Event} evt The event.
|
|
391
244
|
*/
|
|
392
|
-
onKeyDown: (evt:
|
|
245
|
+
onKeyDown: (evt: KeyboardEvent<HTMLDivElement>) => void;
|
|
393
246
|
/**
|
|
394
247
|
* Provides the two-way binding for the input field of the Slider. It also
|
|
395
248
|
* Handles a change to the input field by recalculating the value/thumb and
|
|
396
249
|
* setting state accordingly.
|
|
397
|
-
*
|
|
398
|
-
* @param {Event} evt The event.
|
|
399
250
|
*/
|
|
400
|
-
onChange: (evt:
|
|
251
|
+
onChange: (evt: ChangeEvent<HTMLInputElement>) => void;
|
|
401
252
|
/**
|
|
402
253
|
* Checks for validity of input value after clicking out of the input. It also
|
|
403
254
|
* Handles state change to isValid state.
|
|
404
|
-
*
|
|
405
|
-
* @param {Event} evt The event.
|
|
406
255
|
*/
|
|
407
|
-
onBlur: (evt:
|
|
408
|
-
onInputKeyDown: (evt:
|
|
256
|
+
onBlur: (evt: FocusEvent<HTMLInputElement>) => void;
|
|
257
|
+
onInputKeyDown: (evt: KeyboardEvent<HTMLInputElement>) => void;
|
|
409
258
|
processNewInputValue: (input: HTMLInputElement) => void;
|
|
410
259
|
calcLeftPercent: ({ clientX, value, range }: CalcLeftPercentProps) => number;
|
|
411
260
|
/**
|
|
@@ -434,7 +283,7 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
434
283
|
value: number | undefined;
|
|
435
284
|
left: number;
|
|
436
285
|
};
|
|
437
|
-
calcDistanceToHandle: (handle: HandlePosition, clientX:
|
|
286
|
+
calcDistanceToHandle: (handle: HandlePosition, clientX: number) => number;
|
|
438
287
|
/**
|
|
439
288
|
* Calculates a new slider value based on the current value, a change delta,
|
|
440
289
|
* and a step.
|
|
@@ -452,41 +301,53 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
452
301
|
* Guards against setting either lower or upper values beyond its counterpart.
|
|
453
302
|
*/
|
|
454
303
|
setValueLeftForHandle: (handle: HandlePosition, { value: newValue, left: newLeft }: {
|
|
455
|
-
value:
|
|
456
|
-
left:
|
|
304
|
+
value: number;
|
|
305
|
+
left: number;
|
|
457
306
|
}) => void;
|
|
458
|
-
setValueForHandle: (handle: HandlePosition, value:
|
|
459
|
-
isValidValueForPosition: ({ handle, value: newValue, min, max }: {
|
|
460
|
-
handle:
|
|
461
|
-
value:
|
|
462
|
-
min:
|
|
463
|
-
max:
|
|
307
|
+
setValueForHandle: (handle: HandlePosition, value: number | string) => void;
|
|
308
|
+
isValidValueForPosition: ({ handle, value: newValue, min, max, }: {
|
|
309
|
+
handle: HandlePosition;
|
|
310
|
+
value: number;
|
|
311
|
+
min: number;
|
|
312
|
+
max: number;
|
|
464
313
|
}) => boolean;
|
|
465
|
-
isValidValue: ({ value, min, max }: {
|
|
466
|
-
value:
|
|
467
|
-
min:
|
|
468
|
-
max:
|
|
314
|
+
isValidValue: ({ value, min, max, }: {
|
|
315
|
+
value: number;
|
|
316
|
+
min: number;
|
|
317
|
+
max: number;
|
|
469
318
|
}) => boolean;
|
|
470
|
-
getAdjustedValueForPosition: ({ handle, value: newValue, min, max }: {
|
|
471
|
-
handle:
|
|
472
|
-
value:
|
|
473
|
-
min:
|
|
474
|
-
max:
|
|
475
|
-
}) =>
|
|
476
|
-
getAdjustedValue: ({ value, min, max }: {
|
|
477
|
-
value:
|
|
478
|
-
min:
|
|
479
|
-
max:
|
|
480
|
-
}) =>
|
|
319
|
+
getAdjustedValueForPosition: ({ handle, value: newValue, min, max, }: {
|
|
320
|
+
handle: HandlePosition;
|
|
321
|
+
value: number;
|
|
322
|
+
min: number;
|
|
323
|
+
max: number;
|
|
324
|
+
}) => number;
|
|
325
|
+
getAdjustedValue: ({ value, min, max, }: {
|
|
326
|
+
value: number;
|
|
327
|
+
min: number;
|
|
328
|
+
max: number;
|
|
329
|
+
}) => number;
|
|
481
330
|
/**
|
|
482
331
|
* Get the bounding rect for the requested handles' DOM element.
|
|
483
332
|
*
|
|
484
333
|
* If the bounding rect is not available, a new, empty DOMRect is returned.
|
|
485
334
|
*/
|
|
486
335
|
getHandleBoundingRect: (handle: HandlePosition) => DOMRect;
|
|
487
|
-
getClientXFromEvent(event: MouseEvent | TouchEvent):
|
|
336
|
+
getClientXFromEvent(event: globalThis.MouseEvent | globalThis.TouchEvent): number | undefined;
|
|
488
337
|
hasTwoHandles(): boolean;
|
|
489
|
-
static getDerivedStateFromProps(props:
|
|
338
|
+
static getDerivedStateFromProps(props: SliderProps, state: Slider['state']): Partial<{
|
|
339
|
+
value: number;
|
|
340
|
+
valueUpper: number | undefined;
|
|
341
|
+
left: number;
|
|
342
|
+
leftUpper: number;
|
|
343
|
+
needsOnRelease: boolean;
|
|
344
|
+
isValid: boolean;
|
|
345
|
+
isValidUpper: boolean;
|
|
346
|
+
activeHandle: undefined;
|
|
347
|
+
correctedValue: null;
|
|
348
|
+
correctedPosition: null;
|
|
349
|
+
isRtl: boolean;
|
|
350
|
+
}> | null;
|
|
490
351
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
491
352
|
}
|
|
492
353
|
export default Slider;
|