@carbon/react 1.102.0 → 1.103.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 +1011 -1011
- 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/ComboBox/ComboBox.js +2 -2
- 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/DataTable/TableHeader.js +1 -1
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +1 -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.d.ts +4 -2
- package/es/components/DatePicker/DatePicker.js +9 -6
- package/es/components/DatePicker/index.js +1 -1
- package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/es/components/DatePicker/plugins/rangePlugin.js +2 -1
- package/es/components/{UIShell/_utils.d.ts → DatePicker/utils.d.ts} +2 -2
- package/es/components/{UIShell/_utils.js → DatePicker/utils.js} +2 -2
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dialog/Dialog.js +1 -1
- 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/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.js +230 -249
- package/es/components/Slider/SliderHandles.js +65 -53
- package/es/components/Switch/IconSwitch.js +1 -1
- package/es/components/Tabs/Tabs.js +10 -12
- 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.d.ts +2 -2
- package/es/components/Tile/Tile.js +7 -2
- 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/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/index.js +30 -30
- package/es/internal/useNoInteractiveChildren.js +25 -30
- 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/ComboBox/ComboBox.js +2 -2
- 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/DataTable/TableToolbarMenu.js +1 -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.d.ts +4 -2
- package/lib/components/DatePicker/DatePicker.js +9 -6
- package/lib/components/DatePicker/index.js +1 -1
- package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/lib/components/DatePicker/plugins/rangePlugin.js +2 -1
- package/lib/components/{UIShell/_utils.d.ts → DatePicker/utils.d.ts} +2 -2
- package/lib/components/{UIShell/_utils.js → DatePicker/utils.js} +2 -2
- 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/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.js +229 -248
- package/lib/components/Slider/SliderHandles.js +64 -52
- package/lib/components/Tabs/Tabs.js +9 -11
- 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/Tile/Tile.d.ts +2 -2
- package/lib/components/Tile/Tile.js +6 -1
- package/lib/components/Toggle/Toggle.Skeleton.js +0 -3
- package/lib/components/Toggletip/index.js +0 -3
- 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/index.js +102 -100
- package/lib/internal/useNoInteractiveChildren.js +25 -30
- package/lib/internal/usePresence.d.ts +1 -1
- package/lib/internal/usePresence.js +13 -16
- package/package.json +5 -5
- package/telemetry.yml +2 -1
|
@@ -25,6 +25,7 @@ var Tooltip = require('../Tooltip/Tooltip.js');
|
|
|
25
25
|
var SliderHandles = require('./SliderHandles.js');
|
|
26
26
|
var clamp = require('../../internal/clamp.js');
|
|
27
27
|
var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
|
|
28
|
+
var useId = require('../../internal/useId.js');
|
|
28
29
|
var throttle = require('../../node_modules/es-toolkit/dist/compat/function/throttle.js');
|
|
29
30
|
|
|
30
31
|
const ThumbWrapper = ({
|
|
@@ -62,6 +63,7 @@ const defaultTranslateWithId = (messageId, args) => {
|
|
|
62
63
|
const defaultFormatLabel = (value, label) => {
|
|
63
64
|
return `${value}${label ?? ''}`;
|
|
64
65
|
};
|
|
66
|
+
const hasUpperValue = valueUpper => typeof valueUpper !== 'undefined';
|
|
65
67
|
|
|
66
68
|
// TODO: Assuming a 16ms throttle corresponds to 60 FPS, should it be halved,
|
|
67
69
|
// since many systems can handle 120 FPS? If it doesn't correspond to 60 FPS,
|
|
@@ -78,7 +80,6 @@ var HandlePosition = /*#__PURE__*/function (HandlePosition) {
|
|
|
78
80
|
return HandlePosition;
|
|
79
81
|
}(HandlePosition || {}); // TODO: Delete this type and directory type the properties in the function.
|
|
80
82
|
const Slider = props => {
|
|
81
|
-
var _Fragment, _Fragment2, _Fragment3, _Fragment4;
|
|
82
83
|
// TODO: Move destructured `props` from the IIFE to here.
|
|
83
84
|
|
|
84
85
|
const initialState = {
|
|
@@ -115,14 +116,9 @@ const Slider = props => {
|
|
|
115
116
|
const filledTrackRef = React.useRef(null);
|
|
116
117
|
const elementRef = React.useRef(null);
|
|
117
118
|
const trackRef = React.useRef(null);
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// `twoHandles`.
|
|
122
|
-
const hasTwoHandles = () => {
|
|
123
|
-
return typeof state.valueUpper !== 'undefined';
|
|
124
|
-
};
|
|
125
|
-
const twoHandles = hasTwoHandles();
|
|
119
|
+
const generatedId = useId.useId();
|
|
120
|
+
const prefix = usePrefix.usePrefix();
|
|
121
|
+
const twoHandles = hasUpperValue(state.valueUpper);
|
|
126
122
|
|
|
127
123
|
/**
|
|
128
124
|
* Sets up initial slider position and value in response to component mount.
|
|
@@ -130,7 +126,7 @@ const Slider = props => {
|
|
|
130
126
|
React.useEffect(() => {
|
|
131
127
|
if (elementRef.current) {
|
|
132
128
|
const isRtl = document?.dir === 'rtl';
|
|
133
|
-
if (
|
|
129
|
+
if (twoHandles) {
|
|
134
130
|
const {
|
|
135
131
|
value,
|
|
136
132
|
left
|
|
@@ -182,7 +178,7 @@ const Slider = props => {
|
|
|
182
178
|
|
|
183
179
|
// Fire onChange event handler if present, if there's a usable value, and
|
|
184
180
|
// if the value is different from the last one
|
|
185
|
-
if (
|
|
181
|
+
if (twoHandles) {
|
|
186
182
|
if (filledTrackRef.current) {
|
|
187
183
|
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})`;
|
|
188
184
|
}
|
|
@@ -275,8 +271,7 @@ const Slider = props => {
|
|
|
275
271
|
* @returns The value rounded to the precision determined by the step.
|
|
276
272
|
*/
|
|
277
273
|
const nearestStepValue = (value = 0) => {
|
|
278
|
-
|
|
279
|
-
const decimals = (props.step?.toString().split('.')[1] || '').length;
|
|
274
|
+
const decimals = (props.step?.toString().split('.')[1] ?? '').length;
|
|
280
275
|
return Number(value.toFixed(decimals));
|
|
281
276
|
};
|
|
282
277
|
const handleDrag = event => {
|
|
@@ -316,7 +311,7 @@ const Slider = props => {
|
|
|
316
311
|
});
|
|
317
312
|
const clientX = getClientXFromEvent(evt.nativeEvent);
|
|
318
313
|
let activeHandle;
|
|
319
|
-
if (
|
|
314
|
+
if (twoHandles) {
|
|
320
315
|
if (evt.target == thumbRef.current) {
|
|
321
316
|
activeHandle = HandlePosition.LOWER;
|
|
322
317
|
} else if (evt.target == thumbRefUpper.current) {
|
|
@@ -336,7 +331,7 @@ const Slider = props => {
|
|
|
336
331
|
const focusOptions = {
|
|
337
332
|
preventScroll: true
|
|
338
333
|
};
|
|
339
|
-
if (
|
|
334
|
+
if (twoHandles) {
|
|
340
335
|
if (thumbRef.current && activeHandle === HandlePosition.LOWER) {
|
|
341
336
|
thumbRef.current.focus(focusOptions);
|
|
342
337
|
} else if (thumbRefUpper.current && activeHandle === HandlePosition.UPPER) {
|
|
@@ -409,7 +404,7 @@ const Slider = props => {
|
|
|
409
404
|
});
|
|
410
405
|
// If we're set to two handles, negotiate which drag handle is closest to
|
|
411
406
|
// the users' interaction.
|
|
412
|
-
if (
|
|
407
|
+
if (twoHandles && activeHandle) {
|
|
413
408
|
setValueLeftForHandle(activeHandle, {
|
|
414
409
|
value: nearestStepValue(value),
|
|
415
410
|
left
|
|
@@ -467,7 +462,7 @@ const Slider = props => {
|
|
|
467
462
|
if (evt.shiftKey) {
|
|
468
463
|
delta *= stepMultiplier;
|
|
469
464
|
}
|
|
470
|
-
if (
|
|
465
|
+
if (twoHandles && state.activeHandle) {
|
|
471
466
|
const currentValue = state.activeHandle === HandlePosition.LOWER ? state.value : state.valueUpper;
|
|
472
467
|
const {
|
|
473
468
|
value,
|
|
@@ -521,7 +516,7 @@ const Slider = props => {
|
|
|
521
516
|
// Avoid calling calcValue for invalid numbers, but still update the state.
|
|
522
517
|
const activeHandle = evt.target.dataset.handlePosition ?? HandlePosition.LOWER;
|
|
523
518
|
const targetValue = Number.parseFloat(evt.target.value);
|
|
524
|
-
if (
|
|
519
|
+
if (twoHandles) {
|
|
525
520
|
if (isNaN(targetValue)) {
|
|
526
521
|
setValueForHandle(activeHandle, evt.target.value);
|
|
527
522
|
} else if (isValidValueForPosition({
|
|
@@ -937,13 +932,7 @@ const Slider = props => {
|
|
|
937
932
|
unstable_ariaLabelInputUpper: ariaLabelInputUpper,
|
|
938
933
|
className,
|
|
939
934
|
hideTextInput = false,
|
|
940
|
-
id
|
|
941
|
-
// TODO:
|
|
942
|
-
// 1. Why isn't `inputId` just set to this value instead of an empty
|
|
943
|
-
// string?
|
|
944
|
-
// 2. Why this value instead of something else, like
|
|
945
|
-
// `crypto.randomUUID()` or `useId()`?
|
|
946
|
-
`__carbon-slider_${Math.random().toString(36).substr(2)}`,
|
|
935
|
+
id: idProp,
|
|
947
936
|
min,
|
|
948
937
|
minLabel,
|
|
949
938
|
max,
|
|
@@ -952,9 +941,6 @@ const Slider = props => {
|
|
|
952
941
|
labelText,
|
|
953
942
|
hideLabel,
|
|
954
943
|
step = 1,
|
|
955
|
-
// TODO: Other properties are deleted below. Why isn't this one?
|
|
956
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
957
|
-
stepMultiplier: _stepMultiplier,
|
|
958
944
|
inputType = 'number',
|
|
959
945
|
invalidText,
|
|
960
946
|
required,
|
|
@@ -968,6 +954,7 @@ const Slider = props => {
|
|
|
968
954
|
translateWithId: t = defaultTranslateWithId,
|
|
969
955
|
...other
|
|
970
956
|
} = props;
|
|
957
|
+
const id = idProp ?? generatedId;
|
|
971
958
|
const {
|
|
972
959
|
value,
|
|
973
960
|
valueUpper,
|
|
@@ -991,226 +978,220 @@ const Slider = props => {
|
|
|
991
978
|
invalid: !isValidUpper,
|
|
992
979
|
warn
|
|
993
980
|
});
|
|
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
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
className: cx(`${prefix}--slider__status-msg`, `${prefix}--form-requirement`)
|
|
1209
|
-
}, t(translationIds['carbon.slider.auto-correct-announcement'], {
|
|
1210
|
-
correctedValue
|
|
1211
|
-
})));
|
|
1212
|
-
});
|
|
1213
|
-
})();
|
|
981
|
+
delete other.invalid;
|
|
982
|
+
delete other.onRelease;
|
|
983
|
+
delete other.stepMultiplier;
|
|
984
|
+
delete other.unstable_valueUpper;
|
|
985
|
+
const showWarning = normalizedProps.warn || correctedPosition === HandlePosition.LOWER && isValid;
|
|
986
|
+
const showWarningUpper = normalizedUpperProps.warn || correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
987
|
+
const labelId = `${id}-label`;
|
|
988
|
+
const labelClasses = cx(`${prefix}--label`, {
|
|
989
|
+
[`${prefix}--visually-hidden`]: hideLabel,
|
|
990
|
+
[`${prefix}--label--disabled`]: disabled
|
|
991
|
+
});
|
|
992
|
+
const containerClasses = cx(`${prefix}--slider-container`, {
|
|
993
|
+
[`${prefix}--slider-container--two-handles`]: twoHandles,
|
|
994
|
+
[`${prefix}--slider-container--disabled`]: disabled,
|
|
995
|
+
[`${prefix}--slider-container--readonly`]: readOnly,
|
|
996
|
+
[`${prefix}--slider-container--rtl`]: isRtl
|
|
997
|
+
});
|
|
998
|
+
const sliderClasses = cx(`${prefix}--slider`, {
|
|
999
|
+
[`${prefix}--slider--disabled`]: disabled,
|
|
1000
|
+
[`${prefix}--slider--readonly`]: readOnly
|
|
1001
|
+
});
|
|
1002
|
+
const fixedInputClasses = [`${prefix}--text-input`, `${prefix}--slider-text-input`];
|
|
1003
|
+
const conditionalInputClasses = {
|
|
1004
|
+
[`${prefix}--text-input--light`]: light
|
|
1005
|
+
};
|
|
1006
|
+
const lowerInputClasses = cx([...fixedInputClasses, `${prefix}--slider-text-input--lower`, conditionalInputClasses, {
|
|
1007
|
+
[`${prefix}--text-input--invalid`]: normalizedProps.invalid,
|
|
1008
|
+
[`${prefix}--slider-text-input--warn`]: showWarning
|
|
1009
|
+
}]);
|
|
1010
|
+
const upperInputClasses = cx([...fixedInputClasses, `${prefix}--slider-text-input--upper`, conditionalInputClasses, {
|
|
1011
|
+
[`${prefix}--text-input--invalid`]: twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid,
|
|
1012
|
+
[`${prefix}--slider-text-input--warn`]: showWarningUpper
|
|
1013
|
+
}]);
|
|
1014
|
+
const lowerInputWrapperClasses = cx([`${prefix}--text-input-wrapper`, `${prefix}--slider-text-input-wrapper`, `${prefix}--slider-text-input-wrapper--lower`, {
|
|
1015
|
+
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
|
|
1016
|
+
[`${prefix}--slider-text-input-wrapper--hidden`]: hideTextInput
|
|
1017
|
+
}]);
|
|
1018
|
+
const upperInputWrapperClasses = cx([`${prefix}--text-input-wrapper`, `${prefix}--slider-text-input-wrapper`, `${prefix}--slider-text-input-wrapper--upper`, {
|
|
1019
|
+
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
|
|
1020
|
+
[`${prefix}--slider-text-input-wrapper--hidden`]: hideTextInput
|
|
1021
|
+
}]);
|
|
1022
|
+
const lowerThumbClasses = cx(`${prefix}--slider__thumb`, {
|
|
1023
|
+
[`${prefix}--slider__thumb--lower`]: twoHandles
|
|
1024
|
+
});
|
|
1025
|
+
const upperThumbClasses = cx(`${prefix}--slider__thumb`, {
|
|
1026
|
+
[`${prefix}--slider__thumb--upper`]: twoHandles
|
|
1027
|
+
});
|
|
1028
|
+
const lowerThumbWrapperClasses = cx([`${prefix}--icon-tooltip`, `${prefix}--slider__thumb-wrapper`, {
|
|
1029
|
+
[`${prefix}--slider__thumb-wrapper--lower`]: twoHandles
|
|
1030
|
+
}]);
|
|
1031
|
+
const upperThumbWrapperClasses = cx([`${prefix}--icon-tooltip`, `${prefix}--slider__thumb-wrapper`, {
|
|
1032
|
+
[`${prefix}--slider__thumb-wrapper--upper`]: twoHandles
|
|
1033
|
+
}]);
|
|
1034
|
+
const lowerThumbWrapperProps = {
|
|
1035
|
+
style: {
|
|
1036
|
+
insetInlineStart: `${state.left}%`
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
const upperThumbWrapperProps = {
|
|
1040
|
+
style: {
|
|
1041
|
+
insetInlineStart: `${state.leftUpper}%`
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1045
|
+
className: cx(`${prefix}--form-item`, className)
|
|
1046
|
+
}, /*#__PURE__*/React.createElement(Text.Text, {
|
|
1047
|
+
as: "label",
|
|
1048
|
+
htmlFor: twoHandles ? undefined : id,
|
|
1049
|
+
className: labelClasses,
|
|
1050
|
+
id: labelId
|
|
1051
|
+
}, labelText), /*#__PURE__*/React.createElement("div", {
|
|
1052
|
+
className: containerClasses
|
|
1053
|
+
}, twoHandles ? /*#__PURE__*/React.createElement("div", {
|
|
1054
|
+
className: lowerInputWrapperClasses
|
|
1055
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1056
|
+
type: hideTextInput ? 'hidden' : inputType,
|
|
1057
|
+
id: `${id}-lower-input-for-slider`,
|
|
1058
|
+
name: name,
|
|
1059
|
+
className: lowerInputClasses,
|
|
1060
|
+
value: value,
|
|
1061
|
+
"aria-label": ariaLabelInput,
|
|
1062
|
+
disabled: disabled,
|
|
1063
|
+
required: required,
|
|
1064
|
+
min: min,
|
|
1065
|
+
max: max,
|
|
1066
|
+
step: step,
|
|
1067
|
+
onChange: onChangeInput,
|
|
1068
|
+
onBlur: onBlurInput,
|
|
1069
|
+
onKeyUp: props.onInputKeyUp,
|
|
1070
|
+
onKeyDown: onInputKeyDown,
|
|
1071
|
+
"data-invalid": normalizedProps.invalid ? true : null,
|
|
1072
|
+
"data-handle-position": HandlePosition.LOWER,
|
|
1073
|
+
"aria-invalid": normalizedProps.invalid ? true : undefined,
|
|
1074
|
+
readOnly: readOnly
|
|
1075
|
+
}), normalizedProps.invalid && /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
1076
|
+
className: `${prefix}--slider__invalid-icon`
|
|
1077
|
+
}), showWarning && /*#__PURE__*/React.createElement(iconsReact.WarningAltFilled, {
|
|
1078
|
+
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
1079
|
+
})) : null, /*#__PURE__*/React.createElement(Text.Text, {
|
|
1080
|
+
className: `${prefix}--slider__range-label`
|
|
1081
|
+
}, formatLabel(min, minLabel)), /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({
|
|
1082
|
+
className: sliderClasses,
|
|
1083
|
+
ref: node => {
|
|
1084
|
+
elementRef.current = node;
|
|
1085
|
+
},
|
|
1086
|
+
onMouseDown: onDragStart,
|
|
1087
|
+
onTouchStart: onDragStart,
|
|
1088
|
+
onKeyDown: onKeyDown,
|
|
1089
|
+
role: "presentation",
|
|
1090
|
+
tabIndex: -1,
|
|
1091
|
+
"data-invalid": (twoHandles ? normalizedProps.invalid || normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null
|
|
1092
|
+
}, other), /*#__PURE__*/React.createElement(ThumbWrapper, _rollupPluginBabelHelpers.extends({
|
|
1093
|
+
hasTooltip: hideTextInput,
|
|
1094
|
+
className: lowerThumbWrapperClasses,
|
|
1095
|
+
label: formatLabel(value, undefined),
|
|
1096
|
+
align: "top"
|
|
1097
|
+
}, lowerThumbWrapperProps), /*#__PURE__*/React.createElement("div", {
|
|
1098
|
+
className: lowerThumbClasses,
|
|
1099
|
+
role: "slider",
|
|
1100
|
+
id: twoHandles ? undefined : id,
|
|
1101
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1102
|
+
"aria-valuetext": formatLabel(value, undefined),
|
|
1103
|
+
"aria-valuemax": twoHandles ? valueUpper : max,
|
|
1104
|
+
"aria-valuemin": min,
|
|
1105
|
+
"aria-valuenow": value,
|
|
1106
|
+
"aria-labelledby": twoHandles ? undefined : labelId,
|
|
1107
|
+
"aria-label": twoHandles ? ariaLabelInput : undefined,
|
|
1108
|
+
ref: thumbRef,
|
|
1109
|
+
onFocus: () => setState({
|
|
1110
|
+
activeHandle: HandlePosition.LOWER
|
|
1111
|
+
})
|
|
1112
|
+
}, twoHandles && !isRtl ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SliderHandles.LowerHandle, {
|
|
1113
|
+
"aria-label": ariaLabelInput
|
|
1114
|
+
}), /*#__PURE__*/React.createElement(SliderHandles.LowerHandleFocus, {
|
|
1115
|
+
"aria-label": ariaLabelInput
|
|
1116
|
+
})) : twoHandles && isRtl ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SliderHandles.UpperHandle, {
|
|
1117
|
+
"aria-label": ariaLabelInputUpper
|
|
1118
|
+
}), /*#__PURE__*/React.createElement(SliderHandles.UpperHandleFocus, {
|
|
1119
|
+
"aria-label": ariaLabelInputUpper
|
|
1120
|
+
})) : undefined)), hasUpperValue(valueUpper) ? /*#__PURE__*/React.createElement(ThumbWrapper, _rollupPluginBabelHelpers.extends({
|
|
1121
|
+
hasTooltip: hideTextInput,
|
|
1122
|
+
className: upperThumbWrapperClasses,
|
|
1123
|
+
label: formatLabel(valueUpper, undefined),
|
|
1124
|
+
align: "top"
|
|
1125
|
+
}, upperThumbWrapperProps), /*#__PURE__*/React.createElement("div", {
|
|
1126
|
+
className: upperThumbClasses,
|
|
1127
|
+
role: "slider",
|
|
1128
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1129
|
+
"aria-valuemax": max,
|
|
1130
|
+
"aria-valuemin": value,
|
|
1131
|
+
"aria-valuenow": valueUpper,
|
|
1132
|
+
"aria-label": ariaLabelInputUpper,
|
|
1133
|
+
ref: thumbRefUpper,
|
|
1134
|
+
onFocus: () => setState({
|
|
1135
|
+
activeHandle: HandlePosition.UPPER
|
|
1136
|
+
})
|
|
1137
|
+
}, !isRtl ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SliderHandles.UpperHandle, {
|
|
1138
|
+
"aria-label": ariaLabelInputUpper
|
|
1139
|
+
}), /*#__PURE__*/React.createElement(SliderHandles.UpperHandleFocus, {
|
|
1140
|
+
"aria-label": ariaLabelInputUpper
|
|
1141
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SliderHandles.LowerHandle, {
|
|
1142
|
+
"aria-label": ariaLabelInput
|
|
1143
|
+
}), /*#__PURE__*/React.createElement(SliderHandles.LowerHandleFocus, {
|
|
1144
|
+
"aria-label": ariaLabelInput
|
|
1145
|
+
})))) : null, /*#__PURE__*/React.createElement("div", {
|
|
1146
|
+
className: `${prefix}--slider__track`,
|
|
1147
|
+
ref: node => {
|
|
1148
|
+
trackRef.current = node;
|
|
1149
|
+
}
|
|
1150
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
1151
|
+
className: `${prefix}--slider__filled-track`,
|
|
1152
|
+
ref: filledTrackRef
|
|
1153
|
+
})), /*#__PURE__*/React.createElement(Text.Text, {
|
|
1154
|
+
className: `${prefix}--slider__range-label`
|
|
1155
|
+
}, formatLabel(max, maxLabel)), /*#__PURE__*/React.createElement("div", {
|
|
1156
|
+
className: upperInputWrapperClasses
|
|
1157
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
1158
|
+
type: hideTextInput ? 'hidden' : inputType,
|
|
1159
|
+
id: `${id}-${twoHandles ? 'upper-' : ''}input-for-slider`,
|
|
1160
|
+
name: twoHandles ? nameUpper : name,
|
|
1161
|
+
className: upperInputClasses,
|
|
1162
|
+
value: twoHandles ? valueUpper : value,
|
|
1163
|
+
"aria-labelledby": !ariaLabelInput && !twoHandles ? labelId : undefined,
|
|
1164
|
+
"aria-label": twoHandles ? ariaLabelInputUpper : ariaLabelInput ? ariaLabelInput : undefined,
|
|
1165
|
+
disabled: disabled,
|
|
1166
|
+
required: required,
|
|
1167
|
+
min: min,
|
|
1168
|
+
max: max,
|
|
1169
|
+
step: step,
|
|
1170
|
+
onChange: onChangeInput,
|
|
1171
|
+
onBlur: onBlurInput,
|
|
1172
|
+
onKeyDown: onInputKeyDown,
|
|
1173
|
+
onKeyUp: props.onInputKeyUp,
|
|
1174
|
+
"data-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
|
|
1175
|
+
"data-handle-position": twoHandles ? HandlePosition.UPPER : null,
|
|
1176
|
+
"aria-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : undefined,
|
|
1177
|
+
readOnly: readOnly
|
|
1178
|
+
}), (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) && /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
1179
|
+
className: `${prefix}--slider__invalid-icon`
|
|
1180
|
+
}), showWarningUpper && /*#__PURE__*/React.createElement(iconsReact.WarningAltFilled, {
|
|
1181
|
+
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
1182
|
+
}))), (normalizedProps.invalid || normalizedUpperProps.invalid) && /*#__PURE__*/React.createElement(Text.Text, {
|
|
1183
|
+
as: "div",
|
|
1184
|
+
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--slider__validation-msg--invalid`, `${prefix}--form-requirement`)
|
|
1185
|
+
}, invalidText), (normalizedProps.warn || normalizedUpperProps.warn) && /*#__PURE__*/React.createElement(Text.Text, {
|
|
1186
|
+
as: "div",
|
|
1187
|
+
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--form-requirement`)
|
|
1188
|
+
}, warnText), correctedValue && /*#__PURE__*/React.createElement(Text.Text, {
|
|
1189
|
+
as: "div",
|
|
1190
|
+
role: "alert",
|
|
1191
|
+
className: cx(`${prefix}--slider__status-msg`, `${prefix}--form-requirement`)
|
|
1192
|
+
}, t(translationIds['carbon.slider.auto-correct-announcement'], {
|
|
1193
|
+
correctedValue
|
|
1194
|
+
})));
|
|
1214
1195
|
};
|
|
1215
1196
|
Slider.propTypes = {
|
|
1216
1197
|
/**
|