@luxfi/ui 7.4.0 → 7.4.2

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 (130) hide show
  1. package/dist/avatar.cjs +7 -6
  2. package/dist/avatar.js +7 -5
  3. package/dist/badge.cjs +30 -32
  4. package/dist/badge.js +30 -32
  5. package/dist/bank.d.cts +3 -3
  6. package/dist/bank.d.ts +3 -3
  7. package/dist/checkbox.cjs +4 -4
  8. package/dist/checkbox.d.cts +3 -2
  9. package/dist/checkbox.d.ts +3 -2
  10. package/dist/checkbox.js +5 -4
  11. package/dist/chrome.cjs +950 -0
  12. package/dist/chrome.d.cts +93 -0
  13. package/dist/chrome.d.ts +93 -0
  14. package/dist/chrome.js +921 -0
  15. package/dist/drawer.cjs +86 -20
  16. package/dist/drawer.js +85 -19
  17. package/dist/expiration-selector.cjs +3 -2
  18. package/dist/expiration-selector.js +3 -2
  19. package/dist/greeks-display.cjs +6 -6
  20. package/dist/greeks-display.js +6 -6
  21. package/dist/gui.cjs +13 -0
  22. package/dist/gui.d.cts +2 -0
  23. package/dist/gui.d.ts +2 -0
  24. package/dist/gui.js +2 -0
  25. package/dist/heading.cjs +4 -2
  26. package/dist/heading.js +4 -2
  27. package/dist/iam.cjs +206 -0
  28. package/dist/iam.d.cts +65 -0
  29. package/dist/iam.d.ts +65 -0
  30. package/dist/iam.js +201 -0
  31. package/dist/icons.cjs +13 -0
  32. package/dist/icons.d.cts +1 -0
  33. package/dist/icons.d.ts +1 -0
  34. package/dist/icons.js +2 -0
  35. package/dist/identity.cjs +420 -0
  36. package/dist/identity.d.cts +64 -0
  37. package/dist/identity.d.ts +64 -0
  38. package/dist/identity.js +398 -0
  39. package/dist/index.cjs +1597 -833
  40. package/dist/index.d.cts +7 -3
  41. package/dist/index.d.ts +7 -3
  42. package/dist/index.js +1574 -828
  43. package/dist/input.cjs +3 -1
  44. package/dist/input.d.cts +3 -5
  45. package/dist/input.d.ts +3 -5
  46. package/dist/input.js +3 -1
  47. package/dist/lux.config.cjs +23 -2
  48. package/dist/lux.config.d.cts +28 -10
  49. package/dist/lux.config.d.ts +28 -10
  50. package/dist/lux.config.js +23 -2
  51. package/dist/menu.cjs +4 -4
  52. package/dist/menu.js +4 -4
  53. package/dist/next.cjs +99 -0
  54. package/dist/next.d.cts +29 -0
  55. package/dist/next.d.ts +29 -0
  56. package/dist/next.js +96 -0
  57. package/dist/option-chain.cjs +1 -1
  58. package/dist/option-chain.js +1 -1
  59. package/dist/option-position.cjs +2 -1
  60. package/dist/option-position.js +2 -1
  61. package/dist/pnl-diagram.cjs +8 -6
  62. package/dist/pnl-diagram.js +8 -6
  63. package/dist/progress.cjs +7 -6
  64. package/dist/progress.js +7 -5
  65. package/dist/provider.cjs +136 -4
  66. package/dist/provider.d.cts +15 -3
  67. package/dist/provider.d.ts +15 -3
  68. package/dist/provider.js +136 -5
  69. package/dist/radio.cjs +9 -7
  70. package/dist/radio.js +10 -7
  71. package/dist/separator.cjs +3 -1
  72. package/dist/separator.js +3 -1
  73. package/dist/slider.cjs +28 -16
  74. package/dist/slider.js +28 -15
  75. package/dist/strategy-builder.cjs +2 -1
  76. package/dist/strategy-builder.js +2 -1
  77. package/dist/switch.cjs +11 -12
  78. package/dist/switch.js +12 -12
  79. package/dist/tag.cjs +31 -33
  80. package/dist/tag.js +30 -32
  81. package/dist/textarea.cjs +3 -1
  82. package/dist/textarea.js +3 -1
  83. package/dist/tooltip.cjs +25 -27
  84. package/dist/tooltip.js +24 -26
  85. package/dist/use-narrow.cjs +46 -0
  86. package/dist/use-narrow.d.cts +12 -0
  87. package/dist/use-narrow.d.ts +12 -0
  88. package/dist/use-narrow.js +20 -0
  89. package/dist/vite.cjs +40 -0
  90. package/dist/vite.d.cts +29 -0
  91. package/dist/vite.d.ts +29 -0
  92. package/dist/vite.js +38 -0
  93. package/dist/white-label.cjs +132 -0
  94. package/dist/white-label.d.cts +59 -0
  95. package/dist/white-label.d.ts +59 -0
  96. package/dist/white-label.js +124 -0
  97. package/package.json +85 -19
  98. package/src/avatar.tsx +22 -16
  99. package/src/checkbox.tsx +15 -10
  100. package/src/chrome.tsx +459 -0
  101. package/src/drawer.tsx +83 -10
  102. package/src/expiration-selector.tsx +3 -2
  103. package/src/greeks-display.tsx +9 -6
  104. package/src/gui.ts +17 -0
  105. package/src/heading.tsx +12 -8
  106. package/src/iam.ts +170 -0
  107. package/src/icons.ts +18 -0
  108. package/src/identity.tsx +318 -0
  109. package/src/index.ts +44 -1
  110. package/src/input.tsx +13 -9
  111. package/src/lux.config.ts +16 -15
  112. package/src/menu.tsx +4 -4
  113. package/src/next.ts +142 -0
  114. package/src/option-chain.tsx +1 -1
  115. package/src/option-position.tsx +2 -1
  116. package/src/pnl-diagram.tsx +11 -6
  117. package/src/progress.tsx +15 -8
  118. package/src/provider.tsx +48 -7
  119. package/src/radio.tsx +15 -11
  120. package/src/separator.tsx +8 -3
  121. package/src/slider.tsx +35 -19
  122. package/src/strategy-builder.tsx +3 -2
  123. package/src/switch.tsx +17 -16
  124. package/src/textarea.tsx +8 -4
  125. package/src/tooltip.tsx +2 -21
  126. package/src/use-narrow.ts +40 -0
  127. package/src/vite.ts +78 -0
  128. package/src/white-label.ts +240 -0
  129. package/tokens.css +544 -319
  130. package/src/tokens.css +0 -438
package/dist/tag.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var React3 = require('react');
4
+ var React4 = require('react');
5
5
  var clsx = require('clsx');
6
6
  var tailwindMerge = require('tailwind-merge');
7
7
  var gui = require('@hanzo/gui');
@@ -26,7 +26,7 @@ function _interopNamespace(e) {
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
29
- var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
29
+ var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
30
30
 
31
31
  // src/tag.tsx
32
32
  function cn(...inputs) {
@@ -67,7 +67,7 @@ var CLOSE_BUTTON_CLASSES = [
67
67
  "hover:text-[var(--hover-color,currentColor)]",
68
68
  "disabled:opacity-40"
69
69
  ].join(" ");
70
- var CloseButton = React3__namespace.forwardRef(function CloseButton2(props, ref) {
70
+ var CloseButton = React4__namespace.forwardRef(function CloseButton2(props, ref) {
71
71
  const { variant: _variant, size: _size, className, children, ...rest } = props;
72
72
  return /* @__PURE__ */ jsxRuntime.jsx(
73
73
  CloseButtonFrame,
@@ -214,7 +214,7 @@ var SKELETON_CLASSES = [
214
214
  "bg-[length:200%_100%]"
215
215
  ].join(" ");
216
216
  var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
217
- var Skeleton = React3__namespace.forwardRef(
217
+ var Skeleton = React4__namespace.forwardRef(
218
218
  function Skeleton2(props, ref) {
219
219
  const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
220
220
  const shimStyle = shimToStyle(props);
@@ -223,10 +223,10 @@ var Skeleton = React3__namespace.forwardRef(
223
223
  const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
224
224
  const htmlRest = stripShims(allRest);
225
225
  if (!loading) {
226
- if (asChild && React3__namespace.isValidElement(children)) return children;
226
+ if (asChild && React4__namespace.isValidElement(children)) return children;
227
227
  return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
228
228
  }
229
- if (asChild && React3__namespace.isValidElement(children)) {
229
+ if (asChild && React4__namespace.isValidElement(children)) {
230
230
  return /* @__PURE__ */ jsxRuntime.jsx(
231
231
  Component,
232
232
  {
@@ -252,7 +252,7 @@ var Skeleton = React3__namespace.forwardRef(
252
252
  );
253
253
  }
254
254
  );
255
- React3__namespace.forwardRef(
255
+ React4__namespace.forwardRef(
256
256
  function SkeletonCircle2(props, ref) {
257
257
  const { size = 40, loading = true, className, ...rest } = props;
258
258
  const dimension = typeof size === "number" ? `${size}px` : size;
@@ -268,7 +268,7 @@ React3__namespace.forwardRef(
268
268
  );
269
269
  }
270
270
  );
271
- React3__namespace.forwardRef(
271
+ React4__namespace.forwardRef(
272
272
  function SkeletonText2(props, ref) {
273
273
  const { noOfLines = 3, loading = true, className, ...rest } = props;
274
274
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex w-full flex-col gap-2", className), ...rest, children: Array.from({ length: noOfLines }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -281,26 +281,24 @@ React3__namespace.forwardRef(
281
281
  )) });
282
282
  }
283
283
  );
284
- var LG_BREAKPOINT = 1024;
285
- function useIsMobile() {
286
- const [isMobile, setIsMobile] = React3__namespace.useState(() => {
287
- if (typeof window === "undefined") return false;
288
- return window.innerWidth < LG_BREAKPOINT;
289
- });
290
- React3__namespace.useEffect(() => {
291
- const mql = window.matchMedia(`(max-width: ${LG_BREAKPOINT - 1}px)`);
292
- const handler = (e) => setIsMobile(e.matches);
293
- setIsMobile(mql.matches);
294
- mql.addEventListener("change", handler);
295
- return () => mql.removeEventListener("change", handler);
296
- }, []);
297
- return isMobile;
284
+ var TOUCH_PX = 1024;
285
+ function useBelow(px) {
286
+ const [below, setBelow] = React4__namespace.useState(false);
287
+ React4__namespace.useEffect(() => {
288
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
289
+ const apply = () => setBelow(mql.matches);
290
+ apply();
291
+ mql.addEventListener("change", apply);
292
+ return () => mql.removeEventListener("change", apply);
293
+ }, [px]);
294
+ return below;
298
295
  }
296
+ var useIsTouch = () => useBelow(TOUCH_PX);
299
297
  function mapPlacement(p) {
300
298
  if (!p) return void 0;
301
299
  return p;
302
300
  }
303
- var Tooltip = React3__namespace.forwardRef(
301
+ var Tooltip = React4__namespace.forwardRef(
304
302
  function Tooltip2(props, ref) {
305
303
  const {
306
304
  showArrow: showArrowProp,
@@ -319,28 +317,28 @@ var Tooltip = React3__namespace.forwardRef(
319
317
  interactive,
320
318
  positioning
321
319
  } = props;
322
- const [open, setOpen] = React3__namespace.useState(defaultOpen);
323
- const timeoutRef = React3__namespace.useRef(null);
324
- const isMobile = useIsMobile();
325
- const handleOpenChange = React3__namespace.useCallback((nextOpen) => {
320
+ const [open, setOpen] = React4__namespace.useState(defaultOpen);
321
+ const timeoutRef = React4__namespace.useRef(null);
322
+ const isMobile = useIsTouch();
323
+ const handleOpenChange = React4__namespace.useCallback((nextOpen) => {
326
324
  setOpen(nextOpen);
327
325
  onOpenChange?.({ open: nextOpen });
328
326
  }, [onOpenChange]);
329
- const handleOpenChangeManual = React3__namespace.useCallback((nextOpen) => {
327
+ const handleOpenChangeManual = React4__namespace.useCallback((nextOpen) => {
330
328
  timeoutRef.current && window.clearTimeout(timeoutRef.current);
331
329
  timeoutRef.current = window.setTimeout(() => {
332
330
  setOpen(nextOpen);
333
331
  onOpenChange?.({ open: nextOpen });
334
332
  }, nextOpen ? openDelay : closeDelay);
335
333
  }, [closeDelay, openDelay, onOpenChange]);
336
- const handleClickAway = React3__namespace.useCallback(() => {
334
+ const handleClickAway = React4__namespace.useCallback(() => {
337
335
  handleOpenChangeManual(false);
338
336
  }, [handleOpenChangeManual]);
339
337
  const triggerRef = usehooks.useClickAway(handleClickAway);
340
- const handleTriggerClick = React3__namespace.useCallback(() => {
338
+ const handleTriggerClick = React4__namespace.useCallback(() => {
341
339
  handleOpenChangeManual(!open);
342
340
  }, [handleOpenChangeManual, open]);
343
- const handleContentClick = React3__namespace.useCallback((event) => {
341
+ const handleContentClick = React4__namespace.useCallback((event) => {
344
342
  event.stopPropagation();
345
343
  if (interactive) {
346
344
  const closestLink = event.target?.closest("a");
@@ -349,7 +347,7 @@ var Tooltip = React3__namespace.forwardRef(
349
347
  }
350
348
  }
351
349
  }, [interactive, handleOpenChangeManual]);
352
- React3__namespace.useEffect(() => {
350
+ React4__namespace.useEffect(() => {
353
351
  return () => {
354
352
  if (timeoutRef.current) {
355
353
  clearTimeout(timeoutRef.current);
@@ -440,7 +438,7 @@ var TAG_SELECTED_CLASSES = [
440
438
  "hover:opacity-76"
441
439
  ].join(" ");
442
440
  var TAG_DISABLED_CLASSES = "opacity-40 pointer-events-none cursor-not-allowed";
443
- var Tag = React3__namespace.forwardRef(
441
+ var Tag = React4__namespace.forwardRef(
444
442
  function Tag2(props, ref) {
445
443
  const {
446
444
  variant,
package/dist/tag.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import * as React3 from 'react';
2
+ import * as React4 from 'react';
3
3
  import { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
5
5
  import { styled, View, TooltipGroup, Tooltip as Tooltip$1 } from '@hanzo/gui';
@@ -45,7 +45,7 @@ var CLOSE_BUTTON_CLASSES = [
45
45
  "hover:text-[var(--hover-color,currentColor)]",
46
46
  "disabled:opacity-40"
47
47
  ].join(" ");
48
- var CloseButton = React3.forwardRef(function CloseButton2(props, ref) {
48
+ var CloseButton = React4.forwardRef(function CloseButton2(props, ref) {
49
49
  const { variant: _variant, size: _size, className, children, ...rest } = props;
50
50
  return /* @__PURE__ */ jsx(
51
51
  CloseButtonFrame,
@@ -192,7 +192,7 @@ var SKELETON_CLASSES = [
192
192
  "bg-[length:200%_100%]"
193
193
  ].join(" ");
194
194
  var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
195
- var Skeleton = React3.forwardRef(
195
+ var Skeleton = React4.forwardRef(
196
196
  function Skeleton2(props, ref) {
197
197
  const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
198
198
  const shimStyle = shimToStyle(props);
@@ -201,10 +201,10 @@ var Skeleton = React3.forwardRef(
201
201
  const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
202
202
  const htmlRest = stripShims(allRest);
203
203
  if (!loading) {
204
- if (asChild && React3.isValidElement(children)) return children;
204
+ if (asChild && React4.isValidElement(children)) return children;
205
205
  return /* @__PURE__ */ jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
206
206
  }
207
- if (asChild && React3.isValidElement(children)) {
207
+ if (asChild && React4.isValidElement(children)) {
208
208
  return /* @__PURE__ */ jsx(
209
209
  Component,
210
210
  {
@@ -230,7 +230,7 @@ var Skeleton = React3.forwardRef(
230
230
  );
231
231
  }
232
232
  );
233
- React3.forwardRef(
233
+ React4.forwardRef(
234
234
  function SkeletonCircle2(props, ref) {
235
235
  const { size = 40, loading = true, className, ...rest } = props;
236
236
  const dimension = typeof size === "number" ? `${size}px` : size;
@@ -246,7 +246,7 @@ React3.forwardRef(
246
246
  );
247
247
  }
248
248
  );
249
- React3.forwardRef(
249
+ React4.forwardRef(
250
250
  function SkeletonText2(props, ref) {
251
251
  const { noOfLines = 3, loading = true, className, ...rest } = props;
252
252
  return /* @__PURE__ */ jsx("div", { ref, className: cn("flex w-full flex-col gap-2", className), ...rest, children: Array.from({ length: noOfLines }).map((_, index) => /* @__PURE__ */ jsx(
@@ -259,26 +259,24 @@ React3.forwardRef(
259
259
  )) });
260
260
  }
261
261
  );
262
- var LG_BREAKPOINT = 1024;
263
- function useIsMobile() {
264
- const [isMobile, setIsMobile] = React3.useState(() => {
265
- if (typeof window === "undefined") return false;
266
- return window.innerWidth < LG_BREAKPOINT;
267
- });
268
- React3.useEffect(() => {
269
- const mql = window.matchMedia(`(max-width: ${LG_BREAKPOINT - 1}px)`);
270
- const handler = (e) => setIsMobile(e.matches);
271
- setIsMobile(mql.matches);
272
- mql.addEventListener("change", handler);
273
- return () => mql.removeEventListener("change", handler);
274
- }, []);
275
- return isMobile;
262
+ var TOUCH_PX = 1024;
263
+ function useBelow(px) {
264
+ const [below, setBelow] = React4.useState(false);
265
+ React4.useEffect(() => {
266
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
267
+ const apply = () => setBelow(mql.matches);
268
+ apply();
269
+ mql.addEventListener("change", apply);
270
+ return () => mql.removeEventListener("change", apply);
271
+ }, [px]);
272
+ return below;
276
273
  }
274
+ var useIsTouch = () => useBelow(TOUCH_PX);
277
275
  function mapPlacement(p) {
278
276
  if (!p) return void 0;
279
277
  return p;
280
278
  }
281
- var Tooltip = React3.forwardRef(
279
+ var Tooltip = React4.forwardRef(
282
280
  function Tooltip2(props, ref) {
283
281
  const {
284
282
  showArrow: showArrowProp,
@@ -297,28 +295,28 @@ var Tooltip = React3.forwardRef(
297
295
  interactive,
298
296
  positioning
299
297
  } = props;
300
- const [open, setOpen] = React3.useState(defaultOpen);
301
- const timeoutRef = React3.useRef(null);
302
- const isMobile = useIsMobile();
303
- const handleOpenChange = React3.useCallback((nextOpen) => {
298
+ const [open, setOpen] = React4.useState(defaultOpen);
299
+ const timeoutRef = React4.useRef(null);
300
+ const isMobile = useIsTouch();
301
+ const handleOpenChange = React4.useCallback((nextOpen) => {
304
302
  setOpen(nextOpen);
305
303
  onOpenChange?.({ open: nextOpen });
306
304
  }, [onOpenChange]);
307
- const handleOpenChangeManual = React3.useCallback((nextOpen) => {
305
+ const handleOpenChangeManual = React4.useCallback((nextOpen) => {
308
306
  timeoutRef.current && window.clearTimeout(timeoutRef.current);
309
307
  timeoutRef.current = window.setTimeout(() => {
310
308
  setOpen(nextOpen);
311
309
  onOpenChange?.({ open: nextOpen });
312
310
  }, nextOpen ? openDelay : closeDelay);
313
311
  }, [closeDelay, openDelay, onOpenChange]);
314
- const handleClickAway = React3.useCallback(() => {
312
+ const handleClickAway = React4.useCallback(() => {
315
313
  handleOpenChangeManual(false);
316
314
  }, [handleOpenChangeManual]);
317
315
  const triggerRef = useClickAway(handleClickAway);
318
- const handleTriggerClick = React3.useCallback(() => {
316
+ const handleTriggerClick = React4.useCallback(() => {
319
317
  handleOpenChangeManual(!open);
320
318
  }, [handleOpenChangeManual, open]);
321
- const handleContentClick = React3.useCallback((event) => {
319
+ const handleContentClick = React4.useCallback((event) => {
322
320
  event.stopPropagation();
323
321
  if (interactive) {
324
322
  const closestLink = event.target?.closest("a");
@@ -327,7 +325,7 @@ var Tooltip = React3.forwardRef(
327
325
  }
328
326
  }
329
327
  }, [interactive, handleOpenChangeManual]);
330
- React3.useEffect(() => {
328
+ React4.useEffect(() => {
331
329
  return () => {
332
330
  if (timeoutRef.current) {
333
331
  clearTimeout(timeoutRef.current);
@@ -418,7 +416,7 @@ var TAG_SELECTED_CLASSES = [
418
416
  "hover:opacity-76"
419
417
  ].join(" ");
420
418
  var TAG_DISABLED_CLASSES = "opacity-40 pointer-events-none cursor-not-allowed";
421
- var Tag = React3.forwardRef(
419
+ var Tag = React4.forwardRef(
422
420
  function Tag2(props, ref) {
423
421
  const {
424
422
  variant,
package/dist/textarea.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
+ var gui = require('@hanzo/gui');
4
5
  var React = require('react');
5
6
  var clsx = require('clsx');
6
7
  var tailwindMerge = require('tailwind-merge');
@@ -47,9 +48,10 @@ var Textarea = React__default.default.forwardRef(
47
48
  [onChange, onChangeText]
48
49
  );
49
50
  return /* @__PURE__ */ jsxRuntime.jsx(
50
- "textarea",
51
+ gui.TextArea,
51
52
  {
52
53
  ref,
54
+ unstyled: true,
53
55
  className: cn(TEXTAREA_BASE, TEXTAREA_SIZE_CLASSES[size], TEXTAREA_VARIANT_CLASSES[variant], className),
54
56
  ...rest,
55
57
  onChange: handleChange
package/dist/textarea.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { TextArea } from '@hanzo/gui';
2
3
  import React from 'react';
3
4
  import { clsx } from 'clsx';
4
5
  import { twMerge } from 'tailwind-merge';
@@ -41,9 +42,10 @@ var Textarea = React.forwardRef(
41
42
  [onChange, onChangeText]
42
43
  );
43
44
  return /* @__PURE__ */ jsx(
44
- "textarea",
45
+ TextArea,
45
46
  {
46
47
  ref,
48
+ unstyled: true,
47
49
  className: cn(TEXTAREA_BASE, TEXTAREA_SIZE_CLASSES[size], TEXTAREA_VARIANT_CLASSES[variant], className),
48
50
  ...rest,
49
51
  onChange: handleChange
package/dist/tooltip.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  var gui = require('@hanzo/gui');
5
5
  var usehooks = require('@uidotdev/usehooks');
6
- var React = require('react');
6
+ var React2 = require('react');
7
7
  var clsx = require('clsx');
8
8
  var tailwindMerge = require('tailwind-merge');
9
9
  var jsxRuntime = require('react/jsx-runtime');
@@ -26,32 +26,30 @@ function _interopNamespace(e) {
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
29
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
30
30
 
31
31
  // src/tooltip.tsx
32
+ var TOUCH_PX = 1024;
33
+ function useBelow(px) {
34
+ const [below, setBelow] = React2__namespace.useState(false);
35
+ React2__namespace.useEffect(() => {
36
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
37
+ const apply = () => setBelow(mql.matches);
38
+ apply();
39
+ mql.addEventListener("change", apply);
40
+ return () => mql.removeEventListener("change", apply);
41
+ }, [px]);
42
+ return below;
43
+ }
44
+ var useIsTouch = () => useBelow(TOUCH_PX);
32
45
  function cn(...inputs) {
33
46
  return tailwindMerge.twMerge(clsx.clsx(inputs));
34
47
  }
35
- var LG_BREAKPOINT = 1024;
36
- function useIsMobile() {
37
- const [isMobile, setIsMobile] = React__namespace.useState(() => {
38
- if (typeof window === "undefined") return false;
39
- return window.innerWidth < LG_BREAKPOINT;
40
- });
41
- React__namespace.useEffect(() => {
42
- const mql = window.matchMedia(`(max-width: ${LG_BREAKPOINT - 1}px)`);
43
- const handler = (e) => setIsMobile(e.matches);
44
- setIsMobile(mql.matches);
45
- mql.addEventListener("change", handler);
46
- return () => mql.removeEventListener("change", handler);
47
- }, []);
48
- return isMobile;
49
- }
50
48
  function mapPlacement(p) {
51
49
  if (!p) return void 0;
52
50
  return p;
53
51
  }
54
- var Tooltip = React__namespace.forwardRef(
52
+ var Tooltip = React2__namespace.forwardRef(
55
53
  function Tooltip2(props, ref) {
56
54
  const {
57
55
  showArrow: showArrowProp,
@@ -70,28 +68,28 @@ var Tooltip = React__namespace.forwardRef(
70
68
  interactive,
71
69
  positioning
72
70
  } = props;
73
- const [open, setOpen] = React__namespace.useState(defaultOpen);
74
- const timeoutRef = React__namespace.useRef(null);
75
- const isMobile = useIsMobile();
76
- const handleOpenChange = React__namespace.useCallback((nextOpen) => {
71
+ const [open, setOpen] = React2__namespace.useState(defaultOpen);
72
+ const timeoutRef = React2__namespace.useRef(null);
73
+ const isMobile = useIsTouch();
74
+ const handleOpenChange = React2__namespace.useCallback((nextOpen) => {
77
75
  setOpen(nextOpen);
78
76
  onOpenChange?.({ open: nextOpen });
79
77
  }, [onOpenChange]);
80
- const handleOpenChangeManual = React__namespace.useCallback((nextOpen) => {
78
+ const handleOpenChangeManual = React2__namespace.useCallback((nextOpen) => {
81
79
  timeoutRef.current && window.clearTimeout(timeoutRef.current);
82
80
  timeoutRef.current = window.setTimeout(() => {
83
81
  setOpen(nextOpen);
84
82
  onOpenChange?.({ open: nextOpen });
85
83
  }, nextOpen ? openDelay : closeDelay);
86
84
  }, [closeDelay, openDelay, onOpenChange]);
87
- const handleClickAway = React__namespace.useCallback(() => {
85
+ const handleClickAway = React2__namespace.useCallback(() => {
88
86
  handleOpenChangeManual(false);
89
87
  }, [handleOpenChangeManual]);
90
88
  const triggerRef = usehooks.useClickAway(handleClickAway);
91
- const handleTriggerClick = React__namespace.useCallback(() => {
89
+ const handleTriggerClick = React2__namespace.useCallback(() => {
92
90
  handleOpenChangeManual(!open);
93
91
  }, [handleOpenChangeManual, open]);
94
- const handleContentClick = React__namespace.useCallback((event) => {
92
+ const handleContentClick = React2__namespace.useCallback((event) => {
95
93
  event.stopPropagation();
96
94
  if (interactive) {
97
95
  const closestLink = event.target?.closest("a");
@@ -100,7 +98,7 @@ var Tooltip = React__namespace.forwardRef(
100
98
  }
101
99
  }
102
100
  }, [interactive, handleOpenChangeManual]);
103
- React__namespace.useEffect(() => {
101
+ React2__namespace.useEffect(() => {
104
102
  return () => {
105
103
  if (timeoutRef.current) {
106
104
  clearTimeout(timeoutRef.current);
package/dist/tooltip.js CHANGED
@@ -1,35 +1,33 @@
1
1
  "use client";
2
2
  import { TooltipGroup, Tooltip as Tooltip$1 } from '@hanzo/gui';
3
3
  import { useClickAway } from '@uidotdev/usehooks';
4
- import * as React from 'react';
4
+ import * as React2 from 'react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { jsx, jsxs } from 'react/jsx-runtime';
8
8
 
9
9
  // src/tooltip.tsx
10
+ var TOUCH_PX = 1024;
11
+ function useBelow(px) {
12
+ const [below, setBelow] = React2.useState(false);
13
+ React2.useEffect(() => {
14
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
15
+ const apply = () => setBelow(mql.matches);
16
+ apply();
17
+ mql.addEventListener("change", apply);
18
+ return () => mql.removeEventListener("change", apply);
19
+ }, [px]);
20
+ return below;
21
+ }
22
+ var useIsTouch = () => useBelow(TOUCH_PX);
10
23
  function cn(...inputs) {
11
24
  return twMerge(clsx(inputs));
12
25
  }
13
- var LG_BREAKPOINT = 1024;
14
- function useIsMobile() {
15
- const [isMobile, setIsMobile] = React.useState(() => {
16
- if (typeof window === "undefined") return false;
17
- return window.innerWidth < LG_BREAKPOINT;
18
- });
19
- React.useEffect(() => {
20
- const mql = window.matchMedia(`(max-width: ${LG_BREAKPOINT - 1}px)`);
21
- const handler = (e) => setIsMobile(e.matches);
22
- setIsMobile(mql.matches);
23
- mql.addEventListener("change", handler);
24
- return () => mql.removeEventListener("change", handler);
25
- }, []);
26
- return isMobile;
27
- }
28
26
  function mapPlacement(p) {
29
27
  if (!p) return void 0;
30
28
  return p;
31
29
  }
32
- var Tooltip = React.forwardRef(
30
+ var Tooltip = React2.forwardRef(
33
31
  function Tooltip2(props, ref) {
34
32
  const {
35
33
  showArrow: showArrowProp,
@@ -48,28 +46,28 @@ var Tooltip = React.forwardRef(
48
46
  interactive,
49
47
  positioning
50
48
  } = props;
51
- const [open, setOpen] = React.useState(defaultOpen);
52
- const timeoutRef = React.useRef(null);
53
- const isMobile = useIsMobile();
54
- const handleOpenChange = React.useCallback((nextOpen) => {
49
+ const [open, setOpen] = React2.useState(defaultOpen);
50
+ const timeoutRef = React2.useRef(null);
51
+ const isMobile = useIsTouch();
52
+ const handleOpenChange = React2.useCallback((nextOpen) => {
55
53
  setOpen(nextOpen);
56
54
  onOpenChange?.({ open: nextOpen });
57
55
  }, [onOpenChange]);
58
- const handleOpenChangeManual = React.useCallback((nextOpen) => {
56
+ const handleOpenChangeManual = React2.useCallback((nextOpen) => {
59
57
  timeoutRef.current && window.clearTimeout(timeoutRef.current);
60
58
  timeoutRef.current = window.setTimeout(() => {
61
59
  setOpen(nextOpen);
62
60
  onOpenChange?.({ open: nextOpen });
63
61
  }, nextOpen ? openDelay : closeDelay);
64
62
  }, [closeDelay, openDelay, onOpenChange]);
65
- const handleClickAway = React.useCallback(() => {
63
+ const handleClickAway = React2.useCallback(() => {
66
64
  handleOpenChangeManual(false);
67
65
  }, [handleOpenChangeManual]);
68
66
  const triggerRef = useClickAway(handleClickAway);
69
- const handleTriggerClick = React.useCallback(() => {
67
+ const handleTriggerClick = React2.useCallback(() => {
70
68
  handleOpenChangeManual(!open);
71
69
  }, [handleOpenChangeManual, open]);
72
- const handleContentClick = React.useCallback((event) => {
70
+ const handleContentClick = React2.useCallback((event) => {
73
71
  event.stopPropagation();
74
72
  if (interactive) {
75
73
  const closestLink = event.target?.closest("a");
@@ -78,7 +76,7 @@ var Tooltip = React.forwardRef(
78
76
  }
79
77
  }
80
78
  }, [interactive, handleOpenChangeManual]);
81
- React.useEffect(() => {
79
+ React2.useEffect(() => {
82
80
  return () => {
83
81
  if (timeoutRef.current) {
84
82
  clearTimeout(timeoutRef.current);
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+
26
+ var NARROW_PX = 640;
27
+ var TOUCH_PX = 1024;
28
+ function useBelow(px) {
29
+ const [below, setBelow] = React__namespace.useState(false);
30
+ React__namespace.useEffect(() => {
31
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
32
+ const apply = () => setBelow(mql.matches);
33
+ apply();
34
+ mql.addEventListener("change", apply);
35
+ return () => mql.removeEventListener("change", apply);
36
+ }, [px]);
37
+ return below;
38
+ }
39
+ var useIsNarrow = () => useBelow(NARROW_PX);
40
+ var useIsTouch = () => useBelow(TOUCH_PX);
41
+
42
+ exports.NARROW_PX = NARROW_PX;
43
+ exports.TOUCH_PX = TOUCH_PX;
44
+ exports.useBelow = useBelow;
45
+ exports.useIsNarrow = useIsNarrow;
46
+ exports.useIsTouch = useIsTouch;
@@ -0,0 +1,12 @@
1
+ /** Below this the UI is a phone: menus become sheets, drawers drag. */
2
+ declare const NARROW_PX = 640;
3
+ /** Below this the pointer is a finger: hover-only affordances are suppressed. */
4
+ declare const TOUCH_PX = 1024;
5
+ /** True while the viewport is narrower than `px`. */
6
+ declare function useBelow(px: number): boolean;
7
+ /** Phone-sized: present menus as sheets. */
8
+ declare const useIsNarrow: () => boolean;
9
+ /** Touch-sized: no hover, so hover-only affordances must not be the only path. */
10
+ declare const useIsTouch: () => boolean;
11
+
12
+ export { NARROW_PX, TOUCH_PX, useBelow, useIsNarrow, useIsTouch };
@@ -0,0 +1,12 @@
1
+ /** Below this the UI is a phone: menus become sheets, drawers drag. */
2
+ declare const NARROW_PX = 640;
3
+ /** Below this the pointer is a finger: hover-only affordances are suppressed. */
4
+ declare const TOUCH_PX = 1024;
5
+ /** True while the viewport is narrower than `px`. */
6
+ declare function useBelow(px: number): boolean;
7
+ /** Phone-sized: present menus as sheets. */
8
+ declare const useIsNarrow: () => boolean;
9
+ /** Touch-sized: no hover, so hover-only affordances must not be the only path. */
10
+ declare const useIsTouch: () => boolean;
11
+
12
+ export { NARROW_PX, TOUCH_PX, useBelow, useIsNarrow, useIsTouch };
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+
4
+ var NARROW_PX = 640;
5
+ var TOUCH_PX = 1024;
6
+ function useBelow(px) {
7
+ const [below, setBelow] = React.useState(false);
8
+ React.useEffect(() => {
9
+ const mql = window.matchMedia(`(max-width: ${px - 1}px)`);
10
+ const apply = () => setBelow(mql.matches);
11
+ apply();
12
+ mql.addEventListener("change", apply);
13
+ return () => mql.removeEventListener("change", apply);
14
+ }, [px]);
15
+ return below;
16
+ }
17
+ var useIsNarrow = () => useBelow(NARROW_PX);
18
+ var useIsTouch = () => useBelow(TOUCH_PX);
19
+
20
+ export { NARROW_PX, TOUCH_PX, useBelow, useIsNarrow, useIsTouch };