@salutejs/plasma-new-hope 0.74.1-canary.1178.8685845322.0 → 0.74.1-canary.1180.8686460436.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Avatar/Avatar.js +7 -1
- package/cjs/components/Avatar/Avatar.js.map +1 -1
- package/es/components/Avatar/Avatar.js +7 -1
- package/es/components/Avatar/Avatar.js.map +1 -1
- package/package.json +3 -3
- package/styled-components/cjs/components/Avatar/Avatar.js +7 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +1 -0
- package/styled-components/cjs/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +34 -18
- package/styled-components/es/components/Avatar/Avatar.js +7 -1
- package/styled-components/es/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +1 -0
- package/styled-components/es/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +34 -18
- package/types/components/Avatar/Avatar.d.ts.map +1 -1
@@ -16,7 +16,7 @@ var base = require('./variations/_size/base.js');
|
|
16
16
|
var base$1 = require('./variations/_focused/base.js');
|
17
17
|
var getInitialsForName = require('./utils/getInitialsForName.js');
|
18
18
|
|
19
|
-
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable"];
|
19
|
+
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable", "aria-label"];
|
20
20
|
var getAvatarContent = function getAvatarContent(_ref) {
|
21
21
|
var customText = _ref.customText,
|
22
22
|
url = _ref.url,
|
@@ -63,14 +63,20 @@ var avatarRoot = function avatarRoot(Root) {
|
|
63
63
|
_props$focused = props.focused,
|
64
64
|
focused = _props$focused === void 0 ? true : _props$focused,
|
65
65
|
isScalable = props.isScalable,
|
66
|
+
ariaLabelProp = props['aria-label'],
|
66
67
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
67
68
|
var initials = React.useMemo(function () {
|
68
69
|
return getInitialsForName.getInitialsForName(name);
|
69
70
|
}, [name]);
|
71
|
+
var ariaLabel = ariaLabelProp;
|
72
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.role) === 'button') {
|
73
|
+
ariaLabel = !ariaLabel || ariaLabel.trim() === '' ? name : ariaLabel;
|
74
|
+
}
|
70
75
|
return /*#__PURE__*/React.createElement(Root, _rollupPluginBabelHelpers.extends({
|
71
76
|
ref: ref,
|
72
77
|
size: avatarSize,
|
73
78
|
className: index.cx(Avatar_tokens.classes.avatarItem, className),
|
79
|
+
"aria-label": ariaLabel,
|
74
80
|
focused: focused
|
75
81
|
}, rest), /*#__PURE__*/React.createElement(Avatar_styles.Wrapper, {
|
76
82
|
isScalable: isScalable
|
@@ -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 { AvatarProps } from './Avatar.types';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\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 mergedConfig = mergeConfig(indicatorConfig);\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 ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n\n return (\n <Root
|
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 { AvatarProps } from './Avatar.types';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\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 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 'aria-label': ariaLabelProp,\n ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n let ariaLabel = ariaLabelProp;\n\n if (rest?.role === 'button') {\n ariaLabel = !ariaLabel || ariaLabel.trim() === '' ? name : ariaLabel;\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 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":["getAvatarContent","_ref","customText","url","initials","name","React","createElement","Text","Image","src","alt","mergedConfig","mergeConfig","indicatorConfig","Indicator","component","_exp","_exp5","_ref2","status","concat","tokens","statusOnlineColor","statusOfflineColor","StyledIndicator","styled","class","propsAsIs","vars","avatarRoot","Root","forwardRef","props","ref","avatarSize","size","className","_props$focused","focused","isScalable","ariaLabelProp","rest","_excluded","useMemo","getInitialsForName","ariaLabel","role","trim","_extends","cx","classes","avatarItem","Wrapper","StatusIcon","avatarConfig","tag","layout","base","variations","css","viewCSS","focusedCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,IAAMA,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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BAAO,CAACC,UAAU,EAAEf,SAAS,CAAE;AAC7C,MAAA,YAAA,EAAYS,SAAU;AACtBP,MAAAA,OAAO,EAAEA,OAAAA;AAAQ,KAAA,EACbG,IAAI,CAERpC,eAAAA,KAAA,CAAAC,aAAA,CAAC8C,qBAAO,EAAA;AAACb,MAAAA,UAAU,EAAEA,UAAAA;AAAW,KAAA,EAAExC,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,EAEhGe,MAAM,iBACHd,KAAA,CAAAC,aAAA,CAAC+C,wBAAU,EACPhD,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAACkB,eAAe,EAAA;AAACL,MAAAA,MAAM,EAAEA,MAAAA;KAAO,CACxB,CAEd,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AACN,EAAC;AAEM,IAAMmC,YAAY,GAAG;AACxBlD,EAAAA,IAAI,EAAE,QAAQ;AACdmD,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE3B,UAAU;AAClB4B,EAAAA,IAAI,EAAJA,kBAAI;AACJC,EAAAA,UAAU,EAAE;AACRvB,IAAAA,IAAI,EAAE;AACFwB,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACDtB,IAAAA,OAAO,EAAE;AACLqB,MAAAA,GAAG,EAAEE,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN3B,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;;"}
|
@@ -12,7 +12,7 @@ import { base as base$1 } from './variations/_size/base.js';
|
|
12
12
|
import { base as base$2 } from './variations/_focused/base.js';
|
13
13
|
import { getInitialsForName } from './utils/getInitialsForName.js';
|
14
14
|
|
15
|
-
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable"];
|
15
|
+
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable", "aria-label"];
|
16
16
|
var getAvatarContent = function getAvatarContent(_ref) {
|
17
17
|
var customText = _ref.customText,
|
18
18
|
url = _ref.url,
|
@@ -59,14 +59,20 @@ var avatarRoot = function avatarRoot(Root) {
|
|
59
59
|
_props$focused = props.focused,
|
60
60
|
focused = _props$focused === void 0 ? true : _props$focused,
|
61
61
|
isScalable = props.isScalable,
|
62
|
+
ariaLabelProp = props['aria-label'],
|
62
63
|
rest = _objectWithoutProperties(props, _excluded);
|
63
64
|
var initials = useMemo(function () {
|
64
65
|
return getInitialsForName(name);
|
65
66
|
}, [name]);
|
67
|
+
var ariaLabel = ariaLabelProp;
|
68
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.role) === 'button') {
|
69
|
+
ariaLabel = !ariaLabel || ariaLabel.trim() === '' ? name : ariaLabel;
|
70
|
+
}
|
66
71
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
67
72
|
ref: ref,
|
68
73
|
size: avatarSize,
|
69
74
|
className: cx(classes.avatarItem, className),
|
75
|
+
"aria-label": ariaLabel,
|
70
76
|
focused: focused
|
71
77
|
}, rest), /*#__PURE__*/React.createElement(Wrapper, {
|
72
78
|
isScalable: isScalable
|
@@ -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 { AvatarProps } from './Avatar.types';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\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 mergedConfig = mergeConfig(indicatorConfig);\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 ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n\n return (\n <Root
|
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 { AvatarProps } from './Avatar.types';\nimport { base as viewCSS } from './variations/_size/base';\nimport { base as focusedCSS } from './variations/_focused/base';\nimport { getInitialsForName } from './utils';\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 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 'aria-label': ariaLabelProp,\n ...rest\n } = props;\n\n const initials = useMemo(() => getInitialsForName(name), [name]);\n let ariaLabel = ariaLabelProp;\n\n if (rest?.role === 'button') {\n ariaLabel = !ariaLabel || ariaLabel.trim() === '' ? name : ariaLabel;\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 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":["getAvatarContent","_ref","customText","url","initials","name","React","createElement","Text","Image","src","alt","mergedConfig","mergeConfig","indicatorConfig","Indicator","component","_exp","_exp5","_ref2","status","concat","tokens","statusOnlineColor","statusOfflineColor","StyledIndicator","styled","class","propsAsIs","vars","avatarRoot","Root","forwardRef","props","ref","avatarSize","size","className","_props$focused","focused","isScalable","ariaLabelProp","rest","_excluded","useMemo","getInitialsForName","ariaLabel","role","trim","_extends","cx","classes","avatarItem","Wrapper","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AAE;AACFwB,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACDtB,IAAAA,OAAO,EAAE;AACLqB,MAAAA,GAAG,EAAEE,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN3B,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.74.1-canary.
|
3
|
+
"version": "0.74.1-canary.1180.8686460436.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -67,7 +67,7 @@
|
|
67
67
|
"@rollup/plugin-babel": "^6.0.3",
|
68
68
|
"@rollup/plugin-commonjs": "^25.0.4",
|
69
69
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
70
|
-
"@salutejs/plasma-sb-utils": "0.155.
|
70
|
+
"@salutejs/plasma-sb-utils": "0.155.0",
|
71
71
|
"@storybook/addon-docs": "^7.6.17",
|
72
72
|
"@storybook/addon-essentials": "^7.6.17",
|
73
73
|
"@storybook/addons": "^7.6.17",
|
@@ -102,5 +102,5 @@
|
|
102
102
|
"react-popper": "2.3.0",
|
103
103
|
"storeon": "3.1.5"
|
104
104
|
},
|
105
|
-
"gitHead": "
|
105
|
+
"gitHead": "331bb5e55c51c4c17a951815dcc88928a3a82455"
|
106
106
|
}
|
@@ -15,7 +15,7 @@ var _Avatar2 = /*#__PURE__*/require("./Avatar.styles");
|
|
15
15
|
var _base = /*#__PURE__*/require("./variations/_size/base");
|
16
16
|
var _base2 = /*#__PURE__*/require("./variations/_focused/base");
|
17
17
|
var _utils2 = /*#__PURE__*/require("./utils");
|
18
|
-
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable"];
|
18
|
+
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable", "aria-label"];
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
20
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
21
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
@@ -57,14 +57,20 @@ var avatarRoot = exports.avatarRoot = function avatarRoot(Root) {
|
|
57
57
|
_props$focused = props.focused,
|
58
58
|
focused = _props$focused === void 0 ? true : _props$focused,
|
59
59
|
isScalable = props.isScalable,
|
60
|
+
ariaLabelProp = props['aria-label'],
|
60
61
|
rest = _objectWithoutProperties(props, _excluded);
|
61
62
|
var initials = (0, _react.useMemo)(function () {
|
62
63
|
return (0, _utils2.getInitialsForName)(name);
|
63
64
|
}, [name]);
|
65
|
+
var ariaLabel = ariaLabelProp;
|
66
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.role) === 'button') {
|
67
|
+
ariaLabel = !ariaLabel || ariaLabel.trim() === '' ? name : ariaLabel;
|
68
|
+
}
|
64
69
|
return /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
65
70
|
ref: ref,
|
66
71
|
size: avatarSize,
|
67
72
|
className: (0, _utils.cx)(_Avatar.classes.avatarItem, className),
|
73
|
+
"aria-label": ariaLabel,
|
68
74
|
focused: focused
|
69
75
|
}, rest), /*#__PURE__*/_react["default"].createElement(_Avatar2.Wrapper, {
|
70
76
|
isScalable: isScalable
|
package/styled-components/cjs/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx
CHANGED
@@ -33,40 +33,56 @@ export const Default: Story = {
|
|
33
33
|
|
34
34
|
export const DynamicSize: Story = {
|
35
35
|
args: { totalCount: 10, visibleCount: 3 },
|
36
|
-
render: (args: ComponentProps<typeof AvatarGroup>) => {
|
37
|
-
const itemLength =
|
36
|
+
render: ({ visibleCount, totalCount, ...args }: ComponentProps<typeof AvatarGroup>) => {
|
37
|
+
const itemLength = totalCount;
|
38
38
|
|
39
39
|
return (
|
40
40
|
<AvatarGroup {...args}>
|
41
|
-
{Array(
|
41
|
+
{Array(visibleCount)
|
42
42
|
.fill(true)
|
43
43
|
.map((_, index) => (
|
44
|
-
<Avatar size="xxl" customText={index + 1} />
|
44
|
+
<Avatar size="xxl" key={index} customText={index + 1} />
|
45
45
|
))}
|
46
46
|
|
47
|
-
{itemLength >
|
48
|
-
<Avatar size="xxl" customText={`+${itemLength - args.visibleCount}`} />
|
49
|
-
)}
|
47
|
+
{itemLength > visibleCount && <Avatar size="xxl" customText={`+${itemLength - visibleCount}`} />}
|
50
48
|
</AvatarGroup>
|
51
49
|
);
|
52
50
|
},
|
53
51
|
};
|
54
52
|
|
53
|
+
const list = [
|
54
|
+
{
|
55
|
+
name: 'Илья Муромец',
|
56
|
+
},
|
57
|
+
{
|
58
|
+
name: 'Алеша Попович',
|
59
|
+
},
|
60
|
+
{
|
61
|
+
name: 'Добрыня Никитич',
|
62
|
+
},
|
63
|
+
{
|
64
|
+
name: 'Микула Селянинович',
|
65
|
+
},
|
66
|
+
{
|
67
|
+
name: 'Ставр Годинович',
|
68
|
+
},
|
69
|
+
];
|
70
|
+
|
55
71
|
export const Accessibility: Story = {
|
56
72
|
render: (args: ComponentProps<typeof AvatarGroup>) => {
|
57
73
|
return (
|
58
74
|
<AvatarGroup {...args}>
|
59
|
-
{
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
75
|
+
{list.map((props) => (
|
76
|
+
<Avatar
|
77
|
+
role="button"
|
78
|
+
tabIndex={0}
|
79
|
+
focused
|
80
|
+
key={props.name}
|
81
|
+
size="xxl"
|
82
|
+
url="https://avatars.githubusercontent.com/u/1813468?v=4"
|
83
|
+
{...props}
|
84
|
+
/>
|
85
|
+
))}
|
70
86
|
</AvatarGroup>
|
71
87
|
);
|
72
88
|
},
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable"];
|
1
|
+
var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable", "aria-label"];
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
@@ -47,14 +47,20 @@ export var avatarRoot = function avatarRoot(Root) {
|
|
47
47
|
_props$focused = props.focused,
|
48
48
|
focused = _props$focused === void 0 ? true : _props$focused,
|
49
49
|
isScalable = props.isScalable,
|
50
|
+
ariaLabelProp = props['aria-label'],
|
50
51
|
rest = _objectWithoutProperties(props, _excluded);
|
51
52
|
var initials = useMemo(function () {
|
52
53
|
return getInitialsForName(name);
|
53
54
|
}, [name]);
|
55
|
+
var ariaLabel = ariaLabelProp;
|
56
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.role) === 'button') {
|
57
|
+
ariaLabel = !ariaLabel || ariaLabel.trim() === '' ? name : ariaLabel;
|
58
|
+
}
|
54
59
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
55
60
|
ref: ref,
|
56
61
|
size: avatarSize,
|
57
62
|
className: cx(classes.avatarItem, className),
|
63
|
+
"aria-label": ariaLabel,
|
58
64
|
focused: focused
|
59
65
|
}, rest), /*#__PURE__*/React.createElement(Wrapper, {
|
60
66
|
isScalable: isScalable
|
package/styled-components/es/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx
CHANGED
@@ -33,40 +33,56 @@ export const Default: Story = {
|
|
33
33
|
|
34
34
|
export const DynamicSize: Story = {
|
35
35
|
args: { totalCount: 10, visibleCount: 3 },
|
36
|
-
render: (args: ComponentProps<typeof AvatarGroup>) => {
|
37
|
-
const itemLength =
|
36
|
+
render: ({ visibleCount, totalCount, ...args }: ComponentProps<typeof AvatarGroup>) => {
|
37
|
+
const itemLength = totalCount;
|
38
38
|
|
39
39
|
return (
|
40
40
|
<AvatarGroup {...args}>
|
41
|
-
{Array(
|
41
|
+
{Array(visibleCount)
|
42
42
|
.fill(true)
|
43
43
|
.map((_, index) => (
|
44
|
-
<Avatar size="xxl" customText={index + 1} />
|
44
|
+
<Avatar size="xxl" key={index} customText={index + 1} />
|
45
45
|
))}
|
46
46
|
|
47
|
-
{itemLength >
|
48
|
-
<Avatar size="xxl" customText={`+${itemLength - args.visibleCount}`} />
|
49
|
-
)}
|
47
|
+
{itemLength > visibleCount && <Avatar size="xxl" customText={`+${itemLength - visibleCount}`} />}
|
50
48
|
</AvatarGroup>
|
51
49
|
);
|
52
50
|
},
|
53
51
|
};
|
54
52
|
|
53
|
+
const list = [
|
54
|
+
{
|
55
|
+
name: 'Илья Муромец',
|
56
|
+
},
|
57
|
+
{
|
58
|
+
name: 'Алеша Попович',
|
59
|
+
},
|
60
|
+
{
|
61
|
+
name: 'Добрыня Никитич',
|
62
|
+
},
|
63
|
+
{
|
64
|
+
name: 'Микула Селянинович',
|
65
|
+
},
|
66
|
+
{
|
67
|
+
name: 'Ставр Годинович',
|
68
|
+
},
|
69
|
+
];
|
70
|
+
|
55
71
|
export const Accessibility: Story = {
|
56
72
|
render: (args: ComponentProps<typeof AvatarGroup>) => {
|
57
73
|
return (
|
58
74
|
<AvatarGroup {...args}>
|
59
|
-
{
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
75
|
+
{list.map((props) => (
|
76
|
+
<Avatar
|
77
|
+
role="button"
|
78
|
+
tabIndex={0}
|
79
|
+
focused
|
80
|
+
key={props.name}
|
81
|
+
size="xxl"
|
82
|
+
url="https://avatars.githubusercontent.com/u/1813468?v=4"
|
83
|
+
{...props}
|
84
|
+
/>
|
85
|
+
))}
|
70
86
|
</AvatarGroup>
|
71
87
|
);
|
72
88
|
},
|
@@ -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;AAMlE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,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;AAMlE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAkC7C,eAAO,MAAM,UAAU,SAAU,UAAU,cAAc,EAAE,WAAW,CAAC;;;;;;;;wCAyCtE,CAAC;AAEF,eAAO,MAAM,YAAY;;;mBA3CQ,UAAU,cAAc,EAAE,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;CA2DtE,CAAC"}
|