@popgrids/ui 0.0.34 → 0.0.35
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/avatar.cjs +71 -12
- package/dist/avatar.cjs.map +1 -1
- package/dist/avatar.d.cts +5 -3
- package/dist/avatar.d.ts +5 -3
- package/dist/avatar.js +71 -12
- package/dist/avatar.js.map +1 -1
- package/dist/index.cjs +71 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -12
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Avatar as Avatar$1 } from '@base-ui/react/avatar';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
3
4
|
import { clsx } from 'clsx';
|
|
4
5
|
import { twMerge } from 'tailwind-merge';
|
|
5
6
|
import { mergeProps } from '@base-ui/react/merge-props';
|
|
@@ -88,8 +89,59 @@ var avatarVariants = cva(
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
);
|
|
91
|
-
function
|
|
92
|
-
|
|
92
|
+
function fnv1a32(data) {
|
|
93
|
+
const bytes = new TextEncoder().encode(data);
|
|
94
|
+
let h = 2166136261;
|
|
95
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
96
|
+
h ^= bytes[i];
|
|
97
|
+
h = Math.imul(h, 16777619);
|
|
98
|
+
}
|
|
99
|
+
return h >>> 0;
|
|
100
|
+
}
|
|
101
|
+
var BACKGROUND_COLORS = [
|
|
102
|
+
"#DDD0BE",
|
|
103
|
+
"#E9DCBB",
|
|
104
|
+
"#E9DCBB",
|
|
105
|
+
"#C7D1B0",
|
|
106
|
+
"#C6D0CB",
|
|
107
|
+
"#E9DCBB",
|
|
108
|
+
"#C7D1B0",
|
|
109
|
+
"#E9DCBB",
|
|
110
|
+
"#DFC2C0",
|
|
111
|
+
"#CFD4C6",
|
|
112
|
+
"#D7E3E8",
|
|
113
|
+
"#CFD4C6",
|
|
114
|
+
"#D6B3B3",
|
|
115
|
+
"#E9DCBB",
|
|
116
|
+
"#CFCBDC",
|
|
117
|
+
"#BFD6D7",
|
|
118
|
+
"#E3D2C6",
|
|
119
|
+
"#D1E2E7",
|
|
120
|
+
"#D6B3B3",
|
|
121
|
+
"#BFD6D7",
|
|
122
|
+
"#E9DCBB",
|
|
123
|
+
"#C7D1B0",
|
|
124
|
+
"#DFC2C0",
|
|
125
|
+
"#D1E2E7",
|
|
126
|
+
"#CFD4C6",
|
|
127
|
+
"#E9DCBB",
|
|
128
|
+
"#D7E3E8",
|
|
129
|
+
"#CFD4C6",
|
|
130
|
+
"#C6D0CB",
|
|
131
|
+
"#E9DCBB",
|
|
132
|
+
"#C7D1B0",
|
|
133
|
+
"#E9DCBB",
|
|
134
|
+
"#CFCBDC",
|
|
135
|
+
"#E3D2C6",
|
|
136
|
+
"#E9DCBB"
|
|
137
|
+
];
|
|
138
|
+
function backgroundColor(id) {
|
|
139
|
+
return BACKGROUND_COLORS[fnv1a32(id) % BACKGROUND_COLORS.length];
|
|
140
|
+
}
|
|
141
|
+
var AvatarColorContext = createContext(void 0);
|
|
142
|
+
function Avatar({ className = "", size = "md", colorKey, ...props }) {
|
|
143
|
+
const resolvedColor = colorKey ? backgroundColor(colorKey) : void 0;
|
|
144
|
+
return /* @__PURE__ */ jsx(AvatarColorContext.Provider, { value: resolvedColor, children: /* @__PURE__ */ jsx(
|
|
93
145
|
Avatar$1.Root,
|
|
94
146
|
{
|
|
95
147
|
"data-slot": "avatar",
|
|
@@ -97,25 +149,31 @@ function Avatar({ className = "", size = "md", ...props }) {
|
|
|
97
149
|
className: cn(avatarVariants({ size }), className),
|
|
98
150
|
...props
|
|
99
151
|
}
|
|
100
|
-
);
|
|
152
|
+
) });
|
|
101
153
|
}
|
|
102
|
-
function AvatarImage({ className = "", ...props }) {
|
|
154
|
+
function AvatarImage({ className = "", style, ...props }) {
|
|
155
|
+
const resolvedColor = useContext(AvatarColorContext);
|
|
156
|
+
const mergedStyle = resolvedColor ? { ...style, backgroundColor: resolvedColor } : style;
|
|
103
157
|
return /* @__PURE__ */ jsx(
|
|
104
158
|
Avatar$1.Image,
|
|
105
159
|
{
|
|
106
160
|
"data-slot": "avatar-image",
|
|
107
|
-
className: cn("aspect-square size-full
|
|
108
|
-
...props
|
|
161
|
+
className: cn("mask mask-squircle aspect-square size-full object-cover", className),
|
|
162
|
+
...props,
|
|
163
|
+
style: mergedStyle
|
|
109
164
|
}
|
|
110
165
|
);
|
|
111
166
|
}
|
|
112
|
-
function AvatarFallback({ className = "", ...props }) {
|
|
167
|
+
function AvatarFallback({ className = "", style, ...props }) {
|
|
168
|
+
const resolvedColor = useContext(AvatarColorContext);
|
|
169
|
+
const mergedStyle = resolvedColor ? { ...style, backgroundColor: resolvedColor } : style;
|
|
113
170
|
return /* @__PURE__ */ jsx(
|
|
114
171
|
Avatar$1.Fallback,
|
|
115
172
|
{
|
|
116
173
|
"data-slot": "avatar-fallback",
|
|
117
174
|
className: cn(
|
|
118
|
-
"mask mask-squircle flex size-full items-center justify-center
|
|
175
|
+
"mask mask-squircle text-muted-foreground flex size-full items-center justify-center text-sm group-data-[size=sm]/avatar:text-xs",
|
|
176
|
+
resolvedColor ? void 0 : "bg-muted",
|
|
119
177
|
"group-data-[size=xs]/avatar:text-xs",
|
|
120
178
|
"group-data-[size=sm]/avatar:text-sm",
|
|
121
179
|
"group-data-[size=md]/avatar:text-lg",
|
|
@@ -124,7 +182,8 @@ function AvatarFallback({ className = "", ...props }) {
|
|
|
124
182
|
"group-data-[size=xxl]/avatar:text-5xl",
|
|
125
183
|
className
|
|
126
184
|
),
|
|
127
|
-
...props
|
|
185
|
+
...props,
|
|
186
|
+
style: mergedStyle
|
|
128
187
|
}
|
|
129
188
|
);
|
|
130
189
|
}
|
|
@@ -134,7 +193,7 @@ function AvatarBadge({ className = "", ...props }) {
|
|
|
134
193
|
{
|
|
135
194
|
"data-slot": "avatar-badge",
|
|
136
195
|
className: cn(
|
|
137
|
-
"absolute h-[18px] min-w-[18px]
|
|
196
|
+
"absolute z-10 h-[18px] min-w-[18px] select-none",
|
|
138
197
|
"leading-none",
|
|
139
198
|
"group-data-[size=xs]/avatar:right-[-4px] group-data-[size=xs]/avatar:bottom-[-4px]",
|
|
140
199
|
"group-data-[size=sm]/avatar:right-[-4px] group-data-[size=sm]/avatar:bottom-[-4px]",
|
|
@@ -154,7 +213,7 @@ function AvatarGroup({ className = "", ...props }) {
|
|
|
154
213
|
{
|
|
155
214
|
"data-slot": "avatar-group",
|
|
156
215
|
className: cn(
|
|
157
|
-
"group/avatar-group
|
|
216
|
+
"group/avatar-group *:data-[slot=avatar]:ring-background flex -space-x-2 *:data-[slot=avatar]:ring-2",
|
|
158
217
|
className
|
|
159
218
|
),
|
|
160
219
|
...props
|
|
@@ -167,7 +226,7 @@ function AvatarGroupCount({ className = "", ...props }) {
|
|
|
167
226
|
{
|
|
168
227
|
"data-slot": "avatar-group-count",
|
|
169
228
|
className: cn(
|
|
170
|
-
"relative flex size-8 shrink-0 items-center justify-center rounded-full
|
|
229
|
+
"bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
|
|
171
230
|
className
|
|
172
231
|
),
|
|
173
232
|
...props
|