@lobehub/ui 5.32.6 → 5.33.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/es/ActionIcon/ActionIcon.d.mts +3 -0
- package/es/ActionIcon/ActionIcon.mjs +3 -0
- package/es/ActionIcon/ActionIcon.mjs.map +1 -1
- package/es/Avatar/Avatar.mjs +3 -0
- package/es/Avatar/Avatar.mjs.map +1 -1
- package/es/Tag/Tag.d.mts +3 -0
- package/es/Tag/Tag.mjs +4 -1
- package/es/Tag/Tag.mjs.map +1 -1
- package/es/Text/Text.d.mts +3 -0
- package/es/Text/Text.mjs +3 -0
- package/es/Text/Text.mjs.map +1 -1
- package/es/base-ui/ActionIcon/ActionIcon.d.mts +6 -0
- package/es/base-ui/ActionIcon/ActionIcon.mjs +88 -0
- package/es/base-ui/ActionIcon/ActionIcon.mjs.map +1 -0
- package/es/base-ui/ActionIcon/index.d.mts +4 -0
- package/es/base-ui/ActionIcon/style.d.mts +9 -0
- package/es/base-ui/ActionIcon/style.mjs +36 -0
- package/es/base-ui/ActionIcon/style.mjs.map +1 -0
- package/es/base-ui/ActionIcon/type.d.mts +41 -0
- package/es/base-ui/ActionIcon/utils.mjs +42 -0
- package/es/base-ui/ActionIcon/utils.mjs.map +1 -0
- package/es/base-ui/Avatar/Avatar.mjs +99 -0
- package/es/base-ui/Avatar/Avatar.mjs.map +1 -0
- package/es/base-ui/Avatar/AvatarGroup/index.d.mts +6 -0
- package/es/base-ui/Avatar/AvatarGroup/index.mjs +65 -0
- package/es/base-ui/Avatar/AvatarGroup/index.mjs.map +1 -0
- package/es/base-ui/Avatar/AvatarGroup/style.mjs +17 -0
- package/es/base-ui/Avatar/AvatarGroup/style.mjs.map +1 -0
- package/es/base-ui/Avatar/index.d.mts +12 -0
- package/es/base-ui/Avatar/index.mjs +9 -0
- package/es/base-ui/Avatar/index.mjs.map +1 -0
- package/es/base-ui/Avatar/style.mjs +73 -0
- package/es/base-ui/Avatar/style.mjs.map +1 -0
- package/es/base-ui/Avatar/type.d.mts +128 -0
- package/es/base-ui/Avatar/utils.mjs +27 -0
- package/es/base-ui/Avatar/utils.mjs.map +1 -0
- package/es/base-ui/Tag/Tag.d.mts +6 -0
- package/es/base-ui/Tag/Tag.mjs +85 -0
- package/es/base-ui/Tag/Tag.mjs.map +1 -0
- package/es/base-ui/Tag/index.d.mts +4 -0
- package/es/base-ui/Tag/style.mjs +112 -0
- package/es/base-ui/Tag/style.mjs.map +1 -0
- package/es/base-ui/Tag/type.d.mts +29 -0
- package/es/base-ui/Tag/utils.d.mts +8 -0
- package/es/base-ui/Tag/utils.mjs +41 -0
- package/es/base-ui/Tag/utils.mjs.map +1 -0
- package/es/base-ui/Text/Text.d.mts +6 -0
- package/es/base-ui/Text/Text.mjs +85 -0
- package/es/base-ui/Text/Text.mjs.map +1 -0
- package/es/base-ui/Text/index.d.mts +4 -0
- package/es/base-ui/Text/style.d.mts +39 -0
- package/es/base-ui/Text/style.mjs +120 -0
- package/es/base-ui/Text/style.mjs.map +1 -0
- package/es/base-ui/Text/type.d.mts +43 -0
- package/es/base-ui/index.d.mts +25 -10
- package/es/base-ui/index.mjs +21 -13
- package/es/utils/safeReadableColor.mjs +1 -1
- package/es/utils/safeReadableColor.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import FlexBasic_default from "../../../Flex/FlexBasic.mjs";
|
|
3
|
+
import Avatar from "../Avatar.mjs";
|
|
4
|
+
import { styles } from "./style.mjs";
|
|
5
|
+
import { memo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { cssVar, cx } from "antd-style";
|
|
8
|
+
//#region src/base-ui/Avatar/AvatarGroup/index.tsx
|
|
9
|
+
const AvatarGroup = memo(({ items, max, gap, variant = "borderless", bordered, shadow, size = 48, background, animation, draggable, classNames, shape, styles: customStyles, onClick, ref, zIndexReverse, ...rest }) => {
|
|
10
|
+
const avatars = max ? items.slice(0, max) : items;
|
|
11
|
+
const restAvatars = items.slice(max, items.length);
|
|
12
|
+
const gapValue = gap ?? Math.floor(-size / 4);
|
|
13
|
+
const avatarProps = {
|
|
14
|
+
animation,
|
|
15
|
+
background,
|
|
16
|
+
bordered,
|
|
17
|
+
draggable,
|
|
18
|
+
shadow,
|
|
19
|
+
shape,
|
|
20
|
+
size,
|
|
21
|
+
variant
|
|
22
|
+
};
|
|
23
|
+
return /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
24
|
+
horizontal: true,
|
|
25
|
+
gap,
|
|
26
|
+
ref,
|
|
27
|
+
style: { position: "relative" },
|
|
28
|
+
...rest,
|
|
29
|
+
children: [avatars.map((avatar, index) => {
|
|
30
|
+
const { key, style: avatarStyle, className: avatarClassName, ...restAvatarProps } = avatar;
|
|
31
|
+
return /* @__PURE__ */ jsx(Avatar, {
|
|
32
|
+
className: cx(classNames?.avatar, avatarClassName, styles.avatar),
|
|
33
|
+
style: {
|
|
34
|
+
marginLeft: index === 0 ? 0 : gapValue,
|
|
35
|
+
zIndex: zIndexReverse ? items.length - index : index,
|
|
36
|
+
...customStyles?.avatar,
|
|
37
|
+
...avatarStyle
|
|
38
|
+
},
|
|
39
|
+
onClick: () => onClick?.({
|
|
40
|
+
item: avatar,
|
|
41
|
+
key
|
|
42
|
+
}),
|
|
43
|
+
...avatarProps,
|
|
44
|
+
...restAvatarProps
|
|
45
|
+
}, key);
|
|
46
|
+
}), max && restAvatars.length > 0 && /* @__PURE__ */ jsx(Avatar, {
|
|
47
|
+
...avatarProps,
|
|
48
|
+
avatar: `+${restAvatars.length}`,
|
|
49
|
+
background: cssVar.colorText,
|
|
50
|
+
className: cx(styles.avatar, classNames?.count),
|
|
51
|
+
classNames: { content: styles.count },
|
|
52
|
+
sliceText: false,
|
|
53
|
+
style: {
|
|
54
|
+
marginLeft: gapValue,
|
|
55
|
+
zIndex: zIndexReverse ? 0 : avatars.length,
|
|
56
|
+
...customStyles?.count
|
|
57
|
+
}
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
AvatarGroup.displayName = "AvatarGroup";
|
|
62
|
+
//#endregion
|
|
63
|
+
export { AvatarGroup as default };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Flexbox"],"sources":["../../../../src/base-ui/Avatar/AvatarGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport { cssVar, cx } from 'antd-style';\nimport { memo } from 'react';\n\nimport { Flexbox } from '@/Flex';\n\nimport Avatar from '../Avatar';\nimport type { AvatarGroupProps } from '../type';\nimport { styles } from './style';\n\nconst AvatarGroup = memo<AvatarGroupProps>(\n ({\n items,\n max,\n gap,\n variant = 'borderless',\n bordered,\n shadow,\n size = 48,\n background,\n animation,\n draggable,\n classNames,\n shape,\n styles: customStyles,\n onClick,\n ref,\n zIndexReverse,\n ...rest\n }) => {\n const avatars = max ? items.slice(0, max) : items;\n const restAvatars = items.slice(max, items.length);\n const gapValue = gap ?? Math.floor(-size / 4);\n\n const avatarProps = {\n animation,\n background,\n bordered,\n draggable,\n shadow,\n shape,\n size,\n variant,\n };\n\n return (\n <Flexbox\n horizontal\n gap={gap}\n ref={ref}\n style={{\n position: 'relative',\n }}\n {...rest}\n >\n {avatars.map((avatar, index) => {\n const {\n key,\n style: avatarStyle,\n className: avatarClassName,\n ...restAvatarProps\n } = avatar;\n return (\n <Avatar\n className={cx(classNames?.avatar, avatarClassName, styles.avatar)}\n key={key}\n style={{\n marginLeft: index === 0 ? 0 : gapValue,\n zIndex: zIndexReverse ? items.length - index : index,\n ...customStyles?.avatar,\n ...avatarStyle,\n }}\n onClick={() => onClick?.({ item: avatar, key })}\n {...avatarProps}\n {...restAvatarProps}\n />\n );\n })}\n {max && restAvatars.length > 0 && (\n <Avatar\n {...avatarProps}\n avatar={`+${restAvatars.length}`}\n background={cssVar.colorText}\n className={cx(styles.avatar, classNames?.count)}\n classNames={{ content: styles.count }}\n sliceText={false}\n style={{\n marginLeft: gapValue,\n zIndex: zIndexReverse ? 0 : avatars.length,\n ...customStyles?.count,\n }}\n />\n )}\n </Flexbox>\n );\n },\n);\n\nAvatarGroup.displayName = 'AvatarGroup';\n\nexport default AvatarGroup;\n"],"mappings":";;;;;;;;AAWA,MAAM,cAAc,MACjB,EACC,OACA,KACA,KACA,UAAU,cACV,UACA,QACA,OAAO,IACP,YACA,WACA,WACA,YACA,OACA,QAAQ,cACR,SACA,KACA,eACA,GAAG,WACC;CACJ,MAAM,UAAU,MAAM,MAAM,MAAM,GAAG,GAAG,IAAI;CAC5C,MAAM,cAAc,MAAM,MAAM,KAAK,MAAM,MAAM;CACjD,MAAM,WAAW,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC;CAE5C,MAAM,cAAc;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,OACE,qBAACA,mBAAD;EACE,YAAA;EACK;EACA;EACL,OAAO,EACL,UAAU,WACZ;EACA,GAAI;EAPN,UAAA,CASG,QAAQ,KAAK,QAAQ,UAAU;GAC9B,MAAM,EACJ,KACA,OAAO,aACP,WAAW,iBACX,GAAG,oBACD;GACJ,OACE,oBAAC,QAAD;IACE,WAAW,GAAG,YAAY,QAAQ,iBAAiB,OAAO,MAAM;IAEhE,OAAO;KACL,YAAY,UAAU,IAAI,IAAI;KAC9B,QAAQ,gBAAgB,MAAM,SAAS,QAAQ;KAC/C,GAAG,cAAc;KACjB,GAAG;IACL;IACA,eAAe,UAAU;KAAE,MAAM;KAAQ;IAAI,CAAC;IAC9C,GAAI;IACJ,GAAI;GACL,GAVM,GAUN;EAEL,CAAC,GACA,OAAO,YAAY,SAAS,KAC3B,oBAAC,QAAD;GACE,GAAI;GACJ,QAAQ,IAAI,YAAY;GACxB,YAAY,OAAO;GACnB,WAAW,GAAG,OAAO,QAAQ,YAAY,KAAK;GAC9C,YAAY,EAAE,SAAS,OAAO,MAAM;GACpC,WAAW;GACX,OAAO;IACL,YAAY;IACZ,QAAQ,gBAAgB,IAAI,QAAQ;IACpC,GAAG,cAAc;GACnB;EACD,CAAA,CAEI;;AAEb,CACF;AAEA,YAAY,cAAc"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
//#region src/base-ui/Avatar/AvatarGroup/style.ts
|
|
3
|
+
const styles = createStaticStyles(({ css, cssVar }) => {
|
|
4
|
+
return {
|
|
5
|
+
avatar: css`
|
|
6
|
+
border: 2px solid ${cssVar.colorBgContainer} !important;
|
|
7
|
+
`,
|
|
8
|
+
count: css`
|
|
9
|
+
font-size: 0.8em;
|
|
10
|
+
color: ${cssVar.colorBgLayout};
|
|
11
|
+
`
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { styles };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../../src/base-ui/Avatar/AvatarGroup/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => {\n return {\n avatar: css`\n border: 2px solid ${cssVar.colorBgContainer} !important;\n `,\n count: css`\n font-size: 0.8em;\n color: ${cssVar.colorBgLayout};\n `,\n };\n});\n"],"mappings":";;AAEA,MAAa,SAAS,oBAAoB,EAAE,KAAK,aAAa;CAC5D,OAAO;EACL,QAAQ,GAAG;0BACW,OAAO,iBAAiB;;EAE9C,OAAO,GAAG;;eAEC,OAAO,cAAc;;CAElC;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AvatarClassNames, AvatarGroupItemType, AvatarGroupProps, AvatarProps, AvatarStyles } from "./type.mjs";
|
|
2
|
+
import AvatarGroup from "./AvatarGroup/index.mjs";
|
|
3
|
+
import { ReactNode, RefAttributes } from "react";
|
|
4
|
+
//#region src/base-ui/Avatar/index.d.ts
|
|
5
|
+
interface IAvatar {
|
|
6
|
+
(props: AvatarProps & RefAttributes<HTMLDivElement>): ReactNode;
|
|
7
|
+
Group: typeof AvatarGroup;
|
|
8
|
+
}
|
|
9
|
+
declare const Avatar: IAvatar;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type AvatarClassNames, AvatarGroup, type AvatarGroupItemType, type AvatarGroupProps, type AvatarProps, type AvatarStyles, Avatar as default };
|
|
12
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Avatar$1 from "./Avatar.mjs";
|
|
2
|
+
import AvatarGroup from "./AvatarGroup/index.mjs";
|
|
3
|
+
//#region src/base-ui/Avatar/index.ts
|
|
4
|
+
const Avatar = Avatar$1;
|
|
5
|
+
Avatar.Group = AvatarGroup;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AvatarGroup, Avatar as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["AvatarParent"],"sources":["../../../src/base-ui/Avatar/index.ts"],"sourcesContent":["import type { ReactNode, RefAttributes } from 'react';\n\nimport AvatarParent from './Avatar';\nimport AvatarGroup from './AvatarGroup';\nimport { type AvatarProps } from './type';\n\ninterface IAvatar {\n (props: AvatarProps & RefAttributes<HTMLDivElement>): ReactNode;\n Group: typeof AvatarGroup;\n}\n\nconst Avatar = AvatarParent as unknown as IAvatar;\nAvatar.Group = AvatarGroup;\n\nexport default Avatar;\nexport { default as AvatarGroup } from './AvatarGroup';\nexport type * from './type';\n"],"mappings":";;;AAWA,MAAM,SAASA;AACf,OAAO,QAAQ"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { staticStylish } from "../../styles/theme/customStylishStatic.mjs";
|
|
2
|
+
import { createStaticStyles } from "antd-style";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
//#region src/base-ui/Avatar/style.ts
|
|
5
|
+
const styles = createStaticStyles(({ css, cssVar }) => {
|
|
6
|
+
return {
|
|
7
|
+
borderless: staticStylish.variantBorderlessWithoutHover,
|
|
8
|
+
content: css`
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
padding: 0;
|
|
17
|
+
|
|
18
|
+
font-size: inherit;
|
|
19
|
+
font-weight: bolder;
|
|
20
|
+
line-height: 1;
|
|
21
|
+
color: inherit;
|
|
22
|
+
`,
|
|
23
|
+
filled: staticStylish.variantFilledWithoutHover,
|
|
24
|
+
img: css`
|
|
25
|
+
flex: none;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
object-fit: cover;
|
|
29
|
+
`,
|
|
30
|
+
loading: css`
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0;
|
|
33
|
+
color: #fff;
|
|
34
|
+
background: ${cssVar.colorBgMask};
|
|
35
|
+
`,
|
|
36
|
+
outlined: staticStylish.variantOutlinedWithoutHover,
|
|
37
|
+
root: css`
|
|
38
|
+
user-select: none;
|
|
39
|
+
|
|
40
|
+
position: relative;
|
|
41
|
+
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex: none;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
|
|
48
|
+
background: transparent;
|
|
49
|
+
`,
|
|
50
|
+
shadow: staticStylish.shadow
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const variants = cva(styles.root, {
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
shadow: false,
|
|
56
|
+
variant: "borderless"
|
|
57
|
+
},
|
|
58
|
+
variants: {
|
|
59
|
+
variant: {
|
|
60
|
+
filled: styles.filled,
|
|
61
|
+
outlined: styles.outlined,
|
|
62
|
+
borderless: styles.borderless
|
|
63
|
+
},
|
|
64
|
+
shadow: {
|
|
65
|
+
false: null,
|
|
66
|
+
true: styles.shadow
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//#endregion
|
|
71
|
+
export { styles, variants };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Avatar/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { lobeStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => {\n return {\n borderless: lobeStaticStylish.variantBorderlessWithoutHover,\n content: css`\n overflow: hidden;\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 100%;\n height: 100%;\n padding: 0;\n\n font-size: inherit;\n font-weight: bolder;\n line-height: 1;\n color: inherit;\n `,\n filled: lobeStaticStylish.variantFilledWithoutHover,\n img: css`\n flex: none;\n width: 100%;\n height: 100%;\n object-fit: cover;\n `,\n loading: css`\n position: absolute;\n inset: 0;\n color: #fff;\n background: ${cssVar.colorBgMask};\n `,\n outlined: lobeStaticStylish.variantOutlinedWithoutHover,\n root: css`\n user-select: none;\n\n position: relative;\n\n overflow: hidden;\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n background: transparent;\n `,\n shadow: lobeStaticStylish.shadow,\n };\n});\n\nexport const variants = cva(styles.root, {\n defaultVariants: {\n shadow: false,\n variant: 'borderless',\n },\n\n variants: {\n variant: {\n filled: styles.filled,\n outlined: styles.outlined,\n borderless: styles.borderless,\n },\n shadow: {\n false: null,\n true: styles.shadow,\n },\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,KAAK,aAAa;CAC5D,OAAO;EACL,YAAYA,cAAkB;EAC9B,SAAS,GAAG;;;;;;;;;;;;;;;EAeZ,QAAQA,cAAkB;EAC1B,KAAK,GAAG;;;;;;EAMR,SAAS,GAAG;;;;oBAII,OAAO,YAAY;;EAEnC,UAAUA,cAAkB;EAC5B,MAAM,GAAG;;;;;;;;;;;;;EAaT,QAAQA,cAAkB;CAC5B;AACF,CAAC;AAED,MAAa,WAAW,IAAI,OAAO,MAAM;CACvC,iBAAiB;EACf,QAAQ;EACR,SAAS;CACX;CAEA,UAAU;EACR,SAAS;GACP,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,YAAY,OAAO;EACrB;EACA,QAAQ;GACN,OAAO;GACP,MAAM,OAAO;EACf;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { FlexboxProps } from "../../Flex/type.mjs";
|
|
2
|
+
import "../../Flex/index.mjs";
|
|
3
|
+
import { CSSProperties, ComponentProps, ReactNode, Ref } from "react";
|
|
4
|
+
//#region src/base-ui/Avatar/type.d.ts
|
|
5
|
+
interface AvatarClassNames {
|
|
6
|
+
content?: string;
|
|
7
|
+
img?: string;
|
|
8
|
+
loading?: string;
|
|
9
|
+
root?: string;
|
|
10
|
+
}
|
|
11
|
+
interface AvatarStyles {
|
|
12
|
+
content?: CSSProperties;
|
|
13
|
+
img?: CSSProperties;
|
|
14
|
+
loading?: CSSProperties;
|
|
15
|
+
root?: CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
interface AvatarProps extends ComponentProps<'div'> {
|
|
18
|
+
/**
|
|
19
|
+
* Alias for the native `alt` attribute of the rendered image
|
|
20
|
+
*/
|
|
21
|
+
alt?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Play the animated emoji variant instead of the static one
|
|
24
|
+
*/
|
|
25
|
+
animation?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Avatar content: an image URL, an emoji, or a custom React node
|
|
28
|
+
*/
|
|
29
|
+
avatar?: string | ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Background color, ignored when the avatar is an image or a custom node
|
|
32
|
+
*/
|
|
33
|
+
background?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Show the outer ring
|
|
36
|
+
*/
|
|
37
|
+
bordered?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Custom color for the outer ring
|
|
40
|
+
*/
|
|
41
|
+
borderedColor?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom class names for each part
|
|
44
|
+
*/
|
|
45
|
+
classNames?: AvatarClassNames;
|
|
46
|
+
/**
|
|
47
|
+
* Native `crossOrigin` attribute forwarded to the rendered image
|
|
48
|
+
*/
|
|
49
|
+
crossOrigin?: '' | 'anonymous' | 'use-credentials';
|
|
50
|
+
/**
|
|
51
|
+
* Native `draggable` attribute of the rendered image
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
draggable?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Scale the emoji down when a background color is present
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
emojiScaleWithBackground?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Show the full-size loading overlay
|
|
62
|
+
*/
|
|
63
|
+
loading?: boolean;
|
|
64
|
+
ref?: Ref<HTMLDivElement>;
|
|
65
|
+
/**
|
|
66
|
+
* Apply the lobe shadow style
|
|
67
|
+
*/
|
|
68
|
+
shadow?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @default 'square'
|
|
71
|
+
*/
|
|
72
|
+
shape?: 'circle' | 'square';
|
|
73
|
+
/**
|
|
74
|
+
* Width and height in pixels
|
|
75
|
+
* @default 48
|
|
76
|
+
*/
|
|
77
|
+
size?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Slice fallback text to its first two characters
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
sliceText?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Custom styles for each part
|
|
85
|
+
*/
|
|
86
|
+
styles?: AvatarStyles;
|
|
87
|
+
/**
|
|
88
|
+
* Fallback text when no avatar content resolves; also used as the default image alt text
|
|
89
|
+
*/
|
|
90
|
+
title?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Reserved for tooltip integration; not rendered yet
|
|
93
|
+
*/
|
|
94
|
+
tooltipProps?: Record<string, unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Accepted for compatibility with next/image-based avatars; has no effect on the native img
|
|
97
|
+
*/
|
|
98
|
+
unoptimized?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Visual variant
|
|
101
|
+
* @default 'borderless'
|
|
102
|
+
*/
|
|
103
|
+
variant?: 'borderless' | 'filled' | 'outlined';
|
|
104
|
+
}
|
|
105
|
+
interface AvatarGroupItemType extends Pick<AvatarProps, 'avatar' | 'title' | 'alt' | 'onClick' | 'style' | 'className' | 'loading'> {
|
|
106
|
+
key: string;
|
|
107
|
+
}
|
|
108
|
+
interface AvatarGroupProps extends Pick<AvatarProps, 'variant' | 'bordered' | 'shadow' | 'size' | 'background' | 'animation' | 'draggable' | 'shape'>, Omit<FlexboxProps, 'children' | 'draggable' | 'onClick' | 'ref'> {
|
|
109
|
+
classNames?: {
|
|
110
|
+
avatar?: string;
|
|
111
|
+
count?: string;
|
|
112
|
+
};
|
|
113
|
+
items: AvatarGroupItemType[];
|
|
114
|
+
max?: number;
|
|
115
|
+
onClick?: (props: {
|
|
116
|
+
item: AvatarGroupItemType;
|
|
117
|
+
key: string;
|
|
118
|
+
}) => void;
|
|
119
|
+
ref?: Ref<HTMLDivElement>;
|
|
120
|
+
styles?: {
|
|
121
|
+
avatar?: CSSProperties;
|
|
122
|
+
count?: CSSProperties;
|
|
123
|
+
};
|
|
124
|
+
zIndexReverse?: boolean;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { AvatarClassNames, AvatarGroupItemType, AvatarGroupProps, AvatarProps, AvatarStyles };
|
|
128
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isValidElement } from "react";
|
|
2
|
+
//#region src/base-ui/Avatar/utils.ts
|
|
3
|
+
const isDefaultAntAvatar = (avatar) => {
|
|
4
|
+
if (!avatar) return false;
|
|
5
|
+
const isUrlOrDataUri = typeof avatar === "string" && [
|
|
6
|
+
"/",
|
|
7
|
+
"http",
|
|
8
|
+
"data:"
|
|
9
|
+
].some((prefix) => avatar.startsWith(prefix));
|
|
10
|
+
return Boolean(isUrlOrDataUri || isValidElement(avatar));
|
|
11
|
+
};
|
|
12
|
+
const hasValidBackground = (background) => {
|
|
13
|
+
return Boolean(background && background !== "transparent" && background !== "rgba(0,0,0,0)" && background !== null);
|
|
14
|
+
};
|
|
15
|
+
const formatAvatarText = (text, sliceText) => {
|
|
16
|
+
if (!text) return "";
|
|
17
|
+
const upperText = text.toUpperCase();
|
|
18
|
+
return sliceText ? upperText.slice(0, 2) : upperText;
|
|
19
|
+
};
|
|
20
|
+
const calculateEmojiSize = (size, hasBackground, emojiScaleWithBackground) => {
|
|
21
|
+
if (emojiScaleWithBackground) return hasBackground ? size * .85 : size;
|
|
22
|
+
return size * .85;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { calculateEmojiSize, formatAvatarText, hasValidBackground, isDefaultAntAvatar };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/base-ui/Avatar/utils.ts"],"sourcesContent":["import { isValidElement, type ReactNode } from 'react';\n\nexport const isDefaultAntAvatar = (avatar: ReactNode): boolean => {\n if (!avatar) return false;\n\n const isStringAvatar = typeof avatar === 'string';\n const isUrlOrDataUri =\n isStringAvatar && ['/', 'http', 'data:'].some((prefix) => avatar.startsWith(prefix));\n\n return Boolean(isUrlOrDataUri || isValidElement(avatar));\n};\n\nexport const hasValidBackground = (background?: string | null): boolean => {\n return Boolean(\n background &&\n background !== 'transparent' &&\n background !== 'rgba(0,0,0,0)' &&\n background !== null,\n );\n};\n\nexport const formatAvatarText = (text: string | undefined, sliceText: boolean): string => {\n if (!text) return '';\n\n const upperText = text.toUpperCase();\n return sliceText ? upperText.slice(0, 2) : upperText;\n};\n\nexport const calculateEmojiSize = (\n size: number,\n hasBackground: boolean,\n emojiScaleWithBackground: boolean,\n): number => {\n if (emojiScaleWithBackground) {\n return hasBackground ? size * 0.85 : size;\n }\n return size * 0.85;\n};\n"],"mappings":";;AAEA,MAAa,sBAAsB,WAA+B;CAChE,IAAI,CAAC,QAAQ,OAAO;CAGpB,MAAM,iBADiB,OAAO,WAAW,YAErB;EAAC;EAAK;EAAQ;CAAO,CAAC,CAAC,MAAM,WAAW,OAAO,WAAW,MAAM,CAAC;CAErF,OAAO,QAAQ,kBAAkB,eAAe,MAAM,CAAC;AACzD;AAEA,MAAa,sBAAsB,eAAwC;CACzE,OAAO,QACL,cACA,eAAe,iBACf,eAAe,mBACf,eAAe,IACjB;AACF;AAEA,MAAa,oBAAoB,MAA0B,cAA+B;CACxF,IAAI,CAAC,MAAM,OAAO;CAElB,MAAM,YAAY,KAAK,YAAY;CACnC,OAAO,YAAY,UAAU,MAAM,GAAG,CAAC,IAAI;AAC7C;AAEA,MAAa,sBACX,MACA,eACA,6BACW;CACX,IAAI,0BACF,OAAO,gBAAgB,OAAO,MAAO;CAEvC,OAAO,OAAO;AAChB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { safeReadableColor } from "../../utils/safeReadableColor.mjs";
|
|
3
|
+
import { styles, variants } from "./style.mjs";
|
|
4
|
+
import { colorsPreset, colorsPresetSystem, presetColors, presetSystemColors } from "./utils.mjs";
|
|
5
|
+
import { memo, useMemo, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { cssVar, cx } from "antd-style";
|
|
8
|
+
import { X } from "lucide-react";
|
|
9
|
+
//#region src/base-ui/Tag/Tag.tsx
|
|
10
|
+
const Tag = memo(({ children, className, classNames, closable, closeIcon, color, icon, onClick, onClose, ref, shape = "normal", size = "middle", style, styles: customStyles, variant = "filled", ...rest }) => {
|
|
11
|
+
const [visible, setVisible] = useState(true);
|
|
12
|
+
const colors = useMemo(() => {
|
|
13
|
+
let textColor = cssVar.colorTextSecondary;
|
|
14
|
+
let backgroundColor;
|
|
15
|
+
let borderColor;
|
|
16
|
+
const isBorderless = variant === "borderless";
|
|
17
|
+
const isFilled = variant === "filled";
|
|
18
|
+
const isSolid = variant === "solid";
|
|
19
|
+
const isPresetColor = color && presetColors.includes(color);
|
|
20
|
+
const isPresetSystemColors = color && presetSystemColors.has(color);
|
|
21
|
+
const isHexColor = color && color.startsWith("#");
|
|
22
|
+
if (isPresetColor) {
|
|
23
|
+
const solidBgColor = colorsPreset(color);
|
|
24
|
+
textColor = isSolid ? safeReadableColor(solidBgColor) : colorsPreset(color, "active");
|
|
25
|
+
backgroundColor = isSolid ? solidBgColor : isBorderless ? "transparent" : colorsPreset(color, "fillTertiary");
|
|
26
|
+
borderColor = isSolid ? solidBgColor : colorsPreset(color, isFilled ? "fillQuaternary" : "fillTertiary");
|
|
27
|
+
}
|
|
28
|
+
if (isPresetSystemColors) {
|
|
29
|
+
const solidBgColor = colorsPresetSystem(color);
|
|
30
|
+
textColor = isSolid ? safeReadableColor(solidBgColor) : colorsPresetSystem(color);
|
|
31
|
+
backgroundColor = isSolid ? solidBgColor : isBorderless ? "transparent" : colorsPresetSystem(color, "fillTertiary");
|
|
32
|
+
borderColor = isSolid ? solidBgColor : colorsPresetSystem(color, isFilled ? "fillQuaternary" : "fillTertiary");
|
|
33
|
+
}
|
|
34
|
+
if (isHexColor) {
|
|
35
|
+
textColor = isSolid ? safeReadableColor(color) : isBorderless ? color : cssVar.colorBgLayout;
|
|
36
|
+
backgroundColor = isSolid ? color : isBorderless ? "transparent" : color;
|
|
37
|
+
borderColor = isSolid ? color : borderColor;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
backgroundColor,
|
|
41
|
+
borderColor,
|
|
42
|
+
textColor
|
|
43
|
+
};
|
|
44
|
+
}, [color, variant]);
|
|
45
|
+
if (!visible) return null;
|
|
46
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
47
|
+
className: cx(variants({
|
|
48
|
+
shape,
|
|
49
|
+
size,
|
|
50
|
+
variant
|
|
51
|
+
}), className, classNames?.root),
|
|
52
|
+
ref,
|
|
53
|
+
style: {
|
|
54
|
+
background: colors.backgroundColor,
|
|
55
|
+
borderColor: colors.borderColor,
|
|
56
|
+
color: colors.textColor,
|
|
57
|
+
cursor: onClick ? "pointer" : void 0,
|
|
58
|
+
...style,
|
|
59
|
+
...customStyles?.root
|
|
60
|
+
},
|
|
61
|
+
onClick,
|
|
62
|
+
...rest,
|
|
63
|
+
children: [
|
|
64
|
+
icon,
|
|
65
|
+
children,
|
|
66
|
+
closable && /* @__PURE__ */ jsx("button", {
|
|
67
|
+
"aria-label": "Close",
|
|
68
|
+
className: cx(styles.close, classNames?.closeIcon),
|
|
69
|
+
style: customStyles?.closeIcon,
|
|
70
|
+
type: "button",
|
|
71
|
+
onClick: (e) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
onClose?.(e);
|
|
74
|
+
setVisible(false);
|
|
75
|
+
},
|
|
76
|
+
children: closeIcon ?? /* @__PURE__ */ jsx(X, { size: 12 })
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
Tag.displayName = "Tag";
|
|
82
|
+
//#endregion
|
|
83
|
+
export { Tag as default };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=Tag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.mjs","names":[],"sources":["../../../src/base-ui/Tag/Tag.tsx"],"sourcesContent":["'use client';\n\nimport { cssVar, cx } from 'antd-style';\nimport { X } from 'lucide-react';\nimport { memo, useMemo, useState } from 'react';\n\nimport { safeReadableColor } from '@/utils/safeReadableColor';\n\nimport { styles, variants } from './style';\nimport type { TagProps } from './type';\nimport { colorsPreset, colorsPresetSystem, presetColors, presetSystemColors } from './utils';\n\nconst Tag = memo<TagProps>(\n ({\n children,\n className,\n classNames,\n closable,\n closeIcon,\n color,\n icon,\n onClick,\n onClose,\n ref,\n shape = 'normal',\n size = 'middle',\n style,\n styles: customStyles,\n variant = 'filled',\n ...rest\n }) => {\n const [visible, setVisible] = useState(true);\n\n const colors = useMemo(() => {\n let textColor = cssVar.colorTextSecondary;\n let backgroundColor;\n let borderColor;\n const isBorderless = variant === 'borderless';\n const isFilled = variant === 'filled';\n const isSolid = variant === 'solid';\n const isPresetColor = color && presetColors.includes(color);\n const isPresetSystemColors = color && presetSystemColors.has(color);\n const isHexColor = color && color.startsWith('#');\n\n if (isPresetColor) {\n const solidBgColor = colorsPreset(color);\n textColor = isSolid ? safeReadableColor(solidBgColor) : colorsPreset(color, 'active');\n backgroundColor = isSolid\n ? solidBgColor\n : isBorderless\n ? 'transparent'\n : colorsPreset(color, 'fillTertiary');\n borderColor = isSolid\n ? solidBgColor\n : colorsPreset(color, isFilled ? 'fillQuaternary' : 'fillTertiary');\n }\n if (isPresetSystemColors) {\n const solidBgColor = colorsPresetSystem(color);\n textColor = isSolid ? safeReadableColor(solidBgColor) : colorsPresetSystem(color);\n backgroundColor = isSolid\n ? solidBgColor\n : isBorderless\n ? 'transparent'\n : colorsPresetSystem(color, 'fillTertiary');\n borderColor = isSolid\n ? solidBgColor\n : colorsPresetSystem(color, isFilled ? 'fillQuaternary' : 'fillTertiary');\n }\n if (isHexColor) {\n textColor = isSolid\n ? safeReadableColor(color)\n : isBorderless\n ? color\n : cssVar.colorBgLayout;\n backgroundColor = isSolid ? color : isBorderless ? 'transparent' : color;\n borderColor = isSolid ? color : borderColor;\n }\n\n return {\n backgroundColor,\n borderColor,\n textColor,\n };\n }, [color, variant]);\n\n if (!visible) return null;\n\n return (\n <span\n className={cx(variants({ shape, size, variant }), className, classNames?.root)}\n ref={ref}\n style={{\n background: colors.backgroundColor,\n borderColor: colors.borderColor,\n color: colors.textColor,\n cursor: onClick ? 'pointer' : undefined,\n ...style,\n ...customStyles?.root,\n }}\n onClick={onClick}\n {...rest}\n >\n {icon}\n {children}\n {closable && (\n <button\n aria-label=\"Close\"\n className={cx(styles.close, classNames?.closeIcon)}\n style={customStyles?.closeIcon}\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n onClose?.(e);\n setVisible(false);\n }}\n >\n {closeIcon ?? <X size={12} />}\n </button>\n )}\n </span>\n );\n },\n);\n\nTag.displayName = 'Tag';\n\nexport default Tag;\n"],"mappings":";;;;;;;;;AAYA,MAAM,MAAM,MACT,EACC,UACA,WACA,YACA,UACA,WACA,OACA,MACA,SACA,SACA,KACA,QAAQ,UACR,OAAO,UACP,OACA,QAAQ,cACR,UAAU,UACV,GAAG,WACC;CACJ,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAE3C,MAAM,SAAS,cAAc;EAC3B,IAAI,YAAY,OAAO;EACvB,IAAI;EACJ,IAAI;EACJ,MAAM,eAAe,YAAY;EACjC,MAAM,WAAW,YAAY;EAC7B,MAAM,UAAU,YAAY;EAC5B,MAAM,gBAAgB,SAAS,aAAa,SAAS,KAAK;EAC1D,MAAM,uBAAuB,SAAS,mBAAmB,IAAI,KAAK;EAClE,MAAM,aAAa,SAAS,MAAM,WAAW,GAAG;EAEhD,IAAI,eAAe;GACjB,MAAM,eAAe,aAAa,KAAK;GACvC,YAAY,UAAU,kBAAkB,YAAY,IAAI,aAAa,OAAO,QAAQ;GACpF,kBAAkB,UACd,eACA,eACE,gBACA,aAAa,OAAO,cAAc;GACxC,cAAc,UACV,eACA,aAAa,OAAO,WAAW,mBAAmB,cAAc;EACtE;EACA,IAAI,sBAAsB;GACxB,MAAM,eAAe,mBAAmB,KAAK;GAC7C,YAAY,UAAU,kBAAkB,YAAY,IAAI,mBAAmB,KAAK;GAChF,kBAAkB,UACd,eACA,eACE,gBACA,mBAAmB,OAAO,cAAc;GAC9C,cAAc,UACV,eACA,mBAAmB,OAAO,WAAW,mBAAmB,cAAc;EAC5E;EACA,IAAI,YAAY;GACd,YAAY,UACR,kBAAkB,KAAK,IACvB,eACE,QACA,OAAO;GACb,kBAAkB,UAAU,QAAQ,eAAe,gBAAgB;GACnE,cAAc,UAAU,QAAQ;EAClC;EAEA,OAAO;GACL;GACA;GACA;EACF;CACF,GAAG,CAAC,OAAO,OAAO,CAAC;CAEnB,IAAI,CAAC,SAAS,OAAO;CAErB,OACE,qBAAC,QAAD;EACE,WAAW,GAAG,SAAS;GAAE;GAAO;GAAM;EAAQ,CAAC,GAAG,WAAW,YAAY,IAAI;EACxE;EACL,OAAO;GACL,YAAY,OAAO;GACnB,aAAa,OAAO;GACpB,OAAO,OAAO;GACd,QAAQ,UAAU,YAAY,KAAA;GAC9B,GAAG;GACH,GAAG,cAAc;EACnB;EACS;EACT,GAAI;EAZN,UAAA;GAcG;GACA;GACA,YACC,oBAAC,UAAD;IACE,cAAW;IACX,WAAW,GAAG,OAAO,OAAO,YAAY,SAAS;IACjD,OAAO,cAAc;IACrB,MAAK;IACL,UAAU,MAAM;KACd,EAAE,gBAAgB;KAClB,UAAU,CAAC;KACX,WAAW,KAAK;IAClB;IAEC,UAAA,aAAa,oBAAC,GAAD,EAAG,MAAM,GAAK,CAAA;GACtB,CAAA;EAEN;;AAEV,CACF;AAEA,IAAI,cAAc"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TagClassNames, TagProps, TagShape, TagSize, TagStyles, TagVariant } from "./type.mjs";
|
|
2
|
+
import Tag from "./Tag.mjs";
|
|
3
|
+
import { colorsPreset, colorsPresetSystem, presetColors, presetSystemColors } from "./utils.mjs";
|
|
4
|
+
export { type TagClassNames, type TagProps, type TagShape, type TagSize, type TagStyles, type TagVariant, colorsPreset, colorsPresetSystem, Tag as default, presetColors, presetSystemColors };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { staticStylish } from "../../styles/theme/customStylishStatic.mjs";
|
|
2
|
+
import { createStaticStyles } from "antd-style";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
//#region src/base-ui/Tag/style.ts
|
|
5
|
+
const styles = createStaticStyles(({ css }) => ({
|
|
6
|
+
borderless: staticStylish.variantBorderlessWithoutHover,
|
|
7
|
+
close: css`
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
gap: 0;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
border: none;
|
|
18
|
+
|
|
19
|
+
color: inherit;
|
|
20
|
+
|
|
21
|
+
background: none;
|
|
22
|
+
`,
|
|
23
|
+
filled: staticStylish.variantFilledWithoutHover,
|
|
24
|
+
large: css`
|
|
25
|
+
height: 28px;
|
|
26
|
+
padding-inline: 12px;
|
|
27
|
+
border-radius: 6px;
|
|
28
|
+
`,
|
|
29
|
+
outlined: staticStylish.variantOutlinedWithoutHover,
|
|
30
|
+
round: css`
|
|
31
|
+
border-radius: 999px;
|
|
32
|
+
`,
|
|
33
|
+
roundLarge: css`
|
|
34
|
+
padding-inline: 14px;
|
|
35
|
+
`,
|
|
36
|
+
roundMiddle: css`
|
|
37
|
+
padding-inline: 10px;
|
|
38
|
+
`,
|
|
39
|
+
roundSmall: css`
|
|
40
|
+
padding-inline: 8px;
|
|
41
|
+
`,
|
|
42
|
+
root: css`
|
|
43
|
+
user-select: none;
|
|
44
|
+
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
gap: 0.4em;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
|
|
50
|
+
width: fit-content;
|
|
51
|
+
height: 22px;
|
|
52
|
+
margin: 0;
|
|
53
|
+
|
|
54
|
+
font-size: inherit;
|
|
55
|
+
line-height: 1.2;
|
|
56
|
+
|
|
57
|
+
span {
|
|
58
|
+
margin: 0;
|
|
59
|
+
line-height: inherit;
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
small: css`
|
|
63
|
+
height: 20px;
|
|
64
|
+
padding-inline: 4px;
|
|
65
|
+
border-radius: 3px;
|
|
66
|
+
`
|
|
67
|
+
}));
|
|
68
|
+
const variants = cva(styles.root, {
|
|
69
|
+
compoundVariants: [
|
|
70
|
+
{
|
|
71
|
+
className: styles.roundSmall,
|
|
72
|
+
shape: "round",
|
|
73
|
+
size: "small"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
className: styles.roundMiddle,
|
|
77
|
+
shape: "round",
|
|
78
|
+
size: "middle"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
className: styles.roundLarge,
|
|
82
|
+
shape: "round",
|
|
83
|
+
size: "large"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
defaultVariants: {
|
|
87
|
+
shape: "normal",
|
|
88
|
+
size: "middle",
|
|
89
|
+
variant: "filled"
|
|
90
|
+
},
|
|
91
|
+
variants: {
|
|
92
|
+
shape: {
|
|
93
|
+
normal: null,
|
|
94
|
+
round: styles.round
|
|
95
|
+
},
|
|
96
|
+
size: {
|
|
97
|
+
large: styles.large,
|
|
98
|
+
middle: null,
|
|
99
|
+
small: styles.small
|
|
100
|
+
},
|
|
101
|
+
variant: {
|
|
102
|
+
borderless: styles.borderless,
|
|
103
|
+
filled: styles.filled,
|
|
104
|
+
outlined: styles.outlined,
|
|
105
|
+
solid: styles.filled
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
//#endregion
|
|
110
|
+
export { styles, variants };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Tag/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { lobeStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css }) => ({\n borderless: lobeStaticStylish.variantBorderlessWithoutHover,\n close: css`\n cursor: pointer;\n\n display: inline-flex;\n gap: 0;\n align-items: center;\n justify-content: center;\n\n margin: 0;\n padding: 0;\n border: none;\n\n color: inherit;\n\n background: none;\n `,\n filled: lobeStaticStylish.variantFilledWithoutHover,\n large: css`\n height: 28px;\n padding-inline: 12px;\n border-radius: 6px;\n `,\n outlined: lobeStaticStylish.variantOutlinedWithoutHover,\n round: css`\n border-radius: 999px;\n `,\n roundLarge: css`\n padding-inline: 14px;\n `,\n roundMiddle: css`\n padding-inline: 10px;\n `,\n roundSmall: css`\n padding-inline: 8px;\n `,\n root: css`\n user-select: none;\n\n display: inline-flex;\n gap: 0.4em;\n align-items: center;\n justify-content: center;\n\n width: fit-content;\n height: 22px;\n margin: 0;\n\n font-size: inherit;\n line-height: 1.2;\n\n span {\n margin: 0;\n line-height: inherit;\n }\n `,\n small: css`\n height: 20px;\n padding-inline: 4px;\n border-radius: 3px;\n `,\n}));\n\nexport const variants = cva(styles.root, {\n compoundVariants: [\n {\n className: styles.roundSmall,\n shape: 'round',\n size: 'small',\n },\n {\n className: styles.roundMiddle,\n shape: 'round',\n size: 'middle',\n },\n {\n className: styles.roundLarge,\n shape: 'round',\n size: 'large',\n },\n ],\n defaultVariants: {\n shape: 'normal',\n size: 'middle',\n variant: 'filled',\n },\n variants: {\n shape: {\n normal: null,\n round: styles.round,\n },\n size: {\n large: styles.large,\n middle: null,\n small: styles.small,\n },\n variant: {\n borderless: styles.borderless,\n filled: styles.filled,\n outlined: styles.outlined,\n solid: styles.filled,\n },\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,WAAW;CACrD,YAAYA,cAAkB;CAC9B,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBV,QAAQA,cAAkB;CAC1B,OAAO,GAAG;;;;;CAKV,UAAUA,cAAkB;CAC5B,OAAO,GAAG;;;CAGV,YAAY,GAAG;;;CAGf,aAAa,GAAG;;;CAGhB,YAAY,GAAG;;;CAGf,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;CAoBT,OAAO,GAAG;;;;;AAKZ,EAAE;AAEF,MAAa,WAAW,IAAI,OAAO,MAAM;CACvC,kBAAkB;EAChB;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;EACA;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;EACA;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;CACF;CACA,iBAAiB;EACf,OAAO;EACP,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,OAAO;GACL,QAAQ;GACR,OAAO,OAAO;EAChB;EACA,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ;GACR,OAAO,OAAO;EAChB;EACA,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,OAAO,OAAO;EAChB;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CSSProperties, ComponentProps, MouseEvent, ReactNode, Ref } from "react";
|
|
2
|
+
//#region src/base-ui/Tag/type.d.ts
|
|
3
|
+
type TagShape = 'normal' | 'round';
|
|
4
|
+
type TagSize = 'small' | 'middle' | 'large';
|
|
5
|
+
type TagVariant = 'filled' | 'outlined' | 'borderless' | 'solid';
|
|
6
|
+
interface TagClassNames {
|
|
7
|
+
closeIcon?: string;
|
|
8
|
+
root?: string;
|
|
9
|
+
}
|
|
10
|
+
interface TagStyles {
|
|
11
|
+
closeIcon?: CSSProperties;
|
|
12
|
+
root?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
interface TagProps extends Omit<ComponentProps<'span'>, 'color'> {
|
|
15
|
+
classNames?: TagClassNames;
|
|
16
|
+
closable?: boolean;
|
|
17
|
+
closeIcon?: ReactNode;
|
|
18
|
+
color?: string;
|
|
19
|
+
icon?: ReactNode;
|
|
20
|
+
onClose?: (e: MouseEvent<HTMLSpanElement>) => void;
|
|
21
|
+
ref?: Ref<HTMLSpanElement>;
|
|
22
|
+
shape?: TagShape;
|
|
23
|
+
size?: TagSize;
|
|
24
|
+
styles?: TagStyles;
|
|
25
|
+
variant?: TagVariant;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { TagClassNames, TagProps, TagShape, TagSize, TagStyles, TagVariant };
|
|
29
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/base-ui/Tag/utils.d.ts
|
|
2
|
+
declare const presetColors: string[];
|
|
3
|
+
declare const presetSystemColors: Set<string>;
|
|
4
|
+
declare const colorsPreset: (type: string, ...keys: string[]) => string;
|
|
5
|
+
declare const colorsPresetSystem: (type: string, ...keys: string[]) => string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { colorsPreset, colorsPresetSystem, presetColors, presetSystemColors };
|
|
8
|
+
//# sourceMappingURL=utils.d.mts.map
|