@luxfi/ui 5.6.0 → 6.1.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 (155) hide show
  1. package/dist/components/Badge.d.ts.map +1 -0
  2. package/dist/components/Badge.js +91 -0
  3. package/dist/components/Button.d.ts.map +1 -0
  4. package/dist/components/Button.js +137 -0
  5. package/dist/components/Card.d.ts.map +1 -0
  6. package/dist/components/Card.js +86 -0
  7. package/dist/components/IconButton.d.ts.map +1 -0
  8. package/dist/components/IconButton.js +64 -0
  9. package/dist/components/Input.d.ts.map +1 -0
  10. package/dist/components/Input.js +71 -0
  11. package/dist/components/Modal.d.ts.map +1 -0
  12. package/dist/components/Modal.js +98 -0
  13. package/dist/components/Skeleton.d.ts.map +1 -0
  14. package/dist/components/Skeleton.js +44 -0
  15. package/dist/components/Spinner.d.ts.map +1 -0
  16. package/dist/components/Spinner.js +42 -0
  17. package/dist/components/Switch.d.ts.map +1 -0
  18. package/dist/components/Switch.js +10 -0
  19. package/dist/components/TokenLogo.d.ts.map +1 -0
  20. package/dist/components/TokenLogo.js +57 -0
  21. package/dist/components/Tooltip.d.ts.map +1 -0
  22. package/dist/components/Tooltip.js +34 -0
  23. package/dist/components/index.d.ts.map +1 -0
  24. package/dist/components/index.js +19 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +35 -5618
  27. package/dist/theme/index.d.ts.map +1 -0
  28. package/dist/theme/index.js +6 -0
  29. package/dist/theme/themes.d.ts.map +1 -0
  30. package/dist/theme/themes.js +73 -0
  31. package/dist/theme/tokens.d.ts.map +1 -0
  32. package/dist/theme/tokens.js +101 -0
  33. package/package.json +81 -278
  34. package/dist/accordion.cjs +0 -213
  35. package/dist/accordion.js +0 -186
  36. package/dist/alert.cjs +0 -553
  37. package/dist/alert.js +0 -531
  38. package/dist/avatar.cjs +0 -149
  39. package/dist/avatar.js +0 -125
  40. package/dist/badge.cjs +0 -611
  41. package/dist/badge.js +0 -589
  42. package/dist/button.cjs +0 -689
  43. package/dist/button.js +0 -664
  44. package/dist/checkbox.cjs +0 -265
  45. package/dist/checkbox.js +0 -241
  46. package/dist/close-button.cjs +0 -73
  47. package/dist/close-button.js +0 -51
  48. package/dist/collapsible.cjs +0 -702
  49. package/dist/collapsible.js +0 -679
  50. package/dist/color-mode.cjs +0 -96
  51. package/dist/color-mode.js +0 -72
  52. package/dist/dialog.cjs +0 -279
  53. package/dist/dialog.js +0 -246
  54. package/dist/drawer.cjs +0 -207
  55. package/dist/drawer.js +0 -175
  56. package/dist/empty-state.cjs +0 -93
  57. package/dist/empty-state.js +0 -71
  58. package/dist/field.cjs +0 -183
  59. package/dist/field.js +0 -160
  60. package/dist/heading.cjs +0 -46
  61. package/dist/heading.js +0 -40
  62. package/dist/icon-button.cjs +0 -491
  63. package/dist/icon-button.js +0 -470
  64. package/dist/image.cjs +0 -572
  65. package/dist/image.js +0 -551
  66. package/dist/index.cjs +0 -5779
  67. package/dist/input-group.cjs +0 -155
  68. package/dist/input-group.js +0 -133
  69. package/dist/input.cjs +0 -65
  70. package/dist/input.js +0 -59
  71. package/dist/link.cjs +0 -630
  72. package/dist/link.js +0 -606
  73. package/dist/menu.cjs +0 -305
  74. package/dist/menu.js +0 -269
  75. package/dist/pin-input.cjs +0 -182
  76. package/dist/pin-input.js +0 -160
  77. package/dist/popover.cjs +0 -327
  78. package/dist/popover.js +0 -294
  79. package/dist/progress-circle.cjs +0 -152
  80. package/dist/progress-circle.js +0 -128
  81. package/dist/progress.cjs +0 -117
  82. package/dist/progress.js +0 -94
  83. package/dist/provider.cjs +0 -62
  84. package/dist/provider.js +0 -40
  85. package/dist/radio.cjs +0 -177
  86. package/dist/radio.js +0 -153
  87. package/dist/rating.cjs +0 -80
  88. package/dist/rating.js +0 -58
  89. package/dist/select.cjs +0 -791
  90. package/dist/select.js +0 -757
  91. package/dist/separator.cjs +0 -57
  92. package/dist/separator.js +0 -51
  93. package/dist/skeleton.cjs +0 -370
  94. package/dist/skeleton.js +0 -346
  95. package/dist/slider.cjs +0 -138
  96. package/dist/slider.js +0 -115
  97. package/dist/switch.cjs +0 -163
  98. package/dist/switch.js +0 -140
  99. package/dist/table.cjs +0 -1044
  100. package/dist/table.js +0 -1013
  101. package/dist/tabs.cjs +0 -240
  102. package/dist/tabs.js +0 -213
  103. package/dist/tag.cjs +0 -651
  104. package/dist/tag.js +0 -628
  105. package/dist/textarea.cjs +0 -65
  106. package/dist/textarea.js +0 -59
  107. package/dist/toaster.cjs +0 -99
  108. package/dist/toaster.js +0 -96
  109. package/dist/tooltip.cjs +0 -171
  110. package/dist/tooltip.js +0 -148
  111. package/dist/utils.cjs +0 -11
  112. package/dist/utils.js +0 -9
  113. package/src/accordion.tsx +0 -285
  114. package/src/alert.tsx +0 -221
  115. package/src/avatar.tsx +0 -174
  116. package/src/badge.tsx +0 -158
  117. package/src/button.tsx +0 -411
  118. package/src/checkbox.tsx +0 -307
  119. package/src/close-button.tsx +0 -51
  120. package/src/collapsible.tsx +0 -126
  121. package/src/color-mode.tsx +0 -125
  122. package/src/dialog.tsx +0 -356
  123. package/src/drawer.tsx +0 -186
  124. package/src/empty-state.tsx +0 -97
  125. package/src/field.tsx +0 -202
  126. package/src/heading.tsx +0 -55
  127. package/src/icon-button.tsx +0 -192
  128. package/src/image.tsx +0 -280
  129. package/src/index.ts +0 -192
  130. package/src/input-group.tsx +0 -159
  131. package/src/input.tsx +0 -60
  132. package/src/link.tsx +0 -326
  133. package/src/menu.tsx +0 -471
  134. package/src/pin-input.tsx +0 -187
  135. package/src/popover.tsx +0 -400
  136. package/src/progress-circle.tsx +0 -180
  137. package/src/progress.tsx +0 -109
  138. package/src/provider.tsx +0 -12
  139. package/src/radio.tsx +0 -175
  140. package/src/rating.tsx +0 -79
  141. package/src/select.tsx +0 -696
  142. package/src/separator.tsx +0 -59
  143. package/src/skeleton.tsx +0 -302
  144. package/src/slider.tsx +0 -152
  145. package/src/switch.tsx +0 -158
  146. package/src/table.tsx +0 -621
  147. package/src/tabs.tsx +0 -354
  148. package/src/tag.tsx +0 -159
  149. package/src/textarea.tsx +0 -60
  150. package/src/toaster.tsx +0 -117
  151. package/src/tokens.css +0 -438
  152. package/src/tooltip.tsx +0 -184
  153. package/src/utils/cn.ts +0 -7
  154. package/src/utils.ts +0 -6
  155. package/tokens.css +0 -438
package/src/tabs.tsx DELETED
@@ -1,354 +0,0 @@
1
- import * as RadixTabs from '@radix-ui/react-tabs';
2
- import * as React from 'react';
3
-
4
- import { cn } from './utils';
5
-
6
- // ---------------------------------------------------------------------------
7
- // Variant / size / fitted types (match the old Chakra recipe)
8
- // ---------------------------------------------------------------------------
9
-
10
- type TabsVariant = 'solid' | 'secondary' | 'segmented' | 'unstyled';
11
- type TabsSize = 'sm' | 'md' | 'free';
12
-
13
- // ---------------------------------------------------------------------------
14
- // TabsRoot
15
- // ---------------------------------------------------------------------------
16
-
17
- export interface TabsProps extends Omit<React.ComponentPropsWithoutRef<typeof RadixTabs.Root>, 'onValueChange'> {
18
-
19
- /** Visual variant. Default: "solid". */
20
- variant?: TabsVariant;
21
-
22
- /** Size preset. Default: "md". */
23
- size?: TabsSize;
24
-
25
- /** Stretch triggers to fill the list width. */
26
- fitted?: boolean;
27
-
28
- /**
29
- * @deprecated Chakra-compat. Radix mounts lazily by default (content only
30
- * renders when active). Kept so call-sites don't break at compile time.
31
- */
32
- lazyMount?: boolean;
33
-
34
- /**
35
- * @deprecated Chakra-compat. Radix unmounts inactive content by default.
36
- * Kept so call-sites don't break at compile time.
37
- */
38
- unmountOnExit?: boolean;
39
-
40
- /**
41
- * Chakra-compatible value-change handler.
42
- * Accepts both `(details: { value: string }) => void` (Chakra convention)
43
- * and `(value: string) => void` (Radix convention).
44
- */
45
- onValueChange?: ((details: { value: string }) => void) | ((value: string) => void);
46
- }
47
-
48
- const ROOT_SIZE_CLASSES: Record<TabsSize, string> = {
49
- sm: '[--tabs-height:2rem] [--tabs-content-padding:1.5rem]',
50
- md: '[--tabs-height:2.5rem] [--tabs-content-padding:1.5rem]',
51
- free: '',
52
- };
53
-
54
- export const TabsRoot = React.forwardRef<HTMLDivElement, TabsProps>(
55
- function TabsRoot(props, ref) {
56
- const {
57
- variant = 'solid',
58
- size = 'md',
59
- fitted,
60
- lazyMount: _lazyMount,
61
- unmountOnExit: _unmountOnExit,
62
- onValueChange,
63
- className,
64
- ...rest
65
- } = props;
66
-
67
- // Bridge Chakra-style `onValueChange({value})` to Radix `onValueChange(value)`
68
- const handleValueChange = React.useCallback(
69
- (value: string) => {
70
- if (!onValueChange) return;
71
- // Detect which signature the caller expects by trying the Chakra shape.
72
- // Both signatures are valid TS, so we call with the object form since
73
- // all existing consumers use `({ value })`.
74
- (onValueChange as (details: { value: string }) => void)({ value });
75
- },
76
- [ onValueChange ],
77
- );
78
-
79
- return (
80
- <RadixTabs.Root
81
- ref={ ref }
82
- data-variant={ variant }
83
- data-size={ size }
84
- data-fitted={ fitted ? '' : undefined }
85
- className={ cn(
86
- 'relative',
87
- ROOT_SIZE_CLASSES[size],
88
- className,
89
- ) }
90
- onValueChange={ onValueChange ? handleValueChange : undefined }
91
- { ...rest }
92
- />
93
- );
94
- },
95
- );
96
-
97
- // ---------------------------------------------------------------------------
98
- // TabsList
99
- // ---------------------------------------------------------------------------
100
-
101
- export interface TabsListProps extends React.HTMLAttributes<HTMLDivElement> {
102
- // Radix pass-through
103
- asChild?: boolean;
104
- loop?: boolean;
105
- // Legacy Chakra style-prop shims
106
- flexWrap?: string;
107
- alignItems?: string;
108
- whiteSpace?: string;
109
- bgColor?: string;
110
- marginBottom?: number | string;
111
- mx?: string | Record<string, string>;
112
- px?: string | Record<string, string>;
113
- w?: string | Record<string, string>;
114
- overflowX?: string | Record<string, string>;
115
- overscrollBehaviorX?: string;
116
- css?: Record<string, unknown>;
117
- position?: string;
118
- boxShadow?: string | Record<string, string>;
119
- top?: number | string;
120
- zIndex?: string | Record<string, string>;
121
- }
122
-
123
- export const TabsList = React.forwardRef<HTMLDivElement, TabsListProps>(
124
- function TabsList(props, ref) {
125
- const {
126
- className,
127
- // Strip Chakra style props
128
- flexWrap: _flexWrap, alignItems: _alignItems, whiteSpace: _whiteSpace,
129
- bgColor: _bgColor, marginBottom: _marginBottom, mx: _mx, px: _px,
130
- w: _w, overflowX: _overflowX, overscrollBehaviorX: _overscrollBehaviorX,
131
- css: _css, position: _position, boxShadow: _boxShadow, top: _top,
132
- zIndex: _zIndex,
133
- style: styleProp,
134
- asChild, loop,
135
- ...rest
136
- } = props;
137
-
138
- return (
139
- <RadixTabs.List
140
- ref={ ref }
141
- asChild={ asChild }
142
- loop={ loop }
143
- className={ cn(
144
- 'inline-flex w-full relative isolate flex-row',
145
- 'min-h-[var(--tabs-height,2.5rem)]',
146
- className,
147
- ) }
148
- style={ styleProp }
149
- { ...rest }
150
- />
151
- );
152
- },
153
- );
154
-
155
- // ---------------------------------------------------------------------------
156
- // TabsTrigger
157
- // ---------------------------------------------------------------------------
158
-
159
- export interface TabsTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof RadixTabs.Trigger>, 'dir'> {
160
- // Legacy Chakra style-prop shims
161
- scrollSnapAlign?: string;
162
- flexShrink?: number;
163
- bgColor?: string | Record<string, string>;
164
- w?: string;
165
- py?: string;
166
- borderRadius?: string;
167
- fontWeight?: string;
168
- color?: string;
169
- _hover?: Record<string, string>;
170
- position?: string;
171
- top?: string;
172
- left?: string;
173
- visibility?: string;
174
- }
175
-
176
- const TRIGGER_BASE =
177
- 'outline-none min-w-[var(--tabs-height,2.5rem)] h-[var(--tabs-height,2.5rem)]' +
178
- ' flex items-center relative cursor-pointer gap-2' +
179
- ' focus-visible:z-[1] focus-visible:outline-2 focus-visible:outline-offset-0' +
180
- ' disabled:cursor-not-allowed disabled:opacity-50';
181
-
182
- const TRIGGER_SIZE_CLASSES: Record<TabsSize, string> = {
183
- sm: 'py-1 px-3 text-sm',
184
- md: 'py-2 px-4 text-base',
185
- free: '',
186
- };
187
-
188
- const TRIGGER_VARIANT_CLASSES: Record<TabsVariant, string> = {
189
- solid:
190
- 'font-semibold gap-1 rounded-md bg-transparent' +
191
- ' text-tabs-solid-fg' +
192
- ' data-[state=active]:bg-selected-control-bg data-[state=active]:text-selected-control-text' +
193
- ' data-[state=active]:hover:text-selected-control-text' +
194
- ' hover:text-hover',
195
- secondary:
196
- 'font-medium bg-transparent' +
197
- ' text-tabs-secondary-fg' +
198
- ' border-2 border-solid border-tabs-secondary-border rounded-md' +
199
- ' data-[state=active]:bg-selected-control-bg data-[state=active]:text-selected-control-text' +
200
- ' data-[state=active]:border-transparent data-[state=active]:hover:border-transparent' +
201
- ' hover:text-hover hover:border-hover',
202
- segmented:
203
- 'bg-transparent' +
204
- ' text-text-primary' +
205
- ' border-2 border-solid border-selected-control-bg' +
206
- ' hover:text-hover' +
207
- ' data-[state=active]:text-selected-control-text data-[state=active]:bg-selected-control-bg' +
208
- ' data-[state=active]:border-selected-control-bg' +
209
- ' data-[state=active]:hover:text-selected-control-text',
210
- unstyled: '',
211
- };
212
-
213
- export const TabsTrigger = React.forwardRef<HTMLButtonElement, TabsTriggerProps>(
214
- function TabsTrigger(props, ref) {
215
- const {
216
- className,
217
- // Strip Chakra style props
218
- scrollSnapAlign: _scrollSnapAlign, flexShrink: _flexShrink, bgColor: _bgColor,
219
- w: _w, py: _py, borderRadius: _borderRadius, fontWeight: _fontWeight,
220
- color: _color, _hover, position: _position, top: _top, left: _left,
221
- visibility: _visibility,
222
- ...rest
223
- } = props;
224
-
225
- // Read variant / size from the closest TabsRoot via DOM data attributes.
226
- // We could use React context, but reading from data-* keeps the API surface
227
- // identical to Chakra where recipe tokens cascade automatically.
228
- const internalRef = React.useRef<HTMLButtonElement>(null);
229
- const mergedRef = useMergedRef(ref, internalRef);
230
- const { variant, size, fitted } = useTabsContext(internalRef);
231
-
232
- return (
233
- <RadixTabs.Trigger
234
- ref={ mergedRef }
235
- className={ cn(
236
- 'group',
237
- TRIGGER_BASE,
238
- TRIGGER_SIZE_CLASSES[size],
239
- TRIGGER_VARIANT_CLASSES[variant],
240
- fitted && 'flex-1 text-center justify-center',
241
- className,
242
- ) }
243
- { ...rest }
244
- />
245
- );
246
- },
247
- );
248
-
249
- // ---------------------------------------------------------------------------
250
- // TabsContent
251
- // ---------------------------------------------------------------------------
252
-
253
- export interface TabsContentProps extends React.ComponentPropsWithoutRef<typeof RadixTabs.Content> {
254
- // Legacy Chakra style-prop shims
255
- padding?: number | string;
256
- }
257
-
258
- export const TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(
259
- function TabsContent(props, ref) {
260
- const { className, padding: _padding, ...rest } = props;
261
-
262
- return (
263
- <RadixTabs.Content
264
- ref={ ref }
265
- className={ cn(
266
- 'w-full pt-[var(--tabs-content-padding,1.5rem)]',
267
- 'focus-visible:outline-2 focus-visible:outline-offset-[-2px]',
268
- className,
269
- ) }
270
- { ...rest }
271
- />
272
- );
273
- },
274
- );
275
-
276
- // ---------------------------------------------------------------------------
277
- // TabsCounter
278
- // ---------------------------------------------------------------------------
279
-
280
- export interface TabsCounterProps {
281
- count?: number | null;
282
- }
283
-
284
- const COUNTER_OVERLOAD = 50;
285
-
286
- export const TabsCounter = ({ count }: TabsCounterProps): React.ReactElement | null => {
287
- if (count === undefined || count === null) {
288
- return null;
289
- }
290
-
291
- return (
292
- <span
293
- className={ cn(
294
- 'group-hover:text-inherit',
295
- count > 0 ?
296
- 'text-text-secondary' :
297
- 'text-[rgba(16,17,18,0.24)] dark:text-[rgba(255,255,255,0.24)]',
298
- ) }
299
- >
300
- { count > COUNTER_OVERLOAD ? `${ COUNTER_OVERLOAD }+` : count }
301
- </span>
302
- );
303
- };
304
-
305
- // ---------------------------------------------------------------------------
306
- // Helpers
307
- // ---------------------------------------------------------------------------
308
-
309
- /** Read variant / size / fitted from the nearest ancestor [data-variant] element. */
310
- function useTabsContext(triggerRef: React.RefObject<HTMLButtonElement | null>): {
311
- variant: TabsVariant;
312
- size: TabsSize;
313
- fitted: boolean;
314
- } {
315
- const [ ctx, setCtx ] = React.useState<{
316
- variant: TabsVariant;
317
- size: TabsSize;
318
- fitted: boolean;
319
- }>({ variant: 'solid', size: 'md', fitted: false });
320
-
321
- React.useEffect(() => {
322
- const el = triggerRef.current;
323
- if (!el) return;
324
- const root = el.closest('[data-variant]');
325
- if (!root) return;
326
- setCtx({
327
- variant: (root.getAttribute('data-variant') as TabsVariant) ?? 'solid',
328
- size: (root.getAttribute('data-size') as TabsSize) ?? 'md',
329
- fitted: root.hasAttribute('data-fitted'),
330
- });
331
- }, [ triggerRef ]);
332
-
333
- return ctx;
334
- }
335
-
336
- /** Merge multiple refs into one callback ref. */
337
- function useMergedRef<T>(
338
- ...refs: Array<React.Ref<T> | undefined>
339
- ): React.RefCallback<T> {
340
- return React.useCallback(
341
- (instance: T | null) => {
342
- for (const ref of refs) {
343
- if (!ref) continue;
344
- if (typeof ref === 'function') {
345
- ref(instance);
346
- } else {
347
- (ref as React.MutableRefObject<T | null>).current = instance;
348
- }
349
- }
350
- },
351
- // eslint-disable-next-line react-hooks/exhaustive-deps
352
- refs,
353
- );
354
- }
package/src/tag.tsx DELETED
@@ -1,159 +0,0 @@
1
- import { cva } from 'class-variance-authority';
2
- import * as React from 'react';
3
-
4
- import { cn } from './utils';
5
-
6
- import { CloseButton } from './close-button';
7
- import { Skeleton } from './skeleton';
8
- import { Tooltip } from './tooltip';
9
-
10
- // Inline constants
11
- const nbsp = String.fromCharCode(160);
12
-
13
- // Inline truncation tooltip
14
- function TruncatedTextTooltip({ label, children }: { readonly label: React.ReactNode; readonly children: React.ReactNode }) {
15
- return (
16
- <Tooltip content={ label } positioning={{ placement: 'top' }}>
17
- { children }
18
- </Tooltip>
19
- );
20
- }
21
-
22
- type TagVariant = 'subtle' | 'clickable' | 'filter' | 'select';
23
- type TagSize = 'sm' | 'md' | 'lg';
24
-
25
- const tagVariants = cva(
26
- [
27
- 'inline-flex items-center align-top max-w-full select-text rounded-sm',
28
- 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500',
29
- ].join(' '),
30
- {
31
- variants: {
32
- variant: {
33
- subtle: 'bg-[var(--color-tag-subtle-bg)] text-[var(--color-tag-subtle-fg)]',
34
- clickable: [
35
- 'cursor-pointer',
36
- 'bg-[var(--color-tag-clickable-bg)] text-[var(--color-tag-clickable-fg)]',
37
- 'hover:opacity-76',
38
- ].join(' '),
39
- filter: 'bg-[var(--color-tag-filter-bg)]',
40
- select: [
41
- 'cursor-pointer',
42
- 'bg-[var(--color-tag-select-bg)] text-[var(--color-tag-select-fg)]',
43
- 'hover:text-[var(--color-hover)] hover:opacity-76',
44
- ].join(' '),
45
- },
46
- size: {
47
- sm: 'px-1 py-0.5 min-h-5 gap-1 text-xs',
48
- md: 'px-1 py-0.5 min-h-6 gap-1 text-sm',
49
- lg: 'px-1.5 py-1.5 min-h-8 min-w-8 gap-1 text-sm',
50
- },
51
- },
52
- defaultVariants: {
53
- variant: 'subtle',
54
- size: 'md',
55
- },
56
- },
57
- );
58
-
59
- const TAG_SELECTED_CLASSES = [
60
- 'bg-[var(--color-tag-select-selected-bg)]',
61
- 'text-[var(--color-tag-select-selected-fg)]',
62
- 'hover:text-[var(--color-tag-select-selected-fg)]',
63
- 'hover:opacity-76',
64
- ].join(' ');
65
-
66
- const TAG_DISABLED_CLASSES = 'opacity-40 pointer-events-none cursor-not-allowed';
67
-
68
- export interface TagProps extends Omit<React.ComponentPropsWithRef<'span'>, 'size'> {
69
- readonly variant?: TagVariant;
70
- readonly size?: TagSize;
71
- readonly startElement?: React.ReactNode;
72
- readonly endElement?: React.ReactNode;
73
- readonly endElementProps?: React.HTMLAttributes<HTMLSpanElement>;
74
- readonly label?: string;
75
- readonly onClose?: VoidFunction;
76
- readonly closable?: boolean;
77
- readonly truncated?: boolean;
78
- readonly loading?: boolean;
79
- readonly selected?: boolean;
80
- readonly disabled?: boolean;
81
- }
82
-
83
- export const Tag = React.forwardRef<HTMLSpanElement, TagProps>(
84
- function Tag(props, ref) {
85
- const {
86
- variant,
87
- size,
88
- startElement,
89
- endElement,
90
- endElementProps,
91
- label,
92
- onClose,
93
- closable = Boolean(onClose),
94
- children,
95
- truncated = false,
96
- loading,
97
- selected,
98
- disabled,
99
- className,
100
- ...rest
101
- } = props;
102
-
103
- const labelElement = label ? (
104
- <span className="text-[var(--color-text-secondary)]">{ label }:{ nbsp }</span>
105
- ) : null;
106
-
107
- const labelSpan = (
108
- <span className="line-clamp-1 whitespace-nowrap text-ellipsis font-medium inline">
109
- { labelElement }{ children }
110
- </span>
111
- );
112
-
113
- const contentElement = truncated ? (
114
- <TruncatedTextTooltip label={ children }>
115
- { labelSpan }
116
- </TruncatedTextTooltip>
117
- ) : labelSpan;
118
-
119
- return (
120
- <Skeleton loading={ loading } asChild>
121
- <span
122
- ref={ ref }
123
- className={ cn(
124
- tagVariants({ variant, size }),
125
- selected && !loading && TAG_SELECTED_CLASSES,
126
- disabled && TAG_DISABLED_CLASSES,
127
- className,
128
- ) }
129
- { ...(selected && !loading && { 'data-selected': true }) }
130
- { ...(disabled && { 'data-disabled': true }) }
131
- { ...rest }
132
- >
133
- { startElement && (
134
- <span className="shrink-0 inline-flex items-center justify-center empty:hidden">
135
- { startElement }
136
- </span>
137
- ) }
138
- { contentElement }
139
- { endElement && (
140
- <span
141
- { ...endElementProps }
142
- className={ cn(
143
- 'shrink-0 inline-flex items-center justify-center',
144
- endElementProps?.className,
145
- ) }
146
- >
147
- { endElement }
148
- </span>
149
- ) }
150
- { closable && (
151
- <span className="shrink-0 inline-flex items-center justify-center">
152
- <CloseButton onClick={ onClose }/>
153
- </span>
154
- ) }
155
- </span>
156
- </Skeleton>
157
- );
158
- },
159
- );
package/src/textarea.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 textareaVariants = cva(
7
- [
8
- 'w-full appearance-none outline-none transition-colors resize-y',
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: 'px-2 py-1 text-xs rounded',
22
- sm: 'px-3 py-2 text-sm rounded-md',
23
- md: 'px-4 py-2 text-base rounded-md',
24
- lg: 'px-4 py-3 text-lg rounded-lg',
25
- '2xl': 'px-4 py-3 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',
31
- },
32
- },
33
- defaultVariants: {
34
- size: 'md',
35
- variant: 'outline',
36
- },
37
- },
38
- );
39
-
40
- type TextareaSize = 'xs' | 'sm' | 'md' | 'lg' | '2xl';
41
- type TextareaVariant = 'outline' | 'filled' | 'unstyled';
42
-
43
- export interface TextareaProps extends Omit<React.ComponentPropsWithRef<'textarea'>, 'size'> {
44
- readonly size?: TextareaSize;
45
- readonly variant?: TextareaVariant;
46
- }
47
-
48
- export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
49
- ({ size, variant, className, ...rest }, ref) => {
50
- return (
51
- <textarea
52
- ref={ ref }
53
- className={ cn(textareaVariants({ size, variant }), className) }
54
- { ...rest }
55
- />
56
- );
57
- },
58
- );
59
-
60
- Textarea.displayName = 'Textarea';
package/src/toaster.tsx DELETED
@@ -1,117 +0,0 @@
1
- 'use client';
2
-
3
- import type React from 'react';
4
- import { Toaster as SonnerToaster, toast } from 'sonner';
5
-
6
- const SECOND = 1_000;
7
- const DURATION = 10 * SECOND;
8
-
9
- interface ToastOptions {
10
- readonly id?: string | number;
11
- readonly title?: string;
12
- readonly description?: string;
13
- readonly type?: 'info' | 'warning' | 'success' | 'error' | 'loading';
14
- readonly duration?: number;
15
- readonly action?: { readonly label: string; readonly onClick: () => void };
16
- readonly onStatusChange?: (details: { readonly status: string }) => void;
17
- }
18
-
19
- function mapOptions(opts: ToastOptions): Parameters<typeof toast>[1] {
20
- const external: Parameters<typeof toast>[1] = {
21
- id: opts.id,
22
- description: opts.description,
23
- duration: opts.duration,
24
- };
25
-
26
- if (opts.action) {
27
- external.action = {
28
- label: opts.action.label,
29
- onClick: opts.action.onClick,
30
- };
31
- }
32
-
33
- if (opts.onStatusChange) {
34
- const cb = opts.onStatusChange;
35
- external.onDismiss = () => cb({ status: 'unmounted' });
36
- external.onAutoClose = () => cb({ status: 'unmounted' });
37
- }
38
-
39
- return external;
40
- }
41
-
42
- function create(opts: ToastOptions): string | number {
43
- const external = mapOptions(opts);
44
- const title = opts.title ?? '';
45
-
46
- switch (opts.type) {
47
- case 'success':
48
- return toast.success(title, external);
49
- case 'error':
50
- return toast.error(title, external);
51
- case 'warning':
52
- return toast.warning(title, external);
53
- case 'loading':
54
- return toast.loading(title, external);
55
- case 'info':
56
- default:
57
- return toast.info(title, external);
58
- }
59
- }
60
-
61
- function update(id: string | number, opts: ToastOptions): void {
62
- const title = opts.title ?? '';
63
-
64
- // Sonner does not have a dedicated update method.
65
- // Re-calling a typed toast with the same id replaces it in-place.
66
- const external = mapOptions({ ...opts, id });
67
-
68
- switch (opts.type) {
69
- case 'success':
70
- toast.success(title, external);
71
- break;
72
- case 'error':
73
- toast.error(title, external);
74
- break;
75
- case 'warning':
76
- toast.warning(title, external);
77
- break;
78
- case 'loading':
79
- toast.loading(title, external);
80
- break;
81
- case 'info':
82
- default:
83
- toast.info(title, external);
84
- break;
85
- }
86
- }
87
-
88
- export const toaster = {
89
- create,
90
- success: (opts: ToastOptions) => create({ ...opts, type: 'success' }),
91
- error: (opts: ToastOptions) => create({ ...opts, type: 'error' }),
92
- loading: (opts: ToastOptions) => create({ ...opts, type: 'loading' }),
93
- update,
94
- remove: (id: string | number) => toast.dismiss(id),
95
- } as const;
96
-
97
- export const Toaster: React.FC = () => {
98
- return (
99
- <SonnerToaster
100
- position="top-right"
101
- richColors
102
- closeButton
103
- duration={ DURATION }
104
- offset={{ top: 12, right: 12, bottom: 12, left: 12 }}
105
- mobileOffset={{ top: 16, right: 16, bottom: 16, left: 16 }}
106
- toastOptions={{
107
- className: 'font-sans',
108
- style: {
109
- fontFamily: 'var(--font-sans, "Geist", sans-serif)',
110
- color: 'var(--color-text-primary)',
111
- backgroundColor: 'var(--color-bg-primary)',
112
- borderColor: 'var(--color-border-divider)',
113
- },
114
- }}
115
- />
116
- );
117
- };