@workday/canvas-kit-preview-react 14.0.0-alpha.1212-next.0 → 14.0.0-alpha.1213-next.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.
Files changed (64) hide show
  1. package/avatar/index.ts +5 -0
  2. package/avatar/lib/Avatar.tsx +152 -0
  3. package/avatar/lib/AvatarImage.tsx +20 -0
  4. package/avatar/lib/AvatarName.tsx +32 -0
  5. package/avatar/lib/BaseAvatar.tsx +127 -0
  6. package/avatar/lib/getInitialsFromName.ts +11 -0
  7. package/avatar/package.json +6 -0
  8. package/dist/commonjs/avatar/index.d.ts +6 -0
  9. package/dist/commonjs/avatar/index.d.ts.map +1 -0
  10. package/dist/commonjs/avatar/index.js +21 -0
  11. package/dist/commonjs/avatar/lib/Avatar.d.ts +234 -0
  12. package/dist/commonjs/avatar/lib/Avatar.d.ts.map +1 -0
  13. package/dist/commonjs/avatar/lib/Avatar.js +51 -0
  14. package/dist/commonjs/avatar/lib/AvatarImage.d.ts +6 -0
  15. package/dist/commonjs/avatar/lib/AvatarImage.d.ts.map +1 -0
  16. package/dist/commonjs/avatar/lib/AvatarImage.js +15 -0
  17. package/dist/commonjs/avatar/lib/AvatarName.d.ts +14 -0
  18. package/dist/commonjs/avatar/lib/AvatarName.d.ts.map +1 -0
  19. package/dist/commonjs/avatar/lib/AvatarName.js +16 -0
  20. package/dist/commonjs/avatar/lib/BaseAvatar.d.ts +148 -0
  21. package/dist/commonjs/avatar/lib/BaseAvatar.d.ts.map +1 -0
  22. package/dist/commonjs/avatar/lib/BaseAvatar.js +47 -0
  23. package/dist/commonjs/avatar/lib/getInitialsFromName.d.ts +2 -0
  24. package/dist/commonjs/avatar/lib/getInitialsFromName.d.ts.map +1 -0
  25. package/dist/commonjs/avatar/lib/getInitialsFromName.js +13 -0
  26. package/dist/commonjs/index.d.ts +2 -1
  27. package/dist/commonjs/index.d.ts.map +1 -1
  28. package/dist/commonjs/index.js +2 -1
  29. package/dist/commonjs/information-highlight/lib/InformationHighlight.d.ts +3 -3
  30. package/dist/commonjs/information-highlight/lib/hooks/useInformationHighlightModel.d.ts +5 -5
  31. package/dist/commonjs/information-highlight/lib/parts/Icon.d.ts +1 -1
  32. package/dist/commonjs/pill/lib/PillAvatar.d.ts +158 -169
  33. package/dist/commonjs/pill/lib/PillAvatar.d.ts.map +1 -1
  34. package/dist/commonjs/pill/lib/PillAvatar.js +5 -4
  35. package/dist/es6/avatar/index.d.ts +6 -0
  36. package/dist/es6/avatar/index.d.ts.map +1 -0
  37. package/dist/es6/avatar/index.js +5 -0
  38. package/dist/es6/avatar/lib/Avatar.d.ts +234 -0
  39. package/dist/es6/avatar/lib/Avatar.d.ts.map +1 -0
  40. package/dist/es6/avatar/lib/Avatar.js +45 -0
  41. package/dist/es6/avatar/lib/AvatarImage.d.ts +6 -0
  42. package/dist/es6/avatar/lib/AvatarImage.d.ts.map +1 -0
  43. package/dist/es6/avatar/lib/AvatarImage.js +12 -0
  44. package/dist/es6/avatar/lib/AvatarName.d.ts +14 -0
  45. package/dist/es6/avatar/lib/AvatarName.d.ts.map +1 -0
  46. package/dist/es6/avatar/lib/AvatarName.js +13 -0
  47. package/dist/es6/avatar/lib/BaseAvatar.d.ts +148 -0
  48. package/dist/es6/avatar/lib/BaseAvatar.d.ts.map +1 -0
  49. package/dist/es6/avatar/lib/BaseAvatar.js +44 -0
  50. package/dist/es6/avatar/lib/getInitialsFromName.d.ts +2 -0
  51. package/dist/es6/avatar/lib/getInitialsFromName.d.ts.map +1 -0
  52. package/dist/es6/avatar/lib/getInitialsFromName.js +9 -0
  53. package/dist/es6/index.d.ts +2 -1
  54. package/dist/es6/index.d.ts.map +1 -1
  55. package/dist/es6/index.js +2 -1
  56. package/dist/es6/information-highlight/lib/InformationHighlight.d.ts +3 -3
  57. package/dist/es6/information-highlight/lib/hooks/useInformationHighlightModel.d.ts +5 -5
  58. package/dist/es6/information-highlight/lib/parts/Icon.d.ts +1 -1
  59. package/dist/es6/pill/lib/PillAvatar.d.ts +158 -169
  60. package/dist/es6/pill/lib/PillAvatar.d.ts.map +1 -1
  61. package/dist/es6/pill/lib/PillAvatar.js +5 -4
  62. package/index.ts +2 -1
  63. package/package.json +4 -4
  64. package/pill/lib/PillAvatar.tsx +7 -3
@@ -0,0 +1,5 @@
1
+ export * from './lib/Avatar';
2
+ export * from './lib/AvatarImage';
3
+ export * from './lib/AvatarName';
4
+ export * from './lib/BaseAvatar';
5
+ export * from './lib/getInitialsFromName';
@@ -0,0 +1,152 @@
1
+ import React from 'react';
2
+
3
+ import {createComponent} from '@workday/canvas-kit-react/common';
4
+ import {Property} from 'csstype';
5
+ import {createStencil, handleCsProp} from '@workday/canvas-kit-styling';
6
+
7
+ import {BaseAvatarProps, BaseAvatar, baseAvatarStencil} from './BaseAvatar';
8
+ import {AvatarNameProps} from './AvatarName';
9
+
10
+ export interface AvatarProps extends BaseAvatarProps, AvatarNameProps {
11
+ /**
12
+ * The URL of the user's photo. For best fit, use square images.
13
+ */
14
+ url?: string;
15
+ /**
16
+ * An objectFit property that can customize how to resize your image to fit its container.
17
+ * @default "contain"
18
+ */
19
+ objectFit?: Property.ObjectFit;
20
+ /**
21
+ * If true, the Avatar won't forward the `name` prop to the `alt` attribute of the image. This is useful when the Avatar is purely decorative and is rendered next to a name or text.
22
+ */
23
+ isDecorative?: boolean;
24
+ }
25
+
26
+ export const avatarStencil = createStencil({
27
+ extends: baseAvatarStencil,
28
+ parts: {
29
+ avatarImage: 'avatar-image',
30
+ avatarName: 'avatar-name',
31
+ },
32
+ base: {},
33
+ modifiers: {
34
+ imageLoaded: {
35
+ false: ({avatarImagePart}) => ({
36
+ [avatarImagePart]: {
37
+ display: 'none',
38
+ },
39
+ }),
40
+ },
41
+ objectFit: {
42
+ contain: ({avatarImagePart}) => ({
43
+ [avatarImagePart]: {
44
+ objectFit: 'contain',
45
+ },
46
+ }),
47
+ cover: ({avatarImagePart}) => ({
48
+ [avatarImagePart]: {
49
+ objectFit: 'cover',
50
+ },
51
+ }),
52
+ fill: ({avatarImagePart}) => ({
53
+ [avatarImagePart]: {
54
+ objectFit: 'fill',
55
+ },
56
+ }),
57
+ none: ({avatarImagePart}) => ({
58
+ [avatarImagePart]: {
59
+ objectFit: 'none',
60
+ },
61
+ }),
62
+ ['scale-down']: ({avatarImagePart}) => ({
63
+ [avatarImagePart]: {
64
+ objectFit: 'scale-down',
65
+ },
66
+ }),
67
+ initial: ({avatarImagePart}) => ({
68
+ [avatarImagePart]: {
69
+ objectFit: 'initial',
70
+ },
71
+ }),
72
+
73
+ inherit: ({avatarImagePart}) => ({
74
+ [avatarImagePart]: {
75
+ objectFit: 'inherit',
76
+ },
77
+ }),
78
+ unset: ({avatarImagePart}) => ({
79
+ [avatarImagePart]: {
80
+ objectFit: 'unset',
81
+ },
82
+ }),
83
+ ['-moz-initial']: ({avatarImagePart}) => ({
84
+ [avatarImagePart]: {
85
+ objectFit: '-moz-initial',
86
+ },
87
+ }),
88
+ ['revert']: ({avatarImagePart}) => ({
89
+ [avatarImagePart]: {
90
+ objectFit: 'revert',
91
+ },
92
+ }),
93
+ },
94
+ },
95
+ });
96
+
97
+ /**
98
+ * JSDoc for Avatar. Will be part of the Component API docs
99
+ */
100
+ export const Avatar = createComponent('div')({
101
+ displayName: 'Avatar',
102
+
103
+ Component: (
104
+ {
105
+ url,
106
+ name,
107
+ variant,
108
+ objectFit = 'cover',
109
+ preferredInitials,
110
+ isDecorative,
111
+ size,
112
+ ...elemProps
113
+ }: AvatarProps,
114
+ ref,
115
+ Element
116
+ ) => {
117
+ const [imageLoaded, setImageLoaded] = React.useState(false);
118
+
119
+ const handleImageLoad = () => {
120
+ if (!imageLoaded) {
121
+ setImageLoaded(true);
122
+ }
123
+ };
124
+
125
+ return (
126
+ <BaseAvatar
127
+ as={Element}
128
+ ref={ref}
129
+ {...handleCsProp(elemProps, avatarStencil({variant, size, imageLoaded, objectFit}))}
130
+ >
131
+ {url && (
132
+ <>
133
+ <BaseAvatar.Image
134
+ onLoad={handleImageLoad}
135
+ src={url}
136
+ alt={isDecorative ? undefined : name}
137
+ aria-hidden={isDecorative}
138
+ {...avatarStencil.parts.avatarImage}
139
+ />
140
+ </>
141
+ )}
142
+ {name && (!url || !imageLoaded) && (
143
+ <BaseAvatar.Name
144
+ name={name}
145
+ preferredInitials={preferredInitials}
146
+ {...avatarStencil.parts.avatarName}
147
+ />
148
+ )}
149
+ </BaseAvatar>
150
+ );
151
+ },
152
+ });
@@ -0,0 +1,20 @@
1
+ import {createComponent} from '@workday/canvas-kit-react/common';
2
+
3
+ import {handleCsProp, createStencil, CSProps} from '@workday/canvas-kit-styling';
4
+
5
+ export interface AvatarImageProps extends CSProps {}
6
+
7
+ export const avatarImageStencil = createStencil({
8
+ base: {
9
+ height: '100%',
10
+ width: '100%',
11
+ objectFit: 'cover',
12
+ },
13
+ });
14
+
15
+ export const AvatarImage = createComponent('img')({
16
+ displayName: 'AvatarImage',
17
+ Component: ({...elemProps}: AvatarImageProps, ref, Element) => {
18
+ return <Element ref={ref} {...handleCsProp(elemProps, avatarImageStencil())} />;
19
+ },
20
+ });
@@ -0,0 +1,32 @@
1
+ import {createComponent} from '@workday/canvas-kit-react/common';
2
+ import {CSProps, handleCsProp, createStencil} from '@workday/canvas-kit-styling';
3
+ import {getInitialsFromName} from './getInitialsFromName';
4
+
5
+ export interface AvatarNameProps extends CSProps {
6
+ /**
7
+ * The alt text of the Avatar image. This prop is also used for the initials. The first letter of the first name and the first letter of the second name are chosen for the initials.
8
+ */
9
+ name: string;
10
+ /**
11
+ * If you want full control over the initials, use `preferredInitials` instead.
12
+ */
13
+ preferredInitials?: string;
14
+ }
15
+
16
+ export const avatarNameStencil = createStencil({
17
+ base: {
18
+ textTransform: 'uppercase',
19
+ cursor: 'default',
20
+ },
21
+ });
22
+
23
+ export const AvatarName = createComponent('span')({
24
+ displayName: 'AvatarName',
25
+ Component: ({name, preferredInitials, ...elemProps}: AvatarNameProps, ref, Element) => {
26
+ return (
27
+ <Element ref={ref} {...handleCsProp(elemProps, avatarNameStencil())}>
28
+ {preferredInitials || getInitialsFromName(name)}
29
+ </Element>
30
+ );
31
+ },
32
+ });
@@ -0,0 +1,127 @@
1
+ import React from 'react';
2
+
3
+ import {createComponent} from '@workday/canvas-kit-react/common';
4
+
5
+ import {AvatarImage} from './AvatarImage';
6
+ import {AvatarName} from './AvatarName';
7
+ import {createStencil, cssVar, calc, handleCsProp, CSProps} from '@workday/canvas-kit-styling';
8
+ import {system, base} from '@workday/canvas-tokens-web';
9
+
10
+ export interface BaseAvatarProps extends CSProps {
11
+ /**
12
+ * Children of the BaseAvatar.
13
+ */
14
+ children?: React.ReactNode;
15
+ /**
16
+ * The variant of the Avatar.
17
+ * @default "blue"
18
+ */
19
+ variant?: 'blue' | 'amber' | 'teal' | 'purple';
20
+
21
+ /**
22
+ * The size of the Avatar.
23
+ * `extraExtraSmall` is 24px x 24px
24
+ * `extraSmall` is 32px x 32px
25
+ * `small` is 40px x 40px
26
+ * `medium` is 48px x 48px
27
+ * `large` is 72px x 72px
28
+ * `extraLarge` is 96px x 96px
29
+ * `extraExtraLarge` is 120px x 120px
30
+ * @default "medium"
31
+ */
32
+ size?:
33
+ | 'extraExtraSmall'
34
+ | 'extraSmall'
35
+ | 'small'
36
+ | 'medium'
37
+ | 'large'
38
+ | 'extraLarge'
39
+ | 'extraExtraLarge'
40
+ | (string & {});
41
+ }
42
+
43
+ export const baseAvatarStencil = createStencil({
44
+ vars: {
45
+ backgroundColor: '',
46
+ color: '',
47
+ size: '',
48
+ },
49
+ base: ({backgroundColor, color, size}) => ({
50
+ borderRadius: system.shape.round,
51
+ width: cssVar(size, calc.add(system.space.x10, system.space.x2)),
52
+ height: cssVar(size, calc.add(system.space.x10, system.space.x2)),
53
+ backgroundColor: cssVar(backgroundColor, base.blue300),
54
+ color: cssVar(color, base.blue800),
55
+ display: 'flex',
56
+ alignItems: 'center',
57
+ justifyContent: 'center',
58
+ overflow: 'hidden',
59
+ border: 'none',
60
+ ...system.type.body.medium,
61
+ }),
62
+ modifiers: {
63
+ variant: {
64
+ blue: ({backgroundColor, color}) => ({
65
+ backgroundColor: cssVar(backgroundColor, base.blue300),
66
+ color: cssVar(color, base.blue800),
67
+ }),
68
+ amber: ({backgroundColor, color}) => ({
69
+ backgroundColor: cssVar(backgroundColor, base.amber200),
70
+ color: cssVar(color, base.amber700),
71
+ }),
72
+
73
+ teal: ({backgroundColor, color}) => ({
74
+ backgroundColor: cssVar(backgroundColor, base.teal300),
75
+ color: cssVar(color, base.teal800),
76
+ }),
77
+ purple: ({backgroundColor, color}) => ({
78
+ backgroundColor: cssVar(backgroundColor, base.purple300),
79
+ color: cssVar(color, base.purple800),
80
+ }),
81
+ },
82
+ size: {
83
+ extraExtraSmall: ({size}) => ({
84
+ [size]: system.space.x6,
85
+ ...system.type.subtext.small,
86
+ }),
87
+ extraSmall: ({size}) => ({
88
+ [size]: system.space.x8,
89
+ ...system.type.subtext.medium,
90
+ }),
91
+ small: ({size}) => ({
92
+ [size]: system.space.x10,
93
+ ...system.type.body.small,
94
+ }),
95
+ medium: ({size}) => ({
96
+ [size]: calc.add(system.space.x10, system.space.x2),
97
+ ...system.type.body.medium,
98
+ }),
99
+ large: ({size}) => ({
100
+ [size]: calc.add(system.space.x16, system.space.x2),
101
+ ...system.type.heading.medium,
102
+ }),
103
+ extraLarge: ({size}) => ({
104
+ [size]: calc.add(system.space.x20, system.space.x4),
105
+ ...system.type.title.small,
106
+ }),
107
+ extraExtraLarge: ({size}) => ({
108
+ [size]: calc.multiply(system.space.x10, 3),
109
+ ...system.type.title.medium,
110
+ }),
111
+ },
112
+ },
113
+ });
114
+
115
+ /**
116
+ * JSDoc for Avatar. Will be part of the Component API docs
117
+ */
118
+ export const BaseAvatar = createComponent('div')({
119
+ displayName: 'BaseAvatar',
120
+ subComponents: {
121
+ Image: AvatarImage,
122
+ Name: AvatarName,
123
+ },
124
+ Component: ({variant, size, ...elemProps}: BaseAvatarProps, ref, Element) => {
125
+ return <Element ref={ref} {...handleCsProp(elemProps, baseAvatarStencil({variant, size}))} />;
126
+ },
127
+ });
@@ -0,0 +1,11 @@
1
+ export const getInitialsFromName = (name: string) => {
2
+ // Trim and split by one or more whitespace characters
3
+ const nameParts = name.trim().split(/\s+/).filter(Boolean);
4
+
5
+ const first = nameParts[0];
6
+ const firstInitial = first?.[0] || '';
7
+ const last = nameParts.length > 1 ? nameParts[nameParts.length - 1] : undefined;
8
+ const lastInitial = last?.[0] || '';
9
+
10
+ return `${firstInitial}${lastInitial}`;
11
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../dist/commonjs/avatar",
3
+ "module": "../dist/es6/avatar",
4
+ "sideEffects": false,
5
+ "types": "../dist/es6/avatar"
6
+ }
@@ -0,0 +1,6 @@
1
+ export * from './lib/Avatar';
2
+ export * from './lib/AvatarImage';
3
+ export * from './lib/AvatarName';
4
+ export * from './lib/BaseAvatar';
5
+ export * from './lib/getInitialsFromName';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../avatar/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/Avatar"), exports);
18
+ __exportStar(require("./lib/AvatarImage"), exports);
19
+ __exportStar(require("./lib/AvatarName"), exports);
20
+ __exportStar(require("./lib/BaseAvatar"), exports);
21
+ __exportStar(require("./lib/getInitialsFromName"), exports);
@@ -0,0 +1,234 @@
1
+ import { Property } from 'csstype';
2
+ import { BaseAvatarProps } from './BaseAvatar';
3
+ import { AvatarNameProps } from './AvatarName';
4
+ export interface AvatarProps extends BaseAvatarProps, AvatarNameProps {
5
+ /**
6
+ * The URL of the user's photo. For best fit, use square images.
7
+ */
8
+ url?: string;
9
+ /**
10
+ * An objectFit property that can customize how to resize your image to fit its container.
11
+ * @default "contain"
12
+ */
13
+ objectFit?: Property.ObjectFit;
14
+ /**
15
+ * If true, the Avatar won't forward the `name` prop to the `alt` attribute of the image. This is useful when the Avatar is purely decorative and is rendered next to a name or text.
16
+ */
17
+ isDecorative?: boolean;
18
+ }
19
+ export declare const avatarStencil: import("@workday/canvas-kit-styling").Stencil<{
20
+ imageLoaded: {
21
+ false: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
22
+ readonly avatarImage: "avatar-image";
23
+ readonly avatarName: "avatar-name";
24
+ }>) => {
25
+ "[data-part=\"avatar-image\"]": {
26
+ display: "none";
27
+ };
28
+ };
29
+ };
30
+ objectFit: {
31
+ contain: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
32
+ readonly avatarImage: "avatar-image";
33
+ readonly avatarName: "avatar-name";
34
+ }>) => {
35
+ "[data-part=\"avatar-image\"]": {
36
+ objectFit: "contain";
37
+ };
38
+ };
39
+ cover: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
40
+ readonly avatarImage: "avatar-image";
41
+ readonly avatarName: "avatar-name";
42
+ }>) => {
43
+ "[data-part=\"avatar-image\"]": {
44
+ objectFit: "cover";
45
+ };
46
+ };
47
+ fill: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
48
+ readonly avatarImage: "avatar-image";
49
+ readonly avatarName: "avatar-name";
50
+ }>) => {
51
+ "[data-part=\"avatar-image\"]": {
52
+ objectFit: "fill";
53
+ };
54
+ };
55
+ none: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
56
+ readonly avatarImage: "avatar-image";
57
+ readonly avatarName: "avatar-name";
58
+ }>) => {
59
+ "[data-part=\"avatar-image\"]": {
60
+ objectFit: "none";
61
+ };
62
+ };
63
+ "scale-down": ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
64
+ readonly avatarImage: "avatar-image";
65
+ readonly avatarName: "avatar-name";
66
+ }>) => {
67
+ "[data-part=\"avatar-image\"]": {
68
+ objectFit: "scale-down";
69
+ };
70
+ };
71
+ initial: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
72
+ readonly avatarImage: "avatar-image";
73
+ readonly avatarName: "avatar-name";
74
+ }>) => {
75
+ "[data-part=\"avatar-image\"]": {
76
+ objectFit: "initial";
77
+ };
78
+ };
79
+ inherit: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
80
+ readonly avatarImage: "avatar-image";
81
+ readonly avatarName: "avatar-name";
82
+ }>) => {
83
+ "[data-part=\"avatar-image\"]": {
84
+ objectFit: "inherit";
85
+ };
86
+ };
87
+ unset: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
88
+ readonly avatarImage: "avatar-image";
89
+ readonly avatarName: "avatar-name";
90
+ }>) => {
91
+ "[data-part=\"avatar-image\"]": {
92
+ objectFit: "unset";
93
+ };
94
+ };
95
+ "-moz-initial": ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
96
+ readonly avatarImage: "avatar-image";
97
+ readonly avatarName: "avatar-name";
98
+ }>) => {
99
+ "[data-part=\"avatar-image\"]": {
100
+ objectFit: "-moz-initial";
101
+ };
102
+ };
103
+ revert: ({ avatarImagePart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
104
+ readonly avatarImage: "avatar-image";
105
+ readonly avatarName: "avatar-name";
106
+ }>) => {
107
+ "[data-part=\"avatar-image\"]": {
108
+ objectFit: "revert";
109
+ };
110
+ };
111
+ };
112
+ }, {
113
+ readonly avatarImage: "avatar-image";
114
+ readonly avatarName: "avatar-name";
115
+ }, {}, import("@workday/canvas-kit-styling").Stencil<{
116
+ variant: {
117
+ blue: ({ backgroundColor, color }: {
118
+ backgroundColor: string;
119
+ color: string;
120
+ size: string;
121
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
122
+ backgroundColor: string;
123
+ color: string;
124
+ };
125
+ amber: ({ backgroundColor, color }: {
126
+ backgroundColor: string;
127
+ color: string;
128
+ size: string;
129
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
130
+ backgroundColor: string;
131
+ color: string;
132
+ };
133
+ teal: ({ backgroundColor, color }: {
134
+ backgroundColor: string;
135
+ color: string;
136
+ size: string;
137
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
138
+ backgroundColor: string;
139
+ color: string;
140
+ };
141
+ purple: ({ backgroundColor, color }: {
142
+ backgroundColor: string;
143
+ color: string;
144
+ size: string;
145
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
146
+ backgroundColor: string;
147
+ color: string;
148
+ };
149
+ };
150
+ size: {
151
+ extraExtraSmall: ({ size }: {
152
+ backgroundColor: string;
153
+ color: string;
154
+ size: string;
155
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
156
+ fontFamily: "--cnvs-sys-font-family-default";
157
+ fontWeight: "--cnvs-sys-font-weight-normal";
158
+ lineHeight: "--cnvs-sys-line-height-subtext-small";
159
+ fontSize: "--cnvs-sys-font-size-subtext-small";
160
+ letterSpacing: "--cnvs-base-letter-spacing-50";
161
+ };
162
+ extraSmall: ({ size }: {
163
+ backgroundColor: string;
164
+ color: string;
165
+ size: string;
166
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
167
+ fontFamily: "--cnvs-sys-font-family-default";
168
+ fontWeight: "--cnvs-sys-font-weight-normal";
169
+ lineHeight: "--cnvs-sys-line-height-subtext-medium";
170
+ fontSize: "--cnvs-sys-font-size-subtext-medium";
171
+ letterSpacing: "--cnvs-base-letter-spacing-100";
172
+ };
173
+ small: ({ size }: {
174
+ backgroundColor: string;
175
+ color: string;
176
+ size: string;
177
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
178
+ fontFamily: "--cnvs-sys-font-family-default";
179
+ fontWeight: "--cnvs-sys-font-weight-normal";
180
+ lineHeight: "--cnvs-sys-line-height-body-small";
181
+ fontSize: "--cnvs-sys-font-size-body-small";
182
+ letterSpacing: "--cnvs-base-letter-spacing-200";
183
+ };
184
+ medium: ({ size }: {
185
+ backgroundColor: string;
186
+ color: string;
187
+ size: string;
188
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
189
+ fontFamily: "--cnvs-sys-font-family-default";
190
+ fontWeight: "--cnvs-sys-font-weight-normal";
191
+ lineHeight: "--cnvs-sys-line-height-body-medium";
192
+ fontSize: "--cnvs-sys-font-size-body-medium";
193
+ };
194
+ large: ({ size }: {
195
+ backgroundColor: string;
196
+ color: string;
197
+ size: string;
198
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
199
+ fontFamily: "--cnvs-sys-font-family-default";
200
+ fontWeight: "--cnvs-sys-font-weight-bold";
201
+ lineHeight: "--cnvs-sys-line-height-heading-medium";
202
+ fontSize: "--cnvs-sys-font-size-heading-medium";
203
+ };
204
+ extraLarge: ({ size }: {
205
+ backgroundColor: string;
206
+ color: string;
207
+ size: string;
208
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
209
+ fontFamily: "--cnvs-sys-font-family-default";
210
+ fontWeight: "--cnvs-sys-font-weight-bold";
211
+ lineHeight: "--cnvs-sys-line-height-title-small";
212
+ fontSize: "--cnvs-sys-font-size-title-small";
213
+ };
214
+ extraExtraLarge: ({ size }: {
215
+ backgroundColor: string;
216
+ color: string;
217
+ size: string;
218
+ } & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
219
+ fontFamily: "--cnvs-sys-font-family-default";
220
+ fontWeight: "--cnvs-sys-font-weight-bold";
221
+ lineHeight: "--cnvs-sys-line-height-title-medium";
222
+ fontSize: "--cnvs-sys-font-size-title-medium";
223
+ };
224
+ };
225
+ }, {}, {
226
+ backgroundColor: string;
227
+ color: string;
228
+ size: string;
229
+ }, never, never>, never>;
230
+ /**
231
+ * JSDoc for Avatar. Will be part of the Component API docs
232
+ */
233
+ export declare const Avatar: import("@workday/canvas-kit-react/common").ElementComponent<"div", AvatarProps>;
234
+ //# sourceMappingURL=Avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../avatar/lib/Avatar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAGjC,OAAO,EAAC,eAAe,EAAgC,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,WAAY,SAAQ,eAAe,EAAE,eAAe;IACnE;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqExB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,iFAoDjB,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Avatar = exports.avatarStencil = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = __importDefault(require("react"));
9
+ const common_1 = require("@workday/canvas-kit-react/common");
10
+ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
11
+ const BaseAvatar_1 = require("./BaseAvatar");
12
+ exports.avatarStencil = (0, canvas_kit_styling_1.createStencil)({
13
+ extends: BaseAvatar_1.baseAvatarStencil,
14
+ parts: {
15
+ avatarImage: 'avatar-image',
16
+ avatarName: 'avatar-name',
17
+ },
18
+ base: { name: "9aw6t", styles: "box-sizing:border-box;" },
19
+ modifiers: {
20
+ imageLoaded: {
21
+ false: { name: "24t5xr", styles: "[data-part=\"avatar-image\"]{display:none;}" }
22
+ },
23
+ objectFit: {
24
+ contain: { name: "1ngso1", styles: "[data-part=\"avatar-image\"]{object-fit:contain;}" },
25
+ cover: { name: "346tv9", styles: "[data-part=\"avatar-image\"]{object-fit:cover;}" },
26
+ fill: { name: "2fmgie", styles: "[data-part=\"avatar-image\"]{object-fit:fill;}" },
27
+ none: { name: "1u6u1", styles: "[data-part=\"avatar-image\"]{object-fit:none;}" },
28
+ ['scale-down']: { name: "4d1vf4", styles: "[data-part=\"avatar-image\"]{object-fit:scale-down;}" },
29
+ initial: { name: "crrue", styles: "[data-part=\"avatar-image\"]{object-fit:initial;}" },
30
+ inherit: { name: "1jucsi", styles: "[data-part=\"avatar-image\"]{object-fit:inherit;}" },
31
+ unset: { name: "t95mm", styles: "[data-part=\"avatar-image\"]{object-fit:unset;}" },
32
+ ['-moz-initial']: { name: "2eu3f2", styles: "[data-part=\"avatar-image\"]{object-fit:-moz-initial;}" },
33
+ ['revert']: { name: "1d127p", styles: "[data-part=\"avatar-image\"]{object-fit:revert;}" }
34
+ }
35
+ }
36
+ }, "avatar-b17e14");
37
+ /**
38
+ * JSDoc for Avatar. Will be part of the Component API docs
39
+ */
40
+ exports.Avatar = (0, common_1.createComponent)('div')({
41
+ displayName: 'Avatar',
42
+ Component: ({ url, name, variant, objectFit = 'cover', preferredInitials, isDecorative, size, ...elemProps }, ref, Element) => {
43
+ const [imageLoaded, setImageLoaded] = react_1.default.useState(false);
44
+ const handleImageLoad = () => {
45
+ if (!imageLoaded) {
46
+ setImageLoaded(true);
47
+ }
48
+ };
49
+ return ((0, jsx_runtime_1.jsxs)(BaseAvatar_1.BaseAvatar, { as: Element, ref: ref, ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, (0, exports.avatarStencil)({ variant, size, imageLoaded, objectFit })), children: [url && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(BaseAvatar_1.BaseAvatar.Image, { onLoad: handleImageLoad, src: url, alt: isDecorative ? undefined : name, "aria-hidden": isDecorative, ...exports.avatarStencil.parts.avatarImage }) })), name && (!url || !imageLoaded) && ((0, jsx_runtime_1.jsx)(BaseAvatar_1.BaseAvatar.Name, { name: name, preferredInitials: preferredInitials, ...exports.avatarStencil.parts.avatarName }))] }));
50
+ },
51
+ });