@luxfi/ui 7.4.11 → 7.4.12

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 (70) hide show
  1. package/dist/alert.cjs +68 -46
  2. package/dist/alert.js +69 -46
  3. package/dist/avatar.cjs +49 -46
  4. package/dist/avatar.js +52 -48
  5. package/dist/badge.cjs +82 -49
  6. package/dist/badge.js +83 -50
  7. package/dist/checkbox.cjs +42 -75
  8. package/dist/checkbox.js +43 -76
  9. package/dist/chrome.cjs +3 -7
  10. package/dist/chrome.js +3 -7
  11. package/dist/close-button.cjs +3 -7
  12. package/dist/close-button.js +3 -7
  13. package/dist/dialog.cjs +3 -7
  14. package/dist/dialog.js +3 -7
  15. package/dist/drawer.cjs +3 -7
  16. package/dist/drawer.js +3 -7
  17. package/dist/empty-state.cjs +13 -13
  18. package/dist/empty-state.js +13 -13
  19. package/dist/expiration-selector.cjs +58 -63
  20. package/dist/expiration-selector.js +58 -63
  21. package/dist/greeks-display.cjs +48 -39
  22. package/dist/greeks-display.js +48 -39
  23. package/dist/index.cjs +756 -703
  24. package/dist/index.js +757 -704
  25. package/dist/option-chain.cjs +89 -67
  26. package/dist/option-chain.js +89 -67
  27. package/dist/option-position.cjs +88 -85
  28. package/dist/option-position.js +88 -85
  29. package/dist/pnl-diagram.cjs +20 -20
  30. package/dist/pnl-diagram.js +20 -20
  31. package/dist/popover.cjs +3 -7
  32. package/dist/popover.js +3 -7
  33. package/dist/progress.cjs +15 -22
  34. package/dist/progress.d.cts +6 -6
  35. package/dist/progress.d.ts +6 -6
  36. package/dist/progress.js +15 -22
  37. package/dist/radio.cjs +35 -67
  38. package/dist/radio.d.cts +18 -18
  39. package/dist/radio.d.ts +18 -18
  40. package/dist/radio.js +36 -68
  41. package/dist/slider.cjs +33 -49
  42. package/dist/slider.js +34 -50
  43. package/dist/switch.cjs +48 -55
  44. package/dist/switch.js +49 -56
  45. package/dist/tag.cjs +112 -69
  46. package/dist/tag.js +113 -69
  47. package/dist/tooltip.cjs +28 -17
  48. package/dist/tooltip.js +30 -18
  49. package/package.json +1 -1
  50. package/src/alert.tsx +78 -45
  51. package/src/avatar.tsx +54 -37
  52. package/src/badge.tsx +65 -44
  53. package/src/checkbox.tsx +70 -89
  54. package/src/close-button.tsx +3 -8
  55. package/src/empty-state.tsx +21 -17
  56. package/src/expiration-selector.tsx +84 -66
  57. package/src/greeks-display.tsx +59 -51
  58. package/src/input-group.tsx +38 -24
  59. package/src/option-chain.tsx +154 -104
  60. package/src/option-position.tsx +136 -114
  61. package/src/pin-input.tsx +37 -29
  62. package/src/pnl-diagram.tsx +36 -28
  63. package/src/progress.tsx +17 -21
  64. package/src/radio.tsx +56 -75
  65. package/src/slider.tsx +43 -44
  66. package/src/strategy-builder.tsx +245 -156
  67. package/src/switch.tsx +63 -64
  68. package/src/tag.tsx +89 -51
  69. package/src/tooltip.tsx +21 -13
  70. package/tokens.css +18 -0
package/dist/radio.js CHANGED
@@ -1,40 +1,18 @@
1
1
  "use client";
2
- import { RadioGroup } from '@hanzo/gui';
2
+ import { RadioGroup, Label, VisuallyHidden, Text } from '@hanzo/gui';
3
3
  import * as React from 'react';
4
- import { clsx } from 'clsx';
5
- import { twMerge } from 'tailwind-merge';
6
4
  import { jsx, jsxs } from 'react/jsx-runtime';
7
5
 
8
6
  // src/radio.tsx
9
- function cn(...inputs) {
10
- return twMerge(clsx(inputs));
11
- }
12
- var SIZE_CLASSES = {
13
- xs: {
14
- root: "gap-1.5",
15
- control: "h-3 w-3",
16
- indicator: "h-1.5 w-1.5",
17
- label: "text-xs"
18
- },
19
- sm: {
20
- root: "gap-1.5",
21
- control: "h-3.5 w-3.5",
22
- indicator: "h-1.5 w-1.5",
23
- label: "text-xs"
24
- },
25
- md: {
26
- root: "gap-2",
27
- control: "h-4 w-4",
28
- indicator: "h-2 w-2",
29
- label: "text-sm"
30
- },
31
- lg: {
32
- root: "gap-2.5",
33
- control: "h-5 w-5",
34
- indicator: "h-2.5 w-2.5",
35
- label: "text-base"
36
- }
7
+ var SIZE = {
8
+ xs: { rootGap: 6, control: 12, indicator: 6, label: 12 },
9
+ sm: { rootGap: 6, control: 14, indicator: 6, label: 12 },
10
+ md: { rootGap: 8, control: 16, indicator: 8, label: 14 },
11
+ lg: { rootGap: 10, control: 20, indicator: 10, label: 16 }
37
12
  };
13
+ var INK = "var(--color-text-primary)";
14
+ var RESTING_BORDER = "var(--color-input-border)";
15
+ var OUTLINE = "var(--color-gray-500)";
38
16
  var RadioSizeContext = React.createContext("md");
39
17
  var RadioGroupBase = React.forwardRef(
40
18
  function RadioGroup$1(props, ref) {
@@ -51,7 +29,6 @@ var RadioGroupBase = React.forwardRef(
51
29
  value,
52
30
  onValueChange,
53
31
  size = "md",
54
- className,
55
32
  ...rest
56
33
  } = props;
57
34
  const handleValueChange = React.useCallback(
@@ -73,11 +50,9 @@ var RadioGroupBase = React.forwardRef(
73
50
  defaultValue,
74
51
  value: value ?? void 0,
75
52
  onValueChange: handleValueChange,
76
- className: cn(
77
- "flex",
78
- orientation === "vertical" ? "flex-col gap-3" : "flex-row gap-6",
79
- className
80
- ),
53
+ display: "flex",
54
+ flexDirection: orientation === "vertical" ? "column" : "row",
55
+ gap: orientation === "vertical" ? 12 : 24,
81
56
  ...rest,
82
57
  children
83
58
  }
@@ -89,19 +64,20 @@ var NOOP = () => {
89
64
  };
90
65
  var RadioBase = React.forwardRef(
91
66
  function Radio(props, ref) {
92
- const { children, inputProps, rootRef, value, disabled, className, ...rest } = props;
67
+ const { children, inputProps, rootRef, value, disabled, ...rest } = props;
93
68
  const size = React.useContext(RadioSizeContext);
94
- const sizeClasses = SIZE_CLASSES[size];
69
+ const s = SIZE[size];
95
70
  return /* @__PURE__ */ jsxs(
96
- "label",
71
+ Label,
97
72
  {
98
73
  ref: rootRef,
99
- className: cn(
100
- "inline-flex items-center cursor-pointer select-none",
101
- sizeClasses.root,
102
- disabled && "opacity-50 cursor-not-allowed",
103
- className
104
- ),
74
+ unstyled: true,
75
+ flexDirection: "row",
76
+ alignItems: "center",
77
+ gap: s.rootGap,
78
+ cursor: disabled ? "not-allowed" : "pointer",
79
+ userSelect: "none",
80
+ opacity: disabled ? 0.5 : 1,
105
81
  "data-disabled": disabled || void 0,
106
82
  ...rest,
107
83
  children: [
@@ -111,32 +87,24 @@ var RadioBase = React.forwardRef(
111
87
  unstyled: true,
112
88
  value,
113
89
  disabled,
114
- className: cn(
115
- "inline-flex items-center justify-center shrink-0 rounded-full",
116
- "border-2 border-current/30",
117
- "data-[state=checked]:border-gray-800 dark:border-white",
118
- "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500",
119
- "transition-colors duration-150",
120
- sizeClasses.control
121
- ),
122
- children: /* @__PURE__ */ jsx(
123
- RadioGroup.Indicator,
124
- {
125
- unstyled: true,
126
- className: cn(
127
- "block rounded-full bg-gray-800 dark:bg-white",
128
- sizeClasses.indicator
129
- )
130
- }
131
- )
90
+ flexShrink: 0,
91
+ alignItems: "center",
92
+ justifyContent: "center",
93
+ width: s.control,
94
+ height: s.control,
95
+ borderRadius: 9999,
96
+ borderWidth: 2,
97
+ borderColor: RESTING_BORDER,
98
+ transition: "quicker",
99
+ focusStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: OUTLINE, outlineOffset: 2 },
100
+ children: /* @__PURE__ */ jsx(RadioGroup.Indicator, { unstyled: true, borderRadius: 9999, width: s.indicator, height: s.indicator, backgroundColor: INK })
132
101
  }
133
102
  ),
134
- /* @__PURE__ */ jsx(
103
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(
135
104
  "input",
136
105
  {
137
106
  ref,
138
107
  type: "radio",
139
- className: "sr-only",
140
108
  value,
141
109
  disabled,
142
110
  tabIndex: -1,
@@ -144,8 +112,8 @@ var RadioBase = React.forwardRef(
144
112
  onChange: NOOP,
145
113
  ...inputProps
146
114
  }
147
- ),
148
- children != null && /* @__PURE__ */ jsx("span", { className: sizeClasses.label, children })
115
+ ) }),
116
+ children != null && /* @__PURE__ */ jsx(Text, { fontSize: s.label, children })
149
117
  ]
150
118
  }
151
119
  );
package/dist/slider.cjs CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  var gui = require('@hanzo/gui');
5
5
  var React = require('react');
6
- var clsx = require('clsx');
7
- var tailwindMerge = require('tailwind-merge');
8
6
  var jsxRuntime = require('react/jsx-runtime');
9
7
 
10
8
  function _interopNamespace(e) {
@@ -28,9 +26,11 @@ function _interopNamespace(e) {
28
26
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
27
 
30
28
  // src/slider.tsx
31
- function cn(...inputs) {
32
- return tailwindMerge.twMerge(clsx.clsx(inputs));
33
- }
29
+ var MUTED = "var(--color-text-secondary)";
30
+ var TRACK = "var(--color-border-divider)";
31
+ var ACTIVE = "var(--color-link-primary)";
32
+ var ACTIVE_HOVER = "var(--color-link-primary-hover)";
33
+ var WHITE = "var(--color-white)";
34
34
  var Slider = React__namespace.forwardRef(
35
35
  function Slider2(props, ref) {
36
36
  const {
@@ -63,21 +63,23 @@ var Slider = React__namespace.forwardRef(
63
63
  const handleSlideEnd = React__namespace.useCallback(() => {
64
64
  onValueCommit?.(latest.current);
65
65
  }, [onValueCommit]);
66
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1", className), children: [
67
- label && !showValue && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium text-text-secondary", children: label }),
68
- label && showValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
69
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium text-text-secondary", children: label }),
70
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-text-secondary", children: (value ?? defaultValue ?? [])?.join(", ") })
66
+ return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { className, gap: 4, children: [
67
+ label && !showValue && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 14, fontWeight: "500", color: MUTED, children: label }),
68
+ label && showValue && /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", justifyContent: "space-between", children: [
69
+ /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 14, fontWeight: "500", color: MUTED, children: label }),
70
+ /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 14, color: MUTED, children: (value ?? defaultValue ?? [])?.join(", ") })
71
71
  ] }),
72
72
  /* @__PURE__ */ jsxRuntime.jsxs(
73
73
  gui.Slider,
74
74
  {
75
75
  ref,
76
76
  unstyled: true,
77
- className: cn(
78
- "relative flex w-full touch-none select-none items-center",
79
- hasMarkLabel && "mb-6"
80
- ),
77
+ position: "relative",
78
+ flexDirection: "row",
79
+ width: "100%",
80
+ userSelect: "none",
81
+ alignItems: "center",
82
+ marginBottom: hasMarkLabel ? 24 : 0,
81
83
  value,
82
84
  defaultValue,
83
85
  min,
@@ -89,33 +91,23 @@ var Slider = React__namespace.forwardRef(
89
91
  onValueChange: handleValueChange,
90
92
  onSlideEnd: handleSlideEnd,
91
93
  children: [
92
- /* @__PURE__ */ jsxRuntime.jsx(
93
- gui.Slider.Track,
94
- {
95
- unstyled: true,
96
- className: "relative grow h-1.5 rounded-full bg-border-divider",
97
- children: /* @__PURE__ */ jsxRuntime.jsx(
98
- gui.Slider.TrackActive,
99
- {
100
- unstyled: true,
101
- className: "absolute h-full rounded-full bg-link-primary"
102
- }
103
- )
104
- }
105
- ),
94
+ /* @__PURE__ */ jsxRuntime.jsx(gui.Slider.Track, { unstyled: true, position: "relative", flexGrow: 1, height: 6, borderRadius: 9999, backgroundColor: TRACK, children: /* @__PURE__ */ jsxRuntime.jsx(gui.Slider.TrackActive, { unstyled: true, position: "absolute", height: "100%", borderRadius: 9999, backgroundColor: ACTIVE }) }),
106
95
  resolvedValue?.map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
107
96
  gui.Slider.Thumb,
108
97
  {
109
98
  index,
110
99
  unstyled: true,
111
- className: cn(
112
- "block h-5 w-5",
113
- "rounded-full border-2 border-link-primary bg-white",
114
- "shadow-sm transition-colors",
115
- "hover:border-link-primary-hover",
116
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-link-primary focus-visible:ring-offset-2",
117
- "disabled:pointer-events-none disabled:opacity-50"
118
- )
100
+ width: 20,
101
+ height: 20,
102
+ borderRadius: 9999,
103
+ borderWidth: 2,
104
+ borderColor: ACTIVE,
105
+ backgroundColor: WHITE,
106
+ boxShadow: "0 1px 2px 0 rgba(0,0,0,0.05)",
107
+ transition: "quick",
108
+ hoverStyle: { borderColor: ACTIVE_HOVER },
109
+ focusStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: ACTIVE, outlineOffset: 2 },
110
+ disabledStyle: { pointerEvents: "none", opacity: 0.5 }
119
111
  },
120
112
  index
121
113
  ))
@@ -130,20 +122,12 @@ function SliderMarks(props) {
130
122
  const { marks, min, max } = props;
131
123
  if (!marks?.length) return null;
132
124
  const range = max - min;
133
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full h-4", children: marks.map((mark, index) => {
125
+ return /* @__PURE__ */ jsxRuntime.jsx(gui.View, { position: "relative", width: "100%", height: 16, children: marks.map((mark, index) => {
134
126
  const percent = (mark.value - min) / range * 100;
135
- return /* @__PURE__ */ jsxRuntime.jsxs(
136
- "div",
137
- {
138
- className: "absolute flex flex-col items-center -translate-x-1/2",
139
- style: { left: `${percent}%` },
140
- children: [
141
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 w-0.5 bg-border-divider" }),
142
- mark.label != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-0.5 text-xs text-text-secondary whitespace-nowrap", children: mark.label })
143
- ]
144
- },
145
- index
146
- );
127
+ return /* @__PURE__ */ jsxRuntime.jsxs(gui.View, { position: "absolute", left: `${percent}%`, alignItems: "center", children: [
128
+ /* @__PURE__ */ jsxRuntime.jsx(gui.View, { width: 2, height: 6, backgroundColor: TRACK }),
129
+ mark.label != null && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { marginTop: 2, fontSize: 12, color: MUTED, children: mark.label })
130
+ ] }, index);
147
131
  }) });
148
132
  }
149
133
 
package/dist/slider.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- import { Slider as Slider$1 } from '@hanzo/gui';
2
+ import { YStack, Text, XStack, Slider as Slider$1, View } from '@hanzo/gui';
3
3
  import * as React from 'react';
4
- import { clsx } from 'clsx';
5
- import { twMerge } from 'tailwind-merge';
6
4
  import { jsxs, jsx } from 'react/jsx-runtime';
7
5
 
8
6
  // src/slider.tsx
9
- function cn(...inputs) {
10
- return twMerge(clsx(inputs));
11
- }
7
+ var MUTED = "var(--color-text-secondary)";
8
+ var TRACK = "var(--color-border-divider)";
9
+ var ACTIVE = "var(--color-link-primary)";
10
+ var ACTIVE_HOVER = "var(--color-link-primary-hover)";
11
+ var WHITE = "var(--color-white)";
12
12
  var Slider = React.forwardRef(
13
13
  function Slider2(props, ref) {
14
14
  const {
@@ -41,21 +41,23 @@ var Slider = React.forwardRef(
41
41
  const handleSlideEnd = React.useCallback(() => {
42
42
  onValueCommit?.(latest.current);
43
43
  }, [onValueCommit]);
44
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1", className), children: [
45
- label && !showValue && /* @__PURE__ */ jsx("label", { className: "text-sm font-medium text-text-secondary", children: label }),
46
- label && showValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
47
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium text-text-secondary", children: label }),
48
- /* @__PURE__ */ jsx("span", { className: "text-sm text-text-secondary", children: (value ?? defaultValue ?? [])?.join(", ") })
44
+ return /* @__PURE__ */ jsxs(YStack, { className, gap: 4, children: [
45
+ label && !showValue && /* @__PURE__ */ jsx(Text, { fontSize: 14, fontWeight: "500", color: MUTED, children: label }),
46
+ label && showValue && /* @__PURE__ */ jsxs(XStack, { alignItems: "center", justifyContent: "space-between", children: [
47
+ /* @__PURE__ */ jsx(Text, { fontSize: 14, fontWeight: "500", color: MUTED, children: label }),
48
+ /* @__PURE__ */ jsx(Text, { fontSize: 14, color: MUTED, children: (value ?? defaultValue ?? [])?.join(", ") })
49
49
  ] }),
50
50
  /* @__PURE__ */ jsxs(
51
51
  Slider$1,
52
52
  {
53
53
  ref,
54
54
  unstyled: true,
55
- className: cn(
56
- "relative flex w-full touch-none select-none items-center",
57
- hasMarkLabel && "mb-6"
58
- ),
55
+ position: "relative",
56
+ flexDirection: "row",
57
+ width: "100%",
58
+ userSelect: "none",
59
+ alignItems: "center",
60
+ marginBottom: hasMarkLabel ? 24 : 0,
59
61
  value,
60
62
  defaultValue,
61
63
  min,
@@ -67,33 +69,23 @@ var Slider = React.forwardRef(
67
69
  onValueChange: handleValueChange,
68
70
  onSlideEnd: handleSlideEnd,
69
71
  children: [
70
- /* @__PURE__ */ jsx(
71
- Slider$1.Track,
72
- {
73
- unstyled: true,
74
- className: "relative grow h-1.5 rounded-full bg-border-divider",
75
- children: /* @__PURE__ */ jsx(
76
- Slider$1.TrackActive,
77
- {
78
- unstyled: true,
79
- className: "absolute h-full rounded-full bg-link-primary"
80
- }
81
- )
82
- }
83
- ),
72
+ /* @__PURE__ */ jsx(Slider$1.Track, { unstyled: true, position: "relative", flexGrow: 1, height: 6, borderRadius: 9999, backgroundColor: TRACK, children: /* @__PURE__ */ jsx(Slider$1.TrackActive, { unstyled: true, position: "absolute", height: "100%", borderRadius: 9999, backgroundColor: ACTIVE }) }),
84
73
  resolvedValue?.map((_, index) => /* @__PURE__ */ jsx(
85
74
  Slider$1.Thumb,
86
75
  {
87
76
  index,
88
77
  unstyled: true,
89
- className: cn(
90
- "block h-5 w-5",
91
- "rounded-full border-2 border-link-primary bg-white",
92
- "shadow-sm transition-colors",
93
- "hover:border-link-primary-hover",
94
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-link-primary focus-visible:ring-offset-2",
95
- "disabled:pointer-events-none disabled:opacity-50"
96
- )
78
+ width: 20,
79
+ height: 20,
80
+ borderRadius: 9999,
81
+ borderWidth: 2,
82
+ borderColor: ACTIVE,
83
+ backgroundColor: WHITE,
84
+ boxShadow: "0 1px 2px 0 rgba(0,0,0,0.05)",
85
+ transition: "quick",
86
+ hoverStyle: { borderColor: ACTIVE_HOVER },
87
+ focusStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: ACTIVE, outlineOffset: 2 },
88
+ disabledStyle: { pointerEvents: "none", opacity: 0.5 }
97
89
  },
98
90
  index
99
91
  ))
@@ -108,20 +100,12 @@ function SliderMarks(props) {
108
100
  const { marks, min, max } = props;
109
101
  if (!marks?.length) return null;
110
102
  const range = max - min;
111
- return /* @__PURE__ */ jsx("div", { className: "relative w-full h-4", children: marks.map((mark, index) => {
103
+ return /* @__PURE__ */ jsx(View, { position: "relative", width: "100%", height: 16, children: marks.map((mark, index) => {
112
104
  const percent = (mark.value - min) / range * 100;
113
- return /* @__PURE__ */ jsxs(
114
- "div",
115
- {
116
- className: "absolute flex flex-col items-center -translate-x-1/2",
117
- style: { left: `${percent}%` },
118
- children: [
119
- /* @__PURE__ */ jsx("div", { className: "h-1.5 w-0.5 bg-border-divider" }),
120
- mark.label != null && /* @__PURE__ */ jsx("span", { className: "mt-0.5 text-xs text-text-secondary whitespace-nowrap", children: mark.label })
121
- ]
122
- },
123
- index
124
- );
105
+ return /* @__PURE__ */ jsxs(View, { position: "absolute", left: `${percent}%`, alignItems: "center", children: [
106
+ /* @__PURE__ */ jsx(View, { width: 2, height: 6, backgroundColor: TRACK }),
107
+ mark.label != null && /* @__PURE__ */ jsx(Text, { marginTop: 2, fontSize: 12, color: MUTED, children: mark.label })
108
+ ] }, index);
125
109
  }) });
126
110
  }
127
111
 
package/dist/switch.cjs CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  var gui = require('@hanzo/gui');
5
5
  var React = require('react');
6
- var clsx = require('clsx');
7
- var tailwindMerge = require('tailwind-merge');
8
6
  var jsxRuntime = require('react/jsx-runtime');
9
7
 
10
8
  function _interopNamespace(e) {
@@ -28,28 +26,17 @@ function _interopNamespace(e) {
28
26
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
27
 
30
28
  // src/switch.tsx
31
- function cn(...inputs) {
32
- return tailwindMerge.twMerge(clsx.clsx(inputs));
33
- }
34
29
  var NOOP = () => {
35
30
  };
36
- var SIZE_CLASSES = {
37
- sm: {
38
- root: "h-4 w-7",
39
- thumb: "h-3 w-3",
40
- label: "text-xs"
41
- },
42
- md: {
43
- root: "h-5 w-9",
44
- thumb: "h-4 w-4",
45
- label: "text-sm"
46
- },
47
- lg: {
48
- root: "h-6 w-11",
49
- thumb: "h-5 w-5",
50
- label: "text-base"
51
- }
31
+ var SIZE = {
32
+ sm: { width: 28, height: 16, thumb: 12, label: 12 },
33
+ md: { width: 36, height: 20, thumb: 16, label: 14 },
34
+ lg: { width: 44, height: 24, thumb: 20, label: 16 }
52
35
  };
36
+ var TRACK_ON = "var(--color-text-primary)";
37
+ var TRACK_OFF = "var(--color-switch-bg)";
38
+ var OUTLINE = "var(--color-gray-500)";
39
+ var WHITE = "var(--color-white)";
53
40
  var SwitchBase = React__namespace.forwardRef(
54
41
  function Switch(props, ref) {
55
42
  const {
@@ -66,7 +53,6 @@ var SwitchBase = React__namespace.forwardRef(
66
53
  disabled = false,
67
54
  size = "md",
68
55
  direction,
69
- className,
70
56
  ...rest
71
57
  } = props;
72
58
  const [internalChecked, setInternalChecked] = React__namespace.useState(defaultChecked ?? false);
@@ -81,18 +67,19 @@ var SwitchBase = React__namespace.forwardRef(
81
67
  },
82
68
  [isControlled, onCheckedChange]
83
69
  );
84
- const sizeClasses = SIZE_CLASSES[size];
70
+ const s = SIZE[size];
85
71
  const isRtl = direction === "rtl";
86
72
  return /* @__PURE__ */ jsxRuntime.jsxs(
87
- "label",
73
+ gui.Label,
88
74
  {
89
75
  ref: rootRef,
90
- className: cn(
91
- "inline-flex items-center cursor-pointer select-none gap-2",
92
- isRtl && "flex-row-reverse",
93
- disabled && "opacity-50 cursor-not-allowed",
94
- className
95
- ),
76
+ unstyled: true,
77
+ flexDirection: isRtl ? "row-reverse" : "row",
78
+ alignItems: "center",
79
+ gap: 8,
80
+ cursor: disabled ? "not-allowed" : "pointer",
81
+ userSelect: "none",
82
+ opacity: disabled ? 0.5 : 1,
96
83
  onChange,
97
84
  "data-disabled": disabled || void 0,
98
85
  ...rest,
@@ -104,38 +91,51 @@ var SwitchBase = React__namespace.forwardRef(
104
91
  checked: checkedState,
105
92
  onCheckedChange: handleCheckedChange,
106
93
  disabled,
107
- className: cn(
108
- "relative inline-flex shrink-0 items-center rounded-full",
109
- "bg-gray-300 dark:bg-gray-600",
110
- "data-[state=checked]:bg-gray-800 dark:bg-white",
111
- "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500",
112
- "transition-colors duration-200",
113
- sizeClasses.root
114
- ),
94
+ position: "relative",
95
+ flexShrink: 0,
96
+ alignItems: "center",
97
+ width: s.width,
98
+ height: s.height,
99
+ borderRadius: 9999,
100
+ backgroundColor: checkedState ? TRACK_ON : TRACK_OFF,
101
+ transition: "quick",
102
+ focusStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: OUTLINE, outlineOffset: 2 },
115
103
  children: [
116
- trackLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-0 flex items-center justify-center text-[8px] font-bold text-white pointer-events-none", children: checkedState ? trackLabel.on : trackLabel.off }),
104
+ trackLabel && /* @__PURE__ */ jsxRuntime.jsx(
105
+ gui.Text,
106
+ {
107
+ position: "absolute",
108
+ width: "100%",
109
+ textAlign: "center",
110
+ fontSize: 8,
111
+ fontWeight: "700",
112
+ color: WHITE,
113
+ pointerEvents: "none",
114
+ children: checkedState ? trackLabel.on : trackLabel.off
115
+ }
116
+ ),
117
117
  /* @__PURE__ */ jsxRuntime.jsx(
118
118
  gui.Switch.Thumb,
119
119
  {
120
120
  unstyled: true,
121
121
  "data-thumb": true,
122
122
  transition: "quicker",
123
- className: cn(
124
- "block rounded-full bg-white shadow-sm",
125
- sizeClasses.thumb
126
- ),
127
- children: thumbLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex items-center justify-center h-full w-full text-[8px]", children: checkedState ? thumbLabel.on : thumbLabel.off })
123
+ width: s.thumb,
124
+ height: s.thumb,
125
+ borderRadius: 9999,
126
+ backgroundColor: WHITE,
127
+ boxShadow: "0 1px 2px 0 rgba(0,0,0,0.05)",
128
+ children: thumbLabel && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { width: "100%", height: "100%", textAlign: "center", fontSize: 8, children: checkedState ? thumbLabel.on : thumbLabel.off })
128
129
  }
129
130
  )
130
131
  ]
131
132
  }
132
133
  ),
133
- /* @__PURE__ */ jsxRuntime.jsx(
134
+ /* @__PURE__ */ jsxRuntime.jsx(gui.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(
134
135
  "input",
135
136
  {
136
137
  ref,
137
138
  type: "checkbox",
138
- className: "sr-only",
139
139
  checked: checkedState,
140
140
  disabled,
141
141
  tabIndex: -1,
@@ -143,15 +143,8 @@ var SwitchBase = React__namespace.forwardRef(
143
143
  onChange: NOOP,
144
144
  ...inputProps
145
145
  }
146
- ),
147
- children != null && /* @__PURE__ */ jsxRuntime.jsx(
148
- "span",
149
- {
150
- ...labelProps,
151
- className: cn(sizeClasses.label, labelProps?.className),
152
- children
153
- }
154
- )
146
+ ) }),
147
+ children != null && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { ...labelProps, fontSize: s.label, children })
155
148
  ]
156
149
  }
157
150
  );