@luxfi/ui 5.5.3 → 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 (244) 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 -65
  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 -112
  212. package/site-def/footer/community.tsx +0 -61
  213. package/site-def/footer/company.ts +0 -37
  214. package/site-def/footer/ecosystem.ts +0 -37
  215. package/site-def/footer/index.tsx +0 -26
  216. package/site-def/footer/legal.ts +0 -28
  217. package/site-def/footer/network.ts +0 -45
  218. package/site-def/footer/svg/warpcast-logo.svg +0 -12
  219. package/site-def/index.ts +0 -4
  220. package/site-def/main-nav.tsx +0 -460
  221. package/style/cart-animation.css +0 -29
  222. package/style/checkout-animation.css +0 -23
  223. package/style/drawer-handle-overrides.css +0 -160
  224. package/style/fonts/COPY_TO_PUBLIC_FOR_NON_NEXT.txt +0 -0
  225. package/style/fonts/Druk-Wide-Bold.ttf +0 -0
  226. package/style/fonts/Druk-Wide-Medium.ttf +0 -0
  227. package/style/fonts/InterVariable-Italic.ttf +0 -0
  228. package/style/fonts/InterVariable-Italic.woff2 +0 -0
  229. package/style/fonts/InterVariable.ttf +0 -0
  230. package/style/fonts/InterVariable.woff2 +0 -0
  231. package/style/lux-colors.css +0 -85
  232. package/style/lux-fonts.css +0 -30
  233. package/style/lux-global-non-next.css +0 -52
  234. package/style/lux-global.css +0 -51
  235. package/tailwind/fontFamily.tailwind.lux.ts +0 -18
  236. package/tailwind/index.ts +0 -2
  237. package/tailwind/lux-tw-fonts.ts +0 -40
  238. package/tailwind/tailwind.config.lux-preset.ts +0 -10
  239. package/tsconfig.json +0 -15
  240. package/types/chatbot-config.ts +0 -7
  241. package/types/chatbot-suggested-question.ts +0 -7
  242. package/types/contact-info.ts +0 -11
  243. package/types/index.ts +0 -4
  244. package/types/site-def.ts +0 -46
package/src/image.tsx ADDED
@@ -0,0 +1,280 @@
1
+ import React from 'react';
2
+
3
+ import { cn } from './utils';
4
+
5
+ import type { SkeletonProps } from './skeleton';
6
+ import { Skeleton } from './skeleton';
7
+
8
+ type CSSValue = string | number | undefined;
9
+ type ResponsiveValue<T> = T | { base?: T; sm?: T; md?: T; lg?: T; xl?: T; _light?: T; _dark?: T };
10
+
11
+ // Style props accepted for backward compatibility with Chakra callers.
12
+ // These are converted to inline styles on the <img> element.
13
+ interface StyleProps {
14
+ boxSize?: CSSValue;
15
+ borderRadius?: CSSValue;
16
+ width?: CSSValue;
17
+ w?: ResponsiveValue<CSSValue>;
18
+ height?: CSSValue;
19
+ h?: ResponsiveValue<CSSValue>;
20
+ maxW?: CSSValue;
21
+ maxH?: CSSValue;
22
+ minW?: CSSValue;
23
+ mr?: CSSValue;
24
+ mb?: CSSValue;
25
+ ml?: CSSValue;
26
+ mt?: CSSValue;
27
+ mx?: CSSValue;
28
+ my?: CSSValue;
29
+ marginRight?: CSSValue;
30
+ display?: CSSValue;
31
+ position?: CSSValue;
32
+ top?: CSSValue;
33
+ left?: ResponsiveValue<CSSValue>;
34
+ right?: CSSValue;
35
+ bottom?: CSSValue;
36
+ zIndex?: CSSValue;
37
+ objectFit?: CSSValue;
38
+ objectPosition?: CSSValue;
39
+ flexShrink?: CSSValue;
40
+ overflow?: CSSValue;
41
+ cursor?: CSSValue;
42
+ }
43
+
44
+ export interface ImageProps extends StyleProps {
45
+ readonly className?: string;
46
+ readonly src?: string;
47
+ readonly alt?: string;
48
+ readonly style?: React.CSSProperties;
49
+ readonly fallback?: React.ReactNode;
50
+ readonly onClick?: React.MouseEventHandler<HTMLImageElement>;
51
+ readonly onLoad?: React.ReactEventHandler<HTMLImageElement>;
52
+ readonly onError?: React.ReactEventHandler<HTMLImageElement>;
53
+ // for the case where the image dimensions are not known before the image is loaded
54
+ readonly skeletonWidth?: CSSValue;
55
+ readonly skeletonHeight?: CSSValue;
56
+ }
57
+
58
+ const CHAKRA_SPACING_SCALE: Record<string, string> = {
59
+ '0': '0px',
60
+ '1': '0.25rem',
61
+ '2': '0.5rem',
62
+ '3': '0.75rem',
63
+ '4': '1rem',
64
+ '5': '1.25rem',
65
+ '6': '1.5rem',
66
+ '7': '1.75rem',
67
+ '8': '2rem',
68
+ '10': '2.5rem',
69
+ '12': '3rem',
70
+ '14': '3.5rem',
71
+ '16': '4rem',
72
+ '20': '5rem',
73
+ };
74
+
75
+ const CHAKRA_RADII: Record<string, string> = {
76
+ none: '0',
77
+ sm: '0.125rem',
78
+ base: '0.25rem',
79
+ md: '0.375rem',
80
+ lg: '0.5rem',
81
+ xl: '0.75rem',
82
+ '2xl': '1rem',
83
+ '3xl': '1.5rem',
84
+ full: '9999px',
85
+ };
86
+
87
+ function resolveSize(value: CSSValue): string | undefined {
88
+ if (value === undefined) return undefined;
89
+ if (typeof value === 'number') return `${ value }px`;
90
+ if (CHAKRA_SPACING_SCALE[value]) return CHAKRA_SPACING_SCALE[value];
91
+ return value;
92
+ }
93
+
94
+ function resolveRadius(value: CSSValue): string | undefined {
95
+ if (value === undefined) return undefined;
96
+ if (typeof value === 'number') return `${ value }px`;
97
+ if (CHAKRA_RADII[value as string]) return CHAKRA_RADII[value as string];
98
+ return String(value);
99
+ }
100
+
101
+ function resolveSimple(value: CSSValue): string | number | undefined {
102
+ if (value === undefined) return undefined;
103
+ return typeof value === 'number' ? value : value;
104
+ }
105
+
106
+ // Extract the "base" value from a responsive value or plain value
107
+ function baseValue<T>(val: ResponsiveValue<T> | undefined): T | undefined {
108
+ if (val === undefined) return undefined;
109
+ if (typeof val === 'object' && val !== null && ('base' in val || 'md' in val || 'lg' in val)) {
110
+ return (val as { base?: T }).base;
111
+ }
112
+ return val as T;
113
+ }
114
+
115
+ function buildStyle(props: StyleProps): React.CSSProperties {
116
+ const s: React.CSSProperties = {};
117
+
118
+ const size = resolveSize(props.boxSize);
119
+ if (size) {
120
+ s.width = size;
121
+ s.height = size;
122
+ }
123
+
124
+ const w = resolveSize(props.width ?? baseValue(props.w) as CSSValue);
125
+ if (w) s.width = w;
126
+
127
+ const hVal = baseValue(props.height ?? props.h);
128
+ const h = resolveSize(hVal);
129
+ if (h) s.height = h;
130
+
131
+ const maxW = resolveSize(props.maxW);
132
+ if (maxW) s.maxWidth = maxW;
133
+
134
+ const maxH = resolveSize(props.maxH);
135
+ if (maxH) s.maxHeight = maxH;
136
+
137
+ const minW = resolveSize(props.minW);
138
+ if (minW) s.minWidth = minW;
139
+
140
+ const br = resolveRadius(props.borderRadius);
141
+ if (br) s.borderRadius = br;
142
+
143
+ const mr = resolveSize(props.marginRight ?? props.mr);
144
+ if (mr) s.marginRight = mr;
145
+
146
+ const ml = resolveSize(props.ml);
147
+ if (ml) s.marginLeft = ml;
148
+
149
+ const mt = resolveSize(props.mt);
150
+ if (mt) s.marginTop = mt;
151
+
152
+ const mb = resolveSize(props.mb);
153
+ if (mb) s.marginBottom = mb;
154
+
155
+ const mx = resolveSize(props.mx);
156
+ if (mx) {
157
+ s.marginLeft = mx; s.marginRight = mx;
158
+ }
159
+
160
+ const my = resolveSize(props.my);
161
+ if (my) {
162
+ s.marginTop = my; s.marginBottom = my;
163
+ }
164
+
165
+ if (props.display !== undefined) s.display = String(props.display) as React.CSSProperties['display'];
166
+ if (props.position !== undefined) s.position = String(props.position) as React.CSSProperties['position'];
167
+
168
+ const top = resolveSimple(props.top);
169
+ if (top !== undefined) s.top = typeof top === 'number' ? `${ top }px` : top;
170
+
171
+ const leftVal = baseValue(props.left);
172
+ const left = resolveSimple(leftVal);
173
+ if (left !== undefined) s.left = typeof left === 'number' ? `${ left }px` : left;
174
+
175
+ const right = resolveSimple(props.right);
176
+ if (right !== undefined) s.right = typeof right === 'number' ? `${ right }px` : right;
177
+
178
+ const bottom = resolveSimple(props.bottom);
179
+ if (bottom !== undefined) s.bottom = typeof bottom === 'number' ? `${ bottom }px` : bottom;
180
+
181
+ if (props.zIndex !== undefined) s.zIndex = typeof props.zIndex === 'number' ? props.zIndex : Number(props.zIndex) || undefined;
182
+ if (props.objectFit !== undefined) s.objectFit = String(props.objectFit) as React.CSSProperties['objectFit'];
183
+ if (props.objectPosition !== undefined) s.objectPosition = String(props.objectPosition);
184
+ if (props.flexShrink !== undefined) s.flexShrink = typeof props.flexShrink === 'number' ? props.flexShrink : Number(props.flexShrink);
185
+ if (props.overflow !== undefined) s.overflow = String(props.overflow) as React.CSSProperties['overflow'];
186
+
187
+ return s;
188
+ }
189
+
190
+ // Keys that are style props and should NOT be forwarded to the <img> element
191
+ const STYLE_PROP_KEYS = new Set<string>([
192
+ 'boxSize', 'borderRadius', 'width', 'w', 'height', 'h',
193
+ 'maxW', 'maxH', 'minW',
194
+ 'mr', 'mb', 'ml', 'mt', 'mx', 'my', 'marginRight',
195
+ 'display', 'position', 'top', 'left', 'right', 'bottom',
196
+ 'zIndex', 'objectFit', 'objectPosition', 'flexShrink', 'overflow',
197
+ ]);
198
+
199
+ function extractStyleProps(props: Record<string, unknown>): { styleProps: StyleProps; rest: Record<string, unknown> } {
200
+ const styleProps: Record<string, unknown> = {};
201
+ const rest: Record<string, unknown> = {};
202
+
203
+ for (const key in props) {
204
+ if (STYLE_PROP_KEYS.has(key)) {
205
+ styleProps[key] = props[key];
206
+ } else {
207
+ rest[key] = props[key];
208
+ }
209
+ }
210
+
211
+ return { styleProps: styleProps as StyleProps, rest };
212
+ }
213
+
214
+ export const Image = React.forwardRef<HTMLImageElement, ImageProps>(
215
+ function Image(props, ref) {
216
+ const { fallback, src, onLoad, onError, skeletonWidth, skeletonHeight, alt, className, style: styleProp, ...allRest } = props;
217
+
218
+ const { styleProps, rest: extraProps } = extractStyleProps(allRest as Record<string, unknown>);
219
+
220
+ const [ loading, setLoading ] = React.useState(true);
221
+ const [ error, setError ] = React.useState(false);
222
+
223
+ const handleLoadError = React.useCallback((event: React.SyntheticEvent<HTMLImageElement>) => {
224
+ setError(true);
225
+ setLoading(false);
226
+ onError?.(event);
227
+ }, [ onError ]);
228
+
229
+ const handleLoadSuccess = React.useCallback((event: React.SyntheticEvent<HTMLImageElement>) => {
230
+ setLoading(false);
231
+ onLoad?.(event);
232
+ }, [ onLoad ]);
233
+
234
+ // For fallback rendering, pass through all original style props so Chakra-based fallbacks still work
235
+ const passthroughProps = allRest;
236
+
237
+ if (!src && fallback) {
238
+ if (React.isValidElement(fallback)) {
239
+ return React.cloneElement(fallback, passthroughProps);
240
+ }
241
+ return fallback;
242
+ }
243
+
244
+ if (error) {
245
+ if (React.isValidElement(fallback)) {
246
+ return React.cloneElement(fallback, passthroughProps);
247
+ }
248
+ return fallback;
249
+ }
250
+
251
+ const skeletonProps = {
252
+ ...passthroughProps,
253
+ ...(skeletonWidth !== undefined && { width: skeletonWidth }),
254
+ ...(skeletonHeight !== undefined && { height: skeletonHeight }),
255
+ };
256
+
257
+ const computedStyle = buildStyle(styleProps);
258
+ const mergedStyle: React.CSSProperties = {
259
+ ...computedStyle,
260
+ ...styleProp,
261
+ display: loading ? 'none' : (computedStyle.display || styleProp?.display || 'block'),
262
+ };
263
+
264
+ return (
265
+ <>
266
+ { loading && <Skeleton loading { ...skeletonProps as Partial<SkeletonProps> }/> }
267
+ <img
268
+ ref={ ref }
269
+ src={ src }
270
+ alt={ alt || '' }
271
+ onError={ handleLoadError }
272
+ onLoad={ handleLoadSuccess }
273
+ className={ cn(className) }
274
+ style={ mergedStyle }
275
+ { ...extraProps }
276
+ />
277
+ </>
278
+ );
279
+ },
280
+ );
package/src/index.ts ADDED
@@ -0,0 +1,192 @@
1
+ export { cn } from './utils';
2
+
3
+ export {
4
+ AccordionRoot,
5
+ AccordionItem,
6
+ AccordionItemTrigger,
7
+ AccordionItemContent,
8
+ useAccordion,
9
+ } from './accordion';
10
+
11
+ export { Alert } from './alert';
12
+ export type { AlertProps } from './alert';
13
+
14
+ export { Avatar, AvatarGroup } from './avatar';
15
+ export type { AvatarProps } from './avatar';
16
+
17
+ export { Badge } from './badge';
18
+ export type { BadgeProps } from './badge';
19
+
20
+ export {
21
+ Button,
22
+ ButtonGroup,
23
+ ButtonGroupRadio,
24
+ buttonVariants,
25
+ } from './button';
26
+ export type { ButtonProps, ButtonGroupProps, ButtonGroupRadioProps } from './button';
27
+
28
+ export { Checkbox, CheckboxGroup } from './checkbox';
29
+ export type { CheckboxProps, CheckboxGroupProps } from './checkbox';
30
+
31
+ export { CloseButton } from './close-button';
32
+ export type { CloseButtonProps } from './close-button';
33
+
34
+ export { CollapsibleDetails, CollapsibleList } from './collapsible';
35
+
36
+ export { ColorModeProvider, useColorMode, useColorModeValue } from './color-mode';
37
+ export type { ColorMode } from './color-mode';
38
+
39
+ export {
40
+ DialogRoot,
41
+ DialogContent,
42
+ DialogCloseTrigger,
43
+ DialogHeader,
44
+ DialogBody,
45
+ DialogFooter,
46
+ DialogBackdrop,
47
+ DialogTitle,
48
+ DialogDescription,
49
+ DialogTrigger,
50
+ DialogActionTrigger,
51
+ } from './dialog';
52
+
53
+ export {
54
+ DrawerRoot,
55
+ DrawerContent,
56
+ DrawerCloseTrigger,
57
+ DrawerTrigger,
58
+ DrawerHeader,
59
+ DrawerBody,
60
+ DrawerFooter,
61
+ DrawerTitle,
62
+ DrawerDescription,
63
+ DrawerActionTrigger,
64
+ } from './drawer';
65
+
66
+ export { EmptyState } from './empty-state';
67
+ export type { EmptyStateProps } from './empty-state';
68
+
69
+ export { Field } from './field';
70
+ export type { FieldProps } from './field';
71
+
72
+ export { Heading } from './heading';
73
+ export type { HeadingProps } from './heading';
74
+
75
+ export { IconButton } from './icon-button';
76
+ export type { IconButtonProps } from './icon-button';
77
+
78
+ export { Image } from './image';
79
+ export type { ImageProps } from './image';
80
+
81
+ export { Input } from './input';
82
+ export type { InputProps } from './input';
83
+
84
+ export { InputGroup } from './input-group';
85
+ export type { InputGroupProps } from './input-group';
86
+
87
+ export { Link, LinkBox, LinkOverlay, LinkExternalIcon } from './link';
88
+ export type { LinkProps } from './link';
89
+
90
+ export {
91
+ MenuRoot,
92
+ MenuTrigger,
93
+ MenuContent,
94
+ MenuItem,
95
+ MenuItemText,
96
+ MenuSeparator,
97
+ MenuItemGroup,
98
+ MenuCheckboxItem,
99
+ MenuRadioItemGroup,
100
+ MenuRadioItem,
101
+ MenuTriggerItem,
102
+ MenuArrow,
103
+ } from './menu';
104
+
105
+ export { PinInput } from './pin-input';
106
+
107
+ export {
108
+ PopoverRoot,
109
+ PopoverTrigger,
110
+ PopoverContent,
111
+ PopoverArrow,
112
+ PopoverCloseTrigger,
113
+ PopoverCloseTriggerWrapper,
114
+ PopoverBody,
115
+ PopoverHeader,
116
+ PopoverFooter,
117
+ PopoverTitle,
118
+ PopoverDescription,
119
+ } from './popover';
120
+
121
+ export { Progress } from './progress';
122
+
123
+ export {
124
+ ProgressCircleRoot,
125
+ ProgressCircleRing,
126
+ ProgressCircleValueText,
127
+ } from './progress-circle';
128
+
129
+ export { Radio, RadioGroup } from './radio';
130
+
131
+ export { Rating } from './rating';
132
+
133
+ export {
134
+ SelectRoot,
135
+ SelectControl,
136
+ SelectContent,
137
+ SelectItem,
138
+ SelectValueText,
139
+ SelectItemGroup,
140
+ SelectLabel,
141
+ SelectItemText,
142
+ Select,
143
+ SelectAsync,
144
+ SelectClearTrigger,
145
+ createListCollection,
146
+ } from './select';
147
+ export type { SelectOption, ListCollection, SelectRootProps, SelectProps, SelectAsyncProps } from './select';
148
+
149
+ export { Separator } from './separator';
150
+ export type { SeparatorProps } from './separator';
151
+
152
+ export { Skeleton, SkeletonCircle, SkeletonText } from './skeleton';
153
+ export type { SkeletonProps, SkeletonCircleProps, SkeletonTextProps } from './skeleton';
154
+
155
+ export { Slider } from './slider';
156
+
157
+ export { Switch } from './switch';
158
+
159
+ export {
160
+ TableRoot,
161
+ TableHeader,
162
+ TableBody,
163
+ TableRow,
164
+ TableCell,
165
+ TableColumnHeader,
166
+ TableColumnHeaderSortable,
167
+ TableCaption,
168
+ TableFooter,
169
+ TableScrollWrapper,
170
+ TableHeaderSticky,
171
+ } from './table';
172
+
173
+ export {
174
+ TabsRoot,
175
+ TabsList,
176
+ TabsTrigger,
177
+ TabsContent,
178
+ TabsCounter,
179
+ } from './tabs';
180
+
181
+ export { Tag } from './tag';
182
+ export type { TagProps } from './tag';
183
+
184
+ export { Textarea } from './textarea';
185
+ export type { TextareaProps } from './textarea';
186
+
187
+ export { Toaster, toaster } from './toaster';
188
+
189
+ export { Tooltip } from './tooltip';
190
+ export type { TooltipProps } from './tooltip';
191
+
192
+ export { Provider } from './provider';
@@ -0,0 +1,159 @@
1
+ import { debounce } from 'es-toolkit';
2
+ import * as React from 'react';
3
+
4
+ import { cn } from './utils';
5
+
6
+ import type { InputProps } from './input';
7
+
8
+ function getComponentDisplayName(type: string | React.JSXElementConstructor<unknown>): string | undefined {
9
+ if (typeof type === 'string') return undefined;
10
+ if ('displayName' in type) return type.displayName as string;
11
+ return undefined;
12
+ }
13
+
14
+ export interface InputElementProps extends React.HTMLAttributes<HTMLDivElement> {
15
+ readonly placement?: 'start' | 'end';
16
+ }
17
+
18
+ export interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement> {
19
+ readonly startElementProps?: InputElementProps;
20
+ readonly endElementProps?: InputElementProps;
21
+ readonly startElement?: React.ReactNode;
22
+ readonly endElement?: React.ReactNode;
23
+ readonly children: React.ReactElement<InputElementProps>;
24
+ readonly startOffset?: string | number;
25
+ readonly endOffset?: string | number;
26
+ }
27
+
28
+ export const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
29
+ function InputGroup(props, ref) {
30
+ const {
31
+ startElement,
32
+ startElementProps,
33
+ endElement,
34
+ endElementProps,
35
+ children,
36
+ startOffset,
37
+ endOffset,
38
+ className,
39
+ ...rest
40
+ } = props;
41
+
42
+ const startElementRef = React.useRef<HTMLDivElement>(null);
43
+ const endElementRef = React.useRef<HTMLDivElement>(null);
44
+ const groupRef = React.useRef<HTMLDivElement>(null);
45
+
46
+ const [ inlinePaddings, setInlinePaddings ] = React.useState<{ start?: number; end?: number }>();
47
+
48
+ const calculateInlinePaddings = React.useCallback(() => {
49
+ const startWidth = startElementRef.current?.getBoundingClientRect().width ?? 0;
50
+ const endWidth = endElementRef.current?.getBoundingClientRect().width ?? 0;
51
+
52
+ setInlinePaddings({
53
+ start: startWidth,
54
+ end: endWidth,
55
+ });
56
+ }, []);
57
+
58
+ React.useEffect(() => {
59
+ if (!groupRef.current) return;
60
+
61
+ let timeoutId: ReturnType<typeof setTimeout>;
62
+
63
+ const intersectionObserver = new IntersectionObserver(
64
+ (entries) => {
65
+ const entry = entries[0];
66
+ if (entry && entry.isIntersecting) {
67
+ // Small delay to ensure rendering is complete
68
+ timeoutId = setTimeout(calculateInlinePaddings, 50);
69
+ }
70
+ },
71
+ { threshold: 0.01 },
72
+ );
73
+
74
+ intersectionObserver.observe(groupRef.current);
75
+
76
+ return () => {
77
+ intersectionObserver.disconnect();
78
+ if (timeoutId) {
79
+ clearTimeout(timeoutId);
80
+ }
81
+ };
82
+ }, [ calculateInlinePaddings ]);
83
+
84
+ React.useEffect(() => {
85
+ calculateInlinePaddings();
86
+
87
+ const resizeHandler = debounce(calculateInlinePaddings, 300);
88
+ const resizeObserver = new ResizeObserver(resizeHandler);
89
+
90
+ if (groupRef.current) {
91
+ resizeObserver.observe(groupRef.current);
92
+ }
93
+
94
+ return function cleanup() {
95
+ resizeObserver.disconnect();
96
+ };
97
+ }, [ calculateInlinePaddings ]);
98
+
99
+ // Combine refs for the wrapper div
100
+ const combinedRef = React.useCallback((node: HTMLDivElement) => {
101
+ groupRef.current = node;
102
+ if (typeof ref === 'function') {
103
+ ref(node);
104
+ } else if (ref) {
105
+ ref.current = node;
106
+ }
107
+ }, [ ref ]);
108
+
109
+ const { className: startClassName, ...startRest } = startElementProps ?? {};
110
+ const { className: endClassName, ...endRest } = endElementProps ?? {};
111
+
112
+ return (
113
+ <div
114
+ ref={ combinedRef }
115
+ className={ cn('relative flex w-full items-center', className) }
116
+ { ...rest }
117
+ >
118
+ { startElement && (
119
+ <div
120
+ ref={ startElementRef }
121
+ className={ cn(
122
+ 'pointer-events-none absolute inset-y-0 left-0 z-[1] flex items-center text-[var(--chakra-colors-input-element)]',
123
+ startClassName,
124
+ ) }
125
+ { ...startRest }
126
+ >
127
+ { startElement }
128
+ </div>
129
+ ) }
130
+ { React.Children.map(children, (child: React.ReactElement<InputProps>) => {
131
+ if (getComponentDisplayName(child.type) !== 'FieldInput') {
132
+ return child;
133
+ }
134
+ return React.cloneElement(child, {
135
+ ...(startElement && { ps: startOffset ?? (inlinePaddings?.start ? `${ inlinePaddings.start }px` : undefined) }),
136
+ ...(endElement && { pe: endOffset ?? (inlinePaddings?.end ? `${ inlinePaddings.end }px` : undefined) }),
137
+ // hide input value and placeholder for the first render
138
+ value: inlinePaddings ? child.props.value : undefined,
139
+ placeholder: inlinePaddings ? child.props.placeholder : undefined,
140
+ });
141
+ }) }
142
+ { endElement && (
143
+ <div
144
+ ref={ endElementRef }
145
+ className={ cn(
146
+ 'pointer-events-none absolute inset-y-0 right-0 z-[1] flex items-center text-[var(--chakra-colors-input-element)]',
147
+ endClassName,
148
+ ) }
149
+ { ...endRest }
150
+ >
151
+ { endElement }
152
+ </div>
153
+ ) }
154
+ </div>
155
+ );
156
+ },
157
+ );
158
+
159
+ InputGroup.displayName = 'InputGroup';
package/src/input.tsx ADDED
@@ -0,0 +1,60 @@
1
+ import { cva } from 'class-variance-authority';
2
+ import React from 'react';
3
+
4
+ import { cn } from './utils';
5
+
6
+ const inputVariants = cva(
7
+ [
8
+ 'w-full appearance-none outline-none transition-colors',
9
+ 'bg-[var(--color-input-bg)] text-[var(--color-input-fg)] border-[var(--color-input-border)]',
10
+ 'placeholder:text-[var(--color-input-placeholder,theme(colors.gray.400))]',
11
+ 'hover:border-[var(--color-input-border-hover,theme(colors.gray.400))]',
12
+ 'focus:border-[var(--color-input-border-focus,theme(colors.blue.500))]',
13
+ 'focus:placeholder:text-[var(--color-input-placeholder-focus,theme(colors.gray.300))]',
14
+ 'disabled:opacity-40 disabled:cursor-not-allowed',
15
+ 'read-only:opacity-70',
16
+ 'data-[invalid]:border-[var(--color-input-border-invalid,theme(colors.red.500))]',
17
+ ].join(' '),
18
+ {
19
+ variants: {
20
+ size: {
21
+ xs: 'h-6 px-2 text-xs rounded',
22
+ sm: 'h-8 px-3 text-sm rounded-md',
23
+ md: 'h-10 px-4 text-base rounded-md',
24
+ lg: 'h-12 px-4 text-lg rounded-lg',
25
+ '2xl': 'h-14 px-4 text-xl rounded-lg',
26
+ },
27
+ variant: {
28
+ outline: 'border border-solid',
29
+ filled: 'border-0 bg-[var(--color-input-filled-bg,theme(colors.gray.100))]',
30
+ unstyled: 'border-0 bg-transparent p-0 h-auto',
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ size: 'md',
35
+ variant: 'outline',
36
+ },
37
+ },
38
+ );
39
+
40
+ type InputSize = 'xs' | 'sm' | 'md' | 'lg' | '2xl';
41
+ type InputVariant = 'outline' | 'filled' | 'unstyled';
42
+
43
+ export interface InputProps extends Omit<React.ComponentPropsWithRef<'input'>, 'size'> {
44
+ readonly size?: InputSize;
45
+ readonly variant?: InputVariant;
46
+ }
47
+
48
+ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
49
+ ({ size, variant, className, ...rest }, ref) => {
50
+ return (
51
+ <input
52
+ ref={ ref }
53
+ className={ cn(inputVariants({ size, variant }), className) }
54
+ { ...rest }
55
+ />
56
+ );
57
+ },
58
+ );
59
+
60
+ Input.displayName = 'Input';