@canonical/react-ds-core 0.9.0-experimental.5 → 0.9.0-experimental.9

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 (103) hide show
  1. package/dist/esm/ui/Tooltip/Tooltip.js +18 -0
  2. package/dist/esm/ui/Tooltip/Tooltip.js.map +1 -0
  3. package/dist/esm/ui/Tooltip/common/TooltipArea/TooltipArea.js +29 -0
  4. package/dist/esm/ui/Tooltip/common/TooltipArea/TooltipArea.js.map +1 -0
  5. package/dist/esm/ui/Tooltip/common/TooltipArea/index.js +4 -0
  6. package/dist/esm/ui/Tooltip/common/TooltipArea/index.js.map +1 -0
  7. package/dist/esm/ui/Tooltip/common/TooltipArea/styles.css +13 -0
  8. package/dist/esm/ui/Tooltip/common/TooltipArea/types.js +2 -0
  9. package/dist/esm/ui/Tooltip/common/TooltipArea/types.js.map +1 -0
  10. package/dist/esm/ui/Tooltip/common/index.js +2 -0
  11. package/dist/esm/ui/Tooltip/common/index.js.map +1 -0
  12. package/dist/esm/ui/Tooltip/index.js +6 -0
  13. package/dist/esm/ui/Tooltip/index.js.map +1 -0
  14. package/dist/esm/ui/Tooltip/styles.css +111 -0
  15. package/dist/esm/ui/Tooltip/types.js +2 -0
  16. package/dist/esm/ui/Tooltip/types.js.map +1 -0
  17. package/dist/esm/ui/Tooltip/withTooltip.js +18 -0
  18. package/dist/esm/ui/Tooltip/withTooltip.js.map +1 -0
  19. package/dist/esm/ui/hooks/index.js +6 -0
  20. package/dist/esm/ui/hooks/index.js.map +1 -0
  21. package/dist/esm/ui/hooks/useDelayedToggle/index.js +3 -0
  22. package/dist/esm/ui/hooks/useDelayedToggle/index.js.map +1 -0
  23. package/dist/esm/ui/hooks/useDelayedToggle/types.js +2 -0
  24. package/dist/esm/ui/hooks/useDelayedToggle/types.js.map +1 -0
  25. package/dist/esm/ui/hooks/useDelayedToggle/useDelayedToggle.js +37 -0
  26. package/dist/esm/ui/hooks/useDelayedToggle/useDelayedToggle.js.map +1 -0
  27. package/dist/esm/ui/hooks/usePopup/index.js +3 -0
  28. package/dist/esm/ui/hooks/usePopup/index.js.map +1 -0
  29. package/dist/esm/ui/hooks/usePopup/types.js +2 -0
  30. package/dist/esm/ui/hooks/usePopup/types.js.map +1 -0
  31. package/dist/esm/ui/hooks/usePopup/usePopup.js +71 -0
  32. package/dist/esm/ui/hooks/usePopup/usePopup.js.map +1 -0
  33. package/dist/esm/ui/hooks/useResizeObserver/index.js +3 -0
  34. package/dist/esm/ui/hooks/useResizeObserver/index.js.map +1 -0
  35. package/dist/esm/ui/hooks/useResizeObserver/types.js +2 -0
  36. package/dist/esm/ui/hooks/useResizeObserver/types.js.map +1 -0
  37. package/dist/esm/ui/hooks/useResizeObserver/useResizeObserver.js +33 -0
  38. package/dist/esm/ui/hooks/useResizeObserver/useResizeObserver.js.map +1 -0
  39. package/dist/esm/ui/hooks/useWindowDimensions/index.js +3 -0
  40. package/dist/esm/ui/hooks/useWindowDimensions/index.js.map +1 -0
  41. package/dist/esm/ui/hooks/useWindowDimensions/types.js +2 -0
  42. package/dist/esm/ui/hooks/useWindowDimensions/types.js.map +1 -0
  43. package/dist/esm/ui/hooks/useWindowDimensions/useWindowDimensions.js +50 -0
  44. package/dist/esm/ui/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -0
  45. package/dist/esm/ui/hooks/useWindowFitment/index.js +3 -0
  46. package/dist/esm/ui/hooks/useWindowFitment/index.js.map +1 -0
  47. package/dist/esm/ui/hooks/useWindowFitment/types.js +2 -0
  48. package/dist/esm/ui/hooks/useWindowFitment/types.js.map +1 -0
  49. package/dist/esm/ui/hooks/useWindowFitment/useWindowFitment.js +192 -0
  50. package/dist/esm/ui/hooks/useWindowFitment/useWindowFitment.js.map +1 -0
  51. package/dist/esm/ui/index.js +1 -0
  52. package/dist/esm/ui/index.js.map +1 -1
  53. package/dist/types/ui/Tooltip/Tooltip.d.ts +12 -0
  54. package/dist/types/ui/Tooltip/Tooltip.d.ts.map +1 -0
  55. package/dist/types/ui/Tooltip/common/TooltipArea/TooltipArea.d.ts +10 -0
  56. package/dist/types/ui/Tooltip/common/TooltipArea/TooltipArea.d.ts.map +1 -0
  57. package/dist/types/ui/Tooltip/common/TooltipArea/index.d.ts +3 -0
  58. package/dist/types/ui/Tooltip/common/TooltipArea/index.d.ts.map +1 -0
  59. package/dist/types/ui/Tooltip/common/TooltipArea/types.d.ts +31 -0
  60. package/dist/types/ui/Tooltip/common/TooltipArea/types.d.ts.map +1 -0
  61. package/dist/types/ui/Tooltip/common/index.d.ts +2 -0
  62. package/dist/types/ui/Tooltip/common/index.d.ts.map +1 -0
  63. package/dist/types/ui/Tooltip/index.d.ts +5 -0
  64. package/dist/types/ui/Tooltip/index.d.ts.map +1 -0
  65. package/dist/types/ui/Tooltip/types.d.ts +16 -0
  66. package/dist/types/ui/Tooltip/types.d.ts.map +1 -0
  67. package/dist/types/ui/Tooltip/withTooltip.d.ts +11 -0
  68. package/dist/types/ui/Tooltip/withTooltip.d.ts.map +1 -0
  69. package/dist/types/ui/hooks/index.d.ts +6 -0
  70. package/dist/types/ui/hooks/index.d.ts.map +1 -0
  71. package/dist/types/ui/hooks/useDelayedToggle/index.d.ts +3 -0
  72. package/dist/types/ui/hooks/useDelayedToggle/index.d.ts.map +1 -0
  73. package/dist/types/ui/hooks/useDelayedToggle/types.d.ts +27 -0
  74. package/dist/types/ui/hooks/useDelayedToggle/types.d.ts.map +1 -0
  75. package/dist/types/ui/hooks/useDelayedToggle/useDelayedToggle.d.ts +13 -0
  76. package/dist/types/ui/hooks/useDelayedToggle/useDelayedToggle.d.ts.map +1 -0
  77. package/dist/types/ui/hooks/usePopup/index.d.ts +3 -0
  78. package/dist/types/ui/hooks/usePopup/index.d.ts.map +1 -0
  79. package/dist/types/ui/hooks/usePopup/types.d.ts +60 -0
  80. package/dist/types/ui/hooks/usePopup/types.d.ts.map +1 -0
  81. package/dist/types/ui/hooks/usePopup/usePopup.d.ts +18 -0
  82. package/dist/types/ui/hooks/usePopup/usePopup.d.ts.map +1 -0
  83. package/dist/types/ui/hooks/useResizeObserver/index.d.ts +3 -0
  84. package/dist/types/ui/hooks/useResizeObserver/index.d.ts.map +1 -0
  85. package/dist/types/ui/hooks/useResizeObserver/types.d.ts +7 -0
  86. package/dist/types/ui/hooks/useResizeObserver/types.d.ts.map +1 -0
  87. package/dist/types/ui/hooks/useResizeObserver/useResizeObserver.d.ts +8 -0
  88. package/dist/types/ui/hooks/useResizeObserver/useResizeObserver.d.ts.map +1 -0
  89. package/dist/types/ui/hooks/useWindowDimensions/index.d.ts +3 -0
  90. package/dist/types/ui/hooks/useWindowDimensions/index.d.ts.map +1 -0
  91. package/dist/types/ui/hooks/useWindowDimensions/types.d.ts +21 -0
  92. package/dist/types/ui/hooks/useWindowDimensions/types.d.ts.map +1 -0
  93. package/dist/types/ui/hooks/useWindowDimensions/useWindowDimensions.d.ts +6 -0
  94. package/dist/types/ui/hooks/useWindowDimensions/useWindowDimensions.d.ts.map +1 -0
  95. package/dist/types/ui/hooks/useWindowFitment/index.d.ts +3 -0
  96. package/dist/types/ui/hooks/useWindowFitment/index.d.ts.map +1 -0
  97. package/dist/types/ui/hooks/useWindowFitment/types.d.ts +66 -0
  98. package/dist/types/ui/hooks/useWindowFitment/types.d.ts.map +1 -0
  99. package/dist/types/ui/hooks/useWindowFitment/useWindowFitment.d.ts +4 -0
  100. package/dist/types/ui/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -0
  101. package/dist/types/ui/index.d.ts +1 -0
  102. package/dist/types/ui/index.d.ts.map +1 -1
  103. package/package.json +4 -4
@@ -0,0 +1,192 @@
1
+ import { useCallback, useEffect, useMemo, useRef, } from "react";
2
+ import { useResizeObserver } from "../useResizeObserver/index.js";
3
+ import { useWindowDimensions } from "../useWindowDimensions/index.js";
4
+ const useWindowFitment = ({ preferredDirections = ["top", "bottom", "left", "right"], distance = "0px", gutter = "0px", maxWidth = "350px", resizeDelay = 150, scrollDelay = 150, onBestPositionChange, }) => {
5
+ // This hook is not intended to be used on the server.
6
+ if (typeof window === "undefined") {
7
+ return {
8
+ targetRef: { current: null },
9
+ popupRef: { current: null },
10
+ bestPosition: undefined,
11
+ popupPositionStyle: {},
12
+ };
13
+ }
14
+ const targetRef = useRef(null);
15
+ const popupRef = useRef(null);
16
+ const prevBestPosition = useRef(undefined);
17
+ const windowDimensions = useWindowDimensions({ resizeDelay, scrollDelay });
18
+ const targetSize = useResizeObserver(targetRef?.current);
19
+ const popupSize = useResizeObserver(popupRef?.current);
20
+ /** The distance, in pixels, between the target and the popup. */
21
+ const distanceAsPixelsNumber = useMemo(() => Number.parseInt(distance, 10) || 0, [distance]);
22
+ /** The bounds of the window, accounting for the `gutter` prop. */
23
+ const bounds = useMemo(() => {
24
+ const gutterValues = gutter
25
+ .split(" ")
26
+ .map((val) => Number.parseInt(val, 10));
27
+ const topGutter = gutterValues[0] || 0;
28
+ const rightGutter = gutterValues[1] || gutterValues[0] || 0;
29
+ const bottomGutter = gutterValues[2] || gutterValues[0] || 0;
30
+ const leftGutter = gutterValues[3] || gutterValues[1] || gutterValues[0] || 0;
31
+ return {
32
+ top: topGutter,
33
+ left: leftGutter,
34
+ right: windowDimensions.windowWidth - rightGutter,
35
+ bottom: windowDimensions.windowHeight - bottomGutter,
36
+ };
37
+ }, [gutter, windowDimensions]);
38
+ /**
39
+ * Calculate the relative position of the popup when oriented in a given direction.
40
+ * @param direction The side of the target element to position the popup on.
41
+ * @param targetRect The bounding client rect of the target element.
42
+ * @param popupRect The bounding client rect of the popup element.
43
+ * @returns The calculated relative position of the popup.
44
+ */
45
+ const calculateRelativePosition = useCallback((direction, targetRect, popupRect) => {
46
+ let left = 0;
47
+ let top = 0;
48
+ /*
49
+ We use left and top offsets to position the popup relative to the target element.
50
+ Then, we apply a margin on the opposite side of the popup to create a buffer zone between the target and the popup, to prevent a mouseleave event when moving from the target to the popup.
51
+ The fake margin is already included in `targetRect` dimensions, as it is rendered hidden at least once before the popup is shown.
52
+ In cases where `targetRect` is not included in the calculation, we add `distanceAsPixelsNumber` to account for the fake margin.
53
+ */
54
+ // horizontal offset
55
+ switch (direction) {
56
+ case "top":
57
+ case "bottom":
58
+ left = (targetRect.width - popupRect.width) / 2;
59
+ break;
60
+ case "right":
61
+ left = targetRect.width;
62
+ break;
63
+ case "left":
64
+ left = -(popupRect.width + distanceAsPixelsNumber);
65
+ break;
66
+ }
67
+ // vertical offset
68
+ switch (direction) {
69
+ case "top":
70
+ top = -(popupRect.height + distanceAsPixelsNumber);
71
+ break;
72
+ case "bottom":
73
+ top = targetRect.height;
74
+ break;
75
+ case "right":
76
+ case "left":
77
+ top = (targetRect.height - popupRect.height) / 2;
78
+ break;
79
+ }
80
+ return { left, top };
81
+ }, [distanceAsPixelsNumber]);
82
+ /**
83
+ * Check if the popup fits within the window. Accounts for `gutter` prop.
84
+ * @param candidatePosition The absolute position of the popup
85
+ * @param popupRect The bounding client rect of the popup element.
86
+ * @returns Whether the popup fits within the window.
87
+ */
88
+ const fitsInWindow = useCallback((candidatePosition, popupRect) => {
89
+ // Absolute position of the popup's vertices, relative to the viewport
90
+ const vertices = {
91
+ top: candidatePosition.top,
92
+ right: candidatePosition.left + popupRect.width,
93
+ bottom: candidatePosition.top + popupRect.height,
94
+ left: candidatePosition.left,
95
+ };
96
+ return (vertices.top >= bounds.top &&
97
+ vertices.right <= bounds.right &&
98
+ vertices.bottom <= bounds.bottom &&
99
+ vertices.left >= bounds.left);
100
+ }, [bounds]);
101
+ /**
102
+ * Find the best position for the popup based on the preferred directions.
103
+ * @param targetRect The bounding client rect of the target element.
104
+ * @param popupRect The bounding client rect of the popup element.
105
+ * @returns The best absolute position for the popup.
106
+ */
107
+ const findBestPosition = useCallback((targetRect, popupRect, preferredDirections) => {
108
+ let fallbackPosition = undefined;
109
+ if (!preferredDirections.length) {
110
+ throw new Error("Preferred directions must not be empty.");
111
+ }
112
+ for (const direction of preferredDirections) {
113
+ const relativePosition = calculateRelativePosition(direction, targetRect, popupRect);
114
+ const absolutePosition = {
115
+ top: targetRect.top + relativePosition.top,
116
+ left: targetRect.left + relativePosition.left,
117
+ };
118
+ const bestPositionForName = {
119
+ positionName: direction,
120
+ position: absolutePosition,
121
+ fits: fitsInWindow(absolutePosition, popupRect),
122
+ };
123
+ // Save the calculated position as a fallback in case no other position fits.
124
+ fallbackPosition ||= bestPositionForName;
125
+ // If this position fits, use it.
126
+ if (bestPositionForName.fits) {
127
+ return bestPositionForName;
128
+ }
129
+ }
130
+ // biome-ignore lint/style/noNonNullAssertion: Fallback position is always defined here, due to the loop above and the thrown error if preferredDirections is empty.
131
+ return fallbackPosition;
132
+ }, [calculateRelativePosition, fitsInWindow]);
133
+ /** The best possible position for the popup. */
134
+ const bestPosition = useMemo(() => {
135
+ if (targetRef.current &&
136
+ popupRef.current &&
137
+ windowDimensions &&
138
+ popupSize &&
139
+ targetSize)
140
+ return findBestPosition(targetRef.current.getBoundingClientRect(), popupRef.current.getBoundingClientRect(), preferredDirections);
141
+ }, [
142
+ findBestPosition,
143
+ preferredDirections,
144
+ windowDimensions,
145
+ popupSize,
146
+ targetSize,
147
+ ]);
148
+ /** Notify the consumer when the best position changes. */
149
+ useEffect(() => {
150
+ if (bestPosition?.positionName !== prevBestPosition.current?.positionName) {
151
+ prevBestPosition.current = bestPosition;
152
+ if (onBestPositionChange)
153
+ onBestPositionChange(bestPosition);
154
+ }
155
+ }, [bestPosition, onBestPositionChange]);
156
+ const fakeMargin = useMemo(() => {
157
+ let side = "Top";
158
+ switch (bestPosition?.positionName) {
159
+ case "top":
160
+ side = "Bottom";
161
+ break;
162
+ case "bottom":
163
+ side = "Top";
164
+ break;
165
+ case "left":
166
+ side = "Right";
167
+ break;
168
+ case "right":
169
+ side = "Left";
170
+ break;
171
+ }
172
+ return {
173
+ [`margin${side}`]: `${distanceAsPixelsNumber}px`,
174
+ };
175
+ }, [bestPosition, distanceAsPixelsNumber]);
176
+ /** The style object to be applied to the popup element. */
177
+ const popupPositionStyle = useMemo(() => ({
178
+ maxWidth: maxWidth,
179
+ top: bestPosition?.position?.top || 0,
180
+ left: bestPosition?.position?.left || 0,
181
+ // Fake margin around the popup to prevent a mouseleave event when moving from the target to the popup.
182
+ ...fakeMargin,
183
+ }), [bestPosition, maxWidth, fakeMargin]);
184
+ return {
185
+ targetRef,
186
+ popupRef,
187
+ bestPosition,
188
+ popupPositionStyle,
189
+ };
190
+ };
191
+ export default useWindowFitment;
192
+ //# sourceMappingURL=useWindowFitment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWindowFitment.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowFitment/useWindowFitment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAStE,MAAM,gBAAgB,GAAG,CAAC,EACxB,mBAAmB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EACxD,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,KAAK,EACd,QAAQ,GAAG,OAAO,EAClB,WAAW,GAAG,GAAG,EACjB,WAAW,GAAG,GAAG,EACjB,oBAAoB,GACE,EAA0B,EAAE;IAClD,sDAAsD;IACtD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO;YACL,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC5B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC3B,YAAY,EAAE,SAAS;YACvB,kBAAkB,EAAE,EAAE;SACvB,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACrD,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AG,OAAO,CAAC;gBACf,MAAM;YACR,KAAK,OAAO;gBACV,IAAI,GAAG,MAAM,CAAC;gBACd,MAAM;QACV,CAAC;QACD,OAAO;YACL,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,GAAG,sBAAsB,IAAI;SACjD,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAE3C,2DAA2D;IAC3D,MAAM,kBAAkB,GAAkB,OAAO,CAC/C,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,QAAQ;QAClB,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QACrC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC;QACvC,uGAAuG;QACvG,GAAG,UAAU;KACd,CAAC,EACF,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,CAAC,CACrC,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,kBAAkB;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./Button/index.js";
2
2
  export * from "./Chip/index.js";
3
+ export * from "./Tooltip/index.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type React from "react";
2
+ import "./styles.css";
3
+ import type { TooltipProps } from "./types.js";
4
+ /**
5
+ * The Tooltip component is used to display a message.
6
+ * This component is just the "message" part of the tooltip, and has no interactivity or positioning logic. It is generally not consumed directly, but rather in one of two ways
7
+ * - The [TooltipArea](?path=/docs/tooltip-tooltiparea--docs) component
8
+ * - The [withTooltip](?path=/docs/tooltip-withtooltip--docs) HOC
9
+ */
10
+ declare const Tooltip: ({ id, children, className, style, ref, isOpen, zIndex, onPointerEnter, onFocus, }: TooltipProps) => React.ReactElement;
11
+ export default Tooltip;
12
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../src/ui/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C;;;;;GAKG;AACH,QAAA,MAAM,OAAO,sFAUV,YAAY,KAAG,KAAK,CAAC,YAmBvB,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ReactElement } from "react";
2
+ import type { TooltipAreaProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * Wraps a target element with a tooltip.
6
+ * This component allows you to attach a tooltip to any JSX fragment.
7
+ */
8
+ declare const TooltipArea: ({ children, Message, distance, targetElementId, targetElementClassName, targetElementStyle, messageElementClassName, messageElementStyle, parentElement, ...props }: TooltipAreaProps) => ReactElement;
9
+ export default TooltipArea;
10
+ //# sourceMappingURL=TooltipArea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipArea.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/Tooltip/common/TooltipArea/TooltipArea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,cAAc,CAAC;AAKtB;;;GAGG;AACH,QAAA,MAAM,WAAW,wKAWd,gBAAgB,KAAG,YA8DrB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as TooltipArea } from "./TooltipArea.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/Tooltip/common/TooltipArea/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,cAAc,YAAY,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import type { UsePopupProps } from "../../../hooks/index.js";
3
+ export interface TooltipAreaProps extends UsePopupProps {
4
+ /**
5
+ * The target element to which the tooltip should be attached.
6
+ * This can be any valid React element.
7
+ */
8
+ children: ReactNode;
9
+ /**
10
+ * The content of the tooltip. This can be a string or any valid React node.
11
+ */
12
+ Message: ReactNode;
13
+ /** ID applied to the target element */
14
+ targetElementId?: string;
15
+ /** Class name applied to the target element */
16
+ targetElementClassName?: string;
17
+ /** Style object applied to the target element */
18
+ targetElementStyle?: CSSProperties;
19
+ /** Class name applied to the tooltip/message element */
20
+ messageElementClassName?: string;
21
+ /** Styles applied to the tooltip/message element */
22
+ messageElementStyle?: CSSProperties;
23
+ /**
24
+ * The element to which the tooltip should be attached.
25
+ * This can be any valid React element.
26
+ * When not provided, the tooltip will be attached to the `document.body`.
27
+ * No default is provided at the TooltipArea signature level in order to prevent the component from failing builds in server environments, where `document` is not available.
28
+ */
29
+ parentElement?: HTMLElement;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/Tooltip/common/TooltipArea/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,wDAAwD;IACxD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,aAAa,CAAC;IACpC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export * from "./TooltipArea/index.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/Tooltip/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { default as Tooltip } from "./Tooltip.js";
2
+ export { default as withTooltip } from "./withTooltip.js";
3
+ export * from "./common/index.js";
4
+ export * from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/Tooltip/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { CSSProperties, FocusEventHandler, PointerEventHandler, ReactNode, RefObject } from "react";
2
+ export interface TooltipProps {
3
+ id?: string;
4
+ className?: string;
5
+ children: ReactNode;
6
+ style?: CSSProperties;
7
+ /** Whether the tooltip is open or not */
8
+ isOpen?: boolean;
9
+ /** Ref to the tooltip, useful for calculating its dimensions */
10
+ ref?: RefObject<HTMLDivElement | null>;
11
+ /** The z-index of the tooltip */
12
+ zIndex?: number;
13
+ onPointerEnter?: PointerEventHandler;
14
+ onFocus?: FocusEventHandler;
15
+ }
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,SAAS,EACV,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,YAAY;IAE3B,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,EAAE,SAAS,CAAC;IAEpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,GAAG,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvC,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B"}
@@ -0,0 +1,11 @@
1
+ import { type ComponentType, type FC, type ReactNode } from "react";
2
+ import type { UsePopupProps } from "../hooks/index.js";
3
+ /**
4
+ * A higher-order component that wraps a component with a tooltip.
5
+ * @param Component The component function to wrap. If you need to use a Node instead of a function, use [`TooltipArea`](/?path=/docs/tooltip-withtooltip--docs) instead.
6
+ * @param Message The content of the tooltip
7
+ * @param popupProps The props to pass to the usePopup hook
8
+ */
9
+ declare const withTooltip: <TProps extends object>(Component: ComponentType<TProps>, Message: ReactNode, popupProps?: UsePopupProps) => FC<TProps>;
10
+ export default withTooltip;
11
+ //# sourceMappingURL=withTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTooltip.d.ts","sourceRoot":"","sources":["../../../../src/ui/Tooltip/withTooltip.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,KAAK,aAAa,EAClB,KAAK,EAAE,EAEP,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,MAAM,SAAS,MAAM,aAC7B,aAAa,CAAC,MAAM,CAAC,WACvB,SAAS,eACN,aAAa,KACxB,EAAE,CAAC,MAAM,CAkBX,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./useDelayedToggle/index.js";
2
+ export * from "./usePopup/index.js";
3
+ export * from "./useWindowFitment/index.js";
4
+ export * from "./useResizeObserver/index.js";
5
+ export * from "./useWindowDimensions/index.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as useDelayedToggle } from "./useDelayedToggle.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useDelayedToggle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,cAAc,YAAY,CAAC"}
@@ -0,0 +1,27 @@
1
+ export interface UseDelayedToggleProps {
2
+ /**
3
+ * Delay in milliseconds before setting the flag to true
4
+ * Defaults to 150ms.
5
+ */
6
+ activateDelay?: number;
7
+ /**
8
+ * Delay in milliseconds before setting the flag to false
9
+ * Defaults to 150ms.
10
+ */
11
+ deactivateDelay?: number;
12
+ /** A callback to be called when the flag is set to true. */
13
+ onActivate?: DelayedToggleActivateEventHandler;
14
+ /** A callback to be called when the flag is set to false. */
15
+ onDeactivate?: DelayedToggleActivateEventHandler;
16
+ }
17
+ export interface UseDelayedToggleResult {
18
+ /** The current state of the flag. */
19
+ flag: boolean;
20
+ /** Sets the flag to true after the specified delay. */
21
+ activate: DelayedToggleActivateEventHandler;
22
+ /** Sets the flag to false after the specified delay. */
23
+ deactivate: DelayedToggleActivateEventHandler;
24
+ }
25
+ /** Event handler for delayed toggle activation events. */
26
+ export type DelayedToggleActivateEventHandler = (event: Event) => void;
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useDelayedToggle/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,iCAAiC,CAAC;IAC/C,6DAA6D;IAC7D,YAAY,CAAC,EAAE,iCAAiC,CAAC;CAClD;AAED,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,QAAQ,EAAE,iCAAiC,CAAC;IAC5C,wDAAwD;IACxD,UAAU,EAAE,iCAAiC,CAAC;CAC/C;AAED,0DAA0D;AAC1D,MAAM,MAAM,iCAAiC,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { UseDelayedToggleProps, UseDelayedToggleResult } from "./types.js";
2
+ /**
3
+ * Hook to toggle a flag with a delay.
4
+ * Allows the caller to `activate()` or `deactivate()` some flag
5
+ * @param activateDelay The delay in milliseconds before setting the flag to true.
6
+ * @param deactivateDelay The delay in milliseconds before setting the flag to false.
7
+ * @param onActivate A callback to be called when the flag is set to true.
8
+ * @param onDeactivate A callback to be called when the flag is set to false.
9
+ * @returns The current state of the flag, functions to activate and deactivate the flag.
10
+ */
11
+ declare const useDelayedToggle: ({ activateDelay, deactivateDelay, onActivate, onDeactivate, }: UseDelayedToggleProps) => UseDelayedToggleResult;
12
+ export default useDelayedToggle;
13
+ //# sourceMappingURL=useDelayedToggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDelayedToggle.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useDelayedToggle/useDelayedToggle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEhF;;;;;;;;GAQG;AACH,QAAA,MAAM,gBAAgB,kEAKnB,qBAAqB,KAAG,sBAyC1B,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as usePopup } from "./usePopup.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/usePopup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,cAAc,YAAY,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { CSSProperties, FocusEventHandler, PointerEventHandler, RefObject } from "react";
2
+ import type { UseDelayedToggleProps } from "../useDelayedToggle/index.js";
3
+ import type { UseWindowFitmentProps, UseWindowFitmentResult } from "../useWindowFitment/index.js";
4
+ export interface UsePopupProps extends UseWindowFitmentProps, UseDelayedToggleProps {
5
+ /** A callback to be called when the target element is focused. */
6
+ onFocus?: FocusEventHandler;
7
+ /** A callback to be called when the target element loses focus. */
8
+ onBlur?: FocusEventHandler;
9
+ /** A callback to be called when the mouse enters the target element. */
10
+ onEnter?: PointerEventHandler;
11
+ /** A callback to be called when the mouse leaves the target */
12
+ onLeave?: PointerEventHandler;
13
+ /** A callback to be called when the popup is shown. */
14
+ onShow?: (event?: Event) => void;
15
+ /** A callback to be called when the popup is hidden. */
16
+ onHide?: (event?: Event) => void;
17
+ }
18
+ export interface UsePopupResult extends UseWindowFitmentResult {
19
+ /**
20
+ * A ref to be attached to the target element.
21
+ */
22
+ targetRef: RefObject<HTMLDivElement | null>;
23
+ /**
24
+ * A ref to be attached to the popup element.
25
+ */
26
+ popupRef: RefObject<HTMLDivElement | null>;
27
+ /**
28
+ * The style object to be applied to the popup element.
29
+ */
30
+ popupPositionStyle: CSSProperties;
31
+ /**
32
+ * A unique ID for the popup element. This can be used to associate a trigger with a popup, using `aria-describedby`.
33
+ */
34
+ popupId: string;
35
+ /**
36
+ * Whether the popup is currently open.
37
+ */
38
+ isOpen: boolean;
39
+ /**
40
+ * Whether the target element is currently focused.
41
+ */
42
+ isFocused: boolean;
43
+ /**
44
+ * Event handler for when the target element is focused.
45
+ */
46
+ handleTriggerFocus: FocusEventHandler;
47
+ /**
48
+ * Event handler for when the target element loses focus.
49
+ */
50
+ handleTriggerBlur: FocusEventHandler;
51
+ /**
52
+ * Event handler for when the mouse enters the target element.
53
+ */
54
+ handleTriggerEnter: PointerEventHandler;
55
+ /**
56
+ * Event handler for when the mouse leaves the target element.
57
+ */
58
+ handleTriggerLeave: PointerEventHandler;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/usePopup/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,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types.js";
2
+ /**
3
+ * Manages the state of a popup.
4
+ * @param isOpen An override for the open state.
5
+ * @param deactivateDelay The delay in milliseconds before setting the flag to false.
6
+ * @param activateDelay The delay in milliseconds before setting the flag to true.
7
+ * @param onEnter A callback to be called when the mouse enters the target element.
8
+ * @param onLeave A callback to be called when the mouse leaves the target element.
9
+ * @param onFocus A callback to be called when the target element is focused.
10
+ * @param onBlur A callback to be called when the target element loses focus.
11
+ * @param onShow A callback to be called when the popup is shown.
12
+ * @param onHide A callback to be called when the popup is hidden.
13
+ * @param props The props to be passed to the useWindowFitment hook.
14
+ * @returns The current state of the popup, and event handlers for the target element.
15
+ */
16
+ declare const usePopup: ({ isOpen: isOpenProp, deactivateDelay, activateDelay, onEnter, onLeave, onFocus, onBlur, onShow, onHide, ...props }: UsePopupProps) => UsePopupResult;
17
+ export default usePopup;
18
+ //# sourceMappingURL=usePopup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePopup.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/usePopup/usePopup.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,QAAQ,wHAWX,aAAa,KAAG,cAuElB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as useResizeObserver } from "./useResizeObserver.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useResizeObserver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACtE,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface UseResizeObserverResult {
2
+ /** The width of the observed element */
3
+ width: number;
4
+ /** The height of the observed element */
5
+ height: number;
6
+ }
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useResizeObserver/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,8 @@
1
+ import type { UseResizeObserverResult } from "./types.js";
2
+ /**
3
+ * Hook to observe the size of an element.
4
+ * @param element The element to observe.
5
+ * @returns The size of the element.
6
+ */
7
+ export default function useResizeObserver<TElement extends HTMLElement>(element?: TElement | null): UseResizeObserverResult;
8
+ //# sourceMappingURL=useResizeObserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useResizeObserver/useResizeObserver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,QAAQ,SAAS,WAAW,EACpE,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,GACxB,uBAAuB,CA6BzB"}
@@ -0,0 +1,3 @@
1
+ export { default as useWindowDimensions } from "./useWindowDimensions.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowDimensions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,cAAc,YAAY,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface UseWindowDimensionProps {
2
+ /** Delay in milliseconds before the resize event is triggered */
3
+ resizeDelay?: number;
4
+ /** Delay in milliseconds before the scroll event is triggered */
5
+ scrollDelay?: number;
6
+ /** Callback to be called when the window is resized */
7
+ onResize?: (dimensions: UseWindowDimensionsResult) => void;
8
+ /** Callback to be called when the window is scrolled */
9
+ onScroll?: (dimensions: UseWindowDimensionsResult) => void;
10
+ }
11
+ export interface UseWindowDimensionsResult {
12
+ /** The width of the window */
13
+ windowWidth: number;
14
+ /** The height of the window */
15
+ windowHeight: number;
16
+ /** The horizontal scroll position */
17
+ scrollWidth: number;
18
+ /** The vertical scroll position */
19
+ scrollHeight: number;
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowDimensions/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,yBAAyB,KAAK,IAAI,CAAC;IAC3D,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,yBAAyB,KAAK,IAAI,CAAC;CAC5D;AAED,MAAM,WAAW,yBAAyB;IACxC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,6 @@
1
+ import type { UseWindowDimensionProps, UseWindowDimensionsResult } from "./types.js";
2
+ /**
3
+ * Hook to get the window dimensions and scroll position.
4
+ */
5
+ export default function useWindowDimensions({ onResize, onScroll, resizeDelay, scrollDelay, }?: UseWindowDimensionProps): UseWindowDimensionsResult;
6
+ //# sourceMappingURL=useWindowDimensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWindowDimensions.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowDimensions/useWindowDimensions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,QAAQ,EACR,QAAQ,EACR,WAAiB,EACjB,WAAiB,GAClB,GAAE,uBAA4B,GAAG,yBAAyB,CAoD1D"}
@@ -0,0 +1,3 @@
1
+ export { default as useWindowFitment } from "./useWindowFitment.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowFitment/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,cAAc,YAAY,CAAC"}