@brightlocal/ui-components 1.4.0 → 1.4.1

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.
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
2
3
  import { cva } from "class-variance-authority";
3
4
 
4
5
  import { cn } from "@brightlocal/ui-components/lib/utils";
@@ -26,7 +27,7 @@ const itemVariants = cva(
26
27
  variant: {
27
28
  filled: ["bg-card"],
28
29
  outline: ["bg-background", "border", "border-border"],
29
- loading: ["flex-col", "gap-2", "px-0", "pt-0", "pb-2"],
30
+ loading: ["flex-col", "gap-2", "px-0", "pt-0", "pb-3"],
30
31
  },
31
32
  },
32
33
  defaultVariants: {
@@ -99,6 +100,11 @@ List.displayName = "List";
99
100
  * Extends native `<li>` props with CVA variant styling and optional testing/analytics attributes.
100
101
  */
101
102
  export type ItemProps = React.ComponentProps<"li"> & {
103
+ /**
104
+ * Render as the child element instead of `<li>`.
105
+ * Useful when the item is wrapped by another element (e.g. `<motion.li>`).
106
+ */
107
+ asChild?: boolean;
102
108
  /**
103
109
  * Visual style of the item row.
104
110
  * - `filled` — card background (default)
@@ -128,6 +134,7 @@ export type ItemProps = React.ComponentProps<"li"> & {
128
134
  const Item = React.forwardRef<HTMLLIElement, ItemProps>(
129
135
  (
130
136
  {
137
+ asChild = false,
131
138
  className,
132
139
  variant,
133
140
  dataHook,
@@ -137,26 +144,30 @@ const Item = React.forwardRef<HTMLLIElement, ItemProps>(
137
144
  ...props
138
145
  },
139
146
  ref
140
- ) => (
141
- <li
142
- ref={ref}
143
- className={cn(itemVariants({ variant }), className)}
144
- data-hook={dataHook}
145
- data-slot="item"
146
- data-tracking-el={trackingEl}
147
- data-tracking-label={trackingLabel}
148
- {...props}
149
- >
150
- {variant === "loading" ? (
151
- <>
152
- <Skeleton className="h-4 w-full" />
153
- <Skeleton className="h-4 w-full" />
154
- </>
155
- ) : (
156
- children
157
- )}
158
- </li>
159
- )
147
+ ) => {
148
+ const Comp = asChild ? Slot : "li";
149
+
150
+ return (
151
+ <Comp
152
+ ref={ref}
153
+ className={cn(itemVariants({ variant }), className)}
154
+ data-hook={dataHook}
155
+ data-slot="item"
156
+ data-tracking-el={trackingEl}
157
+ data-tracking-label={trackingLabel}
158
+ {...props}
159
+ >
160
+ {variant === "loading" ? (
161
+ <>
162
+ <Skeleton className="h-4 w-full" />
163
+ <Skeleton className="h-4 w-full" />
164
+ </>
165
+ ) : (
166
+ children
167
+ )}
168
+ </Comp>
169
+ );
170
+ }
160
171
  );
161
172
  Item.displayName = "Item";
162
173