@salutejs/plasma-new-hope 0.76.5-canary.1180.8735798776.0 → 0.76.5-canary.1180.8748298731.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,20 +37,19 @@ var getAvatarContent = function getAvatarContent(_ref) {
37
37
  }
38
38
  return /*#__PURE__*/React.createElement(Avatar_styles.Text, null, initials);
39
39
  };
40
- var getAriaLabel = function getAriaLabel(props) {
41
- var url = props.url,
42
- name = props.name,
43
- status = props.status,
44
- ariaLabelProp = props['aria-label'],
45
- role = props.role,
46
- statusLabels = props.statusLabels;
40
+ var getAriaLabel = function getAriaLabel(_ref2) {
41
+ var url = _ref2.url,
42
+ name = _ref2.name,
43
+ status = _ref2.status,
44
+ ariaLabelProp = _ref2['aria-label'],
45
+ statusLabels = _ref2.statusLabels;
46
+ if (!url) {
47
+ return;
48
+ }
47
49
 
48
50
  // INFO: включаем aria-label чтобы озвучить что на изображении
49
- if (url && role && role === 'button') {
50
- var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
51
- return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
52
- }
53
- return undefined;
51
+ var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
52
+ return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
54
53
  };
55
54
  var mergedConfig = /*#__PURE__*/common.mergeConfig(Indicator$1.indicatorConfig);
56
55
  var Indicator = /*#__PURE__*/common.component(mergedConfig);
@@ -58,8 +57,8 @@ var _exp = function _exp() {
58
57
  return Indicator;
59
58
  };
60
59
  var _exp5 = function _exp5() {
61
- return function (_ref2) {
62
- var status = _ref2.status;
60
+ return function (_ref3) {
61
+ var status = _ref3.status;
63
62
  return status === 'active' ? "var(".concat(Avatar_tokens.tokens.statusOnlineColor, ")") : "var(".concat(Avatar_tokens.tokens.statusOfflineColor, ")");
64
63
  };
65
64
  };
@@ -88,11 +87,9 @@ var avatarRoot = function avatarRoot(Root) {
88
87
  var initials = React.useMemo(function () {
89
88
  return getInitialsForName.getInitialsForName(name);
90
89
  }, [name]);
91
- var ariaLabel = React.useMemo(function () {
92
- return getAriaLabel(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, props), {}, {
93
- statusLabels: statusLabels
94
- }));
95
- }, [name, url, rest.role, status, statusLabels, rest['aria-label']]);
90
+ var ariaLabel = getAriaLabel(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, props), {}, {
91
+ statusLabels: statusLabels
92
+ }));
96
93
  return /*#__PURE__*/React.createElement(Root, _rollupPluginBabelHelpers.extends({
97
94
  ref: ref,
98
95
  size: avatarSize,
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, ReactElement } from 'react';\nimport { styled } from '@linaria/react';\n\nimport { RootProps, component, mergeConfig } from '../../engines';\nimport { cx } from '../../utils';\nimport { indicatorConfig, indicatorTokens } from '../Indicator';\n\nimport { classes, tokens } from './Avatar.tokens';\nimport { base, Wrapper, Image, StatusIcon, Text } from './Avatar.styles';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\nimport type { AvatarProps, StatusLabels } from './Avatar.types';\n\nconst StatusLabelsDefault: StatusLabels = {\n active: 'Активен',\n inactive: 'Неактивен',\n};\n\nconst getAvatarContent = ({\n customText,\n url,\n initials,\n name,\n}: Omit<AvatarProps, 'size'> & { initials?: string }): ReactElement => {\n if (customText) {\n return <Text>{customText}</Text>;\n }\n\n if (url) {\n return <Image src={url} alt={name} />;\n }\n\n return <Text>{initials}</Text>;\n};\n\nconst getAriaLabel = (\n props: Pick<AvatarProps, 'url' | 'status' | 'role' | 'name' | 'aria-label'> & {\n statusLabels: StatusLabels;\n },\n) => {\n const { url, name, status, 'aria-label': ariaLabelProp, role, statusLabels } = props;\n\n // INFO: включаем aria-label чтобы озвучить что на изображении\n if (url && role && role === 'button') {\n const ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;\n\n return status ? `${ariaLabel}. ${statusLabels[status]}` : ariaLabel;\n }\n\n return undefined;\n};\n\nconst mergedConfig = mergeConfig(indicatorConfig);\n\nconst Indicator: React.FunctionComponent<\n React.HTMLAttributes<HTMLDivElement> & { status: AvatarProps['status'] }\n> = component(mergedConfig) as never;\n\nconst StyledIndicator = styled(Indicator)`\n ${indicatorTokens.size}: var(${tokens.statusIconSize});\n ${indicatorTokens.color}: ${({ status }) =>\n status === 'active' ? `var(${tokens.statusOnlineColor})` : `var(${tokens.statusOfflineColor})`}\n`;\n\nexport const avatarRoot = (Root: RootProps<HTMLDivElement, AvatarProps>) => {\n return forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {\n const {\n size: avatarSize,\n name,\n url,\n customText,\n status,\n className,\n focused = true,\n isScalable,\n statusLabels = StatusLabelsDefault,\n ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n const ariaLabel = useMemo(\n () =>\n getAriaLabel({\n ...props,\n statusLabels,\n }),\n [name, url, rest.role, status, statusLabels, rest['aria-label']],\n );\n\n return (\n <Root\n ref={ref}\n size={avatarSize}\n className={cx(classes.avatarItem, className)}\n aria-label={ariaLabel}\n focused={focused}\n {...rest}\n >\n <Wrapper isScalable={isScalable}>{getAvatarContent({ customText, url, initials, name })}</Wrapper>\n\n {status && (\n <StatusIcon>\n <StyledIndicator aria-label={statusLabels[status]} status={status} />\n </StatusIcon>\n )}\n </Root>\n );\n });\n};\n\nexport const avatarConfig = {\n name: 'Avatar',\n tag: 'div',\n layout: avatarRoot,\n base,\n variations: {\n size: {\n css: viewCSS,\n },\n focused: {\n css: focusedCSS,\n },\n },\n defaults: {\n size: 'm',\n },\n};\n"],"names":["StatusLabelsDefault","active","inactive","getAvatarContent","_ref","customText","url","initials","name","React","createElement","Text","Image","src","alt","getAriaLabel","props","status","ariaLabelProp","role","statusLabels","ariaLabel","trim","concat","undefined","mergedConfig","mergeConfig","indicatorConfig","Indicator","component","_exp","_exp5","_ref2","tokens","statusOnlineColor","statusOfflineColor","StyledIndicator","styled","class","propsAsIs","vars","avatarRoot","Root","forwardRef","ref","avatarSize","size","className","_props$focused","focused","isScalable","_props$statusLabels","rest","_excluded","useMemo","getInitialsForName","_objectSpread","_extends","cx","classes","avatarItem","Wrapper","StatusIcon","avatarConfig","tag","layout","base","variations","css","viewCSS","focusedCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,IAAMA,mBAAiC,GAAG;AACtCC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,QAAQ,EAAE,WAAA;AACd,CAAC,CAAA;AAED,IAAMC,gBAAgB,GAAGA,SAAnBA,gBAAgBA,CAAAC,IAAA,EAKiD;AAAA,EAAA,IAJnEC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IACHC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,IAAAA,GAAAA,IAAAA,CAAAA,IAAAA,CAAAA;AAEA,EAAA,IAAIH,UAAU,EAAE;AACZ,IAAA,oBAAOI,KAAA,CAAAC,aAAA,CAACC,kBAAI,EAAA,IAAA,EAAEN,UAAiB,CAAC,CAAA;AACpC,GAAA;AAEA,EAAA,IAAIC,GAAG,EAAE;AACL,IAAA,oBAAOG,KAAA,CAAAC,aAAA,CAACE,mBAAK,EAAA;AAACC,MAAAA,GAAG,EAAEP,GAAI;AAACQ,MAAAA,GAAG,EAAEN,IAAAA;AAAK,KAAG,CAAA,CAAA;AACzC,GAAA;AAEA,EAAA,oBAAOC,KAAA,CAAAC,aAAA,CAACC,kBAAI,EAAA,IAAA,EAAEJ,QAAe,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,IAAMQ,YAAY,GAAGA,SAAfA,YAAYA,CACdC,KAEC,EACA;AACD,EAAA,IAAQV,GAA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,MAAM,EAAExB,UAAU;AAClByB,EAAAA,IAAI,EAAJA,kBAAI;AACJC,EAAAA,UAAU,EAAE;AACRrB,IAAAA,IAAI,EAAE;AACFsB,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACDpB,IAAAA,OAAO,EAAE;AACLmB,MAAAA,GAAG,EAAEE,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNzB,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;;"}
1
+ {"version":3,"file":"Avatar.js","sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, ReactElement } from 'react';\nimport { styled } from '@linaria/react';\n\nimport { RootProps, component, mergeConfig } from '../../engines';\nimport { cx } from '../../utils';\nimport { indicatorConfig, indicatorTokens } from '../Indicator';\n\nimport { classes, tokens } from './Avatar.tokens';\nimport { base, Wrapper, Image, StatusIcon, Text } from './Avatar.styles';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\nimport type { AvatarProps, StatusLabels } from './Avatar.types';\n\nconst StatusLabelsDefault: StatusLabels = {\n active: 'Активен',\n inactive: 'Неактивен',\n};\n\nconst getAvatarContent = ({\n customText,\n url,\n initials,\n name,\n}: Omit<AvatarProps, 'size'> & { initials?: string }): ReactElement => {\n if (customText) {\n return <Text>{customText}</Text>;\n }\n\n if (url) {\n return <Image src={url} alt={name} />;\n }\n\n return <Text>{initials}</Text>;\n};\n\nconst getAriaLabel = ({\n url,\n name,\n status,\n 'aria-label': ariaLabelProp,\n statusLabels,\n}: Pick<AvatarProps, 'url' | 'status' | 'name' | 'aria-label'> & {\n statusLabels: StatusLabels;\n}) => {\n if (!url) {\n return;\n }\n\n // INFO: включаем aria-label чтобы озвучить что на изображении\n const ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;\n\n return status ? `${ariaLabel}. ${statusLabels[status]}` : ariaLabel;\n};\n\nconst mergedConfig = mergeConfig(indicatorConfig);\n\nconst Indicator: React.FunctionComponent<\n React.HTMLAttributes<HTMLDivElement> & { status: AvatarProps['status'] }\n> = component(mergedConfig) as never;\n\nconst StyledIndicator = styled(Indicator)`\n ${indicatorTokens.size}: var(${tokens.statusIconSize});\n ${indicatorTokens.color}: ${({ status }) =>\n status === 'active' ? `var(${tokens.statusOnlineColor})` : `var(${tokens.statusOfflineColor})`}\n`;\n\nexport const avatarRoot = (Root: RootProps<HTMLDivElement, AvatarProps>) => {\n return forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {\n const {\n size: avatarSize,\n name,\n url,\n customText,\n status,\n className,\n focused = true,\n isScalable,\n statusLabels = StatusLabelsDefault,\n ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n const ariaLabel = getAriaLabel({\n ...props,\n statusLabels,\n });\n\n return (\n <Root\n ref={ref}\n size={avatarSize}\n className={cx(classes.avatarItem, className)}\n aria-label={ariaLabel}\n focused={focused}\n {...rest}\n >\n <Wrapper isScalable={isScalable}>{getAvatarContent({ customText, url, initials, name })}</Wrapper>\n\n {status && (\n <StatusIcon>\n <StyledIndicator aria-label={statusLabels[status]} status={status} />\n </StatusIcon>\n )}\n </Root>\n );\n });\n};\n\nexport const avatarConfig = {\n name: 'Avatar',\n tag: 'div',\n layout: avatarRoot,\n base,\n variations: {\n size: {\n css: viewCSS,\n },\n focused: {\n css: focusedCSS,\n },\n },\n defaults: {\n size: 'm',\n },\n};\n"],"names":["StatusLabelsDefault","active","inactive","getAvatarContent","_ref","customText","url","initials","name","React","createElement","Text","Image","src","alt","getAriaLabel","_ref2","status","ariaLabelProp","statusLabels","ariaLabel","trim","concat","mergedConfig","mergeConfig","indicatorConfig","Indicator","component","_exp","_exp5","_ref3","tokens","statusOnlineColor","statusOfflineColor","StyledIndicator","styled","class","propsAsIs","vars","avatarRoot","Root","forwardRef","props","ref","avatarSize","size","className","_props$focused","focused","isScalable","_props$statusLabels","rest","_excluded","useMemo","getInitialsForName","_objectSpread","_extends","cx","classes","avatarItem","Wrapper","StatusIcon","avatarConfig","tag","layout","base","variations","css","viewCSS","focusedCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,IAAMA,mBAAiC,GAAG;AACtCC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,QAAQ,EAAE,WAAA;AACd,CAAC,CAAA;AAED,IAAMC,gBAAgB,GAAGA,SAAnBA,gBAAgBA,CAAAC,IAAA,EAKiD;AAAA,EAAA,IAJnEC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IACHC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,IAAAA,GAAAA,IAAAA,CAAAA,IAAAA,CAAAA;AAEA,EAAA,IAAIH,UAAU,EAAE;AACZ,IAAA,oBAAOI,KAAA,CAAAC,aAAA,CAACC,kBAAI,EAAA,IAAA,EAAEN,UAAiB,CAAC,CAAA;AACpC,GAAA;AAEA,EAAA,IAAIC,GAAG,EAAE;AACL,IAAA,oBAAOG,KAAA,CAAAC,aAAA,CAACE,mBAAK,EAAA;AAACC,MAAAA,GAAG,EAAEP,GAAI;AAACQ,MAAAA,GAAG,EAAEN,IAAAA;AAAK,KAAG,CAAA,CAAA;AACzC,GAAA;AAEA,EAAA,oBAAOC,KAAA,CAAAC,aAAA,CAACC,kBAAI,EAAA,IAAA,EAAEJ,QAAe,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,IAAMQ,YAAY,GAAGA,SAAfA,YAAYA,CAAAC,KAAA,EAQZ;AAAA,EAAA,IAPFV,GAAG,GAAAU,KAAA,CAAHV,GAAG;IACHE,IAAI,GAAAQ,KAAA,CAAJR,IAAI;IACJS,MAAM,GAAAD,KAAA,CAANC,MAAM;IACQC,aAAa,GAAAF,KAAA,CAA3B,YAAY,CAAA;IACZG,YAAAA,GAAAA,KAAAA,CAAAA,YAAAA,CAAAA;EAIA,IAA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B,SAAU;AACtB4B,MAAAA,OAAO,EAAEA,OAAAA;AAAQ,KAAA,EACbG,IAAI,CAER1C,eAAAA,KAAA,CAAAC,aAAA,CAACkD,qBAAO,EAAA;AAACX,MAAAA,UAAU,EAAEA,UAAAA;AAAW,KAAA,EAAE9C,gBAAgB,CAAC;AAAEE,MAAAA,UAAU,EAAVA,UAAU;AAAEC,MAAAA,GAAG,EAAHA,GAAG;AAAEC,MAAAA,QAAQ,EAARA,QAAQ;AAAEC,MAAAA,IAAAA,EAAAA,IAAAA;AAAK,KAAC,CAAW,CAAA,EAEhGS,MAAM,iBACHR,KAAA,CAAAC,aAAA,CAACmD,wBAAU,EACPpD,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAACwB,eAAe,EAAA;MAAC,YAAYf,EAAAA,YAAY,CAACF,MAAM,CAAE;AAACA,MAAAA,MAAM,EAAEA,MAAAA;KAAO,CAC1D,CAEd,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AACN,EAAC;AAEM,IAAM6C,YAAY,GAAG;AACxBtD,EAAAA,IAAI,EAAE,QAAQ;AACduD,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEzB,UAAU;AAClB0B,EAAAA,IAAI,EAAJA,kBAAI;AACJC,EAAAA,UAAU,EAAE;AACRrB,IAAAA,IAAI,EAAE;AACFsB,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACDpB,IAAAA,OAAO,EAAE;AACLmB,MAAAA,GAAG,EAAEE,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNzB,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;;"}
@@ -33,20 +33,19 @@ var getAvatarContent = function getAvatarContent(_ref) {
33
33
  }
34
34
  return /*#__PURE__*/React.createElement(Text, null, initials);
35
35
  };
36
- var getAriaLabel = function getAriaLabel(props) {
37
- var url = props.url,
38
- name = props.name,
39
- status = props.status,
40
- ariaLabelProp = props['aria-label'],
41
- role = props.role,
42
- statusLabels = props.statusLabels;
36
+ var getAriaLabel = function getAriaLabel(_ref2) {
37
+ var url = _ref2.url,
38
+ name = _ref2.name,
39
+ status = _ref2.status,
40
+ ariaLabelProp = _ref2['aria-label'],
41
+ statusLabels = _ref2.statusLabels;
42
+ if (!url) {
43
+ return;
44
+ }
43
45
 
44
46
  // INFO: включаем aria-label чтобы озвучить что на изображении
45
- if (url && role && role === 'button') {
46
- var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
47
- return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
48
- }
49
- return undefined;
47
+ var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
48
+ return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
50
49
  };
51
50
  var mergedConfig = /*#__PURE__*/mergeConfig(indicatorConfig);
52
51
  var Indicator = /*#__PURE__*/component(mergedConfig);
@@ -54,8 +53,8 @@ var _exp = function _exp() {
54
53
  return Indicator;
55
54
  };
56
55
  var _exp5 = function _exp5() {
57
- return function (_ref2) {
58
- var status = _ref2.status;
56
+ return function (_ref3) {
57
+ var status = _ref3.status;
59
58
  return status === 'active' ? "var(".concat(tokens.statusOnlineColor, ")") : "var(".concat(tokens.statusOfflineColor, ")");
60
59
  };
61
60
  };
@@ -84,11 +83,9 @@ var avatarRoot = function avatarRoot(Root) {
84
83
  var initials = useMemo(function () {
85
84
  return getInitialsForName(name);
86
85
  }, [name]);
87
- var ariaLabel = useMemo(function () {
88
- return getAriaLabel(_objectSpread2(_objectSpread2({}, props), {}, {
89
- statusLabels: statusLabels
90
- }));
91
- }, [name, url, rest.role, status, statusLabels, rest['aria-label']]);
86
+ var ariaLabel = getAriaLabel(_objectSpread2(_objectSpread2({}, props), {}, {
87
+ statusLabels: statusLabels
88
+ }));
92
89
  return /*#__PURE__*/React.createElement(Root, _extends({
93
90
  ref: ref,
94
91
  size: avatarSize,
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, ReactElement } from 'react';\nimport { styled } from '@linaria/react';\n\nimport { RootProps, component, mergeConfig } from '../../engines';\nimport { cx } from '../../utils';\nimport { indicatorConfig, indicatorTokens } from '../Indicator';\n\nimport { classes, tokens } from './Avatar.tokens';\nimport { base, Wrapper, Image, StatusIcon, Text } from './Avatar.styles';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\nimport type { AvatarProps, StatusLabels } from './Avatar.types';\n\nconst StatusLabelsDefault: StatusLabels = {\n active: 'Активен',\n inactive: 'Неактивен',\n};\n\nconst getAvatarContent = ({\n customText,\n url,\n initials,\n name,\n}: Omit<AvatarProps, 'size'> & { initials?: string }): ReactElement => {\n if (customText) {\n return <Text>{customText}</Text>;\n }\n\n if (url) {\n return <Image src={url} alt={name} />;\n }\n\n return <Text>{initials}</Text>;\n};\n\nconst getAriaLabel = (\n props: Pick<AvatarProps, 'url' | 'status' | 'role' | 'name' | 'aria-label'> & {\n statusLabels: StatusLabels;\n },\n) => {\n const { url, name, status, 'aria-label': ariaLabelProp, role, statusLabels } = props;\n\n // INFO: включаем aria-label чтобы озвучить что на изображении\n if (url && role && role === 'button') {\n const ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;\n\n return status ? `${ariaLabel}. ${statusLabels[status]}` : ariaLabel;\n }\n\n return undefined;\n};\n\nconst mergedConfig = mergeConfig(indicatorConfig);\n\nconst Indicator: React.FunctionComponent<\n React.HTMLAttributes<HTMLDivElement> & { status: AvatarProps['status'] }\n> = component(mergedConfig) as never;\n\nconst StyledIndicator = styled(Indicator)`\n ${indicatorTokens.size}: var(${tokens.statusIconSize});\n ${indicatorTokens.color}: ${({ status }) =>\n status === 'active' ? `var(${tokens.statusOnlineColor})` : `var(${tokens.statusOfflineColor})`}\n`;\n\nexport const avatarRoot = (Root: RootProps<HTMLDivElement, AvatarProps>) => {\n return forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {\n const {\n size: avatarSize,\n name,\n url,\n customText,\n status,\n className,\n focused = true,\n isScalable,\n statusLabels = StatusLabelsDefault,\n ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n const ariaLabel = useMemo(\n () =>\n getAriaLabel({\n ...props,\n statusLabels,\n }),\n [name, url, rest.role, status, statusLabels, rest['aria-label']],\n );\n\n return (\n <Root\n ref={ref}\n size={avatarSize}\n className={cx(classes.avatarItem, className)}\n aria-label={ariaLabel}\n focused={focused}\n {...rest}\n >\n <Wrapper isScalable={isScalable}>{getAvatarContent({ customText, url, initials, name })}</Wrapper>\n\n {status && (\n <StatusIcon>\n <StyledIndicator aria-label={statusLabels[status]} status={status} />\n </StatusIcon>\n )}\n </Root>\n );\n });\n};\n\nexport const avatarConfig = {\n name: 'Avatar',\n tag: 'div',\n layout: avatarRoot,\n base,\n variations: {\n size: {\n css: viewCSS,\n },\n focused: {\n css: focusedCSS,\n },\n },\n defaults: {\n size: 'm',\n },\n};\n"],"names":["StatusLabelsDefault","active","inactive","getAvatarContent","_ref","customText","url","initials","name","React","createElement","Text","Image","src","alt","getAriaLabel","props","status","ariaLabelProp","role","statusLabels","ariaLabel","trim","concat","undefined","mergedConfig","mergeConfig","indicatorConfig","Indicator","component","_exp","_exp5","_ref2","tokens","statusOnlineColor","statusOfflineColor","StyledIndicator","styled","class","propsAsIs","vars","avatarRoot","Root","forwardRef","ref","avatarSize","size","className","_props$focused","focused","isScalable","_props$statusLabels","rest","_excluded","useMemo","getInitialsForName","_objectSpread","_extends","cx","classes","avatarItem","Wrapper","StatusIcon","avatarConfig","tag","layout","base","variations","css","viewCSS","focusedCSS","defaults"],"mappings":";;;;;;;;;;;;;;AAcA,IAAMA,mBAAiC,GAAG;AACtCC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,QAAQ,EAA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AAU,EAAEb,SAAS,CAAE;AAC7C,MAAA,YAAA,EAAY1B,SAAU;AACtB4B,MAAAA,OAAO,EAAEA,OAAAA;AAAQ,KAAA,EACbG,IAAI,CAER3C,eAAAA,KAAA,CAAAC,aAAA,CAACmD,OAAO,EAAA;AAACX,MAAAA,UAAU,EAAEA,UAAAA;AAAW,KAAA,EAAE/C,gBAAgB,CAAC;AAAEE,MAAAA,UAAU,EAAVA,UAAU;AAAEC,MAAAA,GAAG,EAAHA,GAAG;AAAEC,MAAAA,QAAQ,EAARA,QAAQ;AAAEC,MAAAA,IAAAA,EAAAA,IAAAA;AAAK,KAAC,CAAW,CAAA,EAEhGS,MAAM,iBACHR,KAAA,CAAAC,aAAA,CAACoD,UAAU,EACPrD,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAAC0B,eAAe,EAAA;MAAC,YAAYhB,EAAAA,YAAY,CAACH,MAAM,CAAE;AAACA,MAAAA,MAAM,EAAEA,MAAAA;KAAO,CAC1D,CAEd,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AACN,EAAC;AAEM,IAAM8C,YAAY,GAAG;AACxBvD,EAAAA,IAAI,EAAE,QAAQ;AACdwD,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAExB,UAAU;AAClByB,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACRrB,IAAAA,IAAI,EAAE;AACFsB,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACDpB,IAAAA,OAAO,EAAE;AACLmB,MAAAA,GAAG,EAAEE,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNzB,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
1
+ {"version":3,"file":"Avatar.js","sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, ReactElement } from 'react';\nimport { styled } from '@linaria/react';\n\nimport { RootProps, component, mergeConfig } from '../../engines';\nimport { cx } from '../../utils';\nimport { indicatorConfig, indicatorTokens } from '../Indicator';\n\nimport { classes, tokens } from './Avatar.tokens';\nimport { base, Wrapper, Image, StatusIcon, Text } from './Avatar.styles';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\nimport type { AvatarProps, StatusLabels } from './Avatar.types';\n\nconst StatusLabelsDefault: StatusLabels = {\n active: 'Активен',\n inactive: 'Неактивен',\n};\n\nconst getAvatarContent = ({\n customText,\n url,\n initials,\n name,\n}: Omit<AvatarProps, 'size'> & { initials?: string }): ReactElement => {\n if (customText) {\n return <Text>{customText}</Text>;\n }\n\n if (url) {\n return <Image src={url} alt={name} />;\n }\n\n return <Text>{initials}</Text>;\n};\n\nconst getAriaLabel = ({\n url,\n name,\n status,\n 'aria-label': ariaLabelProp,\n statusLabels,\n}: Pick<AvatarProps, 'url' | 'status' | 'name' | 'aria-label'> & {\n statusLabels: StatusLabels;\n}) => {\n if (!url) {\n return;\n }\n\n // INFO: включаем aria-label чтобы озвучить что на изображении\n const ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;\n\n return status ? `${ariaLabel}. ${statusLabels[status]}` : ariaLabel;\n};\n\nconst mergedConfig = mergeConfig(indicatorConfig);\n\nconst Indicator: React.FunctionComponent<\n React.HTMLAttributes<HTMLDivElement> & { status: AvatarProps['status'] }\n> = component(mergedConfig) as never;\n\nconst StyledIndicator = styled(Indicator)`\n ${indicatorTokens.size}: var(${tokens.statusIconSize});\n ${indicatorTokens.color}: ${({ status }) =>\n status === 'active' ? `var(${tokens.statusOnlineColor})` : `var(${tokens.statusOfflineColor})`}\n`;\n\nexport const avatarRoot = (Root: RootProps<HTMLDivElement, AvatarProps>) => {\n return forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {\n const {\n size: avatarSize,\n name,\n url,\n customText,\n status,\n className,\n focused = true,\n isScalable,\n statusLabels = StatusLabelsDefault,\n ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n const ariaLabel = getAriaLabel({\n ...props,\n statusLabels,\n });\n\n return (\n <Root\n ref={ref}\n size={avatarSize}\n className={cx(classes.avatarItem, className)}\n aria-label={ariaLabel}\n focused={focused}\n {...rest}\n >\n <Wrapper isScalable={isScalable}>{getAvatarContent({ customText, url, initials, name })}</Wrapper>\n\n {status && (\n <StatusIcon>\n <StyledIndicator aria-label={statusLabels[status]} status={status} />\n </StatusIcon>\n )}\n </Root>\n );\n });\n};\n\nexport const avatarConfig = {\n name: 'Avatar',\n tag: 'div',\n layout: avatarRoot,\n base,\n variations: {\n size: {\n css: viewCSS,\n },\n focused: {\n css: focusedCSS,\n },\n },\n defaults: {\n size: 'm',\n },\n};\n"],"names":["StatusLabelsDefault","active","inactive","getAvatarContent","_ref","customText","url","initials","name","React","createElement","Text","Image","src","alt","getAriaLabel","_ref2","status","ariaLabelProp","statusLabels","ariaLabel","trim","concat","mergedConfig","mergeConfig","indicatorConfig","Indicator","component","_exp","_exp5","_ref3","tokens","statusOnlineColor","statusOfflineColor","StyledIndicator","styled","class","propsAsIs","vars","avatarRoot","Root","forwardRef","props","ref","avatarSize","size","className","_props$focused","focused","isScalable","_props$statusLabels","rest","_excluded","useMemo","getInitialsForName","_objectSpread","_extends","cx","classes","avatarItem","Wrapper","StatusIcon","avatarConfig","tag","layout","base","variations","css","viewCSS","focusedCSS","defaults"],"mappings":";;;;;;;;;;;;;;AAcA,IAAMA,mBAAiC,GAAG;AACtCC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,QAAQ,EAAE,WAAA;AACd,CAAC,CAAA;AAED,IAAMC,gBAAgB,GAAGA,SAAnBA,gBAAgBA,CAAAC,IAAA,EAKiD;AAAA,EAAA,IAJnEC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IACHC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,IAAAA,GAA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AA,YAAY,CAACF,MAAM,CAAE;AAACA,MAAAA,MAAM,EAAEA,MAAAA;KAAO,CAC1D,CAEd,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AACN,EAAC;AAEM,IAAM6C,YAAY,GAAG;AACxBtD,EAAAA,IAAI,EAAE,QAAQ;AACduD,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEzB,UAAU;AAClB0B,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACRrB,IAAAA,IAAI,EAAE;AACFsB,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACDpB,IAAAA,OAAO,EAAE;AACLmB,MAAAA,GAAG,EAAEE,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNzB,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.76.5-canary.1180.8735798776.0",
3
+ "version": "0.76.5-canary.1180.8748298731.0",
4
4
  "description": "Salute Design System blueprint",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",
@@ -102,5 +102,5 @@
102
102
  "react-popper": "2.3.0",
103
103
  "storeon": "3.1.5"
104
104
  },
105
- "gitHead": "2b0e50f98ddba9357f729b761ee3135739c10aab"
105
+ "gitHead": "a64954f917ad8547ebbf1df4a8b8ab21d16a7907"
106
106
  }
@@ -47,27 +47,26 @@ var getAvatarContent = function getAvatarContent(_ref) {
47
47
  }
48
48
  return /*#__PURE__*/_react["default"].createElement(_Avatar2.Text, null, initials);
49
49
  };
50
- var getAriaLabel = function getAriaLabel(props) {
51
- var url = props.url,
52
- name = props.name,
53
- status = props.status,
54
- ariaLabelProp = props['aria-label'],
55
- role = props.role,
56
- statusLabels = props.statusLabels;
50
+ var getAriaLabel = function getAriaLabel(_ref2) {
51
+ var url = _ref2.url,
52
+ name = _ref2.name,
53
+ status = _ref2.status,
54
+ ariaLabelProp = _ref2['aria-label'],
55
+ statusLabels = _ref2.statusLabels;
56
+ if (!url) {
57
+ return;
58
+ }
57
59
 
58
60
  // INFO: включаем aria-label чтобы озвучить что на изображении
59
- if (url && role && role === 'button') {
60
- var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
61
- return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
62
- }
63
- return undefined;
61
+ var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
62
+ return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
64
63
  };
65
64
  var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Indicator.indicatorConfig);
66
65
  var Indicator = /*#__PURE__*/(0, _engines.component)(mergedConfig);
67
66
  var StyledIndicator = /*#__PURE__*/(0, _styledComponents["default"])(Indicator).withConfig({
68
67
  componentId: "plasma-new-hope__sc-p4w0wq-0"
69
- })(["", ":var(", ");", ":", ""], _Indicator.indicatorTokens.size, _Avatar.tokens.statusIconSize, _Indicator.indicatorTokens.color, function (_ref2) {
70
- var status = _ref2.status;
68
+ })(["", ":var(", ");", ":", ""], _Indicator.indicatorTokens.size, _Avatar.tokens.statusIconSize, _Indicator.indicatorTokens.color, function (_ref3) {
69
+ var status = _ref3.status;
71
70
  return status === 'active' ? "var(".concat(_Avatar.tokens.statusOnlineColor, ")") : "var(".concat(_Avatar.tokens.statusOfflineColor, ")");
72
71
  });
73
72
  var avatarRoot = exports.avatarRoot = function avatarRoot(Root) {
@@ -87,11 +86,9 @@ var avatarRoot = exports.avatarRoot = function avatarRoot(Root) {
87
86
  var initials = (0, _react.useMemo)(function () {
88
87
  return (0, _utils2.getInitialsForName)(name);
89
88
  }, [name]);
90
- var ariaLabel = (0, _react.useMemo)(function () {
91
- return getAriaLabel(_objectSpread(_objectSpread({}, props), {}, {
92
- statusLabels: statusLabels
93
- }));
94
- }, [name, url, rest.role, status, statusLabels, rest['aria-label']]);
89
+ var ariaLabel = getAriaLabel(_objectSpread(_objectSpread({}, props), {}, {
90
+ statusLabels: statusLabels
91
+ }));
95
92
  return /*#__PURE__*/_react["default"].createElement(Root, _extends({
96
93
  ref: ref,
97
94
  size: avatarSize,
@@ -38,27 +38,26 @@ var getAvatarContent = function getAvatarContent(_ref) {
38
38
  }
39
39
  return /*#__PURE__*/React.createElement(Text, null, initials);
40
40
  };
41
- var getAriaLabel = function getAriaLabel(props) {
42
- var url = props.url,
43
- name = props.name,
44
- status = props.status,
45
- ariaLabelProp = props['aria-label'],
46
- role = props.role,
47
- statusLabels = props.statusLabels;
41
+ var getAriaLabel = function getAriaLabel(_ref2) {
42
+ var url = _ref2.url,
43
+ name = _ref2.name,
44
+ status = _ref2.status,
45
+ ariaLabelProp = _ref2['aria-label'],
46
+ statusLabels = _ref2.statusLabels;
47
+ if (!url) {
48
+ return;
49
+ }
48
50
 
49
51
  // INFO: включаем aria-label чтобы озвучить что на изображении
50
- if (url && role && role === 'button') {
51
- var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
52
- return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
53
- }
54
- return undefined;
52
+ var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
53
+ return status ? "".concat(ariaLabel, ". ").concat(statusLabels[status]) : ariaLabel;
55
54
  };
56
55
  var mergedConfig = /*#__PURE__*/mergeConfig(indicatorConfig);
57
56
  var Indicator = /*#__PURE__*/component(mergedConfig);
58
57
  var StyledIndicator = /*#__PURE__*/styled(Indicator).withConfig({
59
58
  componentId: "plasma-new-hope__sc-p4w0wq-0"
60
- })(["", ":var(", ");", ":", ""], indicatorTokens.size, tokens.statusIconSize, indicatorTokens.color, function (_ref2) {
61
- var status = _ref2.status;
59
+ })(["", ":var(", ");", ":", ""], indicatorTokens.size, tokens.statusIconSize, indicatorTokens.color, function (_ref3) {
60
+ var status = _ref3.status;
62
61
  return status === 'active' ? "var(".concat(tokens.statusOnlineColor, ")") : "var(".concat(tokens.statusOfflineColor, ")");
63
62
  });
64
63
  export var avatarRoot = function avatarRoot(Root) {
@@ -78,11 +77,9 @@ export var avatarRoot = function avatarRoot(Root) {
78
77
  var initials = useMemo(function () {
79
78
  return getInitialsForName(name);
80
79
  }, [name]);
81
- var ariaLabel = useMemo(function () {
82
- return getAriaLabel(_objectSpread(_objectSpread({}, props), {}, {
83
- statusLabels: statusLabels
84
- }));
85
- }, [name, url, rest.role, status, statusLabels, rest['aria-label']]);
80
+ var ariaLabel = getAriaLabel(_objectSpread(_objectSpread({}, props), {}, {
81
+ statusLabels: statusLabels
82
+ }));
86
83
  return /*#__PURE__*/React.createElement(Root, _extends({
87
84
  ref: ref,
88
85
  size: avatarSize,
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAA0B,MAAM,eAAe,CAAC;AASlE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqDhE,eAAO,MAAM,UAAU,SAAU,UAAU,cAAc,EAAE,WAAW,CAAC;;;;;;;;;wCA4CtE,CAAC;AAEF,eAAO,MAAM,YAAY;;;mBA9CQ,UAAU,cAAc,EAAE,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;CA8DtE,CAAC"}
1
+ {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,SAAS,EAA0B,MAAM,eAAe,CAAC;AASlE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuDhE,eAAO,MAAM,UAAU,SAAU,UAAU,cAAc,EAAE,WAAW,CAAC;;;;;;;;;wCAwCtE,CAAC;AAEF,eAAO,MAAM,YAAY;;;mBA1CQ,UAAU,cAAc,EAAE,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;CA0DtE,CAAC"}