@carbon/react 1.109.0 → 1.110.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.
@@ -162,7 +162,7 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
162
162
  inputValue: string | null;
163
163
  }) => boolean;
164
164
  /**
165
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
165
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
166
166
  */
167
167
  size?: ListBoxSize;
168
168
  /**
@@ -35,7 +35,7 @@ declare const DropdownSkeleton: {
35
35
  /**
36
36
  * Specify the size of the ListBox.
37
37
  */
38
- size: PropTypes.Requireable<"sm" | "md" | "lg">;
38
+ size: PropTypes.Requireable<"sm" | "md" | "lg" | "xs">;
39
39
  };
40
40
  };
41
41
  export default DropdownSkeleton;
@@ -122,7 +122,7 @@ export interface DropdownProps<ItemType> extends Omit<HTMLAttributes<HTMLDivElem
122
122
  */
123
123
  selectedItem?: ItemType;
124
124
  /**
125
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
125
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
126
126
  */
127
127
  size?: ListBoxSize;
128
128
  /**
@@ -24,7 +24,8 @@ const Link = React.forwardRef(({ as: BaseComponent, children, className: customC
24
24
  [`${prefix}--link--disabled`]: disabled,
25
25
  [`${prefix}--link--inline`]: inline,
26
26
  [`${prefix}--link--visited`]: visited,
27
- [`${prefix}--link--${size}`]: size
27
+ [`${prefix}--link--${size}`]: size,
28
+ [`${prefix}--link--icon`]: Icon
28
29
  }),
29
30
  rel: target === "_blank" ? "noopener" : void 0,
30
31
  target
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2025
2
+ * Copyright IBM Corp. 2016, 2026
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -37,7 +37,7 @@ export interface ListBoxProps extends Omit<HTMLAttributes<HTMLDivElement>, Exclu
37
37
  */
38
38
  light?: boolean;
39
39
  /**
40
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
40
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
41
41
  */
42
42
  size?: ListBoxSize;
43
43
  /**
@@ -15,7 +15,7 @@ import PropTypes from "prop-types";
15
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
16
  //#region src/components/ListBox/ListBox.tsx
17
17
  /**
18
- * Copyright IBM Corp. 2016, 2025
18
+ * Copyright IBM Corp. 2016, 2026
19
19
  *
20
20
  * This source code is licensed under the Apache-2.0 license found in the
21
21
  * LICENSE file in the root directory of this source tree.
@@ -40,6 +40,7 @@ const ListBox = forwardRef((props, ref) => {
40
40
  ...containerClassName && { [containerClassName]: true },
41
41
  [`${prefix}--list-box`]: true,
42
42
  [`${prefix}--list-box--${size}`]: size,
43
+ [`${prefix}--layout--size-${size}`]: size,
43
44
  [`${prefix}--list-box--inline`]: type === "inline",
44
45
  [`${prefix}--list-box--disabled`]: disabled,
45
46
  [`${prefix}--list-box--light`]: light,
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2025
2
+ * Copyright IBM Corp. 2016, 2026
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  declare const listBoxTypes: readonly ["default", "inline"];
9
- declare const listBoxSizes: readonly ["sm", "md", "lg"];
9
+ declare const listBoxSizes: readonly ["xs", "sm", "md", "lg"];
10
10
  export type ListBoxType = (typeof listBoxTypes)[number];
11
11
  export type ListBoxSize = (typeof listBoxSizes)[number];
12
12
  export declare const ListBoxTypePropType: PropTypes.Requireable<"default" | "inline">;
13
- export declare const ListBoxSizePropType: PropTypes.Requireable<"sm" | "md" | "lg">;
13
+ export declare const ListBoxSizePropType: PropTypes.Requireable<"sm" | "md" | "lg" | "xs">;
14
14
  export {};
@@ -8,13 +8,14 @@
8
8
  import PropTypes from "prop-types";
9
9
  //#region src/components/ListBox/ListBoxPropTypes.ts
10
10
  /**
11
- * Copyright IBM Corp. 2016, 2025
11
+ * Copyright IBM Corp. 2016, 2026
12
12
  *
13
13
  * This source code is licensed under the Apache-2.0 license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
16
  const listBoxTypes = ["default", "inline"];
17
17
  const listBoxSizes = [
18
+ "xs",
18
19
  "sm",
19
20
  "md",
20
21
  "lg"
@@ -143,7 +143,7 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
143
143
  */
144
144
  selectionFeedback?: 'fixed' | 'top' | 'top-after-reopen';
145
145
  /**
146
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
146
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
147
147
  */
148
148
  size?: ListBoxSize;
149
149
  /**
@@ -153,11 +153,11 @@ export interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
153
153
  */
154
154
  unstable_valueUpper?: number;
155
155
  /**
156
- * Specify whether the control is currently in warning state
156
+ * Specify whether the Slider is in a warning state.
157
157
  */
158
158
  warn?: boolean;
159
159
  /**
160
- * Provide the text that is displayed when the control is in warning state
160
+ * Provide the text displayed when the Slider is in a warning state.
161
161
  */
162
162
  warnText?: ReactNode;
163
163
  }
@@ -59,6 +59,8 @@ const calcRawLeftPercent = ({ max, min, value }) => {
59
59
  };
60
60
  /**
61
61
  * Minimum time between processed "drag" events in milliseconds.
62
+ *
63
+ * A value of `16` limits updates to at most ~60 per second.
62
64
  */
63
65
  const EVENT_THROTTLE = 16;
64
66
  const DRAG_EVENT_TYPES = new Set(["mousemove", "touchmove"]);
@@ -96,6 +98,7 @@ const Slider = (props) => {
96
98
  const generatedId = useId();
97
99
  const prefix = usePrefix();
98
100
  const twoHandles = hasUpperValue(state.valueUpper);
101
+ const getOwnerDocument = () => elementRef.current?.ownerDocument;
99
102
  /**
100
103
  * Sets up initial slider position and value in response to component mount.
101
104
  */
@@ -131,8 +134,9 @@ const Slider = (props) => {
131
134
  }
132
135
  }
133
136
  return () => {
134
- DRAG_STOP_EVENT_TYPES.forEach((element) => elementRef.current?.ownerDocument.removeEventListener(element, onDragStop));
135
- DRAG_EVENT_TYPES.forEach((element) => elementRef.current?.ownerDocument.removeEventListener(element, handleDrag));
137
+ const ownerDocument = getOwnerDocument();
138
+ DRAG_STOP_EVENT_TYPES.forEach((type) => ownerDocument?.removeEventListener(type, onDragStop));
139
+ DRAG_EVENT_TYPES.forEach((type) => ownerDocument?.removeEventListener(type, handleDrag));
136
140
  };
137
141
  }, []);
138
142
  useEffect(() => {
@@ -236,11 +240,12 @@ const Slider = (props) => {
236
240
  const onDragStart = (evt) => {
237
241
  if (disabled || readOnly) return;
238
242
  evt.preventDefault();
239
- DRAG_STOP_EVENT_TYPES.forEach((element) => {
240
- elementRef.current?.ownerDocument.addEventListener(element, onDragStop);
243
+ const ownerDocument = getOwnerDocument();
244
+ DRAG_STOP_EVENT_TYPES.forEach((type) => {
245
+ ownerDocument?.addEventListener(type, onDragStop);
241
246
  });
242
- DRAG_EVENT_TYPES.forEach((element) => {
243
- elementRef.current?.ownerDocument.addEventListener(element, handleDrag);
247
+ DRAG_EVENT_TYPES.forEach((type) => {
248
+ ownerDocument?.addEventListener(type, handleDrag);
244
249
  });
245
250
  const clientX = getClientXFromEvent(evt.nativeEvent);
246
251
  let activeHandle;
@@ -264,11 +269,12 @@ const Slider = (props) => {
264
269
  */
265
270
  const onDragStop = () => {
266
271
  if (disabled || readOnly) return;
267
- DRAG_STOP_EVENT_TYPES.forEach((element) => {
268
- elementRef.current?.ownerDocument.removeEventListener(element, onDragStop);
272
+ const ownerDocument = getOwnerDocument();
273
+ DRAG_STOP_EVENT_TYPES.forEach((type) => {
274
+ ownerDocument?.removeEventListener(type, onDragStop);
269
275
  });
270
- DRAG_EVENT_TYPES.forEach((element) => {
271
- elementRef.current?.ownerDocument.removeEventListener(element, handleDrag);
276
+ DRAG_EVENT_TYPES.forEach((type) => {
277
+ ownerDocument?.removeEventListener(type, handleDrag);
272
278
  });
273
279
  setState({ needsOnRelease: true });
274
280
  };
@@ -284,8 +290,8 @@ const Slider = (props) => {
284
290
  * @param activeHandle The first drag event call, we may have an explicit
285
291
  * activeHandle value, which is to be used before state is used.
286
292
  */
287
- const _onDragRef = useRef(null);
288
- _onDragRef.current = (evt, activeHandle) => {
293
+ const onDragRef = useRef(null);
294
+ onDragRef.current = (evt, activeHandle) => {
289
295
  activeHandle = activeHandle ?? stateRef.current.activeHandle;
290
296
  if (disabled || readOnly) return;
291
297
  const { value, left } = calcValue({
@@ -307,11 +313,11 @@ const Slider = (props) => {
307
313
  });
308
314
  };
309
315
  /**
310
- * Throttles calls to `_onDrag` by limiting events to being processed at
311
- * most once every `EVENT_THROTTLE` milliseconds.
316
+ * Throttles drag event handling to at most once every `EVENT_THROTTLE`
317
+ * milliseconds.
312
318
  */
313
319
  const onDrag = useMemo(() => throttle((evt, activeHandle) => {
314
- _onDragRef.current?.(evt, activeHandle);
320
+ onDragRef.current?.(evt, activeHandle);
315
321
  }, EVENT_THROTTLE, {
316
322
  leading: true,
317
323
  trailing: false
@@ -402,11 +408,7 @@ const Slider = (props) => {
402
408
  value: targetValue,
403
409
  min,
404
410
  max
405
- }) : getAdjustedValue({
406
- value: targetValue,
407
- min,
408
- max
409
- });
411
+ }) : clamp(targetValue, min, max);
410
412
  if (adjustedValue !== targetValue) setState({
411
413
  correctedValue: targetValue.toString(),
412
414
  correctedPosition: handlePosition ?? null
@@ -430,7 +432,7 @@ const Slider = (props) => {
430
432
  }
431
433
  };
432
434
  const calcLeftPercent = ({ clientX, value }) => {
433
- const boundingRect = elementRef.current?.getBoundingClientRect?.();
435
+ const boundingRect = elementRef.current?.getBoundingClientRect();
434
436
  let width = boundingRect ? boundingRect.right - boundingRect.left : 0;
435
437
  const nextValue = value ?? min;
436
438
  if (width <= 0) width = 1;
@@ -492,7 +494,7 @@ const Slider = (props) => {
492
494
  */
493
495
  const calcValueForDelta = (currentValue, delta, step = 1) => {
494
496
  const newValue = (delta > 0 ? Math.round(currentValue / step) * step : currentValue) + delta;
495
- const decimals = (step.toString().split(".")[1] || "").length;
497
+ const decimals = (step.toString().split(".")[1] ?? "").length;
496
498
  return Number(newValue.toFixed(decimals));
497
499
  };
498
500
  /**
@@ -538,19 +540,10 @@ const Slider = (props) => {
538
540
  };
539
541
  const getAdjustedValueForPosition = ({ handle, value: newValueInput, min, max }) => {
540
542
  const { value, valueUpper } = state;
541
- let newValue = getAdjustedValue({
542
- value: newValueInput,
543
- min,
544
- max
545
- });
546
- if (handle === "lower" && valueUpper) newValue = newValue > valueUpper ? valueUpper : newValue;
547
- else if (handle === "upper" && value) newValue = newValue < value ? value : newValue;
548
- return newValue;
549
- };
550
- const getAdjustedValue = ({ value, min, max }) => {
551
- if (value < min) value = min;
552
- if (value > max) value = max;
553
- return value;
543
+ const nextValue = clamp(newValueInput, min, max);
544
+ if (handle === "lower" && hasUpperValue(valueUpper)) return Math.min(nextValue, valueUpper);
545
+ if (handle === "upper") return Math.max(nextValue, value);
546
+ return nextValue;
554
547
  };
555
548
  /**
556
549
  * Get the bounding rect for the requested handles' DOM element.
@@ -254,6 +254,10 @@ declare namespace TabList {
254
254
  * to newly selected tabs on component rerender
255
255
  */
256
256
  scrollIntoView: PropTypes.Requireable<boolean>;
257
+ /**
258
+ * Specify the size of the tabs.
259
+ */
260
+ size: PropTypes.Requireable<string>;
257
261
  };
258
262
  }
259
263
  /**
@@ -161,7 +161,7 @@ function TabList({ activation = "automatic", "aria-label": label, children, clas
161
161
  [`${prefix}--tabs__icon--default`]: iconSize === "default",
162
162
  [`${prefix}--tabs__icon--lg`]: iconSize === "lg",
163
163
  [`${prefix}--layout--size-lg`]: iconSize === "lg",
164
- [`${prefix}--layout--size-${size}`]: size && contained && !hasSecondaryLabelTabs,
164
+ [`${prefix}--layout--size-${size}`]: size && !hasSecondaryLabelTabs,
165
165
  [`${prefix}--tabs--tall`]: hasSecondaryLabelTabs,
166
166
  [`${prefix}--tabs--full-width`]: distributeWidth,
167
167
  [`${prefix}--tabs--dismissable`]: dismissable
@@ -342,7 +342,12 @@ TabList.propTypes = {
342
342
  light: deprecate(PropTypes.bool, "The `light` prop for `TabList` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release."),
343
343
  rightOverflowButtonProps: PropTypes.object,
344
344
  scrollDebounceWait: PropTypes.number,
345
- scrollIntoView: PropTypes.bool
345
+ scrollIntoView: PropTypes.bool,
346
+ size: PropTypes.oneOf([
347
+ "sm",
348
+ "md",
349
+ "lg"
350
+ ])
346
351
  };
347
352
  function TabListVertical({ activation = "automatic", "aria-label": label, children, className: customClassName, scrollIntoView, ...rest }) {
348
353
  const { activeIndex, selectedIndex, setSelectedIndex, setActiveIndex } = React.useContext(TabsContext);
@@ -162,7 +162,7 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
162
162
  inputValue: string | null;
163
163
  }) => boolean;
164
164
  /**
165
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
165
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
166
166
  */
167
167
  size?: ListBoxSize;
168
168
  /**
@@ -35,7 +35,7 @@ declare const DropdownSkeleton: {
35
35
  /**
36
36
  * Specify the size of the ListBox.
37
37
  */
38
- size: PropTypes.Requireable<"sm" | "md" | "lg">;
38
+ size: PropTypes.Requireable<"sm" | "md" | "lg" | "xs">;
39
39
  };
40
40
  };
41
41
  export default DropdownSkeleton;
@@ -122,7 +122,7 @@ export interface DropdownProps<ItemType> extends Omit<HTMLAttributes<HTMLDivElem
122
122
  */
123
123
  selectedItem?: ItemType;
124
124
  /**
125
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
125
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
126
126
  */
127
127
  size?: ListBoxSize;
128
128
  /**
@@ -28,7 +28,8 @@ const Link = react.default.forwardRef(({ as: BaseComponent, children, className:
28
28
  [`${prefix}--link--disabled`]: disabled,
29
29
  [`${prefix}--link--inline`]: inline,
30
30
  [`${prefix}--link--visited`]: visited,
31
- [`${prefix}--link--${size}`]: size
31
+ [`${prefix}--link--${size}`]: size,
32
+ [`${prefix}--link--icon`]: Icon
32
33
  }),
33
34
  rel: target === "_blank" ? "noopener" : void 0,
34
35
  target
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2025
2
+ * Copyright IBM Corp. 2016, 2026
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -37,7 +37,7 @@ export interface ListBoxProps extends Omit<HTMLAttributes<HTMLDivElement>, Exclu
37
37
  */
38
38
  light?: boolean;
39
39
  /**
40
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
40
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
41
41
  */
42
42
  size?: ListBoxSize;
43
43
  /**
@@ -19,7 +19,7 @@ prop_types = require_runtime.__toESM(prop_types);
19
19
  let react_jsx_runtime = require("react/jsx-runtime");
20
20
  //#region src/components/ListBox/ListBox.tsx
21
21
  /**
22
- * Copyright IBM Corp. 2016, 2025
22
+ * Copyright IBM Corp. 2016, 2026
23
23
  *
24
24
  * This source code is licensed under the Apache-2.0 license found in the
25
25
  * LICENSE file in the root directory of this source tree.
@@ -44,6 +44,7 @@ const ListBox = (0, react.forwardRef)((props, ref) => {
44
44
  ...containerClassName && { [containerClassName]: true },
45
45
  [`${prefix}--list-box`]: true,
46
46
  [`${prefix}--list-box--${size}`]: size,
47
+ [`${prefix}--layout--size-${size}`]: size,
47
48
  [`${prefix}--list-box--inline`]: type === "inline",
48
49
  [`${prefix}--list-box--disabled`]: disabled,
49
50
  [`${prefix}--list-box--light`]: light,
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2025
2
+ * Copyright IBM Corp. 2016, 2026
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  declare const listBoxTypes: readonly ["default", "inline"];
9
- declare const listBoxSizes: readonly ["sm", "md", "lg"];
9
+ declare const listBoxSizes: readonly ["xs", "sm", "md", "lg"];
10
10
  export type ListBoxType = (typeof listBoxTypes)[number];
11
11
  export type ListBoxSize = (typeof listBoxSizes)[number];
12
12
  export declare const ListBoxTypePropType: PropTypes.Requireable<"default" | "inline">;
13
- export declare const ListBoxSizePropType: PropTypes.Requireable<"sm" | "md" | "lg">;
13
+ export declare const ListBoxSizePropType: PropTypes.Requireable<"sm" | "md" | "lg" | "xs">;
14
14
  export {};
@@ -10,13 +10,14 @@ let prop_types = require("prop-types");
10
10
  prop_types = require_runtime.__toESM(prop_types);
11
11
  //#region src/components/ListBox/ListBoxPropTypes.ts
12
12
  /**
13
- * Copyright IBM Corp. 2016, 2025
13
+ * Copyright IBM Corp. 2016, 2026
14
14
  *
15
15
  * This source code is licensed under the Apache-2.0 license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
17
  */
18
18
  const listBoxTypes = ["default", "inline"];
19
19
  const listBoxSizes = [
20
+ "xs",
20
21
  "sm",
21
22
  "md",
22
23
  "lg"
@@ -143,7 +143,7 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
143
143
  */
144
144
  selectionFeedback?: 'fixed' | 'top' | 'top-after-reopen';
145
145
  /**
146
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
146
+ * Specify the size of the ListBox. Currently supports either `xs`, `sm`, `md` or `lg` as an option.
147
147
  */
148
148
  size?: ListBoxSize;
149
149
  /**
@@ -153,11 +153,11 @@ export interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
153
153
  */
154
154
  unstable_valueUpper?: number;
155
155
  /**
156
- * Specify whether the control is currently in warning state
156
+ * Specify whether the Slider is in a warning state.
157
157
  */
158
158
  warn?: boolean;
159
159
  /**
160
- * Provide the text that is displayed when the control is in warning state
160
+ * Provide the text displayed when the Slider is in a warning state.
161
161
  */
162
162
  warnText?: ReactNode;
163
163
  }
@@ -63,6 +63,8 @@ const calcRawLeftPercent = ({ max, min, value }) => {
63
63
  };
64
64
  /**
65
65
  * Minimum time between processed "drag" events in milliseconds.
66
+ *
67
+ * A value of `16` limits updates to at most ~60 per second.
66
68
  */
67
69
  const EVENT_THROTTLE = 16;
68
70
  const DRAG_EVENT_TYPES = new Set(["mousemove", "touchmove"]);
@@ -100,6 +102,7 @@ const Slider = (props) => {
100
102
  const generatedId = require_useId.useId();
101
103
  const prefix = require_usePrefix.usePrefix();
102
104
  const twoHandles = hasUpperValue(state.valueUpper);
105
+ const getOwnerDocument = () => elementRef.current?.ownerDocument;
103
106
  /**
104
107
  * Sets up initial slider position and value in response to component mount.
105
108
  */
@@ -135,8 +138,9 @@ const Slider = (props) => {
135
138
  }
136
139
  }
137
140
  return () => {
138
- DRAG_STOP_EVENT_TYPES.forEach((element) => elementRef.current?.ownerDocument.removeEventListener(element, onDragStop));
139
- DRAG_EVENT_TYPES.forEach((element) => elementRef.current?.ownerDocument.removeEventListener(element, handleDrag));
141
+ const ownerDocument = getOwnerDocument();
142
+ DRAG_STOP_EVENT_TYPES.forEach((type) => ownerDocument?.removeEventListener(type, onDragStop));
143
+ DRAG_EVENT_TYPES.forEach((type) => ownerDocument?.removeEventListener(type, handleDrag));
140
144
  };
141
145
  }, []);
142
146
  (0, react.useEffect)(() => {
@@ -240,11 +244,12 @@ const Slider = (props) => {
240
244
  const onDragStart = (evt) => {
241
245
  if (disabled || readOnly) return;
242
246
  evt.preventDefault();
243
- DRAG_STOP_EVENT_TYPES.forEach((element) => {
244
- elementRef.current?.ownerDocument.addEventListener(element, onDragStop);
247
+ const ownerDocument = getOwnerDocument();
248
+ DRAG_STOP_EVENT_TYPES.forEach((type) => {
249
+ ownerDocument?.addEventListener(type, onDragStop);
245
250
  });
246
- DRAG_EVENT_TYPES.forEach((element) => {
247
- elementRef.current?.ownerDocument.addEventListener(element, handleDrag);
251
+ DRAG_EVENT_TYPES.forEach((type) => {
252
+ ownerDocument?.addEventListener(type, handleDrag);
248
253
  });
249
254
  const clientX = getClientXFromEvent(evt.nativeEvent);
250
255
  let activeHandle;
@@ -268,11 +273,12 @@ const Slider = (props) => {
268
273
  */
269
274
  const onDragStop = () => {
270
275
  if (disabled || readOnly) return;
271
- DRAG_STOP_EVENT_TYPES.forEach((element) => {
272
- elementRef.current?.ownerDocument.removeEventListener(element, onDragStop);
276
+ const ownerDocument = getOwnerDocument();
277
+ DRAG_STOP_EVENT_TYPES.forEach((type) => {
278
+ ownerDocument?.removeEventListener(type, onDragStop);
273
279
  });
274
- DRAG_EVENT_TYPES.forEach((element) => {
275
- elementRef.current?.ownerDocument.removeEventListener(element, handleDrag);
280
+ DRAG_EVENT_TYPES.forEach((type) => {
281
+ ownerDocument?.removeEventListener(type, handleDrag);
276
282
  });
277
283
  setState({ needsOnRelease: true });
278
284
  };
@@ -288,8 +294,8 @@ const Slider = (props) => {
288
294
  * @param activeHandle The first drag event call, we may have an explicit
289
295
  * activeHandle value, which is to be used before state is used.
290
296
  */
291
- const _onDragRef = (0, react.useRef)(null);
292
- _onDragRef.current = (evt, activeHandle) => {
297
+ const onDragRef = (0, react.useRef)(null);
298
+ onDragRef.current = (evt, activeHandle) => {
293
299
  activeHandle = activeHandle ?? stateRef.current.activeHandle;
294
300
  if (disabled || readOnly) return;
295
301
  const { value, left } = calcValue({
@@ -311,11 +317,11 @@ const Slider = (props) => {
311
317
  });
312
318
  };
313
319
  /**
314
- * Throttles calls to `_onDrag` by limiting events to being processed at
315
- * most once every `EVENT_THROTTLE` milliseconds.
320
+ * Throttles drag event handling to at most once every `EVENT_THROTTLE`
321
+ * milliseconds.
316
322
  */
317
323
  const onDrag = (0, react.useMemo)(() => (0, es_toolkit_compat.throttle)((evt, activeHandle) => {
318
- _onDragRef.current?.(evt, activeHandle);
324
+ onDragRef.current?.(evt, activeHandle);
319
325
  }, EVENT_THROTTLE, {
320
326
  leading: true,
321
327
  trailing: false
@@ -406,11 +412,7 @@ const Slider = (props) => {
406
412
  value: targetValue,
407
413
  min,
408
414
  max
409
- }) : getAdjustedValue({
410
- value: targetValue,
411
- min,
412
- max
413
- });
415
+ }) : require_clamp.clamp(targetValue, min, max);
414
416
  if (adjustedValue !== targetValue) setState({
415
417
  correctedValue: targetValue.toString(),
416
418
  correctedPosition: handlePosition ?? null
@@ -434,7 +436,7 @@ const Slider = (props) => {
434
436
  }
435
437
  };
436
438
  const calcLeftPercent = ({ clientX, value }) => {
437
- const boundingRect = elementRef.current?.getBoundingClientRect?.();
439
+ const boundingRect = elementRef.current?.getBoundingClientRect();
438
440
  let width = boundingRect ? boundingRect.right - boundingRect.left : 0;
439
441
  const nextValue = value ?? min;
440
442
  if (width <= 0) width = 1;
@@ -496,7 +498,7 @@ const Slider = (props) => {
496
498
  */
497
499
  const calcValueForDelta = (currentValue, delta, step = 1) => {
498
500
  const newValue = (delta > 0 ? Math.round(currentValue / step) * step : currentValue) + delta;
499
- const decimals = (step.toString().split(".")[1] || "").length;
501
+ const decimals = (step.toString().split(".")[1] ?? "").length;
500
502
  return Number(newValue.toFixed(decimals));
501
503
  };
502
504
  /**
@@ -542,19 +544,10 @@ const Slider = (props) => {
542
544
  };
543
545
  const getAdjustedValueForPosition = ({ handle, value: newValueInput, min, max }) => {
544
546
  const { value, valueUpper } = state;
545
- let newValue = getAdjustedValue({
546
- value: newValueInput,
547
- min,
548
- max
549
- });
550
- if (handle === "lower" && valueUpper) newValue = newValue > valueUpper ? valueUpper : newValue;
551
- else if (handle === "upper" && value) newValue = newValue < value ? value : newValue;
552
- return newValue;
553
- };
554
- const getAdjustedValue = ({ value, min, max }) => {
555
- if (value < min) value = min;
556
- if (value > max) value = max;
557
- return value;
547
+ const nextValue = require_clamp.clamp(newValueInput, min, max);
548
+ if (handle === "lower" && hasUpperValue(valueUpper)) return Math.min(nextValue, valueUpper);
549
+ if (handle === "upper") return Math.max(nextValue, value);
550
+ return nextValue;
558
551
  };
559
552
  /**
560
553
  * Get the bounding rect for the requested handles' DOM element.
@@ -254,6 +254,10 @@ declare namespace TabList {
254
254
  * to newly selected tabs on component rerender
255
255
  */
256
256
  scrollIntoView: PropTypes.Requireable<boolean>;
257
+ /**
258
+ * Specify the size of the tabs.
259
+ */
260
+ size: PropTypes.Requireable<string>;
257
261
  };
258
262
  }
259
263
  /**
@@ -165,7 +165,7 @@ function TabList({ activation = "automatic", "aria-label": label, children, clas
165
165
  [`${prefix}--tabs__icon--default`]: iconSize === "default",
166
166
  [`${prefix}--tabs__icon--lg`]: iconSize === "lg",
167
167
  [`${prefix}--layout--size-lg`]: iconSize === "lg",
168
- [`${prefix}--layout--size-${size}`]: size && contained && !hasSecondaryLabelTabs,
168
+ [`${prefix}--layout--size-${size}`]: size && !hasSecondaryLabelTabs,
169
169
  [`${prefix}--tabs--tall`]: hasSecondaryLabelTabs,
170
170
  [`${prefix}--tabs--full-width`]: distributeWidth,
171
171
  [`${prefix}--tabs--dismissable`]: dismissable
@@ -346,7 +346,12 @@ TabList.propTypes = {
346
346
  light: require_deprecate.deprecate(prop_types.default.bool, "The `light` prop for `TabList` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release."),
347
347
  rightOverflowButtonProps: prop_types.default.object,
348
348
  scrollDebounceWait: prop_types.default.number,
349
- scrollIntoView: prop_types.default.bool
349
+ scrollIntoView: prop_types.default.bool,
350
+ size: prop_types.default.oneOf([
351
+ "sm",
352
+ "md",
353
+ "lg"
354
+ ])
350
355
  };
351
356
  function TabListVertical({ activation = "automatic", "aria-label": label, children, className: customClassName, scrollIntoView, ...rest }) {
352
357
  const { activeIndex, selectedIndex, setSelectedIndex, setActiveIndex } = react.default.useContext(TabsContext);