@expcat/tigercat-react 2.0.0 → 2.0.19

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 (64) hide show
  1. package/dist/{chunk-JTFNGXOC.mjs → chunk-2ENQZECC.mjs} +53 -31
  2. package/dist/{chunk-O5RAMCBV.mjs → chunk-2JYJPNW3.mjs} +1 -1
  3. package/dist/{chunk-NBQ3Q6DD.mjs → chunk-2WGEHH5A.mjs} +1 -1
  4. package/dist/{chunk-K7MYQISG.mjs → chunk-54HN5BXW.mjs} +10 -4
  5. package/dist/{chunk-C6QK5MJT.mjs → chunk-5CKMYMTS.mjs} +1 -1
  6. package/dist/{chunk-Y7K27DVV.mjs → chunk-6H5Y7Y6E.mjs} +42 -28
  7. package/dist/chunk-6MGQAJ62.mjs +203 -0
  8. package/dist/{chunk-TO2URY7X.mjs → chunk-7AFRHC7P.mjs} +90 -61
  9. package/dist/{chunk-MGQWVJHX.mjs → chunk-ALSOPYM5.mjs} +69 -62
  10. package/dist/{chunk-YCKY72BW.mjs → chunk-BOGOQ44C.mjs} +1 -1
  11. package/dist/{chunk-Q327ESD2.mjs → chunk-BUXHI6UK.mjs} +17 -38
  12. package/dist/{chunk-TORX7SG4.mjs → chunk-CC7IOSNI.mjs} +10 -4
  13. package/dist/{chunk-OVE2ZUJJ.mjs → chunk-D33BIMGK.mjs} +1 -1
  14. package/dist/{chunk-PYDWF4ED.mjs → chunk-D3KP72UC.mjs} +34 -9
  15. package/dist/{chunk-ZEP7I6WB.mjs → chunk-DPWRXXXW.mjs} +16 -8
  16. package/dist/chunk-HKAZXG74.mjs +308 -0
  17. package/dist/{chunk-QWUDJC6K.mjs → chunk-HOYBHB7B.mjs} +38 -17
  18. package/dist/{chunk-3RY6M4AK.mjs → chunk-HS6KUPTI.mjs} +1 -1
  19. package/dist/{chunk-EKESN747.mjs → chunk-HSBN5MLS.mjs} +1 -1
  20. package/dist/{chunk-AJJJ6HWC.mjs → chunk-K4GIKSZE.mjs} +1 -1
  21. package/dist/{chunk-2UOGBS3C.mjs → chunk-KP6DEYWB.mjs} +27 -6
  22. package/dist/{chunk-PAN256RW.mjs → chunk-KVCI2346.mjs} +59 -55
  23. package/dist/{chunk-LBXNMCXN.mjs → chunk-OZ5XLR22.mjs} +6 -1
  24. package/dist/{chunk-5RVLBNLI.mjs → chunk-RJPNBYK5.mjs} +4 -4
  25. package/dist/{chunk-HELLYIX2.mjs → chunk-V6P7ZK6O.mjs} +3 -3
  26. package/dist/{chunk-4XGO3OSE.mjs → chunk-XE4YFBOZ.mjs} +12 -17
  27. package/dist/{chunk-YI7NQWUV.mjs → chunk-YI6YWH66.mjs} +14 -30
  28. package/dist/{chunk-SHCBCM2W.mjs → chunk-YIB6ZXZF.mjs} +142 -105
  29. package/dist/{chunk-SZBYEGKU.mjs → chunk-ZCGIZOMT.mjs} +1 -1
  30. package/dist/{chunk-S7IB6YST.mjs → chunk-ZG56T75O.mjs} +25 -40
  31. package/dist/{chunk-44BPUG24.mjs → chunk-ZH5ZBLAN.mjs} +38 -16
  32. package/dist/components/ActivityFeed.mjs +3 -3
  33. package/dist/components/AutoComplete.mjs +2 -1
  34. package/dist/components/Cascader.mjs +2 -1
  35. package/dist/components/CodeEditor.mjs +1 -1
  36. package/dist/components/ColorPicker.mjs +2 -1
  37. package/dist/components/CropUpload.mjs +3 -3
  38. package/dist/components/DataExport.mjs +3 -3
  39. package/dist/components/DataTableWithToolbar.mjs +6 -6
  40. package/dist/components/DatePicker.mjs +2 -1
  41. package/dist/components/Drawer.mjs +2 -2
  42. package/dist/components/Dropdown.mjs +2 -2
  43. package/dist/components/FormItem.mjs +2 -1
  44. package/dist/components/Image.mjs +5 -5
  45. package/dist/components/ImageGroup.mjs +3 -3
  46. package/dist/components/ImagePreview.mjs +2 -2
  47. package/dist/components/Loading.mjs +2 -2
  48. package/dist/components/Mentions.mjs +2 -1
  49. package/dist/components/Menu.mjs +2 -2
  50. package/dist/components/Modal.mjs +2 -2
  51. package/dist/components/NotificationCenter.mjs +3 -3
  52. package/dist/components/Popconfirm.mjs +3 -3
  53. package/dist/components/Popover.mjs +3 -3
  54. package/dist/components/Select.mjs +2 -1
  55. package/dist/components/Spotlight.mjs +2 -2
  56. package/dist/components/Table.mjs +3 -2
  57. package/dist/components/TimePicker.mjs +2 -1
  58. package/dist/components/Tooltip.mjs +3 -3
  59. package/dist/components/Tour.mjs +2 -2
  60. package/dist/components/TreeSelect.mjs +2 -1
  61. package/dist/index.mjs +5 -2
  62. package/package.json +2 -2
  63. package/dist/chunk-KVARQQAG.mjs +0 -181
  64. package/dist/chunk-SEWNVIHH.mjs +0 -153
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  ImageGroupContext
3
- } from "./chunk-EKESN747.mjs";
3
+ } from "./chunk-HSBN5MLS.mjs";
4
4
  import {
5
5
  ImagePreview
6
- } from "./chunk-SZBYEGKU.mjs";
6
+ } from "./chunk-ZCGIZOMT.mjs";
7
7
  import {
8
8
  usePopup
9
- } from "./chunk-S7IB6YST.mjs";
9
+ } from "./chunk-ZG56T75O.mjs";
10
10
  import {
11
- renderBodyPortal
12
- } from "./chunk-SEWNVIHH.mjs";
11
+ renderOverlayPortal
12
+ } from "./chunk-HKAZXG74.mjs";
13
13
 
14
14
  // src/components/Image.tsx
15
15
  import { useState, useRef, useEffect, useMemo, useContext, useCallback } from "react";
@@ -68,6 +68,9 @@ var Image = ({
68
68
  triggerRef: hoverTriggerRef,
69
69
  floatingRef: hoverFloatingRef,
70
70
  floatingStyles: hoverFloatingStyles,
71
+ floatingClasses: hoverFloatingClasses,
72
+ positioned: hoverPositioned,
73
+ overlayTarget: hoverOverlayTarget,
71
74
  triggerHandlers: hoverTriggerHandlers
72
75
  } = usePopup({
73
76
  trigger: "hover",
@@ -206,17 +209,22 @@ var Image = ({
206
209
  }
207
210
  }
208
211
  ),
209
- hoverPreviewEnabled && hoverVisible && src && renderBodyPortal(
212
+ hoverPreviewEnabled && hoverVisible && src && renderOverlayPortal(
210
213
  /* @__PURE__ */ jsx(
211
214
  "div",
212
215
  {
213
216
  ref: hoverFloatingRef,
214
217
  style: hoverFloatingStyles,
218
+ className: classNames(
219
+ hoverFloatingClasses,
220
+ "rounded-[var(--tiger-radius-md,0.5rem)] border border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface,#ffffff)] p-1 shadow-lg"
221
+ ),
222
+ "data-positioned": hoverPositioned,
215
223
  "aria-hidden": true,
216
- className: "rounded-[var(--tiger-radius-md,0.5rem)] border border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface,#ffffff)] p-1 shadow-lg",
217
224
  children: /* @__PURE__ */ jsx("img", { src, alt: "", className: "block max-w-[16rem] max-h-[16rem] object-contain" })
218
225
  }
219
- )
226
+ ),
227
+ hoverOverlayTarget
220
228
  )
221
229
  ] });
222
230
  };
@@ -0,0 +1,308 @@
1
+ // src/utils/overlay.ts
2
+ import {
3
+ createElement,
4
+ useEffect,
5
+ useLayoutEffect,
6
+ useRef,
7
+ useState,
8
+ useCallback,
9
+ useMemo
10
+ } from "react";
11
+ import { createPortal } from "react-dom";
12
+ import {
13
+ getFocusTrapNavigation,
14
+ getFocusableElements,
15
+ isEventOutside,
16
+ lockBodyScroll,
17
+ isBrowser,
18
+ computeFloatingPosition,
19
+ autoUpdateFloating,
20
+ resolveAnchoredOverlayTarget,
21
+ getAnchoredOverlayTabTarget,
22
+ getAnchoredOverlayLayoutClasses,
23
+ FLOATING_OVERLAY_Z_INDEX,
24
+ getTransformOrigin,
25
+ restoreFocus,
26
+ registerEscapeDismiss
27
+ } from "@expcat/tigercat-core";
28
+ var OVERLAY_LAYER_SELECTOR = "[data-tiger-overlay-layer]";
29
+ function resolveOverlayLayer(element) {
30
+ return element?.closest(OVERLAY_LAYER_SELECTOR) ?? null;
31
+ }
32
+ function useClickOutside({
33
+ enabled,
34
+ refs,
35
+ onOutsideClick,
36
+ defer = false
37
+ }) {
38
+ useEffect(() => {
39
+ if (!enabled) return;
40
+ const handler = (event) => {
41
+ const elements = refs.map((ref) => ref?.current);
42
+ if (isEventOutside(event, elements)) {
43
+ onOutsideClick();
44
+ }
45
+ };
46
+ const attach = () => document.addEventListener("click", handler);
47
+ const detach = () => document.removeEventListener("click", handler);
48
+ if (!defer) {
49
+ attach();
50
+ return () => detach();
51
+ }
52
+ const timer = window.setTimeout(() => attach(), 0);
53
+ return () => {
54
+ window.clearTimeout(timer);
55
+ detach();
56
+ };
57
+ }, [enabled, refs, onOutsideClick, defer]);
58
+ }
59
+ function useEscapeKey({ enabled, onEscape, layerRef }) {
60
+ useEffect(() => {
61
+ if (!enabled) return;
62
+ return registerEscapeDismiss(document, onEscape, () => layerRef?.current ?? null);
63
+ }, [enabled, layerRef, onEscape]);
64
+ }
65
+ function useBodyScrollLock({ enabled }) {
66
+ useEffect(() => {
67
+ if (!enabled) return;
68
+ return lockBodyScroll();
69
+ }, [enabled]);
70
+ }
71
+ function renderBodyPortal(node) {
72
+ if (!isBrowser()) return null;
73
+ return createPortal(node, document.body);
74
+ }
75
+ function renderOverlayPortal(node, target, disabled = false) {
76
+ if (node == null || typeof node === "boolean") return node;
77
+ const layeredNode = createElement(
78
+ "div",
79
+ { className: "contents", "data-tiger-overlay-layer": "" },
80
+ node,
81
+ createElement("div", {
82
+ key: "overlay-host",
83
+ className: "contents",
84
+ "data-tiger-overlay-host": ""
85
+ })
86
+ );
87
+ if (disabled || !target) return layeredNode;
88
+ return createPortal(layeredNode, target);
89
+ }
90
+ function useFocusTrap({ enabled, containerRef }) {
91
+ useEffect(() => {
92
+ const container = containerRef.current;
93
+ if (!enabled || !container) return;
94
+ const ownerDocument = container.ownerDocument;
95
+ const handler = (event) => {
96
+ if (!(event.target instanceof Node) || !container.contains(event.target)) return;
97
+ const focusables = getFocusableElements(container);
98
+ const activeElement = ownerDocument.activeElement;
99
+ const nav = getFocusTrapNavigation(event, focusables, activeElement);
100
+ if (!nav.shouldHandle || !nav.next) return;
101
+ event.preventDefault();
102
+ nav.next.focus();
103
+ };
104
+ ownerDocument.addEventListener("keydown", handler, true);
105
+ return () => ownerDocument.removeEventListener("keydown", handler, true);
106
+ }, [enabled, containerRef]);
107
+ }
108
+ function useFloating(options) {
109
+ const {
110
+ referenceRef,
111
+ floatingRef,
112
+ enabled,
113
+ placement: initialPlacement = "bottom",
114
+ offset: offsetDistance = 8,
115
+ arrowRef,
116
+ onPlacementChange,
117
+ context
118
+ } = options;
119
+ const [x, setX] = useState(0);
120
+ const [y, setY] = useState(0);
121
+ const [placement, setPlacement] = useState(initialPlacement);
122
+ const [arrowX, setArrowX] = useState(void 0);
123
+ const [arrowY, setArrowY] = useState(void 0);
124
+ const [isPositioned, setIsPositioned] = useState(false);
125
+ const [referenceWidth, setReferenceWidth] = useState(0);
126
+ const enabledRef = useRef(enabled);
127
+ const updateRequestRef = useRef(0);
128
+ enabledRef.current = enabled;
129
+ const onPlacementChangeRef = useRef(onPlacementChange);
130
+ onPlacementChangeRef.current = onPlacementChange;
131
+ const update = useCallback(async () => {
132
+ const request = ++updateRequestRef.current;
133
+ const reference = referenceRef.current;
134
+ const floating = floatingRef.current;
135
+ if (!enabledRef.current || !reference || !floating) return;
136
+ const floatingOptions = {
137
+ placement: initialPlacement,
138
+ offset: offsetDistance,
139
+ flip: true,
140
+ shift: true,
141
+ arrowElement: arrowRef?.current
142
+ };
143
+ const result = await computeFloatingPosition(
144
+ reference,
145
+ floating,
146
+ floatingOptions
147
+ );
148
+ if (request !== updateRequestRef.current || !enabledRef.current || referenceRef.current !== reference || floatingRef.current !== floating) {
149
+ return;
150
+ }
151
+ setReferenceWidth(reference.getBoundingClientRect().width);
152
+ setX(result.x);
153
+ setY(result.y);
154
+ setPlacement((prev) => {
155
+ if (prev !== result.placement) {
156
+ onPlacementChangeRef.current?.(result.placement);
157
+ return result.placement;
158
+ }
159
+ return prev;
160
+ });
161
+ if (result.arrow) {
162
+ setArrowX(result.arrow.x);
163
+ setArrowY(result.arrow.y);
164
+ }
165
+ setIsPositioned(true);
166
+ }, [referenceRef, floatingRef, initialPlacement, offsetDistance, arrowRef]);
167
+ useEffect(() => {
168
+ updateRequestRef.current += 1;
169
+ const reference = referenceRef.current;
170
+ const floating = floatingRef.current;
171
+ if (!enabled || !reference || !floating) {
172
+ setIsPositioned(false);
173
+ return;
174
+ }
175
+ update();
176
+ const cleanup = autoUpdateFloating(reference, floating, update);
177
+ return () => {
178
+ updateRequestRef.current += 1;
179
+ cleanup();
180
+ };
181
+ }, [enabled, referenceRef, floatingRef, update, context]);
182
+ return {
183
+ x,
184
+ y,
185
+ placement,
186
+ arrowX,
187
+ arrowY,
188
+ update,
189
+ isPositioned,
190
+ referenceWidth
191
+ };
192
+ }
193
+ function useAnchoredOverlay({
194
+ enabled,
195
+ referenceRef,
196
+ floatingRef,
197
+ containerRef,
198
+ outsideRefs = [],
199
+ placement = "bottom-start",
200
+ offset = 4,
201
+ layout = "anchored",
202
+ matchReferenceWidth = false,
203
+ portal = true,
204
+ dismissOnOutside = false,
205
+ dismissOnEscape = false,
206
+ restoreFocusOnDismiss = false,
207
+ onDismiss
208
+ }) {
209
+ const [target, setTarget] = useState(null);
210
+ const floatingLayerRef = useMemo(
211
+ () => ({
212
+ get current() {
213
+ return resolveOverlayLayer(floatingRef.current) ?? floatingRef.current;
214
+ }
215
+ }),
216
+ [floatingRef]
217
+ );
218
+ useLayoutEffect(() => {
219
+ if (!portal) {
220
+ setTarget(null);
221
+ return;
222
+ }
223
+ setTarget(resolveAnchoredOverlayTarget(referenceRef.current));
224
+ }, [portal, referenceRef]);
225
+ const resolvedTarget = portal && referenceRef.current ? resolveAnchoredOverlayTarget(referenceRef.current) : null;
226
+ const effectiveTarget = resolvedTarget ?? target;
227
+ const {
228
+ x,
229
+ y,
230
+ placement: actualPlacement,
231
+ isPositioned,
232
+ referenceWidth
233
+ } = useFloating({
234
+ referenceRef,
235
+ floatingRef,
236
+ enabled,
237
+ placement,
238
+ offset,
239
+ context: effectiveTarget
240
+ });
241
+ const dismiss = useCallback(
242
+ (reason) => {
243
+ onDismiss?.(reason);
244
+ if (restoreFocusOnDismiss && reason === "escape") {
245
+ window.setTimeout(() => restoreFocus(referenceRef.current, { preventScroll: true }), 0);
246
+ }
247
+ },
248
+ [onDismiss, referenceRef, restoreFocusOnDismiss]
249
+ );
250
+ const dismissOutside = useCallback(() => dismiss("outside"), [dismiss]);
251
+ const dismissOnEscapeKey = useCallback(() => dismiss("escape"), [dismiss]);
252
+ useClickOutside({
253
+ enabled: enabled && dismissOnOutside,
254
+ refs: [containerRef, referenceRef, floatingLayerRef, ...outsideRefs],
255
+ onOutsideClick: dismissOutside,
256
+ defer: false
257
+ });
258
+ useEscapeKey({
259
+ enabled: enabled && dismissOnEscape,
260
+ onEscape: dismissOnEscapeKey,
261
+ layerRef: floatingLayerRef
262
+ });
263
+ useEffect(() => {
264
+ const floating = floatingRef.current;
265
+ if (!enabled || !floating) return;
266
+ const handleTab = (event) => {
267
+ if (event.key !== "Tab") return;
268
+ const target2 = getAnchoredOverlayTabTarget(
269
+ referenceRef.current,
270
+ floatingRef.current,
271
+ event.shiftKey
272
+ );
273
+ if (!target2) return;
274
+ event.preventDefault();
275
+ window.setTimeout(() => restoreFocus(target2, { preventScroll: true }), 0);
276
+ };
277
+ floating.addEventListener("keydown", handleTab, true);
278
+ return () => floating.removeEventListener("keydown", handleTab, true);
279
+ }, [enabled, floatingRef, referenceRef]);
280
+ const floatingStyles = useMemo(
281
+ () => ({
282
+ "--tiger-overlay-x": `${x}px`,
283
+ "--tiger-overlay-y": `${y}px`,
284
+ "--tiger-overlay-reference-width": `${referenceWidth}px`,
285
+ zIndex: FLOATING_OVERLAY_Z_INDEX,
286
+ transformOrigin: getTransformOrigin(actualPlacement)
287
+ }),
288
+ [actualPlacement, referenceWidth, x, y]
289
+ );
290
+ return {
291
+ target: portal ? effectiveTarget : null,
292
+ floatingStyles,
293
+ floatingClasses: getAnchoredOverlayLayoutClasses(layout, matchReferenceWidth),
294
+ positioned: isPositioned,
295
+ placement: actualPlacement,
296
+ x,
297
+ y
298
+ };
299
+ }
300
+
301
+ export {
302
+ useEscapeKey,
303
+ useBodyScrollLock,
304
+ renderBodyPortal,
305
+ renderOverlayPortal,
306
+ useFocusTrap,
307
+ useAnchoredOverlay
308
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  usePopup
3
- } from "./chunk-S7IB6YST.mjs";
3
+ } from "./chunk-ZG56T75O.mjs";
4
4
  import {
5
- renderBodyPortal
6
- } from "./chunk-SEWNVIHH.mjs";
5
+ renderOverlayPortal
6
+ } from "./chunk-HKAZXG74.mjs";
7
7
 
8
8
  // src/components/Popover.tsx
9
9
  import { useMemo, useRef } from "react";
@@ -41,7 +41,17 @@ var Popover = ({
41
41
  const popoverId = popoverIdRef.current;
42
42
  const titleId = `${popoverId}-title`;
43
43
  const contentId = `${popoverId}-content`;
44
- const { currentVisible, containerRef, triggerRef, floatingRef, floatingStyles, triggerHandlers } = usePopup({ open, defaultOpen, disabled, trigger, placement, offset, onOpenChange });
44
+ const {
45
+ currentVisible,
46
+ containerRef,
47
+ triggerRef,
48
+ floatingRef,
49
+ floatingStyles,
50
+ floatingClasses,
51
+ positioned,
52
+ overlayTarget,
53
+ triggerHandlers
54
+ } = usePopup({ open, defaultOpen, disabled, trigger, placement, offset, onOpenChange });
45
55
  const containerClasses = useMemo(
46
56
  () => classNames(getPopoverContainerClasses(), className),
47
57
  [className]
@@ -64,22 +74,33 @@ var Popover = ({
64
74
  children: typeof children === "function" ? children({ open: Boolean(currentVisible) }) : children
65
75
  }
66
76
  ),
67
- currentVisible && renderBodyPortal(
68
- /* @__PURE__ */ jsx("div", { ref: floatingRef, style: floatingStyles, "aria-hidden": false, children: /* @__PURE__ */ jsxs(
77
+ currentVisible && renderOverlayPortal(
78
+ /* @__PURE__ */ jsx(
69
79
  "div",
70
80
  {
71
- id: popoverId,
72
- role: "dialog",
73
- "aria-modal": "false",
74
- "aria-labelledby": hasTitle ? titleId : void 0,
75
- "aria-describedby": hasContent ? contentId : void 0,
76
- className: contentClasses,
77
- children: [
78
- hasTitle && /* @__PURE__ */ jsx("div", { id: titleId, className: POPOVER_TITLE_CLASSES, children: titleContent || title }),
79
- hasContent && /* @__PURE__ */ jsx("div", { id: contentId, className: POPOVER_TEXT_CLASSES, children: contentContent || content })
80
- ]
81
+ ref: floatingRef,
82
+ className: floatingClasses,
83
+ style: floatingStyles,
84
+ "data-positioned": positioned,
85
+ "aria-hidden": false,
86
+ children: /* @__PURE__ */ jsxs(
87
+ "div",
88
+ {
89
+ id: popoverId,
90
+ role: "dialog",
91
+ "aria-modal": "false",
92
+ "aria-labelledby": hasTitle ? titleId : void 0,
93
+ "aria-describedby": hasContent ? contentId : void 0,
94
+ className: contentClasses,
95
+ children: [
96
+ hasTitle && /* @__PURE__ */ jsx("div", { id: titleId, className: POPOVER_TITLE_CLASSES, children: titleContent || title }),
97
+ hasContent && /* @__PURE__ */ jsx("div", { id: contentId, className: POPOVER_TEXT_CLASSES, children: contentContent || content })
98
+ ]
99
+ }
100
+ )
81
101
  }
82
- ) })
102
+ ),
103
+ overlayTarget
83
104
  )
84
105
  ] });
85
106
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Modal
3
- } from "./chunk-K7MYQISG.mjs";
3
+ } from "./chunk-54HN5BXW.mjs";
4
4
  import {
5
5
  ImageCropper
6
6
  } from "./chunk-PD6Q36OO.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ImagePreview
3
- } from "./chunk-SZBYEGKU.mjs";
3
+ } from "./chunk-ZCGIZOMT.mjs";
4
4
 
5
5
  // src/components/ImageGroup.tsx
6
6
  import { useState, useCallback, useMemo, createContext, useRef } from "react";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  renderBodyPortal,
3
3
  useBodyScrollLock
4
- } from "./chunk-SEWNVIHH.mjs";
4
+ } from "./chunk-HKAZXG74.mjs";
5
5
  import {
6
6
  useTigerConfig
7
7
  } from "./chunk-YSIXURBW.mjs";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  usePopup
3
- } from "./chunk-S7IB6YST.mjs";
3
+ } from "./chunk-ZG56T75O.mjs";
4
4
  import {
5
- renderBodyPortal
6
- } from "./chunk-SEWNVIHH.mjs";
5
+ renderOverlayPortal
6
+ } from "./chunk-HKAZXG74.mjs";
7
7
 
8
8
  // src/components/Tooltip.tsx
9
9
  import { useMemo, useRef } from "react";
@@ -34,7 +34,17 @@ var Tooltip = ({
34
34
  if (!tooltipIdRef.current) tooltipIdRef.current = createTooltipId();
35
35
  const tooltipId = tooltipIdRef.current;
36
36
  const describedBy = content != null ? tooltipId : void 0;
37
- const { currentVisible, containerRef, triggerRef, floatingRef, floatingStyles, triggerHandlers } = usePopup({ open, defaultOpen, disabled, trigger, placement, offset, onOpenChange });
37
+ const {
38
+ currentVisible,
39
+ containerRef,
40
+ triggerRef,
41
+ floatingRef,
42
+ floatingStyles,
43
+ floatingClasses,
44
+ positioned,
45
+ overlayTarget,
46
+ triggerHandlers
47
+ } = usePopup({ open, defaultOpen, disabled, trigger, placement, offset, onOpenChange });
38
48
  const containerClasses = useMemo(
39
49
  () => classNames(getTooltipContainerClasses(), className),
40
50
  [className]
@@ -53,8 +63,19 @@ var Tooltip = ({
53
63
  children
54
64
  }
55
65
  ),
56
- currentVisible && renderBodyPortal(
57
- /* @__PURE__ */ jsx("div", { ref: floatingRef, style: floatingStyles, "aria-hidden": false, children: /* @__PURE__ */ jsx("div", { id: tooltipId, role: "tooltip", className: contentClasses, children: content }) })
66
+ currentVisible && renderOverlayPortal(
67
+ /* @__PURE__ */ jsx(
68
+ "div",
69
+ {
70
+ ref: floatingRef,
71
+ className: floatingClasses,
72
+ style: floatingStyles,
73
+ "data-positioned": positioned,
74
+ "aria-hidden": false,
75
+ children: /* @__PURE__ */ jsx("div", { id: tooltipId, role: "tooltip", className: contentClasses, children: content })
76
+ }
77
+ ),
78
+ overlayTarget
58
79
  )
59
80
  ] });
60
81
  };
@@ -1,3 +1,7 @@
1
+ import {
2
+ renderOverlayPortal,
3
+ useAnchoredOverlay
4
+ } from "./chunk-HKAZXG74.mjs";
1
5
  import {
2
6
  useTigerConfig
3
7
  } from "./chunk-YSIXURBW.mjs";
@@ -415,21 +419,6 @@ function useSelectState(props) {
415
419
  findFirstEnabledIndex,
416
420
  focusOptionAt
417
421
  ]);
418
- useEffect(() => {
419
- if (!isOpen) {
420
- return;
421
- }
422
- const handleClickOutside = (event) => {
423
- const target = event.target;
424
- if (dropdownRef.current && triggerRef.current && !dropdownRef.current.contains(target) && !triggerRef.current.contains(target)) {
425
- closeDropdown();
426
- }
427
- };
428
- document.addEventListener("click", handleClickOutside);
429
- return () => {
430
- document.removeEventListener("click", handleClickOutside);
431
- };
432
- }, [isOpen]);
433
422
  return {
434
423
  listboxId,
435
424
  getOptionId,
@@ -639,6 +628,60 @@ function renderOptions(ctx) {
639
628
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
640
629
  var Select = (props) => {
641
630
  const ctx = useSelectState(props);
631
+ const overlay = useAnchoredOverlay({
632
+ enabled: ctx.isOpen,
633
+ referenceRef: ctx.triggerRef,
634
+ floatingRef: ctx.dropdownRef,
635
+ placement: "bottom-start",
636
+ offset: 4,
637
+ layout: "fullscreen-sm",
638
+ matchReferenceWidth: true,
639
+ dismissOnOutside: true,
640
+ dismissOnEscape: true,
641
+ restoreFocusOnDismiss: true,
642
+ onDismiss: ctx.closeDropdown
643
+ });
644
+ const dropdown = ctx.isOpen ? /* @__PURE__ */ jsxs2(
645
+ "div",
646
+ {
647
+ ref: ctx.dropdownRef,
648
+ className: classNames2(selectDropdownBaseClasses, overlay.floatingClasses),
649
+ style: overlay.floatingStyles,
650
+ "data-positioned": overlay.positioned,
651
+ "data-tiger-select-dropdown": "",
652
+ role: "listbox",
653
+ id: ctx.listboxId,
654
+ "aria-multiselectable": ctx.isMultiple ? true : void 0,
655
+ onKeyDown: ctx.handleDropdownKeyDown,
656
+ children: [
657
+ ctx.searchable && /* @__PURE__ */ jsx3(
658
+ "input",
659
+ {
660
+ ref: ctx.searchInputRef,
661
+ type: "text",
662
+ className: selectSearchInputClasses,
663
+ placeholder: ctx.searchPlaceholder,
664
+ value: ctx.searchQuery,
665
+ onChange: ctx.handleSearchInput,
666
+ onKeyDown: ctx.handleSearchKeyDown
667
+ }
668
+ ),
669
+ renderOptions(ctx),
670
+ /* @__PURE__ */ jsx3("div", { className: selectDoneActionClasses, children: /* @__PURE__ */ jsx3(
671
+ "button",
672
+ {
673
+ type: "button",
674
+ className: selectDoneButtonClasses,
675
+ onClick: ctx.closeDropdown,
676
+ onKeyDown: (event) => {
677
+ if (event.key === "Enter" || event.key === " ") event.stopPropagation();
678
+ },
679
+ children: ctx.doneText
680
+ }
681
+ ) })
682
+ ]
683
+ }
684
+ ) : null;
642
685
  return /* @__PURE__ */ jsxs2("div", { ...ctx.divProps, className: ctx.containerClasses, children: [
643
686
  /* @__PURE__ */ jsx3(
644
687
  "button",
@@ -680,46 +723,7 @@ var Select = (props) => {
680
723
  ),
681
724
  /* @__PURE__ */ jsx3("span", { className: classNames2("inline-flex", ctx.isOpen && "rotate-180"), "aria-hidden": "true", children: /* @__PURE__ */ jsx3(SelectChevronIcon, {}) })
682
725
  ] }),
683
- ctx.isOpen && /* @__PURE__ */ jsxs2(
684
- "div",
685
- {
686
- ref: ctx.dropdownRef,
687
- className: selectDropdownBaseClasses,
688
- role: "listbox",
689
- id: ctx.listboxId,
690
- "aria-multiselectable": ctx.isMultiple ? true : void 0,
691
- onKeyDown: ctx.handleDropdownKeyDown,
692
- children: [
693
- ctx.searchable && /* @__PURE__ */ jsx3(
694
- "input",
695
- {
696
- ref: ctx.searchInputRef,
697
- type: "text",
698
- className: selectSearchInputClasses,
699
- placeholder: ctx.searchPlaceholder,
700
- value: ctx.searchQuery,
701
- onChange: ctx.handleSearchInput,
702
- onKeyDown: ctx.handleSearchKeyDown
703
- }
704
- ),
705
- renderOptions(ctx),
706
- /* @__PURE__ */ jsx3("div", { className: selectDoneActionClasses, children: /* @__PURE__ */ jsx3(
707
- "button",
708
- {
709
- type: "button",
710
- className: selectDoneButtonClasses,
711
- onClick: ctx.closeDropdown,
712
- onKeyDown: (event) => {
713
- if (event.key === "Enter" || event.key === " ") {
714
- event.stopPropagation();
715
- }
716
- },
717
- children: ctx.doneText
718
- }
719
- ) })
720
- ]
721
- }
722
- )
726
+ dropdown && renderOverlayPortal(dropdown, overlay.target)
723
727
  ] });
724
728
  };
725
729
 
@@ -11,6 +11,7 @@ import {
11
11
  handleTabKey,
12
12
  getActiveLineIndex,
13
13
  getCodeEditorActiveLineClasses,
14
+ getCodeEditorCaretClasses,
14
15
  codeEditorTextareaClasses,
15
16
  codeEditorHighlightClasses
16
17
  } from "@expcat/tigercat-core";
@@ -144,7 +145,11 @@ var CodeEditor = ({
144
145
  "textarea",
145
146
  {
146
147
  ref: textareaRef,
147
- className: classNames(codeEditorTextareaClasses, wrapClass),
148
+ className: classNames(
149
+ codeEditorTextareaClasses,
150
+ getCodeEditorCaretClasses(theme),
151
+ wrapClass
152
+ ),
148
153
  value: code,
149
154
  onChange: handleInput,
150
155
  onKeyDown: handleKeyDown,