@luxfi/ui 5.5.2 → 5.6.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 (249) hide show
  1. package/dist/accordion.cjs +213 -0
  2. package/dist/accordion.js +186 -0
  3. package/dist/alert.cjs +553 -0
  4. package/dist/alert.js +531 -0
  5. package/dist/avatar.cjs +149 -0
  6. package/dist/avatar.js +125 -0
  7. package/dist/badge.cjs +611 -0
  8. package/dist/badge.js +589 -0
  9. package/dist/button.cjs +689 -0
  10. package/dist/button.js +664 -0
  11. package/dist/checkbox.cjs +265 -0
  12. package/dist/checkbox.js +241 -0
  13. package/dist/close-button.cjs +73 -0
  14. package/dist/close-button.js +51 -0
  15. package/dist/collapsible.cjs +702 -0
  16. package/dist/collapsible.js +679 -0
  17. package/dist/color-mode.cjs +96 -0
  18. package/dist/color-mode.js +72 -0
  19. package/dist/dialog.cjs +279 -0
  20. package/dist/dialog.js +246 -0
  21. package/dist/drawer.cjs +207 -0
  22. package/dist/drawer.js +175 -0
  23. package/dist/empty-state.cjs +93 -0
  24. package/dist/empty-state.js +71 -0
  25. package/dist/field.cjs +183 -0
  26. package/dist/field.js +160 -0
  27. package/dist/heading.cjs +46 -0
  28. package/dist/heading.js +40 -0
  29. package/dist/icon-button.cjs +491 -0
  30. package/dist/icon-button.js +470 -0
  31. package/dist/image.cjs +572 -0
  32. package/dist/image.js +551 -0
  33. package/dist/index.cjs +5779 -0
  34. package/dist/index.js +5619 -0
  35. package/dist/input-group.cjs +155 -0
  36. package/dist/input-group.js +133 -0
  37. package/dist/input.cjs +65 -0
  38. package/dist/input.js +59 -0
  39. package/dist/link.cjs +630 -0
  40. package/dist/link.js +606 -0
  41. package/dist/menu.cjs +305 -0
  42. package/dist/menu.js +269 -0
  43. package/dist/pin-input.cjs +182 -0
  44. package/dist/pin-input.js +160 -0
  45. package/dist/popover.cjs +327 -0
  46. package/dist/popover.js +294 -0
  47. package/dist/progress-circle.cjs +152 -0
  48. package/dist/progress-circle.js +128 -0
  49. package/dist/progress.cjs +117 -0
  50. package/dist/progress.js +94 -0
  51. package/dist/provider.cjs +62 -0
  52. package/dist/provider.js +40 -0
  53. package/dist/radio.cjs +177 -0
  54. package/dist/radio.js +153 -0
  55. package/dist/rating.cjs +80 -0
  56. package/dist/rating.js +58 -0
  57. package/dist/select.cjs +791 -0
  58. package/dist/select.js +757 -0
  59. package/dist/separator.cjs +57 -0
  60. package/dist/separator.js +51 -0
  61. package/dist/skeleton.cjs +370 -0
  62. package/dist/skeleton.js +346 -0
  63. package/dist/slider.cjs +138 -0
  64. package/dist/slider.js +115 -0
  65. package/dist/switch.cjs +163 -0
  66. package/dist/switch.js +140 -0
  67. package/dist/table.cjs +1044 -0
  68. package/dist/table.js +1013 -0
  69. package/dist/tabs.cjs +240 -0
  70. package/dist/tabs.js +213 -0
  71. package/dist/tag.cjs +651 -0
  72. package/dist/tag.js +628 -0
  73. package/dist/textarea.cjs +65 -0
  74. package/dist/textarea.js +59 -0
  75. package/dist/toaster.cjs +99 -0
  76. package/dist/toaster.js +96 -0
  77. package/dist/tooltip.cjs +171 -0
  78. package/dist/tooltip.js +148 -0
  79. package/dist/utils.cjs +11 -0
  80. package/dist/utils.js +9 -0
  81. package/package.json +270 -66
  82. package/src/accordion.tsx +285 -0
  83. package/src/alert.tsx +221 -0
  84. package/src/avatar.tsx +174 -0
  85. package/src/badge.tsx +158 -0
  86. package/src/button.tsx +411 -0
  87. package/src/checkbox.tsx +307 -0
  88. package/src/close-button.tsx +51 -0
  89. package/src/collapsible.tsx +126 -0
  90. package/src/color-mode.tsx +125 -0
  91. package/src/dialog.tsx +356 -0
  92. package/src/drawer.tsx +186 -0
  93. package/src/empty-state.tsx +97 -0
  94. package/src/field.tsx +202 -0
  95. package/src/heading.tsx +55 -0
  96. package/src/icon-button.tsx +192 -0
  97. package/src/image.tsx +280 -0
  98. package/src/index.ts +192 -0
  99. package/src/input-group.tsx +159 -0
  100. package/src/input.tsx +60 -0
  101. package/src/link.tsx +326 -0
  102. package/src/menu.tsx +471 -0
  103. package/src/pin-input.tsx +187 -0
  104. package/src/popover.tsx +400 -0
  105. package/src/progress-circle.tsx +180 -0
  106. package/src/progress.tsx +109 -0
  107. package/src/provider.tsx +12 -0
  108. package/src/radio.tsx +175 -0
  109. package/src/rating.tsx +79 -0
  110. package/src/select.tsx +696 -0
  111. package/src/separator.tsx +59 -0
  112. package/src/skeleton.tsx +302 -0
  113. package/src/slider.tsx +152 -0
  114. package/src/switch.tsx +158 -0
  115. package/src/table.tsx +621 -0
  116. package/src/tabs.tsx +354 -0
  117. package/src/tag.tsx +159 -0
  118. package/src/textarea.tsx +60 -0
  119. package/src/toaster.tsx +117 -0
  120. package/src/tokens.css +438 -0
  121. package/src/tooltip.tsx +184 -0
  122. package/src/utils/cn.ts +7 -0
  123. package/src/utils.ts +6 -0
  124. package/tokens.css +438 -0
  125. package/commerce/ui/conf.ts +0 -13
  126. package/commerce/ui/context.tsx +0 -123
  127. package/commerce/ui/store.ts +0 -295
  128. package/components/access-code-input.tsx +0 -71
  129. package/components/analytics.tsx +0 -23
  130. package/components/auth/auth-listener.tsx +0 -29
  131. package/components/auth/auth-token/clear-auth-token.tsx +0 -12
  132. package/components/auth/auth-token/set-auth-token.tsx +0 -16
  133. package/components/auth/common-auth-domains.ts +0 -17
  134. package/components/auth/login-panel.tsx +0 -111
  135. package/components/auth/mobile-login-button.tsx +0 -107
  136. package/components/auth/signup-panel.tsx +0 -113
  137. package/components/back-button.tsx +0 -49
  138. package/components/chat-widget.tsx +0 -85
  139. package/components/commerce/bag-button.tsx +0 -98
  140. package/components/commerce/buy-button.tsx +0 -34
  141. package/components/commerce/checkout-button.tsx +0 -129
  142. package/components/commerce/checkout-panel/cart-accordian.tsx +0 -66
  143. package/components/commerce/checkout-panel/checkout-panel-props.ts +0 -10
  144. package/components/commerce/checkout-panel/desktop-bag-carousel.tsx +0 -36
  145. package/components/commerce/checkout-panel/desktop-cp.tsx +0 -83
  146. package/components/commerce/checkout-panel/index.tsx +0 -126
  147. package/components/commerce/checkout-panel/mobile-cp.tsx +0 -67
  148. package/components/commerce/checkout-panel/policy-links.tsx +0 -29
  149. package/components/commerce/checkout-panel/steps-indicator.tsx +0 -39
  150. package/components/commerce/checkout-panel/thank-you.tsx +0 -18
  151. package/components/commerce/desktop-bag-popup.tsx +0 -78
  152. package/components/commerce/drawer/index.tsx +0 -88
  153. package/components/commerce/drawer/micro.tsx +0 -145
  154. package/components/commerce/drawer/shell.tsx +0 -85
  155. package/components/contact-dialog/contact-form.tsx +0 -116
  156. package/components/contact-dialog/disclaimer.tsx +0 -13
  157. package/components/contact-dialog/index.tsx +0 -64
  158. package/components/copyright.tsx +0 -21
  159. package/components/drawer-margin.tsx +0 -28
  160. package/components/footer.tsx +0 -78
  161. package/components/header/desktop-nav-menu.tsx +0 -204
  162. package/components/header/desktop.tsx +0 -65
  163. package/components/header/index.tsx +0 -50
  164. package/components/header/mobile-bag-drawer.tsx +0 -51
  165. package/components/header/mobile-menu-toggle-button.tsx +0 -35
  166. package/components/header/mobile-nav-menu-ai.tsx +0 -51
  167. package/components/header/mobile-nav-menu-item.tsx +0 -47
  168. package/components/header/mobile-nav-menu.tsx +0 -102
  169. package/components/header/mobile.tsx +0 -170
  170. package/components/header/theme-toggle.tsx +0 -26
  171. package/components/icons/avatar.tsx +0 -11
  172. package/components/icons/bag-icon.tsx +0 -10
  173. package/components/icons/index.ts +0 -6
  174. package/components/icons/left-arrow.tsx +0 -11
  175. package/components/icons/lux-logo.tsx +0 -10
  176. package/components/icons/right-arrow.tsx +0 -10
  177. package/components/icons/social-icon.tsx +0 -35
  178. package/components/icons/social-svg.css +0 -3
  179. package/components/index.ts +0 -26
  180. package/components/logo.tsx +0 -92
  181. package/components/main.tsx +0 -27
  182. package/components/mini-chart/index.tsx +0 -8
  183. package/components/mini-chart/mini-chart-props.ts +0 -44
  184. package/components/mini-chart/mini-chart.tsx +0 -85
  185. package/components/mini-chart/wrapper.tsx +0 -23
  186. package/components/not-found/index.tsx +0 -28
  187. package/components/not-found/not-found-content.mdx +0 -5
  188. package/components/tooltip.tsx +0 -31
  189. package/environment.d.ts +0 -6
  190. package/next/analytics/fpixel.ts +0 -16
  191. package/next/analytics/google-analytics.ts +0 -14
  192. package/next/analytics/index.ts +0 -3
  193. package/next/analytics/pixel-analytics.tsx +0 -55
  194. package/next/font/get-app-router-font-classes.ts +0 -17
  195. package/next/font/load-and-return-lux-next-fonts-on-import.ts +0 -68
  196. package/next/font/local/Druk-Wide-Bold.ttf +0 -0
  197. package/next/font/local/Druk-Wide-Medium.ttf +0 -0
  198. package/next/font/local/InterVariable-Italic.ttf +0 -0
  199. package/next/font/local/InterVariable-Italic.woff2 +0 -0
  200. package/next/font/local/InterVariable.ttf +0 -0
  201. package/next/font/local/InterVariable.woff2 +0 -0
  202. package/next/font/next-font-desc.ts +0 -28
  203. package/next/font/pages-router-font-vars.tsx +0 -18
  204. package/next/head-metadata/from-next/metadata-types.ts +0 -158
  205. package/next/head-metadata/from-next/opengraph-types.ts +0 -267
  206. package/next/head-metadata/from-next/twitter-types.ts +0 -92
  207. package/next/head-metadata/index.tsx +0 -208
  208. package/next/index.ts +0 -2
  209. package/next/middleware/determine-device-mw.ts +0 -29
  210. package/root-layout/WHY_THIS_IS_SEPARATE.txt +0 -2
  211. package/root-layout/index.tsx +0 -111
  212. package/server/auth-wrapper.ts +0 -24
  213. package/server-actions/TO-DO.txt +0 -1
  214. package/server-actions/firebase-app.ts +0 -29
  215. package/server-actions/index.ts +0 -5
  216. package/server-actions/store-contact.ts +0 -66
  217. package/site-def/footer/community.tsx +0 -61
  218. package/site-def/footer/company.ts +0 -37
  219. package/site-def/footer/ecosystem.ts +0 -37
  220. package/site-def/footer/index.tsx +0 -26
  221. package/site-def/footer/legal.ts +0 -28
  222. package/site-def/footer/network.ts +0 -45
  223. package/site-def/footer/svg/warpcast-logo.svg +0 -12
  224. package/site-def/index.ts +0 -4
  225. package/site-def/main-nav.tsx +0 -460
  226. package/style/cart-animation.css +0 -29
  227. package/style/checkout-animation.css +0 -23
  228. package/style/drawer-handle-overrides.css +0 -160
  229. package/style/fonts/COPY_TO_PUBLIC_FOR_NON_NEXT.txt +0 -0
  230. package/style/fonts/Druk-Wide-Bold.ttf +0 -0
  231. package/style/fonts/Druk-Wide-Medium.ttf +0 -0
  232. package/style/fonts/InterVariable-Italic.ttf +0 -0
  233. package/style/fonts/InterVariable-Italic.woff2 +0 -0
  234. package/style/fonts/InterVariable.ttf +0 -0
  235. package/style/fonts/InterVariable.woff2 +0 -0
  236. package/style/lux-colors.css +0 -85
  237. package/style/lux-fonts.css +0 -30
  238. package/style/lux-global-non-next.css +0 -52
  239. package/style/lux-global.css +0 -51
  240. package/tailwind/fontFamily.tailwind.lux.ts +0 -18
  241. package/tailwind/index.ts +0 -2
  242. package/tailwind/lux-tw-fonts.ts +0 -40
  243. package/tailwind/tailwind.config.lux-preset.ts +0 -10
  244. package/tsconfig.json +0 -15
  245. package/types/chatbot-config.ts +0 -7
  246. package/types/chatbot-suggested-question.ts +0 -7
  247. package/types/contact-info.ts +0 -11
  248. package/types/index.ts +0 -4
  249. package/types/site-def.ts +0 -46
package/src/field.tsx ADDED
@@ -0,0 +1,202 @@
1
+ import * as LabelPrimitive from '@radix-ui/react-label';
2
+ import * as React from 'react';
3
+
4
+ import { cn } from './utils';
5
+
6
+ import type { InputProps } from './input';
7
+ import type { InputGroupProps } from './input-group';
8
+
9
+ // Inline constants
10
+ const space = String.fromCharCode(32);
11
+
12
+ function getComponentDisplayName(type: string | React.JSXElementConstructor<unknown>): string | undefined {
13
+ if (typeof type === 'string') return undefined;
14
+ if ('displayName' in type) return type.displayName as string;
15
+ return undefined;
16
+ }
17
+
18
+ export interface FieldProps {
19
+ readonly label?: React.ReactNode;
20
+ readonly helperText?: React.ReactNode;
21
+ readonly errorText?: React.ReactNode;
22
+ readonly optionalText?: React.ReactNode;
23
+ readonly children: React.ReactElement<InputProps> | React.ReactElement<InputGroupProps>;
24
+ readonly size?: 'sm' | 'md' | 'lg' | '2xl';
25
+ readonly required?: boolean;
26
+ readonly disabled?: boolean;
27
+ readonly readOnly?: boolean;
28
+ readonly invalid?: boolean;
29
+ readonly floating?: boolean;
30
+ readonly bgColor?: string | Record<string, string>;
31
+ readonly id?: string;
32
+ readonly className?: string;
33
+ readonly style?: React.CSSProperties;
34
+ }
35
+
36
+ export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
37
+ function Field(props, ref) {
38
+ const {
39
+ label,
40
+ children,
41
+ helperText,
42
+ errorText,
43
+ optionalText,
44
+ size,
45
+ required,
46
+ disabled,
47
+ readOnly,
48
+ invalid,
49
+ floating,
50
+ id,
51
+ className,
52
+ style,
53
+ } = props;
54
+
55
+ // A floating field cannot be without a label.
56
+ if (floating && label) {
57
+ const injectedProps = {
58
+ className: 'peer',
59
+ placeholder: ' ',
60
+ size,
61
+ floating,
62
+ disabled,
63
+ readOnly,
64
+ };
65
+
66
+ const labelElement = (
67
+ <LabelPrimitive.Root
68
+ className={ cn(
69
+ 'absolute left-3 top-1/2 -translate-y-1/2',
70
+ 'text-[var(--color-input-placeholder,theme(colors.gray.400))]',
71
+ 'pointer-events-none select-none',
72
+ 'origin-top-left transition-all duration-150',
73
+ 'peer-focus:top-1 peer-focus:translate-y-0 peer-focus:scale-75',
74
+ 'peer-[:not(:placeholder-shown)]:top-1 peer-[:not(:placeholder-shown)]:translate-y-0 peer-[:not(:placeholder-shown)]:scale-75',
75
+ ) }
76
+ htmlFor={ id }
77
+ >
78
+ { label }
79
+ { required && (
80
+ <span className="ml-0.5 text-[var(--color-fg-error,theme(colors.red.500))]" aria-hidden="true">*</span>
81
+ ) }
82
+ { !required && optionalText && (
83
+ <span className="ml-1 text-[var(--color-text-secondary,theme(colors.gray.400))] text-sm">
84
+ { optionalText }
85
+ </span>
86
+ ) }
87
+ { errorText && (
88
+ <span className="ml-0.5 text-[var(--color-fg-error,theme(colors.red.500))] text-sm">
89
+ -{ space }{ errorText }
90
+ </span>
91
+ ) }
92
+ </LabelPrimitive.Root>
93
+ );
94
+
95
+ const helperTextElement = helperText ? (
96
+ <p className="mt-1.5 text-xs text-[var(--color-text-secondary,theme(colors.gray.400))]">
97
+ { helperText }
98
+ </p>
99
+ ) : null;
100
+
101
+ const child = React.Children.only<React.ReactElement<InputProps | InputGroupProps>>(children);
102
+ const isInputGroup = getComponentDisplayName(child.type) === 'InputGroup';
103
+
104
+ if (isInputGroup) {
105
+ const inputElement = React.cloneElement(
106
+ React.Children.only<React.ReactElement<InputProps>>(child.props.children as React.ReactElement<InputProps>),
107
+ injectedProps,
108
+ );
109
+
110
+ const groupInputElement = React.cloneElement(child,
111
+ {},
112
+ inputElement,
113
+ labelElement,
114
+ );
115
+
116
+ return (
117
+ <div
118
+ ref={ ref }
119
+ id={ id }
120
+ className={ cn('relative w-full', className) }
121
+ style={ style }
122
+ data-disabled={ disabled || undefined }
123
+ data-readonly={ readOnly || undefined }
124
+ data-invalid={ invalid || undefined }
125
+ >
126
+ { groupInputElement }
127
+ { helperTextElement }
128
+ </div>
129
+ );
130
+ }
131
+
132
+ const inputElement = React.cloneElement(child, injectedProps);
133
+
134
+ return (
135
+ <div
136
+ ref={ ref }
137
+ id={ id }
138
+ className={ cn('relative w-full', className) }
139
+ style={ style }
140
+ data-disabled={ disabled || undefined }
141
+ data-readonly={ readOnly || undefined }
142
+ data-invalid={ invalid || undefined }
143
+ >
144
+ { inputElement }
145
+ { labelElement }
146
+ { helperTextElement }
147
+ </div>
148
+ );
149
+ }
150
+
151
+ // Non-floating: standard field layout
152
+ const injectedProps = {
153
+ size,
154
+ };
155
+ const child = React.Children.only<React.ReactElement<InputProps | InputGroupProps>>(children);
156
+ const clonedChild = React.cloneElement(child, injectedProps);
157
+
158
+ return (
159
+ <div
160
+ ref={ ref }
161
+ id={ id }
162
+ className={ cn('flex flex-col gap-1', className) }
163
+ style={ style }
164
+ data-disabled={ disabled || undefined }
165
+ data-readonly={ readOnly || undefined }
166
+ data-invalid={ invalid || undefined }
167
+ >
168
+ { label && (
169
+ <LabelPrimitive.Root
170
+ className={ cn(
171
+ 'text-sm font-medium text-[var(--color-field-label,theme(colors.gray.700))]',
172
+ 'dark:text-[var(--color-field-label,theme(colors.gray.300))]',
173
+ disabled && 'opacity-40',
174
+ ) }
175
+ htmlFor={ id }
176
+ >
177
+ { label }
178
+ { required && (
179
+ <span className="ml-0.5 text-[var(--color-fg-error,theme(colors.red.500))]" aria-hidden="true">*</span>
180
+ ) }
181
+ { !required && optionalText && (
182
+ <span className="ml-1 text-[var(--color-text-secondary,theme(colors.gray.400))] text-sm font-normal">
183
+ { optionalText }
184
+ </span>
185
+ ) }
186
+ </LabelPrimitive.Root>
187
+ ) }
188
+ { clonedChild }
189
+ { helperText && (
190
+ <p className="text-xs text-[var(--color-text-secondary,theme(colors.gray.400))]">
191
+ { helperText }
192
+ </p>
193
+ ) }
194
+ { errorText && (
195
+ <p className="text-xs text-[var(--color-fg-error,theme(colors.red.500))]">
196
+ { errorText }
197
+ </p>
198
+ ) }
199
+ </div>
200
+ );
201
+ },
202
+ );
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+
3
+ import { cn } from './utils';
4
+
5
+ export interface HeadingProps extends React.ComponentPropsWithoutRef<'h1'> {
6
+ level?: '1' | '2' | '3';
7
+ // Legacy Chakra style-prop shims
8
+ mb?: number | string;
9
+ size?: string;
10
+ }
11
+
12
+ const LEVEL_TAG = {
13
+ '1': 'h1',
14
+ '2': 'h2',
15
+ '3': 'h3',
16
+ } as const;
17
+
18
+ // base (mobile) + lg (desktop) responsive text styles per level
19
+ //
20
+ // Level 1: heading.md -> heading.xl
21
+ // base: 18px/24px font-500
22
+ // lg: 32px/40px font-500 tracking=-0.5px
23
+ //
24
+ // Level 2: heading.sm -> heading.lg
25
+ // base: 16px/24px font-500
26
+ // lg: 24px/32px font-500
27
+ //
28
+ // Level 3: heading.xs -> heading.md
29
+ // base: 14px/20px font-600
30
+ // lg: 18px/24px font-500
31
+ const LEVEL_CLASSES = {
32
+ '1': 'text-[18px] leading-[24px] font-medium lg:text-[32px] lg:leading-[40px] lg:tracking-[-0.5px]',
33
+ '2': 'text-[16px] leading-[24px] font-medium lg:text-[24px] lg:leading-[32px]',
34
+ '3': 'text-[14px] leading-[20px] font-semibold lg:text-[18px] lg:leading-[24px] lg:font-medium',
35
+ } as const;
36
+
37
+ const BASE_CLASSES = 'font-heading text-heading';
38
+
39
+ export const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
40
+ function Heading({ level, className, mb, size: _size, style: styleProp, ...rest }, ref) {
41
+ const Tag = level ? LEVEL_TAG[level] : 'h2';
42
+ const levelClasses = level ? LEVEL_CLASSES[level] : undefined;
43
+ const shimStyle: React.CSSProperties = { ...styleProp };
44
+ if (mb !== undefined) shimStyle.marginBottom = typeof mb === 'number' ? `${ mb * 4 }px` : mb;
45
+
46
+ return (
47
+ <Tag
48
+ ref={ ref }
49
+ className={ cn(BASE_CLASSES, levelClasses, className) }
50
+ style={ Object.keys(shimStyle).length > 0 ? shimStyle : undefined }
51
+ { ...rest }
52
+ />
53
+ );
54
+ },
55
+ );
@@ -0,0 +1,192 @@
1
+ import { cva } from 'class-variance-authority';
2
+ import React from 'react';
3
+
4
+ import { cn } from './utils';
5
+
6
+ import { Skeleton } from './skeleton';
7
+
8
+ /* -------------------------------------------------------------------------- */
9
+ /* CVA variant definitions */
10
+ /* -------------------------------------------------------------------------- */
11
+
12
+ const iconButtonVariants = cva(
13
+ // base
14
+ [
15
+ 'inline-flex items-center justify-center',
16
+ 'p-0 min-w-auto shrink-0',
17
+ 'cursor-pointer border-0 bg-transparent',
18
+ 'disabled:opacity-[var(--opacity-control-disabled,0.4)] disabled:cursor-not-allowed',
19
+ ],
20
+ {
21
+ variants: {
22
+ variant: {
23
+ plain: 'bg-transparent text-inherit border-none hover:bg-transparent',
24
+ icon_secondary: [
25
+ 'bg-transparent text-icon-secondary border-none',
26
+ 'hover:text-hover',
27
+ 'data-[selected]:bg-selected-control-bg data-[selected]:text-selected-control-text',
28
+ 'data-[selected]:hover:text-hover',
29
+ 'data-[expanded]:text-hover',
30
+ ],
31
+ icon_background: [
32
+ 'bg-[var(--color-button-icon-background-bg)] text-icon-secondary border-none',
33
+ 'hover:text-hover',
34
+ 'data-[selected]:bg-selected-control-bg data-[selected]:text-selected-control-text',
35
+ 'data-[selected]:hover:text-hover',
36
+ 'data-[expanded]:text-hover',
37
+ ],
38
+ link: [
39
+ 'bg-transparent text-link-primary border-none font-normal px-0 h-auto',
40
+ 'hover:bg-transparent hover:text-link-primary-hover',
41
+ 'disabled:text-text-secondary',
42
+ ],
43
+ dropdown: [
44
+ 'border-2 border-solid bg-transparent',
45
+ 'text-[var(--color-button-dropdown-fg)] border-[var(--color-button-dropdown-border)]',
46
+ 'hover:bg-transparent hover:text-hover hover:border-hover',
47
+ 'data-[expanded]:bg-transparent data-[expanded]:text-hover data-[expanded]:border-hover',
48
+ 'data-[selected]:bg-selected-control-bg data-[selected]:text-selected-control-text data-[selected]:border-transparent',
49
+ 'data-[selected]:hover:text-hover',
50
+ ],
51
+ pagination: [
52
+ 'border-2 border-solid bg-transparent',
53
+ 'text-[var(--color-button-pagination-fg)] border-[var(--color-button-pagination-border)]',
54
+ 'hover:bg-transparent hover:text-hover hover:border-hover',
55
+ 'data-[selected]:bg-selected-control-bg data-[selected]:text-selected-control-text data-[selected]:border-transparent',
56
+ ],
57
+ },
58
+ size: {
59
+ '2xs': 'size-5 rounded-sm [&_svg]:size-5',
60
+ '2xs_alt': 'size-5 rounded-sm [&_svg]:size-3',
61
+ md: 'size-8 rounded-[var(--radius-base,8px)] [&_svg]:size-5',
62
+ },
63
+ },
64
+ defaultVariants: {
65
+ variant: 'plain',
66
+ },
67
+ },
68
+ );
69
+
70
+ /* -------------------------------------------------------------------------- */
71
+ /* Types */
72
+ /* -------------------------------------------------------------------------- */
73
+
74
+ type Variant = 'plain' | 'icon_secondary' | 'icon_background' | 'link' | 'dropdown' | 'pagination';
75
+ type Size = '2xs' | '2xs_alt' | 'md';
76
+
77
+ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
78
+
79
+ /** Visual variant */
80
+ variant?: Variant;
81
+
82
+ /** Icon-button size */
83
+ size?: Size;
84
+
85
+ /** Show a loading spinner (disables button) */
86
+ loading?: boolean;
87
+
88
+ /** Render a skeleton placeholder instead of the button */
89
+ loadingSkeleton?: boolean;
90
+
91
+ /** Maps to data-expanded for popover trigger styling */
92
+ expanded?: boolean;
93
+
94
+ /** Maps to data-selected for toggle styling */
95
+ selected?: boolean;
96
+
97
+ /** Maps to data-highlighted */
98
+ highlighted?: boolean;
99
+
100
+ /** Polymorphic element type (e.g. "div") */
101
+ as?: React.ElementType;
102
+
103
+ // Legacy Chakra style-prop shims
104
+ boxSize?: number | string;
105
+ color?: string;
106
+ px?: string | number;
107
+ borderRadius?: string;
108
+ ml?: number | string;
109
+ mr?: number | string;
110
+ _hover?: Record<string, string>;
111
+ _expanded?: Record<string, string>;
112
+ }
113
+
114
+ /* -------------------------------------------------------------------------- */
115
+ /* Component */
116
+ /* -------------------------------------------------------------------------- */
117
+
118
+ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
119
+ function IconButton(props, ref) {
120
+ const {
121
+ size,
122
+ variant = 'plain',
123
+ loading,
124
+ loadingSkeleton = false,
125
+ expanded,
126
+ selected,
127
+ highlighted,
128
+ disabled,
129
+ className,
130
+ children,
131
+ as: Comp = 'button',
132
+ style: styleProp,
133
+ // Strip Chakra style props
134
+ boxSize: _boxSize,
135
+ color: _color,
136
+ px: _px,
137
+ borderRadius: _borderRadius,
138
+ ml: _ml,
139
+ mr: _mr,
140
+ _hover,
141
+ _expanded,
142
+ ...rest
143
+ } = props;
144
+
145
+ const SP = 4;
146
+ const shimStyle: React.CSSProperties = { ...styleProp };
147
+ if (_boxSize !== undefined) {
148
+ const bs = typeof _boxSize === 'number' ? `${ _boxSize * SP }px` : _boxSize;
149
+ shimStyle.width = bs;
150
+ shimStyle.height = bs;
151
+ }
152
+ if (_color) shimStyle.color = _color;
153
+ if (_px !== undefined) {
154
+ const v = typeof _px === 'number' ? `${ _px * SP }px` : _px;
155
+ shimStyle.paddingLeft = v;
156
+ shimStyle.paddingRight = v;
157
+ }
158
+ if (_borderRadius) shimStyle.borderRadius = _borderRadius;
159
+ if (_ml !== undefined) shimStyle.marginLeft = typeof _ml === 'number' ? `${ _ml * SP }px` : _ml;
160
+ if (_mr !== undefined) shimStyle.marginRight = typeof _mr === 'number' ? `${ _mr * SP }px` : _mr;
161
+ const mergedBtnStyle = Object.keys(shimStyle).length > 0 ? shimStyle : undefined;
162
+
163
+ const button = (
164
+ <Comp
165
+ ref={ ref }
166
+ type={ Comp === 'button' ? 'button' : undefined }
167
+ disabled={ !loadingSkeleton && (loading || disabled) }
168
+ className={ cn(iconButtonVariants({ variant, size }), className) }
169
+ style={ mergedBtnStyle }
170
+ { ...(expanded ? { 'data-expanded': true } : {}) }
171
+ { ...(selected ? { 'data-selected': true } : {}) }
172
+ { ...(highlighted ? { 'data-highlighted': true } : {}) }
173
+ { ...(loadingSkeleton ? { 'data-loading-skeleton': true } : {}) }
174
+ { ...rest }
175
+ >
176
+ { loading ? (
177
+ <span className="inline-block size-5 animate-spin rounded-full border-2 border-current border-b-transparent border-l-transparent"/>
178
+ ) : children }
179
+ </Comp>
180
+ );
181
+
182
+ if (loadingSkeleton) {
183
+ return (
184
+ <Skeleton loading={ loadingSkeleton } asChild ref={ ref as React.ForwardedRef<HTMLDivElement> }>
185
+ { button }
186
+ </Skeleton>
187
+ );
188
+ }
189
+
190
+ return button;
191
+ },
192
+ );