@cerberus-design/react 0.8.1-next-9e4427f → 0.8.1-next-1c8242e
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/build/legacy/_tsup-dts-rollup.d.cts +15 -10
- package/build/legacy/components/Avatar.cjs +92 -11
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +1 -0
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/FileStatus.cjs +1 -0
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +1 -0
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +1 -0
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +1 -0
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +1 -0
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +1 -0
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/config/cerbIcons.cjs +1 -0
- package/build/legacy/config/cerbIcons.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +1 -0
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +1 -0
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +1 -0
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +1 -0
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +115 -97
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +15 -10
- package/build/modern/{chunk-ID3XWGLY.js → chunk-4YJOK7JJ.js} +2 -2
- package/build/modern/{chunk-GUECLKHY.js → chunk-BDCFYW34.js} +3 -1
- package/build/modern/chunk-BDCFYW34.js.map +1 -0
- package/build/modern/{chunk-HMYC7CR3.js → chunk-CZMC77YO.js} +3 -3
- package/build/modern/{chunk-53QBTZZF.js → chunk-FMFKM2AB.js} +2 -2
- package/build/modern/{chunk-3JF6LWXF.js → chunk-GB3SECCO.js} +2 -2
- package/build/modern/{chunk-OGAH7HBD.js → chunk-KKJKOKP7.js} +2 -2
- package/build/modern/{chunk-7NX4RGDB.js → chunk-MLCVO7JP.js} +2 -2
- package/build/modern/{chunk-5WVXIAG2.js → chunk-NBG2OSYI.js} +2 -2
- package/build/modern/{chunk-EJIMJWPB.js → chunk-QZ6NS6VN.js} +2 -2
- package/build/modern/{chunk-TF3HRELU.js → chunk-TUIVLIJI.js} +2 -2
- package/build/modern/{chunk-ZYXEVTIX.js → chunk-UN3OAW56.js} +27 -7
- package/build/modern/chunk-UN3OAW56.js.map +1 -0
- package/build/modern/{chunk-RHG26FYL.js → chunk-VRPAW76S.js} +2 -2
- package/build/modern/{chunk-4FD33RTW.js → chunk-ZCIJRM2X.js} +2 -2
- package/build/modern/components/Avatar.js +4 -1
- package/build/modern/components/Checkbox.js +3 -3
- package/build/modern/components/FileStatus.js +3 -3
- package/build/modern/components/FileUploader.js +3 -3
- package/build/modern/components/Input.js +3 -3
- package/build/modern/components/Notification.js +3 -3
- package/build/modern/components/Select.js +3 -3
- package/build/modern/components/Toggle.js +3 -3
- package/build/modern/config/cerbIcons.js +1 -1
- package/build/modern/config/defineIcons.js +2 -2
- package/build/modern/context/confirm-modal.js +3 -3
- package/build/modern/context/notification-center.js +4 -4
- package/build/modern/context/prompt-modal.js +4 -4
- package/build/modern/index.js +13 -13
- package/package.json +2 -2
- package/src/components/Avatar.tsx +33 -14
- package/src/config/cerbIcons.ts +3 -0
- package/build/modern/chunk-GUECLKHY.js.map +0 -1
- package/build/modern/chunk-ZYXEVTIX.js.map +0 -1
- /package/build/modern/{chunk-ID3XWGLY.js.map → chunk-4YJOK7JJ.js.map} +0 -0
- /package/build/modern/{chunk-HMYC7CR3.js.map → chunk-CZMC77YO.js.map} +0 -0
- /package/build/modern/{chunk-53QBTZZF.js.map → chunk-FMFKM2AB.js.map} +0 -0
- /package/build/modern/{chunk-3JF6LWXF.js.map → chunk-GB3SECCO.js.map} +0 -0
- /package/build/modern/{chunk-OGAH7HBD.js.map → chunk-KKJKOKP7.js.map} +0 -0
- /package/build/modern/{chunk-7NX4RGDB.js.map → chunk-MLCVO7JP.js.map} +0 -0
- /package/build/modern/{chunk-5WVXIAG2.js.map → chunk-NBG2OSYI.js.map} +0 -0
- /package/build/modern/{chunk-EJIMJWPB.js.map → chunk-QZ6NS6VN.js.map} +0 -0
- /package/build/modern/{chunk-TF3HRELU.js.map → chunk-TUIVLIJI.js.map} +0 -0
- /package/build/modern/{chunk-RHG26FYL.js.map → chunk-VRPAW76S.js.map} +0 -0
- /package/build/modern/{chunk-4FD33RTW.js.map → chunk-ZCIJRM2X.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
avatar,
|
|
5
5
|
type AvatarVariantProps,
|
|
6
6
|
} from '@cerberus/styled-system/recipes'
|
|
7
|
-
import {
|
|
7
|
+
import { $cerberusIcons } from '../config/defineIcons'
|
|
8
8
|
import type { HtmlHTMLAttributes, ReactNode } from 'react'
|
|
9
9
|
import { Show } from './Show'
|
|
10
10
|
|
|
@@ -13,19 +13,21 @@ import { Show } from './Show'
|
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
as?: never
|
|
19
|
-
src: string
|
|
16
|
+
export type SharedAvatarProps = {
|
|
17
|
+
icon?: ReactNode
|
|
20
18
|
width?: number
|
|
21
19
|
height?: number
|
|
22
20
|
}
|
|
23
|
-
export type
|
|
21
|
+
export type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> &
|
|
22
|
+
SharedAvatarProps & {
|
|
23
|
+
ariaLabel: string
|
|
24
|
+
as?: never
|
|
25
|
+
src: string
|
|
26
|
+
}
|
|
27
|
+
export type AvatarAsProps = SharedAvatarProps & {
|
|
24
28
|
as: ReactNode
|
|
25
29
|
ariaLabel?: never
|
|
26
30
|
src?: never
|
|
27
|
-
width?: never
|
|
28
|
-
height?: never
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &
|
|
@@ -44,8 +46,18 @@ export type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &
|
|
|
44
46
|
* ```
|
|
45
47
|
*/
|
|
46
48
|
export function Avatar(props: AvatarProps) {
|
|
47
|
-
const {
|
|
48
|
-
|
|
49
|
+
const {
|
|
50
|
+
ariaLabel,
|
|
51
|
+
as,
|
|
52
|
+
gradient,
|
|
53
|
+
size,
|
|
54
|
+
src,
|
|
55
|
+
width,
|
|
56
|
+
height,
|
|
57
|
+
icon,
|
|
58
|
+
...nativeProps
|
|
59
|
+
} = props
|
|
60
|
+
const { avatar: AvatarIcon } = $cerberusIcons
|
|
49
61
|
const initials = (ariaLabel || '')
|
|
50
62
|
.split(' ')
|
|
51
63
|
.map((word) => word[0])
|
|
@@ -67,12 +79,19 @@ export function Avatar(props: AvatarProps) {
|
|
|
67
79
|
<Show
|
|
68
80
|
when={Boolean(initials)}
|
|
69
81
|
fallback={
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
<Show
|
|
83
|
+
when={Boolean(icon)}
|
|
84
|
+
fallback={
|
|
85
|
+
<AvatarIcon
|
|
86
|
+
size={iconSizeMap[size as keyof typeof iconSizeMap]}
|
|
87
|
+
/>
|
|
88
|
+
}
|
|
89
|
+
>
|
|
90
|
+
{icon}
|
|
91
|
+
</Show>
|
|
73
92
|
}
|
|
74
93
|
>
|
|
75
|
-
|
|
94
|
+
{initials}
|
|
76
95
|
</Show>
|
|
77
96
|
}
|
|
78
97
|
>
|
package/src/config/cerbIcons.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
InformationFilled,
|
|
10
10
|
Restart,
|
|
11
11
|
TrashCan,
|
|
12
|
+
UserFilled,
|
|
12
13
|
Warning,
|
|
13
14
|
WarningFilled,
|
|
14
15
|
type CarbonIconType,
|
|
@@ -19,6 +20,7 @@ import { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'
|
|
|
19
20
|
export type IconType = CarbonIconType | ElementType
|
|
20
21
|
|
|
21
22
|
export interface DefinedIcons {
|
|
23
|
+
avatar?: IconType
|
|
22
24
|
checkbox?: IconType
|
|
23
25
|
close?: IconType
|
|
24
26
|
confirmModal?: IconType
|
|
@@ -38,6 +40,7 @@ export interface DefinedIcons {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export const defaultIcons: DefinedIcons = {
|
|
43
|
+
avatar: UserFilled,
|
|
41
44
|
checkbox: CheckmarkIcon,
|
|
42
45
|
close: CloseFilled,
|
|
43
46
|
confirmModal: Information,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/cerbIcons.ts"],"sourcesContent":["import {\n Checkmark,\n CheckmarkFilled,\n ChevronDown,\n CloseFilled,\n CloudUpload,\n ErrorFilled,\n Information,\n InformationFilled,\n Restart,\n TrashCan,\n Warning,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: IconType\n fileUploader?: IconType\n indeterminate?: IconType\n infoNotification?: IconType\n successNotification?: IconType\n warningNotification?: IconType\n dangerNotification?: IconType\n invalid: IconType\n invalidAlt?: IconType\n redo?: IconType\n selectArrow?: IconType\n toggleChecked?: IconType\n}\n\nexport const defaultIcons: DefinedIcons = {\n checkbox: CheckmarkIcon,\n close: CloseFilled,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n fileUploader: CloudUpload,\n indeterminate: IndeterminateIcon,\n infoNotification: InformationFilled,\n successNotification: CheckmarkFilled,\n warningNotification: WarningFilled,\n dangerNotification: ErrorFilled,\n invalid: WarningFilled,\n invalidAlt: Warning,\n redo: Restart,\n selectArrow: ChevronDown,\n toggleChecked: Checkmark,\n}\n"],"mappings":";;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAyBA,IAAM,eAA6B;AAAA,EACxC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,cAAc;AAAA,EACd,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,eAAe;AACjB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Avatar.tsx"],"sourcesContent":["import { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { UserFilled } from '@cerberus/icons'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> & {\n ariaLabel: string\n as?: never\n src: string\n width?: number\n height?: number\n}\nexport type AvatarAsProps = {\n as: ReactNode\n ariaLabel?: never\n src?: never\n width?: never\n height?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @definition [Avatar docs](https://cerberus.digitalu.design/react/avatar)\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const { ariaLabel, as, gradient, size, src, width, height, ...nativeProps } =\n props\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <UserFilled\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n <>{initials}</>\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n"],"mappings":";;;;;AAAA,SAAS,KAAK,UAAU;AACxB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,kBAAkB;AA+Db,SAKF,UALE;AAxBP,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,WAAW,IAAI,UAAU,MAAM,KAAK,OAAO,QAAQ,GAAG,YAAY,IACxE;AACF,QAAM,YAAY,aAAa,IAC5B,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE,EACP,MAAM,GAAG,CAAC;AAEb,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO,EAAE,UAAU,KAAK,CAAC;AAAA,QACzB,OAAO;AAAA,MACT;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,QAAQ,GAAG,KAAK,QAAQ,EAAE;AAAA,UAChC,UACE;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,QAAQ,QAAQ;AAAA,cACtB,UACE;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAM,YAAY,IAAgC;AAAA;AAAA,cACpD;AAAA,cAGF,0CAAG,oBAAS;AAAA;AAAA,UACd;AAAA,UAGF;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,QAAQ,EAAE;AAAA,cAChB,UACE;AAAA,gBAAC;AAAA;AAAA,kBACC,KAAK,MAAM;AAAA,kBACX,WAAW,IAAI;AAAA,oBACb,GAAG;AAAA,oBACH,WAAW;AAAA,oBACX,GAAG;AAAA,kBACL,CAAC;AAAA,kBACD,UAAS;AAAA,kBACT,SAAQ;AAAA,kBACR;AAAA,kBACA;AAAA,kBACA;AAAA;AAAA,cACF;AAAA,cAGD;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|