@akinon/ui-avatar 0.3.0 → 0.5.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.
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +41 -3
- package/dist/cjs/types.d.ts +55 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +40 -3
- package/dist/esm/types.d.ts +55 -0
- package/package.json +5 -10
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AvatarProps as AntAvatarProps } from 'antd';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
export declare const Avatar: ({ ...restAvatarProps }: AvatarProps) => React.JSX.Element;
|
|
2
|
+
import type { AvatarGroupProps, AvatarProps } from './types';
|
|
3
|
+
export declare const Avatar: ({ shape, ...restAvatarProps }: AvatarProps) => React.JSX.Element;
|
|
4
|
+
export declare const AvatarGroup: ({ maxPopoverPlacement, maxPopoverTrigger, shape, children, ...restAvatarProps }: AvatarGroupProps) => React.JSX.Element;
|
|
5
|
+
export type { AvatarGroupProps, AvatarProps };
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE7D,eAAO,MAAM,MAAM,kCAGhB,WAAW,sBA2Bb,CAAC;AAEF,eAAO,MAAM,WAAW,oFAMrB,gBAAgB,sBAkClB,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -11,11 +11,49 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Avatar = void 0;
|
|
14
|
+
exports.AvatarGroup = exports.Avatar = void 0;
|
|
15
|
+
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
|
+
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
15
17
|
const antd_1 = require("antd");
|
|
16
18
|
const React = require("react");
|
|
17
19
|
const Avatar = (_a) => {
|
|
18
|
-
var restAvatarProps = __rest(_a, []);
|
|
19
|
-
|
|
20
|
+
var { shape = 'circle' } = _a, restAvatarProps = __rest(_a, ["shape"]);
|
|
21
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
22
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
23
|
+
//const avatarToken = (token as GlobalToken).Avatar;
|
|
24
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
25
|
+
token: token,
|
|
26
|
+
path: ['Avatar'],
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
theme: theme
|
|
29
|
+
}, () => {
|
|
30
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-avatar`;
|
|
31
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-avatar`;
|
|
32
|
+
return {
|
|
33
|
+
[prefixCls]: {},
|
|
34
|
+
[prefixClsWithoutHash]: {}
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return useStyle(React.createElement(antd_1.Avatar, Object.assign({ shape: shape }, restAvatarProps)));
|
|
20
38
|
};
|
|
21
39
|
exports.Avatar = Avatar;
|
|
40
|
+
const AvatarGroup = (_a) => {
|
|
41
|
+
var { maxPopoverPlacement = 'top', maxPopoverTrigger = 'hover', shape = 'circle', children } = _a, restAvatarProps = __rest(_a, ["maxPopoverPlacement", "maxPopoverTrigger", "shape", "children"]);
|
|
42
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
43
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
44
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
45
|
+
token: token,
|
|
46
|
+
path: ['AvatarGroup'],
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
theme: theme
|
|
49
|
+
}, () => {
|
|
50
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-avatarGroup`;
|
|
51
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-avatarGroup`;
|
|
52
|
+
return {
|
|
53
|
+
[prefixCls]: {},
|
|
54
|
+
[prefixClsWithoutHash]: {}
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
return useStyle(React.createElement(antd_1.Avatar.Group, Object.assign({ maxPopoverPlacement: maxPopoverPlacement, maxPopoverTrigger: maxPopoverTrigger, shape: shape }, restAvatarProps), children));
|
|
58
|
+
};
|
|
59
|
+
exports.AvatarGroup = AvatarGroup;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
2
|
+
type ScreenSizeMap = Partial<Record<Breakpoint, number>>;
|
|
3
|
+
|
|
4
|
+
type AvatarSize = 'large' | 'small' | 'default' | number | ScreenSizeMap;
|
|
5
|
+
|
|
6
|
+
export interface AvatarProps {
|
|
7
|
+
/** The shape of avatar */
|
|
8
|
+
shape?: 'circle' | 'square';
|
|
9
|
+
/** The size of the avatar */
|
|
10
|
+
size?: AvatarSize;
|
|
11
|
+
/** Letter type unit distance between left and right sides */
|
|
12
|
+
gap?: number;
|
|
13
|
+
/** The address of the image for an image avatar or image element */
|
|
14
|
+
src?: React.ReactNode | string;
|
|
15
|
+
/** A list of sources to use for different screen resolutions */
|
|
16
|
+
srcSet?: string;
|
|
17
|
+
/** Whether the picture is allowed to be dragged */
|
|
18
|
+
draggable?: boolean | 'true' | 'false';
|
|
19
|
+
/** Custom icon type for an icon avatar */
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
/** Additional CSS class name */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Additional CSS class name for the root element */
|
|
24
|
+
rootClassName?: string;
|
|
25
|
+
/** The content of the avatar */
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/** This attribute defines the alternative text describing the image */
|
|
28
|
+
alt?: string;
|
|
29
|
+
/** CORS settings attributes */
|
|
30
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
31
|
+
onClick?: (e?: React.MouseEvent<HTMLElement>) => void;
|
|
32
|
+
/** Handler when img load error, return false to prevent default fallback behavior */
|
|
33
|
+
onError?: () => boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AvatarGroupProps {
|
|
37
|
+
/** Additional CSS class name */
|
|
38
|
+
className?: string;
|
|
39
|
+
/** Additional CSS class name for the root element */
|
|
40
|
+
rootClassName?: string;
|
|
41
|
+
/** The content of the avatar group */
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
/** Maximum number of avatars to display before collapsing */
|
|
44
|
+
maxCount?: number;
|
|
45
|
+
/** Additional CSS styles for the maximum number of avatars */
|
|
46
|
+
maxStyle?: React.CSSProperties;
|
|
47
|
+
/** Placement of the popover for the maximum number of avatars */
|
|
48
|
+
maxPopoverPlacement?: 'top' | 'bottom';
|
|
49
|
+
/** Trigger type for the popover of the maximum number of avatars */
|
|
50
|
+
maxPopoverTrigger?: 'hover' | 'focus' | 'click';
|
|
51
|
+
/** Size of the avatars in the group */
|
|
52
|
+
size?: AvatarSize;
|
|
53
|
+
/** Shape of the avatars in the group */
|
|
54
|
+
shape?: 'circle' | 'square';
|
|
55
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AvatarProps as AntAvatarProps } from 'antd';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
export declare const Avatar: ({ ...restAvatarProps }: AvatarProps) => React.JSX.Element;
|
|
2
|
+
import type { AvatarGroupProps, AvatarProps } from './types';
|
|
3
|
+
export declare const Avatar: ({ shape, ...restAvatarProps }: AvatarProps) => React.JSX.Element;
|
|
4
|
+
export declare const AvatarGroup: ({ maxPopoverPlacement, maxPopoverTrigger, shape, children, ...restAvatarProps }: AvatarGroupProps) => React.JSX.Element;
|
|
5
|
+
export type { AvatarGroupProps, AvatarProps };
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE7D,eAAO,MAAM,MAAM,kCAGhB,WAAW,sBA2Bb,CAAC;AAEF,eAAO,MAAM,WAAW,oFAMrB,gBAAgB,sBAkClB,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,9 +9,46 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { useToken } from '@akinon/ui-theme';
|
|
13
|
+
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
|
+
import { Avatar as AntAvatar, ConfigProvider } from 'antd';
|
|
13
15
|
import * as React from 'react';
|
|
14
16
|
export const Avatar = (_a) => {
|
|
15
|
-
var restAvatarProps = __rest(_a, []);
|
|
16
|
-
|
|
17
|
+
var { shape = 'circle' } = _a, restAvatarProps = __rest(_a, ["shape"]);
|
|
18
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
19
|
+
const { token, hashId } = useToken();
|
|
20
|
+
//const avatarToken = (token as GlobalToken).Avatar;
|
|
21
|
+
const useStyle = useStyleRegister({
|
|
22
|
+
token: token,
|
|
23
|
+
path: ['Avatar'],
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
theme: theme
|
|
26
|
+
}, () => {
|
|
27
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-avatar`;
|
|
28
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-avatar`;
|
|
29
|
+
return {
|
|
30
|
+
[prefixCls]: {},
|
|
31
|
+
[prefixClsWithoutHash]: {}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return useStyle(React.createElement(AntAvatar, Object.assign({ shape: shape }, restAvatarProps)));
|
|
35
|
+
};
|
|
36
|
+
export const AvatarGroup = (_a) => {
|
|
37
|
+
var { maxPopoverPlacement = 'top', maxPopoverTrigger = 'hover', shape = 'circle', children } = _a, restAvatarProps = __rest(_a, ["maxPopoverPlacement", "maxPopoverTrigger", "shape", "children"]);
|
|
38
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
39
|
+
const { token, hashId } = useToken();
|
|
40
|
+
const useStyle = useStyleRegister({
|
|
41
|
+
token: token,
|
|
42
|
+
path: ['AvatarGroup'],
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
theme: theme
|
|
45
|
+
}, () => {
|
|
46
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-avatarGroup`;
|
|
47
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-avatarGroup`;
|
|
48
|
+
return {
|
|
49
|
+
[prefixCls]: {},
|
|
50
|
+
[prefixClsWithoutHash]: {}
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return useStyle(React.createElement(AntAvatar.Group, Object.assign({ maxPopoverPlacement: maxPopoverPlacement, maxPopoverTrigger: maxPopoverTrigger, shape: shape }, restAvatarProps), children));
|
|
17
54
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
2
|
+
type ScreenSizeMap = Partial<Record<Breakpoint, number>>;
|
|
3
|
+
|
|
4
|
+
type AvatarSize = 'large' | 'small' | 'default' | number | ScreenSizeMap;
|
|
5
|
+
|
|
6
|
+
export interface AvatarProps {
|
|
7
|
+
/** The shape of avatar */
|
|
8
|
+
shape?: 'circle' | 'square';
|
|
9
|
+
/** The size of the avatar */
|
|
10
|
+
size?: AvatarSize;
|
|
11
|
+
/** Letter type unit distance between left and right sides */
|
|
12
|
+
gap?: number;
|
|
13
|
+
/** The address of the image for an image avatar or image element */
|
|
14
|
+
src?: React.ReactNode | string;
|
|
15
|
+
/** A list of sources to use for different screen resolutions */
|
|
16
|
+
srcSet?: string;
|
|
17
|
+
/** Whether the picture is allowed to be dragged */
|
|
18
|
+
draggable?: boolean | 'true' | 'false';
|
|
19
|
+
/** Custom icon type for an icon avatar */
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
/** Additional CSS class name */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Additional CSS class name for the root element */
|
|
24
|
+
rootClassName?: string;
|
|
25
|
+
/** The content of the avatar */
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/** This attribute defines the alternative text describing the image */
|
|
28
|
+
alt?: string;
|
|
29
|
+
/** CORS settings attributes */
|
|
30
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
31
|
+
onClick?: (e?: React.MouseEvent<HTMLElement>) => void;
|
|
32
|
+
/** Handler when img load error, return false to prevent default fallback behavior */
|
|
33
|
+
onError?: () => boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AvatarGroupProps {
|
|
37
|
+
/** Additional CSS class name */
|
|
38
|
+
className?: string;
|
|
39
|
+
/** Additional CSS class name for the root element */
|
|
40
|
+
rootClassName?: string;
|
|
41
|
+
/** The content of the avatar group */
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
/** Maximum number of avatars to display before collapsing */
|
|
44
|
+
maxCount?: number;
|
|
45
|
+
/** Additional CSS styles for the maximum number of avatars */
|
|
46
|
+
maxStyle?: React.CSSProperties;
|
|
47
|
+
/** Placement of the popover for the maximum number of avatars */
|
|
48
|
+
maxPopoverPlacement?: 'top' | 'bottom';
|
|
49
|
+
/** Trigger type for the popover of the maximum number of avatars */
|
|
50
|
+
maxPopoverTrigger?: 'hover' | 'focus' | 'click';
|
|
51
|
+
/** Size of the avatars in the group */
|
|
52
|
+
size?: AvatarSize;
|
|
53
|
+
/** Shape of the avatars in the group */
|
|
54
|
+
shape?: 'circle' | 'square';
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-avatar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -9,16 +9,15 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"antd": "5.17.0"
|
|
12
|
+
"antd": "5.17.0",
|
|
13
|
+
"@akinon/ui-theme": "0.7.0"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"clean-package": "2.2.0",
|
|
16
17
|
"copyfiles": "^2.4.1",
|
|
17
18
|
"rimraf": "^5.0.5",
|
|
18
19
|
"typescript": "^5.2.2",
|
|
19
|
-
"@akinon/
|
|
20
|
-
"@akinon/eslint-config": "0.1.0",
|
|
21
|
-
"@akinon/typescript-config": "0.2.0"
|
|
20
|
+
"@akinon/typescript-config": "0.4.0"
|
|
22
21
|
},
|
|
23
22
|
"peerDependencies": {
|
|
24
23
|
"react": ">=18",
|
|
@@ -38,12 +37,8 @@
|
|
|
38
37
|
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
39
38
|
"build:esm": "tsc --outDir dist/esm",
|
|
40
39
|
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
41
|
-
"copy:files": "copyfiles -u 1 src
|
|
40
|
+
"copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
|
|
42
41
|
"clean": "rimraf dist/",
|
|
43
|
-
"lint": "eslint *.ts*",
|
|
44
|
-
"test": "vitest run",
|
|
45
|
-
"test:ui": "vitest --ui",
|
|
46
|
-
"test:watch": "vitest watch",
|
|
47
42
|
"typecheck": "tsc --noEmit"
|
|
48
43
|
}
|
|
49
44
|
}
|