@lp-labs/ui-components 0.0.0-stage → 1.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.
Files changed (244) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/README.md +256 -2
  4. package/dist/cjs/components/Accordion.d.ts +78 -0
  5. package/dist/cjs/components/Accordion.js +78 -0
  6. package/dist/cjs/components/AdvancedComponents.d.ts +353 -0
  7. package/dist/cjs/components/AdvancedComponents.js +353 -0
  8. package/dist/cjs/components/Alert.d.ts +102 -0
  9. package/dist/cjs/components/Alert.js +102 -0
  10. package/dist/cjs/components/Avatar.d.ts +89 -0
  11. package/dist/cjs/components/Avatar.js +89 -0
  12. package/dist/cjs/components/Badge.d.ts +57 -0
  13. package/dist/cjs/components/Badge.js +57 -0
  14. package/dist/cjs/components/Breadcrumb.d.ts +50 -0
  15. package/dist/cjs/components/Breadcrumb.js +50 -0
  16. package/dist/cjs/components/Button.d.ts +77 -0
  17. package/dist/cjs/components/Button.js +77 -0
  18. package/dist/cjs/components/ButtonVariants.d.ts +261 -0
  19. package/dist/cjs/components/ButtonVariants.js +261 -0
  20. package/dist/cjs/components/Card.d.ts +56 -0
  21. package/dist/cjs/components/Card.js +56 -0
  22. package/dist/cjs/components/CardVariants.d.ts +267 -0
  23. package/dist/cjs/components/CardVariants.js +267 -0
  24. package/dist/cjs/components/Checkbox.d.ts +50 -0
  25. package/dist/cjs/components/Checkbox.js +50 -0
  26. package/dist/cjs/components/Chip.d.ts +104 -0
  27. package/dist/cjs/components/Chip.js +104 -0
  28. package/dist/cjs/components/DataDisplayComponents.d.ts +275 -0
  29. package/dist/cjs/components/DataDisplayComponents.js +275 -0
  30. package/dist/cjs/components/Divider.d.ts +77 -0
  31. package/dist/cjs/components/Divider.js +77 -0
  32. package/dist/cjs/components/Drawer.d.ts +142 -0
  33. package/dist/cjs/components/Drawer.js +142 -0
  34. package/dist/cjs/components/Dropdown.d.ts +139 -0
  35. package/dist/cjs/components/Dropdown.js +139 -0
  36. package/dist/cjs/components/Form.d.ts +41 -0
  37. package/dist/cjs/components/Form.js +41 -0
  38. package/dist/cjs/components/FormGroup.d.ts +58 -0
  39. package/dist/cjs/components/FormGroup.js +58 -0
  40. package/dist/cjs/components/FormInputVariants.d.ts +298 -0
  41. package/dist/cjs/components/FormInputVariants.js +298 -0
  42. package/dist/cjs/components/Image.d.ts +106 -0
  43. package/dist/cjs/components/Image.js +106 -0
  44. package/dist/cjs/components/Input.d.ts +65 -0
  45. package/dist/cjs/components/Input.js +65 -0
  46. package/dist/cjs/components/LayoutComponents.d.ts +258 -0
  47. package/dist/cjs/components/LayoutComponents.js +258 -0
  48. package/dist/cjs/components/Link.d.ts +71 -0
  49. package/dist/cjs/components/Link.js +71 -0
  50. package/dist/cjs/components/LoadingFeedbackComponents.d.ts +230 -0
  51. package/dist/cjs/components/LoadingFeedbackComponents.js +230 -0
  52. package/dist/cjs/components/Menu.d.ts +167 -0
  53. package/dist/cjs/components/Menu.js +167 -0
  54. package/dist/cjs/components/Modal.d.ts +145 -0
  55. package/dist/cjs/components/Modal.js +145 -0
  56. package/dist/cjs/components/ModalTypes.d.ts +288 -0
  57. package/dist/cjs/components/ModalTypes.js +288 -0
  58. package/dist/cjs/components/Navbar.d.ts +181 -0
  59. package/dist/cjs/components/Navbar.js +181 -0
  60. package/dist/cjs/components/NavigationComponents.d.ts +276 -0
  61. package/dist/cjs/components/NavigationComponents.js +276 -0
  62. package/dist/cjs/components/Pagination.d.ts +94 -0
  63. package/dist/cjs/components/Pagination.js +94 -0
  64. package/dist/cjs/components/Popover.d.ts +108 -0
  65. package/dist/cjs/components/Popover.js +108 -0
  66. package/dist/cjs/components/Progress.d.ts +68 -0
  67. package/dist/cjs/components/Progress.js +68 -0
  68. package/dist/cjs/components/Radio.d.ts +93 -0
  69. package/dist/cjs/components/Radio.js +93 -0
  70. package/dist/cjs/components/Rating.d.ts +82 -0
  71. package/dist/cjs/components/Rating.js +82 -0
  72. package/dist/cjs/components/Select.d.ts +74 -0
  73. package/dist/cjs/components/Select.js +74 -0
  74. package/dist/cjs/components/Sidebar.d.ts +174 -0
  75. package/dist/cjs/components/Sidebar.js +174 -0
  76. package/dist/cjs/components/Skeleton.d.ts +57 -0
  77. package/dist/cjs/components/Skeleton.js +57 -0
  78. package/dist/cjs/components/Slider.d.ts +64 -0
  79. package/dist/cjs/components/Slider.js +64 -0
  80. package/dist/cjs/components/Spinner.d.ts +70 -0
  81. package/dist/cjs/components/Spinner.js +70 -0
  82. package/dist/cjs/components/Stack.d.ts +75 -0
  83. package/dist/cjs/components/Stack.js +75 -0
  84. package/dist/cjs/components/Stepper.d.ts +150 -0
  85. package/dist/cjs/components/Stepper.js +150 -0
  86. package/dist/cjs/components/Table.d.ts +173 -0
  87. package/dist/cjs/components/Table.js +173 -0
  88. package/dist/cjs/components/Tabs.d.ts +104 -0
  89. package/dist/cjs/components/Tabs.js +104 -0
  90. package/dist/cjs/components/Tag.d.ts +74 -0
  91. package/dist/cjs/components/Tag.js +74 -0
  92. package/dist/cjs/components/Textarea.d.ts +75 -0
  93. package/dist/cjs/components/Textarea.js +75 -0
  94. package/dist/cjs/components/Timeline.d.ts +124 -0
  95. package/dist/cjs/components/Timeline.js +124 -0
  96. package/dist/cjs/components/Toast.d.ts +155 -0
  97. package/dist/cjs/components/Toast.js +155 -0
  98. package/dist/cjs/components/Toggle.d.ts +75 -0
  99. package/dist/cjs/components/Toggle.js +75 -0
  100. package/dist/cjs/components/Tooltip.d.ts +80 -0
  101. package/dist/cjs/components/Tooltip.js +80 -0
  102. package/dist/cjs/components/TypographyComponents.d.ts +265 -0
  103. package/dist/cjs/components/TypographyComponents.js +265 -0
  104. package/dist/cjs/components/UtilityComponents.d.ts +345 -0
  105. package/dist/cjs/components/UtilityComponents.js +345 -0
  106. package/dist/cjs/components/Video.d.ts +82 -0
  107. package/dist/cjs/components/Video.js +82 -0
  108. package/dist/cjs/components/index.d.ts +311 -0
  109. package/dist/cjs/components/index.js +311 -0
  110. package/dist/cjs/index.d.ts +5 -0
  111. package/dist/cjs/index.js +5 -0
  112. package/dist/cjs/styles/main.css +493 -0
  113. package/dist/cjs/theme/ThemeProvider.d.ts +185 -0
  114. package/dist/cjs/theme/ThemeProvider.js +185 -0
  115. package/dist/cjs/theme/index.d.ts +2 -0
  116. package/dist/cjs/theme/index.js +2 -0
  117. package/dist/cjs/utilities/classNames.d.ts +200 -0
  118. package/dist/cjs/utilities/classNames.js +200 -0
  119. package/dist/cjs/utilities/index.d.ts +3 -0
  120. package/dist/cjs/utilities/index.js +3 -0
  121. package/dist/cjs/utilities/styles.d.ts +94 -0
  122. package/dist/cjs/utilities/styles.js +94 -0
  123. package/dist/esm/components/Accordion.d.ts +78 -0
  124. package/dist/esm/components/Accordion.js +78 -0
  125. package/dist/esm/components/AdvancedComponents.d.ts +353 -0
  126. package/dist/esm/components/AdvancedComponents.js +353 -0
  127. package/dist/esm/components/Alert.d.ts +102 -0
  128. package/dist/esm/components/Alert.js +102 -0
  129. package/dist/esm/components/Avatar.d.ts +89 -0
  130. package/dist/esm/components/Avatar.js +89 -0
  131. package/dist/esm/components/Badge.d.ts +57 -0
  132. package/dist/esm/components/Badge.js +57 -0
  133. package/dist/esm/components/Breadcrumb.d.ts +50 -0
  134. package/dist/esm/components/Breadcrumb.js +50 -0
  135. package/dist/esm/components/Button.d.ts +77 -0
  136. package/dist/esm/components/Button.js +77 -0
  137. package/dist/esm/components/ButtonVariants.d.ts +261 -0
  138. package/dist/esm/components/ButtonVariants.js +261 -0
  139. package/dist/esm/components/Card.d.ts +56 -0
  140. package/dist/esm/components/Card.js +56 -0
  141. package/dist/esm/components/CardVariants.d.ts +267 -0
  142. package/dist/esm/components/CardVariants.js +267 -0
  143. package/dist/esm/components/Checkbox.d.ts +50 -0
  144. package/dist/esm/components/Checkbox.js +50 -0
  145. package/dist/esm/components/Chip.d.ts +104 -0
  146. package/dist/esm/components/Chip.js +104 -0
  147. package/dist/esm/components/DataDisplayComponents.d.ts +275 -0
  148. package/dist/esm/components/DataDisplayComponents.js +275 -0
  149. package/dist/esm/components/Divider.d.ts +77 -0
  150. package/dist/esm/components/Divider.js +77 -0
  151. package/dist/esm/components/Drawer.d.ts +142 -0
  152. package/dist/esm/components/Drawer.js +142 -0
  153. package/dist/esm/components/Dropdown.d.ts +139 -0
  154. package/dist/esm/components/Dropdown.js +139 -0
  155. package/dist/esm/components/Form.d.ts +41 -0
  156. package/dist/esm/components/Form.js +41 -0
  157. package/dist/esm/components/FormGroup.d.ts +58 -0
  158. package/dist/esm/components/FormGroup.js +58 -0
  159. package/dist/esm/components/FormInputVariants.d.ts +298 -0
  160. package/dist/esm/components/FormInputVariants.js +298 -0
  161. package/dist/esm/components/Image.d.ts +106 -0
  162. package/dist/esm/components/Image.js +106 -0
  163. package/dist/esm/components/Input.d.ts +65 -0
  164. package/dist/esm/components/Input.js +65 -0
  165. package/dist/esm/components/LayoutComponents.d.ts +258 -0
  166. package/dist/esm/components/LayoutComponents.js +258 -0
  167. package/dist/esm/components/Link.d.ts +71 -0
  168. package/dist/esm/components/Link.js +71 -0
  169. package/dist/esm/components/LoadingFeedbackComponents.d.ts +230 -0
  170. package/dist/esm/components/LoadingFeedbackComponents.js +230 -0
  171. package/dist/esm/components/Menu.d.ts +167 -0
  172. package/dist/esm/components/Menu.js +167 -0
  173. package/dist/esm/components/Modal.d.ts +145 -0
  174. package/dist/esm/components/Modal.js +145 -0
  175. package/dist/esm/components/ModalTypes.d.ts +288 -0
  176. package/dist/esm/components/ModalTypes.js +288 -0
  177. package/dist/esm/components/Navbar.d.ts +181 -0
  178. package/dist/esm/components/Navbar.js +181 -0
  179. package/dist/esm/components/NavigationComponents.d.ts +276 -0
  180. package/dist/esm/components/NavigationComponents.js +276 -0
  181. package/dist/esm/components/Pagination.d.ts +94 -0
  182. package/dist/esm/components/Pagination.js +94 -0
  183. package/dist/esm/components/Popover.d.ts +108 -0
  184. package/dist/esm/components/Popover.js +108 -0
  185. package/dist/esm/components/Progress.d.ts +68 -0
  186. package/dist/esm/components/Progress.js +68 -0
  187. package/dist/esm/components/Radio.d.ts +93 -0
  188. package/dist/esm/components/Radio.js +93 -0
  189. package/dist/esm/components/Rating.d.ts +82 -0
  190. package/dist/esm/components/Rating.js +82 -0
  191. package/dist/esm/components/Select.d.ts +74 -0
  192. package/dist/esm/components/Select.js +74 -0
  193. package/dist/esm/components/Sidebar.d.ts +174 -0
  194. package/dist/esm/components/Sidebar.js +174 -0
  195. package/dist/esm/components/Skeleton.d.ts +57 -0
  196. package/dist/esm/components/Skeleton.js +57 -0
  197. package/dist/esm/components/Slider.d.ts +64 -0
  198. package/dist/esm/components/Slider.js +64 -0
  199. package/dist/esm/components/Spinner.d.ts +70 -0
  200. package/dist/esm/components/Spinner.js +70 -0
  201. package/dist/esm/components/Stack.d.ts +75 -0
  202. package/dist/esm/components/Stack.js +75 -0
  203. package/dist/esm/components/Stepper.d.ts +150 -0
  204. package/dist/esm/components/Stepper.js +150 -0
  205. package/dist/esm/components/Table.d.ts +173 -0
  206. package/dist/esm/components/Table.js +173 -0
  207. package/dist/esm/components/Tabs.d.ts +104 -0
  208. package/dist/esm/components/Tabs.js +104 -0
  209. package/dist/esm/components/Tag.d.ts +74 -0
  210. package/dist/esm/components/Tag.js +74 -0
  211. package/dist/esm/components/Textarea.d.ts +75 -0
  212. package/dist/esm/components/Textarea.js +75 -0
  213. package/dist/esm/components/Timeline.d.ts +124 -0
  214. package/dist/esm/components/Timeline.js +124 -0
  215. package/dist/esm/components/Toast.d.ts +155 -0
  216. package/dist/esm/components/Toast.js +155 -0
  217. package/dist/esm/components/Toggle.d.ts +75 -0
  218. package/dist/esm/components/Toggle.js +75 -0
  219. package/dist/esm/components/Tooltip.d.ts +80 -0
  220. package/dist/esm/components/Tooltip.js +80 -0
  221. package/dist/esm/components/TypographyComponents.d.ts +265 -0
  222. package/dist/esm/components/TypographyComponents.js +265 -0
  223. package/dist/esm/components/UtilityComponents.d.ts +345 -0
  224. package/dist/esm/components/UtilityComponents.js +345 -0
  225. package/dist/esm/components/Video.d.ts +82 -0
  226. package/dist/esm/components/Video.js +82 -0
  227. package/dist/esm/components/index.d.ts +311 -0
  228. package/dist/esm/components/index.js +311 -0
  229. package/dist/esm/index.d.ts +5 -0
  230. package/dist/esm/index.js +5 -0
  231. package/dist/esm/styles/main.css +493 -0
  232. package/dist/esm/theme/ThemeProvider.d.ts +185 -0
  233. package/dist/esm/theme/ThemeProvider.js +185 -0
  234. package/dist/esm/theme/index.d.ts +2 -0
  235. package/dist/esm/theme/index.js +2 -0
  236. package/dist/esm/utilities/classNames.d.ts +200 -0
  237. package/dist/esm/utilities/classNames.js +200 -0
  238. package/dist/esm/utilities/index.d.ts +3 -0
  239. package/dist/esm/utilities/index.js +3 -0
  240. package/dist/esm/utilities/styles.d.ts +94 -0
  241. package/dist/esm/utilities/styles.js +94 -0
  242. package/dist/styles/main.css +493 -0
  243. package/package.json +124 -6
  244. package/src/styles/main.css +493 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * CSS-in-JS style utilities for dynamic styling
3
+ */
4
+
5
+ export interface StyleObject {
6
+ [key: string]: string | number | undefined;
7
+ }
8
+
9
+ export function createStyles(styles: StyleObject): React.CSSProperties {
10
+ const result: React.CSSProperties = {};
11
+
12
+ for (const [key, value] of Object.entries(styles)) {
13
+ if (value !== undefined) {
14
+ // Convert camelCase CSS property names to kebab-case if needed
15
+ const cssKey = key as keyof React.CSSProperties;
16
+ result[cssKey] = value;
17
+ }
18
+ }
19
+
20
+ return result;
21
+ }
22
+
23
+ export function combineStyles(...styles: (StyleObject | undefined | null)[]): React.CSSProperties {
24
+ const result: React.CSSProperties = {};
25
+
26
+ for (const style of styles) {
27
+ if (style) {
28
+ Object.assign(result, createStyles(style));
29
+ }
30
+ }
31
+
32
+ return result;
33
+ }
34
+
35
+ /**
36
+ * Media query builder
37
+ */
38
+ export const media = {
39
+ sm: '@media (min-width: 640px)',
40
+ md: '@media (min-width: 768px)',
41
+ lg: '@media (min-width: 1024px)',
42
+ xl: '@media (min-width: 1280px)',
43
+ '2xl': '@media (min-width: 1536px)',
44
+ dark: '@media (prefers-color-scheme: dark)',
45
+ light: '@media (prefers-color-scheme: light)',
46
+ motion: '@media (prefers-reduced-motion: no-preference)',
47
+ };
48
+
49
+ /**
50
+ * CSS variable builder
51
+ */
52
+ export function createCSSVariables(variables: Record<string, string>): Record<string, string> {
53
+ const result: Record<string, string> = {};
54
+
55
+ for (const [key, value] of Object.entries(variables)) {
56
+ result[`--${key}`] = value;
57
+ }
58
+
59
+ return result;
60
+ }
61
+
62
+ /**
63
+ * Get CSS variable value
64
+ */
65
+ export function getCSSVariable(name: string): string {
66
+ if (typeof window === 'undefined') {
67
+ return '';
68
+ }
69
+ return getComputedStyle(document.documentElement).getPropertyValue(`--${name}`).trim();
70
+ }
71
+
72
+ /**
73
+ * Set CSS variable value
74
+ */
75
+ export function setCSSVariable(name: string, value: string): void {
76
+ if (typeof document === 'undefined') {
77
+ return;
78
+ }
79
+ document.documentElement.style.setProperty(`--${name}`, value);
80
+ }
81
+
82
+ /**
83
+ * CSS animation utilities
84
+ */
85
+ export const animations = {
86
+ fadeIn: 'animation: fadeIn 0.3s ease-in-out',
87
+ fadeOut: 'animation: fadeOut 0.3s ease-in-out',
88
+ slideInUp: 'animation: slideInUp 0.3s ease-in-out',
89
+ slideOutDown: 'animation: slideOutDown 0.3s ease-in-out',
90
+ slideInRight: 'animation: slideInRight 0.3s ease-in-out',
91
+ slideOutLeft: 'animation: slideOutLeft 0.3s ease-in-out',
92
+ scaleIn: 'animation: scaleIn 0.3s ease-in-out',
93
+ scaleOut: 'animation: scaleOut 0.3s ease-in-out',
94
+ };
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import { cn } from '../utilities/classNames';
3
+
4
+ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ items: Array<{
6
+ id: string;
7
+ title: string;
8
+ content: React.ReactNode;
9
+ }>;
10
+ allowMultiple?: boolean;
11
+ }
12
+
13
+ export const Accordion = React.forwardRef<HTMLDivElement, AccordionProps>(
14
+ (
15
+ {
16
+ items,
17
+ allowMultiple = false,
18
+ className,
19
+ ...props
20
+ },
21
+ ref,
22
+ ) => {
23
+ const [openItems, setOpenItems] = React.useState<Set<string>>(new Set());
24
+
25
+ const toggleItem = (id: string) => {
26
+ const newOpen = new Set(openItems);
27
+ if (newOpen.has(id)) {
28
+ newOpen.delete(id);
29
+ } else {
30
+ if (!allowMultiple) {
31
+ newOpen.clear();
32
+ }
33
+ newOpen.add(id);
34
+ }
35
+ setOpenItems(newOpen);
36
+ };
37
+
38
+ return (
39
+ <div ref={ref} className={cn('border border-gray-200 rounded-lg', className)} {...props}>
40
+ {items.map((item, index) => (
41
+ <div
42
+ key={item.id}
43
+ className={cn(
44
+ 'border-b border-gray-200',
45
+ index === items.length - 1 && 'border-b-0',
46
+ )}
47
+ >
48
+ <button
49
+ onClick={() => toggleItem(item.id)}
50
+ className="w-full px-4 py-4 text-left font-medium hover:bg-gray-50 flex justify-between items-center transition-colors"
51
+ aria-expanded={openItems.has(item.id)}
52
+ >
53
+ {item.title}
54
+ <svg
55
+ className={cn(
56
+ 'w-5 h-5 transition-transform',
57
+ openItems.has(item.id) && 'transform rotate-180',
58
+ )}
59
+ fill="none"
60
+ stroke="currentColor"
61
+ viewBox="0 0 24 24"
62
+ >
63
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 14l-7 7m0 0l-7-7m7 7V3" />
64
+ </svg>
65
+ </button>
66
+ {openItems.has(item.id) && (
67
+ <div className="px-4 py-4 text-gray-700 border-t border-gray-200">
68
+ {item.content}
69
+ </div>
70
+ )}
71
+ </div>
72
+ ))}
73
+ </div>
74
+ );
75
+ },
76
+ );
77
+
78
+ Accordion.displayName = 'Accordion';
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import { cn } from '../utilities/classNames';
3
+
4
+ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ items: Array<{
6
+ id: string;
7
+ title: string;
8
+ content: React.ReactNode;
9
+ }>;
10
+ allowMultiple?: boolean;
11
+ }
12
+
13
+ export const Accordion = React.forwardRef<HTMLDivElement, AccordionProps>(
14
+ (
15
+ {
16
+ items,
17
+ allowMultiple = false,
18
+ className,
19
+ ...props
20
+ },
21
+ ref,
22
+ ) => {
23
+ const [openItems, setOpenItems] = React.useState<Set<string>>(new Set());
24
+
25
+ const toggleItem = (id: string) => {
26
+ const newOpen = new Set(openItems);
27
+ if (newOpen.has(id)) {
28
+ newOpen.delete(id);
29
+ } else {
30
+ if (!allowMultiple) {
31
+ newOpen.clear();
32
+ }
33
+ newOpen.add(id);
34
+ }
35
+ setOpenItems(newOpen);
36
+ };
37
+
38
+ return (
39
+ <div ref={ref} className={cn('border border-gray-200 rounded-lg', className)} {...props}>
40
+ {items.map((item, index) => (
41
+ <div
42
+ key={item.id}
43
+ className={cn(
44
+ 'border-b border-gray-200',
45
+ index === items.length - 1 && 'border-b-0',
46
+ )}
47
+ >
48
+ <button
49
+ onClick={() => toggleItem(item.id)}
50
+ className="w-full px-4 py-4 text-left font-medium hover:bg-gray-50 flex justify-between items-center transition-colors"
51
+ aria-expanded={openItems.has(item.id)}
52
+ >
53
+ {item.title}
54
+ <svg
55
+ className={cn(
56
+ 'w-5 h-5 transition-transform',
57
+ openItems.has(item.id) && 'transform rotate-180',
58
+ )}
59
+ fill="none"
60
+ stroke="currentColor"
61
+ viewBox="0 0 24 24"
62
+ >
63
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 14l-7 7m0 0l-7-7m7 7V3" />
64
+ </svg>
65
+ </button>
66
+ {openItems.has(item.id) && (
67
+ <div className="px-4 py-4 text-gray-700 border-t border-gray-200">
68
+ {item.content}
69
+ </div>
70
+ )}
71
+ </div>
72
+ ))}
73
+ </div>
74
+ );
75
+ },
76
+ );
77
+
78
+ Accordion.displayName = 'Accordion';
@@ -0,0 +1,353 @@
1
+ import React from 'react';
2
+
3
+ export interface AdvancedComponentProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ children?: React.ReactNode;
5
+ }
6
+
7
+ export const FormBuilder: React.FC<
8
+ AdvancedComponentProps & {
9
+ fields: Array<{
10
+ id: string;
11
+ type: 'text' | 'email' | 'password' | 'number' | 'date' | 'select' | 'checkbox' | 'radio';
12
+ label: string;
13
+ required?: boolean;
14
+ options?: Array<{ label: string; value: string }>;
15
+ }>;
16
+ onSubmit?: (data: Record<string, any>) => void;
17
+ }
18
+ > = ({
19
+ fields,
20
+ onSubmit,
21
+ className = '',
22
+ ...props
23
+ }) => {
24
+ const [formData, setFormData] = React.useState<Record<string, any>>({});
25
+
26
+ const handleChange = (id: string, value: any) => {
27
+ setFormData((prev) => ({ ...prev, [id]: value }));
28
+ };
29
+
30
+ return (
31
+ <form
32
+ onSubmit={(e) => {
33
+ e.preventDefault();
34
+ onSubmit?.(formData);
35
+ }}
36
+ className={`space-y-4 ${className}`}
37
+ {...props}
38
+ >
39
+ {fields.map((field) => (
40
+ <div key={field.id}>
41
+ <label className="block text-sm font-medium mb-1">
42
+ {field.label}
43
+ {field.required && <span className="text-red-600">*</span>}
44
+ </label>
45
+ {field.type === 'select' && (
46
+ <select
47
+ value={formData[field.id] || ''}
48
+ onChange={(e) => handleChange(field.id, e.target.value)}
49
+ className="w-full px-3 py-2 border border-gray-300 rounded-lg"
50
+ >
51
+ <option value="">Select...</option>
52
+ {field.options?.map((opt) => (
53
+ <option key={opt.value} value={opt.value}>
54
+ {opt.label}
55
+ </option>
56
+ ))}
57
+ </select>
58
+ )}
59
+ {field.type === 'checkbox' && (
60
+ <input
61
+ type="checkbox"
62
+ checked={formData[field.id] || false}
63
+ onChange={(e) => handleChange(field.id, e.target.checked)}
64
+ className="w-4 h-4"
65
+ />
66
+ )}
67
+ {field.type !== 'select' && field.type !== 'checkbox' && (
68
+ <input
69
+ type={field.type}
70
+ value={formData[field.id] || ''}
71
+ onChange={(e) => handleChange(field.id, e.target.value)}
72
+ className="w-full px-3 py-2 border border-gray-300 rounded-lg"
73
+ />
74
+ )}
75
+ </div>
76
+ ))}
77
+ <button
78
+ type="submit"
79
+ className="w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"
80
+ >
81
+ Submit
82
+ </button>
83
+ </form>
84
+ );
85
+ };
86
+
87
+ export const TableBuilder: React.FC<
88
+ AdvancedComponentProps & {
89
+ data: Array<Record<string, any>>;
90
+ columns: Array<{ key: string; label: string }>;
91
+ editable?: boolean;
92
+ }
93
+ > = ({
94
+ data,
95
+ columns,
96
+ editable = false,
97
+ className = '',
98
+ ...props
99
+ }) => {
100
+ const [editingRow, setEditingRow] = React.useState<number | null>(null);
101
+ const [editValues, setEditValues] = React.useState<Record<string, any>>({});
102
+
103
+ return (
104
+ <div className={`overflow-x-auto ${className}`} {...props}>
105
+ <table className="w-full border border-gray-300">
106
+ <thead className="bg-gray-100">
107
+ <tr>
108
+ {columns.map((col) => (
109
+ <th key={col.key} className="px-4 py-2 text-left font-semibold border-b">
110
+ {col.label}
111
+ </th>
112
+ ))}
113
+ {editable && <th className="px-4 py-2 text-left font-semibold border-b">Actions</th>}
114
+ </tr>
115
+ </thead>
116
+ <tbody>
117
+ {data.map((row, idx) => (
118
+ <tr key={idx} className="hover:bg-gray-50 border-b">
119
+ {columns.map((col) => (
120
+ <td key={col.key} className="px-4 py-2">
121
+ {editingRow === idx ? (
122
+ <input
123
+ type="text"
124
+ value={editValues[col.key] || ''}
125
+ onChange={(e) =>
126
+ setEditValues((prev) => ({
127
+ ...prev,
128
+ [col.key]: e.target.value,
129
+ }))
130
+ }
131
+ className="w-full px-2 py-1 border border-gray-300 rounded"
132
+ />
133
+ ) : (
134
+ row[col.key]
135
+ )}
136
+ </td>
137
+ ))}
138
+ {editable && (
139
+ <td className="px-4 py-2 flex gap-2">
140
+ {editingRow === idx ? (
141
+ <>
142
+ <button className="px-2 py-1 bg-green-600 text-white rounded">Save</button>
143
+ <button
144
+ onClick={() => setEditingRow(null)}
145
+ className="px-2 py-1 bg-gray-600 text-white rounded"
146
+ >
147
+ Cancel
148
+ </button>
149
+ </>
150
+ ) : (
151
+ <>
152
+ <button
153
+ onClick={() => {
154
+ setEditingRow(idx);
155
+ setEditValues(row);
156
+ }}
157
+ className="px-2 py-1 bg-blue-600 text-white rounded"
158
+ >
159
+ Edit
160
+ </button>
161
+ <button className="px-2 py-1 bg-red-600 text-white rounded">Delete</button>
162
+ </>
163
+ )}
164
+ </td>
165
+ )}
166
+ </tr>
167
+ ))}
168
+ </tbody>
169
+ </table>
170
+ </div>
171
+ );
172
+ };
173
+
174
+ export const Dashboard: React.FC<
175
+ AdvancedComponentProps & {
176
+ title?: string;
177
+ widgets: Array<{ id: string; title: string; content: React.ReactNode }>;
178
+ columns?: number;
179
+ }
180
+ > = ({
181
+ title,
182
+ widgets,
183
+ columns = 3,
184
+ className = '',
185
+ ...props
186
+ }) => {
187
+ return (
188
+ <div className={className} {...props}>
189
+ {title && <h1 className="text-3xl font-bold mb-8">{title}</h1>}
190
+ <div className={`grid grid-cols-1 md:grid-cols-${columns} gap-6`}>
191
+ {widgets.map((widget) => (
192
+ <div key={widget.id} className="bg-white rounded-lg shadow-md p-6 border border-gray-200">
193
+ <h2 className="text-lg font-semibold mb-4">{widget.title}</h2>
194
+ {widget.content}
195
+ </div>
196
+ ))}
197
+ </div>
198
+ </div>
199
+ );
200
+ };
201
+
202
+ export const Wizard: React.FC<
203
+ AdvancedComponentProps & {
204
+ steps: Array<{ title: string; content: React.ReactNode }>;
205
+ onComplete?: () => void;
206
+ }
207
+ > = ({
208
+ steps,
209
+ onComplete,
210
+ className = '',
211
+ ...props
212
+ }) => {
213
+ const [currentStep, setCurrentStep] = React.useState(0);
214
+
215
+ return (
216
+ <div className={`max-w-2xl mx-auto ${className}`} {...props}>
217
+ <div className="mb-8">
218
+ <div className="flex justify-between mb-4">
219
+ {steps.map((step, idx) => (
220
+ <button
221
+ key={idx}
222
+ onClick={() => setCurrentStep(idx)}
223
+ className={`flex-1 text-center py-2 border-b-4 ${
224
+ idx === currentStep ? 'border-blue-600 text-blue-600' : 'border-gray-300 text-gray-600'
225
+ }`}
226
+ >
227
+ {step.title}
228
+ </button>
229
+ ))}
230
+ </div>
231
+ <div className="bg-white p-6 border border-gray-200 rounded-lg">{steps[currentStep].content}</div>
232
+ </div>
233
+ <div className="flex gap-4 justify-between">
234
+ <button
235
+ onClick={() => setCurrentStep(Math.max(0, currentStep - 1))}
236
+ disabled={currentStep === 0}
237
+ className="px-4 py-2 bg-gray-600 text-white rounded-lg disabled:opacity-50"
238
+ >
239
+ Previous
240
+ </button>
241
+ {currentStep === steps.length - 1 ? (
242
+ <button
243
+ onClick={onComplete}
244
+ className="px-4 py-2 bg-green-600 text-white rounded-lg"
245
+ >
246
+ Complete
247
+ </button>
248
+ ) : (
249
+ <button
250
+ onClick={() => setCurrentStep(Math.min(steps.length - 1, currentStep + 1))}
251
+ className="px-4 py-2 bg-blue-600 text-white rounded-lg"
252
+ >
253
+ Next
254
+ </button>
255
+ )}
256
+ </div>
257
+ </div>
258
+ );
259
+ };
260
+
261
+ export const KanbanBoard: React.FC<
262
+ AdvancedComponentProps & {
263
+ columns: Array<{
264
+ id: string;
265
+ title: string;
266
+ cards: Array<{ id: string; title: string; description?: string }>;
267
+ }>;
268
+ }
269
+ > = ({
270
+ columns,
271
+ className = '',
272
+ ...props
273
+ }) => {
274
+ return (
275
+ <div className={`grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4 overflow-x-auto ${className}`} {...props}>
276
+ {columns.map((col) => (
277
+ <div key={col.id} className="bg-gray-100 rounded-lg p-4 min-w-sm">
278
+ <h3 className="font-semibold mb-4">{col.title}</h3>
279
+ <div className="space-y-2">
280
+ {col.cards.map((card) => (
281
+ <div key={card.id} className="bg-white p-4 rounded-lg shadow-sm border-l-4 border-blue-600">
282
+ <p className="font-medium">{card.title}</p>
283
+ {card.description && <p className="text-sm text-gray-600 mt-1">{card.description}</p>}
284
+ </div>
285
+ ))}
286
+ </div>
287
+ </div>
288
+ ))}
289
+ </div>
290
+ );
291
+ };
292
+
293
+ export const Timeline: React.FC<
294
+ AdvancedComponentProps & {
295
+ items: Array<{
296
+ id: string;
297
+ title: string;
298
+ description?: string;
299
+ timestamp?: string;
300
+ icon?: React.ReactNode;
301
+ }>;
302
+ }
303
+ > = ({
304
+ items,
305
+ className = '',
306
+ ...props
307
+ }) => {
308
+ return (
309
+ <div className={`space-y-6 ${className}`} {...props}>
310
+ {items.map((item, idx) => (
311
+ <div key={item.id} className="flex gap-4">
312
+ <div className="flex flex-col items-center">
313
+ <div className="w-10 h-10 bg-blue-600 text-white rounded-full flex items-center justify-center">
314
+ {item.icon || '●'}
315
+ </div>
316
+ {idx < items.length - 1 && <div className="w-0.5 h-20 bg-gray-300 mt-2"></div>}
317
+ </div>
318
+ <div className="pb-6">
319
+ <h4 className="font-semibold">{item.title}</h4>
320
+ {item.description && <p className="text-gray-600 text-sm mt-1">{item.description}</p>}
321
+ {item.timestamp && <p className="text-gray-500 text-xs mt-2">{item.timestamp}</p>}
322
+ </div>
323
+ </div>
324
+ ))}
325
+ </div>
326
+ );
327
+ };
328
+
329
+ export const OrgChart: React.FC<
330
+ AdvancedComponentProps & {
331
+ root: { name: string; children?: any[] };
332
+ }
333
+ > = ({
334
+ root,
335
+ className = '',
336
+ ...props
337
+ }) => {
338
+ return (
339
+ <div className={`flex flex-col items-center gap-4 ${className}`} {...props}>
340
+ <div className="px-4 py-2 bg-blue-600 text-white rounded-lg font-semibold">{root.name}</div>
341
+ {root.children && root.children.length > 0 && (
342
+ <>
343
+ <div className="w-0.5 h-6 bg-gray-300"></div>
344
+ <div className="flex gap-8">
345
+ {root.children.map((child, idx) => (
346
+ <OrgChart key={idx} root={child} />
347
+ ))}
348
+ </div>
349
+ </>
350
+ )}
351
+ </div>
352
+ );
353
+ };