@flikk/ui 1.0.0-beta.12 → 1.0.0-beta.14

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 (118) hide show
  1. package/dist/components/ai/PromptInput/PromptInput.js +1 -1
  2. package/dist/components/ai/PromptInput/VoiceRecorder.js +1 -1
  3. package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.js +1 -1
  4. package/dist/components/ai/StreamingResponse/StreamingResponse.types.d.ts +7 -7
  5. package/dist/components/charts/FunnelChart/FunnelChart.js +2 -2
  6. package/dist/components/core/Accordion/Accordion.types.d.ts +1 -7
  7. package/dist/components/core/Accordion/AccordionTrigger.js +4 -6
  8. package/dist/components/core/Alert/Alert.types.d.ts +1 -1
  9. package/dist/components/core/Avatar/Avatar.js +22 -18
  10. package/dist/components/core/Avatar/Avatar.theme.js +1 -1
  11. package/dist/components/core/Avatar/Avatar.types.d.ts +9 -8
  12. package/dist/components/core/AvatarGroup/AvatarGroup.js +2 -2
  13. package/dist/components/core/Badge/Badge.js +10 -8
  14. package/dist/components/core/Badge/Badge.theme.js +14 -7
  15. package/dist/components/core/Badge/Badge.types.d.ts +3 -3
  16. package/dist/components/core/Button/Button.ripple.js +1 -1
  17. package/dist/components/core/Button/Button.theme.d.ts +1 -1
  18. package/dist/components/core/Button/Button.theme.js +5 -5
  19. package/dist/components/core/Button/Button.types.d.ts +1 -1
  20. package/dist/components/core/Calendar/CalendarEvent/CalendarEvent.types.d.ts +5 -6
  21. package/dist/components/core/Calendar/CalendarMini/CalendarMini.js +2 -2
  22. package/dist/components/core/Drawer/DrawerHeader.js +1 -1
  23. package/dist/components/core/FileTypeIcon/FileTypeIcon.d.ts +3 -0
  24. package/dist/components/core/FileTypeIcon/FileTypeIcon.js +33 -0
  25. package/dist/components/core/FileTypeIcon/FileTypeIcon.theme.d.ts +2 -0
  26. package/dist/components/core/FileTypeIcon/FileTypeIcon.theme.js +12 -0
  27. package/dist/components/core/FileTypeIcon/FileTypeIcon.types.d.ts +19 -0
  28. package/dist/components/core/FileTypeIcon/fileTypes.d.ts +7 -0
  29. package/dist/components/core/FileTypeIcon/fileTypes.js +30 -0
  30. package/dist/components/core/FileTypeIcon/index.d.ts +2 -0
  31. package/dist/components/core/Link/Link.js +1 -1
  32. package/dist/components/core/MenuItem/MenuItem.theme.js +1 -1
  33. package/dist/components/core/Message/Message.js +1 -1
  34. package/dist/components/core/Message/Message.theme.js +2 -2
  35. package/dist/components/core/Message/Message.types.d.ts +6 -6
  36. package/dist/components/core/Message/MessageAvatar.d.ts +2 -2
  37. package/dist/components/core/Message/MessageAvatar.js +3 -3
  38. package/dist/components/core/Modal/ModalHeader.js +1 -1
  39. package/dist/components/core/NavItem/NavItem.js +100 -52
  40. package/dist/components/core/NavItem/NavItem.theme.js +6 -3
  41. package/dist/components/core/NavItem/NavItem.types.d.ts +44 -30
  42. package/dist/components/core/NavItem/index.d.ts +1 -1
  43. package/dist/components/core/Pill/Pill.theme.js +1 -1
  44. package/dist/components/core/Popover/PopoverBody.js +19 -8
  45. package/dist/components/core/Sidebar/Sidebar.d.ts +11 -1
  46. package/dist/components/core/Sidebar/Sidebar.js +49 -16
  47. package/dist/components/core/Sidebar/Sidebar.theme.js +9 -7
  48. package/dist/components/core/Sidebar/Sidebar.types.d.ts +57 -0
  49. package/dist/components/core/Sidebar/SidebarContent.js +3 -1
  50. package/dist/components/core/Sidebar/SidebarContext.d.ts +14 -0
  51. package/dist/components/core/Sidebar/SidebarContext.js +63 -11
  52. package/dist/components/core/Sidebar/SidebarFooter.js +3 -1
  53. package/dist/components/core/Sidebar/SidebarHeader.js +6 -2
  54. package/dist/components/core/Sidebar/SidebarMobileTrigger.d.ts +3 -0
  55. package/dist/components/core/Sidebar/SidebarMobileTrigger.js +28 -0
  56. package/dist/components/core/Sidebar/SidebarNav.js +3 -2
  57. package/dist/components/core/Sidebar/SidebarNavGroup.js +4 -2
  58. package/dist/components/core/Sidebar/SidebarToggle.js +1 -1
  59. package/dist/components/core/Sidebar/SidebarUserProfile.d.ts +3 -0
  60. package/dist/components/core/Sidebar/SidebarUserProfile.js +35 -0
  61. package/dist/components/core/Sidebar/index.d.ts +3 -1
  62. package/dist/components/core/Tabs/Tabs.theme.d.ts +1 -1
  63. package/dist/components/core/Tabs/Tabs.theme.js +3 -3
  64. package/dist/components/core/Tag/Tag.d.ts +1 -1
  65. package/dist/components/core/Tag/Tag.js +2 -2
  66. package/dist/components/core/Tag/Tag.types.d.ts +1 -1
  67. package/dist/components/core/index.d.ts +1 -1
  68. package/dist/components/core/index.js +3 -1
  69. package/dist/components/data-display/Feed/Feed.animations.d.ts +40 -0
  70. package/dist/components/data-display/Feed/Feed.animations.js +26 -0
  71. package/dist/components/data-display/Feed/Feed.d.ts +5 -1
  72. package/dist/components/data-display/Feed/Feed.js +87 -60
  73. package/dist/components/data-display/Feed/Feed.theme.js +11 -13
  74. package/dist/components/data-display/Feed/Feed.types.d.ts +35 -34
  75. package/dist/components/data-display/Feed/index.d.ts +1 -1
  76. package/dist/components/data-display/GanttChart/GanttTaskBar.js +11 -9
  77. package/dist/components/data-display/GanttChart/GanttToolbar.js +1 -1
  78. package/dist/components/data-display/Timeline/TimelineMarker.js +2 -2
  79. package/dist/components/effects/3d/index.d.ts +1 -1
  80. package/dist/components/effects/AIOrb/AIOrb.d.ts +1 -0
  81. package/dist/components/effects/AIOrb/AIOrb.js +3 -2
  82. package/dist/components/effects/AIOrb/AIOrb.types.d.ts +1 -0
  83. package/dist/components/effects/AIOrb/hooks/index.d.ts +2 -0
  84. package/dist/components/effects/AIOrb/hooks/useOrbState.d.ts +20 -0
  85. package/dist/components/effects/AIOrb/hooks/useOrbState.js +27 -0
  86. package/dist/components/effects/AIOrb/index.d.ts +2 -2
  87. package/dist/components/effects/AIOrb/variants/Aura/Aura.d.ts +3 -0
  88. package/dist/components/effects/AIOrb/variants/Aura/Aura.js +75 -0
  89. package/dist/components/effects/AIOrb/variants/Aura/Aura.shaders.d.ts +28 -0
  90. package/dist/components/effects/AIOrb/variants/Aura/Aura.shaders.js +191 -0
  91. package/dist/components/effects/AIOrb/variants/Aura/Aura.types.d.ts +53 -0
  92. package/dist/components/effects/AIOrb/variants/Aura/ShaderCanvas.d.ts +17 -0
  93. package/dist/components/effects/AIOrb/variants/Aura/ShaderCanvas.js +149 -0
  94. package/dist/components/effects/AIOrb/variants/Aura/index.d.ts +2 -0
  95. package/dist/components/effects/AIOrb/variants/DotSphere/DotSphere.js +38 -7
  96. package/dist/components/effects/AIOrb/variants/DotSphere/DotSphere.types.d.ts +6 -0
  97. package/dist/components/effects/AIOrb/variants/Liquid/Liquid.js +34 -8
  98. package/dist/components/effects/AIOrb/variants/Liquid/Liquid.types.d.ts +6 -0
  99. package/dist/components/effects/AIOrb/variants/index.d.ts +2 -0
  100. package/dist/components/effects/CustomCursor/CustomCursor.d.ts +2 -2
  101. package/dist/components/effects/CustomCursor/CustomCursor.js +50 -47
  102. package/dist/components/effects/GlassSurface/GlassSurface.js +24 -12
  103. package/dist/components/effects/GlassSurface/GlassSurface.types.d.ts +8 -0
  104. package/dist/components/forms/Mention/Mention.js +2 -2
  105. package/dist/components/forms/RichTextEditor/RichTextEditor.js +10 -10
  106. package/dist/index.js +3 -1
  107. package/dist/styles.css +1 -1
  108. package/dist/utils/index.d.ts +1 -0
  109. package/dist/utils/paletteGenerator.d.ts +46 -0
  110. package/package.json +1 -1
  111. package/src/global.scss +1 -0
  112. package/src/styles/theme.css +50 -54
  113. package/dist/components/core/Loader/Loader.d.ts +0 -24
  114. package/dist/components/core/Loader/Loader.js +0 -57
  115. package/dist/components/core/Loader/Loader.theme.d.ts +0 -27
  116. package/dist/components/core/Loader/Loader.theme.js +0 -60
  117. package/dist/components/core/Loader/Loader.types.d.ts +0 -71
  118. package/dist/components/core/Loader/index.d.ts +0 -2
@@ -14,3 +14,4 @@ export * from "./formValidation";
14
14
  export { calculateVelocity, clampScroll, detectScrollDirection, isReducedMotion, lerp, calculateScrollProgress, normalizeWheelDelta, isScrollable, getMaxScroll, throttle, } from './smoothScrollUtils';
15
15
  export { PerformanceMonitor, usePerformanceMonitor } from './performanceMonitor';
16
16
  export { type SemanticColor, semanticBgColors, semanticTextColors, semanticSpinnerColors, } from './colorUtils';
17
+ export { generatePalette, generateThemeCSS, type PaletteStep, type GeneratedPalette, type GeneratePaletteOptions, } from './paletteGenerator';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Palette Generator Utility
3
+ *
4
+ * Converts a hex color to an 11-step OKLCH palette using
5
+ * Tailwind-matched lightness/chroma curves. The hue is extracted
6
+ * from the input color and applied across all steps.
7
+ */
8
+ export interface PaletteStep {
9
+ /** Tailwind step number: 50, 100, 200 ... 950 */
10
+ step: number;
11
+ /** OKLCH CSS string, e.g. "oklch(0.9778 0.0108 270)" */
12
+ oklch: string;
13
+ /** Approximate sRGB hex for preview swatches */
14
+ hex: string;
15
+ }
16
+ export interface GeneratedPalette {
17
+ /** Semantic name, e.g. "primary" */
18
+ name: string;
19
+ /** Extracted OKLCH hue (degrees) */
20
+ hue: number;
21
+ /** 11 palette steps from 50 to 950 */
22
+ steps: PaletteStep[];
23
+ /** Auto-calculated contrast color (hex) for text on the base step */
24
+ contrast: 'light' | 'dark';
25
+ }
26
+ export interface GeneratePaletteOptions {
27
+ /** Scales chroma up/down. Default 1.0 */
28
+ vibrancy?: number;
29
+ }
30
+ /**
31
+ * Generate an 11-step OKLCH palette from a single hex color.
32
+ * Extracts the hue from the input and applies Tailwind-matched
33
+ * lightness and chroma curves.
34
+ */
35
+ export declare function generatePalette(hex: string, name?: string, options?: GeneratePaletteOptions): GeneratedPalette | null;
36
+ /**
37
+ * Generate a complete CSS variable block for all semantic colors.
38
+ *
39
+ * @param palettes - Map of semantic name → hex color
40
+ * @param options - Generation options (vibrancy)
41
+ * @returns Object with `theme` (for @theme block) and `root` (for :root block) CSS strings
42
+ */
43
+ export declare function generateThemeCSS(palettes: Record<string, string>, options?: GeneratePaletteOptions): {
44
+ theme: string;
45
+ root: string;
46
+ } | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flikk/ui",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.14",
4
4
  "description": "A modern React component library built with TypeScript, Tailwind CSS v4, and Framer Motion. Follows the shadcn philosophy with complete className override support.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/global.scss CHANGED
@@ -579,6 +579,7 @@
579
579
  html,
580
580
  body {
581
581
  font-family: var(--font-family-base);
582
+ font-size: 14px;
582
583
  -webkit-font-smoothing: antialiased;
583
584
  -moz-osx-font-smoothing: grayscale;
584
585
  }
@@ -81,7 +81,7 @@
81
81
 
82
82
  /* text color */
83
83
  --color-text-primary: var(--color-neutral-950);
84
- --color-text-secondary: var(--color-neutral-800);
84
+ --color-text-secondary: var(--color-neutral-700);
85
85
  --color-text-placeholder: var(--color-neutral-400);
86
86
  --color-text-muted: var(--color-neutral-500);
87
87
  --color-text-disabled: var(--color-neutral-400);
@@ -112,7 +112,7 @@
112
112
  --color-neutral-950: oklch(14.5% 0 0);
113
113
 
114
114
  /* Font family variables */
115
- --font-family-base: "Geist", sans-serif;
115
+ --font-family-base: var(--font-sans);
116
116
  --font-cursive: "Birthstone", cursive;
117
117
  --font-weight-light: 300;
118
118
  --font-weight-normal: 400;
@@ -121,28 +121,27 @@
121
121
  --font-weight-bold: 700;
122
122
  --font-weight-extrabold: 800;
123
123
 
124
- /* Form element variables with explicit values that match Tailwind's scale */
125
- --form-min-h-sm: 2rem; /* 32px = h-8 in Tailwind */
126
- --form-min-h-md: 2.5rem; /* 40px = h-10 in Tailwind */
127
- --form-min-h-lg: 3rem; /* 48px = h-12 in Tailwind */
124
+ /* Form element variables fixed px so they don't scale with root font-size */
125
+ --form-min-h-sm: 32px; /* h-8 in Tailwind */
126
+ --form-min-h-md: 40px; /* h-10 in Tailwind */
127
+ --form-min-h-lg: 48px; /* h-12 in Tailwind */
128
128
 
129
- --form-label-pb: 0.5rem; /* 8px = pb-2 in Tailwind */
129
+ --form-label-pb: 8px; /* pb-2 in Tailwind */
130
130
 
131
- --form-px-sm: 0.75rem; /* 12px = px-3 in Tailwind */
132
- --form-px-md: 0.875rem; /* 14px = px-3.5 in Tailwind */
133
- --form-px-lg: 1rem; /* 16px = px-4 in Tailwind */
134
-
135
- --form-py-sm: 0.5rem; /* 0.5rem 8px = py-1 in Tailwind */
136
- --form-py-md: 0.625rem; /* 0.625rem 10px = py-2 in Tailwind */
137
- --form-py-lg: 0.75rem; /* 0.75rem 12px = py-3 in Tailwind */
131
+ --form-px-sm: 12px; /* px-3 in Tailwind */
132
+ --form-px-md: 14px; /* px-3.5 in Tailwind */
133
+ --form-px-lg: 16px; /* px-4 in Tailwind */
138
134
 
135
+ --form-py-sm: 8px; /* py-1 in Tailwind */
136
+ --form-py-md: 10px; /* py-2 in Tailwind */
137
+ --form-py-lg: 12px; /* py-3 in Tailwind */
139
138
 
140
139
  /* ============================================
141
140
  BORDER RADIUS SYSTEM
142
141
  Change --radius-base to adjust the entire UI.
143
142
  Individual --*-radius variables can be overridden independently.
144
143
  ============================================ */
145
- --radius-base: 0.5rem; /* 8px - Base radius token */
144
+ --radius-base: 8px; /* Base radius token */
146
145
 
147
146
  /* Forms & Controls (1x base = 8px) */
148
147
  --form-radius: var(--radius-base);
@@ -160,8 +159,8 @@
160
159
  --metric-radius: calc(var(--radius-base) * 2);
161
160
 
162
161
  /* Surfaces (3x base = 24px) */
163
- --card-radius: calc(var(--radius-base) * 3);
164
- --modal-radius: calc(var(--radius-base) * 3);
162
+ --card-radius: calc(var(--radius-base) * 2);
163
+ --modal-radius: calc(var(--radius-base) * 2);
165
164
 
166
165
  /* Special shapes - not part of scale */
167
166
  --segmented-radius: var(--form-radius);
@@ -182,25 +181,24 @@
182
181
  --button-min-h-md: var(--form-min-h-md);
183
182
  --button-min-h-lg: var(--form-min-h-lg);
184
183
 
185
- /* Button padding */
186
- --button-px-sm: 0.75rem; /* 12px */
187
- --button-py-sm: 0; /* 6px */
188
- --button-px-md: 0.875rem; /* 14px */
189
- --button-py-md: 0; /* 10px */
190
- --button-px-lg: 1.25rem; /* 20px */
191
- --button-py-lg: 0; /* 12px */
184
+ /* Button padding — fixed px */
185
+ --button-px-sm: 12px;
186
+ --button-py-sm: 0;
187
+ --button-px-md: 14px;
188
+ --button-py-md: 0;
189
+ --button-px-lg: 20px;
190
+ --button-py-lg: 0;
192
191
 
193
- /* Button icon-only padding */
194
- --button-icon-p-sm: 0.375rem; /* 6px */
195
- --button-icon-p-md: 0.5rem; /* 8px */
196
- --button-icon-p-lg: 0.625rem; /* 10px */
192
+ /* Button icon-only padding — fixed px */
193
+ --button-icon-p-sm: 6px;
194
+ --button-icon-p-md: 8px;
195
+ --button-icon-p-lg: 10px;
197
196
 
198
197
  /* Button icon-only sizes */
199
198
  --button-icon-size-sm: var(--form-min-h-sm);
200
199
  --button-icon-size-md: var(--form-min-h-md);
201
200
  --button-icon-size-lg: var(--form-min-h-lg);
202
201
 
203
-
204
202
  /* Badge variables */
205
203
  --badge-radius: var(--form-radius);
206
204
 
@@ -218,7 +216,6 @@
218
216
  --segmented-py-md: var(--form-py-md);
219
217
  --segmented-py-lg: var(--form-py-lg);
220
218
 
221
-
222
219
  /* Segmented sliding background */
223
220
  --segmented-active-bg: #ffffff;
224
221
  --segmented-active-shadow:
@@ -247,13 +244,12 @@
247
244
  --chat-bubble-border-sender: rgba(255, 255, 255, 0.4);
248
245
  --chat-bubble-border-receiver: rgba(255, 255, 255, 1);
249
246
 
250
- /* Avatar variables */
251
- --avatar-size-xs: 1.5rem; /* 24px = size-6 in Tailwind */
252
- --avatar-size-sm: 2rem; /* 32px = size-8 in Tailwind */
253
- --avatar-size-md: 2.5rem; /* 40px = size-10 in Tailwind */
254
- --avatar-size-lg: 3rem; /* 48px = size-12 in Tailwind */
255
- --avatar-size-xl: 4rem; /* 64px = size-16 in Tailwind */
256
-
247
+ /* Avatar variables — fixed px */
248
+ --avatar-size-xs: 24px; /* size-6 in Tailwind */
249
+ --avatar-size-sm: 32px; /* size-8 in Tailwind */
250
+ --avatar-size-md: 40px; /* size-10 in Tailwind */
251
+ --avatar-size-lg: 48px; /* size-12 in Tailwind */
252
+ --avatar-size-xl: 64px; /* size-16 in Tailwind */
257
253
 
258
254
  /* Avatar radius - now defined in radius system above */
259
255
 
@@ -261,32 +257,32 @@
261
257
  --carousel-container-width: 100%; /* Full width container */
262
258
  --carousel-slide-width: 66vw; /* Default slide width - can be overridden */
263
259
  --carousel-slide-height: 44rem; /* 384px = h-96 */
264
- --carousel-slide-gap: 1rem; /* 16px gap between slides */
265
- --carousel-controls-size: 3rem; /* 48px control button size */
266
- --carousel-controls-offset: 1rem; /* Distance from edge */
260
+ --carousel-slide-gap: 16px; /* gap between slides */
261
+ --carousel-controls-size: 48px; /* control button size */
262
+ --carousel-controls-offset: 16px; /* distance from edge */
267
263
 
268
264
  /* Popover variables - radius now defined in radius system above */
269
265
  --popover-shadow:
270
266
  0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
271
267
  --popover-border-width: 1px;
272
268
  --popover-backdrop-opacity: 0.5;
273
- --popover-offset-sm: 0.5rem;
274
- --popover-offset-md: 0.5rem;
275
- --popover-offset-lg: 0.75rem;
276
- --popover-max-width-sm: 16rem;
277
- --popover-max-width-md: 24rem;
278
- --popover-max-width-lg: 32rem;
279
- --popover-padding-sm: 0.75rem;
280
- --popover-padding-md: 0.75rem;
281
- --popover-padding-lg: 1rem;
269
+ --popover-offset-sm: 8px;
270
+ --popover-offset-md: 8px;
271
+ --popover-offset-lg: 12px;
272
+ --popover-max-width-sm: 256px;
273
+ --popover-max-width-md: 384px;
274
+ --popover-max-width-lg: 512px;
275
+ --popover-padding-sm: 12px;
276
+ --popover-padding-md: 12px;
277
+ --popover-padding-lg: 16px;
282
278
 
283
279
  /* NavItem variables */
284
280
  --nav-item-radius: var(--radius-base);
285
- --nav-item-min-h: 2.5rem; /* 40px = h-10 in Tailwind */
281
+ --nav-item-min-h: 40px; /* h-10 in Tailwind */
286
282
 
287
- /* NavItem padding */
288
- --nav-item-px: 0.75rem; /* 12px = px-3 in Tailwind */
289
- --nav-item-py: 0.625rem; /* 10px = py-2.5 in Tailwind */
283
+ /* NavItem padding — fixed px */
284
+ --nav-item-px: 12px; /* px-3 in Tailwind */
285
+ --nav-item-py: 10px; /* py-2.5 in Tailwind */
290
286
 
291
287
  /* Modal and Drawer */
292
288
  --overlay-bg: rgba(0, 0, 0, 0.65);
@@ -325,7 +321,7 @@
325
321
  --color-text-inverse: var(--color-neutral-950);
326
322
 
327
323
  /* Base theme colors */
328
- --color-primary: var(--color-primary-400);
324
+ --color-primary: var(--color-primary-600);
329
325
  --color-success: var(--color-success-400);
330
326
  --color-warning: var(--color-warning-400);
331
327
  --color-danger: var(--color-danger-400);
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { LoaderProps } from './Loader.types';
3
- /**
4
- * Loader component - Supports both circular (spinner) and linear (progress bar) variants
5
- *
6
- * Features:
7
- * - Circular variant: Spinning loader for indeterminate loading
8
- * - Linear variant: Progress bar with determinate (value) or indeterminate modes
9
- * - Multiple sizes and semantic colors
10
- * - Optional percentage/label display for linear variant
11
- * - Full theme customization
12
- *
13
- * @example
14
- * // Circular loader
15
- * <Loader variant="circular" size="md" />
16
- *
17
- * // Linear progress bar (determinate)
18
- * <Loader variant="linear" value={60} showLabel />
19
- *
20
- * // Linear loading bar (indeterminate)
21
- * <Loader variant="linear" />
22
- */
23
- declare const Loader: React.ForwardRefExoticComponent<LoaderProps & React.RefAttributes<HTMLDivElement>>;
24
- export { Loader };
@@ -1,57 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import React__default, { useMemo } from 'react';
3
- import { loaderTheme } from './Loader.theme.js';
4
- import { cn } from '../../../utils/cn.js';
5
-
6
- /**
7
- * Loader component - Supports both circular (spinner) and linear (progress bar) variants
8
- *
9
- * Features:
10
- * - Circular variant: Spinning loader for indeterminate loading
11
- * - Linear variant: Progress bar with determinate (value) or indeterminate modes
12
- * - Multiple sizes and semantic colors
13
- * - Optional percentage/label display for linear variant
14
- * - Full theme customization
15
- *
16
- * @example
17
- * // Circular loader
18
- * <Loader variant="circular" size="md" />
19
- *
20
- * // Linear progress bar (determinate)
21
- * <Loader variant="linear" value={60} showLabel />
22
- *
23
- * // Linear loading bar (indeterminate)
24
- * <Loader variant="linear" />
25
- */
26
- const Loader = React__default.forwardRef(({ variant = 'circular', size = 'md', color = 'primary', value, max = 100, showLabel = false, label, className, theme: customTheme, ...props }, ref) => {
27
- var _a, _b;
28
- // Merge custom theme with default theme
29
- const theme = useMemo(() => customTheme ? { ...loaderTheme, ...customTheme } : loaderTheme, [customTheme]);
30
- // Calculate percentage for linear variant
31
- const percentage = useMemo(() => {
32
- if (value === undefined || value === null)
33
- return 0;
34
- const pct = Math.min(Math.max((value / max) * 100, 0), 100);
35
- return Math.round(pct);
36
- }, [value, max]);
37
- // Determine if this is indeterminate mode (no value provided)
38
- const isIndeterminate = value === undefined || value === null;
39
- // Get theme values for current size and color
40
- const sizeStyles = ((_a = theme.sizes) === null || _a === void 0 ? void 0 : _a[size]) || theme.sizes['md'];
41
- const colorStyles = ((_b = theme.colors) === null || _b === void 0 ? void 0 : _b[color]) || theme.colors['primary'];
42
- // Render circular variant (spinner)
43
- if (variant === 'circular') {
44
- return (jsx("div", { ref: ref, className: cn(theme.baseStyle, className), role: "status", "aria-label": "loading", ...props, children: jsx("div", { className: cn(theme.circularStyle, theme.animation, sizeStyles === null || sizeStyles === void 0 ? void 0 : sizeStyles.circular, colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.circular) }) }));
45
- }
46
- // Render linear variant (progress bar)
47
- return (jsxs("div", { ref: ref, className: cn(theme.linearContainerStyle, className), role: "progressbar", "aria-valuemin": 0, "aria-valuemax": max, "aria-valuenow": isIndeterminate ? undefined : value, "aria-label": isIndeterminate ? "loading" : `${percentage}% complete`, ...props, children: [jsx("div", { className: cn(theme.linearTrackStyle, sizeStyles === null || sizeStyles === void 0 ? void 0 : sizeStyles.linear), children: isIndeterminate ? (
48
- // Indeterminate loading animation
49
- jsx("div", { className: cn(theme.linearBarStyle, colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.linear, "w-1/3 animate-[shimmer_2s_ease-in-out_infinite]"), style: {
50
- backgroundImage: `linear-gradient(90deg, transparent, currentColor, transparent)`,
51
- } })) : (
52
- // Determinate progress bar
53
- jsx("div", { className: cn(theme.linearBarStyle, colorStyles === null || colorStyles === void 0 ? void 0 : colorStyles.linear), style: { width: `${percentage}%` } })) }), showLabel && !isIndeterminate && (jsx("span", { className: theme.linearLabelStyle, children: label || `${percentage}%` }))] }));
54
- });
55
- Loader.displayName = 'Loader';
56
-
57
- export { Loader };
@@ -1,27 +0,0 @@
1
- import { LoaderSize, LoaderColor } from "./Loader.types";
2
- /**
3
- * Internal theme structure for the Loader component
4
- */
5
- interface LoaderTheme {
6
- baseStyle: string;
7
- circularStyle: string;
8
- linearContainerStyle: string;
9
- linearTrackStyle: string;
10
- linearBarStyle: string;
11
- linearLabelStyle: string;
12
- sizes: Record<LoaderSize, {
13
- circular: string;
14
- linear: string;
15
- }>;
16
- colors: Record<LoaderColor, {
17
- circular: string;
18
- linear: string;
19
- }>;
20
- animation: string;
21
- }
22
- /**
23
- * Default theme for the Loader component
24
- * Uses production-ready CSS variables from global.scss
25
- */
26
- export declare const loaderTheme: LoaderTheme;
27
- export {};
@@ -1,60 +0,0 @@
1
- /**
2
- * Default theme for the Loader component
3
- * Uses production-ready CSS variables from global.scss
4
- */
5
- const loaderTheme = {
6
- // Base styles for the loader container
7
- baseStyle: "inline-flex items-center justify-center",
8
- // Circular variant (spinner) styles
9
- circularStyle: "rounded-full",
10
- // Linear variant container
11
- linearContainerStyle: "w-full flex items-center gap-3",
12
- // Linear track (background)
13
- linearTrackStyle: "flex-1 h-2 rounded-full bg-[var(--color-background-tertiary)] overflow-hidden",
14
- // Linear bar (foreground)
15
- linearBarStyle: "h-full rounded-full transition-all duration-300 ease-out",
16
- // Label text for linear variant
17
- linearLabelStyle: "text-base font-medium text-[var(--color-text-secondary)] min-w-[3ch] tabular-nums",
18
- // Size variants for both circular and linear
19
- sizes: {
20
- sm: {
21
- circular: "size-4 border-2",
22
- linear: "h-1.5",
23
- },
24
- md: {
25
- circular: "size-5 border-[3px]",
26
- linear: "h-2",
27
- },
28
- lg: {
29
- circular: "size-6 border-[3px]",
30
- linear: "h-3",
31
- },
32
- },
33
- // Color variants using correct CSS variables
34
- colors: {
35
- primary: {
36
- circular: "border-[var(--color-primary)] border-t-transparent",
37
- linear: "bg-[var(--color-primary)]",
38
- },
39
- success: {
40
- circular: "border-[var(--color-success)] border-t-transparent",
41
- linear: "bg-[var(--color-success)]",
42
- },
43
- warning: {
44
- circular: "border-[var(--color-warning)] border-t-transparent",
45
- linear: "bg-[var(--color-warning)]",
46
- },
47
- danger: {
48
- circular: "border-[var(--color-danger)] border-t-transparent",
49
- linear: "bg-[var(--color-danger)]",
50
- },
51
- muted: {
52
- circular: "border-[var(--color-text-muted)] border-t-transparent",
53
- linear: "bg-[var(--color-text-muted)]",
54
- },
55
- },
56
- // Animation class for circular spinner
57
- animation: "animate-[spin_1s_linear_infinite]",
58
- };
59
-
60
- export { loaderTheme };
@@ -1,71 +0,0 @@
1
- /**
2
- * Loader component props
3
- * Supports both circular (spinner) and linear (progress bar) variants
4
- */
5
- export interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {
6
- /**
7
- * The variant of the loader
8
- * @default "circular"
9
- */
10
- variant?: LoaderVariant;
11
- /**
12
- * The size of the loader
13
- * @default "md"
14
- */
15
- size?: LoaderSize;
16
- /**
17
- * The color of the loader
18
- * @default "primary"
19
- */
20
- color?: LoaderColor;
21
- /**
22
- * Current progress value (0-100)
23
- * Only applies to linear variant
24
- * If not provided, shows indeterminate loading animation
25
- */
26
- value?: number;
27
- /**
28
- * Maximum value for progress
29
- * @default 100
30
- */
31
- max?: number;
32
- /**
33
- * Show percentage label
34
- * Only applies to linear variant with value prop
35
- * @default false
36
- */
37
- showLabel?: boolean;
38
- /**
39
- * Custom label text (overrides percentage)
40
- * Only applies to linear variant
41
- */
42
- label?: string;
43
- /**
44
- * Custom CSS class to apply to the loader
45
- */
46
- className?: string;
47
- /**
48
- * Theme overrides for the loader
49
- */
50
- theme?: LoaderThemeOverrides;
51
- }
52
- export type LoaderVariant = "circular" | "linear";
53
- export type LoaderSize = "sm" | "md" | "lg";
54
- export type LoaderColor = "primary" | "success" | "warning" | "danger" | "muted";
55
- export interface LoaderThemeOverrides {
56
- baseStyle?: string;
57
- circularStyle?: string;
58
- linearContainerStyle?: string;
59
- linearTrackStyle?: string;
60
- linearBarStyle?: string;
61
- linearLabelStyle?: string;
62
- sizes?: Partial<Record<LoaderSize, {
63
- circular: string;
64
- linear: string;
65
- }>>;
66
- colors?: Partial<Record<LoaderColor, {
67
- circular: string;
68
- linear: string;
69
- }>>;
70
- animation?: string;
71
- }
@@ -1,2 +0,0 @@
1
- export { Loader } from './Loader';
2
- export type { LoaderProps, LoaderVariant, LoaderSize, LoaderColor } from './Loader.types';