@beemafrica/ui 0.1.6 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beemafrica/ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Shared Beem UI components built on shadcn/Radix",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -22,6 +22,7 @@
22
22
  "@tanstack/react-table": "^9.1.2",
23
23
  "class-variance-authority": "^0.7.1",
24
24
  "clsx": "^2.1.1",
25
+ "cmdk": "^1.1.1",
25
26
  "lucide-react": "^1.31.0",
26
27
  "next-themes": "^0.4.6",
27
28
  "radix-ui": "^1.6.7",
@@ -1,8 +1,7 @@
1
- import * as React from "react"
1
+ import { cn } from "@beemafrica/ui/lib/utils"
2
2
  import { cva, type VariantProps } from "class-variance-authority"
3
3
  import { Slot } from "radix-ui"
4
-
5
- import { cn } from "@beemafrica/ui/lib/utils"
4
+ import type * as React from "react"
6
5
 
7
6
  const badgeVariants = cva(
8
7
  "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
@@ -0,0 +1,195 @@
1
+ "use client"
2
+
3
+ import {
4
+ Dialog,
5
+ DialogContent,
6
+ DialogDescription,
7
+ DialogHeader,
8
+ DialogTitle,
9
+ } from "@beemafrica/ui/components/dialog"
10
+ import {
11
+ InputGroup,
12
+ InputGroupAddon,
13
+ } from "@beemafrica/ui/components/input-group"
14
+
15
+ import { cn } from "@beemafrica/ui/lib/utils"
16
+ import { Command as CommandPrimitive } from "cmdk"
17
+ import { CheckIcon, SearchIcon } from "lucide-react"
18
+ import type * as React from "react"
19
+
20
+ function Command({
21
+ className,
22
+ ...props
23
+ }: React.ComponentProps<typeof CommandPrimitive>) {
24
+ return (
25
+ <CommandPrimitive
26
+ data-slot="command"
27
+ className={cn(
28
+ "flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",
29
+ className
30
+ )}
31
+ {...props}
32
+ />
33
+ )
34
+ }
35
+
36
+ function CommandDialog({
37
+ title = "Command Palette",
38
+ description = "Search for a command to run...",
39
+ children,
40
+ className,
41
+ showCloseButton = false,
42
+ ...props
43
+ }: React.ComponentProps<typeof Dialog> & {
44
+ title?: string
45
+ description?: string
46
+ className?: string
47
+ showCloseButton?: boolean
48
+ }) {
49
+ return (
50
+ <Dialog {...props}>
51
+ <DialogHeader className="sr-only">
52
+ <DialogTitle>{title}</DialogTitle>
53
+ <DialogDescription>{description}</DialogDescription>
54
+ </DialogHeader>
55
+ <DialogContent
56
+ className={cn(
57
+ "top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",
58
+ className
59
+ )}
60
+ showCloseButton={showCloseButton}
61
+ >
62
+ {children}
63
+ </DialogContent>
64
+ </Dialog>
65
+ )
66
+ }
67
+
68
+ function CommandInput({
69
+ className,
70
+ ...props
71
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
72
+ return (
73
+ <div data-slot="command-input-wrapper" className="p-1 pb-0">
74
+ <InputGroup className="h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:ps-2!">
75
+ <CommandPrimitive.Input
76
+ data-slot="command-input"
77
+ className={cn(
78
+ "w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
79
+ className
80
+ )}
81
+ {...props}
82
+ />
83
+ <InputGroupAddon>
84
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
85
+ </InputGroupAddon>
86
+ </InputGroup>
87
+ </div>
88
+ )
89
+ }
90
+
91
+ function CommandList({
92
+ className,
93
+ ...props
94
+ }: React.ComponentProps<typeof CommandPrimitive.List>) {
95
+ return (
96
+ <CommandPrimitive.List
97
+ data-slot="command-list"
98
+ className={cn(
99
+ "no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
100
+ className
101
+ )}
102
+ {...props}
103
+ />
104
+ )
105
+ }
106
+
107
+ function CommandEmpty({
108
+ className,
109
+ ...props
110
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
111
+ return (
112
+ <CommandPrimitive.Empty
113
+ data-slot="command-empty"
114
+ className={cn("py-6 text-center text-sm", className)}
115
+ {...props}
116
+ />
117
+ )
118
+ }
119
+
120
+ function CommandGroup({
121
+ className,
122
+ ...props
123
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
124
+ return (
125
+ <CommandPrimitive.Group
126
+ data-slot="command-group"
127
+ className={cn(
128
+ "overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",
129
+ className
130
+ )}
131
+ {...props}
132
+ />
133
+ )
134
+ }
135
+
136
+ function CommandSeparator({
137
+ className,
138
+ ...props
139
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
140
+ return (
141
+ <CommandPrimitive.Separator
142
+ data-slot="command-separator"
143
+ className={cn("-mx-1 h-px bg-border", className)}
144
+ {...props}
145
+ />
146
+ )
147
+ }
148
+
149
+ function CommandItem({
150
+ className,
151
+ children,
152
+ ...props
153
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
154
+ return (
155
+ <CommandPrimitive.Item
156
+ data-slot="command-item"
157
+ className={cn(
158
+ "group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",
159
+ className
160
+ )}
161
+ {...props}
162
+ >
163
+ {children}
164
+ <CheckIcon className="ms-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
165
+ </CommandPrimitive.Item>
166
+ )
167
+ }
168
+
169
+ function CommandShortcut({
170
+ className,
171
+ ...props
172
+ }: React.ComponentProps<"span">) {
173
+ return (
174
+ <span
175
+ data-slot="command-shortcut"
176
+ className={cn(
177
+ "ms-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",
178
+ className
179
+ )}
180
+ {...props}
181
+ />
182
+ )
183
+ }
184
+
185
+ export {
186
+ Command,
187
+ CommandDialog,
188
+ CommandEmpty,
189
+ CommandGroup,
190
+ CommandInput,
191
+ CommandItem,
192
+ CommandList,
193
+ CommandSeparator,
194
+ CommandShortcut,
195
+ }
@@ -0,0 +1,155 @@
1
+ "use client"
2
+
3
+ import { Button } from "@beemafrica/ui/components/button"
4
+ import { Input } from "@beemafrica/ui/components/input"
5
+ import { Textarea } from "@beemafrica/ui/components/textarea"
6
+ import { cn } from "@beemafrica/ui/lib/utils"
7
+ import { cva, type VariantProps } from "class-variance-authority"
8
+ import type * as React from "react"
9
+
10
+ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
11
+ return (
12
+ <div
13
+ data-slot="input-group"
14
+ role="group"
15
+ className={cn(
16
+ "group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ )
22
+ }
23
+
24
+ const inputGroupAddonVariants = cva(
25
+ "flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
26
+ {
27
+ variants: {
28
+ align: {
29
+ "inline-start":
30
+ "order-first ps-2 has-[>button]:ms-[-0.3rem] has-[>kbd]:ms-[-0.15rem]",
31
+ "inline-end":
32
+ "order-last pe-2 has-[>button]:me-[-0.3rem] has-[>kbd]:me-[-0.15rem]",
33
+ "block-start":
34
+ "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
35
+ "block-end":
36
+ "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",
37
+ },
38
+ },
39
+ defaultVariants: {
40
+ align: "inline-start",
41
+ },
42
+ }
43
+ )
44
+
45
+ function InputGroupAddon({
46
+ className,
47
+ align = "inline-start",
48
+ ...props
49
+ }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
50
+ return (
51
+ <div
52
+ role="group"
53
+ data-slot="input-group-addon"
54
+ data-align={align}
55
+ className={cn(inputGroupAddonVariants({ align }), className)}
56
+ onClick={(e) => {
57
+ if ((e.target as HTMLElement).closest("button")) {
58
+ return
59
+ }
60
+ e.currentTarget.parentElement?.querySelector("input")?.focus()
61
+ }}
62
+ {...props}
63
+ />
64
+ )
65
+ }
66
+
67
+ const inputGroupButtonVariants = cva(
68
+ "flex items-center gap-2 text-sm shadow-none",
69
+ {
70
+ variants: {
71
+ size: {
72
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
73
+ sm: "",
74
+ "icon-xs":
75
+ "size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
76
+ "icon-sm": "size-8 p-0 has-[>svg]:p-0",
77
+ },
78
+ },
79
+ defaultVariants: {
80
+ size: "xs",
81
+ },
82
+ }
83
+ )
84
+
85
+ function InputGroupButton({
86
+ className,
87
+ type = "button",
88
+ variant = "ghost",
89
+ size = "xs",
90
+ ...props
91
+ }: Omit<React.ComponentProps<typeof Button>, "size"> &
92
+ VariantProps<typeof inputGroupButtonVariants>) {
93
+ return (
94
+ <Button
95
+ type={type}
96
+ data-size={size}
97
+ variant={variant}
98
+ className={cn(inputGroupButtonVariants({ size }), className)}
99
+ {...props}
100
+ />
101
+ )
102
+ }
103
+
104
+ function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
105
+ return (
106
+ <span
107
+ className={cn(
108
+ "flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
109
+ className
110
+ )}
111
+ {...props}
112
+ />
113
+ )
114
+ }
115
+
116
+ function InputGroupInput({
117
+ className,
118
+ ...props
119
+ }: React.ComponentProps<"input">) {
120
+ return (
121
+ <Input
122
+ data-slot="input-group-control"
123
+ className={cn(
124
+ "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
125
+ className
126
+ )}
127
+ {...props}
128
+ />
129
+ )
130
+ }
131
+
132
+ function InputGroupTextarea({
133
+ className,
134
+ ...props
135
+ }: React.ComponentProps<"textarea">) {
136
+ return (
137
+ <Textarea
138
+ data-slot="input-group-control"
139
+ className={cn(
140
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
141
+ className
142
+ )}
143
+ {...props}
144
+ />
145
+ )
146
+ }
147
+
148
+ export {
149
+ InputGroup,
150
+ InputGroupAddon,
151
+ InputGroupButton,
152
+ InputGroupInput,
153
+ InputGroupText,
154
+ InputGroupTextarea,
155
+ }
@@ -1,9 +1,8 @@
1
1
  "use client"
2
2
 
3
- import * as React from "react"
4
- import { RadioGroup as RadioGroupPrimitive } from "radix-ui"
5
-
6
3
  import { cn } from "@beemafrica/ui/lib/utils"
4
+ import { RadioGroup as RadioGroupPrimitive } from "radix-ui"
5
+ import type * as React from "react"
7
6
 
8
7
  function RadioGroup({
9
8
  className,
@@ -1,3 +1,5 @@
1
+ "use client"
2
+
1
3
  import { Avatar, AvatarFallback } from "@beemafrica/ui/components/avatar"
2
4
  import { Button } from "@beemafrica/ui/components/button"
3
5
  import {
@@ -6,20 +8,20 @@ import {
6
8
  CollapsibleTrigger,
7
9
  } from "@beemafrica/ui/components/collapsible"
8
10
  import { cn } from "@beemafrica/ui/lib/utils"
9
- import { ChevronRightIcon } from "lucide-react"
11
+ import { ChevronRightIcon, ExternalLink } from "lucide-react"
10
12
 
11
13
  interface History {
12
14
  label: string
13
15
  value: string
14
16
  }
15
17
  interface TicketProps {
16
- key: number
17
18
  user_initial?: string
18
19
  user_name?: string
19
20
  message?: string
20
21
  time?: string
21
22
  type?: string
22
23
  history?: History[]
24
+ click: () => void
23
25
  }
24
26
 
25
27
  function Ticket({
@@ -29,6 +31,7 @@ function Ticket({
29
31
  message,
30
32
  time,
31
33
  history,
34
+ click,
32
35
  }: TicketProps) {
33
36
  let avatar_background = ""
34
37
  let container_background = ""
@@ -72,42 +75,45 @@ function Ticket({
72
75
  className={cn(
73
76
  container_background,
74
77
  border,
75
- "py-[14px] px-[16px] rounded-[12px] border shadow-sm flex flex-col gap-3"
78
+ "py-[14px] px-[16px] rounded-[12px] border shadow-sm flex flex-col gap-3 cursor-pointer"
76
79
  )}
77
80
  >
78
- <div className="flex flex-row items-center justify-between">
79
- <div className="flex flex-row gap-1.5 items-center">
80
- <Avatar
81
- className={cn(
82
- avatar_background,
83
- "inline-flex size-[30px] select-none items-center justify-center overflow-hidden rounded-full align-middle"
84
- )}
85
- >
86
- <AvatarFallback
81
+ <button type="button" onClick={click} className="w-full text-left">
82
+ <div className="flex flex-row items-center justify-between">
83
+ <div className="flex flex-row gap-1.5 items-center">
84
+ <Avatar
87
85
  className={cn(
88
86
  avatar_background,
89
- "leading-1 flex size-full items-center justify-center text-[12px] text-white font-semibold"
87
+ "inline-flex size-[30px] select-none items-center justify-center overflow-hidden rounded-full align-middle"
90
88
  )}
91
- delayMs={600}
92
89
  >
93
- <p>{user_initial ?? "N/A"}</p>
94
- </AvatarFallback>
95
- </Avatar>
90
+ <AvatarFallback
91
+ className={cn(
92
+ avatar_background,
93
+ "leading-1 flex size-full items-center justify-center text-[12px] text-white font-semibold"
94
+ )}
95
+ delayMs={600}
96
+ >
97
+ <p>{user_initial ?? "N/A"}</p>
98
+ </AvatarFallback>
99
+ </Avatar>
96
100
 
97
- {user_name && <p className="font-bold text-black">{user_name}</p>}
98
- <p
99
- className={cn(
100
- pill_background,
101
- pill_text_color,
102
- "py-[3px] px-[10px] rounded-[9999px] text-xs"
103
- )}
104
- >
105
- {ticket_type}
106
- </p>
107
- </div>
101
+ {user_name && <p className="font-bold text-black">{user_name}</p>}
102
+ <p
103
+ className={cn(
104
+ pill_background,
105
+ pill_text_color,
106
+ "py-[3px] px-[10px] rounded-[9999px] text-xs"
107
+ )}
108
+ >
109
+ {ticket_type}
110
+ </p>
111
+ <ExternalLink size="12px" className="text-[#6B7B8D]" />
112
+ </div>
108
113
 
109
- {time && <p className="text-[#98A9B8] text-[11.5px]">{time} </p>}
110
- </div>
114
+ {time && <p className="text-[#98A9B8] text-[11.5px]">{time} </p>}
115
+ </div>
116
+ </button>
111
117
 
112
118
  {message && <p className="leading-snug">{message}</p>}
113
119
  {history && history.length > 0 && (