@firecms/ui 3.0.0-canary.142 → 3.0.0-canary.144
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/components/BooleanSwitchWithLabel.d.ts +4 -1
- package/dist/index.es.js +15 -5
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +15 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Avatar.tsx +34 -21
- package/src/components/BooleanSwitchWithLabel.tsx +12 -4
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@firecms/ui",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.0.0-canary.
|
4
|
+
"version": "3.0.0-canary.144",
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
6
6
|
"funding": {
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
@@ -107,7 +107,7 @@
|
|
107
107
|
"src",
|
108
108
|
"tailwind.config.js"
|
109
109
|
],
|
110
|
-
"gitHead": "
|
110
|
+
"gitHead": "8f862289db623ffd350e61e4ab4a06957ed97bdf",
|
111
111
|
"publishConfig": {
|
112
112
|
"access": "public"
|
113
113
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { useState } from "react";
|
2
2
|
import { cls } from "../util";
|
3
3
|
|
4
4
|
export interface AvatarProps {
|
@@ -19,36 +19,49 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
|
|
19
19
|
style,
|
20
20
|
outerClassName,
|
21
21
|
...props
|
22
|
-
},
|
22
|
+
},
|
23
|
+
ref
|
24
|
+
) => {
|
25
|
+
const [isImageError, setIsImageError] = useState(false);
|
26
|
+
|
27
|
+
const handleImageError = () => {
|
28
|
+
setIsImageError(true);
|
29
|
+
};
|
23
30
|
|
24
31
|
return (
|
25
32
|
<button
|
26
33
|
ref={ref}
|
27
34
|
style={style}
|
28
35
|
{...props}
|
29
|
-
className={cls(
|
36
|
+
className={cls(
|
37
|
+
"rounded-full flex items-center justify-center overflow-hidden",
|
30
38
|
"p-1 hover:bg-slate-200 hover:dark:bg-slate-700 w-12 h-12 min-w-12 min-h-12",
|
31
39
|
outerClassName
|
32
|
-
)}
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
)}
|
41
|
+
>
|
42
|
+
{src && !isImageError ? (
|
43
|
+
<img
|
44
|
+
className={cls(
|
36
45
|
"bg-slate-100 dark:bg-slate-800",
|
37
46
|
"w-full h-full object-cover rounded-full",
|
38
|
-
className
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
className
|
48
|
+
)}
|
49
|
+
src={src}
|
50
|
+
alt={alt}
|
51
|
+
onError={handleImageError}
|
52
|
+
/>
|
53
|
+
) : (
|
54
|
+
<span
|
55
|
+
className={cls(
|
56
|
+
"bg-slate-100 dark:bg-slate-800",
|
57
|
+
"flex items-center justify-center",
|
58
|
+
"w-full h-full py-1.5 text-lg font-medium text-slate-900 dark:text-white rounded-full",
|
59
|
+
className
|
60
|
+
)}
|
61
|
+
>
|
62
|
+
{children}
|
63
|
+
</span>
|
64
|
+
)}
|
52
65
|
</button>
|
53
66
|
);
|
54
67
|
};
|
@@ -15,6 +15,9 @@ export type BooleanSwitchWithLabelProps = BooleanSwitchProps & {
|
|
15
15
|
label?: React.ReactNode,
|
16
16
|
error?: boolean,
|
17
17
|
autoFocus?: boolean,
|
18
|
+
fullWidth?: boolean,
|
19
|
+
className?: string,
|
20
|
+
inputClassName?: string,
|
18
21
|
};
|
19
22
|
|
20
23
|
/**
|
@@ -31,6 +34,9 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
31
34
|
autoFocus,
|
32
35
|
disabled,
|
33
36
|
size,
|
37
|
+
className,
|
38
|
+
fullWidth = true,
|
39
|
+
inputClassName,
|
34
40
|
...props
|
35
41
|
}: BooleanSwitchWithLabelProps) {
|
36
42
|
|
@@ -58,19 +64,21 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
58
64
|
!invisible && fieldBackgroundMixin,
|
59
65
|
!invisible && (disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin),
|
60
66
|
disabled ? "cursor-default" : "cursor-pointer",
|
61
|
-
"rounded-md max-w-full justify-between
|
67
|
+
"rounded-md max-w-full justify-between box-border relative inline-flex items-center",
|
62
68
|
!invisible && focus && !disabled ? focusedClasses : "",
|
63
69
|
error ? "text-red-500 dark:text-red-600" : (focus && !disabled ? "text-primary" : (!disabled ? "text-text-primary dark:text-text-primary-dark" : "text-text-secondary dark:text-text-secondary-dark")),
|
64
70
|
size === "smallest" ? "min-h-[40px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
|
65
71
|
size === "smallest" ? "pl-2" : "pl-4",
|
66
72
|
size === "smallest" ? "pr-4" : "pr-6",
|
67
|
-
position === "end" ? "flex-row-reverse" : "flex-row"
|
73
|
+
position === "end" ? "flex-row-reverse" : "flex-row",
|
74
|
+
fullWidth ? "w-full" : "",
|
75
|
+
className
|
68
76
|
)}
|
69
77
|
onClick={disabled ? undefined : (e) => {
|
70
78
|
if (props.allowIndeterminate) {
|
71
79
|
if (value === null || value === undefined) onValueChange?.(true)
|
72
80
|
else if (value) onValueChange?.(false)
|
73
|
-
else onValueChange?.(null as any);
|
81
|
+
else onValueChange?.(null as any);
|
74
82
|
} else {
|
75
83
|
onValueChange?.(!value);
|
76
84
|
}
|
@@ -82,7 +90,7 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
82
90
|
value={value}
|
83
91
|
ref={refInput}
|
84
92
|
size={size}
|
85
|
-
className={invisible && focus ? focusedClasses : ""}
|
93
|
+
className={cls(invisible && focus ? focusedClasses : "", inputClassName)}
|
86
94
|
disabled={disabled}
|
87
95
|
{...props}
|
88
96
|
/>
|