@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.
- package/README.md +7 -1
- package/component-meta.json +10 -11
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +104 -56
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +182 -173
- package/dist/index.cjs +1 -1
- package/dist/index.js +128 -124
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +5 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -60
- package/package.json +1 -1
- package/src/blocks/input-list.tsx +341 -233
- package/src/components/list.tsx +32 -21
package/src/components/list.tsx
CHANGED
|
@@ -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-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|