@carbon/react 1.85.0-rc.0 → 1.85.1

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.
Files changed (40) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +869 -799
  2. package/es/components/DatePicker/DatePicker.d.ts +1 -1
  3. package/es/components/DatePicker/DatePicker.js +2 -2
  4. package/es/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
  5. package/es/components/DatePicker/plugins/appendToPlugin.js +9 -12
  6. package/es/components/Menu/Menu.js +7 -2
  7. package/es/components/Menu/MenuItem.js +13 -2
  8. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
  9. package/es/components/MultiSelect/filter.d.ts +10 -0
  10. package/es/components/MultiSelect/filter.js +21 -0
  11. package/es/components/Slider/Slider.d.ts +59 -198
  12. package/es/components/Slider/Slider.js +68 -120
  13. package/es/components/Tabs/usePressable.d.ts +19 -0
  14. package/es/components/Tabs/usePressable.js +19 -33
  15. package/es/components/Tooltip/Tooltip.d.ts +2 -2
  16. package/es/components/Tooltip/Tooltip.js +2 -2
  17. package/es/components/TreeView/TreeNode.d.ts +22 -0
  18. package/es/components/TreeView/TreeNode.js +116 -9
  19. package/es/components/UIShell/HeaderPanel.js +5 -7
  20. package/lib/components/DatePicker/DatePicker.d.ts +1 -1
  21. package/lib/components/DatePicker/DatePicker.js +1 -1
  22. package/lib/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
  23. package/lib/components/DatePicker/plugins/appendToPlugin.js +9 -12
  24. package/lib/components/Menu/Menu.js +7 -2
  25. package/lib/components/Menu/MenuItem.js +13 -2
  26. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
  27. package/lib/components/MultiSelect/filter.d.ts +10 -0
  28. package/lib/components/MultiSelect/filter.js +25 -0
  29. package/lib/components/Slider/Slider.d.ts +59 -198
  30. package/lib/components/Slider/Slider.js +67 -119
  31. package/lib/components/Tabs/usePressable.d.ts +19 -0
  32. package/lib/components/Tabs/usePressable.js +19 -33
  33. package/lib/components/Tooltip/Tooltip.d.ts +2 -2
  34. package/lib/components/Tooltip/Tooltip.js +2 -2
  35. package/lib/components/TreeView/TreeNode.d.ts +22 -0
  36. package/lib/components/TreeView/TreeNode.js +115 -8
  37. package/lib/components/UIShell/HeaderPanel.js +5 -7
  38. package/package.json +6 -6
  39. package/es/components/ComboBox/tools/filter.js +0 -18
  40. package/lib/components/ComboBox/tools/filter.js +0 -22
@@ -4,8 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { type KeyboardEventHandler, PureComponent, ReactNode } from 'react';
8
- import PropTypes from 'prop-types';
7
+ import React, { PureComponent, ReactNode, type ChangeEvent, type FocusEvent, type InputHTMLAttributes, type KeyboardEvent, type KeyboardEventHandler, type MouseEvent, type RefObject, type TouchEvent } from 'react';
9
8
  import { TranslateWithId } from '../../types/common';
10
9
  declare const translationIds: {
11
10
  readonly autoCorrectAnnouncement: "carbon.slider.auto-correct-announcement";
@@ -14,15 +13,12 @@ declare const translationIds: {
14
13
  * Message ids that will be passed to translateWithId().
15
14
  */
16
15
  type TranslationKey = (typeof translationIds)[keyof typeof translationIds];
17
- /**
18
- * Distinguish two handles by lower and upper positions.
19
- */
20
16
  declare enum HandlePosition {
21
17
  LOWER = "lower",
22
18
  UPPER = "upper"
23
19
  }
24
20
  type ExcludedAttributes = 'onChange' | 'onBlur';
25
- export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey, {
21
+ export interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey, {
26
22
  correctedValue?: string;
27
23
  }> {
28
24
  /**
@@ -116,14 +112,13 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
116
112
  }) => void;
117
113
  /**
118
114
  * The callback to get notified of change in value.
119
- * `({ value: number, valueUpper?: number }) => void`
120
115
  */
121
116
  onChange?: (data: {
122
117
  value: SliderProps['value'];
123
118
  valueUpper: SliderProps['unstable_valueUpper'];
124
119
  }) => void;
125
120
  /**
126
- * Provide an optional function to be called when a key is pressed in the number input. When there are two handles, you can obtain the relevant handle position by using `event.target.dataset.handlePosition`.
121
+ * Provide an optional function to be called when a key is pressed in the number input.
127
122
  */
128
123
  onInputKeyUp?: KeyboardEventHandler<HTMLInputElement>;
129
124
  /**
@@ -166,7 +161,7 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
166
161
  /**
167
162
  * Provide the text that is displayed when the control is in warning state
168
163
  */
169
- warnText?: React.ReactNode;
164
+ warnText?: ReactNode;
170
165
  }
171
166
  interface CalcLeftPercentProps {
172
167
  clientX?: number;
@@ -174,146 +169,8 @@ interface CalcLeftPercentProps {
174
169
  range?: number;
175
170
  }
176
171
  declare class Slider extends PureComponent<SliderProps> {
177
- static propTypes: {
178
- /**
179
- * The `ariaLabel` for the `<input>`.
180
- */
181
- ariaLabelInput: PropTypes.Requireable<string>;
182
- /**
183
- * The child nodes.
184
- */
185
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
186
- /**
187
- * The CSS class name for the slider.
188
- */
189
- className: PropTypes.Requireable<string>;
190
- /**
191
- * `true` to disable this slider.
192
- */
193
- disabled: PropTypes.Requireable<boolean>;
194
- /**
195
- * The callback to format the label associated with the minimum/maximum value.
196
- */
197
- formatLabel: PropTypes.Requireable<(...args: any[]) => any>;
198
- /**
199
- * `true` to hide the number input box.
200
- */
201
- hideTextInput: PropTypes.Requireable<boolean>;
202
- /**
203
- * The ID of the `<input>`.
204
- */
205
- id: PropTypes.Requireable<string>;
206
- /**
207
- * The `type` attribute of the `<input>`.
208
- */
209
- inputType: PropTypes.Requireable<string>;
210
- /**
211
- * `Specify whether the Slider is currently invalid
212
- */
213
- invalid: PropTypes.Requireable<boolean>;
214
- /**
215
- * Provide the text that is displayed when the Slider is in an invalid state
216
- */
217
- invalidText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
218
- /**
219
- * The label for the slider.
220
- */
221
- labelText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
222
- /**
223
- * Specify whether you want the underlying label to be visually hidden
224
- */
225
- hideLabel: PropTypes.Requireable<boolean>;
226
- /**
227
- * `true` to use the light version.
228
- */
229
- light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
230
- /**
231
- * The maximum value.
232
- */
233
- max: PropTypes.Validator<number>;
234
- /**
235
- * The label associated with the maximum value.
236
- */
237
- maxLabel: PropTypes.Requireable<string>;
238
- /**
239
- * The minimum value.
240
- */
241
- min: PropTypes.Validator<number>;
242
- /**
243
- * The label associated with the minimum value.
244
- */
245
- minLabel: PropTypes.Requireable<string>;
246
- /**
247
- * The `name` attribute of the `<input>`.
248
- */
249
- name: PropTypes.Requireable<string>;
250
- /**
251
- * Provide an optional function to be called when the input element
252
- * loses focus
253
- */
254
- onBlur: PropTypes.Requireable<(...args: any[]) => any>;
255
- /**
256
- * The callback to get notified of change in value.
257
- */
258
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
259
- /**
260
- * Provide an optional function to be called when a key is pressed in the number input
261
- */
262
- onInputKeyUp: PropTypes.Requireable<(...args: any[]) => any>;
263
- /**
264
- * The callback to get notified of value on handle release.
265
- */
266
- onRelease: PropTypes.Requireable<(...args: any[]) => any>;
267
- /**
268
- * Whether the slider should be read-only
269
- */
270
- readOnly: PropTypes.Requireable<boolean>;
271
- /**
272
- * `true` to specify if the control is required.
273
- */
274
- required: PropTypes.Requireable<boolean>;
275
- /**
276
- * A value determining how much the value should increase/decrease by moving the thumb by mouse. If a value other than 1 is provided and the input is *not* hidden, the new step requirement should be added to a visible label. Values outside the `step` increment will be considered invalid.
277
- */
278
- step: PropTypes.Requireable<number>;
279
- /**
280
- * A value determining how much the value should increase/decrease by Shift+arrow keys,
281
- * which will be `(max - min) / stepMultiplier`.
282
- */
283
- stepMultiplier: PropTypes.Requireable<number>;
284
- /**
285
- * Supply a method to translate internal strings with your i18n tool of
286
- * choice. Translation keys are available on the `translationIds` field for
287
- * this component.
288
- */
289
- translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
290
- /**
291
- * The `ariaLabel` for the upper bound `<input>` when there are two handles.
292
- */
293
- unstable_ariaLabelInputUpper: PropTypes.Requireable<string>;
294
- /**
295
- * The `name` attribute of the upper bound `<input>` when there are two handles.
296
- */
297
- unstable_nameUpper: PropTypes.Requireable<string>;
298
- /**
299
- * The upper bound when there are two handles.
300
- */
301
- unstable_valueUpper: PropTypes.Requireable<number>;
302
- /**
303
- * The value of the slider. When there are two handles, value is the lower
304
- * bound.
305
- */
306
- value: PropTypes.Validator<number>;
307
- /**
308
- * `Specify whether the Slider is in a warn state
309
- */
310
- warn: PropTypes.Requireable<boolean>;
311
- /**
312
- * Provide the text that is displayed when the Slider is in a warn state
313
- */
314
- warnText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
315
- };
316
172
  static contextType: React.Context<any>;
173
+ static translationIds: "carbon.slider.auto-correct-announcement"[];
317
174
  state: {
318
175
  value: number;
319
176
  valueUpper: number | undefined;
@@ -322,14 +179,14 @@ declare class Slider extends PureComponent<SliderProps> {
322
179
  needsOnRelease: boolean;
323
180
  isValid: boolean;
324
181
  isValidUpper: boolean;
325
- activeHandle: null;
182
+ activeHandle: undefined;
326
183
  correctedValue: null;
327
184
  correctedPosition: null;
328
185
  isRtl: boolean;
329
186
  };
330
- thumbRef: React.RefObject<HTMLDivElement | null>;
331
- thumbRefUpper: React.RefObject<HTMLDivElement | null>;
332
- filledTrackRef: React.RefObject<HTMLDivElement | null>;
187
+ thumbRef: RefObject<HTMLDivElement | null>;
188
+ thumbRefUpper: RefObject<HTMLDivElement | null>;
189
+ filledTrackRef: RefObject<HTMLDivElement | null>;
333
190
  element: HTMLDivElement | null;
334
191
  inputId: string;
335
192
  track: HTMLDivElement | null | undefined;
@@ -355,16 +212,15 @@ declare class Slider extends PureComponent<SliderProps> {
355
212
  * @returns The value rounded to the precision determined by the step.
356
213
  */
357
214
  nearestStepValue(value?: number): number;
215
+ handleDrag: (event: Event) => void;
358
216
  /**
359
217
  * Sets up "drag" event handlers and calls `this.onDrag` in case dragging
360
218
  * started on somewhere other than the thumb without a corresponding "move"
361
219
  * event.
362
- *
363
- * @param {Event} evt The event.
364
220
  */
365
- onDragStart: (evt: any) => void;
221
+ onDragStart: (evt: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
366
222
  /**
367
- * Unregisters "drag" and "drag stop" event handlers and calls sets the flag
223
+ * Removes "drag" and "drag stop" event handlers and calls sets the flag
368
224
  * indicating that the `onRelease` callback should be called.
369
225
  */
370
226
  onDragStop: () => void;
@@ -372,40 +228,33 @@ declare class Slider extends PureComponent<SliderProps> {
372
228
  * Handles a "drag" event by recalculating the value/thumb and setting state
373
229
  * accordingly.
374
230
  *
375
- * @param {Event} evt The event.
376
- * @param activeHandle
377
- * The first drag event call, we may have an explicit activeHandle value,
378
- * which is to be used before state is used.
231
+ * @param evt The event.
232
+ * @param activeHandle The first drag event call, we may have an explicit
233
+ * activeHandle value, which is to be used before state is used.
379
234
  */
380
- _onDrag: (evt: any, activeHandle?: HandlePosition | null) => void;
235
+ _onDrag: (evt: globalThis.MouseEvent | globalThis.TouchEvent, activeHandle?: HandlePosition) => void;
381
236
  /**
382
237
  * Throttles calls to `this._onDrag` by limiting events to being processed at
383
238
  * most once every `EVENT_THROTTLE` milliseconds.
384
239
  */
385
- onDrag: import("es-toolkit/compat").DebouncedFunc<(evt: any, activeHandle?: HandlePosition | null) => void>;
240
+ onDrag: import("es-toolkit/compat").DebouncedFunc<(evt: globalThis.MouseEvent | globalThis.TouchEvent, activeHandle?: HandlePosition) => void>;
386
241
  /**
387
242
  * Handles a `keydown` event by recalculating the value/thumb and setting
388
243
  * state accordingly.
389
- *
390
- * @param {Event} evt The event.
391
244
  */
392
- onKeyDown: (evt: any) => void;
245
+ onKeyDown: (evt: KeyboardEvent<HTMLDivElement>) => void;
393
246
  /**
394
247
  * Provides the two-way binding for the input field of the Slider. It also
395
248
  * Handles a change to the input field by recalculating the value/thumb and
396
249
  * setting state accordingly.
397
- *
398
- * @param {Event} evt The event.
399
250
  */
400
- onChange: (evt: any) => void;
251
+ onChange: (evt: ChangeEvent<HTMLInputElement>) => void;
401
252
  /**
402
253
  * Checks for validity of input value after clicking out of the input. It also
403
254
  * Handles state change to isValid state.
404
- *
405
- * @param {Event} evt The event.
406
255
  */
407
- onBlur: (evt: React.FocusEvent<HTMLInputElement>) => void;
408
- onInputKeyDown: (evt: any) => void;
256
+ onBlur: (evt: FocusEvent<HTMLInputElement>) => void;
257
+ onInputKeyDown: (evt: KeyboardEvent<HTMLInputElement>) => void;
409
258
  processNewInputValue: (input: HTMLInputElement) => void;
410
259
  calcLeftPercent: ({ clientX, value, range }: CalcLeftPercentProps) => number;
411
260
  /**
@@ -434,7 +283,7 @@ declare class Slider extends PureComponent<SliderProps> {
434
283
  value: number | undefined;
435
284
  left: number;
436
285
  };
437
- calcDistanceToHandle: (handle: HandlePosition, clientX: any) => number;
286
+ calcDistanceToHandle: (handle: HandlePosition, clientX: number) => number;
438
287
  /**
439
288
  * Calculates a new slider value based on the current value, a change delta,
440
289
  * and a step.
@@ -452,41 +301,53 @@ declare class Slider extends PureComponent<SliderProps> {
452
301
  * Guards against setting either lower or upper values beyond its counterpart.
453
302
  */
454
303
  setValueLeftForHandle: (handle: HandlePosition, { value: newValue, left: newLeft }: {
455
- value: any;
456
- left: any;
304
+ value: number;
305
+ left: number;
457
306
  }) => void;
458
- setValueForHandle: (handle: HandlePosition, value: any) => void;
459
- isValidValueForPosition: ({ handle, value: newValue, min, max }: {
460
- handle: any;
461
- value: any;
462
- min: any;
463
- max: any;
307
+ setValueForHandle: (handle: HandlePosition, value: number | string) => void;
308
+ isValidValueForPosition: ({ handle, value: newValue, min, max, }: {
309
+ handle: HandlePosition;
310
+ value: number;
311
+ min: number;
312
+ max: number;
464
313
  }) => boolean;
465
- isValidValue: ({ value, min, max }: {
466
- value: any;
467
- min: any;
468
- max: any;
314
+ isValidValue: ({ value, min, max, }: {
315
+ value: number;
316
+ min: number;
317
+ max: number;
469
318
  }) => boolean;
470
- getAdjustedValueForPosition: ({ handle, value: newValue, min, max }: {
471
- handle: any;
472
- value: any;
473
- min: any;
474
- max: any;
475
- }) => any;
476
- getAdjustedValue: ({ value, min, max }: {
477
- value: any;
478
- min: any;
479
- max: any;
480
- }) => any;
319
+ getAdjustedValueForPosition: ({ handle, value: newValue, min, max, }: {
320
+ handle: HandlePosition;
321
+ value: number;
322
+ min: number;
323
+ max: number;
324
+ }) => number;
325
+ getAdjustedValue: ({ value, min, max, }: {
326
+ value: number;
327
+ min: number;
328
+ max: number;
329
+ }) => number;
481
330
  /**
482
331
  * Get the bounding rect for the requested handles' DOM element.
483
332
  *
484
333
  * If the bounding rect is not available, a new, empty DOMRect is returned.
485
334
  */
486
335
  getHandleBoundingRect: (handle: HandlePosition) => DOMRect;
487
- getClientXFromEvent(event: MouseEvent | TouchEvent): any;
336
+ getClientXFromEvent(event: globalThis.MouseEvent | globalThis.TouchEvent): number | undefined;
488
337
  hasTwoHandles(): boolean;
489
- static getDerivedStateFromProps(props: any, state: any): {} | null;
338
+ static getDerivedStateFromProps(props: SliderProps, state: Slider['state']): Partial<{
339
+ value: number;
340
+ valueUpper: number | undefined;
341
+ left: number;
342
+ leftUpper: number;
343
+ needsOnRelease: boolean;
344
+ isValid: boolean;
345
+ isValidUpper: boolean;
346
+ activeHandle: undefined;
347
+ correctedValue: null;
348
+ correctedPosition: null;
349
+ isRtl: boolean;
350
+ }> | null;
490
351
  render(): import("react/jsx-runtime").JSX.Element;
491
352
  }
492
353
  export default Slider;