@carbon/utilities 0.17.0 → 0.18.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.
Files changed (63) hide show
  1. package/README.md +37 -0
  2. package/es/carousel/index.d.ts +2 -0
  3. package/es/carousel/index.js +3 -1
  4. package/es/chunk-BYypO7fO.js +18 -0
  5. package/es/chunk-Bzxox1sl.d.ts +48 -0
  6. package/es/chunk-CYAX4TFi.js +80 -0
  7. package/es/chunk-Ci2WlFE4.js +437 -0
  8. package/es/chunk-DPUOAfLB.d.ts +55 -0
  9. package/{types/datePartsOrder/datePartsOrder.d.ts → es/datePartsOrder/index.d.ts} +6 -4
  10. package/es/datePartsOrder/index.js +21 -1
  11. package/es/dateTimeFormat/index.d.ts +9 -0
  12. package/es/dateTimeFormat/index.js +16 -1
  13. package/{types/documentLang/documentLang.d.ts → es/documentLang/index.d.ts} +5 -3
  14. package/es/documentLang/index.js +69 -1
  15. package/es/index.d.ts +8 -0
  16. package/es/index.js +10 -1
  17. package/es/makeDraggable/index.d.ts +47 -0
  18. package/es/makeDraggable/index.js +148 -1
  19. package/es/overflowHandler/index.d.ts +104 -0
  20. package/es/overflowHandler/index.js +95 -1
  21. package/lib/carousel/index.js +4 -1
  22. package/lib/chunk-C5VBwGBG.js +443 -0
  23. package/lib/chunk-Dc0mzKQx.js +107 -0
  24. package/lib/datePartsOrder/index.js +23 -1
  25. package/lib/dateTimeFormat/index.js +17 -1
  26. package/lib/documentLang/index.js +72 -1
  27. package/lib/index.js +24 -1
  28. package/lib/makeDraggable/index.js +150 -1
  29. package/lib/overflowHandler/index.js +99 -1
  30. package/package.json +29 -12
  31. package/scss/carousel/_carousel.scss +34 -2
  32. package/es/carousel/carousel.js +0 -1
  33. package/es/carousel/swipeEvents.js +0 -1
  34. package/es/carousel/types.js +0 -0
  35. package/es/datePartsOrder/datePartsOrder.js +0 -1
  36. package/es/dateTimeFormat/absolute.js +0 -1
  37. package/es/dateTimeFormat/relative.js +0 -1
  38. package/es/documentLang/documentLang.js +0 -1
  39. package/es/makeDraggable/makeDraggable.js +0 -1
  40. package/es/overflowHandler/overflowHandler.js +0 -1
  41. package/lib/carousel/carousel.js +0 -1
  42. package/lib/carousel/swipeEvents.js +0 -1
  43. package/lib/carousel/types.js +0 -1
  44. package/lib/datePartsOrder/datePartsOrder.js +0 -1
  45. package/lib/dateTimeFormat/absolute.js +0 -1
  46. package/lib/dateTimeFormat/relative.js +0 -1
  47. package/lib/documentLang/documentLang.js +0 -1
  48. package/lib/makeDraggable/makeDraggable.js +0 -1
  49. package/lib/overflowHandler/overflowHandler.js +0 -1
  50. package/types/carousel/carousel.d.ts +0 -14
  51. package/types/carousel/index.d.ts +0 -8
  52. package/types/carousel/swipeEvents.d.ts +0 -9
  53. package/types/carousel/types.d.ts +0 -36
  54. package/types/datePartsOrder/index.d.ts +0 -7
  55. package/types/dateTimeFormat/absolute.d.ts +0 -30
  56. package/types/dateTimeFormat/index.d.ts +0 -12
  57. package/types/dateTimeFormat/relative.d.ts +0 -10
  58. package/types/documentLang/index.d.ts +0 -7
  59. package/types/index.d.ts +0 -13
  60. package/types/makeDraggable/index.d.ts +0 -7
  61. package/types/makeDraggable/makeDraggable.d.ts +0 -38
  62. package/types/overflowHandler/index.d.ts +0 -7
  63. package/types/overflowHandler/overflowHandler.d.ts +0 -85
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
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 * as relative from './relative';
8
- import * as absolute from './absolute';
9
- export declare const dateTimeFormat: {
10
- relative: typeof relative;
11
- absolute: typeof absolute;
12
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2024
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
- export declare function format(date: Date | number, options?: Partial<{
8
- locale: string;
9
- style: Intl.RelativeTimeFormatStyle;
10
- }>): string;
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 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
- export * from './documentLang';
package/types/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 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
- export * from '@internationalized/number';
8
- export type * from '@internationalized/number';
9
- export * from './carousel';
10
- export * from './datePartsOrder';
11
- export * from './dateTimeFormat';
12
- export * from './documentLang';
13
- export * from './overflowHandler';
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 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
- export * from './makeDraggable';
@@ -1,38 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2025, 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
- interface DraggableProps {
8
- /**
9
- * HTML element to move.
10
- */
11
- el: HTMLElement;
12
- /**
13
- * HTML element to initiate the drag (e.g., header).
14
- */
15
- dragHandle?: HTMLElement;
16
- /**
17
- * HTML element to focus on drag for keyboard interaction (e.g., Drag Icon).
18
- */
19
- focusableDragHandle?: HTMLElement;
20
- /**
21
- * Pixel value that defines the distance to move when dragging with arrow
22
- * keys.
23
- */
24
- dragStep?: number;
25
- /**
26
- * Pixel value that defines the distance to move when dragging with
27
- * shift+arrow keys.
28
- */
29
- shiftDragStep?: number;
30
- }
31
- /**
32
- * Makes a given element draggable using a handle element.
33
- *@param draggable - object which accepts el and optional attributes handle,focusableInHandle,dragStep and shiftDragStep
34
- */
35
- export declare const makeDraggable: ({ el, dragHandle, focusableDragHandle, dragStep, shiftDragStep, }: DraggableProps) => {
36
- cleanup: () => void;
37
- };
38
- export {};
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 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
- export * from './overflowHandler';
@@ -1,85 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2025, 2026
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
- /**
8
- * Calculates the size (width or height) of a given HTML element.
9
- *
10
- * This function performs an expensive calculation by temporarily changing the
11
- * display style of the element if it is not currently visible. It then uses
12
- * `getBoundingClientRect` to retrieve the size of the element.
13
- *
14
- * @param el - The HTML element whose size is to be calculated.
15
- * @param dimension - The dimension to measure ('width' or 'height').
16
- * @returns The size of the element in pixels. Returns 0 if the element is not provided.
17
- */
18
- export declare function getSize(el: HTMLElement | undefined, dimension: 'width' | 'height'): number;
19
- /**
20
- * Options for updating the overflow handler.
21
- * Determines which items should be visible and which should be hidden
22
- * based on the container size, item sizes, and other constraints.
23
- */
24
- export interface UpdateOverflowHandlerOptions {
25
- /** The container element that holds the items. */
26
- container: HTMLElement;
27
- /** An array of item elements to be managed for overflow. */
28
- items: HTMLElement[];
29
- /** An element that represents the offset, which can be shown or hidden based on overflow. Identified by `data-offset` attribute. */
30
- offset: HTMLElement | undefined;
31
- /** An array of sizes corresponding to each item in the `items` array. */
32
- sizes: number[];
33
- /** An array of sizes corresponding to each item in the fixed items array. */
34
- fixedSizes: number[];
35
- /** The size of the offset element. */
36
- offsetSize: number;
37
- /** The maximum number of items that can be visible at once. If undefined, all items can be visible. */
38
- maxVisibleItems?: number;
39
- /** The dimension to consider for overflow, either 'width' or 'height'. */
40
- dimension: 'width' | 'height';
41
- /** A callback function that is called when the visible or hidden items change. */
42
- onChange: (visibleItems: HTMLElement[], hiddenItems: HTMLElement[]) => void;
43
- /** An array of previously hidden items to compare against the new hidden items. */
44
- previousHiddenItems?: HTMLElement[];
45
- }
46
- /**
47
- * Updates the overflow handler by determining which items should be visible and which should be hidden.
48
- *
49
- * @param options - Configuration options for updating the overflow handler.
50
- * @returns An array of hidden items after the update.
51
- */
52
- export declare function updateOverflowHandler({ container, items, offset, sizes, fixedSizes, offsetSize, maxVisibleItems, dimension, onChange, previousHiddenItems, }: UpdateOverflowHandlerOptions): HTMLElement[];
53
- /**
54
- * Options for initializing an overflow handler.
55
- */
56
- export interface OverflowHandlerOptions {
57
- /**
58
- * The container element that holds the items. along with offset item
59
- */
60
- container: HTMLElement;
61
- /**
62
- * Maximum number of visible items. If provided, only this number of items will be shown.
63
- */
64
- maxVisibleItems?: number;
65
- /**
66
- * Callback function invoked when the visible and hidden items change.
67
- * @param visibleItems - The array of items that are currently visible.
68
- * @param hiddenItems - The array of items that are currently hidden.
69
- */
70
- onChange: (visibleItems: HTMLElement[], hiddenItems: HTMLElement[]) => void;
71
- /**
72
- * The dimension to consider for overflow calculations. Defaults to 'width'.
73
- */
74
- dimension?: 'width' | 'height';
75
- }
76
- /**
77
- * Represents an instance of an overflow handler.
78
- */
79
- export interface OverflowHandler {
80
- /**
81
- * Disconnects the overflow handler, cleaning up any event listeners or resources.
82
- */
83
- disconnect: () => void;
84
- }
85
- export declare function createOverflowHandler({ container, maxVisibleItems, onChange, dimension, }: OverflowHandlerOptions): OverflowHandler;