@salutejs/plasma-new-hope 0.76.3-canary.1180.8720362393.0 → 0.77.0-canary.1185.8719560164.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. package/cjs/components/Avatar/Avatar.js +1 -35
  2. package/cjs/components/Avatar/Avatar.js.map +1 -1
  3. package/cjs/components/Combobox/Combobox.css +2 -2
  4. package/cjs/components/Combobox/ui/ComboboxDivider/ComboboxDivider.css +2 -2
  5. package/cjs/components/Combobox/ui/ComboboxDivider/ComboboxDivider.js +1 -1
  6. package/cjs/components/Combobox/ui/ComboboxFooter/ComboboxFooter.css +2 -2
  7. package/cjs/components/Combobox/ui/ComboboxFooter/ComboboxFooter.js +1 -1
  8. package/cjs/components/Combobox/ui/ComboboxGroup/ComboboxGroup.css +2 -2
  9. package/cjs/components/Combobox/ui/ComboboxGroup/ComboboxGroup.js +1 -1
  10. package/cjs/components/Combobox/ui/ComboboxHeader/ComboboxHeader.css +2 -2
  11. package/cjs/components/Combobox/ui/ComboboxHeader/ComboboxHeader.js +1 -1
  12. package/cjs/components/Combobox/ui/ComboboxItem/ComboboxItem.css +2 -2
  13. package/cjs/components/Combobox/ui/ComboboxItem/ComboboxItem.js +1 -1
  14. package/cjs/components/Combobox/ui/ComboboxItem/ComboboxItem.styles.js +1 -1
  15. package/cjs/components/Dropdown/Dropdown.css +2 -2
  16. package/cjs/components/Dropdown/Dropdown.js +27 -4
  17. package/cjs/components/Dropdown/Dropdown.js.map +1 -1
  18. package/cjs/components/Dropdown/Dropdown.styles.js +1 -1
  19. package/cjs/components/Dropdown/Dropdown.styles.js.map +1 -1
  20. package/cjs/components/Dropdown/{Dropdown.styles_1daxhqh.css → Dropdown.styles_13400l5.css} +1 -1
  21. package/cjs/components/Dropdown/Dropdown.tokens.js +1 -0
  22. package/cjs/components/Dropdown/Dropdown.tokens.js.map +1 -1
  23. package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +81 -0
  24. package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -0
  25. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
  26. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
  27. package/cjs/components/Dropdown/utils/index.js +43 -0
  28. package/cjs/components/Dropdown/utils/index.js.map +1 -1
  29. package/cjs/components/Pagination/Pagination.css +2 -2
  30. package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -2
  31. package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.js +1 -1
  32. package/cjs/components/Select/Select.css +2 -2
  33. package/cjs/components/Select/ui/SelectDivider/SelectDivider.css +2 -2
  34. package/cjs/components/Select/ui/SelectDivider/SelectDivider.js +1 -1
  35. package/cjs/components/Select/ui/SelectFooter/SelectFooter.css +2 -2
  36. package/cjs/components/Select/ui/SelectFooter/SelectFooter.js +1 -1
  37. package/cjs/components/Select/ui/SelectGroup/SelectGroup.css +2 -2
  38. package/cjs/components/Select/ui/SelectGroup/SelectGroup.js +1 -1
  39. package/cjs/components/Select/ui/SelectHeader/SelectHeader.css +2 -2
  40. package/cjs/components/Select/ui/SelectHeader/SelectHeader.js +1 -1
  41. package/cjs/components/Select/ui/SelectItem/SelectItem.css +2 -2
  42. package/cjs/components/Select/ui/SelectItem/SelectItem.js +1 -1
  43. package/cjs/components/Select/ui/SelectItem/SelectItem.styles.js +1 -1
  44. package/cjs/index.css +2 -2
  45. package/cjs/index.js +2 -0
  46. package/cjs/index.js.map +1 -1
  47. package/es/components/Avatar/Avatar.js +2 -36
  48. package/es/components/Avatar/Avatar.js.map +1 -1
  49. package/es/components/Combobox/Combobox.css +2 -2
  50. package/es/components/Combobox/ui/ComboboxDivider/ComboboxDivider.css +2 -2
  51. package/es/components/Combobox/ui/ComboboxDivider/ComboboxDivider.js +1 -1
  52. package/es/components/Combobox/ui/ComboboxFooter/ComboboxFooter.css +2 -2
  53. package/es/components/Combobox/ui/ComboboxFooter/ComboboxFooter.js +1 -1
  54. package/es/components/Combobox/ui/ComboboxGroup/ComboboxGroup.css +2 -2
  55. package/es/components/Combobox/ui/ComboboxGroup/ComboboxGroup.js +1 -1
  56. package/es/components/Combobox/ui/ComboboxHeader/ComboboxHeader.css +2 -2
  57. package/es/components/Combobox/ui/ComboboxHeader/ComboboxHeader.js +1 -1
  58. package/es/components/Combobox/ui/ComboboxItem/ComboboxItem.css +2 -2
  59. package/es/components/Combobox/ui/ComboboxItem/ComboboxItem.js +1 -1
  60. package/es/components/Combobox/ui/ComboboxItem/ComboboxItem.styles.js +1 -1
  61. package/es/components/Dropdown/Dropdown.css +2 -2
  62. package/es/components/Dropdown/Dropdown.js +29 -6
  63. package/es/components/Dropdown/Dropdown.js.map +1 -1
  64. package/es/components/Dropdown/Dropdown.styles.js +1 -1
  65. package/es/components/Dropdown/Dropdown.styles.js.map +1 -1
  66. package/es/components/Dropdown/{Dropdown.styles_1daxhqh.css → Dropdown.styles_13400l5.css} +1 -1
  67. package/es/components/Dropdown/Dropdown.tokens.js +1 -0
  68. package/es/components/Dropdown/Dropdown.tokens.js.map +1 -1
  69. package/es/components/Dropdown/hooks/useKeyboardNavigation.js +76 -0
  70. package/es/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -0
  71. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
  72. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
  73. package/es/components/Dropdown/utils/index.js +45 -3
  74. package/es/components/Dropdown/utils/index.js.map +1 -1
  75. package/es/components/Pagination/Pagination.css +2 -2
  76. package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -2
  77. package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.js +1 -1
  78. package/es/components/Select/Select.css +2 -2
  79. package/es/components/Select/ui/SelectDivider/SelectDivider.css +2 -2
  80. package/es/components/Select/ui/SelectDivider/SelectDivider.js +1 -1
  81. package/es/components/Select/ui/SelectFooter/SelectFooter.css +2 -2
  82. package/es/components/Select/ui/SelectFooter/SelectFooter.js +1 -1
  83. package/es/components/Select/ui/SelectGroup/SelectGroup.css +2 -2
  84. package/es/components/Select/ui/SelectGroup/SelectGroup.js +1 -1
  85. package/es/components/Select/ui/SelectHeader/SelectHeader.css +2 -2
  86. package/es/components/Select/ui/SelectHeader/SelectHeader.js +1 -1
  87. package/es/components/Select/ui/SelectItem/SelectItem.css +2 -2
  88. package/es/components/Select/ui/SelectItem/SelectItem.js +1 -1
  89. package/es/components/Select/ui/SelectItem/SelectItem.styles.js +1 -1
  90. package/es/index.css +2 -2
  91. package/es/index.js +1 -0
  92. package/es/index.js.map +1 -1
  93. package/package.json +2 -2
  94. package/styled-components/cjs/components/Avatar/Avatar.js +1 -40
  95. package/styled-components/cjs/components/Avatar/Avatar.template-doc.mdx +2 -52
  96. package/styled-components/cjs/components/Dropdown/Dropdown.js +28 -6
  97. package/styled-components/cjs/components/Dropdown/Dropdown.styles.js +1 -1
  98. package/styled-components/cjs/components/Dropdown/Dropdown.tokens.js +1 -0
  99. package/styled-components/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +83 -0
  100. package/styled-components/cjs/components/Dropdown/index.js +9 -1
  101. package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
  102. package/styled-components/cjs/components/Dropdown/utils/index.js +48 -1
  103. package/styled-components/cjs/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +1 -26
  104. package/styled-components/cjs/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +18 -36
  105. package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.js +1 -1
  106. package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.stories.tsx +27 -7
  107. package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.js +1 -1
  108. package/styled-components/cjs/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.stories.tsx +30 -11
  109. package/styled-components/cjs/examples/plasma_web/components/Avatar/Avatar.stories.tsx +1 -26
  110. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Normal/Dropdown.config.js +1 -1
  111. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Normal/Dropdown.stories.tsx +28 -9
  112. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Tight/Dropdown.config.js +1 -1
  113. package/styled-components/cjs/examples/plasma_web/components/Dropdown/Tight/Dropdown.stories.tsx +31 -12
  114. package/styled-components/cjs/examples/sds_engineer/components/Avatar/Avatar.stories.tsx +1 -27
  115. package/styled-components/es/components/Avatar/Avatar.js +1 -41
  116. package/styled-components/es/components/Avatar/Avatar.template-doc.mdx +2 -52
  117. package/styled-components/es/components/Dropdown/Dropdown.js +29 -6
  118. package/styled-components/es/components/Dropdown/Dropdown.styles.js +1 -1
  119. package/styled-components/es/components/Dropdown/Dropdown.tokens.js +1 -0
  120. package/styled-components/es/components/Dropdown/hooks/useKeyboardNavigation.js +77 -0
  121. package/styled-components/es/components/Dropdown/index.js +1 -0
  122. package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +5 -3
  123. package/styled-components/es/components/Dropdown/utils/index.js +48 -1
  124. package/styled-components/es/examples/plasma_b2c/components/Avatar/Avatar.stories.tsx +1 -26
  125. package/styled-components/es/examples/plasma_b2c/components/AvatarGroup/AvatarGroup.stories.tsx +18 -36
  126. package/styled-components/es/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.js +1 -1
  127. package/styled-components/es/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.stories.tsx +27 -7
  128. package/styled-components/es/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.js +1 -1
  129. package/styled-components/es/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.stories.tsx +30 -11
  130. package/styled-components/es/examples/plasma_web/components/Avatar/Avatar.stories.tsx +1 -26
  131. package/styled-components/es/examples/plasma_web/components/Dropdown/Normal/Dropdown.config.js +1 -1
  132. package/styled-components/es/examples/plasma_web/components/Dropdown/Normal/Dropdown.stories.tsx +28 -9
  133. package/styled-components/es/examples/plasma_web/components/Dropdown/Tight/Dropdown.config.js +1 -1
  134. package/styled-components/es/examples/plasma_web/components/Dropdown/Tight/Dropdown.stories.tsx +31 -12
  135. package/styled-components/es/examples/sds_engineer/components/Avatar/Avatar.stories.tsx +1 -27
  136. package/types/components/Avatar/Avatar.d.ts +1 -3
  137. package/types/components/Avatar/Avatar.d.ts.map +1 -1
  138. package/types/components/Avatar/Avatar.types.d.ts +0 -7
  139. package/types/components/Avatar/Avatar.types.d.ts.map +1 -1
  140. package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
  141. package/types/components/Dropdown/Dropdown.tokens.d.ts +1 -0
  142. package/types/components/Dropdown/Dropdown.tokens.d.ts.map +1 -1
  143. package/types/components/Dropdown/Dropdown.types.d.ts +7 -2
  144. package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
  145. package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts +13 -0
  146. package/types/components/Dropdown/hooks/useKeyboardNavigation.d.ts.map +1 -0
  147. package/types/components/Dropdown/index.d.ts +1 -0
  148. package/types/components/Dropdown/index.d.ts.map +1 -1
  149. package/types/components/Dropdown/ui/DropdownItem/DropdownItem.d.ts.map +1 -1
  150. package/types/components/Dropdown/utils/index.d.ts +5 -2
  151. package/types/components/Dropdown/utils/index.d.ts.map +1 -1
  152. package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts +0 -2
  153. package/types/examples/plasma_b2c/components/Avatar/Avatar.d.ts.map +1 -1
  154. package/types/examples/plasma_b2c/components/Dropdown/Normal/Dropdown.config.d.ts.map +1 -1
  155. package/types/examples/plasma_b2c/components/Dropdown/Tight/Dropdown.config.d.ts.map +1 -1
  156. package/types/examples/plasma_web/components/Avatar/Avatar.d.ts +0 -2
  157. package/types/examples/plasma_web/components/Avatar/Avatar.d.ts.map +1 -1
  158. package/types/examples/plasma_web/components/Dropdown/Normal/Dropdown.config.d.ts.map +1 -1
  159. package/types/examples/plasma_web/components/Dropdown/Tight/Dropdown.config.d.ts.map +1 -1
  160. package/types/examples/sds_engineer/components/Avatar/Avatar.d.ts +0 -1
  161. package/types/examples/sds_engineer/components/Avatar/Avatar.d.ts.map +1 -1
@@ -15,22 +15,13 @@ 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", "statusDict"];
18
+ var _excluded = ["size", "name", "url", "customText", "status", "className", "focused", "isScalable"];
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; }
22
22
  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); }
23
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
27
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
28
23
  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; }
29
24
  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; }
30
- var StatusDictDefault = {
31
- active: 'Активен',
32
- inactive: 'Неактивен'
33
- };
34
25
  var getAvatarContent = function getAvatarContent(_ref) {
35
26
  var customText = _ref.customText,
36
27
  url = _ref.url,
@@ -47,27 +38,6 @@ var getAvatarContent = function getAvatarContent(_ref) {
47
38
  }
48
39
  return /*#__PURE__*/_react["default"].createElement(_Avatar2.Text, null, initials);
49
40
  };
50
- var getAriaLabel = function getAriaLabel(props) {
51
- var customText = props.customText,
52
- url = props.url,
53
- name = props.name,
54
- status = props.status,
55
- ariaLabelProp = props['aria-label'],
56
- role = props.role,
57
- statusDict = props.statusDict;
58
-
59
- // INFO: В этих сценариях aria-label не нужен
60
- if (customText || !role || role !== 'button') {
61
- return undefined;
62
- }
63
-
64
- // INFO: включаем aria-label чтобы озвучить что на изображении
65
- if (url) {
66
- var ariaLabel = !ariaLabelProp || ariaLabelProp.trim() === '' ? name : ariaLabelProp;
67
- return status ? "".concat(ariaLabel, ". ").concat(statusDict[status]) : ariaLabel;
68
- }
69
- return undefined;
70
- };
71
41
  var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Indicator.indicatorConfig);
72
42
  var Indicator = /*#__PURE__*/(0, _engines.component)(mergedConfig);
73
43
  var StyledIndicator = /*#__PURE__*/(0, _styledComponents["default"])(Indicator).withConfig({
@@ -87,22 +57,14 @@ var avatarRoot = exports.avatarRoot = function avatarRoot(Root) {
87
57
  _props$focused = props.focused,
88
58
  focused = _props$focused === void 0 ? true : _props$focused,
89
59
  isScalable = props.isScalable,
90
- _props$statusDict = props.statusDict,
91
- statusDict = _props$statusDict === void 0 ? StatusDictDefault : _props$statusDict,
92
60
  rest = _objectWithoutProperties(props, _excluded);
93
61
  var initials = (0, _react.useMemo)(function () {
94
62
  return (0, _utils2.getInitialsForName)(name);
95
63
  }, [name]);
96
- var ariaLabel = (0, _react.useMemo)(function () {
97
- return getAriaLabel(_objectSpread(_objectSpread({}, props), {}, {
98
- statusDict: statusDict
99
- }));
100
- }, [name, url, rest.role, status, customText, statusDict, rest['aria-label']]);
101
64
  return /*#__PURE__*/_react["default"].createElement(Root, _extends({
102
65
  ref: ref,
103
66
  size: avatarSize,
104
67
  className: (0, _utils.cx)(_Avatar.classes.avatarItem, className),
105
- "aria-label": ariaLabel,
106
68
  focused: focused
107
69
  }, rest), /*#__PURE__*/_react["default"].createElement(_Avatar2.Wrapper, {
108
70
  isScalable: isScalable
@@ -112,7 +74,6 @@ var avatarRoot = exports.avatarRoot = function avatarRoot(Root) {
112
74
  initials: initials,
113
75
  name: name
114
76
  })), status && /*#__PURE__*/_react["default"].createElement(_Avatar2.StatusIcon, null, /*#__PURE__*/_react["default"].createElement(StyledIndicator, {
115
- "aria-label": statusDict[status],
116
77
  status: status
117
78
  })));
118
79
  });
@@ -81,32 +81,7 @@ export function App() {
81
81
  ```
82
82
 
83
83
  ### Доступность
84
-
85
- #### Avatar c использованием изображения
86
-
87
- В данном случае руководствуемся принципом универсального дизайна, т.е. незрячий должен получить ту же информацию, что и зрячий.
88
-
89
- Поэтому добавляем/используем свойства: `role`, `tabIndex` и `aria-label`.
90
-
91
- Примечание:
92
- - если указано свойство `name` то `aria-label` можно опустить;
93
-
94
- ```tsx live
95
- import React from 'react';
96
- import { Avatar } from '@salutejs/{{ package }}';
97
-
98
- export function App() {
99
- return (
100
- <>
101
- <Avatar role="button" tabIndex={0} name="Иван Фадеев" url="https://avatars.githubusercontent.com/u/1813468?v=4" />
102
- </>
103
- );
104
- }
105
- ```
106
-
107
- #### Avatar c текстом
108
-
109
- В этом случае достаточно указать свойство `name`.
84
+ Добавляем `"role"` и `"tabIndex"`.
110
85
 
111
86
  ```tsx live
112
87
  import React from 'react';
@@ -115,33 +90,8 @@ import { Avatar } from '@salutejs/{{ package }}';
115
90
  export function App() {
116
91
  return (
117
92
  <>
118
- <Avatar role="button" tabIndex={0} name="Иван Фадеев" />
93
+ <Avatar role="button" tabIndex="0" name="Иван Фадеев" />
119
94
  </>
120
95
  );
121
96
  }
122
97
  ```
123
-
124
- #### Avatar и статус
125
-
126
- Если указано свойство `status` его значение будет так же озвучено в комбинации со свойством `name` или `aria-label`.
127
-
128
- ```tsx live
129
- import React from 'react';
130
- import { Avatar } from '@salutejs/{{ package }}';
131
-
132
- export function App() {
133
- return (
134
- <>
135
- <Avatar role="button" tabIndex={0} name="Иван Фадеев" status="inactive" />
136
- </>
137
- );
138
- }
139
- ```
140
-
141
- Озвучит как `ИФ. Неактивен`. (В данном примере озвучиваются инициалы, производное от ФИО)
142
-
143
- #### Свойство statusDict
144
-
145
- Опциональное свойство для корректной озвучки значений свойства `status`.
146
-
147
- По-умолчанию стоит значение для русскоговорящих `{ active: 'Активен', inactive: 'Неактивен' }`.
@@ -7,11 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.dropdownRoot = exports.dropdownConfig = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
9
  var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
10
+ var _utils = /*#__PURE__*/require("../../utils");
10
11
  var _base = /*#__PURE__*/require("./variations/_view/base");
11
12
  var _base2 = /*#__PURE__*/require("./variations/_size/base");
12
13
  var _Dropdown = /*#__PURE__*/require("./Dropdown.styles");
13
- var _utils = /*#__PURE__*/require("./utils");
14
- var _excluded = ["id", "target", "children", "hasArrow", "role", "view", "size", "frame", "onToggle", "isFocusTrapped", "isOpen", "placement", "trigger", "offset", "preventOverflow", "closeOnOverlayClick", "closeOnEsc"];
14
+ var _utils2 = /*#__PURE__*/require("./utils");
15
+ var _Dropdown2 = /*#__PURE__*/require("./Dropdown.tokens");
16
+ var _useKeyboardNavigation = /*#__PURE__*/require("./hooks/useKeyboardNavigation");
17
+ var _excluded = ["id", "target", "children", "hasArrow", "view", "size", "frame", "onToggle", "className", "isFocusTrapped", "isOpen", "role", "placement", "trigger", "offset", "preventOverflow", "closeOnOverlayClick", "closeOnEsc"];
15
18
  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); }
16
19
  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; }
17
20
  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); }
@@ -26,15 +29,17 @@ var dropdownRoot = exports.dropdownRoot = function dropdownRoot(Root) {
26
29
  target = _ref.target,
27
30
  children = _ref.children,
28
31
  hasArrow = _ref.hasArrow,
29
- role = _ref.role,
30
32
  view = _ref.view,
31
33
  size = _ref.size,
32
34
  frame = _ref.frame,
33
35
  _onToggle = _ref.onToggle,
36
+ className = _ref.className,
34
37
  _ref$isFocusTrapped = _ref.isFocusTrapped,
35
38
  isFocusTrapped = _ref$isFocusTrapped === void 0 ? true : _ref$isFocusTrapped,
36
39
  _ref$isOpen = _ref.isOpen,
37
40
  isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
41
+ _ref$role = _ref.role,
42
+ role = _ref$role === void 0 ? 'listbox' : _ref$role,
38
43
  _ref$placement = _ref.placement,
39
44
  placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
40
45
  _ref$trigger = _ref.trigger,
@@ -52,9 +57,24 @@ var dropdownRoot = exports.dropdownRoot = function dropdownRoot(Root) {
52
57
  var innerId = id || uniqId;
53
58
  var rootRef = (0, _react.useRef)(null);
54
59
  var dropdownRef = (0, _react.useRef)(null);
60
+ var itemsRefs = (0, _react.useRef)([]);
55
61
  var handleRef = (0, _plasmaCore.useForkRef)(rootRef, outerRootRef);
56
62
  var trapRef = (0, _plasmaCore.useFocusTrap)(isOpen && isFocusTrapped);
57
63
  var dropdownForkRef = (0, _plasmaCore.useForkRef)(dropdownRef, trapRef);
64
+ var _useKeyNavigation = (0, _useKeyboardNavigation.useKeyNavigation)({
65
+ itemsRefs: itemsRefs,
66
+ opened: isOpen,
67
+ updateOpened: _onToggle
68
+ }),
69
+ onKeyDownTarget = _useKeyNavigation.onKeyDownTarget;
70
+ var childrenArray = (0, _react.useMemo)(function () {
71
+ return _react.Children.toArray(children);
72
+ }, [children]);
73
+ var childrenMemo = (0, _react.useMemo)(function () {
74
+ return (0, _utils2.getChildren)(childrenArray, {
75
+ childrenRefs: itemsRefs
76
+ });
77
+ }, [childrenArray, isOpen]);
58
78
  return /*#__PURE__*/_react["default"].createElement(_Dropdown.StyledPopover, {
59
79
  role: role,
60
80
  isOpen: isOpen,
@@ -68,17 +88,19 @@ var dropdownRoot = exports.dropdownRoot = function dropdownRoot(Root) {
68
88
  offset: offset,
69
89
  preventOverflow: preventOverflow,
70
90
  hasArrow: hasArrow,
71
- placement: (0, _utils.getPlacements)(placement),
91
+ placement: (0, _utils2.getPlacements)(placement),
72
92
  trigger: trigger,
73
93
  closeOnOverlayClick: closeOnOverlayClick,
74
94
  closeOnEsc: closeOnEsc,
75
95
  isFocusTrapped: isFocusTrapped,
76
- frame: frame
96
+ frame: frame,
97
+ onKeyDown: onKeyDownTarget
77
98
  }, /*#__PURE__*/_react["default"].createElement(Root, _extends({
99
+ className: (0, _utils.cx)(className, _Dropdown2.classes.dropdownRoot),
78
100
  ref: handleRef,
79
101
  view: view,
80
102
  size: size
81
- }, rest), /*#__PURE__*/_react["default"].createElement(_Dropdown.StyledDropdown, null, children)));
103
+ }, rest), /*#__PURE__*/_react["default"].createElement(_Dropdown.StyledDropdown, null, childrenMemo)));
82
104
  });
83
105
  };
84
106
  var dropdownConfig = exports.dropdownConfig = {
@@ -13,7 +13,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
13
13
  var Popover = /*#__PURE__*/(0, _engines.component)(_Popover.popoverConfig);
14
14
  var StyledPopover = exports.StyledPopover = /*#__PURE__*/(0, _styledComponents["default"])(Popover).withConfig({
15
15
  componentId: "plasma-new-hope__sc-13ezpo5-0"
16
- })([".", "{display:block;}"], /*#__PURE__*/String(_Popover.popoverClasses.target));
16
+ })([".", ",.", "{display:block;}"], /*#__PURE__*/String(_Popover.popoverClasses.wrapper), /*#__PURE__*/String(_Popover.popoverClasses.target));
17
17
  var StyledDropdown = exports.StyledDropdown = /*#__PURE__*/_styledComponents["default"].div.withConfig({
18
18
  componentId: "plasma-new-hope__sc-13ezpo5-1"
19
19
  })(["box-sizing:border-box;background:var(", ");box-shadow:var(", ");border-radius:var(", ");width:var(", ");height:var(", ");padding:var(", ") var(", ") var(", ") var(", ");"], _Dropdown.tokens.background, _Dropdown.tokens.boxShadow, _Dropdown.tokens.borderRadius, _Dropdown.tokens.width, _Dropdown.tokens.height, _Dropdown.tokens.paddingTop, _Dropdown.tokens.paddingRight, _Dropdown.tokens.paddingBottom, _Dropdown.tokens.paddingLeft);
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.tokens = exports.classes = void 0;
7
7
  var classes = exports.classes = {
8
+ dropdownRoot: 'dropdown-root',
8
9
  dropdownItemIsSelected: 'dropdown-item-is-selected',
9
10
  dropdownItemIsDisabled: 'dropdown-item-is-disabled'
10
11
  };
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useKeyNavigation = exports.Keys = void 0;
7
+ var _react = /*#__PURE__*/require("react");
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ var Keys = exports.Keys = {
15
+ Tab: 'Tab',
16
+ Enter: 'Enter',
17
+ Escape: 'Escape',
18
+ ArrowUp: 'ArrowUp',
19
+ ArrowDown: 'ArrowDown'
20
+ };
21
+ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref) {
22
+ var itemsRefs = _ref.itemsRefs,
23
+ opened = _ref.opened,
24
+ updateOpened = _ref.updateOpened;
25
+ var _useState = (0, _react.useState)(0),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ selectItemIndex = _useState2[0],
28
+ setSelectItemIndex = _useState2[1];
29
+ (0, _react.useEffect)(function () {
30
+ var _itemsRefs$current, _itemsRefs$current$se;
31
+ if (!opened) {
32
+ setSelectItemIndex(0);
33
+ return;
34
+ }
35
+ itemsRefs === null || itemsRefs === void 0 ? void 0 : (_itemsRefs$current = itemsRefs.current) === null || _itemsRefs$current === void 0 ? void 0 : (_itemsRefs$current$se = _itemsRefs$current[selectItemIndex]) === null || _itemsRefs$current$se === void 0 ? void 0 : _itemsRefs$current$se.focus();
36
+ }, [opened]);
37
+ var onKeyDownTarget = (0, _react.useCallback)(function (event) {
38
+ var _focusedItem, _focusedItem2;
39
+ event.stopPropagation();
40
+ var code = event.code;
41
+ var itemsRefsCount = itemsRefs.current.length;
42
+ var newOpened = opened;
43
+ var newSelectItemIndex = selectItemIndex;
44
+ var focusedItem = null;
45
+ if (code === Keys.Escape || code === Keys.Tab) {
46
+ newOpened = false;
47
+ newSelectItemIndex = -1;
48
+ updateOpened === null || updateOpened === void 0 ? void 0 : updateOpened(newOpened, event);
49
+ }
50
+ if (code === Keys.ArrowUp) {
51
+ var _itemsRefs$current2;
52
+ newSelectItemIndex = newSelectItemIndex - 1 === -1 ? itemsRefsCount - 1 : newSelectItemIndex - 1;
53
+ focusedItem = itemsRefs === null || itemsRefs === void 0 ? void 0 : (_itemsRefs$current2 = itemsRefs.current) === null || _itemsRefs$current2 === void 0 ? void 0 : _itemsRefs$current2[newSelectItemIndex];
54
+ }
55
+ if (code === Keys.ArrowDown) {
56
+ var _itemsRefs$current3;
57
+ newSelectItemIndex = newSelectItemIndex + 1 === itemsRefsCount ? 0 : newSelectItemIndex + 1;
58
+ focusedItem = itemsRefs === null || itemsRefs === void 0 ? void 0 : (_itemsRefs$current3 = itemsRefs.current) === null || _itemsRefs$current3 === void 0 ? void 0 : _itemsRefs$current3[newSelectItemIndex];
59
+ }
60
+ if (code === Keys.Enter) {
61
+ event.preventDefault();
62
+ var item = itemsRefs.current[newSelectItemIndex];
63
+
64
+ // TODO: #1016
65
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
+ // @ts-ignore
67
+ if (item !== null && item !== void 0 && item.ariaDisabled) {
68
+ return;
69
+ }
70
+ item === null || item === void 0 ? void 0 : item.click();
71
+ }
72
+ setSelectItemIndex(newSelectItemIndex);
73
+ (_focusedItem = focusedItem) === null || _focusedItem === void 0 ? void 0 : _focusedItem.focus();
74
+ (_focusedItem2 = focusedItem) === null || _focusedItem2 === void 0 ? void 0 : _focusedItem2.scrollIntoView({
75
+ behavior: 'smooth',
76
+ block: 'center',
77
+ inline: 'center'
78
+ });
79
+ }, [opened, selectItemIndex, updateOpened]);
80
+ return {
81
+ onKeyDownTarget: onKeyDownTarget
82
+ };
83
+ };
@@ -7,7 +7,8 @@ var _exportNames = {
7
7
  dropdownRoot: true,
8
8
  dropdownConfig: true,
9
9
  dropdownClasses: true,
10
- dropdownTokens: true
10
+ dropdownTokens: true,
11
+ useDropdownKeyNavigation: true
11
12
  };
12
13
  Object.defineProperty(exports, "dropdownClasses", {
13
14
  enumerable: true,
@@ -33,8 +34,15 @@ Object.defineProperty(exports, "dropdownTokens", {
33
34
  return _Dropdown2.tokens;
34
35
  }
35
36
  });
37
+ Object.defineProperty(exports, "useDropdownKeyNavigation", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _useKeyboardNavigation.useKeyNavigation;
41
+ }
42
+ });
36
43
  var _Dropdown = /*#__PURE__*/require("./Dropdown");
37
44
  var _Dropdown2 = /*#__PURE__*/require("./Dropdown.tokens");
45
+ var _useKeyboardNavigation = /*#__PURE__*/require("./hooks/useKeyboardNavigation");
38
46
  var _ui = /*#__PURE__*/require("./ui");
39
47
  Object.keys(_ui).forEach(function (key) {
40
48
  if (key === "default" || key === "__esModule") return;
@@ -13,7 +13,7 @@ var _utils2 = /*#__PURE__*/require("../../utils");
13
13
  var _base = /*#__PURE__*/require("./variations/_view/base");
14
14
  var _base2 = /*#__PURE__*/require("./variations/_size/base");
15
15
  var _DropdownItem = /*#__PURE__*/require("./DropdownItem.styles");
16
- var _excluded = ["id", "className", "children", "text", "isSelected", "name", "checked", "value", "role", "view", "size", "disabled", "contentLeft", "contentRight", "onSelect", "onClick", "onChange"];
16
+ var _excluded = ["id", "className", "children", "text", "isSelected", "name", "checked", "value", "view", "size", "disabled", "role", "contentLeft", "contentRight", "onSelect", "onClick", "onChange"];
17
17
  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); }
18
18
  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; }
19
19
  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); }
@@ -37,10 +37,11 @@ var dropdownItemRoot = exports.dropdownItemRoot = function dropdownItemRoot(Root
37
37
  name = _ref.name,
38
38
  checked = _ref.checked,
39
39
  value = _ref.value,
40
- role = _ref.role,
41
40
  view = _ref.view,
42
41
  size = _ref.size,
43
42
  disabled = _ref.disabled,
43
+ _ref$role = _ref.role,
44
+ role = _ref$role === void 0 ? 'option' : _ref$role,
44
45
  ContentLeftComponent = _ref.contentLeft,
45
46
  ContentRightComponent = _ref.contentRight,
46
47
  onSelect = _ref.onSelect,
@@ -74,7 +75,7 @@ var dropdownItemRoot = exports.dropdownItemRoot = function dropdownItemRoot(Root
74
75
  value: value,
75
76
  checked: checked || isSelected,
76
77
  disabled: disabled,
77
- tabIndex: 0
78
+ tabIndex: -1
78
79
  }, !disabled && {
79
80
  onChange: handleOnChange
80
81
  });
@@ -94,6 +95,7 @@ var dropdownItemRoot = exports.dropdownItemRoot = function dropdownItemRoot(Root
94
95
  ref: outerRootRef,
95
96
  tabIndex: 0,
96
97
  "aria-disabled": disabled,
98
+ "aria-selected": isSelected,
97
99
  onClick: handleOnClick,
98
100
  "data-value": value
99
101
  }, rest), text ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_DropdownItem.StyledContentLeft, null, ContentLeftComponent && ContentLeft), /*#__PURE__*/_react["default"].createElement(_DropdownItem.StyledText, null, text), /*#__PURE__*/_react["default"].createElement(_DropdownItem.StyledContentRight, null, ContentRightComponent && ContentRight)) : children);
@@ -3,10 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getValidComponent = exports.getPlacements = exports.getPlacement = void 0;
6
+ exports.getValidComponent = exports.getPlacements = exports.getPlacement = exports.getChildren = void 0;
7
7
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
8
8
  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); }
9
9
  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; }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
15
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11
16
  var getPlacement = exports.getPlacement = function getPlacement(placement) {
12
17
  return "".concat(placement, "-start");
@@ -35,4 +40,46 @@ var getValidComponent = exports.getValidComponent = function getValidComponent(e
35
40
  return /*#__PURE__*/_react["default"].createElement(Component, props);
36
41
  }
37
42
  return element;
43
+ };
44
+ var getChildren = exports.getChildren = function getChildren(children, externalProps) {
45
+ if (externalProps.childrenRefs) {
46
+ externalProps.childrenRefs.current = [];
47
+ }
48
+ var res = _react.Children.map(children || [], function (child) {
49
+ var hasValue = ('value' in (child === null || child === void 0 ? void 0 : child.props));
50
+ var hasTarget = ('target' in (child === null || child === void 0 ? void 0 : child.props));
51
+ if (! /*#__PURE__*/(0, _react.isValidElement)(child) || !hasValue && !hasTarget) {
52
+ return child;
53
+ }
54
+ if (hasTarget) {
55
+ var _ref = child === null || child === void 0 ? void 0 : child.props,
56
+ target = _ref.target;
57
+ if (! /*#__PURE__*/(0, _react.isValidElement)(target)) {
58
+ return child;
59
+ }
60
+ var targetProps = _objectSpread(_objectSpread({}, target === null || target === void 0 ? void 0 : target.props), {}, {
61
+ ref: function ref(element) {
62
+ var _externalProps$childr;
63
+ if (externalProps !== null && externalProps !== void 0 && (_externalProps$childr = externalProps.childrenRefs) !== null && _externalProps$childr !== void 0 && _externalProps$childr.current && element) {
64
+ externalProps.childrenRefs.current.push(element);
65
+ }
66
+ }
67
+ });
68
+ var updatedTarget = /*#__PURE__*/(0, _react.cloneElement)(target, targetProps);
69
+ var updatedProps = _objectSpread(_objectSpread({}, child === null || child === void 0 ? void 0 : child.props), {}, {
70
+ target: updatedTarget
71
+ });
72
+ return /*#__PURE__*/(0, _react.cloneElement)(child, updatedProps);
73
+ }
74
+ var props = _objectSpread(_objectSpread({}, child === null || child === void 0 ? void 0 : child.props), {}, {
75
+ ref: function ref(element) {
76
+ var _externalProps$childr2;
77
+ if (externalProps !== null && externalProps !== void 0 && (_externalProps$childr2 = externalProps.childrenRefs) !== null && _externalProps$childr2 !== void 0 && _externalProps$childr2.current && element) {
78
+ externalProps.childrenRefs.current.push(element);
79
+ }
80
+ }
81
+ });
82
+ return /*#__PURE__*/(0, _react.cloneElement)(child, props);
83
+ });
84
+ return res;
38
85
  };
@@ -34,38 +34,13 @@ export const Default: Story = {
34
34
  };
35
35
 
36
36
  export const Accessibility: Story = {
37
- args: {
38
- role: 'button',
39
- name: 'Геннадий Силуянович',
40
- tabIndex: 0,
41
- view: 'default',
42
- size: 'xxl',
43
- status: 'active',
44
- focused: true,
45
- },
46
- };
47
-
48
- export const AccessibilityWithURL: Story = {
49
37
  args: {
50
38
  role: 'button',
51
39
  tabIndex: 0,
52
40
  view: 'default',
53
41
  size: 'xxl',
42
+ name: 'Иван Фадеев',
54
43
  status: 'active',
55
44
  focused: true,
56
- name: 'Микула Селянинович',
57
- url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
58
- },
59
- };
60
-
61
- export const AccessibilityWithCustomText: Story = {
62
- args: {
63
- role: 'button',
64
- tabIndex: 0,
65
- view: 'default',
66
- size: 'xxl',
67
- status: 'inactive',
68
- focused: true,
69
- customText: 'ФИО',
70
45
  },
71
46
  };
@@ -8,7 +8,6 @@ import { Avatar } from '../Avatar/Avatar';
8
8
  import { AvatarGroup } from './AvatarGroup';
9
9
 
10
10
  type Story = StoryObj<ComponentProps<typeof AvatarGroup>>;
11
- type Avatar = ComponentProps<typeof Avatar>;
12
11
 
13
12
  const meta: Meta<typeof AvatarGroup> = {
14
13
  title: 'plasma_b2c/AvatarGroup',
@@ -34,57 +33,40 @@ export const Default: Story = {
34
33
 
35
34
  export const DynamicSize: Story = {
36
35
  args: { totalCount: 10, visibleCount: 3 },
37
- render: ({ visibleCount, totalCount, ...args }: ComponentProps<typeof AvatarGroup>) => {
38
- const itemLength = totalCount;
36
+ render: (args: ComponentProps<typeof AvatarGroup>) => {
37
+ const itemLength = args.totalCount;
39
38
 
40
39
  return (
41
40
  <AvatarGroup {...args}>
42
- {Array(visibleCount)
41
+ {Array(args.visibleCount)
43
42
  .fill(true)
44
43
  .map((_, index) => (
45
- <Avatar size="xxl" key={index} customText={index + 1} />
44
+ <Avatar size="xxl" customText={index + 1} />
46
45
  ))}
47
46
 
48
- {itemLength > visibleCount && <Avatar size="xxl" customText={`+${itemLength - visibleCount}`} />}
47
+ {itemLength > args.visibleCount && (
48
+ <Avatar size="xxl" customText={`+${itemLength - args.visibleCount}`} />
49
+ )}
49
50
  </AvatarGroup>
50
51
  );
51
52
  },
52
53
  };
53
54
 
54
- const list: Array<Avatar> = [
55
- {
56
- name: 'Илья Муромец',
57
- status: 'active',
58
- url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
59
- },
60
- {
61
- name: 'Алеша Попович',
62
- status: 'active',
63
- url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
64
- },
65
- {
66
- name: 'Добрыня Никитич',
67
- status: 'active',
68
- url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
69
- },
70
- {
71
- name: 'Микула Селянинович',
72
- status: 'inactive',
73
- url: 'https://avatars.githubusercontent.com/u/1813468?v=4',
74
- },
75
- {
76
- name: 'Ставр Годинович',
77
- status: 'inactive',
78
- },
79
- ];
80
-
81
55
  export const Accessibility: Story = {
82
56
  render: (args: ComponentProps<typeof AvatarGroup>) => {
83
57
  return (
84
58
  <AvatarGroup {...args}>
85
- {list.map((props) => (
86
- <Avatar role="button" tabIndex={0} focused key={props.name} size="xxl" {...props} />
87
- ))}
59
+ {Array(5)
60
+ .fill(true)
61
+ .map(() => (
62
+ <Avatar
63
+ role="button"
64
+ tabIndex={0}
65
+ focused
66
+ size="xxl"
67
+ url="https://avatars.githubusercontent.com/u/1813468?v=4"
68
+ />
69
+ ))}
88
70
  </AvatarGroup>
89
71
  );
90
72
  },
@@ -21,7 +21,7 @@ var config = exports.config = {
21
21
  l: /*#__PURE__*/(0, _styledComponents.css)(["", ";", ";", ":1.0625rem;", ":1rem;", ":1.0625rem;", ":1rem;", ":0.75rem;", ":var(--plasma-typo-body-l-font-family);", ":var(--plasma-typo-body-l-font-size);", ":var(--plasma-typo-body-l-font-style);", ":var(--plasma-typo-body-l-font-weight);", ":var(--plasma-typo-body-l-letter-spacing);", ":var(--plasma-typo-body-l-line-height);"], dropdownSizeCommon, dropdownItemSizeCommon, _Dropdown.dropdownTokens.itemPaddingTop, _Dropdown.dropdownTokens.itemPaddingRight, _Dropdown.dropdownTokens.itemPaddingBottom, _Dropdown.dropdownTokens.itemPaddingLeft, _Dropdown.dropdownTokens.itemBorderRadius, _Dropdown.dropdownTokens.itemFontFamily, _Dropdown.dropdownTokens.itemFontSize, _Dropdown.dropdownTokens.itemFontStyle, _Dropdown.dropdownTokens.itemFontWeightBold, _Dropdown.dropdownTokens.itemFontLetterSpacing, _Dropdown.dropdownTokens.itemFontLineHeight)
22
22
  },
23
23
  view: {
24
- "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":0.4;", ":var(--surface-solid-card);", ":var(--shadow-down-soft-s);", ":var(--plasma-colors-transparent);", ":var(--surface-transparent-secondary);", ":inherit;", ":inherit;", ":inherit;", ":inherit;", ":var(--text-primary);"], _Dropdown.dropdownTokens.disabledOpacity, _Dropdown.dropdownTokens.background, _Dropdown.dropdownTokens.boxShadow, _Dropdown.dropdownTokens.itemBackground, _Dropdown.dropdownTokens.itemBackgroundHover, _Dropdown.dropdownTokens.itemBackgroundSelected, _Dropdown.dropdownTokens.itemColorSelected, _Dropdown.dropdownTokens.itemBackgroundSelectedHover, _Dropdown.dropdownTokens.itemColorSelectedHover, _Dropdown.dropdownTokens.itemColor)
24
+ "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":0.4;", ":var(--surface-accent);", ":var(--surface-solid-card);", ":var(--shadow-down-soft-s);", ":var(--plasma-colors-transparent);", ":var(--surface-transparent-secondary);", ":inherit;", ":inherit;", ":inherit;", ":inherit;", ":var(--text-primary);"], _Dropdown.dropdownTokens.disabledOpacity, _Dropdown.dropdownTokens.focusColor, _Dropdown.dropdownTokens.background, _Dropdown.dropdownTokens.boxShadow, _Dropdown.dropdownTokens.itemBackground, _Dropdown.dropdownTokens.itemBackgroundHover, _Dropdown.dropdownTokens.itemBackgroundSelected, _Dropdown.dropdownTokens.itemColorSelected, _Dropdown.dropdownTokens.itemBackgroundSelectedHover, _Dropdown.dropdownTokens.itemColorSelectedHover, _Dropdown.dropdownTokens.itemColor)
25
25
  }
26
26
  }
27
27
  };