@srcroot/ui 0.0.1 → 0.0.3

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/dist/index.js CHANGED
@@ -500,6 +500,97 @@ var REGISTRY = {
500
500
  description: "Date picker",
501
501
  category: "Forms",
502
502
  dependencies: []
503
+ },
504
+ sidebar: {
505
+ file: "sidebar.tsx",
506
+ description: "Responsive sidebar with mobile drawer",
507
+ category: "Layout",
508
+ dependencies: ["sheet", "button"]
509
+ },
510
+ // Added Components
511
+ combobox: {
512
+ file: "combobox.tsx",
513
+ description: "Searchable select with autocomplete",
514
+ category: "Forms",
515
+ dependencies: ["popover"]
516
+ },
517
+ command: {
518
+ file: "command.tsx",
519
+ description: "Command palette / search menu",
520
+ category: "Navigation",
521
+ dependencies: []
522
+ },
523
+ "context-menu": {
524
+ file: "context-menu.tsx",
525
+ description: "Right-click context menu",
526
+ category: "Overlay / Feedback",
527
+ dependencies: []
528
+ },
529
+ "date-picker": {
530
+ file: "date-picker.tsx",
531
+ description: "Date picker with calendar",
532
+ category: "Forms",
533
+ dependencies: ["calendar", "popover", "button"]
534
+ },
535
+ drawer: {
536
+ file: "drawer.tsx",
537
+ description: "Bottom/top sheet drawer",
538
+ category: "Overlay / Feedback",
539
+ dependencies: []
540
+ },
541
+ "file-upload": {
542
+ file: "file-upload.tsx",
543
+ description: "Drag-and-drop file upload",
544
+ category: "Forms",
545
+ dependencies: []
546
+ },
547
+ "hover-card": {
548
+ file: "hover-card.tsx",
549
+ description: "Hover-triggered popover",
550
+ category: "Overlay / Feedback",
551
+ dependencies: []
552
+ },
553
+ kbd: {
554
+ file: "kbd.tsx",
555
+ description: "Keyboard shortcut display",
556
+ category: "Typography",
557
+ dependencies: []
558
+ },
559
+ menubar: {
560
+ file: "menubar.tsx",
561
+ description: "Horizontal menu with dropdowns",
562
+ category: "Navigation",
563
+ dependencies: []
564
+ },
565
+ "native-select": {
566
+ file: "native-select.tsx",
567
+ description: "Styled browser-native select",
568
+ category: "Forms",
569
+ dependencies: []
570
+ },
571
+ resizable: {
572
+ file: "resizable.tsx",
573
+ description: "Resizable panel layout",
574
+ category: "Layout",
575
+ dependencies: []
576
+ },
577
+ "scroll-area": {
578
+ file: "scroll-area.tsx",
579
+ description: "Custom scrollbar container",
580
+ category: "Layout",
581
+ dependencies: []
582
+ },
583
+ toggle: {
584
+ file: "toggle.tsx",
585
+ description: "Toggle button",
586
+ category: "Forms",
587
+ dependencies: []
588
+ },
589
+ "toggle-group": {
590
+ file: "toggle-group.tsx",
591
+ description: "Grouped toggle buttons",
592
+ category: "Forms",
593
+ dependencies: ["toggle"]
503
594
  }
504
595
  };
505
596
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcroot/ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "A shadcn-style CLI UI library with polymorphic, accessible React components",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,12 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18.0.0 || ^19.0.0",
41
- "react-dom": "^18.0.0 || ^19.0.0"
41
+ "react-dom": "^18.0.0 || ^19.0.0",
42
+ "lucide-react": "^0.300.0",
43
+ "cmdk": "^1.0.0",
44
+ "class-variance-authority": "^0.7.0",
45
+ "clsx": "^2.0.0",
46
+ "tailwind-merge": "^2.0.0",
47
+ "tailwindcss": "^3.0.0"
42
48
  }
43
- }
49
+ }
@@ -22,15 +22,12 @@ const badgeVariants = cva(
22
22
  }
23
23
  )
24
24
 
25
- type BadgeVariants = VariantProps<typeof badgeVariants>
26
-
27
- interface BadgeBaseProps extends BadgeVariants {
28
- className?: string
29
- children?: React.ReactNode
30
- }
25
+ interface BadgeProps
26
+ extends React.HTMLAttributes<HTMLSpanElement>,
27
+ VariantProps<typeof badgeVariants> { }
31
28
 
32
29
  /**
33
- * Polymorphic Badge component for status indicators
30
+ * Badge component for status indicators
34
31
  *
35
32
  * @example
36
33
  * // Default badge
@@ -38,26 +35,13 @@ interface BadgeBaseProps extends BadgeVariants {
38
35
  *
39
36
  * // Destructive variant
40
37
  * <Badge variant="destructive">Error</Badge>
41
- *
42
- * // As a link
43
- * <Badge as="a" href="/status">View Status</Badge>
44
38
  */
45
- const Badge = React.forwardRef(
46
- <T extends React.ElementType = "span">(
47
- {
48
- as,
49
- className,
50
- variant,
51
- ...props
52
- }: BadgeBaseProps & { as?: T } & Omit<React.ComponentPropsWithoutRef<T>, keyof BadgeBaseProps | "as">,
53
- ref: React.ForwardedRef<React.ElementRef<T>>
54
- ) => {
55
- const Comp = as || "span"
56
-
39
+ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
40
+ ({ className, variant, ...props }, ref) => {
57
41
  return (
58
- <Comp
59
- ref={ref as any}
60
- className={cn(badgeVariants({ variant, className }))}
42
+ <span
43
+ ref={ref}
44
+ className={cn(badgeVariants({ variant }), className)}
61
45
  {...props}
62
46
  />
63
47
  )
@@ -28,7 +28,7 @@ Breadcrumb.displayName = "Breadcrumb"
28
28
 
29
29
  const BreadcrumbList = React.forwardRef<
30
30
  HTMLOListElement,
31
- React.OListHTMLAttributes<HTMLOListElement>
31
+ React.OlHTMLAttributes<HTMLOListElement>
32
32
  >(({ className, ...props }, ref) => (
33
33
  <ol
34
34
  ref={ref}
@@ -33,15 +33,12 @@ const buttonGroupVariants = cva("inline-flex", {
33
33
  },
34
34
  })
35
35
 
36
- type ButtonGroupVariants = VariantProps<typeof buttonGroupVariants>
37
-
38
- interface ButtonGroupBaseProps extends ButtonGroupVariants {
39
- className?: string
40
- children?: React.ReactNode
41
- }
36
+ interface ButtonGroupProps
37
+ extends React.HTMLAttributes<HTMLDivElement>,
38
+ VariantProps<typeof buttonGroupVariants> { }
42
39
 
43
40
  /**
44
- * Polymorphic ButtonGroup to group buttons together
41
+ * ButtonGroup to group buttons together
45
42
  *
46
43
  * @example
47
44
  * <ButtonGroup>
@@ -49,31 +46,14 @@ interface ButtonGroupBaseProps extends ButtonGroupVariants {
49
46
  * <Button>Center</Button>
50
47
  * <Button>Right</Button>
51
48
  * </ButtonGroup>
52
- *
53
- * @example
54
- * <ButtonGroup attached={false}>
55
- * <Button>Spaced</Button>
56
- * <Button>Buttons</Button>
57
- * </ButtonGroup>
58
49
  */
59
- const ButtonGroup = React.forwardRef(
60
- <T extends React.ElementType = "div">(
61
- {
62
- as,
63
- className,
64
- orientation,
65
- attached,
66
- ...props
67
- }: ButtonGroupBaseProps & { as?: T } & Omit<React.ComponentPropsWithoutRef<T>, keyof ButtonGroupBaseProps | "as">,
68
- ref: React.ForwardedRef<React.ElementRef<T>>
69
- ) => {
70
- const Comp = as || "div"
71
-
50
+ const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(
51
+ ({ className, orientation, attached, ...props }, ref) => {
72
52
  return (
73
- <Comp
74
- ref={ref as any}
53
+ <div
54
+ ref={ref}
75
55
  role="group"
76
- className={cn(buttonGroupVariants({ orientation, attached, className }))}
56
+ className={cn(buttonGroupVariants({ orientation, attached }), className)}
77
57
  {...props}
78
58
  />
79
59
  )
@@ -32,68 +32,42 @@ const buttonVariants = cva(
32
32
  }
33
33
  )
34
34
 
35
- type ButtonVariants = VariantProps<typeof buttonVariants>
36
-
37
- interface ButtonBaseProps extends ButtonVariants {
38
- className?: string
39
- children?: React.ReactNode
35
+ interface ButtonProps
36
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
37
+ VariantProps<typeof buttonVariants> {
38
+ asChild?: boolean
40
39
  }
41
40
 
42
41
  /**
43
- * Polymorphic Button component
42
+ * Button component
44
43
  *
45
44
  * @example
46
- * // As a button (default)
45
+ * // Default button
47
46
  * <Button variant="outline">Click me</Button>
48
47
  *
49
- * // As a link
50
- * <Button as="a" href="/home" variant="link">Go Home</Button>
51
- *
52
48
  * // With loading state
53
49
  * <Button disabled>
54
50
  * <LoadingSpinner /> Processing...
55
51
  * </Button>
56
52
  */
57
- const Button = React.forwardRef(
58
- <T extends React.ElementType = "button">(
59
- {
60
- as,
61
- className,
62
- variant,
63
- size,
64
- ...props
65
- }: ButtonBaseProps & { as?: T } & Omit<React.ComponentPropsWithoutRef<T>, keyof ButtonBaseProps | "as">,
66
- ref: React.ForwardedRef<React.ElementRef<T>>
67
- ) => {
68
- const Comp = as || "button"
69
-
70
- // Ensure proper keyboard handling for non-button elements
71
- const handleKeyDown = (e: React.KeyboardEvent) => {
72
- if (Comp !== "button" && (e.key === "Enter" || e.key === " ")) {
73
- e.preventDefault()
74
- ; (e.currentTarget as HTMLElement).click()
75
- }
76
- // Call original onKeyDown if provided
77
- const originalOnKeyDown = (props as any).onKeyDown
78
- if (originalOnKeyDown) {
79
- originalOnKeyDown(e)
80
- }
53
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
54
+ ({ className, variant, size, asChild = false, children, ...props }, ref) => {
55
+ if (asChild && React.isValidElement(children)) {
56
+ return React.cloneElement(children as React.ReactElement<any>, {
57
+ ref,
58
+ className: cn(buttonVariants({ variant, size }), className),
59
+ ...props,
60
+ })
81
61
  }
82
62
 
83
- // Add role="button" for non-button elements
84
- const accessibilityProps = Comp !== "button" ? {
85
- role: "button",
86
- tabIndex: 0,
87
- onKeyDown: handleKeyDown,
88
- } : {}
89
-
90
63
  return (
91
- <Comp
92
- ref={ref as any}
93
- className={cn(buttonVariants({ variant, size, className }))}
94
- {...accessibilityProps}
64
+ <button
65
+ ref={ref}
66
+ className={cn(buttonVariants({ variant, size }), className)}
95
67
  {...props}
96
- />
68
+ >
69
+ {children}
70
+ </button>
97
71
  )
98
72
  }
99
73
  )