@eightshift/ui-components 1.7.2 → 1.8.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 (111) hide show
  1. package/dist/{Button-VbCAu4hd.js → Button-Xa6Ny0p_.js} +7 -7
  2. package/dist/{Color-BpLubxWI.js → Color-VsesNqCf.js} +5 -17
  3. package/dist/{ColorSwatch-CinC14s3.js → ColorSwatch-xOFAZO_h.js} +4 -4
  4. package/dist/ComboBox-CP_SqnqT.js +1886 -0
  5. package/dist/Dialog-jcIYer1n.js +2177 -0
  6. package/dist/{FieldError-BttM1Nxd.js → FieldError-BPe3YgNH.js} +2 -2
  7. package/dist/{FocusScope-CtCX0OGo.js → FocusScope-uV-xoRHT.js} +8 -9
  8. package/dist/{Group-XzWUooix.js → Group-Bvmb49y7.js} +5 -5
  9. package/dist/{Heading-DZelepHV.js → Heading-Bfhyr4ZC.js} +1 -1
  10. package/dist/{Hidden-CcFqOzrp.js → Hidden-7ZhNuLM9.js} +2 -2
  11. package/dist/{Input-CV1qVS6t.js → Input-C2dTSp9z.js} +10 -10
  12. package/dist/{Label-BwqMVkuV.js → Label-DqNX_sAU.js} +2 -2
  13. package/dist/{List-Bx2anbX-.js → List-C7L49CxW.js} +1 -1
  14. package/dist/{ListBox-DuZPdnkk.js → ListBox-B9r1QoSm.js} +19 -18
  15. package/dist/{NumberFormatter-U_Gx0UDq.js → NumberFormatter-DA8u1Ot7.js} +4 -6
  16. package/dist/OverlayArrow-ClRhYjQu.js +567 -0
  17. package/dist/{Select-c7902d94.esm-DtzFQzf-.js → Select-aab027f3.esm-B8nEum75.js} +4 -4
  18. package/dist/{SelectionManager-x27KqnAT.js → SelectionManager-DP537Pbu.js} +177 -141
  19. package/dist/{Separator-BM58t3PP.js → Separator-Dmxzf3m_.js} +62 -52
  20. package/dist/{Slider-D9Cs6yKr.js → Slider-BgHBCyI7.js} +16 -14
  21. package/dist/{Text-BVIXT8qq.js → Text-DImhB4rT.js} +1 -1
  22. package/dist/{VisuallyHidden-WhC7vZaL.js → VisuallyHidden-wryJF4qQ.js} +2 -2
  23. package/dist/assets/style.css +1 -1
  24. package/dist/assets/wp-ui-enhancements.css +1 -1
  25. package/dist/components/animated-visibility/animated-visibility.js +141 -113
  26. package/dist/components/base-control/base-control.js +1 -1
  27. package/dist/components/button/button.js +10 -7
  28. package/dist/components/checkbox/checkbox.js +19 -11
  29. package/dist/components/color-pickers/color-picker.js +1 -1
  30. package/dist/components/color-pickers/color-swatch.js +3 -3
  31. package/dist/components/color-pickers/gradient-editor.js +2 -2
  32. package/dist/components/color-pickers/solid-color-picker.js +21 -21
  33. package/dist/components/component-toggle/component-toggle.js +1 -1
  34. package/dist/components/draggable/draggable-handle.js +2 -2
  35. package/dist/components/draggable/draggable.js +2 -2
  36. package/dist/components/draggable-list/draggable-list-item.js +2 -2
  37. package/dist/components/draggable-list/draggable-list.js +2 -2
  38. package/dist/components/expandable/expandable.js +3 -3
  39. package/dist/components/index.js +8 -4
  40. package/dist/components/input-field/input-field.js +7 -7
  41. package/dist/components/item-collection/item-collection.js +1 -1
  42. package/dist/components/link-input/link-input.js +10 -1872
  43. package/dist/components/list-box/list-box.js +2 -2
  44. package/dist/components/matrix-align/matrix-align.js +2 -2
  45. package/dist/components/menu/menu.js +7 -974
  46. package/dist/components/modal/modal.js +7 -7
  47. package/dist/components/number-picker/number-picker.js +10 -10
  48. package/dist/components/option-select/option-select.js +1 -1
  49. package/dist/components/options-panel/options-panel.js +1 -1
  50. package/dist/components/placeholders/file-placeholder.js +1 -1
  51. package/dist/components/popover/popover.js +2 -2
  52. package/dist/components/radio/radio.js +13 -13
  53. package/dist/components/repeater/repeater-item.js +1 -1
  54. package/dist/components/repeater/repeater.js +2 -2
  55. package/dist/components/responsive/mini-responsive.js +3 -3
  56. package/dist/components/responsive/responsive-legacy.js +2 -2
  57. package/dist/components/responsive/responsive.js +2 -2
  58. package/dist/components/responsive-preview/responsive-preview.js +1 -1
  59. package/dist/components/select/async-multi-select.js +3 -3
  60. package/dist/components/select/async-single-select.js +2 -2
  61. package/dist/components/select/custom-select-default-components.js +1 -1
  62. package/dist/components/select/multi-select-components.js +1 -1
  63. package/dist/components/select/multi-select.js +3 -3
  64. package/dist/components/select/react-select-component-wrappers.js +1 -1
  65. package/dist/components/select/single-select.js +2 -2
  66. package/dist/components/select/v2/async-select.js +307 -0
  67. package/dist/components/select/v2/shared.js +24 -0
  68. package/dist/components/select/v2/single-select.js +993 -0
  69. package/dist/components/slider/column-config-slider.js +3 -3
  70. package/dist/components/slider/slider.js +3 -3
  71. package/dist/components/slider/utils.js +1 -1
  72. package/dist/components/tabs/tabs.js +16 -16
  73. package/dist/components/toggle/switch.js +6 -6
  74. package/dist/components/toggle/toggle.js +1 -1
  75. package/dist/components/toggle-button/toggle-button.js +55 -12
  76. package/dist/components/tooltip/tooltip.js +532 -8
  77. package/dist/{context-Cs-ZD1nu.js → context-BI3VdU0Z.js} +2 -2
  78. package/dist/{default-i18n-DRnM8y4w.js → default-i18n-CM1-Xvzf.js} +183 -176
  79. package/dist/{focusSafely-CgFLw4FA.js → focusSafely-Cl9cN7Qx.js} +14 -14
  80. package/dist/icons/icons.js +19 -0
  81. package/dist/icons/jsx-svg.js +16 -3
  82. package/dist/{index-a301f526.esm-BMg114iK.js → index-641ee5b8.esm-BclOH4xf.js} +165 -29
  83. package/dist/{index-BTCzc3zb.js → index-D0mHceYg.js} +81 -17
  84. package/dist/index.js +7 -3
  85. package/dist/{multi-select-components-DTvEidE3.js → multi-select-components-BGQBvx-z.js} +55 -44
  86. package/dist/{react-jsx-parser.min-B5HVwW_W.js → react-jsx-parser.min-CVit0rZn.js} +5620 -7409
  87. package/dist/{react-select-async.esm-CxA8wpeT.js → react-select-async.esm-B8kK0aL4.js} +3 -3
  88. package/dist/{react-select.esm-CeE7o5M9.js → react-select.esm-ucYwBxq5.js} +3 -3
  89. package/dist/{textSelection-CvK0YHTZ.js → textSelection-DDDNsS-g.js} +1 -1
  90. package/dist/{useButton-Cy9eEev7.js → useButton-CRKy9xk2.js} +4 -4
  91. package/dist/{useEvent-LZebwyrb.js → useEvent-D54lIBrO.js} +1 -1
  92. package/dist/{useFocusRing-BMOTWmOx.js → useFocusRing-DKxoCzVD.js} +1 -1
  93. package/dist/{useFocusable-ByyKSVQv.js → useFocusable-CPKTGWPn.js} +4 -4
  94. package/dist/{useFormReset-B8m1uz1J.js → useFormReset-CTp--h9B.js} +1 -1
  95. package/dist/{useFormValidationState-BjMhz_VI.js → useFormValidation-BNBrliSj.js} +92 -88
  96. package/dist/{useLabel-B6uO0wVK.js → useLabel-CzGdEzIq.js} +2 -2
  97. package/dist/{useLabels-5dFkeiXx.js → useLabels-eGSmZC_Z.js} +1 -1
  98. package/dist/{useListState-eKxv7HPC.js → useListState-D7mE1Y00.js} +1 -1
  99. package/dist/{useLocalizedStringFormatter-BaKmjFNp.js → useLocalizedStringFormatter-BBeUyA9l.js} +1 -1
  100. package/dist/{useNumberField-DMMUTZ-h.js → useNumberField-BmEJmL3K.js} +27 -20
  101. package/dist/{useNumberFormatter-Cyx5Dxkf.js → useNumberFormatter-CTY_UZxq.js} +2 -2
  102. package/dist/{usePress-D8nPoIQm.js → usePress-BG9At5Lb.js} +4 -4
  103. package/dist/{useSingleSelectListState-CABciySJ.js → useSingleSelectListState-DeJEr7lC.js} +2 -2
  104. package/dist/{useToggle-BmltE9Zr.js → useToggle-QlyoyPYv.js} +4 -4
  105. package/dist/{useToggleState-DZXLEnA_.js → useToggleState-C1mnFRiI.js} +1 -1
  106. package/dist/{utils-BCJajCwh.js → utils-BSxcP7tv.js} +15 -14
  107. package/package.json +20 -20
  108. package/dist/Dialog-BN5EE7UH.js +0 -934
  109. package/dist/isScrollable-Dh9D9IOd.js +0 -9
  110. package/dist/tooltip-eKaARDoV.js +0 -1084
  111. package/dist/useMenuTrigger-4fwEmto8.js +0 -246
@@ -1,1084 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { j as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, d as $b5e257d569688ac6$export$535bd6ca7f90a273, c as $3ef42575df84b30b$export$9d1611c77c2fe928, e as $bdb11010cef70236$export$f680877a34711e37, a as $64fa3d84918910a7$export$29f1550f4b0d4415, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a, o as $64fa3d84918910a7$export$45fda7c47f93fd48, p as $64fa3d84918910a7$export$6d3443f2c48bfc20 } from "./utils-BCJajCwh.js";
3
- import React__default, { useEffect, useState, useRef, useCallback, useContext, useMemo, forwardRef, createContext } from "react";
4
- import { $ as $e6afbd83fe6ebbd2$export$4c014de7c8940b4c, b as $e6afbd83fe6ebbd2$export$13f3202a3e5ddd5 } from "./useFocusable-ByyKSVQv.js";
5
- import { o as $c87311424ea30a05$export$78551043582a6a98, $ as $6179b936705e76d3$export$ae780daf29e6d456, u as $507fabe10e71c6fb$export$630ff653c5ada6a9, a as $507fabe10e71c6fb$export$b9b3dfddab17db27, e as $458b0a5536c1a7cf$export$40bfa8c7b0832715, d as $9ab94262bd0047c7$export$420e68273165f4ec } from "./focusSafely-CgFLw4FA.js";
6
- import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps-EDDcM64A.js";
7
- import { $ as $dbSRa$reactdom } from "./index-BTCzc3zb.js";
8
- import { a as $9446cca9a3875146$export$7d15b64cf5a3a4c4 } from "./number-GajL10e1.js";
9
- import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-Cs-ZD1nu.js";
10
- import { c as clsx } from "./lite-DVmmD_-j.js";
11
- function $9daab02d461809db$var$hasResizeObserver() {
12
- return typeof window.ResizeObserver !== "undefined";
13
- }
14
- function $9daab02d461809db$export$683480f191c0e3ea(options) {
15
- const { ref, box, onResize } = options;
16
- useEffect(() => {
17
- let element = ref === null || ref === void 0 ? void 0 : ref.current;
18
- if (!element) return;
19
- if (!$9daab02d461809db$var$hasResizeObserver()) {
20
- window.addEventListener("resize", onResize, false);
21
- return () => {
22
- window.removeEventListener("resize", onResize, false);
23
- };
24
- } else {
25
- const resizeObserverInstance = new window.ResizeObserver((entries) => {
26
- if (!entries.length) return;
27
- onResize();
28
- });
29
- resizeObserverInstance.observe(element, {
30
- box
31
- });
32
- return () => {
33
- if (element) resizeObserverInstance.unobserve(element);
34
- };
35
- }
36
- }, [
37
- onResize,
38
- ref,
39
- box
40
- ]);
41
- }
42
- const $edcf132a9284368a$var$AXIS = {
43
- top: "top",
44
- bottom: "top",
45
- left: "left",
46
- right: "left"
47
- };
48
- const $edcf132a9284368a$var$FLIPPED_DIRECTION = {
49
- top: "bottom",
50
- bottom: "top",
51
- left: "right",
52
- right: "left"
53
- };
54
- const $edcf132a9284368a$var$CROSS_AXIS = {
55
- top: "left",
56
- left: "top"
57
- };
58
- const $edcf132a9284368a$var$AXIS_SIZE = {
59
- top: "height",
60
- left: "width"
61
- };
62
- const $edcf132a9284368a$var$TOTAL_SIZE = {
63
- width: "totalWidth",
64
- height: "totalHeight"
65
- };
66
- const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {};
67
- let $edcf132a9284368a$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
68
- function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
69
- let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
70
- let scroll = {};
71
- let isPinchZoomedIn = ($edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.scale) > 1;
72
- if (containerNode.tagName === "BODY") {
73
- let documentElement = document.documentElement;
74
- totalWidth = documentElement.clientWidth;
75
- totalHeight = documentElement.clientHeight;
76
- var _visualViewport_width;
77
- width = (_visualViewport_width = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
78
- var _visualViewport_height;
79
- height = (_visualViewport_height = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : totalHeight;
80
- scroll.top = documentElement.scrollTop || containerNode.scrollTop;
81
- scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;
82
- if ($edcf132a9284368a$var$visualViewport) {
83
- top = $edcf132a9284368a$var$visualViewport.offsetTop;
84
- left = $edcf132a9284368a$var$visualViewport.offsetLeft;
85
- }
86
- } else {
87
- ({ width, height, top, left } = $edcf132a9284368a$var$getOffset(containerNode));
88
- scroll.top = containerNode.scrollTop;
89
- scroll.left = containerNode.scrollLeft;
90
- totalWidth = width;
91
- totalHeight = height;
92
- }
93
- if ($c87311424ea30a05$export$78551043582a6a98() && (containerNode.tagName === "BODY" || containerNode.tagName === "HTML") && isPinchZoomedIn) {
94
- scroll.top = 0;
95
- scroll.left = 0;
96
- top = $edcf132a9284368a$var$visualViewport.pageTop;
97
- left = $edcf132a9284368a$var$visualViewport.pageLeft;
98
- }
99
- return {
100
- width,
101
- height,
102
- totalWidth,
103
- totalHeight,
104
- scroll,
105
- top,
106
- left
107
- };
108
- }
109
- function $edcf132a9284368a$var$getScroll(node) {
110
- return {
111
- top: node.scrollTop,
112
- left: node.scrollLeft,
113
- width: node.scrollWidth,
114
- height: node.scrollHeight
115
- };
116
- }
117
- function $edcf132a9284368a$var$getDelta(axis, offset, size, boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary) {
118
- let containerScroll = containerDimensions.scroll[axis];
119
- let boundarySize = boundaryDimensions[$edcf132a9284368a$var$AXIS_SIZE[axis]];
120
- let boundaryStartEdge = boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding;
121
- let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] - padding;
122
- let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
123
- let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
124
- if (startEdgeOffset < boundaryStartEdge) return boundaryStartEdge - startEdgeOffset;
125
- else if (endEdgeOffset > boundaryEndEdge) return Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset);
126
- else return 0;
127
- }
128
- function $edcf132a9284368a$var$getMargins(node) {
129
- let style = window.getComputedStyle(node);
130
- return {
131
- top: parseInt(style.marginTop, 10) || 0,
132
- bottom: parseInt(style.marginBottom, 10) || 0,
133
- left: parseInt(style.marginLeft, 10) || 0,
134
- right: parseInt(style.marginRight, 10) || 0
135
- };
136
- }
137
- function $edcf132a9284368a$var$parsePlacement(input) {
138
- if ($edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input]) return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
139
- let [placement, crossPlacement] = input.split(" ");
140
- let axis = $edcf132a9284368a$var$AXIS[placement] || "right";
141
- let crossAxis = $edcf132a9284368a$var$CROSS_AXIS[axis];
142
- if (!$edcf132a9284368a$var$AXIS[crossPlacement]) crossPlacement = "center";
143
- let size = $edcf132a9284368a$var$AXIS_SIZE[axis];
144
- let crossSize = $edcf132a9284368a$var$AXIS_SIZE[crossAxis];
145
- $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input] = {
146
- placement,
147
- crossPlacement,
148
- axis,
149
- crossAxis,
150
- size,
151
- crossSize
152
- };
153
- return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
154
- }
155
- function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
156
- let { placement, crossPlacement, axis, crossAxis, size, crossSize } = placementInfo;
157
- let position = {};
158
- position[crossAxis] = childOffset[crossAxis];
159
- if (crossPlacement === "center")
160
- position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;
161
- else if (crossPlacement !== crossAxis)
162
- position[crossAxis] += childOffset[crossSize] - overlaySize[crossSize];
163
- position[crossAxis] += crossOffset;
164
- const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;
165
- const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
166
- position[crossAxis] = $9446cca9a3875146$export$7d15b64cf5a3a4c4(position[crossAxis], minPosition, maxPosition);
167
- if (placement === axis) {
168
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
169
- position[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);
170
- } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);
171
- return position;
172
- }
173
- function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
174
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height];
175
- let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - position.bottom - overlayHeight);
176
- let maxHeight = heightGrowthDirection !== "top" ? (
177
- // We want the distance between the top of the overlay to the bottom of the boundary
178
- Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top - overlayTop - (margins.top + margins.bottom + padding))
179
- ) : Math.max(0, overlayTop + overlayHeight - (boundaryDimensions.top + boundaryDimensions.scroll.top) - (margins.top + margins.bottom + padding));
180
- return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
181
- }
182
- function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
183
- let { placement, axis, size } = placementInfo;
184
- if (placement === axis) return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - boundaryDimensions.scroll[axis] + containerOffsetWithBoundary[axis] - margins[axis] - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
185
- return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - margins[axis] - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
186
- }
187
- function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
188
- let placementInfo = $edcf132a9284368a$var$parsePlacement(placementInput);
189
- let { size, crossAxis, crossSize, placement, crossPlacement } = placementInfo;
190
- let position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
191
- let normalizedOffset = offset;
192
- let space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo);
193
- if (flip && scrollSize[size] > space) {
194
- let flippedPlacementInfo = $edcf132a9284368a$var$parsePlacement(`${$edcf132a9284368a$var$FLIPPED_DIRECTION[placement]} ${crossPlacement}`);
195
- let flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
196
- let flippedSpace = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo);
197
- if (flippedSpace > space) {
198
- placementInfo = flippedPlacementInfo;
199
- position = flippedPosition;
200
- normalizedOffset = offset;
201
- }
202
- }
203
- let heightGrowthDirection = "bottom";
204
- if (placementInfo.axis === "top") {
205
- if (placementInfo.placement === "top") heightGrowthDirection = "top";
206
- else if (placementInfo.placement === "bottom") heightGrowthDirection = "bottom";
207
- } else if (placementInfo.crossAxis === "top") {
208
- if (placementInfo.crossPlacement === "top") heightGrowthDirection = "bottom";
209
- else if (placementInfo.crossPlacement === "bottom") heightGrowthDirection = "top";
210
- }
211
- let delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
212
- position[crossAxis] += delta;
213
- let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
214
- if (userSetMaxHeight && userSetMaxHeight < maxHeight) maxHeight = userSetMaxHeight;
215
- overlaySize.height = Math.min(overlaySize.height, maxHeight);
216
- position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
217
- delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
218
- position[crossAxis] += delta;
219
- let arrowPosition = {};
220
- let preferredArrowPosition = childOffset[crossAxis] + 0.5 * childOffset[crossSize] - position[crossAxis] - margins[$edcf132a9284368a$var$AXIS[crossAxis]];
221
- const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
222
- const overlayMargin = $edcf132a9284368a$var$AXIS[crossAxis] === "left" ? margins.left + margins.right : margins.top + margins.bottom;
223
- const arrowMaxPosition = overlaySize[crossSize] - overlayMargin - arrowSize / 2 - arrowBoundaryOffset;
224
- const arrowOverlappingChildMinEdge = childOffset[crossAxis] + arrowSize / 2 - (position[crossAxis] + margins[$edcf132a9284368a$var$AXIS[crossAxis]]);
225
- const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - arrowSize / 2 - (position[crossAxis] + margins[$edcf132a9284368a$var$AXIS[crossAxis]]);
226
- const arrowPositionOverlappingChild = $9446cca9a3875146$export$7d15b64cf5a3a4c4(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);
227
- arrowPosition[crossAxis] = $9446cca9a3875146$export$7d15b64cf5a3a4c4(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition);
228
- return {
229
- position,
230
- maxHeight,
231
- arrowOffsetLeft: arrowPosition.left,
232
- arrowOffsetTop: arrowPosition.top,
233
- placement: placementInfo.placement
234
- };
235
- }
236
- function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
237
- let { placement, targetNode, overlayNode, scrollNode, padding, shouldFlip, boundaryElement, offset, crossOffset, maxHeight, arrowSize = 0, arrowBoundaryOffset = 0 } = opts;
238
- let container = overlayNode instanceof HTMLElement ? $edcf132a9284368a$var$getContainingBlock(overlayNode) : document.documentElement;
239
- let isViewportContainer = container === document.documentElement;
240
- const containerPositionStyle = window.getComputedStyle(container).position;
241
- let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== "static";
242
- let childOffset = isViewportContainer ? $edcf132a9284368a$var$getOffset(targetNode) : $edcf132a9284368a$var$getPosition(targetNode, container);
243
- if (!isViewportContainer) {
244
- let { marginTop, marginLeft } = window.getComputedStyle(targetNode);
245
- childOffset.top += parseInt(marginTop, 10) || 0;
246
- childOffset.left += parseInt(marginLeft, 10) || 0;
247
- }
248
- let overlaySize = $edcf132a9284368a$var$getOffset(overlayNode);
249
- let margins = $edcf132a9284368a$var$getMargins(overlayNode);
250
- overlaySize.width += margins.left + margins.right;
251
- overlaySize.height += margins.top + margins.bottom;
252
- let scrollSize = $edcf132a9284368a$var$getScroll(scrollNode);
253
- let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement);
254
- let containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container);
255
- let containerOffsetWithBoundary = boundaryElement.tagName === "BODY" ? $edcf132a9284368a$var$getOffset(container) : $edcf132a9284368a$var$getPosition(container, boundaryElement);
256
- if (container.tagName === "HTML" && boundaryElement.tagName === "BODY") {
257
- containerDimensions.scroll.top = 0;
258
- containerDimensions.scroll.left = 0;
259
- }
260
- return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset);
261
- }
262
- function $edcf132a9284368a$var$getOffset(node) {
263
- let { top, left, width, height } = node.getBoundingClientRect();
264
- let { scrollTop, scrollLeft, clientTop, clientLeft } = document.documentElement;
265
- return {
266
- top: top + scrollTop - clientTop,
267
- left: left + scrollLeft - clientLeft,
268
- width,
269
- height
270
- };
271
- }
272
- function $edcf132a9284368a$var$getPosition(node, parent) {
273
- let style = window.getComputedStyle(node);
274
- let offset;
275
- if (style.position === "fixed") {
276
- let { top, left, width, height } = node.getBoundingClientRect();
277
- offset = {
278
- top,
279
- left,
280
- width,
281
- height
282
- };
283
- } else {
284
- offset = $edcf132a9284368a$var$getOffset(node);
285
- let parentOffset = $edcf132a9284368a$var$getOffset(parent);
286
- let parentStyle = window.getComputedStyle(parent);
287
- parentOffset.top += (parseInt(parentStyle.borderTopWidth, 10) || 0) - parent.scrollTop;
288
- parentOffset.left += (parseInt(parentStyle.borderLeftWidth, 10) || 0) - parent.scrollLeft;
289
- offset.top -= parentOffset.top;
290
- offset.left -= parentOffset.left;
291
- }
292
- offset.top -= parseInt(style.marginTop, 10) || 0;
293
- offset.left -= parseInt(style.marginLeft, 10) || 0;
294
- return offset;
295
- }
296
- function $edcf132a9284368a$var$getContainingBlock(node) {
297
- let offsetParent = node.offsetParent;
298
- if (offsetParent && offsetParent === document.body && window.getComputedStyle(offsetParent).position === "static" && !$edcf132a9284368a$var$isContainingBlock(offsetParent)) offsetParent = document.documentElement;
299
- if (offsetParent == null) {
300
- offsetParent = node.parentElement;
301
- while (offsetParent && !$edcf132a9284368a$var$isContainingBlock(offsetParent)) offsetParent = offsetParent.parentElement;
302
- }
303
- return offsetParent || document.documentElement;
304
- }
305
- function $edcf132a9284368a$var$isContainingBlock(node) {
306
- let style = window.getComputedStyle(node);
307
- return style.transform !== "none" || /transform|perspective/.test(style.willChange) || style.filter !== "none" || style.contain === "paint" || // @ts-ignore
308
- "backdropFilter" in style && style.backdropFilter !== "none" || // @ts-ignore
309
- "WebkitBackdropFilter" in style && style.WebkitBackdropFilter !== "none";
310
- }
311
- const $dd149f63282afbbf$export$f6211563215e3b37 = /* @__PURE__ */ new WeakMap();
312
- function $dd149f63282afbbf$export$18fc8428861184da(opts) {
313
- let { triggerRef, isOpen, onClose } = opts;
314
- useEffect(() => {
315
- if (!isOpen || onClose === null) return;
316
- let onScroll = (e) => {
317
- let target = e.target;
318
- if (!triggerRef.current || target instanceof Node && !target.contains(triggerRef.current)) return;
319
- if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;
320
- let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
321
- if (onCloseHandler) onCloseHandler();
322
- };
323
- window.addEventListener("scroll", onScroll, true);
324
- return () => {
325
- window.removeEventListener("scroll", onScroll, true);
326
- };
327
- }, [
328
- isOpen,
329
- onClose,
330
- triggerRef
331
- ]);
332
- }
333
- let $2a41e45df1593e64$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
334
- function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
335
- let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
336
- let { arrowSize = 0, targetRef, overlayRef, scrollRef = overlayRef, placement = "bottom", containerPadding = 12, shouldFlip = true, boundaryElement = typeof document !== "undefined" ? document.body : null, offset = 0, crossOffset = 0, shouldUpdatePosition = true, isOpen = true, onClose, maxHeight, arrowBoundaryOffset = 0 } = props;
337
- let [position, setPosition] = useState({
338
- position: {},
339
- arrowOffsetLeft: void 0,
340
- arrowOffsetTop: void 0,
341
- maxHeight: void 0,
342
- placement: void 0
343
- });
344
- let deps = [
345
- shouldUpdatePosition,
346
- placement,
347
- overlayRef.current,
348
- targetRef.current,
349
- scrollRef.current,
350
- containerPadding,
351
- shouldFlip,
352
- boundaryElement,
353
- offset,
354
- crossOffset,
355
- isOpen,
356
- direction,
357
- maxHeight,
358
- arrowBoundaryOffset,
359
- arrowSize
360
- ];
361
- let lastScale = useRef($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale);
362
- useEffect(() => {
363
- if (isOpen) lastScale.current = $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale;
364
- }, [
365
- isOpen
366
- ]);
367
- let updatePosition = useCallback(() => {
368
- if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !boundaryElement) return;
369
- if (($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale) !== lastScale.current) return;
370
- let anchor = null;
371
- if (scrollRef.current && scrollRef.current.contains(document.activeElement)) {
372
- let anchorRect = document.activeElement.getBoundingClientRect();
373
- let scrollRect = scrollRef.current.getBoundingClientRect();
374
- anchor = {
375
- type: "top",
376
- offset: anchorRect.top - scrollRect.top
377
- };
378
- if (anchor.offset > scrollRect.height / 2) {
379
- anchor.type = "bottom";
380
- anchor.offset = anchorRect.bottom - scrollRect.bottom;
381
- }
382
- }
383
- let overlay = overlayRef.current;
384
- if (!maxHeight && overlayRef.current) {
385
- var _window_visualViewport;
386
- overlay.style.top = "0px";
387
- overlay.style.bottom = "";
388
- var _window_visualViewport_height;
389
- overlay.style.maxHeight = ((_window_visualViewport_height = (_window_visualViewport = window.visualViewport) === null || _window_visualViewport === void 0 ? void 0 : _window_visualViewport.height) !== null && _window_visualViewport_height !== void 0 ? _window_visualViewport_height : window.innerHeight) + "px";
390
- }
391
- let position2 = $edcf132a9284368a$export$b3ceb0cbf1056d98({
392
- placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
393
- overlayNode: overlayRef.current,
394
- targetNode: targetRef.current,
395
- scrollNode: scrollRef.current || overlayRef.current,
396
- padding: containerPadding,
397
- shouldFlip,
398
- boundaryElement,
399
- offset,
400
- crossOffset,
401
- maxHeight,
402
- arrowSize,
403
- arrowBoundaryOffset
404
- });
405
- overlay.style.top = "";
406
- overlay.style.bottom = "";
407
- overlay.style.left = "";
408
- overlay.style.right = "";
409
- Object.keys(position2.position).forEach((key) => overlay.style[key] = position2.position[key] + "px");
410
- overlay.style.maxHeight = position2.maxHeight != null ? position2.maxHeight + "px" : void 0;
411
- if (anchor) {
412
- let anchorRect = document.activeElement.getBoundingClientRect();
413
- let scrollRect = scrollRef.current.getBoundingClientRect();
414
- let newOffset = anchorRect[anchor.type] - scrollRect[anchor.type];
415
- scrollRef.current.scrollTop += newOffset - anchor.offset;
416
- }
417
- setPosition(position2);
418
- }, deps);
419
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(updatePosition, deps);
420
- $2a41e45df1593e64$var$useResize(updatePosition);
421
- $9daab02d461809db$export$683480f191c0e3ea({
422
- ref: overlayRef,
423
- onResize: updatePosition
424
- });
425
- $9daab02d461809db$export$683480f191c0e3ea({
426
- ref: targetRef,
427
- onResize: updatePosition
428
- });
429
- let isResizing = useRef(false);
430
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
431
- let timeout;
432
- let onResize = () => {
433
- isResizing.current = true;
434
- clearTimeout(timeout);
435
- timeout = setTimeout(() => {
436
- isResizing.current = false;
437
- }, 500);
438
- updatePosition();
439
- };
440
- let onScroll = () => {
441
- if (isResizing.current) onResize();
442
- };
443
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("resize", onResize);
444
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("scroll", onScroll);
445
- return () => {
446
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("resize", onResize);
447
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("scroll", onScroll);
448
- };
449
- }, [
450
- updatePosition
451
- ]);
452
- let close = useCallback(() => {
453
- if (!isResizing.current) onClose();
454
- }, [
455
- onClose,
456
- isResizing
457
- ]);
458
- $dd149f63282afbbf$export$18fc8428861184da({
459
- triggerRef: targetRef,
460
- isOpen,
461
- onClose: onClose && close
462
- });
463
- var _position_maxHeight;
464
- return {
465
- overlayProps: {
466
- style: {
467
- position: "absolute",
468
- zIndex: 1e5,
469
- ...position.position,
470
- maxHeight: (_position_maxHeight = position.maxHeight) !== null && _position_maxHeight !== void 0 ? _position_maxHeight : "100vh"
471
- }
472
- },
473
- placement: position.placement,
474
- arrowProps: {
475
- "aria-hidden": "true",
476
- role: "presentation",
477
- style: {
478
- left: position.arrowOffsetLeft,
479
- top: position.arrowOffsetTop
480
- }
481
- },
482
- updatePosition
483
- };
484
- }
485
- function $2a41e45df1593e64$var$useResize(onResize) {
486
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
487
- window.addEventListener("resize", onResize, false);
488
- return () => {
489
- window.removeEventListener("resize", onResize, false);
490
- };
491
- }, [
492
- onResize
493
- ]);
494
- }
495
- function $2a41e45df1593e64$var$translateRTL(position, direction) {
496
- if (direction === "rtl") return position.replace("start", "right").replace("end", "left");
497
- return position.replace("start", "left").replace("end", "right");
498
- }
499
- const $f57aed4a881a3485$var$Context = /* @__PURE__ */ React__default.createContext(null);
500
- function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
501
- let { children } = props;
502
- let parent = useContext($f57aed4a881a3485$var$Context);
503
- let [modalCount, setModalCount] = useState(0);
504
- let context = useMemo(() => ({
505
- parent,
506
- modalCount,
507
- addModal() {
508
- setModalCount((count) => count + 1);
509
- if (parent) parent.addModal();
510
- },
511
- removeModal() {
512
- setModalCount((count) => count - 1);
513
- if (parent) parent.removeModal();
514
- }
515
- }), [
516
- parent,
517
- modalCount
518
- ]);
519
- return /* @__PURE__ */ React__default.createElement($f57aed4a881a3485$var$Context.Provider, {
520
- value: context
521
- }, children);
522
- }
523
- function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
524
- let context = useContext($f57aed4a881a3485$var$Context);
525
- return {
526
- modalProviderProps: {
527
- "aria-hidden": context && context.modalCount > 0 ? true : null
528
- }
529
- };
530
- }
531
- function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
532
- let { modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
533
- return /* @__PURE__ */ React__default.createElement("div", {
534
- "data-overlay-container": true,
535
- ...props,
536
- ...modalProviderProps
537
- });
538
- }
539
- function $f57aed4a881a3485$export$bf688221f59024e5(props) {
540
- return /* @__PURE__ */ React__default.createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, /* @__PURE__ */ React__default.createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
541
- }
542
- function $f57aed4a881a3485$export$b47c3594eab58386(props) {
543
- let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
544
- let { portalContainer = isSSR ? null : document.body, ...rest } = props;
545
- React__default.useEffect(() => {
546
- if (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.closest("[data-overlay-container]")) throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.");
547
- }, [
548
- portalContainer
549
- ]);
550
- if (!portalContainer) return null;
551
- let contents = /* @__PURE__ */ React__default.createElement($f57aed4a881a3485$export$bf688221f59024e5, rest);
552
- return /* @__PURE__ */ $dbSRa$reactdom.createPortal(contents, portalContainer);
553
- }
554
- function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
555
- let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
556
- labelable: true
557
- });
558
- let { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
559
- onHoverStart: () => state === null || state === void 0 ? void 0 : state.open(true),
560
- onHoverEnd: () => state === null || state === void 0 ? void 0 : state.close()
561
- });
562
- return {
563
- tooltipProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, hoverProps, {
564
- role: "tooltip"
565
- })
566
- };
567
- }
568
- function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
569
- let { isDisabled, trigger } = props;
570
- let tooltipId = $bdb11010cef70236$export$f680877a34711e37();
571
- let isHovered = useRef(false);
572
- let isFocused = useRef(false);
573
- let handleShow = () => {
574
- if (isHovered.current || isFocused.current) state.open(isFocused.current);
575
- };
576
- let handleHide = (immediate) => {
577
- if (!isHovered.current && !isFocused.current) state.close(immediate);
578
- };
579
- useEffect(() => {
580
- let onKeyDown = (e) => {
581
- if (ref && ref.current) {
582
- if (e.key === "Escape") {
583
- e.stopPropagation();
584
- state.close(true);
585
- }
586
- }
587
- };
588
- if (state.isOpen) {
589
- document.addEventListener("keydown", onKeyDown, true);
590
- return () => {
591
- document.removeEventListener("keydown", onKeyDown, true);
592
- };
593
- }
594
- }, [
595
- ref,
596
- state
597
- ]);
598
- let onHoverStart = () => {
599
- if (trigger === "focus") return;
600
- if ($507fabe10e71c6fb$export$630ff653c5ada6a9() === "pointer") isHovered.current = true;
601
- else isHovered.current = false;
602
- handleShow();
603
- };
604
- let onHoverEnd = () => {
605
- if (trigger === "focus") return;
606
- isFocused.current = false;
607
- isHovered.current = false;
608
- handleHide();
609
- };
610
- let onPressStart = () => {
611
- isFocused.current = false;
612
- isHovered.current = false;
613
- handleHide(true);
614
- };
615
- let onFocus = () => {
616
- let isVisible = $507fabe10e71c6fb$export$b9b3dfddab17db27();
617
- if (isVisible) {
618
- isFocused.current = true;
619
- handleShow();
620
- }
621
- };
622
- let onBlur = () => {
623
- isFocused.current = false;
624
- isHovered.current = false;
625
- handleHide(true);
626
- };
627
- let { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
628
- isDisabled,
629
- onHoverStart,
630
- onHoverEnd
631
- });
632
- let { focusableProps } = $e6afbd83fe6ebbd2$export$4c014de7c8940b4c({
633
- isDisabled,
634
- onFocus,
635
- onBlur
636
- }, ref);
637
- return {
638
- triggerProps: {
639
- "aria-describedby": state.isOpen ? tooltipId : void 0,
640
- ...$3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, hoverProps, {
641
- onPointerDown: onPressStart,
642
- onKeyDown: onPressStart
643
- })
644
- },
645
- tooltipProps: {
646
- id: tooltipId
647
- }
648
- };
649
- }
650
- function $fc909762b330b746$export$61c6a8c84e605fb6(props) {
651
- let [isOpen, setOpen] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(props.isOpen, props.defaultOpen || false, props.onOpenChange);
652
- const open = useCallback(() => {
653
- setOpen(true);
654
- }, [
655
- setOpen
656
- ]);
657
- const close = useCallback(() => {
658
- setOpen(false);
659
- }, [
660
- setOpen
661
- ]);
662
- const toggle = useCallback(() => {
663
- setOpen(!isOpen);
664
- }, [
665
- setOpen,
666
- isOpen
667
- ]);
668
- return {
669
- isOpen,
670
- setOpen,
671
- open,
672
- close,
673
- toggle
674
- };
675
- }
676
- const $8796f90736e175cb$var$TOOLTIP_DELAY = 1500;
677
- const $8796f90736e175cb$var$TOOLTIP_COOLDOWN = 500;
678
- let $8796f90736e175cb$var$tooltips = {};
679
- let $8796f90736e175cb$var$tooltipId = 0;
680
- let $8796f90736e175cb$var$globalWarmedUp = false;
681
- let $8796f90736e175cb$var$globalWarmUpTimeout = null;
682
- let $8796f90736e175cb$var$globalCooldownTimeout = null;
683
- function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
684
- let { delay = $8796f90736e175cb$var$TOOLTIP_DELAY, closeDelay = $8796f90736e175cb$var$TOOLTIP_COOLDOWN } = props;
685
- let { isOpen, open, close } = $fc909762b330b746$export$61c6a8c84e605fb6(props);
686
- let id = useMemo(() => `${++$8796f90736e175cb$var$tooltipId}`, []);
687
- let closeTimeout = useRef(void 0);
688
- let closeCallback = useRef(close);
689
- let ensureTooltipEntry = () => {
690
- $8796f90736e175cb$var$tooltips[id] = hideTooltip;
691
- };
692
- let closeOpenTooltips = () => {
693
- for (let hideTooltipId in $8796f90736e175cb$var$tooltips) if (hideTooltipId !== id) {
694
- $8796f90736e175cb$var$tooltips[hideTooltipId](true);
695
- delete $8796f90736e175cb$var$tooltips[hideTooltipId];
696
- }
697
- };
698
- let showTooltip = () => {
699
- clearTimeout(closeTimeout.current);
700
- closeTimeout.current = null;
701
- closeOpenTooltips();
702
- ensureTooltipEntry();
703
- $8796f90736e175cb$var$globalWarmedUp = true;
704
- open();
705
- if ($8796f90736e175cb$var$globalWarmUpTimeout) {
706
- clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
707
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
708
- }
709
- if ($8796f90736e175cb$var$globalCooldownTimeout) {
710
- clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
711
- $8796f90736e175cb$var$globalCooldownTimeout = null;
712
- }
713
- };
714
- let hideTooltip = (immediate) => {
715
- if (immediate || closeDelay <= 0) {
716
- clearTimeout(closeTimeout.current);
717
- closeTimeout.current = null;
718
- closeCallback.current();
719
- } else if (!closeTimeout.current) closeTimeout.current = setTimeout(() => {
720
- closeTimeout.current = null;
721
- closeCallback.current();
722
- }, closeDelay);
723
- if ($8796f90736e175cb$var$globalWarmUpTimeout) {
724
- clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
725
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
726
- }
727
- if ($8796f90736e175cb$var$globalWarmedUp) {
728
- if ($8796f90736e175cb$var$globalCooldownTimeout) clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
729
- $8796f90736e175cb$var$globalCooldownTimeout = setTimeout(() => {
730
- delete $8796f90736e175cb$var$tooltips[id];
731
- $8796f90736e175cb$var$globalCooldownTimeout = null;
732
- $8796f90736e175cb$var$globalWarmedUp = false;
733
- }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay));
734
- }
735
- };
736
- let warmupTooltip = () => {
737
- closeOpenTooltips();
738
- ensureTooltipEntry();
739
- if (!isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp) $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(() => {
740
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
741
- $8796f90736e175cb$var$globalWarmedUp = true;
742
- showTooltip();
743
- }, delay);
744
- else if (!isOpen) showTooltip();
745
- };
746
- useEffect(() => {
747
- closeCallback.current = close;
748
- }, [
749
- close
750
- ]);
751
- useEffect(() => {
752
- return () => {
753
- clearTimeout(closeTimeout.current);
754
- let tooltip = $8796f90736e175cb$var$tooltips[id];
755
- if (tooltip) delete $8796f90736e175cb$var$tooltips[id];
756
- };
757
- }, [
758
- id
759
- ]);
760
- return {
761
- isOpen,
762
- open: (immediate) => {
763
- if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
764
- else showTooltip();
765
- },
766
- close: hideTooltip
767
- };
768
- }
769
- const $44f671af83e7d9e0$export$2de4954e8ae13b9f = /* @__PURE__ */ createContext({
770
- placement: "bottom"
771
- });
772
- function $44f671af83e7d9e0$var$OverlayArrow(props, ref) {
773
- [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $44f671af83e7d9e0$export$2de4954e8ae13b9f);
774
- let placement = props.placement;
775
- let style = {
776
- position: "absolute",
777
- [placement]: "100%",
778
- transform: placement === "top" || placement === "bottom" ? "translateX(-50%)" : "translateY(-50%)"
779
- };
780
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
781
- ...props,
782
- defaultClassName: "react-aria-OverlayArrow",
783
- values: {
784
- placement
785
- }
786
- });
787
- if (renderProps.style) Object.keys(renderProps.style).forEach((key) => renderProps.style[key] === void 0 && delete renderProps.style[key]);
788
- return /* @__PURE__ */ React__default.createElement("div", {
789
- ...props,
790
- ...renderProps,
791
- style: {
792
- ...style,
793
- ...renderProps.style
794
- },
795
- ref,
796
- "data-placement": placement
797
- });
798
- }
799
- const $44f671af83e7d9e0$export$746d02f47f4d381 = /* @__PURE__ */ forwardRef($44f671af83e7d9e0$var$OverlayArrow);
800
- const $4e3b923658d69c60$export$7a7623236eec67fa = /* @__PURE__ */ createContext(null);
801
- const $4e3b923658d69c60$export$39ae08fa83328b12 = /* @__PURE__ */ createContext(null);
802
- function $4e3b923658d69c60$export$8c610744efcf8a1d(props) {
803
- let state = $8796f90736e175cb$export$4d40659c25ecb50b(props);
804
- let ref = useRef(null);
805
- let { triggerProps, tooltipProps } = $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref);
806
- return /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
807
- values: [
808
- [
809
- $4e3b923658d69c60$export$7a7623236eec67fa,
810
- state
811
- ],
812
- [
813
- $4e3b923658d69c60$export$39ae08fa83328b12,
814
- {
815
- ...tooltipProps,
816
- triggerRef: ref
817
- }
818
- ]
819
- ]
820
- }, /* @__PURE__ */ React__default.createElement($e6afbd83fe6ebbd2$export$13f3202a3e5ddd5, {
821
- ...triggerProps,
822
- ref
823
- }, props.children));
824
- }
825
- function $4e3b923658d69c60$var$Tooltip({ UNSTABLE_portalContainer, ...props }, ref) {
826
- [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $4e3b923658d69c60$export$39ae08fa83328b12);
827
- let contextState = useContext($4e3b923658d69c60$export$7a7623236eec67fa);
828
- let localState = $8796f90736e175cb$export$4d40659c25ecb50b(props);
829
- let state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;
830
- let isExiting = $64fa3d84918910a7$export$45fda7c47f93fd48(ref, state.isOpen) || props.isExiting || false;
831
- if (!state.isOpen && !isExiting) return null;
832
- return /* @__PURE__ */ React__default.createElement($f57aed4a881a3485$export$b47c3594eab58386, {
833
- portalContainer: UNSTABLE_portalContainer
834
- }, /* @__PURE__ */ React__default.createElement($4e3b923658d69c60$var$TooltipInner, {
835
- ...props,
836
- tooltipRef: ref,
837
- isExiting
838
- }));
839
- }
840
- const $4e3b923658d69c60$export$28c660c63b792dea = /* @__PURE__ */ forwardRef($4e3b923658d69c60$var$Tooltip);
841
- function $4e3b923658d69c60$var$TooltipInner(props) {
842
- let state = useContext($4e3b923658d69c60$export$7a7623236eec67fa);
843
- let arrowRef = useRef(null);
844
- let [arrowWidth, setArrowWidth] = useState(0);
845
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
846
- if (arrowRef.current && state.isOpen) setArrowWidth(arrowRef.current.getBoundingClientRect().width);
847
- }, [
848
- state.isOpen,
849
- arrowRef
850
- ]);
851
- let { overlayProps, arrowProps, placement } = $2a41e45df1593e64$export$d39e1813b3bdd0e1({
852
- placement: props.placement || "top",
853
- targetRef: props.triggerRef,
854
- overlayRef: props.tooltipRef,
855
- offset: props.offset,
856
- crossOffset: props.crossOffset,
857
- isOpen: state.isOpen,
858
- arrowSize: arrowWidth,
859
- arrowBoundaryOffset: props.arrowBoundaryOffset,
860
- shouldFlip: props.shouldFlip
861
- });
862
- let isEntering = $64fa3d84918910a7$export$6d3443f2c48bfc20(props.tooltipRef, !!placement) || props.isEntering || false;
863
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
864
- ...props,
865
- defaultClassName: "react-aria-Tooltip",
866
- values: {
867
- placement,
868
- isEntering,
869
- isExiting: props.isExiting,
870
- state
871
- }
872
- });
873
- props = $3ef42575df84b30b$export$9d1611c77c2fe928(props, overlayProps);
874
- let { tooltipProps } = $326e436e94273fe1$export$1c4b08e0eca38426(props, state);
875
- return /* @__PURE__ */ React__default.createElement("div", {
876
- ...tooltipProps,
877
- ref: props.tooltipRef,
878
- ...renderProps,
879
- style: {
880
- ...overlayProps.style,
881
- ...renderProps.style
882
- },
883
- "data-placement": placement,
884
- "data-entering": isEntering || void 0,
885
- "data-exiting": props.isExiting || void 0
886
- }, /* @__PURE__ */ React__default.createElement($44f671af83e7d9e0$export$2de4954e8ae13b9f.Provider, {
887
- value: {
888
- ...arrowProps,
889
- placement,
890
- ref: arrowRef
891
- }
892
- }, renderProps.children));
893
- }
894
- /**
895
- * A simple tooltip component.
896
- *
897
- * It can be used in two modes:
898
- * - **Controlled mode**: You can control the tooltip with the `open` prop.
899
- * - **Uncontrolled mode**: The tooltip will be open by default with the `defaultOpen` prop.
900
- *
901
- * @component
902
- * @param {Object} props - Component props.
903
- * @param {string|JSX.Element} props.text - The text to display in the tooltip.
904
- * @param {TooltipTheme} [props.theme='dark'] - The theme of the tooltip.
905
- * @param {number} [props.offset=0] - Additional offset between the tooltip and the element on the main axis (same axis as element).
906
- * @param {number} [props.crossOffset=0] - Additional offset between the tooltip and the element on the cross axis (opposite axis as element).
907
- * @param {number} [props.containerPadding=12] - Space that should be left between the tooltip and the main containing element (usually browser window).
908
- * @param {number} [props.openDelay=1500] - Duration before the tooltip is shown, in milliseconds.
909
- * @param {number} [props.closeDelay=500] - Duration before the tooltip is hidden, in milliseconds.
910
- * @param {boolean} [props.shouldFlip=true] - If `false`, the tooltip will not flip to the opposite side if there is not enough space.
911
- * @param {boolean} [props.defaultOpen] - (**Uncontrolled mode**) Whether the tooltip is initially open.
912
- * @param {boolean} [props.open] - (**Controlled mode**) Whether the tooltip is open.
913
- * @param {Function} [props.onOpenChange] - (**Controlled mode**) Function to run when the tooltip is opened or closed.
914
- * @param {TooltipPlacement} [props.placement] - The side of the trigger element where the tooltip will be displayed.
915
- * @param {string} [props.className] - Classes to pass to the tooltip.
916
- * @param {RefObject<Element>} [props.triggerRef] - Ref to anchor the tooltip to. If not provided, the tooltip will be anchored to the trigger element.
917
- * @param {boolean} [props.arrow] - If `true`, an arrow is shown on the tooltip.
918
- *
919
- * @returns {JSX.Element} The Tooltip component.
920
- *
921
- * @typedef {'light' | 'dark'} TooltipTheme
922
- * @typedef {'bottom' | 'bottom left' | 'bottom right' | 'bottom start' | 'bottom end' | 'top' | 'top left' | 'top right' | 'top start' | 'top end' | 'left' | 'left top' | 'left bottom' | 'start' | 'start top' | 'start bottom' | 'right' | 'right top' | 'right bottom' | 'end' | 'end top' | 'end bottom'} TooltipPlacement
923
- *
924
- * @example
925
- * <Tooltip text='My tooltip'>
926
- * <Button>Hover me</Button>
927
- * </Tooltip>
928
- *
929
- * @preserve
930
- */
931
- const Tooltip = (props) => {
932
- const {
933
- children,
934
- text,
935
- theme = "dark",
936
- offset = 0,
937
- crossOffset = 0,
938
- containerPadding = 12,
939
- openDelay = 1500,
940
- closeDelay = 500,
941
- shouldFlip = true,
942
- arrow,
943
- open,
944
- defaultOpen,
945
- onOpenChange,
946
- placement,
947
- className,
948
- triggerRef,
949
- disabled
950
- } = props;
951
- return /* @__PURE__ */ jsxs(
952
- $4e3b923658d69c60$export$8c610744efcf8a1d,
953
- {
954
- delay: openDelay,
955
- closeDelay,
956
- isDisabled: disabled,
957
- isOpen: open,
958
- onOpenChange,
959
- defaultOpen,
960
- children: [
961
- children,
962
- /* @__PURE__ */ jsxs(
963
- $4e3b923658d69c60$export$28c660c63b792dea,
964
- {
965
- containerPadding,
966
- placement,
967
- shouldFlip,
968
- triggerRef,
969
- offset,
970
- crossOffset,
971
- className: ({ isEntering, isExiting }) => clsx(
972
- "es-uic-group",
973
- "es-uic-z-20 es-uic-select-none es-uic-rounded-md es-uic-border es-uic-px-1.5 es-uic-py-0.5 es-uic-text-sm es-uic-shadow es-uic-backdrop-blur-3xl es-uic-will-change-[transform,opacity] es-uic-fill-mode-forwards",
974
- theme === "light" && "es-uic-border-gray-200 es-uic-bg-white/90 es-uic-text-gray-700",
975
- theme === "dark" && "es-uic-border-gray-600 es-uic-bg-black/80 es-uic-text-gray-100",
976
- isEntering && "es-uic-duration-300 es-uic-ease-out es-uic-animate-in es-uic-fade-in",
977
- isEntering && "placement-left:es-uic-slide-in-from-right-0.5 placement-right:es-uic-slide-in-from-left-0.5 placement-top:es-uic-slide-in-from-bottom-0.5 placement-bottom:es-uic-slide-in-from-top-0.5",
978
- isExiting && "es-uic-duration-150 es-uic-ease-in es-uic-animate-out es-uic-fade-out",
979
- isExiting && "placement-left:es-uic-slide-out-to-right-0.5 placement-right:es-uic-slide-out-to-left-0.5 placement-top:es-uic-slide-out-to-bottom-0.5 placement-bottom:es-uic-slide-out-to-top-0.5",
980
- className
981
- ),
982
- children: [
983
- arrow && /* @__PURE__ */ jsx($44f671af83e7d9e0$export$746d02f47f4d381, { children: /* @__PURE__ */ jsx(
984
- "svg",
985
- {
986
- width: 8,
987
- height: 8,
988
- viewBox: "0 0 8 8",
989
- className: clsx(
990
- "es-uic-m-px es-uic-stroke-none es-uic-drop-shadow-sm",
991
- theme === "light" && "es-uic-fill-gray-200",
992
- theme === "dark" && "es-uic-fill-gray-600",
993
- "group-placement-left:-es-uic-rotate-90 group-placement-right:es-uic-rotate-90 group-placement-bottom:es-uic-rotate-180",
994
- "forced-colors:es-uic-fill-[Canvas] forced-colors:es-uic-stroke-[ButtonBorder]"
995
- ),
996
- children: /* @__PURE__ */ jsx("path", { d: "M0 0 L4 4 L8 0" })
997
- }
998
- ) }),
999
- text
1000
- ]
1001
- }
1002
- )
1003
- ]
1004
- }
1005
- );
1006
- };
1007
- /**
1008
- * A "decorative" tooltip than can be used with element that usually don't support tooltips.
1009
- * Usually the only elements that support tooltips are interactive elements like buttons or links.
1010
- *
1011
- * This component will wrap the element and add the tooltip functionality to it.
1012
- * The tooltip will be shown when the element is hovered or anything within is focused.
1013
- *
1014
- * **Note**: This is not officially supported by the ARIA spec, so use with caution.
1015
- *
1016
- * @see {@link Tooltip} before using this component.
1017
- *
1018
- * @component
1019
- * @param {Object} props - Component props.
1020
- * @param {string|JSX.Element} props.text - The text to display in the tooltip.
1021
- * @param {TooltipTheme} [props.theme='dark'] - The theme of the tooltip.
1022
- * @param {number} [props.offset=0] - Additional offset between the tooltip and the element on the main axis (same axis as element).
1023
- * @param {number} [props.crossOffset=0] - Additional offset between the tooltip and the element on the cross axis (opposite axis as element).
1024
- * @param {number} [props.containerPadding=12] - Space that should be left between the tooltip and the main containing element (usually browser window).
1025
- * @param {number} [props.openDelay=1500] - Duration before the tooltip is shown, in milliseconds.
1026
- * @param {number} [props.closeDelay=500] - Duration before the tooltip is hidden, in milliseconds.
1027
- * @param {boolean} [props.shouldFlip=true] - If `false`, the tooltip will not flip to the opposite side if there is not enough space.
1028
- * @param {TooltipPlacement} [props.placement] - The side of the trigger element where the tooltip will be displayed.
1029
- * @param {string} [props.className] - Classes to pass to the tooltip.
1030
- * @param {string} [props.wrapperClassName] - Classes to pass to the tooltip wrapper (if `doNotReplaceChild` is `false`).
1031
- * @param {boolean} [props.arrow] - If `true`, an arrow is shown on the tooltip.
1032
- *
1033
- * @returns {JSX.Element} The DecorativeTooltip component.
1034
- *
1035
- * @typedef {'light' | 'dark'} TooltipTheme
1036
- * @typedef {'bottom' | 'bottom left' | 'bottom right' | 'bottom start' | 'bottom end' | 'top' | 'top left' | 'top right' | 'top start' | 'top end' | 'left' | 'left top' | 'left bottom' | 'start' | 'start top' | 'start bottom' | 'right' | 'right top' | 'right bottom' | 'end' | 'end top' | 'end bottom'} TooltipPlacement
1037
- *
1038
- * @example
1039
- * <DecorativeTooltip text='My tooltip'>
1040
- * <span>Hover me</span>
1041
- * </DecorativeTooltip>
1042
- *
1043
- * @preserve
1044
- */
1045
- const DecorativeTooltip = (props) => {
1046
- const { openDelay, closeDelay, children, text, wrapperClassName, ...rest } = props;
1047
- const [open, setOpen] = useState(false);
1048
- let { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
1049
- onHoverStart: () => setTimeout(() => setOpen(true), openDelay),
1050
- onHoverEnd: () => setTimeout(() => setOpen(false), closeDelay)
1051
- });
1052
- let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
1053
- onFocusWithinChange: (isFocusWithin) => setOpen(isFocusWithin)
1054
- });
1055
- const ref = useRef(null);
1056
- return /* @__PURE__ */ jsx(
1057
- Tooltip,
1058
- {
1059
- triggerRef: ref,
1060
- text,
1061
- open,
1062
- className: "es-uic-pointer-events-none",
1063
- ...rest,
1064
- children: /* @__PURE__ */ jsx(
1065
- "div",
1066
- {
1067
- ref,
1068
- className: clsx("es-uic-inline", wrapperClassName),
1069
- ...$3ef42575df84b30b$export$9d1611c77c2fe928(hoverProps, focusWithinProps),
1070
- children
1071
- }
1072
- )
1073
- }
1074
- );
1075
- };
1076
- export {
1077
- $fc909762b330b746$export$61c6a8c84e605fb6 as $,
1078
- DecorativeTooltip as D,
1079
- Tooltip as T,
1080
- $9daab02d461809db$export$683480f191c0e3ea as a,
1081
- $dd149f63282afbbf$export$f6211563215e3b37 as b,
1082
- $2a41e45df1593e64$export$d39e1813b3bdd0e1 as c,
1083
- $44f671af83e7d9e0$export$2de4954e8ae13b9f as d
1084
- };