@lobehub/ui 2.7.4 → 2.8.0

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.
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { GroupAvatarProps } from './type';
3
+ declare const GroupAvatar: import("react").NamedExoticComponent<GroupAvatarProps>;
4
+ export default GroupAvatar;
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ var _excluded = ["className", "style", "avatars", "size", "smoothCornerType"];
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ 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
+ 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 { memo, useMemo } from 'react';
13
+ import Avatar from "../Avatar";
14
+ import Block from "../Block";
15
+ import Grid from "../Grid";
16
+ import { getSmoothCornersMaskStyle } from "../utils/smoothCorners";
17
+ import { useStyles } from "./style";
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ var GroupAvatar = /*#__PURE__*/memo(function (_ref) {
20
+ var className = _ref.className,
21
+ style = _ref.style,
22
+ _ref$avatars = _ref.avatars,
23
+ avatars = _ref$avatars === void 0 ? [] : _ref$avatars,
24
+ _ref$size = _ref.size,
25
+ size = _ref$size === void 0 ? 32 : _ref$size,
26
+ _ref$smoothCornerType = _ref.smoothCornerType,
27
+ smoothCornerType = _ref$smoothCornerType === void 0 ? 'squircle' : _ref$smoothCornerType,
28
+ rest = _objectWithoutProperties(_ref, _excluded);
29
+ var _useStyles = useStyles(),
30
+ cx = _useStyles.cx,
31
+ styles = _useStyles.styles;
32
+ var smoothCornersMask = useMemo(function () {
33
+ return getSmoothCornersMaskStyle(smoothCornerType);
34
+ }, [smoothCornerType]);
35
+ var calcSize = useMemo(function () {
36
+ var avatarSize = Math.floor(size / 2 * 0.75);
37
+ var gapSize = Math.floor((size - avatarSize * 2) / 4);
38
+ return {
39
+ avatarSize: avatarSize,
40
+ gapSize: gapSize,
41
+ gridWidth: avatarSize * 2 + gapSize,
42
+ maxItemWidth: avatarSize - 1
43
+ };
44
+ }, [size]);
45
+ return /*#__PURE__*/_jsx(Block, _objectSpread(_objectSpread({
46
+ align: 'center',
47
+ className: cx(styles.root, className),
48
+ height: size,
49
+ justify: 'center',
50
+ style: _objectSpread(_objectSpread({}, smoothCornersMask), style),
51
+ width: size
52
+ }, rest), {}, {
53
+ children: /*#__PURE__*/_jsx(Grid, {
54
+ gap: calcSize.gapSize,
55
+ maxItemWidth: calcSize.maxItemWidth,
56
+ rows: 2,
57
+ width: calcSize.gridWidth,
58
+ children: avatars === null || avatars === void 0 ? void 0 : avatars.slice(0, 4).map(function (item, index) {
59
+ if (typeof item === 'string') {
60
+ return /*#__PURE__*/_jsx(Avatar, {
61
+ avatar: item,
62
+ size: calcSize.avatarSize
63
+ }, index);
64
+ }
65
+ return /*#__PURE__*/_jsx(Avatar, _objectSpread(_objectSpread({}, item), {}, {
66
+ size: calcSize.avatarSize
67
+ }), index);
68
+ })
69
+ })
70
+ }));
71
+ });
72
+ export default GroupAvatar;
@@ -0,0 +1,2 @@
1
+ export { default } from './GroupAvatar';
2
+ export type * from './type';
@@ -0,0 +1 @@
1
+ export { default } from "./GroupAvatar";
@@ -0,0 +1,3 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ root: import("antd-style").SerializedStyles;
3
+ }>;
@@ -0,0 +1,9 @@
1
+ var _templateObject;
2
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css;
6
+ return {
7
+ root: 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 /* The mask will be applied via inline style */\n }\n "])))
8
+ };
9
+ });
@@ -0,0 +1,12 @@
1
+ import type { Ref } from 'react';
2
+ import type { AvatarProps } from "../Avatar/type";
3
+ import type { BlockProps } from "../Block/type";
4
+ import type { SMOOTH_CORNER_MASKS } from "../utils/smoothCorners";
5
+ type AvatarItem = string | Omit<AvatarProps, 'size'>;
6
+ export interface GroupAvatarProps extends Omit<BlockProps, 'width' | 'height' | 'variant'> {
7
+ avatars?: AvatarItem[];
8
+ ref?: Ref<HTMLDivElement>;
9
+ size?: number;
10
+ smoothCornerType?: keyof typeof SMOOTH_CORNER_MASKS;
11
+ }
12
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/es/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export { default as Footer, type FooterProps } from './Footer';
25
25
  export { default as Form, FormGroup, type FormGroupItemType, type FormGroupProps, type FormInstance, FormItem, type FormItemProps, type FormProps, FormSubmitFooter, type FormSubmitFooterProps, FormTitle, type FormTitleProps, } from './Form';
26
26
  export { default as FormModal, type FormModalProps } from './FormModal';
27
27
  export { default as Grid, type GridProps } from './Grid';
28
+ export { default as GroupAvatar, type GroupAvatarProps } from './GroupAvatar';
28
29
  export { default as GuideCard, type GuideCardProps } from './GuideCard';
29
30
  export { default as Header, type HeaderProps } from './Header';
30
31
  export { default as Highlighter, type HighlighterProps, highlighterThemes, SyntaxHighlighter, type SyntaxHighlighterProps, } from './Highlighter';
package/es/index.js CHANGED
@@ -25,6 +25,7 @@ export { default as Footer } from "./Footer";
25
25
  export { default as Form, FormGroup, FormItem, FormSubmitFooter, FormTitle } from "./Form";
26
26
  export { default as FormModal } from "./FormModal";
27
27
  export { default as Grid } from "./Grid";
28
+ export { default as GroupAvatar } from "./GroupAvatar";
28
29
  export { default as GuideCard } from "./GuideCard";
29
30
  export { default as Header } from "./Header";
30
31
  export { default as Highlighter, highlighterThemes, SyntaxHighlighter } from "./Highlighter";
@@ -0,0 +1,22 @@
1
+ import type { CSSProperties } from 'react';
2
+ /**
3
+ * Create a Base64 encoded SVG mask for smooth corners
4
+ * @param options - Configuration options
5
+ */
6
+ export declare const createSmoothCornersMask: (options?: {
7
+ cornerValue?: number;
8
+ size?: number;
9
+ }) => string;
10
+ /**
11
+ * Predefined smooth corners masks for common corner values
12
+ */
13
+ export declare const SMOOTH_CORNER_MASKS: {
14
+ readonly ios: string;
15
+ readonly sharp: string;
16
+ readonly smooth: string;
17
+ readonly squircle: string;
18
+ };
19
+ /**
20
+ * CSS helper to apply smooth corners mask
21
+ */
22
+ export declare const getSmoothCornersMaskStyle: (cornerType?: keyof typeof SMOOTH_CORNER_MASKS) => CSSProperties;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Smooth Corners utility using Base64 SVG mask
3
+ * A simpler alternative to CSS Houdini Paint API
4
+ */
5
+
6
+ /**
7
+ * Generate a smooth corners SVG path using superellipse formula
8
+ * @param size - The size of the shape
9
+ * @param n - The superellipse exponent (4 = squircle, 5 = iOS style)
10
+ */
11
+ var generateSuperellipsePath = function generateSuperellipsePath(size) {
12
+ var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
13
+ var r = size / 2;
14
+ var points = [];
15
+
16
+ // Generate points for the superellipse
17
+ for (var i = 0; i <= 360; i += 2) {
18
+ var angle = i * Math.PI / 180;
19
+ var cosAngle = Math.cos(angle);
20
+ var sinAngle = Math.sin(angle);
21
+
22
+ // Superellipse formula
23
+ var x = r * Math.sign(cosAngle) * Math.pow(Math.abs(cosAngle), 2 / n);
24
+ var y = r * Math.sign(sinAngle) * Math.pow(Math.abs(sinAngle), 2 / n);
25
+ points.push("".concat(r + x, ",").concat(r + y));
26
+ }
27
+ return "M".concat(points[0], "L").concat(points.slice(1).join('L'), "Z");
28
+ };
29
+
30
+ /**
31
+ * Create a Base64 encoded SVG mask for smooth corners
32
+ * @param options - Configuration options
33
+ */
34
+ export var createSmoothCornersMask = function createSmoothCornersMask() {
35
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
+ var _options$size = options.size,
37
+ size = _options$size === void 0 ? 100 : _options$size,
38
+ _options$cornerValue = options.cornerValue,
39
+ cornerValue = _options$cornerValue === void 0 ? 4 : _options$cornerValue;
40
+ var path = generateSuperellipsePath(size, cornerValue);
41
+ var svg = "\n <svg width=\"".concat(size, "\" height=\"").concat(size, "\" viewBox=\"0 0 ").concat(size, " ").concat(size, "\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"").concat(path, "\" fill=\"white\"/>\n </svg>\n ").trim().replaceAll(/\s+/g, ' ');
42
+ return "data:image/svg+xml;base64,".concat(btoa(svg));
43
+ };
44
+
45
+ /**
46
+ * Predefined smooth corners masks for common corner values
47
+ */
48
+ export var SMOOTH_CORNER_MASKS = {
49
+ // n=4, classic squircle
50
+ ios: createSmoothCornersMask({
51
+ cornerValue: 5
52
+ }),
53
+ // n=3, more rounded
54
+ sharp: createSmoothCornersMask({
55
+ cornerValue: 6
56
+ }),
57
+ // n=5, iOS style
58
+ smooth: createSmoothCornersMask({
59
+ cornerValue: 3
60
+ }),
61
+ squircle: createSmoothCornersMask({
62
+ cornerValue: 4
63
+ }) // n=6, less rounded
64
+ };
65
+
66
+ /**
67
+ * CSS helper to apply smooth corners mask
68
+ */
69
+ export var getSmoothCornersMaskStyle = function getSmoothCornersMaskStyle() {
70
+ var cornerType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'squircle';
71
+ return {
72
+ // WebKit prefix for better browser support
73
+ WebkitMaskImage: "url(\"".concat(SMOOTH_CORNER_MASKS[cornerType], "\")"),
74
+ WebkitMaskPosition: 'center',
75
+ WebkitMaskRepeat: 'no-repeat',
76
+ WebkitMaskSize: '100% 100%',
77
+ maskImage: "url(\"".concat(SMOOTH_CORNER_MASKS[cornerType], "\")"),
78
+ maskPosition: 'center',
79
+ maskRepeat: 'no-repeat',
80
+ maskSize: '100% 100%'
81
+ };
82
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.7.4",
3
+ "version": "2.8.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -45,48 +45,48 @@
45
45
  "icons.js"
46
46
  ],
47
47
  "dependencies": {
48
- "@ant-design/cssinjs": "^1.23.0",
48
+ "@ant-design/cssinjs": "^1.24.0",
49
49
  "@dnd-kit/core": "^6.3.1",
50
50
  "@dnd-kit/modifiers": "^9.0.0",
51
51
  "@dnd-kit/sortable": "^10.0.0",
52
52
  "@dnd-kit/utilities": "^3.2.2",
53
53
  "@emoji-mart/data": "^1.2.1",
54
54
  "@emoji-mart/react": "^1.1.1",
55
- "@floating-ui/react": "^0.27.5",
55
+ "@floating-ui/react": "^0.27.14",
56
56
  "@giscus/react": "^3.1.0",
57
57
  "@lobehub/fluent-emoji": "^2.0.0",
58
- "@lobehub/icons": "^2.0.0",
58
+ "@lobehub/icons": "^2.19.0",
59
59
  "@mdx-js/mdx": "^3.1.0",
60
60
  "@mdx-js/react": "^3.1.0",
61
- "@radix-ui/react-slot": "^1.1.2",
62
- "@shikijs/transformers": "^3.2.1",
61
+ "@radix-ui/react-slot": "^1.2.3",
62
+ "@shikijs/transformers": "^3.8.1",
63
63
  "@splinetool/runtime": "0.9.526",
64
- "ahooks": "^3.8.4",
64
+ "ahooks": "^3.9.0",
65
65
  "antd-style": "^3.7.1",
66
66
  "chroma-js": "^3.1.2",
67
67
  "class-variance-authority": "^0.7.1",
68
68
  "dayjs": "^1.11.13",
69
69
  "emoji-mart": "^5.6.0",
70
70
  "fast-deep-equal": "^3.1.3",
71
- "framer-motion": "^12.6.3",
71
+ "framer-motion": "^12.23.11",
72
72
  "immer": "^10.1.1",
73
- "katex": "^0.16.9",
73
+ "katex": "^0.16.22",
74
74
  "leva": "^0.10.0",
75
75
  "lodash-es": "^4.17.21",
76
76
  "lucide-react": "^0.525.0",
77
- "mermaid": "^11.6.0",
77
+ "mermaid": "^11.9.0",
78
78
  "numeral": "^2.0.6",
79
79
  "polished": "^4.3.1",
80
- "query-string": "^9.1.1",
80
+ "query-string": "^9.2.2",
81
81
  "rc-collapse": "^4.0.0",
82
82
  "rc-footer": "^0.6.8",
83
- "rc-image": "^7.11.1",
83
+ "rc-image": "^7.12.0",
84
84
  "rc-menu": "^9.16.1",
85
85
  "re-resizable": "^6.11.2",
86
86
  "react-avatar-editor": "^13.0.2",
87
87
  "react-error-boundary": "^5.0.0",
88
88
  "react-hotkeys-hook": "^5.1.0",
89
- "react-layout-kit": "^1.9.2",
89
+ "react-layout-kit": "^2.0.0",
90
90
  "react-markdown": "^10.1.0",
91
91
  "react-merge-refs": "^3.0.2",
92
92
  "react-rnd": "^10.5.2",
@@ -98,8 +98,8 @@
98
98
  "remark-gfm": "^4.0.1",
99
99
  "remark-github": "^12.0.0",
100
100
  "remark-math": "^6.0.0",
101
- "shiki": "^3.2.1",
102
- "swr": "^2.3.3",
101
+ "shiki": "^3.8.1",
102
+ "swr": "^2.3.4",
103
103
  "ts-md5": "^1.3.1",
104
104
  "unified": "^11.0.5",
105
105
  "url-join": "^5.0.0",