@luxfi/ui 5.6.0 → 6.0.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.
- package/README.md +109 -0
- package/package.json +81 -278
- package/dist/accordion.cjs +0 -213
- package/dist/accordion.js +0 -186
- package/dist/alert.cjs +0 -553
- package/dist/alert.js +0 -531
- package/dist/avatar.cjs +0 -149
- package/dist/avatar.js +0 -125
- package/dist/badge.cjs +0 -611
- package/dist/badge.js +0 -589
- package/dist/button.cjs +0 -689
- package/dist/button.js +0 -664
- package/dist/checkbox.cjs +0 -265
- package/dist/checkbox.js +0 -241
- package/dist/close-button.cjs +0 -73
- package/dist/close-button.js +0 -51
- package/dist/collapsible.cjs +0 -702
- package/dist/collapsible.js +0 -679
- package/dist/color-mode.cjs +0 -96
- package/dist/color-mode.js +0 -72
- package/dist/dialog.cjs +0 -279
- package/dist/dialog.js +0 -246
- package/dist/drawer.cjs +0 -207
- package/dist/drawer.js +0 -175
- package/dist/empty-state.cjs +0 -93
- package/dist/empty-state.js +0 -71
- package/dist/field.cjs +0 -183
- package/dist/field.js +0 -160
- package/dist/heading.cjs +0 -46
- package/dist/heading.js +0 -40
- package/dist/icon-button.cjs +0 -491
- package/dist/icon-button.js +0 -470
- package/dist/image.cjs +0 -572
- package/dist/image.js +0 -551
- package/dist/index.cjs +0 -5779
- package/dist/index.js +0 -5619
- package/dist/input-group.cjs +0 -155
- package/dist/input-group.js +0 -133
- package/dist/input.cjs +0 -65
- package/dist/input.js +0 -59
- package/dist/link.cjs +0 -630
- package/dist/link.js +0 -606
- package/dist/menu.cjs +0 -305
- package/dist/menu.js +0 -269
- package/dist/pin-input.cjs +0 -182
- package/dist/pin-input.js +0 -160
- package/dist/popover.cjs +0 -327
- package/dist/popover.js +0 -294
- package/dist/progress-circle.cjs +0 -152
- package/dist/progress-circle.js +0 -128
- package/dist/progress.cjs +0 -117
- package/dist/progress.js +0 -94
- package/dist/provider.cjs +0 -62
- package/dist/provider.js +0 -40
- package/dist/radio.cjs +0 -177
- package/dist/radio.js +0 -153
- package/dist/rating.cjs +0 -80
- package/dist/rating.js +0 -58
- package/dist/select.cjs +0 -791
- package/dist/select.js +0 -757
- package/dist/separator.cjs +0 -57
- package/dist/separator.js +0 -51
- package/dist/skeleton.cjs +0 -370
- package/dist/skeleton.js +0 -346
- package/dist/slider.cjs +0 -138
- package/dist/slider.js +0 -115
- package/dist/switch.cjs +0 -163
- package/dist/switch.js +0 -140
- package/dist/table.cjs +0 -1044
- package/dist/table.js +0 -1013
- package/dist/tabs.cjs +0 -240
- package/dist/tabs.js +0 -213
- package/dist/tag.cjs +0 -651
- package/dist/tag.js +0 -628
- package/dist/textarea.cjs +0 -65
- package/dist/textarea.js +0 -59
- package/dist/toaster.cjs +0 -99
- package/dist/toaster.js +0 -96
- package/dist/tooltip.cjs +0 -171
- package/dist/tooltip.js +0 -148
- package/dist/utils.cjs +0 -11
- package/dist/utils.js +0 -9
- package/src/accordion.tsx +0 -285
- package/src/alert.tsx +0 -221
- package/src/avatar.tsx +0 -174
- package/src/badge.tsx +0 -158
- package/src/button.tsx +0 -411
- package/src/checkbox.tsx +0 -307
- package/src/close-button.tsx +0 -51
- package/src/collapsible.tsx +0 -126
- package/src/color-mode.tsx +0 -125
- package/src/dialog.tsx +0 -356
- package/src/drawer.tsx +0 -186
- package/src/empty-state.tsx +0 -97
- package/src/field.tsx +0 -202
- package/src/heading.tsx +0 -55
- package/src/icon-button.tsx +0 -192
- package/src/image.tsx +0 -280
- package/src/index.ts +0 -192
- package/src/input-group.tsx +0 -159
- package/src/input.tsx +0 -60
- package/src/link.tsx +0 -326
- package/src/menu.tsx +0 -471
- package/src/pin-input.tsx +0 -187
- package/src/popover.tsx +0 -400
- package/src/progress-circle.tsx +0 -180
- package/src/progress.tsx +0 -109
- package/src/provider.tsx +0 -12
- package/src/radio.tsx +0 -175
- package/src/rating.tsx +0 -79
- package/src/select.tsx +0 -696
- package/src/separator.tsx +0 -59
- package/src/skeleton.tsx +0 -302
- package/src/slider.tsx +0 -152
- package/src/switch.tsx +0 -158
- package/src/table.tsx +0 -621
- package/src/tabs.tsx +0 -354
- package/src/tag.tsx +0 -159
- package/src/textarea.tsx +0 -60
- package/src/toaster.tsx +0 -117
- package/src/tokens.css +0 -438
- package/src/tooltip.tsx +0 -184
- package/src/utils/cn.ts +0 -7
- package/src/utils.ts +0 -6
- package/tokens.css +0 -438
package/src/image.tsx
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
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';
|
package/src/input-group.tsx
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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';
|