@lobehub/ui 2.8.1 → 2.8.2
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.
|
@@ -9,11 +9,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
10
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
+
import { cva } from 'class-variance-authority';
|
|
12
13
|
import { memo, useMemo } from 'react';
|
|
13
14
|
import Avatar from "../Avatar";
|
|
14
15
|
import Block from "../Block";
|
|
15
16
|
import Grid from "../Grid";
|
|
16
|
-
import { getSmoothCornersMaskStyle } from "../utils/smoothCorners";
|
|
17
17
|
import { useStyles } from "./style";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
19
|
var GroupAvatar = /*#__PURE__*/memo(function (_ref) {
|
|
@@ -31,9 +31,6 @@ var GroupAvatar = /*#__PURE__*/memo(function (_ref) {
|
|
|
31
31
|
var _useStyles = useStyles(),
|
|
32
32
|
cx = _useStyles.cx,
|
|
33
33
|
styles = _useStyles.styles;
|
|
34
|
-
var smoothCornersMask = useMemo(function () {
|
|
35
|
-
return getSmoothCornersMaskStyle(cornerShape);
|
|
36
|
-
}, [cornerShape]);
|
|
37
34
|
var calcSize = useMemo(function () {
|
|
38
35
|
var isCircle = cornerShape === 'circle';
|
|
39
36
|
var avatarSize = Math.floor(size / 2 * (isCircle ? 0.65 : 0.75));
|
|
@@ -45,12 +42,32 @@ var GroupAvatar = /*#__PURE__*/memo(function (_ref) {
|
|
|
45
42
|
maxItemWidth: avatarSize - 1
|
|
46
43
|
};
|
|
47
44
|
}, [size, cornerShape]);
|
|
45
|
+
var variants = useMemo(function () {
|
|
46
|
+
return cva(styles.root, {
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
cornerShape: 'squircle'
|
|
49
|
+
},
|
|
50
|
+
variants: {
|
|
51
|
+
cornerShape: {
|
|
52
|
+
circle: styles.circle,
|
|
53
|
+
ios: styles.ios,
|
|
54
|
+
sharp: styles.sharp,
|
|
55
|
+
smooth: styles.smooth,
|
|
56
|
+
square: styles.square,
|
|
57
|
+
squircle: styles.squircle
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
61
|
+
});
|
|
62
|
+
}, [styles]);
|
|
48
63
|
return /*#__PURE__*/_jsx(Block, _objectSpread(_objectSpread({
|
|
49
64
|
align: 'center',
|
|
50
|
-
className: cx(
|
|
65
|
+
className: cx(variants({
|
|
66
|
+
cornerShape: cornerShape
|
|
67
|
+
}), className),
|
|
51
68
|
height: size,
|
|
52
69
|
justify: 'center',
|
|
53
|
-
style:
|
|
70
|
+
style: style,
|
|
54
71
|
width: size
|
|
55
72
|
}, rest), {}, {
|
|
56
73
|
children: /*#__PURE__*/_jsx(Grid, {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
2
|
+
circle: import("antd-style").SerializedStyles;
|
|
3
|
+
ios: import("antd-style").SerializedStyles;
|
|
2
4
|
root: import("antd-style").SerializedStyles;
|
|
5
|
+
sharp: import("antd-style").SerializedStyles;
|
|
6
|
+
smooth: import("antd-style").SerializedStyles;
|
|
7
|
+
square: import("antd-style").SerializedStyles;
|
|
8
|
+
squircle: import("antd-style").SerializedStyles;
|
|
3
9
|
}>;
|
package/es/GroupAvatar/style.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
var _templateObject;
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
|
+
import { SMOOTH_CORNER_MASKS } from "../utils/smoothCorners";
|
|
4
5
|
export var useStyles = createStyles(function (_ref) {
|
|
5
6
|
var css = _ref.css;
|
|
7
|
+
var baseRoot = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n flex: none;\n\n /* Fallback for browsers without mask support */\n border-radius: 15%;\n\n /* Apply smooth corners mask with fallback */\n @supports (mask-image: url('data:image/svg+xml;base64,')) {\n border-radius: 0;\n }\n "])));
|
|
8
|
+
var createCornerVariant = function createCornerVariant(cornerType) {
|
|
9
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /* WebKit prefix for better browser support */\n mask-image: url('", "');\n\n mask-image: url('", "');\n mask-position: center;\n mask-position: center;\n mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n mask-size: 100% 100%;\n mask-size: 100% 100%;\n "])), SMOOTH_CORNER_MASKS[cornerType], SMOOTH_CORNER_MASKS[cornerType]);
|
|
10
|
+
};
|
|
6
11
|
return {
|
|
7
|
-
|
|
12
|
+
circle: createCornerVariant('circle'),
|
|
13
|
+
ios: createCornerVariant('ios'),
|
|
14
|
+
root: baseRoot,
|
|
15
|
+
sharp: createCornerVariant('sharp'),
|
|
16
|
+
smooth: createCornerVariant('smooth'),
|
|
17
|
+
square: createCornerVariant('square'),
|
|
18
|
+
squircle: createCornerVariant('squircle')
|
|
8
19
|
};
|
|
9
20
|
});
|