@carbon/react 1.102.0-rc.0 → 1.103.0-rc.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 +976 -976
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/es/components/Button/Button.Skeleton.js +2 -1
- package/es/components/Button/Button.d.ts +4 -4
- package/es/components/Button/Button.js +4 -4
- package/es/components/Button/index.js +1 -1
- package/es/components/ButtonSet/ButtonSet.js +1 -1
- package/es/components/Checkbox/index.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +2 -2
- package/es/components/ComboBox/ComboBox.js +3 -4
- package/es/components/ComposedModal/ComposedModal.js +0 -3
- package/es/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
- package/es/components/ComposedModal/ComposedModalPresence.js +14 -1
- package/es/components/ComposedModal/index.d.ts +1 -1
- package/es/components/ContainedList/index.js +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +3 -2
- package/es/components/DataTable/TableExpandRow.js +2 -2
- package/es/components/DataTable/TableHeader.js +1 -1
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DataTable/tools/normalize.js +2 -1
- package/es/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
- package/es/components/DatePicker/DatePicker.Skeleton.js +2 -2
- package/es/components/DatePicker/DatePicker.js +3 -2
- package/es/components/DatePicker/index.js +1 -1
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dialog/Dialog.js +1 -1
- package/es/components/Dropdown/Dropdown.js +1 -3
- package/es/components/Dropdown/index.js +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/es/components/FeatureFlags/index.d.ts +8 -18
- package/es/components/FeatureFlags/index.js +23 -103
- package/es/components/FileUploader/FileUploader.Skeleton.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +3 -7
- package/es/components/Icon/Icon.Skeleton.js +1 -1
- package/es/components/IconIndicator/index.js +1 -1
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/Modal/ModalPresence.d.ts +9 -1
- package/es/components/Modal/ModalPresence.js +14 -1
- package/es/components/Modal/index.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +9 -10
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +15 -13
- package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +3 -5
- package/es/components/OverflowMenuV2/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +2 -23
- package/es/components/Pagination/Pagination.Skeleton.js +1 -1
- package/es/components/Pagination/Pagination.d.ts +4 -0
- package/es/components/Pagination/Pagination.js +6 -1
- package/es/components/Pagination/experimental/Pagination.js +12 -1
- package/es/components/Popover/index.js +1 -1
- package/es/components/ProgressIndicator/ProgressIndicator.js +3 -3
- package/es/components/RadioButton/RadioButton.Skeleton.js +1 -1
- package/es/components/Search/index.js +1 -1
- package/es/components/Select/index.js +1 -1
- package/es/components/ShapeIndicator/index.js +1 -1
- package/es/components/Slider/Slider.d.ts +1 -1
- package/es/components/Slider/Slider.js +230 -255
- package/es/components/Slider/SliderHandles.js +65 -53
- package/es/components/Switch/IconSwitch.js +1 -1
- package/es/components/Tabs/Tabs.js +2 -6
- package/es/components/Tag/Tag.Skeleton.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextArea/index.js +1 -1
- package/es/components/TextInput/index.js +1 -1
- package/es/components/Tile/Tile.js +1 -1
- package/es/components/TileGroup/TileGroup.d.ts +1 -1
- package/es/components/TileGroup/TileGroup.js +2 -1
- package/es/components/Toggle/Toggle.Skeleton.js +1 -1
- package/es/components/Toggletip/index.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/HeaderPanel.js +3 -2
- package/es/components/UIShell/SideNav.d.ts +1 -4
- package/es/components/UIShell/SideNav.js +10 -25
- package/es/components/UIShell/SideNavContext.d.ts +17 -0
- package/es/components/UIShell/SideNavContext.js +24 -0
- package/es/components/UIShell/SideNavItems.d.ts +1 -1
- package/es/components/UIShell/SideNavItems.js +12 -16
- package/es/components/UIShell/SideNavLink.js +8 -4
- package/es/components/UIShell/SideNavMenu.js +7 -5
- package/es/components/UIShell/Switcher.js +5 -4
- package/es/index.js +30 -30
- package/es/internal/useNoInteractiveChildren.js +25 -30
- package/es/internal/useOverflowItems.d.ts +1 -5
- package/es/internal/useOverflowItems.js +6 -27
- package/es/internal/usePresence.d.ts +1 -1
- package/es/internal/usePresence.js +14 -17
- package/lib/components/Button/Button.Skeleton.js +2 -1
- package/lib/components/Button/Button.d.ts +4 -4
- package/lib/components/Button/Button.js +4 -4
- package/lib/components/Button/index.js +1 -1
- package/lib/components/ButtonSet/ButtonSet.js +1 -1
- package/lib/components/Checkbox/index.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +3 -4
- package/lib/components/ComposedModal/ComposedModal.js +0 -3
- package/lib/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
- package/lib/components/ComposedModal/ComposedModalPresence.js +14 -0
- package/lib/components/ComposedModal/index.d.ts +1 -1
- package/lib/components/ContainedList/index.js +0 -3
- package/lib/components/ContentSwitcher/ContentSwitcher.js +2 -1
- package/lib/components/DataTable/TableExpandRow.js +1 -1
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DataTable/tools/normalize.js +2 -1
- package/lib/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
- package/lib/components/DatePicker/DatePicker.Skeleton.js +2 -2
- package/lib/components/DatePicker/DatePicker.js +3 -2
- package/lib/components/DatePicker/index.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +1 -3
- package/lib/components/Dropdown/index.js +1 -1
- package/lib/components/FeatureFlags/index.d.ts +8 -18
- package/lib/components/FeatureFlags/index.js +21 -102
- package/lib/components/FileUploader/FileUploader.Skeleton.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +2 -6
- package/lib/components/Icon/Icon.Skeleton.js +0 -3
- package/lib/components/IconIndicator/index.js +0 -3
- package/lib/components/Modal/ModalPresence.d.ts +9 -1
- package/lib/components/Modal/ModalPresence.js +14 -0
- package/lib/components/Modal/index.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +8 -9
- package/lib/components/NumberInput/NumberInput.js +14 -12
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -7
- package/lib/components/OverflowMenuV2/index.js +1 -1
- package/lib/components/PageHeader/PageHeader.js +2 -23
- package/lib/components/Pagination/Pagination.Skeleton.js +0 -3
- package/lib/components/Pagination/Pagination.d.ts +4 -0
- package/lib/components/Pagination/Pagination.js +6 -1
- package/lib/components/Pagination/experimental/Pagination.js +12 -1
- package/lib/components/ProgressIndicator/ProgressIndicator.js +3 -3
- package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -3
- package/lib/components/Search/index.js +1 -1
- package/lib/components/Select/index.js +1 -1
- package/lib/components/ShapeIndicator/index.js +0 -3
- package/lib/components/Slider/Slider.d.ts +1 -1
- package/lib/components/Slider/Slider.js +229 -254
- package/lib/components/Slider/SliderHandles.js +64 -52
- package/lib/components/Tabs/Tabs.js +1 -5
- package/lib/components/Tag/Tag.Skeleton.js +0 -3
- package/lib/components/TextArea/index.js +1 -1
- package/lib/components/TextInput/index.js +1 -1
- package/lib/components/TileGroup/TileGroup.d.ts +1 -1
- package/lib/components/TileGroup/TileGroup.js +2 -1
- package/lib/components/Toggle/Toggle.Skeleton.js +0 -3
- package/lib/components/Toggletip/index.js +0 -3
- package/lib/components/UIShell/HeaderPanel.js +2 -1
- package/lib/components/UIShell/SideNav.d.ts +1 -4
- package/lib/components/UIShell/SideNav.js +8 -24
- package/lib/components/UIShell/SideNavContext.d.ts +17 -0
- package/lib/components/UIShell/SideNavContext.js +27 -0
- package/lib/components/UIShell/SideNavItems.d.ts +1 -1
- package/lib/components/UIShell/SideNavItems.js +11 -15
- package/lib/components/UIShell/SideNavLink.js +7 -3
- package/lib/components/UIShell/SideNavMenu.js +8 -6
- package/lib/components/UIShell/Switcher.js +4 -3
- package/lib/index.js +102 -100
- package/lib/internal/useNoInteractiveChildren.js +25 -30
- package/lib/internal/useOverflowItems.d.ts +1 -5
- package/lib/internal/useOverflowItems.js +6 -27
- package/lib/internal/usePresence.d.ts +1 -1
- package/lib/internal/usePresence.js +13 -16
- package/package.json +8 -8
- package/telemetry.yml +2 -1
- package/es/components/UIShell/_utils.d.ts +0 -7
- package/es/components/UIShell/_utils.js +0 -10
- package/lib/components/UIShell/_utils.d.ts +0 -7
- package/lib/components/UIShell/_utils.js +0 -12
|
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Enter, ArrowDown, ArrowLeft, ArrowUp, ArrowRight } from '../../internal/keyboard/keys.js';
|
|
13
13
|
import { matches } from '../../internal/keyboard/match.js';
|
|
14
|
-
import {
|
|
14
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
16
16
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
17
17
|
import { Text } from '../Text/Text.js';
|
|
@@ -21,6 +21,7 @@ import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
|
21
21
|
import { LowerHandle, LowerHandleFocus, UpperHandle, UpperHandleFocus } from './SliderHandles.js';
|
|
22
22
|
import { clamp } from '../../internal/clamp.js';
|
|
23
23
|
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
24
|
+
import { useId } from '../../internal/useId.js';
|
|
24
25
|
import { throttle } from '../../node_modules/es-toolkit/dist/compat/function/throttle.js';
|
|
25
26
|
|
|
26
27
|
const ThumbWrapper = ({
|
|
@@ -58,6 +59,7 @@ const defaultTranslateWithId = (messageId, args) => {
|
|
|
58
59
|
const defaultFormatLabel = (value, label) => {
|
|
59
60
|
return `${value}${label ?? ''}`;
|
|
60
61
|
};
|
|
62
|
+
const hasUpperValue = valueUpper => typeof valueUpper !== 'undefined';
|
|
61
63
|
|
|
62
64
|
// TODO: Assuming a 16ms throttle corresponds to 60 FPS, should it be halved,
|
|
63
65
|
// since many systems can handle 120 FPS? If it doesn't correspond to 60 FPS,
|
|
@@ -74,7 +76,6 @@ var HandlePosition = /*#__PURE__*/function (HandlePosition) {
|
|
|
74
76
|
return HandlePosition;
|
|
75
77
|
}(HandlePosition || {}); // TODO: Delete this type and directory type the properties in the function.
|
|
76
78
|
const Slider = props => {
|
|
77
|
-
var _Fragment, _Fragment2, _Fragment3, _Fragment4;
|
|
78
79
|
// TODO: Move destructured `props` from the IIFE to here.
|
|
79
80
|
|
|
80
81
|
const initialState = {
|
|
@@ -111,14 +112,9 @@ const Slider = props => {
|
|
|
111
112
|
const filledTrackRef = useRef(null);
|
|
112
113
|
const elementRef = useRef(null);
|
|
113
114
|
const trackRef = useRef(null);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// `twoHandles`.
|
|
118
|
-
const hasTwoHandles = () => {
|
|
119
|
-
return typeof state.valueUpper !== 'undefined';
|
|
120
|
-
};
|
|
121
|
-
const twoHandles = hasTwoHandles();
|
|
115
|
+
const generatedId = useId();
|
|
116
|
+
const prefix = usePrefix();
|
|
117
|
+
const twoHandles = hasUpperValue(state.valueUpper);
|
|
122
118
|
|
|
123
119
|
/**
|
|
124
120
|
* Sets up initial slider position and value in response to component mount.
|
|
@@ -126,7 +122,7 @@ const Slider = props => {
|
|
|
126
122
|
useEffect(() => {
|
|
127
123
|
if (elementRef.current) {
|
|
128
124
|
const isRtl = document?.dir === 'rtl';
|
|
129
|
-
if (
|
|
125
|
+
if (twoHandles) {
|
|
130
126
|
const {
|
|
131
127
|
value,
|
|
132
128
|
left
|
|
@@ -178,7 +174,7 @@ const Slider = props => {
|
|
|
178
174
|
|
|
179
175
|
// Fire onChange event handler if present, if there's a usable value, and
|
|
180
176
|
// if the value is different from the last one
|
|
181
|
-
if (
|
|
177
|
+
if (twoHandles) {
|
|
182
178
|
if (filledTrackRef.current) {
|
|
183
179
|
filledTrackRef.current.style.transform = state.isRtl ? `translate(${100 - state.leftUpper}%, -50%) scaleX(${(state.leftUpper - state.left) / 100})` : `translate(${state.left}%, -50%) scaleX(${(state.leftUpper - state.left) / 100})`;
|
|
184
180
|
}
|
|
@@ -271,8 +267,7 @@ const Slider = props => {
|
|
|
271
267
|
* @returns The value rounded to the precision determined by the step.
|
|
272
268
|
*/
|
|
273
269
|
const nearestStepValue = (value = 0) => {
|
|
274
|
-
|
|
275
|
-
const decimals = (props.step?.toString().split('.')[1] || '').length;
|
|
270
|
+
const decimals = (props.step?.toString().split('.')[1] ?? '').length;
|
|
276
271
|
return Number(value.toFixed(decimals));
|
|
277
272
|
};
|
|
278
273
|
const handleDrag = event => {
|
|
@@ -312,7 +307,7 @@ const Slider = props => {
|
|
|
312
307
|
});
|
|
313
308
|
const clientX = getClientXFromEvent(evt.nativeEvent);
|
|
314
309
|
let activeHandle;
|
|
315
|
-
if (
|
|
310
|
+
if (twoHandles) {
|
|
316
311
|
if (evt.target == thumbRef.current) {
|
|
317
312
|
activeHandle = HandlePosition.LOWER;
|
|
318
313
|
} else if (evt.target == thumbRefUpper.current) {
|
|
@@ -332,7 +327,7 @@ const Slider = props => {
|
|
|
332
327
|
const focusOptions = {
|
|
333
328
|
preventScroll: true
|
|
334
329
|
};
|
|
335
|
-
if (
|
|
330
|
+
if (twoHandles) {
|
|
336
331
|
if (thumbRef.current && activeHandle === HandlePosition.LOWER) {
|
|
337
332
|
thumbRef.current.focus(focusOptions);
|
|
338
333
|
} else if (thumbRefUpper.current && activeHandle === HandlePosition.UPPER) {
|
|
@@ -405,7 +400,7 @@ const Slider = props => {
|
|
|
405
400
|
});
|
|
406
401
|
// If we're set to two handles, negotiate which drag handle is closest to
|
|
407
402
|
// the users' interaction.
|
|
408
|
-
if (
|
|
403
|
+
if (twoHandles && activeHandle) {
|
|
409
404
|
setValueLeftForHandle(activeHandle, {
|
|
410
405
|
value: nearestStepValue(value),
|
|
411
406
|
left
|
|
@@ -463,7 +458,7 @@ const Slider = props => {
|
|
|
463
458
|
if (evt.shiftKey) {
|
|
464
459
|
delta *= stepMultiplier;
|
|
465
460
|
}
|
|
466
|
-
if (
|
|
461
|
+
if (twoHandles && state.activeHandle) {
|
|
467
462
|
const currentValue = state.activeHandle === HandlePosition.LOWER ? state.value : state.valueUpper;
|
|
468
463
|
const {
|
|
469
464
|
value,
|
|
@@ -517,7 +512,7 @@ const Slider = props => {
|
|
|
517
512
|
// Avoid calling calcValue for invalid numbers, but still update the state.
|
|
518
513
|
const activeHandle = evt.target.dataset.handlePosition ?? HandlePosition.LOWER;
|
|
519
514
|
const targetValue = Number.parseFloat(evt.target.value);
|
|
520
|
-
if (
|
|
515
|
+
if (twoHandles) {
|
|
521
516
|
if (isNaN(targetValue)) {
|
|
522
517
|
setValueForHandle(activeHandle, evt.target.value);
|
|
523
518
|
} else if (isValidValueForPosition({
|
|
@@ -933,13 +928,7 @@ const Slider = props => {
|
|
|
933
928
|
unstable_ariaLabelInputUpper: ariaLabelInputUpper,
|
|
934
929
|
className,
|
|
935
930
|
hideTextInput = false,
|
|
936
|
-
id
|
|
937
|
-
// TODO:
|
|
938
|
-
// 1. Why isn't `inputId` just set to this value instead of an empty
|
|
939
|
-
// string?
|
|
940
|
-
// 2. Why this value instead of something else, like
|
|
941
|
-
// `crypto.randomUUID()` or `useId()`?
|
|
942
|
-
`__carbon-slider_${Math.random().toString(36).substr(2)}`,
|
|
931
|
+
id: idProp,
|
|
943
932
|
min,
|
|
944
933
|
minLabel,
|
|
945
934
|
max,
|
|
@@ -948,9 +937,6 @@ const Slider = props => {
|
|
|
948
937
|
labelText,
|
|
949
938
|
hideLabel,
|
|
950
939
|
step = 1,
|
|
951
|
-
// TODO: Other properties are deleted below. Why isn't this one?
|
|
952
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
953
|
-
stepMultiplier: _stepMultiplier,
|
|
954
940
|
inputType = 'number',
|
|
955
941
|
invalidText,
|
|
956
942
|
required,
|
|
@@ -964,6 +950,7 @@ const Slider = props => {
|
|
|
964
950
|
translateWithId: t = defaultTranslateWithId,
|
|
965
951
|
...other
|
|
966
952
|
} = props;
|
|
953
|
+
const id = idProp ?? generatedId;
|
|
967
954
|
const {
|
|
968
955
|
value,
|
|
969
956
|
valueUpper,
|
|
@@ -987,232 +974,220 @@ const Slider = props => {
|
|
|
987
974
|
invalid: !isValidUpper,
|
|
988
975
|
warn
|
|
989
976
|
});
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
}, invalidText), (normalizedProps.warn || normalizedUpperProps.warn) && /*#__PURE__*/React.createElement(Text, {
|
|
1205
|
-
as: "div",
|
|
1206
|
-
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--form-requirement`)
|
|
1207
|
-
}, warnText), correctedValue && /*#__PURE__*/React.createElement(Text, {
|
|
1208
|
-
as: "div",
|
|
1209
|
-
role: "alert",
|
|
1210
|
-
className: cx(`${prefix}--slider__status-msg`, `${prefix}--form-requirement`)
|
|
1211
|
-
}, t(translationIds['carbon.slider.auto-correct-announcement'], {
|
|
1212
|
-
correctedValue
|
|
1213
|
-
})));
|
|
1214
|
-
});
|
|
1215
|
-
})();
|
|
977
|
+
delete other.invalid;
|
|
978
|
+
delete other.onRelease;
|
|
979
|
+
delete other.stepMultiplier;
|
|
980
|
+
delete other.unstable_valueUpper;
|
|
981
|
+
const showWarning = normalizedProps.warn || correctedPosition === HandlePosition.LOWER && isValid;
|
|
982
|
+
const showWarningUpper = normalizedUpperProps.warn || correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
983
|
+
const labelId = `${id}-label`;
|
|
984
|
+
const labelClasses = cx(`${prefix}--label`, {
|
|
985
|
+
[`${prefix}--visually-hidden`]: hideLabel,
|
|
986
|
+
[`${prefix}--label--disabled`]: disabled
|
|
987
|
+
});
|
|
988
|
+
const containerClasses = cx(`${prefix}--slider-container`, {
|
|
989
|
+
[`${prefix}--slider-container--two-handles`]: twoHandles,
|
|
990
|
+
[`${prefix}--slider-container--disabled`]: disabled,
|
|
991
|
+
[`${prefix}--slider-container--readonly`]: readOnly,
|
|
992
|
+
[`${prefix}--slider-container--rtl`]: isRtl
|
|
993
|
+
});
|
|
994
|
+
const sliderClasses = cx(`${prefix}--slider`, {
|
|
995
|
+
[`${prefix}--slider--disabled`]: disabled,
|
|
996
|
+
[`${prefix}--slider--readonly`]: readOnly
|
|
997
|
+
});
|
|
998
|
+
const fixedInputClasses = [`${prefix}--text-input`, `${prefix}--slider-text-input`];
|
|
999
|
+
const conditionalInputClasses = {
|
|
1000
|
+
[`${prefix}--text-input--light`]: light
|
|
1001
|
+
};
|
|
1002
|
+
const lowerInputClasses = cx([...fixedInputClasses, `${prefix}--slider-text-input--lower`, conditionalInputClasses, {
|
|
1003
|
+
[`${prefix}--text-input--invalid`]: normalizedProps.invalid,
|
|
1004
|
+
[`${prefix}--slider-text-input--warn`]: showWarning
|
|
1005
|
+
}]);
|
|
1006
|
+
const upperInputClasses = cx([...fixedInputClasses, `${prefix}--slider-text-input--upper`, conditionalInputClasses, {
|
|
1007
|
+
[`${prefix}--text-input--invalid`]: twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid,
|
|
1008
|
+
[`${prefix}--slider-text-input--warn`]: showWarningUpper
|
|
1009
|
+
}]);
|
|
1010
|
+
const lowerInputWrapperClasses = cx([`${prefix}--text-input-wrapper`, `${prefix}--slider-text-input-wrapper`, `${prefix}--slider-text-input-wrapper--lower`, {
|
|
1011
|
+
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
|
|
1012
|
+
[`${prefix}--slider-text-input-wrapper--hidden`]: hideTextInput
|
|
1013
|
+
}]);
|
|
1014
|
+
const upperInputWrapperClasses = cx([`${prefix}--text-input-wrapper`, `${prefix}--slider-text-input-wrapper`, `${prefix}--slider-text-input-wrapper--upper`, {
|
|
1015
|
+
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
|
|
1016
|
+
[`${prefix}--slider-text-input-wrapper--hidden`]: hideTextInput
|
|
1017
|
+
}]);
|
|
1018
|
+
const lowerThumbClasses = cx(`${prefix}--slider__thumb`, {
|
|
1019
|
+
[`${prefix}--slider__thumb--lower`]: twoHandles
|
|
1020
|
+
});
|
|
1021
|
+
const upperThumbClasses = cx(`${prefix}--slider__thumb`, {
|
|
1022
|
+
[`${prefix}--slider__thumb--upper`]: twoHandles
|
|
1023
|
+
});
|
|
1024
|
+
const lowerThumbWrapperClasses = cx([`${prefix}--icon-tooltip`, `${prefix}--slider__thumb-wrapper`, {
|
|
1025
|
+
[`${prefix}--slider__thumb-wrapper--lower`]: twoHandles
|
|
1026
|
+
}]);
|
|
1027
|
+
const upperThumbWrapperClasses = cx([`${prefix}--icon-tooltip`, `${prefix}--slider__thumb-wrapper`, {
|
|
1028
|
+
[`${prefix}--slider__thumb-wrapper--upper`]: twoHandles
|
|
1029
|
+
}]);
|
|
1030
|
+
const lowerThumbWrapperProps = {
|
|
1031
|
+
style: {
|
|
1032
|
+
insetInlineStart: `${state.left}%`
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
const upperThumbWrapperProps = {
|
|
1036
|
+
style: {
|
|
1037
|
+
insetInlineStart: `${state.leftUpper}%`
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1041
|
+
className: cx(`${prefix}--form-item`, className)
|
|
1042
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
1043
|
+
as: "label",
|
|
1044
|
+
htmlFor: twoHandles ? undefined : id,
|
|
1045
|
+
className: labelClasses,
|
|
1046
|
+
id: labelId
|
|
1047
|
+
}, labelText), /*#__PURE__*/React.createElement("div", {
|
|
1048
|
+
className: containerClasses
|
|
1049
|
+
}, twoHandles ? /*#__PURE__*/React.createElement("div", {
|
|
1050
|
+
className: lowerInputWrapperClasses
|
|
1051
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1052
|
+
type: hideTextInput ? 'hidden' : inputType,
|
|
1053
|
+
id: `${id}-lower-input-for-slider`,
|
|
1054
|
+
name: name,
|
|
1055
|
+
className: lowerInputClasses,
|
|
1056
|
+
value: value,
|
|
1057
|
+
"aria-label": ariaLabelInput,
|
|
1058
|
+
disabled: disabled,
|
|
1059
|
+
required: required,
|
|
1060
|
+
min: min,
|
|
1061
|
+
max: max,
|
|
1062
|
+
step: step,
|
|
1063
|
+
onChange: onChangeInput,
|
|
1064
|
+
onBlur: onBlurInput,
|
|
1065
|
+
onKeyUp: props.onInputKeyUp,
|
|
1066
|
+
onKeyDown: onInputKeyDown,
|
|
1067
|
+
"data-invalid": normalizedProps.invalid ? true : null,
|
|
1068
|
+
"data-handle-position": HandlePosition.LOWER,
|
|
1069
|
+
"aria-invalid": normalizedProps.invalid ? true : undefined,
|
|
1070
|
+
readOnly: readOnly
|
|
1071
|
+
}), normalizedProps.invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
1072
|
+
className: `${prefix}--slider__invalid-icon`
|
|
1073
|
+
}), showWarning && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
1074
|
+
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
1075
|
+
})) : null, /*#__PURE__*/React.createElement(Text, {
|
|
1076
|
+
className: `${prefix}--slider__range-label`
|
|
1077
|
+
}, formatLabel(min, minLabel)), /*#__PURE__*/React.createElement("div", _extends({
|
|
1078
|
+
className: sliderClasses,
|
|
1079
|
+
ref: node => {
|
|
1080
|
+
elementRef.current = node;
|
|
1081
|
+
},
|
|
1082
|
+
onMouseDown: onDragStart,
|
|
1083
|
+
onTouchStart: onDragStart,
|
|
1084
|
+
onKeyDown: onKeyDown,
|
|
1085
|
+
role: "presentation",
|
|
1086
|
+
tabIndex: -1,
|
|
1087
|
+
"data-invalid": (twoHandles ? normalizedProps.invalid || normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null
|
|
1088
|
+
}, other), /*#__PURE__*/React.createElement(ThumbWrapper, _extends({
|
|
1089
|
+
hasTooltip: hideTextInput,
|
|
1090
|
+
className: lowerThumbWrapperClasses,
|
|
1091
|
+
label: formatLabel(value, undefined),
|
|
1092
|
+
align: "top"
|
|
1093
|
+
}, lowerThumbWrapperProps), /*#__PURE__*/React.createElement("div", {
|
|
1094
|
+
className: lowerThumbClasses,
|
|
1095
|
+
role: "slider",
|
|
1096
|
+
id: twoHandles ? undefined : id,
|
|
1097
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1098
|
+
"aria-valuetext": formatLabel(value, undefined),
|
|
1099
|
+
"aria-valuemax": twoHandles ? valueUpper : max,
|
|
1100
|
+
"aria-valuemin": min,
|
|
1101
|
+
"aria-valuenow": value,
|
|
1102
|
+
"aria-labelledby": twoHandles ? undefined : labelId,
|
|
1103
|
+
"aria-label": twoHandles ? ariaLabelInput : undefined,
|
|
1104
|
+
ref: thumbRef,
|
|
1105
|
+
onFocus: () => setState({
|
|
1106
|
+
activeHandle: HandlePosition.LOWER
|
|
1107
|
+
})
|
|
1108
|
+
}, twoHandles && !isRtl ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LowerHandle, {
|
|
1109
|
+
"aria-label": ariaLabelInput
|
|
1110
|
+
}), /*#__PURE__*/React.createElement(LowerHandleFocus, {
|
|
1111
|
+
"aria-label": ariaLabelInput
|
|
1112
|
+
})) : twoHandles && isRtl ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UpperHandle, {
|
|
1113
|
+
"aria-label": ariaLabelInputUpper
|
|
1114
|
+
}), /*#__PURE__*/React.createElement(UpperHandleFocus, {
|
|
1115
|
+
"aria-label": ariaLabelInputUpper
|
|
1116
|
+
})) : undefined)), hasUpperValue(valueUpper) ? /*#__PURE__*/React.createElement(ThumbWrapper, _extends({
|
|
1117
|
+
hasTooltip: hideTextInput,
|
|
1118
|
+
className: upperThumbWrapperClasses,
|
|
1119
|
+
label: formatLabel(valueUpper, undefined),
|
|
1120
|
+
align: "top"
|
|
1121
|
+
}, upperThumbWrapperProps), /*#__PURE__*/React.createElement("div", {
|
|
1122
|
+
className: upperThumbClasses,
|
|
1123
|
+
role: "slider",
|
|
1124
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1125
|
+
"aria-valuemax": max,
|
|
1126
|
+
"aria-valuemin": value,
|
|
1127
|
+
"aria-valuenow": valueUpper,
|
|
1128
|
+
"aria-label": ariaLabelInputUpper,
|
|
1129
|
+
ref: thumbRefUpper,
|
|
1130
|
+
onFocus: () => setState({
|
|
1131
|
+
activeHandle: HandlePosition.UPPER
|
|
1132
|
+
})
|
|
1133
|
+
}, !isRtl ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UpperHandle, {
|
|
1134
|
+
"aria-label": ariaLabelInputUpper
|
|
1135
|
+
}), /*#__PURE__*/React.createElement(UpperHandleFocus, {
|
|
1136
|
+
"aria-label": ariaLabelInputUpper
|
|
1137
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LowerHandle, {
|
|
1138
|
+
"aria-label": ariaLabelInput
|
|
1139
|
+
}), /*#__PURE__*/React.createElement(LowerHandleFocus, {
|
|
1140
|
+
"aria-label": ariaLabelInput
|
|
1141
|
+
})))) : null, /*#__PURE__*/React.createElement("div", {
|
|
1142
|
+
className: `${prefix}--slider__track`,
|
|
1143
|
+
ref: node => {
|
|
1144
|
+
trackRef.current = node;
|
|
1145
|
+
}
|
|
1146
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
1147
|
+
className: `${prefix}--slider__filled-track`,
|
|
1148
|
+
ref: filledTrackRef
|
|
1149
|
+
})), /*#__PURE__*/React.createElement(Text, {
|
|
1150
|
+
className: `${prefix}--slider__range-label`
|
|
1151
|
+
}, formatLabel(max, maxLabel)), /*#__PURE__*/React.createElement("div", {
|
|
1152
|
+
className: upperInputWrapperClasses
|
|
1153
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1154
|
+
type: hideTextInput ? 'hidden' : inputType,
|
|
1155
|
+
id: `${id}-${twoHandles ? 'upper-' : ''}input-for-slider`,
|
|
1156
|
+
name: twoHandles ? nameUpper : name,
|
|
1157
|
+
className: upperInputClasses,
|
|
1158
|
+
value: twoHandles ? valueUpper : value,
|
|
1159
|
+
"aria-labelledby": !ariaLabelInput && !twoHandles ? labelId : undefined,
|
|
1160
|
+
"aria-label": twoHandles ? ariaLabelInputUpper : ariaLabelInput ? ariaLabelInput : undefined,
|
|
1161
|
+
disabled: disabled,
|
|
1162
|
+
required: required,
|
|
1163
|
+
min: min,
|
|
1164
|
+
max: max,
|
|
1165
|
+
step: step,
|
|
1166
|
+
onChange: onChangeInput,
|
|
1167
|
+
onBlur: onBlurInput,
|
|
1168
|
+
onKeyDown: onInputKeyDown,
|
|
1169
|
+
onKeyUp: props.onInputKeyUp,
|
|
1170
|
+
"data-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
|
|
1171
|
+
"data-handle-position": twoHandles ? HandlePosition.UPPER : null,
|
|
1172
|
+
"aria-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : undefined,
|
|
1173
|
+
readOnly: readOnly
|
|
1174
|
+
}), (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
1175
|
+
className: `${prefix}--slider__invalid-icon`
|
|
1176
|
+
}), showWarningUpper && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
1177
|
+
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
1178
|
+
}))), (normalizedProps.invalid || normalizedUpperProps.invalid) && /*#__PURE__*/React.createElement(Text, {
|
|
1179
|
+
as: "div",
|
|
1180
|
+
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--slider__validation-msg--invalid`, `${prefix}--form-requirement`)
|
|
1181
|
+
}, invalidText), (normalizedProps.warn || normalizedUpperProps.warn) && /*#__PURE__*/React.createElement(Text, {
|
|
1182
|
+
as: "div",
|
|
1183
|
+
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--form-requirement`)
|
|
1184
|
+
}, warnText), correctedValue && /*#__PURE__*/React.createElement(Text, {
|
|
1185
|
+
as: "div",
|
|
1186
|
+
role: "alert",
|
|
1187
|
+
className: cx(`${prefix}--slider__status-msg`, `${prefix}--form-requirement`)
|
|
1188
|
+
}, t(translationIds['carbon.slider.auto-correct-announcement'], {
|
|
1189
|
+
correctedValue
|
|
1190
|
+
})));
|
|
1216
1191
|
};
|
|
1217
1192
|
Slider.propTypes = {
|
|
1218
1193
|
/**
|