@carbon/react 1.85.0-rc.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 +942 -872
- 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/Menu/Menu.js +7 -2
- package/es/components/Menu/MenuItem.js +13 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/es/components/MultiSelect/filter.d.ts +10 -0
- package/es/components/MultiSelect/filter.js +21 -0
- 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/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 +116 -9
- 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/Menu/Menu.js +7 -2
- package/lib/components/Menu/MenuItem.js +13 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/lib/components/MultiSelect/filter.d.ts +10 -0
- package/lib/components/MultiSelect/filter.js +25 -0
- 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/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 +115 -8
- package/package.json +6 -6
- package/es/components/ComboBox/tools/filter.js +0 -18
- package/lib/components/ComboBox/tools/filter.js +0 -22
|
@@ -34,7 +34,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
34
34
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
35
35
|
|
|
36
36
|
const ThumbWrapper = ({
|
|
37
|
-
hasTooltip
|
|
37
|
+
hasTooltip,
|
|
38
38
|
className,
|
|
39
39
|
style,
|
|
40
40
|
children,
|
|
@@ -60,24 +60,6 @@ const ThumbWrapper = ({
|
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
ThumbWrapper.propTypes = {
|
|
64
|
-
/**
|
|
65
|
-
* The thumb node itself.
|
|
66
|
-
*/
|
|
67
|
-
children: PropTypes__default["default"].node,
|
|
68
|
-
/**
|
|
69
|
-
* CSS wrapper class names.
|
|
70
|
-
*/
|
|
71
|
-
className: PropTypes__default["default"].string,
|
|
72
|
-
/**
|
|
73
|
-
* Should the thumb show a tooltip with the current value?
|
|
74
|
-
*/
|
|
75
|
-
hasTooltip: PropTypes__default["default"].bool.isRequired,
|
|
76
|
-
/**
|
|
77
|
-
* Percentage offset for the select thumb value.
|
|
78
|
-
*/
|
|
79
|
-
style: PropTypes__default["default"].object
|
|
80
|
-
};
|
|
81
63
|
const translationIds = {
|
|
82
64
|
autoCorrectAnnouncement: 'carbon.slider.auto-correct-announcement'
|
|
83
65
|
};
|
|
@@ -96,27 +78,18 @@ function translateWithId(translationId, translationState) {
|
|
|
96
78
|
return '';
|
|
97
79
|
}
|
|
98
80
|
const defaultFormatLabel = (value, label) => {
|
|
99
|
-
return
|
|
81
|
+
return `${value}${label ?? ''}`;
|
|
100
82
|
};
|
|
101
83
|
|
|
84
|
+
// TODO: Assuming a 16ms throttle corresponds to 60 FPS, should it be halved,
|
|
85
|
+
// since many systems can handle 120 FPS? If it doesn't correspond to 60 FPS,
|
|
86
|
+
// what does it correspond to?
|
|
102
87
|
/**
|
|
103
|
-
* Minimum time between processed "drag" events.
|
|
104
|
-
*/
|
|
105
|
-
const EVENT_THROTTLE = 16; // ms
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Event types that trigger "drags".
|
|
88
|
+
* Minimum time between processed "drag" events in milliseconds.
|
|
109
89
|
*/
|
|
90
|
+
const EVENT_THROTTLE = 16;
|
|
110
91
|
const DRAG_EVENT_TYPES = new Set(['mousemove', 'touchmove']);
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Event types that trigger a "drag" to stop.
|
|
114
|
-
*/
|
|
115
92
|
const DRAG_STOP_EVENT_TYPES = new Set(['mouseup', 'touchend', 'touchcancel']);
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Distinguish two handles by lower and upper positions.
|
|
119
|
-
*/
|
|
120
93
|
var HandlePosition = /*#__PURE__*/function (HandlePosition) {
|
|
121
94
|
HandlePosition["LOWER"] = "lower";
|
|
122
95
|
HandlePosition["UPPER"] = "upper";
|
|
@@ -133,7 +106,7 @@ class Slider extends React.PureComponent {
|
|
|
133
106
|
needsOnRelease: false,
|
|
134
107
|
isValid: true,
|
|
135
108
|
isValidUpper: true,
|
|
136
|
-
activeHandle:
|
|
109
|
+
activeHandle: undefined,
|
|
137
110
|
correctedValue: null,
|
|
138
111
|
correctedPosition: null,
|
|
139
112
|
isRtl: false
|
|
@@ -144,12 +117,15 @@ class Slider extends React.PureComponent {
|
|
|
144
117
|
_rollupPluginBabelHelpers.defineProperty(this, "element", null);
|
|
145
118
|
_rollupPluginBabelHelpers.defineProperty(this, "inputId", '');
|
|
146
119
|
_rollupPluginBabelHelpers.defineProperty(this, "track", void 0);
|
|
120
|
+
_rollupPluginBabelHelpers.defineProperty(this, "handleDrag", event => {
|
|
121
|
+
if (event instanceof globalThis.MouseEvent || event instanceof globalThis.TouchEvent) {
|
|
122
|
+
this.onDrag(event);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
147
125
|
/**
|
|
148
126
|
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
149
127
|
* started on somewhere other than the thumb without a corresponding "move"
|
|
150
128
|
* event.
|
|
151
|
-
*
|
|
152
|
-
* @param {Event} evt The event.
|
|
153
129
|
*/
|
|
154
130
|
_rollupPluginBabelHelpers.defineProperty(this, "onDragStart", evt => {
|
|
155
131
|
// Do nothing if component is disabled
|
|
@@ -163,23 +139,23 @@ class Slider extends React.PureComponent {
|
|
|
163
139
|
// @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#notes
|
|
164
140
|
evt.preventDefault();
|
|
165
141
|
|
|
166
|
-
//
|
|
142
|
+
// Add drag stop handlers
|
|
167
143
|
DRAG_STOP_EVENT_TYPES.forEach(element => {
|
|
168
144
|
this.element?.ownerDocument.addEventListener(element, this.onDragStop);
|
|
169
145
|
});
|
|
170
146
|
|
|
171
|
-
//
|
|
147
|
+
// Add drag handlers
|
|
172
148
|
DRAG_EVENT_TYPES.forEach(element => {
|
|
173
|
-
this.element?.ownerDocument.addEventListener(element, this.
|
|
149
|
+
this.element?.ownerDocument.addEventListener(element, this.handleDrag);
|
|
174
150
|
});
|
|
175
|
-
const clientX = this.getClientXFromEvent(evt);
|
|
151
|
+
const clientX = this.getClientXFromEvent(evt.nativeEvent);
|
|
176
152
|
let activeHandle;
|
|
177
153
|
if (this.hasTwoHandles()) {
|
|
178
154
|
if (evt.target == this.thumbRef.current) {
|
|
179
155
|
activeHandle = HandlePosition.LOWER;
|
|
180
156
|
} else if (evt.target == this.thumbRefUpper.current) {
|
|
181
157
|
activeHandle = HandlePosition.UPPER;
|
|
182
|
-
} else {
|
|
158
|
+
} else if (clientX) {
|
|
183
159
|
const distanceToLower = this.calcDistanceToHandle(HandlePosition.LOWER, clientX);
|
|
184
160
|
const distanceToUpper = this.calcDistanceToHandle(HandlePosition.UPPER, clientX);
|
|
185
161
|
if (distanceToLower <= distanceToUpper) {
|
|
@@ -209,10 +185,10 @@ class Slider extends React.PureComponent {
|
|
|
209
185
|
|
|
210
186
|
// Perform first recalculation since we probably didn't click exactly in the
|
|
211
187
|
// middle of the thumb.
|
|
212
|
-
this.onDrag(evt, activeHandle);
|
|
188
|
+
this.onDrag(evt.nativeEvent, activeHandle);
|
|
213
189
|
});
|
|
214
190
|
/**
|
|
215
|
-
*
|
|
191
|
+
* Removes "drag" and "drag stop" event handlers and calls sets the flag
|
|
216
192
|
* indicating that the `onRelease` callback should be called.
|
|
217
193
|
*/
|
|
218
194
|
_rollupPluginBabelHelpers.defineProperty(this, "onDragStop", () => {
|
|
@@ -228,7 +204,7 @@ class Slider extends React.PureComponent {
|
|
|
228
204
|
|
|
229
205
|
// Remove drag handlers
|
|
230
206
|
DRAG_EVENT_TYPES.forEach(element => {
|
|
231
|
-
this.element?.ownerDocument.removeEventListener(element, this.
|
|
207
|
+
this.element?.ownerDocument.removeEventListener(element, this.handleDrag);
|
|
232
208
|
});
|
|
233
209
|
|
|
234
210
|
// Set needsOnRelease flag so event fires on next update.
|
|
@@ -242,12 +218,11 @@ class Slider extends React.PureComponent {
|
|
|
242
218
|
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
243
219
|
* accordingly.
|
|
244
220
|
*
|
|
245
|
-
* @param
|
|
246
|
-
* @param activeHandle
|
|
247
|
-
*
|
|
248
|
-
* which is to be used before state is used.
|
|
221
|
+
* @param evt The event.
|
|
222
|
+
* @param activeHandle The first drag event call, we may have an explicit
|
|
223
|
+
* activeHandle value, which is to be used before state is used.
|
|
249
224
|
*/
|
|
250
|
-
_rollupPluginBabelHelpers.defineProperty(this, "_onDrag", (evt, activeHandle
|
|
225
|
+
_rollupPluginBabelHelpers.defineProperty(this, "_onDrag", (evt, activeHandle) => {
|
|
251
226
|
activeHandle = activeHandle ?? this.state.activeHandle;
|
|
252
227
|
// Do nothing if component is disabled, or we have no event.
|
|
253
228
|
if (this.props.disabled || this.props.readOnly || !evt) {
|
|
@@ -291,8 +266,6 @@ class Slider extends React.PureComponent {
|
|
|
291
266
|
/**
|
|
292
267
|
* Handles a `keydown` event by recalculating the value/thumb and setting
|
|
293
268
|
* state accordingly.
|
|
294
|
-
*
|
|
295
|
-
* @param {Event} evt The event.
|
|
296
269
|
*/
|
|
297
270
|
_rollupPluginBabelHelpers.defineProperty(this, "onKeyDown", evt => {
|
|
298
271
|
// Do nothing if component is disabled, or we don't have a valid event
|
|
@@ -355,8 +328,6 @@ class Slider extends React.PureComponent {
|
|
|
355
328
|
* Provides the two-way binding for the input field of the Slider. It also
|
|
356
329
|
* Handles a change to the input field by recalculating the value/thumb and
|
|
357
330
|
* setting state accordingly.
|
|
358
|
-
*
|
|
359
|
-
* @param {Event} evt The event.
|
|
360
331
|
*/
|
|
361
332
|
_rollupPluginBabelHelpers.defineProperty(this, "onChange", evt => {
|
|
362
333
|
// Do nothing if component is disabled
|
|
@@ -406,8 +377,6 @@ class Slider extends React.PureComponent {
|
|
|
406
377
|
/**
|
|
407
378
|
* Checks for validity of input value after clicking out of the input. It also
|
|
408
379
|
* Handles state change to isValid state.
|
|
409
|
-
*
|
|
410
|
-
* @param {Event} evt The event.
|
|
411
380
|
*/
|
|
412
381
|
_rollupPluginBabelHelpers.defineProperty(this, "onBlur", evt => {
|
|
413
382
|
// Do nothing if we have no valid event, target, or value
|
|
@@ -420,12 +389,12 @@ class Slider extends React.PureComponent {
|
|
|
420
389
|
this.processNewInputValue(evt.target);
|
|
421
390
|
this.props.onBlur?.({
|
|
422
391
|
value: targetValue,
|
|
423
|
-
handlePosition: evt.target
|
|
392
|
+
handlePosition: evt.target.dataset.handlePosition
|
|
424
393
|
});
|
|
425
394
|
});
|
|
426
395
|
_rollupPluginBabelHelpers.defineProperty(this, "onInputKeyDown", evt => {
|
|
427
396
|
// Do nothing if component is disabled, or we don't have a valid event.
|
|
428
|
-
if (this.props.disabled || this.props.readOnly) {
|
|
397
|
+
if (this.props.disabled || this.props.readOnly || !(evt.target instanceof HTMLInputElement)) {
|
|
429
398
|
return;
|
|
430
399
|
}
|
|
431
400
|
|
|
@@ -448,7 +417,7 @@ class Slider extends React.PureComponent {
|
|
|
448
417
|
// When there are two handles, we'll also have the data-handle-position
|
|
449
418
|
// attribute to consider the other value before settling on the validity to
|
|
450
419
|
// set.
|
|
451
|
-
const handlePosition = input
|
|
420
|
+
const handlePosition = input.dataset.handlePosition;
|
|
452
421
|
if (handlePosition === HandlePosition.LOWER) {
|
|
453
422
|
this.setState({
|
|
454
423
|
isValid: validity
|
|
@@ -492,7 +461,7 @@ class Slider extends React.PureComponent {
|
|
|
492
461
|
});
|
|
493
462
|
if (handlePosition) {
|
|
494
463
|
this.setValueLeftForHandle(handlePosition, {
|
|
495
|
-
value,
|
|
464
|
+
value: this.nearestStepValue(value),
|
|
496
465
|
left
|
|
497
466
|
});
|
|
498
467
|
} else {
|
|
@@ -521,7 +490,7 @@ class Slider extends React.PureComponent {
|
|
|
521
490
|
if (clientX) {
|
|
522
491
|
const leftOffset = this.state.isRtl ? (boundingRect?.right ?? 0) - clientX : clientX - (boundingRect?.left ?? 0);
|
|
523
492
|
return leftOffset / width;
|
|
524
|
-
} else if (value !== null && value !== undefined && range) {
|
|
493
|
+
} else if (value !== null && typeof value !== 'undefined' && range) {
|
|
525
494
|
// Prevent NaN calculation if the range is 0.
|
|
526
495
|
return range === 0 ? 0 : (value - this.props.min) / range;
|
|
527
496
|
}
|
|
@@ -729,15 +698,15 @@ class Slider extends React.PureComponent {
|
|
|
729
698
|
_rollupPluginBabelHelpers.defineProperty(this, "getHandleBoundingRect", handle => {
|
|
730
699
|
let boundingRect;
|
|
731
700
|
if (handle === HandlePosition.LOWER) {
|
|
732
|
-
boundingRect = this
|
|
701
|
+
boundingRect = this.thumbRef.current?.getBoundingClientRect();
|
|
733
702
|
} else {
|
|
734
|
-
boundingRect = this
|
|
703
|
+
boundingRect = this.thumbRefUpper.current?.getBoundingClientRect();
|
|
735
704
|
}
|
|
736
705
|
return boundingRect ?? new DOMRect();
|
|
737
706
|
});
|
|
738
|
-
this.thumbRef = /*#__PURE__*/
|
|
739
|
-
this.thumbRefUpper = /*#__PURE__*/
|
|
740
|
-
this.filledTrackRef = /*#__PURE__*/
|
|
707
|
+
this.thumbRef = /*#__PURE__*/React.createRef();
|
|
708
|
+
this.thumbRefUpper = /*#__PURE__*/React.createRef();
|
|
709
|
+
this.filledTrackRef = /*#__PURE__*/React.createRef();
|
|
741
710
|
}
|
|
742
711
|
|
|
743
712
|
/**
|
|
@@ -839,7 +808,7 @@ class Slider extends React.PureComponent {
|
|
|
839
808
|
value: this.props.value,
|
|
840
809
|
useRawValue: true
|
|
841
810
|
}));
|
|
842
|
-
if (this.props.unstable_valueUpper !== undefined) {
|
|
811
|
+
if (typeof this.props.unstable_valueUpper !== 'undefined') {
|
|
843
812
|
const {
|
|
844
813
|
value: valueUpper,
|
|
845
814
|
left: leftUpper
|
|
@@ -880,7 +849,7 @@ class Slider extends React.PureComponent {
|
|
|
880
849
|
return clientX;
|
|
881
850
|
}
|
|
882
851
|
hasTwoHandles() {
|
|
883
|
-
return this.state.valueUpper !== undefined;
|
|
852
|
+
return typeof this.state.valueUpper !== 'undefined';
|
|
884
853
|
}
|
|
885
854
|
|
|
886
855
|
// syncs invalid state and prop
|
|
@@ -889,49 +858,17 @@ class Slider extends React.PureComponent {
|
|
|
889
858
|
isValid,
|
|
890
859
|
isValidUpper
|
|
891
860
|
} = state;
|
|
892
|
-
|
|
861
|
+
const derivedState = {};
|
|
893
862
|
|
|
894
863
|
// Will override state in favor of invalid prop
|
|
895
864
|
if (props.invalid === true) {
|
|
896
|
-
if (isValid === true)
|
|
897
|
-
|
|
898
|
-
...derivedState,
|
|
899
|
-
isValid: false
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
if (isValid === true) {
|
|
903
|
-
derivedState = {
|
|
904
|
-
...derivedState,
|
|
905
|
-
isValid: false
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
if (isValidUpper === true) {
|
|
909
|
-
derivedState = {
|
|
910
|
-
...derivedState,
|
|
911
|
-
isValidUpper: false
|
|
912
|
-
};
|
|
913
|
-
}
|
|
865
|
+
if (isValid === true) derivedState.isValid = false;
|
|
866
|
+
if (isValidUpper === true) derivedState.isValidUpper = false;
|
|
914
867
|
} else if (props.invalid === false) {
|
|
915
|
-
if (isValid === false)
|
|
916
|
-
|
|
917
|
-
...derivedState,
|
|
918
|
-
isValid: true
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
if (isValid === false) {
|
|
922
|
-
derivedState = {
|
|
923
|
-
...derivedState,
|
|
924
|
-
isValid: true
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
if (isValidUpper === false) {
|
|
928
|
-
derivedState = {
|
|
929
|
-
...derivedState,
|
|
930
|
-
isValidUpper: true
|
|
931
|
-
};
|
|
932
|
-
}
|
|
868
|
+
if (isValid === false) derivedState.isValid = true;
|
|
869
|
+
if (isValidUpper === false) derivedState.isValidUpper = true;
|
|
933
870
|
}
|
|
934
|
-
return Object.
|
|
871
|
+
return Object.keys(derivedState).length ? derivedState : null;
|
|
935
872
|
}
|
|
936
873
|
render() {
|
|
937
874
|
var _Fragment, _Fragment2, _Fragment3, _Fragment4;
|
|
@@ -940,15 +877,22 @@ class Slider extends React.PureComponent {
|
|
|
940
877
|
unstable_ariaLabelInputUpper: ariaLabelInputUpper,
|
|
941
878
|
className,
|
|
942
879
|
hideTextInput = false,
|
|
943
|
-
id = this.inputId = this.inputId ||
|
|
880
|
+
id = this.inputId = this.inputId ||
|
|
881
|
+
// TODO:
|
|
882
|
+
// 1. Why isn't `inputId` just set to this value instead of an empty
|
|
883
|
+
// string?
|
|
884
|
+
// 2. Why this value instead of something else, like
|
|
885
|
+
// `crypto.randomUUID()` or `useId()`?
|
|
886
|
+
`__carbon-slider_${Math.random().toString(36).substr(2)}`,
|
|
944
887
|
min,
|
|
945
|
-
minLabel
|
|
888
|
+
minLabel,
|
|
946
889
|
max,
|
|
947
|
-
maxLabel
|
|
890
|
+
maxLabel,
|
|
948
891
|
formatLabel = defaultFormatLabel,
|
|
949
892
|
labelText,
|
|
950
893
|
hideLabel,
|
|
951
894
|
step = 1,
|
|
895
|
+
// TODO: Other properties are deleted below. Why isn't this one?
|
|
952
896
|
stepMultiplier: _stepMultiplier,
|
|
953
897
|
inputType = 'number',
|
|
954
898
|
invalidText,
|
|
@@ -976,8 +920,12 @@ class Slider extends React.PureComponent {
|
|
|
976
920
|
correctedPosition,
|
|
977
921
|
isRtl
|
|
978
922
|
} = this.state;
|
|
979
|
-
const showWarning = !readOnly && warn ||
|
|
980
|
-
|
|
923
|
+
const showWarning = !readOnly && warn ||
|
|
924
|
+
// TODO: https://github.com/carbon-design-system/carbon/issues/18991#issuecomment-2795709637
|
|
925
|
+
typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
|
|
926
|
+
const showWarningUpper = !readOnly && warn ||
|
|
927
|
+
// TODO: https://github.com/carbon-design-system/carbon/issues/18991#issuecomment-2795709637
|
|
928
|
+
typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
981
929
|
return /*#__PURE__*/React__default["default"].createElement(usePrefix.PrefixContext.Consumer, null, prefix => {
|
|
982
930
|
const labelId = `${id}-label`;
|
|
983
931
|
const labelClasses = cx__default["default"](`${prefix}--label`, {
|
|
@@ -1087,14 +1035,14 @@ class Slider extends React.PureComponent {
|
|
|
1087
1035
|
}, other), /*#__PURE__*/React__default["default"].createElement(ThumbWrapper, _rollupPluginBabelHelpers["extends"]({
|
|
1088
1036
|
hasTooltip: hideTextInput,
|
|
1089
1037
|
className: lowerThumbWrapperClasses,
|
|
1090
|
-
label:
|
|
1038
|
+
label: formatLabel(value, undefined),
|
|
1091
1039
|
align: "top"
|
|
1092
1040
|
}, lowerThumbWrapperProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1093
1041
|
className: lowerThumbClasses,
|
|
1094
1042
|
role: "slider",
|
|
1095
1043
|
id: twoHandles ? undefined : id,
|
|
1096
1044
|
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1097
|
-
"aria-valuetext":
|
|
1045
|
+
"aria-valuetext": formatLabel(value, undefined),
|
|
1098
1046
|
"aria-valuemax": twoHandles ? valueUpper : max,
|
|
1099
1047
|
"aria-valuemin": min,
|
|
1100
1048
|
"aria-valuenow": value,
|
|
@@ -1115,7 +1063,7 @@ class Slider extends React.PureComponent {
|
|
|
1115
1063
|
}))) : undefined)), twoHandles ? /*#__PURE__*/React__default["default"].createElement(ThumbWrapper, _rollupPluginBabelHelpers["extends"]({
|
|
1116
1064
|
hasTooltip: hideTextInput,
|
|
1117
1065
|
className: upperThumbWrapperClasses,
|
|
1118
|
-
label:
|
|
1066
|
+
label: formatLabel(valueUpper ?? 0, undefined),
|
|
1119
1067
|
align: "top"
|
|
1120
1068
|
}, upperThumbWrapperProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1121
1069
|
className: upperThumbClasses,
|
|
@@ -1190,7 +1138,9 @@ class Slider extends React.PureComponent {
|
|
|
1190
1138
|
});
|
|
1191
1139
|
}
|
|
1192
1140
|
}
|
|
1193
|
-
_rollupPluginBabelHelpers.defineProperty(Slider, "
|
|
1141
|
+
_rollupPluginBabelHelpers.defineProperty(Slider, "contextType", index.FeatureFlagContext);
|
|
1142
|
+
_rollupPluginBabelHelpers.defineProperty(Slider, "translationIds", Object.values(translationIds));
|
|
1143
|
+
Slider.propTypes = {
|
|
1194
1144
|
/**
|
|
1195
1145
|
* The `ariaLabel` for the `<input>`.
|
|
1196
1146
|
*/
|
|
@@ -1273,7 +1223,7 @@ _rollupPluginBabelHelpers.defineProperty(Slider, "propTypes", {
|
|
|
1273
1223
|
*/
|
|
1274
1224
|
onChange: PropTypes__default["default"].func,
|
|
1275
1225
|
/**
|
|
1276
|
-
* Provide an optional function to be called when a key is pressed in the number input
|
|
1226
|
+
* Provide an optional function to be called when a key is pressed in the number input.
|
|
1277
1227
|
*/
|
|
1278
1228
|
onInputKeyUp: PropTypes__default["default"].func,
|
|
1279
1229
|
/**
|
|
@@ -1328,8 +1278,6 @@ _rollupPluginBabelHelpers.defineProperty(Slider, "propTypes", {
|
|
|
1328
1278
|
* Provide the text that is displayed when the Slider is in a warn state
|
|
1329
1279
|
*/
|
|
1330
1280
|
warnText: PropTypes__default["default"].node
|
|
1331
|
-
}
|
|
1332
|
-
_rollupPluginBabelHelpers.defineProperty(Slider, "contextType", index.FeatureFlagContext);
|
|
1333
|
-
Slider.translationIds = Object.values(translationIds);
|
|
1281
|
+
};
|
|
1334
1282
|
|
|
1335
1283
|
exports["default"] = Slider;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { type RefObject } from 'react';
|
|
8
|
+
type UsePressableState = {
|
|
9
|
+
longPress: boolean;
|
|
10
|
+
};
|
|
11
|
+
type UsePressableOptions = {
|
|
12
|
+
onPress?: (state: UsePressableState) => void;
|
|
13
|
+
onPressIn?: () => void;
|
|
14
|
+
onPressOut?: (state: UsePressableState) => void;
|
|
15
|
+
onLongPress?: () => void;
|
|
16
|
+
delayLongPressMs?: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const usePressable: (ref: RefObject<HTMLElement | null>, { onPress, onPressIn, onPressOut, onLongPress, delayLongPressMs, }?: UsePressableOptions) => void;
|
|
19
|
+
export {};
|
|
@@ -11,26 +11,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var React = require('react');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {React.RefObject<HTMLElement | null>} ref
|
|
18
|
-
*
|
|
19
|
-
* @param {{
|
|
20
|
-
* onPress?(state: { longPress: boolean }): void,
|
|
21
|
-
* onPressIn?(): void,
|
|
22
|
-
* onPressOut?(): void,
|
|
23
|
-
* onLongPress?(): void,
|
|
24
|
-
* delayLongPressMs?: number,
|
|
25
|
-
* }} options
|
|
26
|
-
*/
|
|
27
|
-
function usePressable(ref, {
|
|
14
|
+
const usePressable = (ref, {
|
|
28
15
|
onPress,
|
|
29
16
|
onPressIn,
|
|
30
17
|
onPressOut,
|
|
31
18
|
onLongPress,
|
|
32
19
|
delayLongPressMs = 500
|
|
33
|
-
} = {}) {
|
|
20
|
+
} = {}) => {
|
|
34
21
|
const savedOnPress = React.useRef(onPress);
|
|
35
22
|
const savedOnPressIn = React.useRef(onPressIn);
|
|
36
23
|
const savedOnPressOut = React.useRef(onPressOut);
|
|
@@ -53,55 +40,54 @@ function usePressable(ref, {
|
|
|
53
40
|
savedOnLongPress.current = onLongPress;
|
|
54
41
|
}, [onLongPress]);
|
|
55
42
|
React.useEffect(() => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
} = ref;
|
|
43
|
+
const element = ref.current;
|
|
44
|
+
if (!element) return;
|
|
59
45
|
|
|
60
46
|
// Fired when a pointer becomes active buttons state.
|
|
61
|
-
|
|
47
|
+
const onPointerDown = event => {
|
|
62
48
|
setPendingLongPress(true);
|
|
63
49
|
savedOnPressIn.current?.();
|
|
64
50
|
event.preventDefault();
|
|
65
|
-
}
|
|
51
|
+
};
|
|
66
52
|
|
|
67
53
|
// Fired when a pointer is no longer active buttons state.
|
|
68
|
-
|
|
54
|
+
const onPointerUp = () => {
|
|
69
55
|
setPendingLongPress(false);
|
|
70
56
|
setLongPress(false);
|
|
71
57
|
savedOnPressOut.current?.(state.current);
|
|
72
|
-
}
|
|
58
|
+
};
|
|
73
59
|
|
|
74
60
|
// A browser fires this event if it concludes the pointer
|
|
75
61
|
// will no longer be able to generate events (for example
|
|
76
62
|
// the related device is deactivated).
|
|
77
|
-
|
|
63
|
+
const onPointerCancel = () => {
|
|
78
64
|
setPendingLongPress(false);
|
|
79
65
|
setLongPress(false);
|
|
80
|
-
savedOnPressOut.current?.();
|
|
66
|
+
savedOnPressOut.current?.(state.current);
|
|
81
67
|
state.current.longPress = false;
|
|
82
|
-
}
|
|
68
|
+
};
|
|
83
69
|
|
|
84
70
|
// Fired when a pointer is moved out of the hit test
|
|
85
71
|
// boundaries of an element. For pen devices, this event
|
|
86
72
|
// is fired when the stylus leaves the hover range
|
|
87
73
|
// detectable by the digitizer.
|
|
88
|
-
|
|
74
|
+
const onPointerLeave = () => {
|
|
89
75
|
setPendingLongPress(false);
|
|
90
76
|
setLongPress(false);
|
|
91
|
-
savedOnPressOut.current?.();
|
|
77
|
+
savedOnPressOut.current?.(state.current);
|
|
92
78
|
state.current.longPress = false;
|
|
93
|
-
}
|
|
94
|
-
|
|
79
|
+
};
|
|
80
|
+
const onClick = () => {
|
|
95
81
|
setLongPress(false);
|
|
96
82
|
setPendingLongPress(false);
|
|
97
83
|
savedOnPress.current?.(state.current);
|
|
98
84
|
state.current.longPress = false;
|
|
99
|
-
}
|
|
85
|
+
};
|
|
100
86
|
|
|
101
87
|
// Certain devices treat long press events as context menu triggers
|
|
102
|
-
|
|
88
|
+
const onContextMenu = event => {
|
|
103
89
|
event.preventDefault();
|
|
104
|
-
}
|
|
90
|
+
};
|
|
105
91
|
element.addEventListener('pointerdown', onPointerDown);
|
|
106
92
|
element.addEventListener('pointerup', onPointerUp);
|
|
107
93
|
element.addEventListener('pointercancel', onPointerCancel);
|
|
@@ -134,6 +120,6 @@ function usePressable(ref, {
|
|
|
134
120
|
return savedOnLongPress.current?.();
|
|
135
121
|
}
|
|
136
122
|
}, [longPress]);
|
|
137
|
-
}
|
|
123
|
+
};
|
|
138
124
|
|
|
139
125
|
exports.usePressable = usePressable;
|
|
@@ -4,7 +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 from 'react';
|
|
7
|
+
import React, { type JSX } from 'react';
|
|
8
8
|
import { Popover, PopoverAlignment } from '../Popover';
|
|
9
9
|
import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
|
|
10
10
|
interface TooltipBaseProps {
|
|
@@ -15,7 +15,7 @@ interface TooltipBaseProps {
|
|
|
15
15
|
/**
|
|
16
16
|
* Pass in the child to which the tooltip will be applied
|
|
17
17
|
*/
|
|
18
|
-
children?: React.ReactElement<
|
|
18
|
+
children?: React.ReactElement<JSX.IntrinsicElements[keyof JSX.IntrinsicElements]>;
|
|
19
19
|
/**
|
|
20
20
|
* Specify an optional className to be applied to the container node
|
|
21
21
|
*/
|
|
@@ -65,7 +65,7 @@ const Tooltip = /*#__PURE__*/React__default["default"].forwardRef(({
|
|
|
65
65
|
|
|
66
66
|
// An `aria-label` takes precedence over `aria-describedby`, but when it's
|
|
67
67
|
// needed and the user doesn't specify one, the fallback `id` is used.
|
|
68
|
-
const labelledBy = hasAriaLabel ?
|
|
68
|
+
const labelledBy = hasAriaLabel ? undefined : hasLabel ? ariaLabelledBy ?? id : undefined;
|
|
69
69
|
|
|
70
70
|
// If `aria-label` is present, use any provided `aria-describedby`.
|
|
71
71
|
// If not, fallback to child's `aria-describedby` or the tooltip `id` if needed.
|
|
@@ -185,7 +185,7 @@ const Tooltip = /*#__PURE__*/React__default["default"].forwardRef(({
|
|
|
185
185
|
open: open
|
|
186
186
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
187
187
|
className: `${prefix}--tooltip-trigger__wrapper`
|
|
188
|
-
}, child !== undefined ? /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
188
|
+
}, typeof child !== 'undefined' ? /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
189
189
|
...triggerProps,
|
|
190
190
|
...getChildEventHandlers(child.props)
|
|
191
191
|
}) : null), /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, {
|
|
@@ -78,6 +78,17 @@ export type TreeNodeProps = {
|
|
|
78
78
|
* Optional: The URL the TreeNode is linking to
|
|
79
79
|
*/
|
|
80
80
|
href?: string;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* Specify how the trigger should align with the tooltip when text is truncated
|
|
84
|
+
*/
|
|
85
|
+
align?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
|
|
86
|
+
/**
|
|
87
|
+
* **Experimental**: Will attempt to automatically align the floating
|
|
88
|
+
* element to avoid collisions with the viewport and being clipped by
|
|
89
|
+
* ancestor elements.
|
|
90
|
+
*/
|
|
91
|
+
autoAlign?: boolean;
|
|
81
92
|
} & Omit<React.LiHTMLAttributes<HTMLElement>, 'onSelect'>;
|
|
82
93
|
declare const TreeNode: React.ForwardRefExoticComponent<{
|
|
83
94
|
/**
|
|
@@ -152,5 +163,16 @@ declare const TreeNode: React.ForwardRefExoticComponent<{
|
|
|
152
163
|
* Optional: The URL the TreeNode is linking to
|
|
153
164
|
*/
|
|
154
165
|
href?: string;
|
|
166
|
+
/**
|
|
167
|
+
*
|
|
168
|
+
* Specify how the trigger should align with the tooltip when text is truncated
|
|
169
|
+
*/
|
|
170
|
+
align?: "top" | "bottom" | "left" | "right" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-end" | "left-start" | "right-end" | "right-start";
|
|
171
|
+
/**
|
|
172
|
+
* **Experimental**: Will attempt to automatically align the floating
|
|
173
|
+
* element to avoid collisions with the viewport and being clipped by
|
|
174
|
+
* ancestor elements.
|
|
175
|
+
*/
|
|
176
|
+
autoAlign?: boolean;
|
|
155
177
|
} & Omit<React.LiHTMLAttributes<HTMLElement>, "onSelect"> & React.RefAttributes<HTMLElement>>;
|
|
156
178
|
export default TreeNode;
|